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