rtw_mesh.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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_MESH_H_
  16. #define __RTW_MESH_H_
  17. #ifndef CONFIG_AP_MODE
  18. #error "CONFIG_RTW_MESH can't be enabled when CONFIG_AP_MODE is not defined\n"
  19. #endif
  20. #define RTW_MESH_TTL 31
  21. #define RTW_MESH_PERR_MIN_INT 100
  22. #define RTW_MESH_DEFAULT_ELEMENT_TTL 31
  23. #define RTW_MESH_RANN_INTERVAL 5000
  24. #define RTW_MESH_PATH_TO_ROOT_TIMEOUT 6000
  25. #define RTW_MESH_DIAM_TRAVERSAL_TIME 50
  26. #define RTW_MESH_PATH_TIMEOUT 5000
  27. #define RTW_MESH_PREQ_MIN_INT 10
  28. #define RTW_MESH_MAX_PREQ_RETRIES 4
  29. #define RTW_MESH_MIN_DISCOVERY_TIMEOUT (2 * RTW_MESH_DIAM_TRAVERSAL_TIME)
  30. #define RTW_MESH_ROOT_CONFIRMATION_INTERVAL 2000
  31. #define RTW_MESH_PATH_REFRESH_TIME 1000
  32. #define RTW_MESH_ROOT_INTERVAL 5000
  33. #define RTW_MESH_SANE_METRIC_DELTA 100
  34. #define RTW_MESH_MAX_ROOT_ADD_CHK_CNT 2
  35. #define RTW_MESH_PLINK_UNKNOWN 0
  36. #define RTW_MESH_PLINK_LISTEN 1
  37. #define RTW_MESH_PLINK_OPN_SNT 2
  38. #define RTW_MESH_PLINK_OPN_RCVD 3
  39. #define RTW_MESH_PLINK_CNF_RCVD 4
  40. #define RTW_MESH_PLINK_ESTAB 5
  41. #define RTW_MESH_PLINK_HOLDING 6
  42. #define RTW_MESH_PLINK_BLOCKED 7
  43. extern const char *_rtw_mesh_plink_str[];
  44. #define rtw_mesh_plink_str(s) ((s <= RTW_MESH_PLINK_BLOCKED) ? _rtw_mesh_plink_str[s] : _rtw_mesh_plink_str[RTW_MESH_PLINK_UNKNOWN])
  45. #define RTW_MESH_PS_UNKNOWN 0
  46. #define RTW_MESH_PS_ACTIVE 1
  47. #define RTW_MESH_PS_LSLEEP 2
  48. #define RTW_MESH_PS_DSLEEP 3
  49. extern const char *_rtw_mesh_ps_str[];
  50. #define rtw_mesh_ps_str(mps) ((mps <= RTW_MESH_PS_DSLEEP) ? _rtw_mesh_ps_str[mps] : _rtw_mesh_ps_str[RTW_MESH_PS_UNKNOWN])
  51. #define GET_MESH_CONF_ELE_PATH_SEL_PROTO_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 0, 0, 8)
  52. #define GET_MESH_CONF_ELE_PATH_SEL_METRIC_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 1, 0, 8)
  53. #define GET_MESH_CONF_ELE_CONGEST_CTRL_MODE_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 2, 0, 8)
  54. #define GET_MESH_CONF_ELE_SYNC_METHOD_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 3, 0, 8)
  55. #define GET_MESH_CONF_ELE_AUTH_PROTO_ID(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 4, 0, 8)
  56. #define GET_MESH_CONF_ELE_MESH_FORMATION(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 0, 8)
  57. #define GET_MESH_CONF_ELE_CTO_MGATE(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 0, 1)
  58. #define GET_MESH_CONF_ELE_NUM_OF_PEERINGS(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 1, 6)
  59. #define GET_MESH_CONF_ELE_CTO_AS(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 5, 7, 1)
  60. #define GET_MESH_CONF_ELE_MESH_CAP(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 0, 8)
  61. #define GET_MESH_CONF_ELE_ACCEPT_PEERINGS(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 0, 1)
  62. #define GET_MESH_CONF_ELE_MCCA_SUP(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 1, 1)
  63. #define GET_MESH_CONF_ELE_MCCA_EN(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 2, 1)
  64. #define GET_MESH_CONF_ELE_FORWARDING(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 3, 1)
  65. #define GET_MESH_CONF_ELE_MBCA_EN(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 4, 1)
  66. #define GET_MESH_CONF_ELE_TBTT_ADJ(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 5, 1)
  67. #define GET_MESH_CONF_ELE_PS_LEVEL(_iec) LE_BITS_TO_1BYTE(((u8 *)(_iec)) + 6, 6, 1)
  68. #define SET_MESH_CONF_ELE_PATH_SEL_PROTO_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 0, 0, 8, _val)
  69. #define SET_MESH_CONF_ELE_PATH_SEL_METRIC_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 1, 0, 8, _val)
  70. #define SET_MESH_CONF_ELE_CONGEST_CTRL_MODE_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 2, 0, 8, _val)
  71. #define SET_MESH_CONF_ELE_SYNC_METHOD_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 3, 0, 8, _val)
  72. #define SET_MESH_CONF_ELE_AUTH_PROTO_ID(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 4, 0, 8, _val)
  73. #define SET_MESH_CONF_ELE_CTO_MGATE(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 0, 1, _val)
  74. #define SET_MESH_CONF_ELE_NUM_OF_PEERINGS(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 1, 6, _val)
  75. #define SET_MESH_CONF_ELE_CTO_AS(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 5, 7, 1, _val)
  76. #define SET_MESH_CONF_ELE_ACCEPT_PEERINGS(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 0, 1, _val)
  77. #define SET_MESH_CONF_ELE_MCCA_SUP(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 1, 1, _val)
  78. #define SET_MESH_CONF_ELE_MCCA_EN(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 2, 1, _val)
  79. #define SET_MESH_CONF_ELE_FORWARDING(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 3, 1, _val)
  80. #define SET_MESH_CONF_ELE_MBCA_EN(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 4, 1, _val)
  81. #define SET_MESH_CONF_ELE_TBTT_ADJ(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 5, 1, _val)
  82. #define SET_MESH_CONF_ELE_PS_LEVEL(_iec, _val) SET_BITS_TO_LE_1BYTE(((u8 *)(_iec)) + 6, 6, 1, _val)
  83. /* Mesh flags */
  84. #define MESH_FLAGS_AE 0x3 /* mask */
  85. #define MESH_FLAGS_AE_A4 0x1
  86. #define MESH_FLAGS_AE_A5_A6 0x2
  87. /* Max number of paths */
  88. #define RTW_MESH_MAX_PATHS 1024
  89. #define RTW_PREQ_Q_F_START 0x1
  90. #define RTW_PREQ_Q_F_REFRESH 0x2
  91. #define RTW_PREQ_Q_F_CHK 0x4
  92. #define RTW_PREQ_Q_F_PEER_AKA 0x8
  93. struct rtw_mesh_preq_queue {
  94. _list list;
  95. u8 dst[ETH_ALEN];
  96. u8 flags;
  97. };
  98. extern const u8 ae_to_mesh_ctrl_len[];
  99. enum mesh_frame_type {
  100. MESH_UCAST_DATA = 0x0,
  101. MESH_BMCAST_DATA = 0x1,
  102. MESH_UCAST_PX_DATA = 0x2,
  103. MESH_BMCAST_PX_DATA = 0x3,
  104. MESH_MHOP_UCAST_ACT = 0x4,
  105. MESH_MHOP_BMCAST_ACT = 0x5,
  106. };
  107. enum mpath_sel_frame_type {
  108. MPATH_PREQ = 0,
  109. MPATH_PREP,
  110. MPATH_PERR,
  111. MPATH_RANN
  112. };
  113. /**
  114. * enum rtw_mesh_deferred_task_flags - mesh deferred tasks
  115. *
  116. *
  117. *
  118. * @RTW_MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
  119. * @RTW_MESH_WORK_ROOT: the mesh root station needs to send a frame
  120. * @RTW_MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
  121. * mesh nodes
  122. * @RTW_MESH_WORK_MBSS_CHANGED: rebuild beacon and notify driver of BSS changes
  123. */
  124. enum rtw_mesh_deferred_task_flags {
  125. RTW_MESH_WORK_HOUSEKEEPING,
  126. RTW_MESH_WORK_ROOT,
  127. RTW_MESH_WORK_DRIFT_ADJUST,
  128. RTW_MESH_WORK_MBSS_CHANGED,
  129. };
  130. #define RTW_MESH_MAX_PEER_CANDIDATES 15 /* aid consideration */
  131. #define RTW_MESH_MAX_PEER_LINKS 8
  132. #define RTW_MESH_PEER_LINK_TIMEOUT 20
  133. #define RTW_MESH_PEER_CONF_DISABLED 0 /* special time value means no confirmation ongoing */
  134. #if CONFIG_RTW_MESH_PEER_BLACKLIST
  135. #define IS_PEER_CONF_DISABLED(plink) ((plink)->peer_conf_end_time == RTW_MESH_PEER_CONF_DISABLED)
  136. #define IS_PEER_CONF_TIMEOUT(plink)(!IS_PEER_CONF_DISABLED(plink) && rtw_time_after(rtw_get_current_time(), (plink)->peer_conf_end_time))
  137. #define SET_PEER_CONF_DISABLED(plink) (plink)->peer_conf_end_time = RTW_MESH_PEER_CONF_DISABLED
  138. #define SET_PEER_CONF_END_TIME(plink, timeout_ms) \
  139. do { \
  140. (plink)->peer_conf_end_time = rtw_get_current_time() + rtw_ms_to_systime(timeout_ms); \
  141. if ((plink)->peer_conf_end_time == RTW_MESH_PEER_CONF_DISABLED) \
  142. (plink)->peer_conf_end_time++; \
  143. } while (0)
  144. #else
  145. #define IS_PEER_CONF_DISABLED(plink) 1
  146. #define IS_PEER_CONF_TIMEOUT(plink) 0
  147. #define SET_PEER_CONF_DISABLED(plink) do {} while (0)
  148. #define SET_PEER_CONF_END_TIME(plink, timeout_ms) do {} while (0)
  149. #endif /* CONFIG_RTW_MESH_PEER_BLACKLIST */
  150. #define RTW_MESH_CTO_MGATE_CONF_DISABLED 0 /* special time value means no confirmation ongoing */
  151. #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
  152. #define IS_CTO_MGATE_CONF_DISABLED(plink) ((plink)->cto_mgate_conf_end_time == RTW_MESH_CTO_MGATE_CONF_DISABLED)
  153. #define IS_CTO_MGATE_CONF_TIMEOUT(plink)(!IS_CTO_MGATE_CONF_DISABLED(plink) && rtw_time_after(rtw_get_current_time(), (plink)->cto_mgate_conf_end_time))
  154. #define SET_CTO_MGATE_CONF_DISABLED(plink) (plink)->cto_mgate_conf_end_time = RTW_MESH_CTO_MGATE_CONF_DISABLED
  155. #define SET_CTO_MGATE_CONF_END_TIME(plink, timeout_ms) \
  156. do { \
  157. (plink)->cto_mgate_conf_end_time = rtw_get_current_time() + rtw_ms_to_systime(timeout_ms); \
  158. if ((plink)->cto_mgate_conf_end_time == RTW_MESH_CTO_MGATE_CONF_DISABLED) \
  159. (plink)->cto_mgate_conf_end_time++; \
  160. } while (0)
  161. #else
  162. #define IS_CTO_MGATE_CONF_DISABLED(plink) 1
  163. #define IS_CTO_MGATE_CONF_TIMEOUT(plink) 0
  164. #define SET_CTO_MGATE_CONF_DISABLED(plink) do {} while (0)
  165. #define SET_CTO_MGATE_CONF_END_TIME(plink, timeout_ms) do {} while (0)
  166. #endif /* CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST */
  167. struct mesh_plink_ent {
  168. u8 valid;
  169. u8 addr[ETH_ALEN];
  170. u8 plink_state;
  171. #ifdef CONFIG_RTW_MESH_AEK
  172. u8 aek_valid;
  173. u8 aek[32];
  174. #endif
  175. u16 llid;
  176. u16 plid;
  177. #ifndef CONFIG_RTW_MESH_DRIVER_AID
  178. u16 aid; /* aid assigned from upper layer */
  179. #endif
  180. u16 peer_aid; /* aid assigned from peer */
  181. u8 chosen_pmk[16];
  182. #ifdef CONFIG_RTW_MESH_AEK
  183. u8 sel_pcs[4];
  184. u8 l_nonce[32];
  185. u8 p_nonce[32];
  186. #endif
  187. #ifdef CONFIG_RTW_MESH_DRIVER_AID
  188. u8 *tx_conf_ies;
  189. u16 tx_conf_ies_len;
  190. #endif
  191. u8 *rx_conf_ies;
  192. u16 rx_conf_ies_len;
  193. struct wlan_network *scanned;
  194. #if CONFIG_RTW_MESH_PEER_BLACKLIST
  195. systime peer_conf_end_time;
  196. #endif
  197. #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
  198. systime cto_mgate_conf_end_time;
  199. #endif
  200. };
  201. #ifdef CONFIG_RTW_MESH_AEK
  202. #define MESH_PLINK_AEK_VALID(ent) ent->aek_valid
  203. #else
  204. #define MESH_PLINK_AEK_VALID(ent) 0
  205. #endif
  206. struct mesh_plink_pool {
  207. _lock lock;
  208. u8 num; /* current ent being used */
  209. struct mesh_plink_ent ent[RTW_MESH_MAX_PEER_CANDIDATES];
  210. #if CONFIG_RTW_MESH_ACNODE_PREVENT
  211. u8 acnode_rsvd;
  212. #endif
  213. #if CONFIG_RTW_MESH_PEER_BLACKLIST
  214. _queue peer_blacklist;
  215. #endif
  216. #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
  217. _queue cto_mgate_blacklist;
  218. #endif
  219. };
  220. struct mesh_peer_sel_policy {
  221. u32 scanr_exp_ms;
  222. #if CONFIG_RTW_MESH_ACNODE_PREVENT
  223. u8 acnode_prevent;
  224. u32 acnode_conf_timeout_ms;
  225. u32 acnode_notify_timeout_ms;
  226. #endif
  227. #if CONFIG_RTW_MESH_OFFCH_CAND
  228. u8 offch_cand;
  229. u32 offch_find_int_ms; /* 0 means no offch find triggerred by driver self*/
  230. #endif
  231. #if CONFIG_RTW_MESH_PEER_BLACKLIST
  232. u32 peer_conf_timeout_ms;
  233. u32 peer_blacklist_timeout_ms;
  234. #endif
  235. #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
  236. u8 cto_mgate_require;
  237. u32 cto_mgate_conf_timeout_ms;
  238. u32 cto_mgate_blacklist_timeout_ms;
  239. #endif
  240. };
  241. /* b2u flags */
  242. #define RTW_MESH_B2U_ALL BIT0
  243. #define RTW_MESH_B2U_GA_UCAST BIT1 /* Group addressed unicast frame, forward only */
  244. #define RTW_MESH_B2U_BCAST BIT2
  245. #define RTW_MESH_B2U_IP_MCAST BIT3
  246. #define rtw_msrc_b2u_policy_chk(flags, mda) ( \
  247. (flags & RTW_MESH_B2U_ALL) \
  248. || ((flags & RTW_MESH_B2U_BCAST) && is_broadcast_mac_addr(mda)) \
  249. || ((flags & RTW_MESH_B2U_IP_MCAST) && (IP_MCAST_MAC(mda) || ICMPV6_MCAST_MAC(mda))) \
  250. )
  251. #define rtw_mfwd_b2u_policy_chk(flags, mda, ucst) ( \
  252. (flags & RTW_MESH_B2U_ALL) \
  253. || ((flags & RTW_MESH_B2U_GA_UCAST) && ucst) \
  254. || ((flags & RTW_MESH_B2U_BCAST) && is_broadcast_mac_addr(mda)) \
  255. || ((flags & RTW_MESH_B2U_IP_MCAST) && (IP_MCAST_MAC(mda) || ICMPV6_MCAST_MAC(mda))) \
  256. )
  257. /**
  258. * @sane_metric_delta: Controlling if trigger additional path check mechanism
  259. * @max_root_add_chk_cnt: The retry cnt to send additional root confirmation
  260. * PREQ through old(last) path
  261. */
  262. struct rtw_mesh_cfg {
  263. u8 max_peer_links; /* peering limit */
  264. u32 plink_timeout; /* seconds */
  265. u8 dot11MeshTTL;
  266. u8 element_ttl;
  267. u32 path_refresh_time;
  268. u16 dot11MeshHWMPpreqMinInterval;
  269. u16 dot11MeshHWMPnetDiameterTraversalTime;
  270. u32 dot11MeshHWMPactivePathTimeout;
  271. u8 dot11MeshHWMPmaxPREQretries;
  272. u16 min_discovery_timeout;
  273. u16 dot11MeshHWMPconfirmationInterval;
  274. u16 dot11MeshHWMPperrMinInterval;
  275. u8 dot11MeshHWMPRootMode;
  276. BOOLEAN dot11MeshForwarding;
  277. s32 rssi_threshold; /* in dBm, 0: no specified */
  278. u16 dot11MeshHWMPRannInterval;
  279. BOOLEAN dot11MeshGateAnnouncementProtocol;
  280. u32 dot11MeshHWMPactivePathToRootTimeout;
  281. u16 dot11MeshHWMProotInterval;
  282. u8 path_gate_timeout_factor;
  283. #ifdef CONFIG_RTW_MESH_ADD_ROOT_CHK
  284. u16 sane_metric_delta;
  285. u8 max_root_add_chk_cnt;
  286. #endif
  287. struct mesh_peer_sel_policy peer_sel_policy;
  288. #if CONFIG_RTW_MESH_DATA_BMC_TO_UC
  289. u8 b2u_flags_msrc;
  290. u8 b2u_flags_mfwd;
  291. #endif
  292. };
  293. struct rtw_mesh_stats {
  294. u32 fwded_mcast; /* Mesh forwarded multicast frames */
  295. u32 fwded_unicast; /* Mesh forwarded unicast frames */
  296. u32 fwded_frames; /* Mesh total forwarded frames */
  297. u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
  298. u32 dropped_frames_no_route; /* Not transmitted, no route found */
  299. u32 dropped_frames_congestion;/* Not forwarded due to congestion */
  300. u32 dropped_frames_duplicate;
  301. u32 mrc_del_qlen; /* MRC entry deleted cause by queue length limit */
  302. };
  303. struct rtw_mrc;
  304. struct rtw_mesh_info {
  305. u8 mesh_id[NDIS_802_11_LENGTH_SSID];
  306. size_t mesh_id_len;
  307. /* Active Path Selection Protocol Identifier */
  308. u8 mesh_pp_id;
  309. /* Active Path Selection Metric Identifier */
  310. u8 mesh_pm_id;
  311. /* Congestion Control Mode Identifier */
  312. u8 mesh_cc_id;
  313. /* Synchronization Protocol Identifier */
  314. u8 mesh_sp_id;
  315. /* Authentication Protocol Identifier */
  316. u8 mesh_auth_id;
  317. struct mesh_plink_pool plink_ctl;
  318. u32 mesh_seqnum;
  319. /* MSTA's own hwmp sequence number */
  320. u32 sn;
  321. systime last_preq;
  322. systime last_sn_update;
  323. systime next_perr;
  324. /* Last used Path Discovery ID */
  325. u32 preq_id;
  326. ATOMIC_T mpaths;
  327. struct rtw_mesh_table *mesh_paths;
  328. struct rtw_mesh_table *mpp_paths;
  329. int mesh_paths_generation;
  330. int mpp_paths_generation;
  331. int num_gates;
  332. struct rtw_mesh_path *max_addr_gate;
  333. bool max_addr_gate_is_larger_than_self;
  334. struct rtw_mesh_stats mshstats;
  335. _queue mpath_tx_queue;
  336. u32 mpath_tx_queue_len;
  337. struct tasklet_struct mpath_tx_tasklet;
  338. struct rtw_mrc *mrc;
  339. _lock mesh_preq_queue_lock;
  340. struct rtw_mesh_preq_queue preq_queue;
  341. int preq_queue_len;
  342. };
  343. extern const char *_action_self_protected_str[];
  344. #define action_self_protected_str(action) ((action < RTW_ACT_SELF_PROTECTED_NUM) ? _action_self_protected_str[action] : _action_self_protected_str[0])
  345. u8 *rtw_set_ie_mesh_id(u8 *buf, u32 *buf_len, const char *mesh_id, u8 id_len);
  346. u8 *rtw_set_ie_mesh_config(u8 *buf, u32 *buf_len
  347. , u8 path_sel_proto, u8 path_sel_metric, u8 congest_ctl_mode, u8 sync_method, u8 auth_proto
  348. , u8 num_of_peerings, bool cto_mgate, bool cto_as
  349. , bool accept_peerings, bool mcca_sup, bool mcca_en, bool forwarding
  350. , bool mbca_en, bool tbtt_adj, bool ps_level);
  351. int rtw_bss_is_same_mbss(WLAN_BSSID_EX *a, WLAN_BSSID_EX *b);
  352. int rtw_bss_is_candidate_mesh_peer(WLAN_BSSID_EX *self, WLAN_BSSID_EX *target, u8 ch, u8 add_peer);
  353. void rtw_chk_candidate_peer_notify(_adapter *adapter, struct wlan_network *scanned);
  354. void rtw_mesh_peer_status_chk(_adapter *adapter);
  355. #if CONFIG_RTW_MESH_ACNODE_PREVENT
  356. void rtw_mesh_update_scanned_acnode_status(_adapter *adapter, struct wlan_network *scanned);
  357. bool rtw_mesh_scanned_is_acnode_confirmed(_adapter *adapter, struct wlan_network *scanned);
  358. bool rtw_mesh_acnode_prevent_allow_sacrifice(_adapter *adapter);
  359. struct sta_info *rtw_mesh_acnode_prevent_pick_sacrifice(_adapter *adapter);
  360. void dump_mesh_acnode_prevent_settings(void *sel, _adapter *adapter);
  361. #endif
  362. #if CONFIG_RTW_MESH_OFFCH_CAND
  363. u8 rtw_mesh_offch_candidate_accepted(_adapter *adapter);
  364. u8 rtw_mesh_select_operating_ch(_adapter *adapter);
  365. void dump_mesh_offch_cand_settings(void *sel, _adapter *adapter);
  366. #endif
  367. #if CONFIG_RTW_MESH_PEER_BLACKLIST
  368. int rtw_mesh_peer_blacklist_add(_adapter *adapter, const u8 *addr);
  369. int rtw_mesh_peer_blacklist_del(_adapter *adapter, const u8 *addr);
  370. int rtw_mesh_peer_blacklist_search(_adapter *adapter, const u8 *addr);
  371. void rtw_mesh_peer_blacklist_flush(_adapter *adapter);
  372. void dump_mesh_peer_blacklist(void *sel, _adapter *adapter);
  373. void dump_mesh_peer_blacklist_settings(void *sel, _adapter *adapter);
  374. #endif
  375. #if CONFIG_RTW_MESH_CTO_MGATE_BLACKLIST
  376. u8 rtw_mesh_cto_mgate_required(_adapter *adapter);
  377. u8 rtw_mesh_cto_mgate_network_filter(_adapter *adapter, struct wlan_network *scanned);
  378. int rtw_mesh_cto_mgate_blacklist_add(_adapter *adapter, const u8 *addr);
  379. int rtw_mesh_cto_mgate_blacklist_del(_adapter *adapter, const u8 *addr);
  380. int rtw_mesh_cto_mgate_blacklist_search(_adapter *adapter, const u8 *addr);
  381. void rtw_mesh_cto_mgate_blacklist_flush(_adapter *adapter);
  382. void dump_mesh_cto_mgate_blacklist(void *sel, _adapter *adapter);
  383. void dump_mesh_cto_mgate_blacklist_settings(void *sel, _adapter *adapter);
  384. #endif
  385. void dump_mesh_peer_sel_policy(void *sel, _adapter *adapter);
  386. void dump_mesh_networks(void *sel, _adapter *adapter);
  387. void rtw_mesh_adjust_chbw(u8 req_ch, u8 *req_bw, u8 *req_offset);
  388. int rtw_sae_check_frames(_adapter *adapter, const u8 *buf, u32 len, u8 tx);
  389. int rtw_mesh_check_frames_tx(_adapter *adapter, const u8 **buf, size_t *len);
  390. int rtw_mesh_check_frames_rx(_adapter *adapter, const u8 *buf, size_t len);
  391. int rtw_mesh_on_auth(_adapter *adapter, union recv_frame *rframe);
  392. unsigned int on_action_self_protected(_adapter *adapter, union recv_frame *rframe);
  393. bool rtw_mesh_update_bss_peering_status(_adapter *adapter, WLAN_BSSID_EX *bss);
  394. bool rtw_mesh_update_bss_formation_info(_adapter *adapter, WLAN_BSSID_EX *bss);
  395. bool rtw_mesh_update_bss_forwarding_state(_adapter *adapter, WLAN_BSSID_EX *bss);
  396. struct mesh_plink_ent *_rtw_mesh_plink_get(_adapter *adapter, const u8 *hwaddr);
  397. struct mesh_plink_ent *rtw_mesh_plink_get(_adapter *adapter, const u8 *hwaddr);
  398. struct mesh_plink_ent *rtw_mesh_plink_get_no_estab_by_idx(_adapter *adapter, u8 idx);
  399. int _rtw_mesh_plink_add(_adapter *adapter, const u8 *hwaddr);
  400. int rtw_mesh_plink_add(_adapter *adapter, const u8 *hwaddr);
  401. int rtw_mesh_plink_set_state(_adapter *adapter, const u8 *hwaddr, u8 state);
  402. #ifdef CONFIG_RTW_MESH_AEK
  403. int rtw_mesh_plink_set_aek(_adapter *adapter, const u8 *hwaddr, const u8 *aek);
  404. #endif
  405. #if CONFIG_RTW_MESH_PEER_BLACKLIST
  406. int rtw_mesh_plink_set_peer_conf_timeout(_adapter *adapter, const u8 *hwaddr);
  407. #endif
  408. void _rtw_mesh_plink_del_ent(_adapter *adapter, struct mesh_plink_ent *ent);
  409. int rtw_mesh_plink_del(_adapter *adapter, const u8 *hwaddr);
  410. void rtw_mesh_plink_ctl_init(_adapter *adapter);
  411. void rtw_mesh_plink_ctl_deinit(_adapter *adapter);
  412. void dump_mesh_plink_ctl(void *sel, _adapter *adapter);
  413. int rtw_mesh_peer_establish(_adapter *adapter, struct mesh_plink_ent *plink, struct sta_info *sta);
  414. void _rtw_mesh_expire_peer_ent(_adapter *adapter, struct mesh_plink_ent *plink);
  415. void rtw_mesh_expire_peer(_adapter *adapter, const u8 *peer_addr);
  416. u8 rtw_mesh_ps_annc(_adapter *adapter, u8 ps);
  417. unsigned int on_action_mesh(_adapter *adapter, union recv_frame *rframe);
  418. void rtw_mesh_cfg_init(_adapter *adapter);
  419. void rtw_mesh_cfg_init_max_peer_links(_adapter *adapter, u8 stack_conf);
  420. void rtw_mesh_cfg_init_plink_timeout(_adapter *adapter, u32 stack_conf);
  421. void rtw_mesh_init_mesh_info(_adapter *adapter);
  422. void rtw_mesh_deinit_mesh_info(_adapter *adapter);
  423. #if CONFIG_RTW_MESH_DATA_BMC_TO_UC
  424. void dump_mesh_b2u_flags(void *sel, _adapter *adapter);
  425. #endif
  426. int rtw_mesh_addr_resolve(_adapter *adapter, struct xmit_frame *xframe, _pkt *pkt, _list *b2u_list);
  427. s8 rtw_mesh_tx_set_whdr_mctrl_len(u8 mesh_frame_mode, struct pkt_attrib *attrib);
  428. void rtw_mesh_tx_build_mctrl(_adapter *adapter, struct pkt_attrib *attrib, u8 *buf);
  429. u8 rtw_mesh_tx_build_whdr(_adapter *adapter, struct pkt_attrib *attrib
  430. , u16 *fctrl, struct rtw_ieee80211_hdr *whdr);
  431. int rtw_mesh_rx_data_validate_hdr(_adapter *adapter, union recv_frame *rframe, struct sta_info **sta);
  432. int rtw_mesh_rx_data_validate_mctrl(_adapter *adapter, union recv_frame *rframe
  433. , const struct rtw_ieee80211s_hdr *mctrl, const u8 *mda, const u8 *msa
  434. , u8 *mctrl_len, const u8 **da, const u8 **sa);
  435. int rtw_mesh_rx_validate_mctrl_non_amsdu(_adapter *adapter, union recv_frame *rframe);
  436. int rtw_mesh_rx_msdu_act_check(union recv_frame *rframe
  437. , const u8 *mda, const u8 *msa
  438. , const u8 *da, const u8 *sa
  439. , struct rtw_ieee80211s_hdr *mctrl
  440. , struct xmit_frame **fwd_frame, _list *b2u_list);
  441. void dump_mesh_stats(void *sel, _adapter *adapter);
  442. #if defined(PLATFORM_LINUX) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
  443. #define rtw_lockdep_assert_held(l) lockdep_assert_held(l)
  444. #define rtw_lockdep_is_held(l) lockdep_is_held(l)
  445. #else
  446. #error "TBD\n"
  447. #endif
  448. #include "rtw_mesh_pathtbl.h"
  449. #include "rtw_mesh_hwmp.h"
  450. #endif /* __RTW_MESH_H_ */