qlink.h 28 KB

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