• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef QOS_COMMON_H
16 #define QOS_COMMON_H
17 
18 namespace OHOS {
19 namespace QosCommon {
20 
21 constexpr int NR_QOS = 6;
22 constexpr int QOS_NICE_FLAG = 0x01;
23 constexpr int QOS_LATENCY_NICE_FLAG = 0x02;
24 constexpr int QOS_UCLAMP_FLAG = 0x04;
25 constexpr int QOS_RT_FLAG = 0x08;
26 constexpr int QOS_ALL_FLAG = (QOS_NICE_FLAG | QOS_LATENCY_NICE_FLAG | \
27                         QOS_UCLAMP_FLAG | QOS_RT_FLAG);
28 
29 constexpr int AF_RTG_ALL = 0x1fff;
30 constexpr int AF_RTG_DELEGATED = 0x1fff;
31 
32 struct AuthCtrlData {
33     int uid;
34     unsigned int type;
35     unsigned int rtgFlag;
36     unsigned int qosFlag;
37     unsigned int status;
38 };
39 
40 struct QosCtrlData {
41     int pid;
42     unsigned int type;
43     int level;
44 };
45 
46 struct QosPolicyData {
47     int nice;
48     int latencyNice;
49     int uclampMin;
50     int uclampMax;
51     int rtSchedPriority;
52 };
53 
54 struct QosPolicyDatas {
55     int policyType;
56     unsigned int policyFlag;
57     struct QosPolicyData policys[NR_QOS + 1];
58 };
59 
60 enum AuthOperationType {
61     AUTH_ENABLE = 1,
62     AUTH_DELETE,
63     AUTH_GET,
64     AUTH_SWITCH,
65     AUTH_MAX_NR,
66 };
67 
68 enum QosOperationType {
69     QOS_APPLY = 1,
70     QOS_LEAVE,
71     QOS_MAX_NR,
72 };
73 
74 enum QosPolicyType {
75     QOS_POLICY_DEFAULT = 1,
76     QOS_POLICY_SYSTEM_SERVER = 2,
77     QOS_POLICY_FRONT = 3,
78     QOS_POLICY_BACK = 4,
79     QOS_POLICY_MAX_NR,
80 };
81 
82 enum AuthStatus {
83     AUTH_STATUS_DISABLED = 1,
84     AUTH_STATUS_SYSTEM_SERVER = 2,
85     AUTH_STATUS_FOREGROUND,
86     AUTH_STATUS_BACKGROUND,
87     AUTH_STATUS_DEAD,
88 };
89 
90 #define QOS_CTRL_BASIC_OPERATION \
91     _IOWR(0xCC, 1, struct QosCtrlData)
92 #define QOS_CTRL_POLICY_OPERATION \
93     _IOWR(0xCC, 2, struct QosPolicyDatas)
94 #define BASIC_AUTH_CTRL_OPERATION \
95     _IOWR(0xCD, 1, struct AuthCtrlData)
96 
97 int AuthEnable(int uid, unsigned int flag, unsigned int status);
98 int AuthPause(int uid);
99 int AuthDelete(int uid);
100 int QosApplyForThread(int level, int tid);
101 int QosLeaveForThread(int tid);
102 int QosPolicy(struct QosPolicyDatas *policyDatas);
103 
104 } // namespace QosCommon
105 } // namespace OHOS
106 #endif // QOS_COMMON_H