rtw_rm_fsm.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. *****************************************************************************/
  15. #ifndef __RTW_RM_FSM_H_
  16. #define __RTW_RM_FSM_H_
  17. #ifdef CONFIG_RTW_80211K
  18. #define RM_SUPPORT_IWPRIV_DBG 1
  19. #define RM_MORE_DBG_MSG 0
  20. #define DBG_BCN_REQ_DETAIL 0
  21. #define DBG_BCN_REQ_WILDCARD 0
  22. #define DBG_BCN_REQ_SSID 0
  23. #define DBG_BCN_REQ_SSID_NAME "RealKungFu"
  24. #define RM_REQ_TIMEOUT 10000 /* 10 seconds */
  25. #define RM_MEAS_TIMEOUT 10000 /* 10 seconds */
  26. #define RM_REPT_SCAN_INTVL 5000 /* 5 seconds */
  27. #define RM_REPT_POLL_INTVL 2000 /* 2 seconds */
  28. #define RM_COND_INTVL 2000 /* 2 seconds */
  29. #define RM_SCAN_DENY_TIMES 10
  30. #define RM_BUSY_TRAFFIC_TIMES 10
  31. #define RM_WAIT_BUSY_TIMEOUT 1000 /* 1 seconds */
  32. #define MEAS_REQ_MOD_PARALLEL BIT(0)
  33. #define MEAS_REQ_MOD_ENABLE BIT(1)
  34. #define MEAS_REQ_MOD_REQUEST BIT(2)
  35. #define MEAS_REQ_MOD_REPORT BIT(3)
  36. #define MEAS_REQ_MOD_DUR_MAND BIT(4)
  37. #define MEAS_REP_MOD_LATE BIT(0)
  38. #define MEAS_REP_MOD_INCAP BIT(1)
  39. #define MEAS_REP_MOD_REFUSE BIT(2)
  40. #define RM_MASTER BIT(0) /* STA who issue meas_req */
  41. #define RM_SLAVE 0 /* STA who do measurement */
  42. #define CLOCK_UNIT 10 /* ms */
  43. #define RTW_MAX_NB_RPT_IE_NUM 16
  44. #define RM_GET_AID(rmid) ((rmid&0xffff0000)>>16)
  45. #define RM_IS_ID_FOR_ALL(rmid) (rmid&RM_ALL_MEAS)
  46. /*
  47. * define the following channels as the max channels in each channel plan.
  48. * 2G, total 14 chnls
  49. * {1,2,3,4,5,6,7,8,9,10,11,12,13,14}
  50. * 5G, total 25 chnls
  51. * {36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161,165}
  52. */
  53. #define MAX_OP_CHANNEL_SET_NUM 11
  54. typedef struct _RT_OPERATING_CLASS {
  55. int global_op_class;
  56. int Len;
  57. u16 Channel[MAX_OP_CHANNEL_SET_NUM];
  58. } RT_OPERATING_CLASS, *PRT_OPERATING_CLASS;
  59. /* IEEE 802.11-2012 Table 8-59 Measurement Type definitions
  60. * for measurement request
  61. * modify rm_meas_type_req_name() when adding new type
  62. */
  63. enum meas_type_of_req {
  64. basic_req, /* spectrum measurement */
  65. cca_req,
  66. rpi_histo_req,
  67. ch_load_req,
  68. noise_histo_req,
  69. bcn_req,
  70. frame_req,
  71. sta_statis_req,
  72. lci_req,
  73. meas_type_req_max,
  74. };
  75. /* IEEE 802.11-2012 Table 8-81 Measurement Type definitions
  76. * for measurement report
  77. * modify rm_type_rep_name() when adding new type
  78. */
  79. enum meas_type_of_rep {
  80. basic_rep, /* spectrum measurement */
  81. cca_rep,
  82. rpi_histo_rep,
  83. ch_load_rep, /* radio measurement */
  84. noise_histo_rep,
  85. bcn_rep,
  86. frame_rep,
  87. sta_statis_rep, /* Radio measurement and WNM */
  88. lci_rep,
  89. meas_type_rep_max
  90. };
  91. /*
  92. * Beacon request
  93. */
  94. /* IEEE 802.11-2012 Table 8-64 Measurement mode for Beacon Request element */
  95. enum bcn_req_meas_mode {
  96. bcn_req_passive,
  97. bcn_req_active,
  98. bcn_req_bcn_table
  99. };
  100. /* IEEE 802.11-2012 Table 8-65 optional subelement IDs for Beacon Request */
  101. enum bcn_req_opt_sub_id{
  102. bcn_req_ssid = 0, /* len 0-32 */
  103. bcn_req_rep_info = 1, /* len 2 */
  104. bcn_req_rep_detail = 2, /* len 1 */
  105. bcn_req_req = 10, /* len 0-237 */
  106. bcn_req_ac_ch_rep = 51 /* len 1-237 */
  107. };
  108. /* IEEE 802.11-2012 Table 8-66 Reporting condition of Beacon Report */
  109. enum bcn_rep_cound_id{
  110. bcn_rep_cond_immediately, /* default */
  111. bcn_req_cond_rcpi_greater,
  112. bcn_req_cond_rcpi_less,
  113. bcn_req_cond_rsni_greater,
  114. bcn_req_cond_rsni_less,
  115. bcn_req_cond_max
  116. };
  117. struct opt_rep_info {
  118. u8 cond;
  119. u8 threshold;
  120. };
  121. #define BCN_REQ_OPT_MAX_NUM 16
  122. struct bcn_req_opt {
  123. /* all req cmd id */
  124. u8 opt_id[BCN_REQ_OPT_MAX_NUM];
  125. u8 opt_id_num;
  126. u8 rep_detail;
  127. NDIS_802_11_SSID ssid;
  128. /* bcn report condition */
  129. struct opt_rep_info rep_cond;
  130. /* 0:default(Report to be issued after each measurement) */
  131. u8 *req_start; /*id : 10 request;start */
  132. u8 req_len; /*id : 10 request;length */
  133. };
  134. /*
  135. * channel load
  136. */
  137. /* IEEE 802.11-2012 Table 8-60 optional subelement IDs for channel load request */
  138. enum ch_load_opt_sub_id{
  139. ch_load_rsvd,
  140. ch_load_rep_info
  141. };
  142. /* IEEE 802.11-2012 Table 8-61 Reporting condition for channel load Report */
  143. enum ch_load_cound_id{
  144. ch_load_cond_immediately, /* default */
  145. ch_load_cond_anpi_equal_greater,
  146. ch_load_cond_anpi_equal_less,
  147. ch_load_cond_max
  148. };
  149. /*
  150. * Noise histogram
  151. */
  152. /* IEEE 802.11-2012 Table 8-62 optional subelement IDs for noise histogram */
  153. enum noise_histo_opt_sub_id{
  154. noise_histo_rsvd,
  155. noise_histo_rep_info
  156. };
  157. /* IEEE 802.11-2012 Table 8-63 Reporting condition for noise historgarm Report */
  158. enum noise_histo_cound_id{
  159. noise_histo_cond_immediately, /* default */
  160. noise_histo_cond_anpi_equal_greater,
  161. noise_histo_cond_anpi_equal_less,
  162. noise_histo_cond_max
  163. };
  164. struct meas_req_opt {
  165. /* report condition */
  166. struct opt_rep_info rep_cond;
  167. };
  168. /*
  169. * State machine
  170. */
  171. enum RM_STATE {
  172. RM_ST_IDLE,
  173. RM_ST_DO_MEAS,
  174. RM_ST_WAIT_MEAS,
  175. RM_ST_SEND_REPORT,
  176. RM_ST_RECV_REPORT,
  177. RM_ST_END,
  178. RM_ST_MAX
  179. };
  180. struct rm_meas_req {
  181. u8 category;
  182. u8 action_code; /* T8-206 */
  183. u8 diag_token;
  184. u16 rpt;
  185. u8 e_id;
  186. u8 len;
  187. u8 m_token;
  188. u8 m_mode; /* req:F8-105, rep:F8-141 */
  189. u8 m_type; /* T8-59 */
  190. u8 op_class;
  191. u8 ch_num;
  192. u16 rand_intvl; /* units of TU */
  193. u16 meas_dur; /* units of TU */
  194. u8 bssid[6]; /* for bcn_req */
  195. u8 *pssid;
  196. u8 *opt_s_elem_start;
  197. int opt_s_elem_len;
  198. union {
  199. struct bcn_req_opt bcn;
  200. struct meas_req_opt clm;
  201. struct meas_req_opt nhm;
  202. }opt;
  203. struct rtw_ieee80211_channel ch_set[MAX_OP_CHANNEL_SET_NUM];
  204. u8 ch_set_ch_amount;
  205. };
  206. struct rm_meas_rep {
  207. u8 category;
  208. u8 action_code; /* T8-206 */
  209. u8 diag_token;
  210. u8 e_id; /* T8-54, 38 request; 39 report */
  211. u8 len;
  212. u8 m_token;
  213. u8 m_mode; /* req:F8-105, rep:F8-141 */
  214. u8 m_type; /* T8-59 */
  215. u8 op_class;
  216. u8 ch_num;
  217. u8 ch_load;
  218. u8 anpi;
  219. u8 ipi[11];
  220. u16 rpt;
  221. u8 bssid[6]; /* for bcn_req */
  222. };
  223. #define MAX_BUF_NUM 128
  224. struct data_buf {
  225. u8 *pbuf;
  226. u16 len;
  227. };
  228. struct rm_obj {
  229. /* aid << 16
  230. |diag_token << 8
  231. |B(1) 1/0:All_AID/UNIC
  232. |B(0) 1/0:RM_MASTER/RM_SLAVE */
  233. u32 rmid;
  234. enum RM_STATE state;
  235. struct rm_meas_req q;
  236. struct rm_meas_rep p;
  237. struct sta_info *psta;
  238. struct rm_clock *pclock;
  239. /* meas report */
  240. u64 meas_start_time;
  241. u64 meas_end_time;
  242. int wait_busy;
  243. u8 poll_mode;
  244. struct data_buf buf[MAX_BUF_NUM];
  245. _list list;
  246. };
  247. /*
  248. * Measurement
  249. */
  250. struct opt_subelement {
  251. u8 id;
  252. u8 length;
  253. u8 *data;
  254. };
  255. /* 802.11-2012 Table 8-206 Radio Measurment Action field */
  256. enum rm_action_code {
  257. RM_ACT_RADIO_MEAS_REQ,
  258. RM_ACT_RADIO_MEAS_REP,
  259. RM_ACT_LINK_MEAS_REQ,
  260. RM_ACT_LINK_MEAS_REP,
  261. RM_ACT_NB_REP_REQ, /* 4 */
  262. RM_ACT_NB_REP_RESP,
  263. RM_ACT_RESV,
  264. RM_ACT_MAX
  265. };
  266. /* 802.11-2012 Table 8-119 RM Enabled Capabilities definition */
  267. enum rm_cap_en {
  268. RM_LINK_MEAS_CAP_EN,
  269. RM_NB_REP_CAP_EN, /* neighbor report */
  270. RM_PARAL_MEAS_CAP_EN, /* parallel report */
  271. RM_REPEAT_MEAS_CAP_EN,
  272. RM_BCN_PASSIVE_MEAS_CAP_EN,
  273. RM_BCN_ACTIVE_MEAS_CAP_EN,
  274. RM_BCN_TABLE_MEAS_CAP_EN,
  275. RM_BCN_MEAS_REP_COND_CAP_EN, /* conditions */
  276. RM_FRAME_MEAS_CAP_EN,
  277. RM_CH_LOAD_CAP_EN,
  278. RM_NOISE_HISTO_CAP_EN, /* noise historgram */
  279. RM_STATIS_MEAS_CAP_EN, /* statistics */
  280. RM_LCI_MEAS_CAP_EN, /* 12 */
  281. RM_LCI_AMIMUTH_CAP_EN,
  282. RM_TRANS_STREAM_CAT_MEAS_CAP_EN,
  283. RM_TRIG_TRANS_STREAM_CAT_MEAS_CAP_EN,
  284. RM_AP_CH_REP_CAP_EN,
  285. RM_RM_MIB_CAP_EN,
  286. RM_OP_CH_MAX_MEAS_DUR0, /* 18-20 */
  287. RM_OP_CH_MAX_MEAS_DUR1,
  288. RM_OP_CH_MAX_MEAS_DUR2,
  289. RM_NONOP_CH_MAX_MEAS_DUR0, /* 21-23 */
  290. RM_NONOP_CH_MAX_MEAS_DUR1,
  291. RM_NONOP_CH_MAX_MEAS_DUR2,
  292. RM_MEAS_PILOT_CAP0, /* 24-26 */
  293. RM_MEAS_PILOT_CAP1,
  294. RM_MEAS_PILOT_CAP2,
  295. RM_MEAS_PILOT_TRANS_INFO_CAP_EN,
  296. RM_NB_REP_TSF_OFFSET_CAP_EN,
  297. RM_RCPI_MEAS_CAP_EN, /* 29 */
  298. RM_RSNI_MEAS_CAP_EN,
  299. RM_BSS_AVG_ACCESS_DELAY_CAP_EN,
  300. RM_AVALB_ADMIS_CAPACITY_CAP_EN,
  301. RM_ANT_CAP_EN,
  302. RM_RSVD, /* 34-39 */
  303. RM_MAX
  304. };
  305. char *rm_state_name(enum RM_STATE state);
  306. char *rm_event_name(enum RM_EV_ID evid);
  307. char *rm_type_req_name(u8 meas_type);
  308. int _rm_post_event(_adapter *padapter, u32 rmid, enum RM_EV_ID evid);
  309. int rm_enqueue_rmobj(_adapter *padapter, struct rm_obj *obj, bool to_head);
  310. void rm_free_rmobj(struct rm_obj *prm);
  311. struct rm_obj *rm_alloc_rmobj(_adapter *padapter);
  312. struct rm_obj *rm_get_rmobj(_adapter *padapter, u32 rmid);
  313. struct sta_info *rm_get_psta(_adapter *padapter, u32 rmid);
  314. int retrieve_radio_meas_result(struct rm_obj *prm);
  315. int rm_radio_meas_report_cond(struct rm_obj *prm);
  316. int rm_recv_radio_mens_req(_adapter *padapter,
  317. union recv_frame *precv_frame,struct sta_info *psta);
  318. int rm_recv_radio_mens_rep(_adapter *padapter,
  319. union recv_frame *precv_frame, struct sta_info *psta);
  320. int rm_radio_mens_nb_rep(_adapter *padapter,
  321. union recv_frame *precv_frame, struct sta_info *psta);
  322. int issue_null_reply(struct rm_obj *prm);
  323. int issue_beacon_rep(struct rm_obj *prm);
  324. int issue_nb_req(struct rm_obj *prm);
  325. int issue_radio_meas_req(struct rm_obj *prm);
  326. int issue_radio_meas_rep(struct rm_obj *prm);
  327. void rm_set_rep_mode(struct rm_obj *prm, u8 mode);
  328. int ready_for_scan(struct rm_obj *prm);
  329. int rm_sitesurvey(struct rm_obj *prm);
  330. #endif /*CONFIG_RTW_80211K*/
  331. #endif /*__RTW_RM_FSM_H_*/