1 /* 2 * Copyright (c) 2015-2016 Quantenna Communications, Inc. 3 * All rights reserved. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 */ 16 17 #ifndef _QTN_QLINK_H_ 18 #define _QTN_QLINK_H_ 19 20 #include <linux/ieee80211.h> 21 22 #define QLINK_PROTO_VER 5 23 24 #define QLINK_MACID_RSVD 0xFF 25 #define QLINK_VIFID_RSVD 0xFF 26 27 /* Common QLINK protocol messages definitions. 28 */ 29 30 /** 31 * enum qlink_msg_type - QLINK message types 32 * 33 * Used to distinguish between message types of QLINK protocol. 34 * 35 * @QLINK_MSG_TYPE_CMD: Message is carrying data of a command sent from 36 * driver to wireless hardware. 37 * @QLINK_MSG_TYPE_CMDRSP: Message is carrying data of a response to a command. 38 * Sent from wireless HW to driver in reply to previously issued command. 39 * @QLINK_MSG_TYPE_EVENT: Data for an event originated in wireless hardware and 40 * sent asynchronously to driver. 41 */ 42 enum qlink_msg_type { 43 QLINK_MSG_TYPE_CMD = 1, 44 QLINK_MSG_TYPE_CMDRSP = 2, 45 QLINK_MSG_TYPE_EVENT = 3 46 }; 47 48 /** 49 * struct qlink_msg_header - common QLINK protocol message header 50 * 51 * Portion of QLINK protocol header common for all message types. 52 * 53 * @type: Message type, one of &enum qlink_msg_type. 54 * @len: Total length of message including all headers. 55 */ 56 struct qlink_msg_header { 57 __le16 type; 58 __le16 len; 59 } __packed; 60 61 /* Generic definitions of data and information carried in QLINK messages 62 */ 63 64 enum qlink_hw_capab { 65 QLINK_HW_SUPPORTS_REG_UPDATE = BIT(0), 66 }; 67 68 enum qlink_phy_mode { 69 QLINK_PHYMODE_BGN = BIT(0), 70 QLINK_PHYMODE_AN = BIT(1), 71 QLINK_PHYMODE_AC = BIT(2), 72 }; 73 74 enum qlink_iface_type { 75 QLINK_IFTYPE_AP = 1, 76 QLINK_IFTYPE_STATION = 2, 77 QLINK_IFTYPE_ADHOC = 3, 78 QLINK_IFTYPE_MONITOR = 4, 79 QLINK_IFTYPE_WDS = 5, 80 QLINK_IFTYPE_AP_VLAN = 6, 81 }; 82 83 /** 84 * struct qlink_intf_info - information on virtual interface. 85 * 86 * Data describing a single virtual interface. 87 * 88 * @if_type: Mode of interface operation, one of &enum qlink_iface_type 89 * @vlanid: VLAN ID for AP_VLAN interface type 90 * @mac_addr: MAC address of virtual interface. 91 */ 92 struct qlink_intf_info { 93 __le16 if_type; 94 __le16 vlanid; 95 u8 mac_addr[ETH_ALEN]; 96 u8 rsvd[2]; 97 } __packed; 98 99 enum qlink_sta_flags { 100 QLINK_STA_FLAG_INVALID = 0, 101 QLINK_STA_FLAG_AUTHORIZED = BIT(0), 102 QLINK_STA_FLAG_SHORT_PREAMBLE = BIT(1), 103 QLINK_STA_FLAG_WME = BIT(2), 104 QLINK_STA_FLAG_MFP = BIT(3), 105 QLINK_STA_FLAG_AUTHENTICATED = BIT(4), 106 QLINK_STA_FLAG_TDLS_PEER = BIT(5), 107 QLINK_STA_FLAG_ASSOCIATED = BIT(6), 108 }; 109 110 enum qlink_channel_width { 111 QLINK_CHAN_WIDTH_5 = 0, 112 QLINK_CHAN_WIDTH_10, 113 QLINK_CHAN_WIDTH_20_NOHT, 114 QLINK_CHAN_WIDTH_20, 115 QLINK_CHAN_WIDTH_40, 116 QLINK_CHAN_WIDTH_80, 117 QLINK_CHAN_WIDTH_80P80, 118 QLINK_CHAN_WIDTH_160, 119 }; 120 121 /** 122 * struct qlink_chandef - qlink channel definition 123 * 124 * @center_freq1: center frequency of first segment 125 * @center_freq2: center frequency of second segment (80+80 only) 126 * @width: channel width, one of @enum qlink_channel_width 127 */ 128 struct qlink_chandef { 129 __le16 center_freq1; 130 __le16 center_freq2; 131 u8 width; 132 u8 rsvd[3]; 133 } __packed; 134 135 #define QLINK_MAX_NR_CIPHER_SUITES 5 136 #define QLINK_MAX_NR_AKM_SUITES 2 137 138 struct qlink_auth_encr { 139 __le32 wpa_versions; 140 __le32 cipher_group; 141 __le32 n_ciphers_pairwise; 142 __le32 ciphers_pairwise[QLINK_MAX_NR_CIPHER_SUITES]; 143 __le32 n_akm_suites; 144 __le32 akm_suites[QLINK_MAX_NR_AKM_SUITES]; 145 __le16 control_port_ethertype; 146 u8 auth_type; 147 u8 privacy; 148 u8 mfp; 149 u8 control_port; 150 u8 control_port_no_encrypt; 151 } __packed; 152 153 /* QLINK Command messages related definitions 154 */ 155 156 /** 157 * enum qlink_cmd_type - list of supported commands 158 * 159 * Commands are QLINK messages of type @QLINK_MSG_TYPE_CMD, sent by driver to 160 * wireless network device for processing. Device is expected to send back a 161 * reply message of type &QLINK_MSG_TYPE_CMDRSP, containing at least command 162 * execution status (one of &enum qlink_cmd_result) at least. Reply message 163 * may also contain data payload specific to the command type. 164 * 165 * @QLINK_CMD_CHANS_INFO_GET: for the specified MAC and specified band, get 166 * number of operational channels and information on each of the channel. 167 * This command is generic to a specified MAC, interface index must be set 168 * to QLINK_VIFID_RSVD in command header. 169 * @QLINK_CMD_REG_NOTIFY: notify device about regulatory domain change. This 170 * command is supported only if device reports QLINK_HW_SUPPORTS_REG_UPDATE 171 * capability. 172 */ 173 enum qlink_cmd_type { 174 QLINK_CMD_FW_INIT = 0x0001, 175 QLINK_CMD_FW_DEINIT = 0x0002, 176 QLINK_CMD_REGISTER_MGMT = 0x0003, 177 QLINK_CMD_SEND_MGMT_FRAME = 0x0004, 178 QLINK_CMD_MGMT_SET_APPIE = 0x0005, 179 QLINK_CMD_PHY_PARAMS_GET = 0x0011, 180 QLINK_CMD_PHY_PARAMS_SET = 0x0012, 181 QLINK_CMD_GET_HW_INFO = 0x0013, 182 QLINK_CMD_MAC_INFO = 0x0014, 183 QLINK_CMD_ADD_INTF = 0x0015, 184 QLINK_CMD_DEL_INTF = 0x0016, 185 QLINK_CMD_CHANGE_INTF = 0x0017, 186 QLINK_CMD_UPDOWN_INTF = 0x0018, 187 QLINK_CMD_REG_NOTIFY = 0x0019, 188 QLINK_CMD_CHANS_INFO_GET = 0x001A, 189 QLINK_CMD_CHAN_SWITCH = 0x001B, 190 QLINK_CMD_CHAN_GET = 0x001C, 191 QLINK_CMD_CONFIG_AP = 0x0020, 192 QLINK_CMD_START_AP = 0x0021, 193 QLINK_CMD_STOP_AP = 0x0022, 194 QLINK_CMD_GET_STA_INFO = 0x0030, 195 QLINK_CMD_ADD_KEY = 0x0040, 196 QLINK_CMD_DEL_KEY = 0x0041, 197 QLINK_CMD_SET_DEFAULT_KEY = 0x0042, 198 QLINK_CMD_SET_DEFAULT_MGMT_KEY = 0x0043, 199 QLINK_CMD_CHANGE_STA = 0x0051, 200 QLINK_CMD_DEL_STA = 0x0052, 201 QLINK_CMD_SCAN = 0x0053, 202 QLINK_CMD_CHAN_STATS = 0x0054, 203 QLINK_CMD_CONNECT = 0x0060, 204 QLINK_CMD_DISCONNECT = 0x0061, 205 }; 206 207 /** 208 * struct qlink_cmd - QLINK command message header 209 * 210 * Header used for QLINK messages of QLINK_MSG_TYPE_CMD type. 211 * 212 * @mhdr: Common QLINK message header. 213 * @cmd_id: command id, one of &enum qlink_cmd_type. 214 * @seq_num: sequence number of command message, used for matching with 215 * response message. 216 * @macid: index of physical radio device the command is destined to or 217 * QLINK_MACID_RSVD if not applicable. 218 * @vifid: index of virtual wireless interface on specified @macid the command 219 * is destined to or QLINK_VIFID_RSVD if not applicable. 220 */ 221 struct qlink_cmd { 222 struct qlink_msg_header mhdr; 223 __le16 cmd_id; 224 __le16 seq_num; 225 u8 rsvd[2]; 226 u8 macid; 227 u8 vifid; 228 } __packed; 229 230 /** 231 * struct qlink_cmd_manage_intf - interface management command 232 * 233 * Data for interface management commands QLINK_CMD_ADD_INTF, QLINK_CMD_DEL_INTF 234 * and QLINK_CMD_CHANGE_INTF. 235 * 236 * @intf_info: interface description. 237 */ 238 struct qlink_cmd_manage_intf { 239 struct qlink_cmd chdr; 240 struct qlink_intf_info intf_info; 241 } __packed; 242 243 enum qlink_mgmt_frame_type { 244 QLINK_MGMT_FRAME_ASSOC_REQ = 0x00, 245 QLINK_MGMT_FRAME_ASSOC_RESP = 0x01, 246 QLINK_MGMT_FRAME_REASSOC_REQ = 0x02, 247 QLINK_MGMT_FRAME_REASSOC_RESP = 0x03, 248 QLINK_MGMT_FRAME_PROBE_REQ = 0x04, 249 QLINK_MGMT_FRAME_PROBE_RESP = 0x05, 250 QLINK_MGMT_FRAME_BEACON = 0x06, 251 QLINK_MGMT_FRAME_ATIM = 0x07, 252 QLINK_MGMT_FRAME_DISASSOC = 0x08, 253 QLINK_MGMT_FRAME_AUTH = 0x09, 254 QLINK_MGMT_FRAME_DEAUTH = 0x0A, 255 QLINK_MGMT_FRAME_ACTION = 0x0B, 256 257 QLINK_MGMT_FRAME_TYPE_COUNT 258 }; 259 260 /** 261 * struct qlink_cmd_mgmt_frame_register - data for QLINK_CMD_REGISTER_MGMT 262 * 263 * @frame_type: MGMT frame type the registration request describes, one of 264 * &enum qlink_mgmt_frame_type. 265 * @do_register: 0 - unregister, otherwise register for reception of specified 266 * MGMT frame type. 267 */ 268 struct qlink_cmd_mgmt_frame_register { 269 struct qlink_cmd chdr; 270 __le16 frame_type; 271 u8 do_register; 272 } __packed; 273 274 enum qlink_mgmt_frame_tx_flags { 275 QLINK_MGMT_FRAME_TX_FLAG_NONE = 0, 276 QLINK_MGMT_FRAME_TX_FLAG_OFFCHAN = BIT(0), 277 QLINK_MGMT_FRAME_TX_FLAG_NO_CCK = BIT(1), 278 QLINK_MGMT_FRAME_TX_FLAG_ACK_NOWAIT = BIT(2), 279 }; 280 281 /** 282 * struct qlink_cmd_mgmt_frame_tx - data for QLINK_CMD_SEND_MGMT_FRAME command 283 * 284 * @cookie: opaque request identifier. 285 * @freq: Frequency to use for frame transmission. 286 * @flags: Transmission flags, one of &enum qlink_mgmt_frame_tx_flags. 287 * @frame_data: frame to transmit. 288 */ 289 struct qlink_cmd_mgmt_frame_tx { 290 struct qlink_cmd chdr; 291 __le32 cookie; 292 __le16 freq; 293 __le16 flags; 294 u8 frame_data[0]; 295 } __packed; 296 297 /** 298 * struct qlink_cmd_mgmt_append_ie - data for QLINK_CMD_MGMT_SET_APPIE command 299 * 300 * @type: type of MGMT frame to appent requested IEs to, one of 301 * &enum qlink_mgmt_frame_type. 302 * @flags: for future use. 303 * @ie_data: IEs data to append. 304 */ 305 struct qlink_cmd_mgmt_append_ie { 306 struct qlink_cmd chdr; 307 u8 type; 308 u8 flags; 309 u8 ie_data[0]; 310 } __packed; 311 312 /** 313 * struct qlink_cmd_get_sta_info - data for QLINK_CMD_GET_STA_INFO command 314 * 315 * @sta_addr: MAC address of the STA statistics is requested for. 316 */ 317 struct qlink_cmd_get_sta_info { 318 struct qlink_cmd chdr; 319 u8 sta_addr[ETH_ALEN]; 320 } __packed; 321 322 /** 323 * struct qlink_cmd_add_key - data for QLINK_CMD_ADD_KEY command. 324 * 325 * @key_index: index of the key being installed. 326 * @pairwise: whether to use pairwise key. 327 * @addr: MAC address of a STA key is being installed to. 328 * @cipher: cipher suite. 329 * @vlanid: VLAN ID for AP_VLAN interface type 330 * @key_data: key data itself. 331 */ 332 struct qlink_cmd_add_key { 333 struct qlink_cmd chdr; 334 u8 key_index; 335 u8 pairwise; 336 u8 addr[ETH_ALEN]; 337 __le32 cipher; 338 __le16 vlanid; 339 u8 key_data[0]; 340 } __packed; 341 342 /** 343 * struct qlink_cmd_del_key_req - data for QLINK_CMD_DEL_KEY command 344 * 345 * @key_index: index of the key being removed. 346 * @pairwise: whether to use pairwise key. 347 * @addr: MAC address of a STA for which a key is removed. 348 */ 349 struct qlink_cmd_del_key { 350 struct qlink_cmd chdr; 351 u8 key_index; 352 u8 pairwise; 353 u8 addr[ETH_ALEN]; 354 } __packed; 355 356 /** 357 * struct qlink_cmd_set_def_key - data for QLINK_CMD_SET_DEFAULT_KEY command 358 * 359 * @key_index: index of the key to be set as default one. 360 * @unicast: key is unicast. 361 * @multicast: key is multicast. 362 */ 363 struct qlink_cmd_set_def_key { 364 struct qlink_cmd chdr; 365 u8 key_index; 366 u8 unicast; 367 u8 multicast; 368 } __packed; 369 370 /** 371 * struct qlink_cmd_set_def_mgmt_key - data for QLINK_CMD_SET_DEFAULT_MGMT_KEY 372 * 373 * @key_index: index of the key to be set as default MGMT key. 374 */ 375 struct qlink_cmd_set_def_mgmt_key { 376 struct qlink_cmd chdr; 377 u8 key_index; 378 } __packed; 379 380 /** 381 * struct qlink_cmd_change_sta - data for QLINK_CMD_CHANGE_STA command 382 * 383 * @sta_flags_mask: STA flags mask, bitmap of &enum qlink_sta_flags 384 * @sta_flags_set: STA flags values, bitmap of &enum qlink_sta_flags 385 * @if_type: Mode of interface operation, one of &enum qlink_iface_type 386 * @vlanid: VLAN ID to assign to specific STA 387 * @sta_addr: address of the STA for which parameters are set. 388 */ 389 struct qlink_cmd_change_sta { 390 struct qlink_cmd chdr; 391 __le32 sta_flags_mask; 392 __le32 sta_flags_set; 393 __le16 if_type; 394 __le16 vlanid; 395 u8 sta_addr[ETH_ALEN]; 396 } __packed; 397 398 /** 399 * struct qlink_cmd_del_sta - data for QLINK_CMD_DEL_STA command. 400 * 401 * See &struct station_del_parameters 402 */ 403 struct qlink_cmd_del_sta { 404 struct qlink_cmd chdr; 405 __le16 reason_code; 406 u8 subtype; 407 u8 sta_addr[ETH_ALEN]; 408 } __packed; 409 410 enum qlink_sta_connect_flags { 411 QLINK_STA_CONNECT_DISABLE_HT = BIT(0), 412 QLINK_STA_CONNECT_DISABLE_VHT = BIT(1), 413 QLINK_STA_CONNECT_USE_RRM = BIT(2), 414 }; 415 416 /** 417 * struct qlink_cmd_connect - data for QLINK_CMD_CONNECT command 418 * 419 * @flags: for future use. 420 * @channel: channel which should be used to connect. 421 * @bg_scan_period: period of background scan. 422 * @aen: authentication information. 423 * @bssid: BSSID of the BSS to connect to. 424 * @payload: variable portion of connection request. 425 */ 426 struct qlink_cmd_connect { 427 struct qlink_cmd chdr; 428 __le32 flags; 429 __le16 channel; 430 __le16 bg_scan_period; 431 struct qlink_auth_encr aen; 432 u8 bssid[ETH_ALEN]; 433 u8 payload[0]; 434 } __packed; 435 436 /** 437 * struct qlink_cmd_disconnect - data for QLINK_CMD_DISCONNECT command 438 * 439 * @reason: code of the reason of disconnect, see &enum ieee80211_reasoncode. 440 */ 441 struct qlink_cmd_disconnect { 442 struct qlink_cmd chdr; 443 __le16 reason; 444 } __packed; 445 446 /** 447 * struct qlink_cmd_updown - data for QLINK_CMD_UPDOWN_INTF command 448 * 449 * @if_up: bring specified interface DOWN (if_up==0) or UP (otherwise). 450 * Interface is specified in common command header @chdr. 451 */ 452 struct qlink_cmd_updown { 453 struct qlink_cmd chdr; 454 u8 if_up; 455 } __packed; 456 457 /** 458 * enum qlink_band - a list of frequency bands 459 * 460 * @QLINK_BAND_2GHZ: 2.4GHz band 461 * @QLINK_BAND_5GHZ: 5GHz band 462 * @QLINK_BAND_60GHZ: 60GHz band 463 */ 464 enum qlink_band { 465 QLINK_BAND_2GHZ = BIT(0), 466 QLINK_BAND_5GHZ = BIT(1), 467 QLINK_BAND_60GHZ = BIT(2), 468 }; 469 470 /** 471 * struct qlink_cmd_chans_info_get - data for QLINK_CMD_CHANS_INFO_GET command 472 * 473 * @band: a PHY band for which channels info is needed, one of @enum qlink_band 474 */ 475 struct qlink_cmd_chans_info_get { 476 struct qlink_cmd chdr; 477 u8 band; 478 } __packed; 479 480 /** 481 * struct qlink_cmd_get_chan_stats - data for QLINK_CMD_CHAN_STATS command 482 * 483 * @channel: channel number according to 802.11 17.3.8.3.2 and Annex J 484 */ 485 struct qlink_cmd_get_chan_stats { 486 struct qlink_cmd chdr; 487 __le16 channel; 488 } __packed; 489 490 /** 491 * enum qlink_reg_initiator - Indicates the initiator of a reg domain request 492 * 493 * See &enum nl80211_reg_initiator for more info. 494 */ 495 enum qlink_reg_initiator { 496 QLINK_REGDOM_SET_BY_CORE, 497 QLINK_REGDOM_SET_BY_USER, 498 QLINK_REGDOM_SET_BY_DRIVER, 499 QLINK_REGDOM_SET_BY_COUNTRY_IE, 500 }; 501 502 /** 503 * enum qlink_user_reg_hint_type - type of user regulatory hint 504 * 505 * See &enum nl80211_user_reg_hint_type for more info. 506 */ 507 enum qlink_user_reg_hint_type { 508 QLINK_USER_REG_HINT_USER = 0, 509 QLINK_USER_REG_HINT_CELL_BASE = 1, 510 QLINK_USER_REG_HINT_INDOOR = 2, 511 }; 512 513 /** 514 * struct qlink_cmd_reg_notify - data for QLINK_CMD_REG_NOTIFY command 515 * 516 * @alpha2: the ISO / IEC 3166 alpha2 country code. 517 * @initiator: which entity sent the request, one of &enum qlink_reg_initiator. 518 * @user_reg_hint_type: type of hint for QLINK_REGDOM_SET_BY_USER request, one 519 * of &enum qlink_user_reg_hint_type. 520 */ 521 struct qlink_cmd_reg_notify { 522 struct qlink_cmd chdr; 523 u8 alpha2[2]; 524 u8 initiator; 525 u8 user_reg_hint_type; 526 } __packed; 527 528 /** 529 * struct qlink_cmd_chan_switch - data for QLINK_CMD_CHAN_SWITCH command 530 * 531 * @channel: channel number according to 802.11 17.3.8.3.2 and Annex J 532 * @radar_required: whether radar detection is required on the new channel 533 * @block_tx: whether transmissions should be blocked while changing 534 * @beacon_count: number of beacons until switch 535 */ 536 struct qlink_cmd_chan_switch { 537 struct qlink_cmd chdr; 538 __le16 channel; 539 u8 radar_required; 540 u8 block_tx; 541 u8 beacon_count; 542 } __packed; 543 544 /** 545 * enum qlink_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID 546 * 547 * Refer to &enum nl80211_hidden_ssid 548 */ 549 enum qlink_hidden_ssid { 550 QLINK_HIDDEN_SSID_NOT_IN_USE, 551 QLINK_HIDDEN_SSID_ZERO_LEN, 552 QLINK_HIDDEN_SSID_ZERO_CONTENTS 553 }; 554 555 /** 556 * struct qlink_cmd_config_ap - data for QLINK_CMD_CONFIG_AP command 557 * 558 * @beacon_interval: beacon interval 559 * @inactivity_timeout: station's inactivity period in seconds 560 * @dtim_period: DTIM period 561 * @hidden_ssid: whether to hide the SSID, one of &enum qlink_hidden_ssid 562 * @smps_mode: SMPS mode 563 * @ht_required: stations must support HT 564 * @vht_required: stations must support VHT 565 * @aen: encryption info 566 * @info: variable configurations 567 */ 568 struct qlink_cmd_config_ap { 569 struct qlink_cmd chdr; 570 __le16 beacon_interval; 571 __le16 inactivity_timeout; 572 u8 dtim_period; 573 u8 hidden_ssid; 574 u8 smps_mode; 575 u8 p2p_ctwindow; 576 u8 p2p_opp_ps; 577 u8 pbss; 578 u8 ht_required; 579 u8 vht_required; 580 struct qlink_auth_encr aen; 581 u8 info[0]; 582 } __packed; 583 584 /* QLINK Command Responses messages related definitions 585 */ 586 587 enum qlink_cmd_result { 588 QLINK_CMD_RESULT_OK = 0, 589 QLINK_CMD_RESULT_INVALID, 590 QLINK_CMD_RESULT_ENOTSUPP, 591 QLINK_CMD_RESULT_ENOTFOUND, 592 QLINK_CMD_RESULT_EALREADY, 593 }; 594 595 /** 596 * struct qlink_resp - QLINK command response message header 597 * 598 * Header used for QLINK messages of QLINK_MSG_TYPE_CMDRSP type. 599 * 600 * @mhdr: see &struct qlink_msg_header. 601 * @cmd_id: command ID the response corresponds to, one of &enum qlink_cmd_type. 602 * @seq_num: sequence number of command message, used for matching with 603 * response message. 604 * @result: result of the command execution, one of &enum qlink_cmd_result. 605 * @macid: index of physical radio device the response is sent from or 606 * QLINK_MACID_RSVD if not applicable. 607 * @vifid: index of virtual wireless interface on specified @macid the response 608 * is sent from or QLINK_VIFID_RSVD if not applicable. 609 */ 610 struct qlink_resp { 611 struct qlink_msg_header mhdr; 612 __le16 cmd_id; 613 __le16 seq_num; 614 __le16 result; 615 u8 macid; 616 u8 vifid; 617 } __packed; 618 619 /** 620 * struct qlink_resp_get_mac_info - response for QLINK_CMD_MAC_INFO command 621 * 622 * Data describing specific physical device providing wireless MAC 623 * functionality. 624 * 625 * @dev_mac: MAC address of physical WMAC device (used for first BSS on 626 * specified WMAC). 627 * @num_tx_chain: Number of transmit chains used by WMAC. 628 * @num_rx_chain: Number of receive chains used by WMAC. 629 * @vht_cap: VHT capabilities. 630 * @ht_cap: HT capabilities. 631 * @bands_cap: wireless bands WMAC can operate in, bitmap of &enum qlink_band. 632 * @phymode_cap: PHY modes WMAC can operate in, bitmap of &enum qlink_phy_mode. 633 * @max_ap_assoc_sta: Maximum number of associations supported by WMAC. 634 * @radar_detect_widths: bitmask of channels BW for which WMAC can detect radar. 635 * @var_info: variable-length WMAC info data. 636 */ 637 struct qlink_resp_get_mac_info { 638 struct qlink_resp rhdr; 639 u8 dev_mac[ETH_ALEN]; 640 u8 num_tx_chain; 641 u8 num_rx_chain; 642 struct ieee80211_vht_cap vht_cap; 643 struct ieee80211_ht_cap ht_cap; 644 u8 bands_cap; 645 u8 phymode_cap; 646 __le16 max_ap_assoc_sta; 647 __le16 radar_detect_widths; 648 u8 var_info[0]; 649 } __packed; 650 651 /** 652 * enum qlink_dfs_regions - regulatory DFS regions 653 * 654 * Corresponds to &enum nl80211_dfs_regions. 655 */ 656 enum qlink_dfs_regions { 657 QLINK_DFS_UNSET = 0, 658 QLINK_DFS_FCC = 1, 659 QLINK_DFS_ETSI = 2, 660 QLINK_DFS_JP = 3, 661 }; 662 663 /** 664 * struct qlink_resp_get_hw_info - response for QLINK_CMD_GET_HW_INFO command 665 * 666 * Description of wireless hardware capabilities and features. 667 * 668 * @fw_ver: wireless hardware firmware version. 669 * @hw_capab: Bitmap of capabilities supported by firmware. 670 * @ql_proto_ver: Version of QLINK protocol used by firmware. 671 * @num_mac: Number of separate physical radio devices provided by hardware. 672 * @mac_bitmap: Bitmap of MAC IDs that are active and can be used in firmware. 673 * @total_tx_chains: total number of transmit chains used by device. 674 * @total_rx_chains: total number of receive chains. 675 * @alpha2: country code ID firmware is configured to. 676 * @n_reg_rules: number of regulatory rules TLVs in variable portion of the 677 * message. 678 * @dfs_region: regulatory DFS region, one of @enum qlink_dfs_region. 679 * @info: variable-length HW info, can contain QTN_TLV_ID_REG_RULE. 680 */ 681 struct qlink_resp_get_hw_info { 682 struct qlink_resp rhdr; 683 __le32 fw_ver; 684 __le32 hw_capab; 685 __le16 ql_proto_ver; 686 u8 num_mac; 687 u8 mac_bitmap; 688 u8 total_tx_chain; 689 u8 total_rx_chain; 690 u8 alpha2[2]; 691 u8 n_reg_rules; 692 u8 dfs_region; 693 u8 info[0]; 694 } __packed; 695 696 /** 697 * struct qlink_resp_manage_intf - response for interface management commands 698 * 699 * Response data for QLINK_CMD_ADD_INTF and QLINK_CMD_CHANGE_INTF commands. 700 * 701 * @rhdr: Common Command Response message header. 702 * @intf_info: interface description. 703 */ 704 struct qlink_resp_manage_intf { 705 struct qlink_resp rhdr; 706 struct qlink_intf_info intf_info; 707 } __packed; 708 709 /** 710 * struct qlink_resp_get_sta_info - response for QLINK_CMD_GET_STA_INFO command 711 * 712 * Response data containing statistics for specified STA. 713 * 714 * @sta_addr: MAC address of STA the response carries statistic for. 715 * @info: statistics for specified STA. 716 */ 717 struct qlink_resp_get_sta_info { 718 struct qlink_resp rhdr; 719 u8 sta_addr[ETH_ALEN]; 720 u8 info[0]; 721 } __packed; 722 723 /** 724 * struct qlink_resp_get_chan_info - response for QLINK_CMD_CHANS_INFO_GET cmd 725 * 726 * @band: frequency band to which channels belong to, one of @enum qlink_band. 727 * @num_chans: total number of channels info data contained in reply data. 728 * @info: variable-length channels info. 729 */ 730 struct qlink_resp_get_chan_info { 731 struct qlink_resp rhdr; 732 u8 band; 733 u8 num_chans; 734 u8 rsvd[2]; 735 u8 info[0]; 736 } __packed; 737 738 /** 739 * struct qlink_resp_phy_params - response for QLINK_CMD_PHY_PARAMS_GET command 740 * 741 * @info: variable-length array of PHY params. 742 */ 743 struct qlink_resp_phy_params { 744 struct qlink_resp rhdr; 745 u8 info[0]; 746 } __packed; 747 748 /** 749 * struct qlink_resp_get_chan_stats - response for QLINK_CMD_CHAN_STATS cmd 750 * 751 * @info: variable-length channel info. 752 */ 753 struct qlink_resp_get_chan_stats { 754 struct qlink_cmd rhdr; 755 u8 info[0]; 756 } __packed; 757 758 /** 759 * struct qlink_resp_channel_get - response for QLINK_CMD_CHAN_GET command 760 * 761 * @chan: definition of current operating channel. 762 */ 763 struct qlink_resp_channel_get { 764 struct qlink_resp rhdr; 765 struct qlink_chandef chan; 766 } __packed; 767 768 /* QLINK Events messages related definitions 769 */ 770 771 enum qlink_event_type { 772 QLINK_EVENT_STA_ASSOCIATED = 0x0021, 773 QLINK_EVENT_STA_DEAUTH = 0x0022, 774 QLINK_EVENT_MGMT_RECEIVED = 0x0023, 775 QLINK_EVENT_SCAN_RESULTS = 0x0024, 776 QLINK_EVENT_SCAN_COMPLETE = 0x0025, 777 QLINK_EVENT_BSS_JOIN = 0x0026, 778 QLINK_EVENT_BSS_LEAVE = 0x0027, 779 QLINK_EVENT_FREQ_CHANGE = 0x0028, 780 }; 781 782 /** 783 * struct qlink_event - QLINK event message header 784 * 785 * Header used for QLINK messages of QLINK_MSG_TYPE_EVENT type. 786 * 787 * @mhdr: Common QLINK message header. 788 * @event_id: Specifies specific event ID, one of &enum qlink_event_type. 789 * @macid: index of physical radio device the event was generated on or 790 * QLINK_MACID_RSVD if not applicable. 791 * @vifid: index of virtual wireless interface on specified @macid the event 792 * was generated on or QLINK_VIFID_RSVD if not applicable. 793 */ 794 struct qlink_event { 795 struct qlink_msg_header mhdr; 796 __le16 event_id; 797 u8 macid; 798 u8 vifid; 799 } __packed; 800 801 /** 802 * struct qlink_event_sta_assoc - data for QLINK_EVENT_STA_ASSOCIATED event 803 * 804 * @sta_addr: Address of a STA for which new association event was generated 805 * @frame_control: control bits from 802.11 ASSOC_REQUEST header. 806 * @payload: IEs from association request. 807 */ 808 struct qlink_event_sta_assoc { 809 struct qlink_event ehdr; 810 u8 sta_addr[ETH_ALEN]; 811 __le16 frame_control; 812 u8 ies[0]; 813 } __packed; 814 815 /** 816 * struct qlink_event_sta_deauth - data for QLINK_EVENT_STA_DEAUTH event 817 * 818 * @sta_addr: Address of a deauthenticated STA. 819 * @reason: reason for deauthentication. 820 */ 821 struct qlink_event_sta_deauth { 822 struct qlink_event ehdr; 823 u8 sta_addr[ETH_ALEN]; 824 __le16 reason; 825 } __packed; 826 827 /** 828 * struct qlink_event_bss_join - data for QLINK_EVENT_BSS_JOIN event 829 * 830 * @bssid: BSSID of a BSS which interface tried to joined. 831 * @status: status of joining attempt, see &enum ieee80211_statuscode. 832 */ 833 struct qlink_event_bss_join { 834 struct qlink_event ehdr; 835 u8 bssid[ETH_ALEN]; 836 __le16 status; 837 } __packed; 838 839 /** 840 * struct qlink_event_bss_leave - data for QLINK_EVENT_BSS_LEAVE event 841 * 842 * @reason: reason of disconnecting from BSS. 843 */ 844 struct qlink_event_bss_leave { 845 struct qlink_event ehdr; 846 __le16 reason; 847 } __packed; 848 849 /** 850 * struct qlink_event_freq_change - data for QLINK_EVENT_FREQ_CHANGE event 851 * 852 * @chan: new operating channel definition 853 */ 854 struct qlink_event_freq_change { 855 struct qlink_event ehdr; 856 struct qlink_chandef chan; 857 } __packed; 858 859 enum qlink_rxmgmt_flags { 860 QLINK_RXMGMT_FLAG_ANSWERED = 1 << 0, 861 }; 862 863 /** 864 * struct qlink_event_rxmgmt - data for QLINK_EVENT_MGMT_RECEIVED event 865 * 866 * @freq: Frequency on which the frame was received in MHz. 867 * @sig_dbm: signal strength in dBm. 868 * @flags: bitmap of &enum qlink_rxmgmt_flags. 869 * @frame_data: data of Rx'd frame itself. 870 */ 871 struct qlink_event_rxmgmt { 872 struct qlink_event ehdr; 873 __le32 freq; 874 __le32 sig_dbm; 875 __le32 flags; 876 u8 frame_data[0]; 877 } __packed; 878 879 enum qlink_frame_type { 880 QLINK_BSS_FTYPE_UNKNOWN, 881 QLINK_BSS_FTYPE_BEACON, 882 QLINK_BSS_FTYPE_PRESP, 883 }; 884 885 /** 886 * struct qlink_event_scan_result - data for QLINK_EVENT_SCAN_RESULTS event 887 * 888 * @tsf: TSF timestamp indicating when scan results were generated. 889 * @freq: Center frequency of the channel where BSS for which the scan result 890 * event was generated was discovered. 891 * @capab: capabilities field. 892 * @bintval: beacon interval announced by discovered BSS. 893 * @signal: signal strength. 894 * @frame_type: frame type used to get scan result, see &enum qlink_frame_type. 895 * @bssid: BSSID announced by discovered BSS. 896 * @ssid_len: length of SSID announced by BSS. 897 * @ssid: SSID announced by discovered BSS. 898 * @payload: IEs that are announced by discovered BSS in its MGMt frames. 899 */ 900 struct qlink_event_scan_result { 901 struct qlink_event ehdr; 902 __le64 tsf; 903 __le16 freq; 904 __le16 capab; 905 __le16 bintval; 906 s8 signal; 907 u8 frame_type; 908 u8 bssid[ETH_ALEN]; 909 u8 ssid_len; 910 u8 ssid[IEEE80211_MAX_SSID_LEN]; 911 u8 payload[0]; 912 } __packed; 913 914 /** 915 * enum qlink_scan_complete_flags - indicates result of scan request. 916 * 917 * @QLINK_SCAN_NONE: Scan request was processed. 918 * @QLINK_SCAN_ABORTED: Scan was aborted. 919 */ 920 enum qlink_scan_complete_flags { 921 QLINK_SCAN_NONE = 0, 922 QLINK_SCAN_ABORTED = BIT(0), 923 }; 924 925 /** 926 * struct qlink_event_scan_complete - data for QLINK_EVENT_SCAN_COMPLETE event 927 * 928 * @flags: flags indicating the status of pending scan request, 929 * see &enum qlink_scan_complete_flags. 930 */ 931 struct qlink_event_scan_complete { 932 struct qlink_event ehdr; 933 __le32 flags; 934 } __packed; 935 936 /* QLINK TLVs (Type-Length Values) definitions 937 */ 938 939 enum qlink_tlv_id { 940 QTN_TLV_ID_FRAG_THRESH = 0x0201, 941 QTN_TLV_ID_RTS_THRESH = 0x0202, 942 QTN_TLV_ID_SRETRY_LIMIT = 0x0203, 943 QTN_TLV_ID_LRETRY_LIMIT = 0x0204, 944 QTN_TLV_ID_REG_RULE = 0x0207, 945 QTN_TLV_ID_CHANNEL = 0x020F, 946 QTN_TLV_ID_CHANDEF = 0x0210, 947 QTN_TLV_ID_COVERAGE_CLASS = 0x0213, 948 QTN_TLV_ID_IFACE_LIMIT = 0x0214, 949 QTN_TLV_ID_NUM_IFACE_COMB = 0x0215, 950 QTN_TLV_ID_CHANNEL_STATS = 0x0216, 951 QTN_TLV_ID_STA_BASIC_COUNTERS = 0x0300, 952 QTN_TLV_ID_STA_GENERIC_INFO = 0x0301, 953 QTN_TLV_ID_KEY = 0x0302, 954 QTN_TLV_ID_SEQ = 0x0303, 955 QTN_TLV_ID_IE_SET = 0x0305, 956 }; 957 958 struct qlink_tlv_hdr { 959 __le16 type; 960 __le16 len; 961 u8 val[0]; 962 } __packed; 963 964 struct qlink_iface_limit { 965 __le16 max_num; 966 __le16 type; 967 } __packed; 968 969 struct qlink_iface_comb_num { 970 __le16 iface_comb_num; 971 } __packed; 972 973 struct qlink_sta_stat_basic_counters { 974 __le64 rx_bytes; 975 __le64 tx_bytes; 976 __le64 rx_beacons; 977 __le32 rx_packets; 978 __le32 tx_packets; 979 __le32 rx_dropped; 980 __le32 tx_failed; 981 } __packed; 982 983 enum qlink_sta_info_rate_flags { 984 QLINK_STA_INFO_RATE_FLAG_INVALID = 0, 985 QLINK_STA_INFO_RATE_FLAG_HT_MCS = BIT(0), 986 QLINK_STA_INFO_RATE_FLAG_VHT_MCS = BIT(1), 987 QLINK_STA_INFO_RATE_FLAG_SHORT_GI = BIT(2), 988 QLINK_STA_INFO_RATE_FLAG_60G = BIT(3), 989 }; 990 991 enum qlink_sta_info_rate_bw { 992 QLINK_STA_INFO_RATE_BW_5 = 0, 993 QLINK_STA_INFO_RATE_BW_10 = 1, 994 QLINK_STA_INFO_RATE_BW_20 = 2, 995 QLINK_STA_INFO_RATE_BW_40 = 3, 996 QLINK_STA_INFO_RATE_BW_80 = 4, 997 QLINK_STA_INFO_RATE_BW_160 = 5, 998 }; 999 1000 /** 1001 * struct qlink_sta_info_rate - STA rate statistics 1002 * 1003 * @rate: data rate in Mbps. 1004 * @flags: bitmap of &enum qlink_sta_flags. 1005 * @mcs: 802.11-defined MCS index. 1006 * nss: Number of Spatial Streams. 1007 * @bw: bandwidth, one of &enum qlink_sta_info_rate_bw. 1008 */ 1009 struct qlink_sta_info_rate { 1010 __le16 rate; 1011 u8 flags; 1012 u8 mcs; 1013 u8 nss; 1014 u8 bw; 1015 } __packed; 1016 1017 struct qlink_sta_info_state { 1018 __le32 mask; 1019 __le32 value; 1020 } __packed; 1021 1022 #define QLINK_RSSI_OFFSET 120 1023 1024 struct qlink_sta_info_generic { 1025 struct qlink_sta_info_state state; 1026 __le32 connected_time; 1027 __le32 inactive_time; 1028 struct qlink_sta_info_rate rx_rate; 1029 struct qlink_sta_info_rate tx_rate; 1030 u8 rssi; 1031 u8 rssi_avg; 1032 } __packed; 1033 1034 struct qlink_tlv_frag_rts_thr { 1035 struct qlink_tlv_hdr hdr; 1036 __le16 thr; 1037 } __packed; 1038 1039 struct qlink_tlv_rlimit { 1040 struct qlink_tlv_hdr hdr; 1041 u8 rlimit; 1042 } __packed; 1043 1044 struct qlink_tlv_cclass { 1045 struct qlink_tlv_hdr hdr; 1046 u8 cclass; 1047 } __packed; 1048 1049 /** 1050 * enum qlink_reg_rule_flags - regulatory rule flags 1051 * 1052 * See description of &enum nl80211_reg_rule_flags 1053 */ 1054 enum qlink_reg_rule_flags { 1055 QLINK_RRF_NO_OFDM = BIT(0), 1056 QLINK_RRF_NO_CCK = BIT(1), 1057 QLINK_RRF_NO_INDOOR = BIT(2), 1058 QLINK_RRF_NO_OUTDOOR = BIT(3), 1059 QLINK_RRF_DFS = BIT(4), 1060 QLINK_RRF_PTP_ONLY = BIT(5), 1061 QLINK_RRF_PTMP_ONLY = BIT(6), 1062 QLINK_RRF_NO_IR = BIT(7), 1063 QLINK_RRF_AUTO_BW = BIT(8), 1064 QLINK_RRF_IR_CONCURRENT = BIT(9), 1065 QLINK_RRF_NO_HT40MINUS = BIT(10), 1066 QLINK_RRF_NO_HT40PLUS = BIT(11), 1067 QLINK_RRF_NO_80MHZ = BIT(12), 1068 QLINK_RRF_NO_160MHZ = BIT(13), 1069 }; 1070 1071 /** 1072 * struct qlink_tlv_reg_rule - data for QTN_TLV_ID_REG_RULE TLV 1073 * 1074 * Regulatory rule description. 1075 * 1076 * @start_freq_khz: start frequency of the range the rule is attributed to. 1077 * @end_freq_khz: end frequency of the range the rule is attributed to. 1078 * @max_bandwidth_khz: max bandwidth that channels in specified range can be 1079 * configured to. 1080 * @max_antenna_gain: max antenna gain that can be used in the specified 1081 * frequency range, dBi. 1082 * @max_eirp: maximum EIRP. 1083 * @flags: regulatory rule flags in &enum qlink_reg_rule_flags. 1084 * @dfs_cac_ms: DFS CAC period. 1085 */ 1086 struct qlink_tlv_reg_rule { 1087 struct qlink_tlv_hdr hdr; 1088 __le32 start_freq_khz; 1089 __le32 end_freq_khz; 1090 __le32 max_bandwidth_khz; 1091 __le32 max_antenna_gain; 1092 __le32 max_eirp; 1093 __le32 flags; 1094 __le32 dfs_cac_ms; 1095 } __packed; 1096 1097 enum qlink_channel_flags { 1098 QLINK_CHAN_DISABLED = BIT(0), 1099 QLINK_CHAN_NO_IR = BIT(1), 1100 QLINK_CHAN_RADAR = BIT(3), 1101 QLINK_CHAN_NO_HT40PLUS = BIT(4), 1102 QLINK_CHAN_NO_HT40MINUS = BIT(5), 1103 QLINK_CHAN_NO_OFDM = BIT(6), 1104 QLINK_CHAN_NO_80MHZ = BIT(7), 1105 QLINK_CHAN_NO_160MHZ = BIT(8), 1106 QLINK_CHAN_INDOOR_ONLY = BIT(9), 1107 QLINK_CHAN_IR_CONCURRENT = BIT(10), 1108 QLINK_CHAN_NO_20MHZ = BIT(11), 1109 QLINK_CHAN_NO_10MHZ = BIT(12), 1110 }; 1111 1112 enum qlink_dfs_state { 1113 QLINK_DFS_USABLE, 1114 QLINK_DFS_UNAVAILABLE, 1115 QLINK_DFS_AVAILABLE, 1116 }; 1117 1118 struct qlink_tlv_channel { 1119 struct qlink_tlv_hdr hdr; 1120 __le16 hw_value; 1121 __le16 center_freq; 1122 __le32 flags; 1123 u8 band; 1124 u8 max_antenna_gain; 1125 u8 max_power; 1126 u8 max_reg_power; 1127 __le32 dfs_cac_ms; 1128 u8 dfs_state; 1129 u8 beacon_found; 1130 u8 rsvd[2]; 1131 } __packed; 1132 1133 /** 1134 * struct qlink_tlv_chandef - data for QTN_TLV_ID_CHANDEF TLV 1135 * 1136 * Channel definition. 1137 * 1138 * @chan: channel definition data. 1139 */ 1140 struct qlink_tlv_chandef { 1141 struct qlink_tlv_hdr hdr; 1142 struct qlink_chandef chan; 1143 } __packed; 1144 1145 struct qlink_chan_stats { 1146 __le32 chan_num; 1147 __le32 cca_tx; 1148 __le32 cca_rx; 1149 __le32 cca_busy; 1150 __le32 cca_try; 1151 s8 chan_noise; 1152 } __packed; 1153 1154 #endif /* _QTN_QLINK_H_ */ 1155