wl1251_cmd.h 10 KB

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