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 3 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 }; 81 82 /** 83 * struct qlink_intf_info - information on virtual interface. 84 * 85 * Data describing a single virtual interface. 86 * 87 * @if_type: Mode of interface operation, one of &enum qlink_iface_type 88 * @flags: interface flagsmap. 89 * @mac_addr: MAC address of virtual interface. 90 */ 91 struct qlink_intf_info { 92 __le16 if_type; 93 __le16 flags; 94 u8 mac_addr[ETH_ALEN]; 95 u8 rsvd[2]; 96 } __packed; 97 98 enum qlink_sta_flags { 99 QLINK_STA_FLAG_INVALID = 0, 100 QLINK_STA_FLAG_AUTHORIZED = BIT(0), 101 QLINK_STA_FLAG_SHORT_PREAMBLE = BIT(1), 102 QLINK_STA_FLAG_WME = BIT(2), 103 QLINK_STA_FLAG_MFP = BIT(3), 104 QLINK_STA_FLAG_AUTHENTICATED = BIT(4), 105 QLINK_STA_FLAG_TDLS_PEER = BIT(5), 106 QLINK_STA_FLAG_ASSOCIATED = BIT(6), 107 }; 108 109 enum qlink_channel_width { 110 QLINK_CHAN_WIDTH_5 = BIT(0), 111 QLINK_CHAN_WIDTH_10 = BIT(1), 112 QLINK_CHAN_WIDTH_20_NOHT = BIT(2), 113 QLINK_CHAN_WIDTH_20 = BIT(3), 114 QLINK_CHAN_WIDTH_40 = BIT(4), 115 QLINK_CHAN_WIDTH_80 = BIT(5), 116 QLINK_CHAN_WIDTH_80P80 = BIT(6), 117 QLINK_CHAN_WIDTH_160 = BIT(7), 118 }; 119 120 /* QLINK Command messages related definitions 121 */ 122 123 /** 124 * enum qlink_cmd_type - list of supported commands 125 * 126 * Commands are QLINK messages of type @QLINK_MSG_TYPE_CMD, sent by driver to 127 * wireless network device for processing. Device is expected to send back a 128 * reply message of type &QLINK_MSG_TYPE_CMDRSP, containing at least command 129 * execution status (one of &enum qlink_cmd_result) at least. Reply message 130 * may also contain data payload specific to the command type. 131 * 132 * @QLINK_CMD_CHANS_INFO_GET: for the specified MAC and specified band, get 133 * number of operational channels and information on each of the channel. 134 * This command is generic to a specified MAC, interface index must be set 135 * to QLINK_VIFID_RSVD in command header. 136 */ 137 enum qlink_cmd_type { 138 QLINK_CMD_FW_INIT = 0x0001, 139 QLINK_CMD_FW_DEINIT = 0x0002, 140 QLINK_CMD_REGISTER_MGMT = 0x0003, 141 QLINK_CMD_SEND_MGMT_FRAME = 0x0004, 142 QLINK_CMD_MGMT_SET_APPIE = 0x0005, 143 QLINK_CMD_PHY_PARAMS_GET = 0x0011, 144 QLINK_CMD_PHY_PARAMS_SET = 0x0012, 145 QLINK_CMD_GET_HW_INFO = 0x0013, 146 QLINK_CMD_MAC_INFO = 0x0014, 147 QLINK_CMD_ADD_INTF = 0x0015, 148 QLINK_CMD_DEL_INTF = 0x0016, 149 QLINK_CMD_CHANGE_INTF = 0x0017, 150 QLINK_CMD_UPDOWN_INTF = 0x0018, 151 QLINK_CMD_REG_REGION = 0x0019, 152 QLINK_CMD_CHANS_INFO_GET = 0x001A, 153 QLINK_CMD_CONFIG_AP = 0x0020, 154 QLINK_CMD_START_AP = 0x0021, 155 QLINK_CMD_STOP_AP = 0x0022, 156 QLINK_CMD_GET_STA_INFO = 0x0030, 157 QLINK_CMD_ADD_KEY = 0x0040, 158 QLINK_CMD_DEL_KEY = 0x0041, 159 QLINK_CMD_SET_DEFAULT_KEY = 0x0042, 160 QLINK_CMD_SET_DEFAULT_MGMT_KEY = 0x0043, 161 QLINK_CMD_CHANGE_STA = 0x0051, 162 QLINK_CMD_DEL_STA = 0x0052, 163 QLINK_CMD_SCAN = 0x0053, 164 QLINK_CMD_CONNECT = 0x0060, 165 QLINK_CMD_DISCONNECT = 0x0061, 166 }; 167 168 /** 169 * struct qlink_cmd - QLINK command message header 170 * 171 * Header used for QLINK messages of QLINK_MSG_TYPE_CMD type. 172 * 173 * @mhdr: Common QLINK message header. 174 * @cmd_id: command id, one of &enum qlink_cmd_type. 175 * @seq_num: sequence number of command message, used for matching with 176 * response message. 177 * @macid: index of physical radio device the command is destined to or 178 * QLINK_MACID_RSVD if not applicable. 179 * @vifid: index of virtual wireless interface on specified @macid the command 180 * is destined to or QLINK_VIFID_RSVD if not applicable. 181 */ 182 struct qlink_cmd { 183 struct qlink_msg_header mhdr; 184 __le16 cmd_id; 185 __le16 seq_num; 186 u8 rsvd[2]; 187 u8 macid; 188 u8 vifid; 189 } __packed; 190 191 /** 192 * struct qlink_cmd_manage_intf - interface management command 193 * 194 * Data for interface management commands QLINK_CMD_ADD_INTF, QLINK_CMD_DEL_INTF 195 * and QLINK_CMD_CHANGE_INTF. 196 * 197 * @intf_info: interface description. 198 */ 199 struct qlink_cmd_manage_intf { 200 struct qlink_cmd chdr; 201 struct qlink_intf_info intf_info; 202 } __packed; 203 204 enum qlink_mgmt_frame_type { 205 QLINK_MGMT_FRAME_ASSOC_REQ = 0x00, 206 QLINK_MGMT_FRAME_ASSOC_RESP = 0x01, 207 QLINK_MGMT_FRAME_REASSOC_REQ = 0x02, 208 QLINK_MGMT_FRAME_REASSOC_RESP = 0x03, 209 QLINK_MGMT_FRAME_PROBE_REQ = 0x04, 210 QLINK_MGMT_FRAME_PROBE_RESP = 0x05, 211 QLINK_MGMT_FRAME_BEACON = 0x06, 212 QLINK_MGMT_FRAME_ATIM = 0x07, 213 QLINK_MGMT_FRAME_DISASSOC = 0x08, 214 QLINK_MGMT_FRAME_AUTH = 0x09, 215 QLINK_MGMT_FRAME_DEAUTH = 0x0A, 216 QLINK_MGMT_FRAME_ACTION = 0x0B, 217 218 QLINK_MGMT_FRAME_TYPE_COUNT 219 }; 220 221 /** 222 * struct qlink_cmd_mgmt_frame_register - data for QLINK_CMD_REGISTER_MGMT 223 * 224 * @frame_type: MGMT frame type the registration request describes, one of 225 * &enum qlink_mgmt_frame_type. 226 * @do_register: 0 - unregister, otherwise register for reception of specified 227 * MGMT frame type. 228 */ 229 struct qlink_cmd_mgmt_frame_register { 230 struct qlink_cmd chdr; 231 __le16 frame_type; 232 u8 do_register; 233 } __packed; 234 235 enum qlink_mgmt_frame_tx_flags { 236 QLINK_MGMT_FRAME_TX_FLAG_NONE = 0, 237 QLINK_MGMT_FRAME_TX_FLAG_OFFCHAN = BIT(0), 238 QLINK_MGMT_FRAME_TX_FLAG_NO_CCK = BIT(1), 239 QLINK_MGMT_FRAME_TX_FLAG_ACK_NOWAIT = BIT(2), 240 }; 241 242 /** 243 * struct qlink_cmd_mgmt_frame_tx - data for QLINK_CMD_SEND_MGMT_FRAME command 244 * 245 * @cookie: opaque request identifier. 246 * @freq: Frequency to use for frame transmission. 247 * @flags: Transmission flags, one of &enum qlink_mgmt_frame_tx_flags. 248 * @frame_data: frame to transmit. 249 */ 250 struct qlink_cmd_mgmt_frame_tx { 251 struct qlink_cmd chdr; 252 __le32 cookie; 253 __le16 freq; 254 __le16 flags; 255 u8 frame_data[0]; 256 } __packed; 257 258 /** 259 * struct qlink_cmd_mgmt_append_ie - data for QLINK_CMD_MGMT_SET_APPIE command 260 * 261 * @type: type of MGMT frame to appent requested IEs to, one of 262 * &enum qlink_mgmt_frame_type. 263 * @flags: for future use. 264 * @ie_data: IEs data to append. 265 */ 266 struct qlink_cmd_mgmt_append_ie { 267 struct qlink_cmd chdr; 268 u8 type; 269 u8 flags; 270 u8 ie_data[0]; 271 } __packed; 272 273 /** 274 * struct qlink_cmd_get_sta_info - data for QLINK_CMD_GET_STA_INFO command 275 * 276 * @sta_addr: MAC address of the STA statistics is requested for. 277 */ 278 struct qlink_cmd_get_sta_info { 279 struct qlink_cmd chdr; 280 u8 sta_addr[ETH_ALEN]; 281 } __packed; 282 283 /** 284 * struct qlink_cmd_add_key - data for QLINK_CMD_ADD_KEY command. 285 * 286 * @key_index: index of the key being installed. 287 * @pairwise: whether to use pairwise key. 288 * @addr: MAC address of a STA key is being installed to. 289 * @cipher: cipher suite. 290 * @key_data: key data itself. 291 */ 292 struct qlink_cmd_add_key { 293 struct qlink_cmd chdr; 294 u8 key_index; 295 u8 pairwise; 296 u8 addr[ETH_ALEN]; 297 __le32 cipher; 298 u8 key_data[0]; 299 } __packed; 300 301 /** 302 * struct qlink_cmd_del_key_req - data for QLINK_CMD_DEL_KEY command 303 * 304 * @key_index: index of the key being removed. 305 * @pairwise: whether to use pairwise key. 306 * @addr: MAC address of a STA for which a key is removed. 307 */ 308 struct qlink_cmd_del_key { 309 struct qlink_cmd chdr; 310 u8 key_index; 311 u8 pairwise; 312 u8 addr[ETH_ALEN]; 313 } __packed; 314 315 /** 316 * struct qlink_cmd_set_def_key - data for QLINK_CMD_SET_DEFAULT_KEY command 317 * 318 * @key_index: index of the key to be set as default one. 319 * @unicast: key is unicast. 320 * @multicast: key is multicast. 321 */ 322 struct qlink_cmd_set_def_key { 323 struct qlink_cmd chdr; 324 u8 key_index; 325 u8 unicast; 326 u8 multicast; 327 } __packed; 328 329 /** 330 * struct qlink_cmd_set_def_mgmt_key - data for QLINK_CMD_SET_DEFAULT_MGMT_KEY 331 * 332 * @key_index: index of the key to be set as default MGMT key. 333 */ 334 struct qlink_cmd_set_def_mgmt_key { 335 struct qlink_cmd chdr; 336 u8 key_index; 337 } __packed; 338 339 /** 340 * struct qlink_cmd_change_sta - data for QLINK_CMD_CHANGE_STA command 341 * 342 * @sta_flags_mask: STA flags mask, bitmap of &enum qlink_sta_flags 343 * @sta_flags_set: STA flags values, bitmap of &enum qlink_sta_flags 344 * @sta_addr: address of the STA for which parameters are set. 345 */ 346 struct qlink_cmd_change_sta { 347 struct qlink_cmd chdr; 348 __le32 sta_flags_mask; 349 __le32 sta_flags_set; 350 u8 sta_addr[ETH_ALEN]; 351 } __packed; 352 353 /** 354 * struct qlink_cmd_del_sta - data for QLINK_CMD_DEL_STA command. 355 * 356 * See &struct station_del_parameters 357 */ 358 struct qlink_cmd_del_sta { 359 struct qlink_cmd chdr; 360 __le16 reason_code; 361 u8 subtype; 362 u8 sta_addr[ETH_ALEN]; 363 } __packed; 364 365 enum qlink_sta_connect_flags { 366 QLINK_STA_CONNECT_DISABLE_HT = BIT(0), 367 QLINK_STA_CONNECT_DISABLE_VHT = BIT(1), 368 QLINK_STA_CONNECT_USE_RRM = BIT(2), 369 }; 370 371 /** 372 * struct qlink_cmd_connect - data for QLINK_CMD_CONNECT command 373 * 374 * @flags: for future use. 375 * @freq: center frequence of a channel which should be used to connect. 376 * @bg_scan_period: period of background scan. 377 * @bssid: BSSID of the BSS to connect to. 378 * @payload: variable portion of connection request. 379 */ 380 struct qlink_cmd_connect { 381 struct qlink_cmd chdr; 382 __le32 flags; 383 __le16 freq; 384 __le16 bg_scan_period; 385 u8 bssid[ETH_ALEN]; 386 u8 payload[0]; 387 } __packed; 388 389 /** 390 * struct qlink_cmd_disconnect - data for QLINK_CMD_DISCONNECT command 391 * 392 * @reason: code of the reason of disconnect, see &enum ieee80211_reasoncode. 393 */ 394 struct qlink_cmd_disconnect { 395 struct qlink_cmd chdr; 396 __le16 reason; 397 } __packed; 398 399 /** 400 * struct qlink_cmd_updown - data for QLINK_CMD_UPDOWN_INTF command 401 * 402 * @if_up: bring specified interface DOWN (if_up==0) or UP (otherwise). 403 * Interface is specified in common command header @chdr. 404 */ 405 struct qlink_cmd_updown { 406 struct qlink_cmd chdr; 407 u8 if_up; 408 } __packed; 409 410 /** 411 * enum qlink_band - a list of frequency bands 412 * 413 * @QLINK_BAND_2GHZ: 2.4GHz band 414 * @QLINK_BAND_5GHZ: 5GHz band 415 * @QLINK_BAND_60GHZ: 60GHz band 416 */ 417 enum qlink_band { 418 QLINK_BAND_2GHZ = BIT(0), 419 QLINK_BAND_5GHZ = BIT(1), 420 QLINK_BAND_60GHZ = BIT(2), 421 }; 422 423 /** 424 * struct qlink_cmd_chans_info_get - data for QLINK_CMD_CHANS_INFO_GET command 425 * 426 * @band: a PHY band for which channels info is needed, one of @enum qlink_band 427 */ 428 struct qlink_cmd_chans_info_get { 429 struct qlink_cmd chdr; 430 u8 band; 431 } __packed; 432 433 /* QLINK Command Responses messages related definitions 434 */ 435 436 enum qlink_cmd_result { 437 QLINK_CMD_RESULT_OK = 0, 438 QLINK_CMD_RESULT_INVALID, 439 QLINK_CMD_RESULT_ENOTSUPP, 440 QLINK_CMD_RESULT_ENOTFOUND, 441 }; 442 443 /** 444 * struct qlink_resp - QLINK command response message header 445 * 446 * Header used for QLINK messages of QLINK_MSG_TYPE_CMDRSP type. 447 * 448 * @mhdr: see &struct qlink_msg_header. 449 * @cmd_id: command ID the response corresponds to, one of &enum qlink_cmd_type. 450 * @seq_num: sequence number of command message, used for matching with 451 * response message. 452 * @result: result of the command execution, one of &enum qlink_cmd_result. 453 * @macid: index of physical radio device the response is sent from or 454 * QLINK_MACID_RSVD if not applicable. 455 * @vifid: index of virtual wireless interface on specified @macid the response 456 * is sent from or QLINK_VIFID_RSVD if not applicable. 457 */ 458 struct qlink_resp { 459 struct qlink_msg_header mhdr; 460 __le16 cmd_id; 461 __le16 seq_num; 462 __le16 result; 463 u8 macid; 464 u8 vifid; 465 } __packed; 466 467 /** 468 * struct qlink_resp_get_mac_info - response for QLINK_CMD_MAC_INFO command 469 * 470 * Data describing specific physical device providing wireless MAC 471 * functionality. 472 * 473 * @dev_mac: MAC address of physical WMAC device (used for first BSS on 474 * specified WMAC). 475 * @num_tx_chain: Number of transmit chains used by WMAC. 476 * @num_rx_chain: Number of receive chains used by WMAC. 477 * @vht_cap: VHT capabilities. 478 * @ht_cap: HT capabilities. 479 * @bands_cap: wireless bands WMAC can operate in, bitmap of &enum qlink_band. 480 * @phymode_cap: PHY modes WMAC can operate in, bitmap of &enum qlink_phy_mode. 481 * @max_ap_assoc_sta: Maximum number of associations supported by WMAC. 482 * @radar_detect_widths: bitmask of channels BW for which WMAC can detect radar. 483 * @var_info: variable-length WMAC info data. 484 */ 485 struct qlink_resp_get_mac_info { 486 struct qlink_resp rhdr; 487 u8 dev_mac[ETH_ALEN]; 488 u8 num_tx_chain; 489 u8 num_rx_chain; 490 struct ieee80211_vht_cap vht_cap; 491 struct ieee80211_ht_cap ht_cap; 492 u8 bands_cap; 493 u8 phymode_cap; 494 __le16 max_ap_assoc_sta; 495 __le16 radar_detect_widths; 496 u8 var_info[0]; 497 } __packed; 498 499 /** 500 * struct qlink_resp_get_hw_info - response for QLINK_CMD_GET_HW_INFO command 501 * 502 * Description of wireless hardware capabilities and features. 503 * 504 * @fw_ver: wireless hardware firmware version. 505 * @hw_capab: Bitmap of capabilities supported by firmware. 506 * @ql_proto_ver: Version of QLINK protocol used by firmware. 507 * @country_code: country code ID firmware is configured to. 508 * @num_mac: Number of separate physical radio devices provided by hardware. 509 * @mac_bitmap: Bitmap of MAC IDs that are active and can be used in firmware. 510 * @total_tx_chains: total number of transmit chains used by device. 511 * @total_rx_chains: total number of receive chains. 512 */ 513 struct qlink_resp_get_hw_info { 514 struct qlink_resp rhdr; 515 __le32 fw_ver; 516 __le32 hw_capab; 517 __le16 ql_proto_ver; 518 u8 alpha2_code[2]; 519 u8 num_mac; 520 u8 mac_bitmap; 521 u8 total_tx_chain; 522 u8 total_rx_chain; 523 } __packed; 524 525 /** 526 * struct qlink_resp_manage_intf - response for interface management commands 527 * 528 * Response data for QLINK_CMD_ADD_INTF and QLINK_CMD_CHANGE_INTF commands. 529 * 530 * @rhdr: Common Command Response message header. 531 * @intf_info: interface description. 532 */ 533 struct qlink_resp_manage_intf { 534 struct qlink_resp rhdr; 535 struct qlink_intf_info intf_info; 536 } __packed; 537 538 /** 539 * struct qlink_resp_get_sta_info - response for QLINK_CMD_GET_STA_INFO command 540 * 541 * Response data containing statistics for specified STA. 542 * 543 * @sta_addr: MAC address of STA the response carries statistic for. 544 * @info: statistics for specified STA. 545 */ 546 struct qlink_resp_get_sta_info { 547 struct qlink_resp rhdr; 548 u8 sta_addr[ETH_ALEN]; 549 u8 info[0]; 550 } __packed; 551 552 /** 553 * struct qlink_resp_get_chan_info - response for QLINK_CMD_CHANS_INFO_GET cmd 554 * 555 * @band: frequency band to which channels belong to, one of @enum qlink_band. 556 * @num_chans: total number of channels info data contained in reply data. 557 * @info: variable-length channels info. 558 */ 559 struct qlink_resp_get_chan_info { 560 struct qlink_resp rhdr; 561 u8 band; 562 u8 num_chans; 563 u8 rsvd[2]; 564 u8 info[0]; 565 } __packed; 566 567 /** 568 * struct qlink_resp_phy_params - response for QLINK_CMD_PHY_PARAMS_GET command 569 * 570 * @info: variable-length array of PHY params. 571 */ 572 struct qlink_resp_phy_params { 573 struct qlink_resp rhdr; 574 u8 info[0]; 575 } __packed; 576 577 /* QLINK Events messages related definitions 578 */ 579 580 enum qlink_event_type { 581 QLINK_EVENT_STA_ASSOCIATED = 0x0021, 582 QLINK_EVENT_STA_DEAUTH = 0x0022, 583 QLINK_EVENT_MGMT_RECEIVED = 0x0023, 584 QLINK_EVENT_SCAN_RESULTS = 0x0024, 585 QLINK_EVENT_SCAN_COMPLETE = 0x0025, 586 QLINK_EVENT_BSS_JOIN = 0x0026, 587 QLINK_EVENT_BSS_LEAVE = 0x0027, 588 }; 589 590 /** 591 * struct qlink_event - QLINK event message header 592 * 593 * Header used for QLINK messages of QLINK_MSG_TYPE_EVENT type. 594 * 595 * @mhdr: Common QLINK message header. 596 * @event_id: Specifies specific event ID, one of &enum qlink_event_type. 597 * @macid: index of physical radio device the event was generated on or 598 * QLINK_MACID_RSVD if not applicable. 599 * @vifid: index of virtual wireless interface on specified @macid the event 600 * was generated on or QLINK_VIFID_RSVD if not applicable. 601 */ 602 struct qlink_event { 603 struct qlink_msg_header mhdr; 604 __le16 event_id; 605 u8 macid; 606 u8 vifid; 607 } __packed; 608 609 /** 610 * struct qlink_event_sta_assoc - data for QLINK_EVENT_STA_ASSOCIATED event 611 * 612 * @sta_addr: Address of a STA for which new association event was generated 613 * @frame_control: control bits from 802.11 ASSOC_REQUEST header. 614 * @payload: IEs from association request. 615 */ 616 struct qlink_event_sta_assoc { 617 struct qlink_event ehdr; 618 u8 sta_addr[ETH_ALEN]; 619 __le16 frame_control; 620 u8 ies[0]; 621 } __packed; 622 623 /** 624 * struct qlink_event_sta_deauth - data for QLINK_EVENT_STA_DEAUTH event 625 * 626 * @sta_addr: Address of a deauthenticated STA. 627 * @reason: reason for deauthentication. 628 */ 629 struct qlink_event_sta_deauth { 630 struct qlink_event ehdr; 631 u8 sta_addr[ETH_ALEN]; 632 __le16 reason; 633 } __packed; 634 635 /** 636 * struct qlink_event_bss_join - data for QLINK_EVENT_BSS_JOIN event 637 * 638 * @bssid: BSSID of a BSS which interface tried to joined. 639 * @status: status of joining attempt, see &enum ieee80211_statuscode. 640 */ 641 struct qlink_event_bss_join { 642 struct qlink_event ehdr; 643 u8 bssid[ETH_ALEN]; 644 __le16 status; 645 } __packed; 646 647 /** 648 * struct qlink_event_bss_leave - data for QLINK_EVENT_BSS_LEAVE event 649 * 650 * @reason: reason of disconnecting from BSS. 651 */ 652 struct qlink_event_bss_leave { 653 struct qlink_event ehdr; 654 u16 reason; 655 } __packed; 656 657 enum qlink_rxmgmt_flags { 658 QLINK_RXMGMT_FLAG_ANSWERED = 1 << 0, 659 }; 660 661 /** 662 * struct qlink_event_rxmgmt - data for QLINK_EVENT_MGMT_RECEIVED event 663 * 664 * @freq: Frequency on which the frame was received in MHz. 665 * @sig_dbm: signal strength in dBm. 666 * @flags: bitmap of &enum qlink_rxmgmt_flags. 667 * @frame_data: data of Rx'd frame itself. 668 */ 669 struct qlink_event_rxmgmt { 670 struct qlink_event ehdr; 671 __le32 freq; 672 __le32 sig_dbm; 673 __le32 flags; 674 u8 frame_data[0]; 675 } __packed; 676 677 enum qlink_frame_type { 678 QLINK_BSS_FTYPE_UNKNOWN, 679 QLINK_BSS_FTYPE_BEACON, 680 QLINK_BSS_FTYPE_PRESP, 681 }; 682 683 /** 684 * struct qlink_event_scan_result - data for QLINK_EVENT_SCAN_RESULTS event 685 * 686 * @tsf: TSF timestamp indicating when scan results were generated. 687 * @freq: Center frequency of the channel where BSS for which the scan result 688 * event was generated was discovered. 689 * @capab: capabilities field. 690 * @bintval: beacon interval announced by discovered BSS. 691 * @signal: signal strength. 692 * @frame_type: frame type used to get scan result, see &enum qlink_frame_type. 693 * @bssid: BSSID announced by discovered BSS. 694 * @ssid_len: length of SSID announced by BSS. 695 * @ssid: SSID announced by discovered BSS. 696 * @payload: IEs that are announced by discovered BSS in its MGMt frames. 697 */ 698 struct qlink_event_scan_result { 699 struct qlink_event ehdr; 700 __le64 tsf; 701 __le16 freq; 702 __le16 capab; 703 __le16 bintval; 704 s8 signal; 705 u8 frame_type; 706 u8 bssid[ETH_ALEN]; 707 u8 ssid_len; 708 u8 ssid[IEEE80211_MAX_SSID_LEN]; 709 u8 payload[0]; 710 } __packed; 711 712 /** 713 * enum qlink_scan_complete_flags - indicates result of scan request. 714 * 715 * @QLINK_SCAN_NONE: Scan request was processed. 716 * @QLINK_SCAN_ABORTED: Scan was aborted. 717 */ 718 enum qlink_scan_complete_flags { 719 QLINK_SCAN_NONE = 0, 720 QLINK_SCAN_ABORTED = BIT(0), 721 }; 722 723 /** 724 * struct qlink_event_scan_complete - data for QLINK_EVENT_SCAN_COMPLETE event 725 * 726 * @flags: flags indicating the status of pending scan request, 727 * see &enum qlink_scan_complete_flags. 728 */ 729 struct qlink_event_scan_complete { 730 struct qlink_event ehdr; 731 __le32 flags; 732 } __packed; 733 734 /* QLINK TLVs (Type-Length Values) definitions 735 */ 736 737 enum qlink_tlv_id { 738 QTN_TLV_ID_FRAG_THRESH = 0x0201, 739 QTN_TLV_ID_RTS_THRESH = 0x0202, 740 QTN_TLV_ID_SRETRY_LIMIT = 0x0203, 741 QTN_TLV_ID_LRETRY_LIMIT = 0x0204, 742 QTN_TLV_ID_BCN_PERIOD = 0x0205, 743 QTN_TLV_ID_DTIM = 0x0206, 744 QTN_TLV_ID_CHANNEL = 0x020F, 745 QTN_TLV_ID_COVERAGE_CLASS = 0x0213, 746 QTN_TLV_ID_IFACE_LIMIT = 0x0214, 747 QTN_TLV_ID_NUM_IFACE_COMB = 0x0215, 748 QTN_TLV_ID_STA_BASIC_COUNTERS = 0x0300, 749 QTN_TLV_ID_STA_GENERIC_INFO = 0x0301, 750 QTN_TLV_ID_KEY = 0x0302, 751 QTN_TLV_ID_SEQ = 0x0303, 752 QTN_TLV_ID_CRYPTO = 0x0304, 753 QTN_TLV_ID_IE_SET = 0x0305, 754 }; 755 756 struct qlink_tlv_hdr { 757 __le16 type; 758 __le16 len; 759 u8 val[0]; 760 } __packed; 761 762 struct qlink_iface_limit { 763 __le16 max_num; 764 __le16 type_mask; 765 } __packed; 766 767 struct qlink_iface_comb_num { 768 __le16 iface_comb_num; 769 } __packed; 770 771 struct qlink_sta_stat_basic_counters { 772 __le64 rx_bytes; 773 __le64 tx_bytes; 774 __le64 rx_beacons; 775 __le32 rx_packets; 776 __le32 tx_packets; 777 __le32 rx_dropped; 778 __le32 tx_failed; 779 } __packed; 780 781 enum qlink_sta_info_rate_flags { 782 QLINK_STA_INFO_RATE_FLAG_INVALID = 0, 783 QLINK_STA_INFO_RATE_FLAG_HT_MCS = BIT(0), 784 QLINK_STA_INFO_RATE_FLAG_VHT_MCS = BIT(1), 785 QLINK_STA_INFO_RATE_FLAG_SHORT_GI = BIT(2), 786 QLINK_STA_INFO_RATE_FLAG_60G = BIT(3), 787 }; 788 789 enum qlink_sta_info_rate_bw { 790 QLINK_STA_INFO_RATE_BW_5 = 0, 791 QLINK_STA_INFO_RATE_BW_10 = 1, 792 QLINK_STA_INFO_RATE_BW_20 = 2, 793 QLINK_STA_INFO_RATE_BW_40 = 3, 794 QLINK_STA_INFO_RATE_BW_80 = 4, 795 QLINK_STA_INFO_RATE_BW_160 = 5, 796 }; 797 798 /** 799 * struct qlink_sta_info_rate - STA rate statistics 800 * 801 * @rate: data rate in Mbps. 802 * @flags: bitmap of &enum qlink_sta_flags. 803 * @mcs: 802.11-defined MCS index. 804 * nss: Number of Spatial Streams. 805 * @bw: bandwidth, one of &enum qlink_sta_info_rate_bw. 806 */ 807 struct qlink_sta_info_rate { 808 __le16 rate; 809 u8 flags; 810 u8 mcs; 811 u8 nss; 812 u8 bw; 813 } __packed; 814 815 struct qlink_sta_info_state { 816 __le32 mask; 817 __le32 value; 818 } __packed; 819 820 #define QLINK_RSSI_OFFSET 120 821 822 struct qlink_sta_info_generic { 823 struct qlink_sta_info_state state; 824 __le32 connected_time; 825 __le32 inactive_time; 826 struct qlink_sta_info_rate rx_rate; 827 struct qlink_sta_info_rate tx_rate; 828 u8 rssi; 829 u8 rssi_avg; 830 } __packed; 831 832 struct qlink_tlv_frag_rts_thr { 833 struct qlink_tlv_hdr hdr; 834 __le16 thr; 835 } __packed; 836 837 struct qlink_tlv_rlimit { 838 struct qlink_tlv_hdr hdr; 839 u8 rlimit; 840 } __packed; 841 842 struct qlink_tlv_cclass { 843 struct qlink_tlv_hdr hdr; 844 u8 cclass; 845 } __packed; 846 847 enum qlink_dfs_state { 848 QLINK_DFS_USABLE, 849 QLINK_DFS_UNAVAILABLE, 850 QLINK_DFS_AVAILABLE, 851 }; 852 853 enum qlink_channel_flags { 854 QLINK_CHAN_DISABLED = BIT(0), 855 QLINK_CHAN_NO_IR = BIT(1), 856 QLINK_CHAN_RADAR = BIT(3), 857 QLINK_CHAN_NO_HT40PLUS = BIT(4), 858 QLINK_CHAN_NO_HT40MINUS = BIT(5), 859 QLINK_CHAN_NO_OFDM = BIT(6), 860 QLINK_CHAN_NO_80MHZ = BIT(7), 861 QLINK_CHAN_NO_160MHZ = BIT(8), 862 QLINK_CHAN_INDOOR_ONLY = BIT(9), 863 QLINK_CHAN_IR_CONCURRENT = BIT(10), 864 QLINK_CHAN_NO_20MHZ = BIT(11), 865 QLINK_CHAN_NO_10MHZ = BIT(12), 866 }; 867 868 struct qlink_tlv_channel { 869 struct qlink_tlv_hdr hdr; 870 __le16 hw_value; 871 __le16 center_freq; 872 __le32 flags; 873 u8 band; 874 u8 max_antenna_gain; 875 u8 max_power; 876 u8 max_reg_power; 877 __le32 dfs_cac_ms; 878 u8 dfs_state; 879 u8 beacon_found; 880 u8 rsvd[2]; 881 } __packed; 882 883 #define QLINK_MAX_NR_CIPHER_SUITES 5 884 #define QLINK_MAX_NR_AKM_SUITES 2 885 886 struct qlink_auth_encr { 887 __le32 wpa_versions; 888 __le32 cipher_group; 889 __le32 n_ciphers_pairwise; 890 __le32 ciphers_pairwise[QLINK_MAX_NR_CIPHER_SUITES]; 891 __le32 n_akm_suites; 892 __le32 akm_suites[QLINK_MAX_NR_AKM_SUITES]; 893 __le16 control_port_ethertype; 894 u8 auth_type; 895 u8 privacy; 896 u8 mfp; 897 u8 control_port; 898 u8 control_port_no_encrypt; 899 } __packed; 900 901 #endif /* _QTN_QLINK_H_ */ 902