cmd.h 10 KB

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