1 /* 2 * Copyright (C) 2021 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 NSTACKX_CONGESTION_H 17 #define NSTACKX_CONGESTION_H 18 19 #include "nstackx_common_header.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define MIN_MTU 64 26 #define MAX_MTU 65536 27 #define BITINBYTE 8 28 29 #define MAX_WIFI_NEGO_RATE 2500 30 31 typedef struct _WifiRateInfo { 32 uint32_t rateBitrate; 33 uint32_t rateWidth; 34 } WifiRateInfo; 35 36 typedef struct _WifiStationInfo { 37 uint32_t txRate; 38 uint32_t rxRate; 39 int32_t signal; 40 uint32_t freq; 41 } WifiStationInfo; 42 43 typedef enum { 44 ROOT_QUEUE = -1, /* ROOT queueu */ 45 HI_QUEUE = 1, /* QDISC queue 1 WLAN_HI_QUEUE = 0 */ 46 NORMAL_QUEUE, /* QDISC queue 2 WLAN_NORMAL_QUEUE */ 47 TCP_DATA_QUEUE, /* QDISC queue 3 WLAN_TCP_DATA_QUEUE */ 48 TCP_ACK_QUEUE, /* QDISC queue 4 WLAN_TCP_ACK_QUEUE */ 49 UDP_BK_QUEUE, /* QDISC queue 5 WLAN_UDP_BK_QUEUE */ 50 UDP_BE_QUEUE, /* QDISC queue 6 WLAN_UDP_BE_QUEUE */ 51 UDP_VI_QUEUE, /* QDISC queue 7 WLAN_UDP_VI_QUEUE */ 52 UDP_VO_QUEUE, /* QDISC queue 8 WLAN_UDP_VO_QUEUE */ 53 MAX_QUEUE, 54 } QDISC_PROTOCOL_TYPE; 55 56 NSTACKX_EXPORT WifiStationInfo GetGTxWifiStationInfo(uint8_t socketIndex); 57 NSTACKX_EXPORT int32_t CheckWlanNegoRateValid(uint32_t rate); 58 59 /* for JNI */ 60 typedef int32_t (*GetWifiInfoHook)(const char *devName, WifiStationInfo *wifiStationInfo); 61 NSTACKX_EXPORT int32_t CongestionInitGetWifiHook(GetWifiInfoHook getWifiInfoFromCb); 62 63 /* for qdisc */ 64 NSTACKX_EXPORT int32_t GetQdiscLen(const char *devName, int32_t protocol, uint32_t *len); 65 66 /* for wifi */ 67 NSTACKX_EXPORT int32_t GetServerWifiStationInfo(const char *devName, WifiStationInfo *wifiStationInfo); 68 NSTACKX_EXPORT int32_t UpdateWifiStationInfo(const char *devName, WifiStationInfo *txWifiStationInfo, 69 uint8_t socketIndex, int *changeStatus); 70 NSTACKX_EXPORT int32_t GetConngestSendRate(WifiStationInfo *rxWifiStationInfo, uint16_t connType, uint32_t mtu, 71 uint8_t socketIndex, uint16_t *sendRateResult); 72 NSTACKX_EXPORT int32_t GetWifiInfoDMsg(const char *devName, WifiStationInfo *wifiStationInfo); 73 NSTACKX_EXPORT int32_t GetConngestSendRateDMsg(const char *devName, uint32_t speedTX, uint32_t speedRX, 74 uint32_t *sendRateResult, uint32_t mtu); 75 76 /* init and clean */ 77 NSTACKX_EXPORT int32_t CongModuleInit(void); 78 NSTACKX_EXPORT void CongModuleClean(void); 79 80 #ifdef __cplusplus 81 } 82 #endif 83 84 #endif 85