cmd.h 9.9 KB

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