cmd.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * This file is part of wl1251
  4. *
  5. * Copyright (c) 1998-2007 Texas Instruments Incorporated
  6. * Copyright (C) 2008 Nokia Corporation
  7. */
  8. #ifndef __WL1251_CMD_H__
  9. #define __WL1251_CMD_H__
  10. #include "wl1251.h"
  11. #include <net/cfg80211.h>
  12. struct acx_header;
  13. int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len);
  14. int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len);
  15. int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len);
  16. int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity,
  17. void *bitmap, u16 bitmap_len, u8 bitmap_control);
  18. int wl1251_cmd_data_path_rx(struct wl1251 *wl, u8 channel, bool enable);
  19. int wl1251_cmd_data_path_tx(struct wl1251 *wl, u8 channel, bool enable);
  20. int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel,
  21. u16 beacon_interval, u8 dtim_interval);
  22. int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
  23. int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
  24. void *buf, size_t buf_len);
  25. int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len,
  26. struct ieee80211_channel *channels[],
  27. unsigned int n_channels, unsigned int n_probes);
  28. int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout);
  29. /* unit ms */
  30. #define WL1251_COMMAND_TIMEOUT 2000
  31. enum wl1251_commands {
  32. CMD_RESET = 0,
  33. CMD_INTERROGATE = 1, /*use this to read information elements*/
  34. CMD_CONFIGURE = 2, /*use this to write information elements*/
  35. CMD_ENABLE_RX = 3,
  36. CMD_ENABLE_TX = 4,
  37. CMD_DISABLE_RX = 5,
  38. CMD_DISABLE_TX = 6,
  39. CMD_SCAN = 8,
  40. CMD_STOP_SCAN = 9,
  41. CMD_VBM = 10,
  42. CMD_START_JOIN = 11,
  43. CMD_SET_KEYS = 12,
  44. CMD_READ_MEMORY = 13,
  45. CMD_WRITE_MEMORY = 14,
  46. CMD_BEACON = 19,
  47. CMD_PROBE_RESP = 20,
  48. CMD_NULL_DATA = 21,
  49. CMD_PROBE_REQ = 22,
  50. CMD_TEST = 23,
  51. CMD_RADIO_CALIBRATE = 25, /* OBSOLETE */
  52. CMD_ENABLE_RX_PATH = 27, /* OBSOLETE */
  53. CMD_NOISE_HIST = 28,
  54. CMD_RX_RESET = 29,
  55. CMD_PS_POLL = 30,
  56. CMD_QOS_NULL_DATA = 31,
  57. CMD_LNA_CONTROL = 32,
  58. CMD_SET_BCN_MODE = 33,
  59. CMD_MEASUREMENT = 34,
  60. CMD_STOP_MEASUREMENT = 35,
  61. CMD_DISCONNECT = 36,
  62. CMD_SET_PS_MODE = 37,
  63. CMD_CHANNEL_SWITCH = 38,
  64. CMD_STOP_CHANNEL_SWICTH = 39,
  65. CMD_AP_DISCOVERY = 40,
  66. CMD_STOP_AP_DISCOVERY = 41,
  67. CMD_SPS_SCAN = 42,
  68. CMD_STOP_SPS_SCAN = 43,
  69. CMD_HEALTH_CHECK = 45,
  70. CMD_DEBUG = 46,
  71. CMD_TRIGGER_SCAN_TO = 47,
  72. NUM_COMMANDS,
  73. MAX_COMMAND_ID = 0xFFFF,
  74. };
  75. #define MAX_CMD_PARAMS 572
  76. struct wl1251_cmd_header {
  77. u16 id;
  78. u16 status;
  79. } __packed;
  80. struct wl1251_command {
  81. struct wl1251_cmd_header header;
  82. u8 parameters[MAX_CMD_PARAMS];
  83. } __packed;
  84. enum {
  85. CMD_MAILBOX_IDLE = 0,
  86. CMD_STATUS_SUCCESS = 1,
  87. CMD_STATUS_UNKNOWN_CMD = 2,
  88. CMD_STATUS_UNKNOWN_IE = 3,
  89. CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
  90. CMD_STATUS_RX_BUSY = 13,
  91. CMD_STATUS_INVALID_PARAM = 14,
  92. CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
  93. CMD_STATUS_OUT_OF_MEMORY = 16,
  94. CMD_STATUS_STA_TABLE_FULL = 17,
  95. CMD_STATUS_RADIO_ERROR = 18,
  96. CMD_STATUS_WRONG_NESTING = 19,
  97. CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
  98. CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
  99. MAX_COMMAND_STATUS = 0xff
  100. };
  101. /*
  102. * CMD_READ_MEMORY
  103. *
  104. * The host issues this command to read the WiLink device memory/registers.
  105. *
  106. * Note: The Base Band address has special handling (16 bits registers and
  107. * addresses). For more information, see the hardware specification.
  108. */
  109. /*
  110. * CMD_WRITE_MEMORY
  111. *
  112. * The host issues this command to write the WiLink device memory/registers.
  113. *
  114. * The Base Band address has special handling (16 bits registers and
  115. * addresses). For more information, see the hardware specification.
  116. */
  117. #define MAX_READ_SIZE 256
  118. struct cmd_read_write_memory {
  119. struct wl1251_cmd_header header;
  120. /* The address of the memory to read from or write to.*/
  121. u32 addr;
  122. /* The amount of data in bytes to read from or write to the WiLink
  123. * device.*/
  124. u32 size;
  125. /* The actual value read from or written to the Wilink. The source
  126. of this field is the Host in WRITE command or the Wilink in READ
  127. command. */
  128. u8 value[MAX_READ_SIZE];
  129. } __packed;
  130. #define CMDMBOX_HEADER_LEN 4
  131. #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
  132. #define WL1251_SCAN_OPT_PASSIVE 1
  133. #define WL1251_SCAN_OPT_5GHZ_BAND 2
  134. #define WL1251_SCAN_OPT_TRIGGERD_SCAN 4
  135. #define WL1251_SCAN_OPT_PRIORITY_HIGH 8
  136. #define WL1251_SCAN_MIN_DURATION 30000
  137. #define WL1251_SCAN_MAX_DURATION 60000
  138. #define WL1251_SCAN_NUM_PROBES 3
  139. struct wl1251_scan_parameters {
  140. __le32 rx_config_options;
  141. __le32 rx_filter_options;
  142. /*
  143. * Scan options:
  144. * bit 0: When this bit is set, passive scan.
  145. * bit 1: Band, when this bit is set we scan
  146. * in the 5Ghz band.
  147. * bit 2: voice mode, 0 for normal scan.
  148. * bit 3: scan priority, 1 for high priority.
  149. */
  150. __le16 scan_options;
  151. /* Number of channels to scan */
  152. u8 num_channels;
  153. /* Number opf probe requests to send, per channel */
  154. u8 num_probe_requests;
  155. /* Rate and modulation for probe requests */
  156. __le16 tx_rate;
  157. u8 tid_trigger;
  158. u8 ssid_len;
  159. u8 ssid[32];
  160. } __packed;
  161. struct wl1251_scan_ch_parameters {
  162. __le32 min_duration; /* in TU */
  163. __le32 max_duration; /* in TU */
  164. u32 bssid_lsb;
  165. u16 bssid_msb;
  166. /*
  167. * bits 0-3: Early termination count.
  168. * bits 4-5: Early termination condition.
  169. */
  170. u8 early_termination;
  171. u8 tx_power_att;
  172. u8 channel;
  173. u8 pad[3];
  174. } __packed;
  175. /* SCAN parameters */
  176. #define SCAN_MAX_NUM_OF_CHANNELS 16
  177. struct wl1251_cmd_scan {
  178. struct wl1251_cmd_header header;
  179. struct wl1251_scan_parameters params;
  180. struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
  181. } __packed;
  182. enum {
  183. BSS_TYPE_IBSS = 0,
  184. BSS_TYPE_STA_BSS = 2,
  185. BSS_TYPE_AP_BSS = 3,
  186. MAX_BSS_TYPE = 0xFF
  187. };
  188. #define JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
  189. #define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE 0x01 /* Early wakeup time */
  190. struct cmd_join {
  191. struct wl1251_cmd_header header;
  192. u32 bssid_lsb;
  193. u16 bssid_msb;
  194. u16 beacon_interval; /* in TBTTs */
  195. u32 rx_config_options;
  196. u32 rx_filter_options;
  197. /*
  198. * The target uses this field to determine the rate at
  199. * which to transmit control frame responses (such as
  200. * ACK or CTS frames).
  201. */
  202. u16 basic_rate_set;
  203. u8 dtim_interval;
  204. u8 tx_ctrl_frame_rate; /* OBSOLETE */
  205. u8 tx_ctrl_frame_mod; /* OBSOLETE */
  206. /*
  207. * bits 0-2: This bitwise field specifies the type
  208. * of BSS to start or join (BSS_TYPE_*).
  209. * bit 4: Band - The radio band in which to join
  210. * or start.
  211. * 0 - 2.4GHz band
  212. * 1 - 5GHz band
  213. * bits 3, 5-7: Reserved
  214. */
  215. u8 bss_type;
  216. u8 channel;
  217. u8 ssid_len;
  218. u8 ssid[IEEE80211_MAX_SSID_LEN];
  219. u8 ctrl; /* JOIN_CMD_CTRL_* */
  220. u8 tx_mgt_frame_rate; /* OBSOLETE */
  221. u8 tx_mgt_frame_mod; /* OBSOLETE */
  222. u8 reserved;
  223. } __packed;
  224. struct cmd_enabledisable_path {
  225. struct wl1251_cmd_header header;
  226. u8 channel;
  227. u8 padding[3];
  228. } __packed;
  229. #define WL1251_MAX_TEMPLATE_SIZE 300
  230. struct wl1251_cmd_packet_template {
  231. struct wl1251_cmd_header header;
  232. __le16 size;
  233. u8 data[];
  234. } __packed;
  235. #define TIM_ELE_ID 5
  236. #define PARTIAL_VBM_MAX 251
  237. struct wl1251_tim {
  238. u8 identity;
  239. u8 length;
  240. u8 dtim_count;
  241. u8 dtim_period;
  242. u8 bitmap_ctrl;
  243. u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
  244. } __packed;
  245. /* Virtual Bit Map update */
  246. struct wl1251_cmd_vbm_update {
  247. struct wl1251_cmd_header header;
  248. __le16 len;
  249. u8 padding[2];
  250. struct wl1251_tim tim;
  251. } __packed;
  252. enum wl1251_cmd_ps_mode {
  253. CHIP_ACTIVE_MODE,
  254. CHIP_POWER_SAVE_MODE
  255. };
  256. struct wl1251_cmd_ps_params {
  257. struct wl1251_cmd_header header;
  258. u8 ps_mode; /* STATION_* */
  259. u8 send_null_data; /* Do we have to send NULL data packet ? */
  260. u8 retries; /* Number of retires for the initial NULL data packet */
  261. /*
  262. * TUs during which the target stays awake after switching
  263. * to power save mode.
  264. */
  265. u8 hang_over_period;
  266. u16 null_data_rate;
  267. u8 pad[2];
  268. } __packed;
  269. struct wl1251_cmd_trigger_scan_to {
  270. struct wl1251_cmd_header header;
  271. u32 timeout;
  272. } __packed;
  273. /* HW encryption keys */
  274. #define NUM_ACCESS_CATEGORIES_COPY 4
  275. #define MAX_KEY_SIZE 32
  276. /* When set, disable HW encryption */
  277. #define DF_ENCRYPTION_DISABLE 0x01
  278. /* When set, disable HW decryption */
  279. #define DF_SNIFF_MODE_ENABLE 0x80
  280. enum wl1251_cmd_key_action {
  281. KEY_ADD_OR_REPLACE = 1,
  282. KEY_REMOVE = 2,
  283. KEY_SET_ID = 3,
  284. MAX_KEY_ACTION = 0xffff,
  285. };
  286. enum wl1251_cmd_key_type {
  287. KEY_WEP_DEFAULT = 0,
  288. KEY_WEP_ADDR = 1,
  289. KEY_AES_GROUP = 4,
  290. KEY_AES_PAIRWISE = 5,
  291. KEY_WEP_GROUP = 6,
  292. KEY_TKIP_MIC_GROUP = 10,
  293. KEY_TKIP_MIC_PAIRWISE = 11,
  294. };
  295. /*
  296. *
  297. * key_type_e key size key format
  298. * ---------- --------- ----------
  299. * 0x00 5, 13, 29 Key data
  300. * 0x01 5, 13, 29 Key data
  301. * 0x04 16 16 bytes of key data
  302. * 0x05 16 16 bytes of key data
  303. * 0x0a 32 16 bytes of TKIP key data
  304. * 8 bytes of RX MIC key data
  305. * 8 bytes of TX MIC key data
  306. * 0x0b 32 16 bytes of TKIP key data
  307. * 8 bytes of RX MIC key data
  308. * 8 bytes of TX MIC key data
  309. *
  310. */
  311. struct wl1251_cmd_set_keys {
  312. struct wl1251_cmd_header header;
  313. /* Ignored for default WEP key */
  314. u8 addr[ETH_ALEN];
  315. /* key_action_e */
  316. u16 key_action;
  317. u16 reserved_1;
  318. /* key size in bytes */
  319. u8 key_size;
  320. /* key_type_e */
  321. u8 key_type;
  322. u8 ssid_profile;
  323. /*
  324. * TKIP, AES: frame's key id field.
  325. * For WEP default key: key id;
  326. */
  327. u8 id;
  328. u8 reserved_2[6];
  329. u8 key[MAX_KEY_SIZE];
  330. u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
  331. u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
  332. } __packed;
  333. #endif /* __WL1251_CMD_H__ */