stats.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /*
  2. ** Id: stats.h#1
  3. */
  4. /*! \file stats.h
  5. \brief This file includes statistics support.
  6. */
  7. /*
  8. ** Log: stats.h
  9. *
  10. * 07 17 2014 samp.lin
  11. * NULL
  12. * Initial version.
  13. */
  14. /*******************************************************************************
  15. * C O M P I L E R F L A G S
  16. ********************************************************************************
  17. */
  18. /*******************************************************************************
  19. * E X T E R N A L R E F E R E N C E S
  20. ********************************************************************************
  21. */
  22. extern UINT_64 u8DrvOwnStart, u8DrvOwnEnd;
  23. extern UINT32 u4DrvOwnMax;
  24. extern BOOLEAN fgIsUnderSuspend;
  25. /*******************************************************************************
  26. * C O N S T A N T S
  27. ********************************************************************************
  28. */
  29. /* Command to TDLS core module */
  30. typedef enum _STATS_CMD_CORE_ID {
  31. STATS_CORE_CMD_ENV_REQUEST = 0x00
  32. } STATS_CMD_CORE_ID;
  33. typedef enum _STATS_EVENT_HOST_ID {
  34. STATS_HOST_EVENT_ENV_REPORT = 0x00,
  35. STATS_HOST_EVENT_RX_DROP
  36. } STATS_EVENT_HOST_ID;
  37. #define CFG_ARP BIT(0)
  38. #define CFG_DNS BIT(1)
  39. #define CFG_TCP BIT(2)
  40. #define CFG_UDP BIT(3)
  41. #define CFG_EAPOL BIT(4)
  42. #define CFG_DHCP BIT(5)
  43. #define CFG_ICMP BIT(6)
  44. /*******************************************************************************
  45. * D A T A T Y P E S
  46. ********************************************************************************
  47. */
  48. typedef struct _STATS_CMD_CORE_T {
  49. UINT32 u4Command; /* STATS_CMD_CORE_ID */
  50. UINT8 ucStaRecIdx;
  51. UINT8 ucReserved[3];
  52. UINT32 u4Reserved[4];
  53. #define STATS_CMD_CORE_RESERVED_SIZE 50
  54. union {
  55. UINT8 Reserved[STATS_CMD_CORE_RESERVED_SIZE];
  56. } Content;
  57. } STATS_CMD_CORE_T;
  58. typedef struct _STATS_INFO_ENV_T {
  59. BOOLEAN fgIsUsed; /* TRUE: used */
  60. /* ------------------- TX ------------------- */
  61. BOOLEAN fgTxIsRtsUsed; /* TRUE: we use RTS/CTS currently */
  62. BOOLEAN fgTxIsRtsEverUsed; /* TRUE: we ever use RTS/CTS */
  63. BOOLEAN fgTxIsCtsSelfUsed; /* TRUE: we use CTS-self */
  64. #define STATS_INFO_TX_PARAM_HW_BW40_OFFSET 0
  65. #define STATS_INFO_TX_PARAM_HW_SHORT_GI20_OFFSET 1
  66. #define STATS_INFO_TX_PARAM_HW_SHORT_GI40_OFFSET 2
  67. #define STATS_INFO_TX_PARAM_USE_BW40_OFFSET 3
  68. #define STATS_INFO_TX_PARAM_USE_SHORT_GI_OFFSET 4
  69. #define STATS_INFO_TX_PARAM_NO_ACK_OFFSET 5
  70. UINT_8 ucTxParam;
  71. UINT_8 ucStaRecIdx;
  72. UINT_8 ucReserved1[2];
  73. UINT32 u4TxDataCntAll; /* total tx count from host */
  74. UINT32 u4TxDataCntOK; /* total tx ok count to air */
  75. UINT32 u4TxDataCntErr; /* total tx err count to air */
  76. /* WLAN_STATUS_BUFFER_RETAINED ~ WLAN_STATUS_PACKET_LIFETIME_ERROR */
  77. UINT32 u4TxDataCntErrType[6]; /* total tx err count for different type to air */
  78. UINT_8 ucTxRate1NonHTMax;
  79. UINT_8 ucTxRate1HTMax;
  80. UINT32 u4TxRateCntNonHT[16]; /* tx done rate */
  81. UINT32 u4TxRateCntHT[16]; /* tx done rate */
  82. UINT_8 ucTxAggBitmap; /* TX BA sessions TID0 ~ TID7 */
  83. UINT_8 ucTxPeerAggMaxSize;
  84. /* ------------------- RX ------------------- */
  85. BOOLEAN fgRxIsRtsUsed; /* TRUE: peer uses RTS/CTS currently */
  86. BOOLEAN fgRxIsRtsEverUsed; /* TRUE: peer ever uses RTS/CTS */
  87. UINT_8 ucRcvRcpi;
  88. UINT_8 ucHwChanNum;
  89. BOOLEAN fgRxIsShortGI;
  90. UINT_8 ucReserved2[1];
  91. UINT32 u4RxDataCntAll; /* total rx count from peer */
  92. UINT32 u4RxDataCntErr; /* total rx err count */
  93. UINT32 u4RxRateCnt[3][16]; /* [0]:CCK, [1]:OFDM, [2]:MIXED (skip green mode) */
  94. UINT_8 ucRxAggBitmap; /* RX BA sessions TID0 ~ TID7 */
  95. UINT_8 ucRxAggMaxSize;
  96. #define STATS_INFO_PHY_MODE_CCK 0
  97. #define STATS_INFO_PHY_MODE_OFDM 1
  98. #define STATS_INFO_PHY_MODE_HT 2
  99. #define STATS_INFO_PHY_MODE_VHT 3
  100. UINT_8 ucBssSupPhyMode; /* CCK, OFDM, HT, or VHT BSS */
  101. UINT_8 ucVersion; /* the version of statistics info environment */
  102. /* ------------------- Delay ------------------- */
  103. #define STATS_AIR_DELAY_INT 500 /* 500 byte */
  104. /* delay in firmware from host to MAC */
  105. /* unit: us, for 500B, 1000B, max */
  106. UINT32 u4StayIntMaxH2M[3], u4StayIntMinH2M[3], u4StayIntAvgH2M[3];
  107. /* delay in firmware from MAC to TX done */
  108. /* unit: 32us, for 500B, 1000B, max */
  109. UINT32 u4AirDelayMax[3], u4AirDelayMin[3], u4AirDelayAvg[3];
  110. /* delay in firmware from host to TX done */
  111. /* unit: us, for 500B, 1000B, max */
  112. UINT32 u4StayIntMax[3], u4StayIntMin[3], u4StayIntAvg[3];
  113. UINT32 u4StayIntMaxSysTime[3];
  114. /* delay in firmware from driver to TX done */
  115. /* unit: us, for 500B, 1000B, max */
  116. UINT32 u4StayIntMaxD2T[3], u4StayIntMinD2T[3], u4StayIntAvgD2T[3];
  117. /* delay count in firmware from host to TX done */
  118. /* u4StayIntByConst: divide 4 fix partitions to count each delay in firmware */
  119. #define STATS_STAY_INT_CONST 1 /* 1ms */
  120. #define STATS_STAY_INT_CONST_2 5
  121. #define STATS_STAY_INT_CONST_3 10
  122. #define STATS_STAY_INT_CONST_4 15
  123. #define STATS_STAY_INT_CONST_NUM 4
  124. UINT32 u4StayIntByConst[STATS_STAY_INT_CONST_NUM];
  125. /*
  126. u4StayIntMaxPast: past maximum delay in firmware
  127. u4StayIntCnt[]: divide 4 partitions to count each delay in firmware
  128. */
  129. #define STATS_STAY_INT_NUM 4
  130. UINT32 u4StayIntMaxPast;
  131. UINT32 u4StayIntCnt[STATS_STAY_INT_NUM + 1];
  132. /* delay count in firmware from driver to HIF */
  133. /* u4StayIntD2HByConst: divide 4 fix partitions to count each delay in firmware */
  134. #define STATS_STAY_INT_D2H_CONST 10 /* 10ms */
  135. #define STATS_STAY_INT_D2H_CONST_2 20
  136. #define STATS_STAY_INT_D2H_CONST_3 30
  137. #define STATS_STAY_INT_D2H_CONST_4 40
  138. #define STATS_STAY_INT_D2H_CONST_NUM 4
  139. UINT32 u4StayIntD2HByConst[STATS_STAY_INT_D2H_CONST_NUM];
  140. /* unit: us, for 500B, 1000B, max */
  141. UINT32 u4StayIntMaxRx[3], u4StayIntMinRx[3], u4StayIntAvgRx[3];
  142. /* ------------------- Others ------------------- */
  143. UINT32 u4NumOfChanChange; /* total channel change count */
  144. UINT32 u4NumOfRetryCnt; /* total TX retry count */
  145. UINT32 u4RxFifoFullCnt; /* counter of the number of the packets which
  146. pass RFCR but are dropped due to FIFO full. */
  147. UINT32 u4PsIntMax; /* maximum time from ps to active */
  148. UINT_8 ucNumOfPsChange; /* peer power save change count */
  149. UINT_8 ucReserved3[3];
  150. UINT32 u4ReportSysTime; /* firmware system time */
  151. UINT32 u4RxDataCntOk; /* total rx count to hif */
  152. /* V4 */
  153. UINT32 u4RxRateRetryCnt[3][16]; /* [0]:CCK, [1]:OFDM, [2]:MIXED (skip green mode) */
  154. UINT32 au4ChanIdleCnt[10]; /* past Channel idle count in unit of slot */
  155. /* V5 */
  156. UINT32 u4BtContUseTime; /* the air time that BT continuous occypy */
  157. /* V6 */
  158. UINT32 u4LastTxOkTime; /* last time we tx ok to the station */
  159. /* V7 */
  160. UINT_8 ucBtWfCoexGrantCnt[8]; /* [0]:WF Rx Grant Cnt[1]: WF Tx Grant Cnt[2]: WF Grant with Priority1 */
  161. /* [4]:BT Rx Grant Cnt[5]: BT Tx Grant Cnt[6]: BT Grant with Priority1 */
  162. /* V8 */
  163. UINT_32 u4RxMacFreeDescCnt[6];
  164. UINT_32 u4RxHifFreeDescCnt[6];
  165. /* V9 */
  166. #define STATS_MAX_RX_DROP_TYPE 20
  167. UINT32 u4NumOfRxDrop[STATS_MAX_RX_DROP_TYPE];
  168. /* V10 */
  169. UINT_32 u4NumOfTxDone; /* number of all packets (data/man/ctrl) tx done */
  170. UINT_32 u4NumOfTxDoneFixRate; /* number of done rate = 0 */
  171. UINT_32 u4NumOfTxDoneErrRate; /* number of error done rate */
  172. UINT_32 u4NumOfNullTxDone; /* number of null tx done */
  173. UINT_32 u4NumOfQoSNullTxDone; /* number of QoS-null tx done */
  174. /* V11 */
  175. /* delay in firmware from HIF RX to HIF RX Done */
  176. /* unit: us, for 500B, 1000B, max */
  177. UINT32 u4StayIntMaxHR2HRD[3], u4StayIntMinHR2HRD[3], u4StayIntAvgHR2HRD[3];
  178. /* V12 */
  179. UINT32 u4AirDelayTotal; /* agg all the air delay */
  180. /* V13 */
  181. UINT32 u4CurrChnlInfo; /* add current channel information */
  182. UINT_8 ucReserved_rate[4]; /* the field must be the last one */
  183. } STATS_INFO_ENV_T;
  184. /*******************************************************************************
  185. * M A C R O D E C L A R A T I O N S
  186. ********************************************************************************
  187. */
  188. #if (CFG_SUPPORT_STATISTICS == 1)
  189. #define STATS_ENV_REPORT_DETECT statsEnvReportDetect
  190. #define STATS_RX_REORDER_FALL_AHEAD_INC(__StaRec__) \
  191. { \
  192. (__StaRec__)->u4RxReorderFallAheadCnt++; \
  193. }
  194. #define STATS_RX_REORDER_FALL_BEHIND_INC(__StaRec__) \
  195. { \
  196. (__StaRec__)->u4RxReorderFallBehindCnt++; \
  197. }
  198. #define STATS_RX_REORDER_HOLE_INC(__StaRec__) \
  199. { \
  200. (__StaRec__)->u4RxReorderHoleCnt++; \
  201. }
  202. #define STATS_RX_REORDER_HOLE_TIMEOUT_INC(__StaRec__, __IsTimeout__) \
  203. { \
  204. if ((__IsTimeout__) == TRUE) \
  205. (__StaRec__)->u4RxReorderHoleTimeoutCnt++; \
  206. }
  207. #define STATS_RX_ARRIVE_TIME_RECORD(__SwRfb__) \
  208. { \
  209. (__SwRfb__)->rRxTime = StatsEnvTimeGet(); \
  210. }
  211. #define STATS_RX_PASS2OS_INC StatsEnvRxDone
  212. #define STATS_RX_PKT_INFO_DISPLAY StatsRxPktInfoDisplay
  213. #define STATS_TX_TIME_ARRIVE(__Skb__) \
  214. do { \
  215. UINT_64 __SysTime; \
  216. __SysTime = StatsEnvTimeGet(); /* us */ \
  217. GLUE_SET_PKT_XTIME(__Skb__, __SysTime); \
  218. } while (FALSE)
  219. #define STATS_TX_TIME_TO_HIF StatsEnvTxTime2Hif
  220. #define STATS_TX_PKT_CALLBACK StatsTxPktCallBack
  221. #define STATS_TX_PKT_DONE_INFO_DISPLAY StatsTxPktDoneInfoDisplay
  222. #define STATS_DRIVER_OWN_RESET() \
  223. { \
  224. u4DrvOwnMax = 0; \
  225. }
  226. #define STATS_DRIVER_OWN_START_RECORD() \
  227. { \
  228. u8DrvOwnStart = StatsEnvTimeGet(); \
  229. }
  230. #define STATS_DRIVER_OWN_END_RECORD() \
  231. { \
  232. u8DrvOwnEnd = StatsEnvTimeGet(); \
  233. }
  234. #define STATS_DRIVER_OWN_STOP() \
  235. do { \
  236. UINT32 __Diff; \
  237. __Diff = (UINT32)(u8DrvOwnEnd - u8DrvOwnStart); \
  238. if (__Diff > u4DrvOwnMax) \
  239. u4DrvOwnMax = __Diff; \
  240. } while (FALSE)
  241. #else
  242. #define STATS_ENV_REPORT_DETECT(__Adapter__, __StaRecIndex__)
  243. #define STATS_RX_REORDER_FALL_AHEAD_INC(__StaRec__)
  244. #define STATS_RX_REORDER_FALL_BEHIND_INC(__StaRec__)
  245. #define STATS_RX_REORDER_HOLE_INC(__StaRec__)
  246. #define STATS_RX_REORDER_HOLE_TIMEOUT_INC(__StaRec__, __IsTimeout__)
  247. #define STATS_RX_PASS2OS_INC(__StaRec__, __SwRfb__)
  248. #define STATS_RX_PKT_INFO_DISPLAY(__Pkt__)
  249. #define STATS_TX_TIME_ARRIVE(__Skb__)
  250. #define STATS_TX_TIME_TO_HIF(__MsduInfo__, __HwTxHeader__)
  251. #define STATS_TX_PKT_CALLBACK(__Pkt__, __fgIsNeedAck__)
  252. #define STATS_TX_PKT_DONE_INFO_DISPLAY(__Adapter__, __Event__)
  253. #define STATS_DRIVER_OWN_RESET()
  254. #define STATS_DRIVER_OWN_START_RECORD()
  255. #define STATS_DRIVER_OWN_END_RECORD()
  256. #define STATS_DRIVER_OWN_STOP()
  257. #endif /* CFG_SUPPORT_STATISTICS */
  258. /*******************************************************************************
  259. * F U N C T I O N D E C L A R A T I O N S
  260. ********************************************************************************
  261. */
  262. /*******************************************************************************
  263. * P R I V A T E D A T A
  264. ********************************************************************************
  265. */
  266. /*******************************************************************************
  267. * P R I V A T E F U N C T I O N S
  268. ********************************************************************************
  269. */
  270. /*******************************************************************************
  271. * P U B L I C F U N C T I O N S
  272. ********************************************************************************
  273. */
  274. VOID statsEnvReportDetect(ADAPTER_T *prAdapter, UINT8 ucStaRecIndex);
  275. VOID StatsEnvRxDone(STA_RECORD_T *prStaRec, SW_RFB_T *prSwRfb);
  276. UINT_64 StatsEnvTimeGet(VOID);
  277. VOID StatsEnvTxTime2Hif(MSDU_INFO_T *prMsduInfo, HIF_TX_HEADER_T *prHwTxHeader);
  278. VOID statsEventHandle(GLUE_INFO_T *prGlueInfo, UINT8 *prInBuf, UINT32 u4InBufLen);
  279. VOID StatsRxPktInfoDisplay(UINT_8 *pPkt);
  280. VOID StatsTxPktCallBack(UINT_8 *pPkt, P_MSDU_INFO_T prMsduInfo);
  281. VOID StatsTxPktDoneInfoDisplay(ADAPTER_T *prAdapter, UINT_8 *pucEvtBuf);
  282. VOID StatsSetCfgTxDone(UINT_16 u2Cfg, BOOLEAN fgSet);
  283. UINT_16 StatsGetCfgTxDone(VOID);
  284. /* End of stats.h */