1 /* 2 * Copyright (c) 2022 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 16 #ifndef QOS_INTERFACE_H 17 #define QOS_INTERFACE_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /* 24 * generic 25 */ 26 #define SYSTEM_UID 1000 27 #define ROOT_UID 0 28 29 /* 30 * auth_ctrl 31 */ 32 struct AuthCtrlData { 33 unsigned int uid; 34 unsigned int type; 35 unsigned int rtgUaFlag; 36 unsigned int qosUaFlag; 37 unsigned int status; 38 }; 39 40 enum class AuthManipulateType { 41 AUTH_ENABLE = 1, 42 AUTH_DELETE, 43 AUTH_GET, 44 AUTH_SWITCH, 45 AUTH_MAX_NR, 46 }; 47 48 enum class AuthStatus { 49 AUTH_STATUS_DISABLED = 1, 50 AUTH_STATUS_SYSTEM_SERVER = 2, 51 AUTH_STATUS_FOREGROUND = 3, 52 AUTH_STATUS_BACKGROUND = 4, 53 AUTH_STATUS_DEAD, 54 }; 55 56 enum class QosClassLevel { 57 QOS_UNSPECIFIED = 0, 58 QOS_BACKGROUND = 1, 59 QOS_UTILITY = 2, 60 QOS_DEFAULT = 3, 61 QOS_USER_INITIATED = 4, 62 QOS_DEADLINE_REQUEST = 5, 63 QOS_USER_INTERACTIVE = 6, 64 QOS_MAX, 65 }; 66 67 #define BASIC_AUTH_CTRL_OPERATION \ 68 _IOWR(0xCD, 1, struct AuthCtrlData) 69 70 /* 71 * qos ctrl 72 */ 73 enum class QosManipulateType { 74 QOS_APPLY = 1, 75 QOS_LEAVE, 76 QOS_MAX_NR, 77 }; 78 79 struct QosCtrlData { 80 int pid; 81 unsigned int type; 82 unsigned int level; 83 }; 84 85 struct QosPolicyData { 86 int nice; 87 int latencyNice; 88 int uclampMin; 89 int uclampMax; 90 int rtSchedPriority; 91 }; 92 93 enum class QosPolicyType { 94 QOS_POLICY_DEFAULT = 1, 95 QOS_POLICY_SYSTEM_SERVER = 2, 96 QOS_POLICY_FRONT = 3, 97 QOS_POLICY_BACK = 4, 98 QOS_POLICY_MAX_NR, 99 }; 100 101 #define QOS_FLAG_NICE 0X01 102 #define QOS_FLAG_LATENCY_NICE 0X02 103 #define QOS_FLAG_UCLAMP 0x04 104 #define QOS_FLAG_RT 0x08 105 106 #define QOS_FLAG_ALL (QOS_FLAG_NICE | \ 107 QOS_FLAG_LATENCY_NICE | \ 108 QOS_FLAG_UCLAMP | \ 109 QOS_FLAG_RT) 110 111 struct QosPolicyDatas { 112 int policyType; 113 unsigned int policyFlag; 114 struct QosPolicyData policys[static_cast<int>(QosClassLevel::QOS_MAX)]; 115 }; 116 117 #define QOS_CTRL_BASIC_OPERATION \ 118 _IOWR(0xCC, 1, struct QosCtrlData) 119 #define QOS_CTRL_POLICY_OPERATION \ 120 _IOWR(0xCC, 2, struct QosPolicyDatas) 121 122 /* 123 * RTG 124 */ 125 #define AF_RTG_ALL 0x1fff 126 #define AF_RTG_DELEGATED 0x1fff 127 128 struct RtgEnableData { 129 int enable; 130 int len; 131 char *data; 132 }; 133 134 #define CMD_ID_SET_ENABLE \ 135 _IOWR(0xAB, 1, struct RtgEnableData) 136 137 /* 138 * interface 139 */ 140 int EnableRtg(bool flag); 141 int AuthEnable(unsigned int uid, unsigned int uaFlag, unsigned int status); 142 int AuthPause(unsigned int uid); 143 int AuthDelete(unsigned int uid); 144 int AuthGet(unsigned int uid, unsigned int *uaFlag, unsigned int *status); 145 int AuthSwitch(unsigned int uid, unsigned int rtgFlag, unsigned int qosFlag, unsigned int status); 146 int QosApply(unsigned int level); 147 int QosApplyForOther(unsigned int level, int tid); 148 int QosLeave(void); 149 int QosLeaveForOther(int tid); 150 int QosPolicy(struct QosPolicyDatas *policyDatas); 151 152 #ifdef __cplusplus 153 } 154 #endif 155 #endif /* OQS_INTERFACE_H */