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 /* DFX */ 44 typedef struct _RamInfo { 45 uint32_t availableRam; 46 uint32_t totalRam; 47 } RamInfo; 48 49 typedef enum { 50 ROOT_QUEUE = -1, /* ROOT queueu */ 51 HI_QUEUE = 1, /* QDISC queue 1 WLAN_HI_QUEUE = 0 */ 52 NORMAL_QUEUE, /* QDISC queue 2 WLAN_NORMAL_QUEUE */ 53 TCP_DATA_QUEUE, /* QDISC queue 3 WLAN_TCP_DATA_QUEUE */ 54 TCP_ACK_QUEUE, /* QDISC queue 4 WLAN_TCP_ACK_QUEUE */ 55 UDP_BK_QUEUE, /* QDISC queue 5 WLAN_UDP_BK_QUEUE */ 56 UDP_BE_QUEUE, /* QDISC queue 6 WLAN_UDP_BE_QUEUE */ 57 UDP_VI_QUEUE, /* QDISC queue 7 WLAN_UDP_VI_QUEUE */ 58 UDP_VO_QUEUE, /* QDISC queue 8 WLAN_UDP_VO_QUEUE */ 59 MAX_QUEUE, 60 } QDISC_PROTOCOL_TYPE; 61 62 NSTACKX_EXPORT WifiStationInfo GetGTxWifiStationInfo(uint8_t socketIndex); 63 NSTACKX_EXPORT int32_t CheckWlanNegoRateValid(uint32_t rate); 64 65 /* for JNI */ 66 typedef int32_t (*GetWifiInfoHook)(const char *devName, WifiStationInfo *wifiStationInfo); 67 NSTACKX_EXPORT int32_t CongestionInitGetWifiHook(GetWifiInfoHook getWifiInfoFromCb); 68 69 /* for qdisc */ 70 NSTACKX_EXPORT int32_t GetQdiscLen(const char *devName, int32_t protocol, uint32_t *len); 71 72 /* for wifi */ 73 NSTACKX_EXPORT int32_t GetServerWifiStationInfo(const char *devName, WifiStationInfo *wifiStationInfo); 74 NSTACKX_EXPORT int32_t UpdateWifiStationInfo(const char *devName, WifiStationInfo *txWifiStationInfo, 75 uint8_t socketIndex, int *changeStatus); 76 NSTACKX_EXPORT int32_t GetConngestSendRate(WifiStationInfo *rxWifiStationInfo, uint16_t connType, uint32_t mtu, 77 uint8_t socketIndex, uint16_t *sendRateResult); 78 NSTACKX_EXPORT int32_t GetWifiInfoDMsg(const char *devName, WifiStationInfo *wifiStationInfo); 79 NSTACKX_EXPORT int32_t GetConngestSendRateDMsg(const char *devName, uint32_t speedTX, uint32_t speedRX, 80 uint32_t *sendRateResult, uint32_t mtu); 81 82 /* init and clean */ 83 NSTACKX_EXPORT int32_t CongModuleInit(void); 84 NSTACKX_EXPORT void CongModuleClean(void); 85 86 #ifdef __cplusplus 87 } 88 #endif 89 90 #endif 91