1 /* 2 * Fundamental types and constants relating to 802.11s Mesh 3 * 4 * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation 5 * 6 * Copyright (C) 1999-2017, 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$ 30 */ 31 32 #ifndef _802_11s_h_ 33 #define _802_11s_h_ 34 35 /* This marks the start of a packed structure section. */ 36 #include <packed_section_start.h> 37 38 #define DOT11_MESH_FLAGS_AE_MASK 0x3 39 #define DOT11_MESH_FLAGS_AE_SHIFT 0 40 41 #define DOT11_MESH_CONNECTED_AS_SET 7 42 #define DOT11_MESH_NUMBER_PEERING_SET 1 43 #define DOT11_MESH_MESH_GWSET 0 44 45 #define DOT11_MESH_ACTION_LINK_MET_REP 0 46 #define DOT11_MESH_ACTION_PATH_SEL 1 47 #define DOT11_MESH_ACTION_GATE_ANN 2 48 #define DOT11_MESH_ACTION_CONG_CONT_NOTIF 3 49 #define DOT11_MESH_ACTION_MCCA_SETUP_REQ 4 50 #define DOT11_MESH_ACTION_MCCA_SETUP_REP 5 51 #define DOT11_MESH_ACTION_MCCA_ADVT_REQ 6 52 #define DOT11_MESH_ACTION_MCCA_ADVT 7 53 #define DOT11_MESH_ACTION_MCCA_TEARDOWN 8 54 #define DOT11_MESH_ACTION_TBTT_ADJ_REQ 9 55 #define DOT11_MESH_ACTION_TBTT_ADJ_RESP 10 56 57 /* self-protected action field values: 7-57v24 */ 58 #define DOT11_SELFPROT_ACTION_MESH_PEER_OPEN 1 59 #define DOT11_SELFPROT_ACTION_MESH_PEER_CONFM 2 60 #define DOT11_SELFPROT_ACTION_MESH_PEER_CLOSE 3 61 #define DOT11_SELFPROT_ACTION_MESH_PEER_GK_INF 4 62 #define DOT11_SELFPROT_ACTION_MESH_PEER_GK_ACK 5 63 64 #define DOT11_MESH_AUTH_PROTO_NONE 0 65 #define DOT11_MESH_AUTH_PROTO_SAE 1 66 #define DOT11_MESH_AUTH_PROTO_8021X 2 67 #define DOT11_MESH_AUTH_PROTO_VS 255 68 69 #define DOT11_MESH_PATHSEL_LEN 2 70 #define DOT11_MESH_PERR_LEN1 2 /* Least PERR length fixed */ 71 #define DOT11_MESH_PERR_LEN2 13 /* Least PERR length variable */ 72 #define DOT11_MESH_PREP_LEN 31 /* Least PREP length */ 73 #define DOT11_MESH_PREQ_LEN 37 /* Least PREQ length */ 74 75 #define DOT11_MESH_PATHSEL_PROTID_HWMP 1 76 #define DOT11_MESH_PATHSEL_METRICID_ALM 1 /* Air link metric */ 77 #define DOT11_MESH_CONGESTCTRL_NONE 0 78 #define DOT11_MESH_CONGESTCTRL_SP 1 79 #define DOT11_MESH_SYNCMETHOD_NOFFSET 1 80 81 BWL_PRE_PACKED_STRUCT struct dot11_meshctrl_hdr { 82 uint8 flags; /* flag bits such as ae etc */ 83 uint8 ttl; /* time to live */ 84 uint32 seq; /* sequence control */ 85 struct ether_addr a5; /* optional address 5 */ 86 struct ether_addr a6; /* optional address 6 */ 87 } BWL_POST_PACKED_STRUCT; 88 89 /* Mesh Path Selection Action Frame */ 90 BWL_PRE_PACKED_STRUCT struct dot11_mesh_pathsel { 91 uint8 category; 92 uint8 meshaction; 93 uint8 data[]; 94 } BWL_POST_PACKED_STRUCT; 95 typedef struct dot11_mesh_pathsel dot11_mesh_pathsel_t; 96 97 /* Mesh PREQ IE */ 98 BWL_PRE_PACKED_STRUCT struct mesh_preq_ie { 99 uint8 id; 100 uint8 len; 101 uint8 flags; 102 uint8 hop_count; 103 uint8 ttl; 104 uint32 pathdis_id; 105 struct ether_addr originator_addr; 106 uint32 originator_seq; 107 union { 108 BWL_PRE_PACKED_STRUCT struct { 109 struct ether_addr target_ext_add; 110 uint32 lifetime; 111 uint32 metric; 112 uint8 target_count; 113 uint8 data[]; 114 } BWL_POST_PACKED_STRUCT oea; 115 116 BWL_PRE_PACKED_STRUCT struct { 117 uint32 lifetime; 118 uint32 metric; 119 uint8 target_count; 120 uint8 data[]; 121 } BWL_POST_PACKED_STRUCT noea; 122 } u; 123 } BWL_POST_PACKED_STRUCT; 124 typedef struct mesh_preq_ie mesh_preq_ie_t; 125 126 /* Target info (part of Mesh PREQ IE) */ 127 BWL_PRE_PACKED_STRUCT struct mesh_targetinfo { 128 uint8 target_flag; 129 struct ether_addr target_addr; 130 uint32 target_seq; 131 } BWL_POST_PACKED_STRUCT; 132 typedef struct mesh_targetinfo mesh_targetinfo_t; 133 134 /* Mesh PREP IE */ 135 BWL_PRE_PACKED_STRUCT struct mesh_prep_ie { 136 uint8 id; 137 uint8 len; 138 uint8 flags; 139 uint8 hop_count; 140 uint8 ttl; 141 struct ether_addr target_addr; 142 uint32 target_seq; 143 union { 144 BWL_PRE_PACKED_STRUCT struct { 145 struct ether_addr target_ext_add; 146 uint32 lifetime; 147 uint32 metric; 148 uint8 target_count; 149 struct ether_addr originator_addr; 150 uint32 originator_seq; 151 } BWL_POST_PACKED_STRUCT oea; 152 153 BWL_PRE_PACKED_STRUCT struct { 154 uint32 lifetime; 155 uint32 metric; 156 uint8 target_count; 157 struct ether_addr originator_addr; 158 uint32 originator_seq; 159 } BWL_POST_PACKED_STRUCT noea; 160 } u; 161 } BWL_POST_PACKED_STRUCT; 162 typedef struct mesh_prep_ie mesh_prep_ie_t; 163 164 /* Mesh PERR IE */ 165 struct mesh_perr_ie { 166 uint8 id; 167 uint8 len; 168 uint8 ttl; 169 uint8 num_dest; 170 uint8 data[]; 171 }; 172 typedef struct mesh_perr_ie mesh_perr_ie_t; 173 174 /* Destination info is part of PERR IE */ 175 BWL_PRE_PACKED_STRUCT struct mesh_perr_destinfo { 176 uint8 flags; 177 struct ether_addr destination_addr; 178 uint32 dest_seq; 179 union { 180 BWL_PRE_PACKED_STRUCT struct { 181 struct ether_addr dest_ext_addr; 182 } BWL_POST_PACKED_STRUCT dea; 183 184 BWL_PRE_PACKED_STRUCT struct { 185 /* 1 byte reason code to be populated manually in software */ 186 uint16 reason_code; 187 } BWL_POST_PACKED_STRUCT nodea; 188 } u; 189 } BWL_POST_PACKED_STRUCT; 190 typedef struct mesh_perr_destinfo mesh_perr_destinfo_t; 191 192 /* Mesh peering action frame hdr */ 193 BWL_PRE_PACKED_STRUCT struct mesh_peering_frmhdr { 194 uint8 category; 195 uint8 action; 196 union { 197 struct { 198 uint16 capability; 199 } open; 200 struct { 201 uint16 capability; 202 uint16 AID; 203 } confirm; 204 uint8 data[1]; 205 } u; 206 } BWL_POST_PACKED_STRUCT; 207 typedef struct mesh_peering_frmhdr mesh_peering_frmhdr_t; 208 209 /* Mesh peering mgmt IE */ 210 BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_common { 211 uint16 mesh_peer_prot_id; 212 uint16 local_link_id; 213 } BWL_POST_PACKED_STRUCT; 214 typedef struct mesh_peer_mgmt_ie_common mesh_peer_mgmt_ie_common_t; 215 #define MESH_PEER_MGMT_IE_OPEN_LEN (4) 216 217 BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_cfm { 218 mesh_peer_mgmt_ie_common_t common; 219 uint16 peer_link_id; 220 } BWL_POST_PACKED_STRUCT; 221 typedef struct mesh_peer_mgmt_ie_cfm mesh_peer_mgmt_ie_cfm_t; 222 #define MESH_PEER_MGMT_IE_CONF_LEN (6) 223 224 BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_close { 225 mesh_peer_mgmt_ie_common_t common; 226 /* uint16 peer_link_id; 227 * simplicity: not supported, TODO for future 228 */ 229 uint16 reason_code; 230 } BWL_POST_PACKED_STRUCT; 231 typedef struct mesh_peer_mgmt_ie_close mesh_peer_mgmt_ie_close_t; 232 #define MESH_PEER_MGMT_IE_CLOSE_LEN (6) 233 234 struct mesh_config_ie { 235 uint8 activ_path_sel_prot_id; 236 uint8 activ_path_sel_metric_id; 237 uint8 cong_ctl_mode_id; 238 uint8 sync_method_id; 239 uint8 auth_prot_id; 240 uint8 mesh_formation_info; 241 uint8 mesh_cap; 242 }; 243 typedef struct mesh_config_ie mesh_config_ie_t; 244 #define MESH_CONFIG_IE_LEN (7) 245 246 /* Mesh peering states */ 247 #define MESH_PEERING_IDLE 0 248 #define MESH_PEERING_OPEN_SNT 1 249 #define MESH_PEERING_CNF_RCVD 2 250 #define MESH_PEERING_OPEN_RCVD 3 251 #define MESH_PEERING_ESTAB 4 252 #define MESH_PEERING_HOLDING 5 253 #define MESH_PEERING_LAST_STATE 6 254 /* for debugging: mapping strings */ 255 #define MESH_PEERING_STATE_STRINGS \ 256 {"IDLE ", "OPNSNT", "CNFRCV", "OPNRCV", "ESTAB ", "HOLDNG"} 257 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 /* once an entry is added into mesh_peer_list, if peering is lost, it will 279 * get retried for peering, MAX_MESH_PEER_ENTRY_RETRIES times. after wards, it 280 * wont get retried and will be moved to MESH_PEER_ENTRY_STATE_TIMEDOUT state, 281 * until user adds it again explicitely, when its entry_state is changed 282 * to MESH_PEER_ENTRY_STATE_ACTIVE and tried again. 283 */ 284 #define MAX_MESH_SELF_PEER_ENTRY_RETRIES 3 285 #define MESH_SELF_PEER_ENTRY_STATE_ACTIVE 1 286 #define MESH_SELF_PEER_ENTRY_STATE_TIMEDOUT 2 287 288 /** Mesh Channel Switch Parameter IE data structure */ 289 BWL_PRE_PACKED_STRUCT struct dot11_mcsp_body { 290 uint8 ttl; /* remaining number of hops allowed for this element. */ 291 uint8 flags; /* attributes of this channel switch attempt */ 292 uint8 reason; /* reason for the mesh channel switch */ 293 uint16 precedence; /* random value in the range 0 to 65535 */ 294 } BWL_POST_PACKED_STRUCT; 295 296 #define DOT11_MCSP_TTL_DEFAULT 1 297 #define DOT11_MCSP_FLAG_TRANS_RESTRICT 0x1 /* no transmit except frames with mcsp */ 298 #define DOT11_MCSP_FLAG_INIT 0x2 /* initiates the channel switch attempt */ 299 #define DOT11_MCSP_FLAG_REASON 0x4 /* validity of reason code field */ 300 #define DOT11_MCSP_REASON_REGULATORY 0 /* meet regulatory requirements */ 301 #define DOT11_MCSP_REASON_UNSPECIFIED 1 /* unspecified reason */ 302 303 BWL_PRE_PACKED_STRUCT struct dot11_mesh_csp { 304 uint8 id; /* id DOT11_MNG_MESH_CSP_ID */ 305 uint8 len; /* length of IE */ 306 struct dot11_mcsp_body body; /* body of the ie */ 307 } BWL_POST_PACKED_STRUCT; 308 typedef struct dot11_mesh_csp dot11_mesh_csp_ie_t; 309 #define DOT11_MESH_CSP_IE_LEN 5 /* length of mesh channel switch parameter IE body */ 310 311 /* This marks the end of a packed structure section. */ 312 #include <packed_section_end.h> 313 314 #endif /* #ifndef _802_11s_H_ */ 315