wl1251_cmd.h 10 KB

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