802.11s.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * Fundamental types and constants relating to 802.11s Mesh
  3. *
  4. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  5. *
  6. * Copyright (C) 1999-2020, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. *
  27. * <<Broadcom-WL-IPTag/Open:>>
  28. *
  29. * $Id: 802.11s.h 681862 2018-01-03 12:34:14Z $
  30. */
  31. #ifndef _802_11s_h_
  32. #define _802_11s_h_
  33. /* This marks the start of a packed structure section. */
  34. #include <packed_section_start.h>
  35. #define DOT11_MESH_FLAGS_AE_MASK 0x3
  36. #define DOT11_MESH_FLAGS_AE_SHIFT 0
  37. #define DOT11_MESH_CONNECTED_AS_SET 7
  38. #define DOT11_MESH_NUMBER_PEERING_SET 1
  39. #define DOT11_MESH_MESH_GWSET 0
  40. #define DOT11_MESH_ACTION_LINK_MET_REP 0
  41. #define DOT11_MESH_ACTION_PATH_SEL 1
  42. #define DOT11_MESH_ACTION_GATE_ANN 2
  43. #define DOT11_MESH_ACTION_CONG_CONT_NOTIF 3
  44. #define DOT11_MESH_ACTION_MCCA_SETUP_REQ 4
  45. #define DOT11_MESH_ACTION_MCCA_SETUP_REP 5
  46. #define DOT11_MESH_ACTION_MCCA_ADVT_REQ 6
  47. #define DOT11_MESH_ACTION_MCCA_ADVT 7
  48. #define DOT11_MESH_ACTION_MCCA_TEARDOWN 8
  49. #define DOT11_MESH_ACTION_TBTT_ADJ_REQ 9
  50. #define DOT11_MESH_ACTION_TBTT_ADJ_RESP 10
  51. /* self-protected action field values: 7-57v24 */
  52. #define DOT11_SELFPROT_ACTION_MESH_PEER_OPEN 1
  53. #define DOT11_SELFPROT_ACTION_MESH_PEER_CONFM 2
  54. #define DOT11_SELFPROT_ACTION_MESH_PEER_CLOSE 3
  55. #define DOT11_SELFPROT_ACTION_MESH_PEER_GK_INF 4
  56. #define DOT11_SELFPROT_ACTION_MESH_PEER_GK_ACK 5
  57. #define DOT11_MESH_AUTH_PROTO_NONE 0
  58. #define DOT11_MESH_AUTH_PROTO_SAE 1
  59. #define DOT11_MESH_AUTH_PROTO_8021X 2
  60. #define DOT11_MESH_AUTH_PROTO_VS 255
  61. #define DOT11_MESH_PATHSEL_LEN 2
  62. #define DOT11_MESH_PERR_LEN1 2 /* Least PERR length fixed */
  63. #define DOT11_MESH_PERR_LEN2 13 /* Least PERR length variable */
  64. #define DOT11_MESH_PREP_LEN 31 /* Least PREP length */
  65. #define DOT11_MESH_PREQ_LEN 37 /* Least PREQ length */
  66. #define DOT11_MESH_PATHSEL_PROTID_HWMP 1
  67. #define DOT11_MESH_PATHSEL_METRICID_ALM 1 /* Air link metric */
  68. #define DOT11_MESH_CONGESTCTRL_NONE 0
  69. #define DOT11_MESH_CONGESTCTRL_SP 1
  70. #define DOT11_MESH_SYNCMETHOD_NOFFSET 1
  71. BWL_PRE_PACKED_STRUCT struct dot11_meshctrl_hdr {
  72. uint8 flags; /* flag bits such as ae etc */
  73. uint8 ttl; /* time to live */
  74. uint32 seq; /* sequence control */
  75. struct ether_addr a5; /* optional address 5 */
  76. struct ether_addr a6; /* optional address 6 */
  77. } BWL_POST_PACKED_STRUCT;
  78. /* Mesh Path Selection Action Frame */
  79. BWL_PRE_PACKED_STRUCT struct dot11_mesh_pathsel {
  80. uint8 category;
  81. uint8 meshaction;
  82. uint8 data[];
  83. } BWL_POST_PACKED_STRUCT;
  84. typedef struct dot11_mesh_pathsel dot11_mesh_pathsel_t;
  85. /* Mesh PREQ IE */
  86. BWL_PRE_PACKED_STRUCT struct mesh_preq_ie {
  87. uint8 id;
  88. uint8 len;
  89. uint8 flags;
  90. uint8 hop_count;
  91. uint8 ttl;
  92. uint32 pathdis_id;
  93. struct ether_addr originator_addr;
  94. uint32 originator_seq;
  95. union {
  96. BWL_PRE_PACKED_STRUCT struct {
  97. struct ether_addr target_ext_add;
  98. uint32 lifetime;
  99. uint32 metric;
  100. uint8 target_count;
  101. uint8 data[];
  102. } BWL_POST_PACKED_STRUCT oea;
  103. BWL_PRE_PACKED_STRUCT struct {
  104. uint32 lifetime;
  105. uint32 metric;
  106. uint8 target_count;
  107. uint8 data[];
  108. } BWL_POST_PACKED_STRUCT noea;
  109. } u;
  110. } BWL_POST_PACKED_STRUCT;
  111. typedef struct mesh_preq_ie mesh_preq_ie_t;
  112. /* Target info (part of Mesh PREQ IE) */
  113. BWL_PRE_PACKED_STRUCT struct mesh_targetinfo {
  114. uint8 target_flag;
  115. struct ether_addr target_addr;
  116. uint32 target_seq;
  117. } BWL_POST_PACKED_STRUCT;
  118. typedef struct mesh_targetinfo mesh_targetinfo_t;
  119. /* Mesh PREP IE */
  120. BWL_PRE_PACKED_STRUCT struct mesh_prep_ie {
  121. uint8 id;
  122. uint8 len;
  123. uint8 flags;
  124. uint8 hop_count;
  125. uint8 ttl;
  126. struct ether_addr target_addr;
  127. uint32 target_seq;
  128. union {
  129. BWL_PRE_PACKED_STRUCT struct {
  130. struct ether_addr target_ext_add;
  131. uint32 lifetime;
  132. uint32 metric;
  133. uint8 target_count;
  134. struct ether_addr originator_addr;
  135. uint32 originator_seq;
  136. } BWL_POST_PACKED_STRUCT oea;
  137. BWL_PRE_PACKED_STRUCT struct {
  138. uint32 lifetime;
  139. uint32 metric;
  140. uint8 target_count;
  141. struct ether_addr originator_addr;
  142. uint32 originator_seq;
  143. } BWL_POST_PACKED_STRUCT noea;
  144. } u;
  145. } BWL_POST_PACKED_STRUCT;
  146. typedef struct mesh_prep_ie mesh_prep_ie_t;
  147. /* Mesh PERR IE */
  148. struct mesh_perr_ie {
  149. uint8 id;
  150. uint8 len;
  151. uint8 ttl;
  152. uint8 num_dest;
  153. uint8 data[];
  154. };
  155. typedef struct mesh_perr_ie mesh_perr_ie_t;
  156. /* Destination info is part of PERR IE */
  157. BWL_PRE_PACKED_STRUCT struct mesh_perr_destinfo {
  158. uint8 flags;
  159. struct ether_addr destination_addr;
  160. uint32 dest_seq;
  161. union {
  162. BWL_PRE_PACKED_STRUCT struct {
  163. struct ether_addr dest_ext_addr;
  164. } BWL_POST_PACKED_STRUCT dea;
  165. BWL_PRE_PACKED_STRUCT struct {
  166. /* 1 byte reason code to be populated manually in software */
  167. uint16 reason_code;
  168. } BWL_POST_PACKED_STRUCT nodea;
  169. } u;
  170. } BWL_POST_PACKED_STRUCT;
  171. typedef struct mesh_perr_destinfo mesh_perr_destinfo_t;
  172. /* Mesh peering action frame hdr */
  173. BWL_PRE_PACKED_STRUCT struct mesh_peering_frmhdr {
  174. uint8 category;
  175. uint8 action;
  176. union {
  177. struct {
  178. uint16 capability;
  179. } open;
  180. struct {
  181. uint16 capability;
  182. uint16 AID;
  183. } confirm;
  184. uint8 data[1];
  185. } u;
  186. } BWL_POST_PACKED_STRUCT;
  187. typedef struct mesh_peering_frmhdr mesh_peering_frmhdr_t;
  188. /* Mesh peering mgmt IE */
  189. BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_common {
  190. uint16 mesh_peer_prot_id;
  191. uint16 local_link_id;
  192. } BWL_POST_PACKED_STRUCT;
  193. typedef struct mesh_peer_mgmt_ie_common mesh_peer_mgmt_ie_common_t;
  194. #define MESH_PEER_MGMT_IE_OPEN_LEN (4)
  195. BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_cfm {
  196. mesh_peer_mgmt_ie_common_t common;
  197. uint16 peer_link_id;
  198. } BWL_POST_PACKED_STRUCT;
  199. typedef struct mesh_peer_mgmt_ie_cfm mesh_peer_mgmt_ie_cfm_t;
  200. #define MESH_PEER_MGMT_IE_CONF_LEN (6)
  201. BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_close {
  202. mesh_peer_mgmt_ie_common_t common;
  203. /* uint16 peer_link_id;
  204. * simplicity: not supported, TODO for future
  205. */
  206. uint16 reason_code;
  207. } BWL_POST_PACKED_STRUCT;
  208. typedef struct mesh_peer_mgmt_ie_close mesh_peer_mgmt_ie_close_t;
  209. #define MESH_PEER_MGMT_IE_CLOSE_LEN (6)
  210. struct mesh_config_ie {
  211. uint8 activ_path_sel_prot_id;
  212. uint8 activ_path_sel_metric_id;
  213. uint8 cong_ctl_mode_id;
  214. uint8 sync_method_id;
  215. uint8 auth_prot_id;
  216. uint8 mesh_formation_info;
  217. uint8 mesh_cap;
  218. };
  219. typedef struct mesh_config_ie mesh_config_ie_t;
  220. #define MESH_CONFIG_IE_LEN (7)
  221. /* Mesh peering states */
  222. #define MESH_PEERING_IDLE 0
  223. #define MESH_PEERING_OPEN_SNT 1
  224. #define MESH_PEERING_CNF_RCVD 2
  225. #define MESH_PEERING_OPEN_RCVD 3
  226. #define MESH_PEERING_ESTAB 4
  227. #define MESH_PEERING_HOLDING 5
  228. #define MESH_PEERING_LAST_STATE 6
  229. /* for debugging: mapping strings */
  230. #define MESH_PEERING_STATE_STRINGS \
  231. {"IDLE ", "OPNSNT", "CNFRCV", "OPNRCV", "ESTAB ", "HOLDNG"}
  232. typedef BWL_PRE_PACKED_STRUCT struct mesh_peer_info {
  233. /* mesh_peer_instance as given in the spec. Note that, peer address
  234. * is stored in scb
  235. */
  236. uint16 mesh_peer_prot_id;
  237. uint16 local_link_id;
  238. uint16 peer_link_id;
  239. /* AID generated by *peer* to self & received in peer_confirm */
  240. uint16 peer_aid;
  241. /* TODO: no mention in spec? possibly used in PS case. Note that aid generated
  242. * from self to peer is stored in scb.
  243. */
  244. uint8 state;
  245. /* TODO: struct mesh_peer_info *next; this field is required
  246. * if multiple peerings per same src is allowed, which is
  247. * true as per spec.
  248. */
  249. } BWL_POST_PACKED_STRUCT mesh_peer_info_t;
  250. /* once an entry is added into mesh_peer_list, if peering is lost, it will
  251. * get retried for peering, MAX_MESH_PEER_ENTRY_RETRIES times. after wards, it
  252. * wont get retried and will be moved to MESH_PEER_ENTRY_STATE_TIMEDOUT state,
  253. * until user adds it again explicitely, when its entry_state is changed
  254. * to MESH_PEER_ENTRY_STATE_ACTIVE and tried again.
  255. */
  256. #define MAX_MESH_SELF_PEER_ENTRY_RETRIES 3
  257. #define MESH_SELF_PEER_ENTRY_STATE_ACTIVE 1
  258. #define MESH_SELF_PEER_ENTRY_STATE_TIMEDOUT 2
  259. /** Mesh Channel Switch Parameter IE data structure */
  260. BWL_PRE_PACKED_STRUCT struct dot11_mcsp_body {
  261. uint8 ttl; /* remaining number of hops allowed for this element. */
  262. uint8 flags; /* attributes of this channel switch attempt */
  263. uint8 reason; /* reason for the mesh channel switch */
  264. uint16 precedence; /* random value in the range 0 to 65535 */
  265. } BWL_POST_PACKED_STRUCT;
  266. #define DOT11_MCSP_TTL_DEFAULT 1
  267. #define DOT11_MCSP_FLAG_TRANS_RESTRICT 0x1 /* no transmit except frames with mcsp */
  268. #define DOT11_MCSP_FLAG_INIT 0x2 /* initiates the channel switch attempt */
  269. #define DOT11_MCSP_FLAG_REASON 0x4 /* validity of reason code field */
  270. #define DOT11_MCSP_REASON_REGULATORY 0 /* meet regulatory requirements */
  271. #define DOT11_MCSP_REASON_UNSPECIFIED 1 /* unspecified reason */
  272. BWL_PRE_PACKED_STRUCT struct dot11_mesh_csp {
  273. uint8 id; /* id DOT11_MNG_MESH_CSP_ID */
  274. uint8 len; /* length of IE */
  275. struct dot11_mcsp_body body; /* body of the ie */
  276. } BWL_POST_PACKED_STRUCT;
  277. typedef struct dot11_mesh_csp dot11_mesh_csp_ie_t;
  278. #define DOT11_MESH_CSP_IE_LEN 5 /* length of mesh channel switch parameter IE body */
  279. /* This marks the end of a packed structure section. */
  280. #include <packed_section_end.h>
  281. #endif /* #ifndef _802_11s_H_ */