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