cmd.h 11 KB

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