wl1271_cmd.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
  5. * Copyright (C) 2009 Nokia Corporation
  6. *
  7. * Contact: Luciano Coelho <luciano.coelho@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 __WL1271_CMD_H__
  25. #define __WL1271_CMD_H__
  26. #include "wl1271.h"
  27. struct acx_header;
  28. int wl1271_cmd_send(struct wl1271 *wl, u16 type, void *buf, size_t buf_len);
  29. int wl1271_cmd_join(struct wl1271 *wl);
  30. int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
  31. int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
  32. int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
  33. int wl1271_cmd_data_path(struct wl1271 *wl, u8 channel, bool enable);
  34. int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode);
  35. int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
  36. size_t len);
  37. int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len,
  38. u8 active_scan, u8 high_prio, u8 band,
  39. u8 probe_requests);
  40. int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
  41. void *buf, size_t buf_len);
  42. int wl1271_cmd_build_null_data(struct wl1271 *wl);
  43. int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
  44. int wl1271_cmd_build_probe_req(struct wl1271 *wl, u8 *ssid, size_t ssid_len,
  45. u8 band);
  46. int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
  47. int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
  48. u8 key_size, const u8 *key, const u8 *addr,
  49. u32 tx_seq_32, u16 tx_seq_16);
  50. int wl1271_cmd_disconnect(struct wl1271 *wl);
  51. enum wl1271_commands {
  52. CMD_INTERROGATE = 1, /*use this to read information elements*/
  53. CMD_CONFIGURE = 2, /*use this to write information elements*/
  54. CMD_ENABLE_RX = 3,
  55. CMD_ENABLE_TX = 4,
  56. CMD_DISABLE_RX = 5,
  57. CMD_DISABLE_TX = 6,
  58. CMD_SCAN = 8,
  59. CMD_STOP_SCAN = 9,
  60. CMD_START_JOIN = 11,
  61. CMD_SET_KEYS = 12,
  62. CMD_READ_MEMORY = 13,
  63. CMD_WRITE_MEMORY = 14,
  64. CMD_SET_TEMPLATE = 19,
  65. CMD_TEST = 23,
  66. CMD_NOISE_HIST = 28,
  67. CMD_LNA_CONTROL = 32,
  68. CMD_SET_BCN_MODE = 33,
  69. CMD_MEASUREMENT = 34,
  70. CMD_STOP_MEASUREMENT = 35,
  71. CMD_DISCONNECT = 36,
  72. CMD_SET_PS_MODE = 37,
  73. CMD_CHANNEL_SWITCH = 38,
  74. CMD_STOP_CHANNEL_SWICTH = 39,
  75. CMD_AP_DISCOVERY = 40,
  76. CMD_STOP_AP_DISCOVERY = 41,
  77. CMD_SPS_SCAN = 42,
  78. CMD_STOP_SPS_SCAN = 43,
  79. CMD_HEALTH_CHECK = 45,
  80. CMD_DEBUG = 46,
  81. CMD_TRIGGER_SCAN_TO = 47,
  82. CMD_CONNECTION_SCAN_CFG = 48,
  83. CMD_CONNECTION_SCAN_SSID_CFG = 49,
  84. CMD_START_PERIODIC_SCAN = 50,
  85. CMD_STOP_PERIODIC_SCAN = 51,
  86. CMD_SET_STA_STATE = 52,
  87. NUM_COMMANDS,
  88. MAX_COMMAND_ID = 0xFFFF,
  89. };
  90. #define MAX_CMD_PARAMS 572
  91. enum cmd_templ {
  92. CMD_TEMPL_NULL_DATA = 0,
  93. CMD_TEMPL_BEACON,
  94. CMD_TEMPL_CFG_PROBE_REQ_2_4,
  95. CMD_TEMPL_CFG_PROBE_REQ_5,
  96. CMD_TEMPL_PROBE_RESPONSE,
  97. CMD_TEMPL_QOS_NULL_DATA,
  98. CMD_TEMPL_PS_POLL,
  99. CMD_TEMPL_KLV,
  100. CMD_TEMPL_DISCONNECT,
  101. CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
  102. CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
  103. CMD_TEMPL_BAR, /* for firmware internal use only */
  104. CMD_TEMPL_CTS, /*
  105. * For CTS-to-self (FastCTS) mechanism
  106. * for BT/WLAN coexistence (SoftGemini). */
  107. CMD_TEMPL_MAX = 0xff
  108. };
  109. /* unit ms */
  110. #define WL1271_COMMAND_TIMEOUT 2000
  111. #define WL1271_CMD_TEMPL_MAX_SIZE 252
  112. struct wl1271_cmd_header {
  113. __le16 id;
  114. __le16 status;
  115. /* payload */
  116. u8 data[0];
  117. } __attribute__ ((packed));
  118. #define WL1271_CMD_MAX_PARAMS 572
  119. struct wl1271_command {
  120. struct wl1271_cmd_header header;
  121. u8 parameters[WL1271_CMD_MAX_PARAMS];
  122. } __attribute__ ((packed));
  123. enum {
  124. CMD_MAILBOX_IDLE = 0,
  125. CMD_STATUS_SUCCESS = 1,
  126. CMD_STATUS_UNKNOWN_CMD = 2,
  127. CMD_STATUS_UNKNOWN_IE = 3,
  128. CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
  129. CMD_STATUS_RX_BUSY = 13,
  130. CMD_STATUS_INVALID_PARAM = 14,
  131. CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
  132. CMD_STATUS_OUT_OF_MEMORY = 16,
  133. CMD_STATUS_STA_TABLE_FULL = 17,
  134. CMD_STATUS_RADIO_ERROR = 18,
  135. CMD_STATUS_WRONG_NESTING = 19,
  136. CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
  137. CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
  138. MAX_COMMAND_STATUS = 0xff
  139. };
  140. /*
  141. * CMD_READ_MEMORY
  142. *
  143. * The host issues this command to read the WiLink device memory/registers.
  144. *
  145. * Note: The Base Band address has special handling (16 bits registers and
  146. * addresses). For more information, see the hardware specification.
  147. */
  148. /*
  149. * CMD_WRITE_MEMORY
  150. *
  151. * The host issues this command to write the WiLink device memory/registers.
  152. *
  153. * The Base Band address has special handling (16 bits registers and
  154. * addresses). For more information, see the hardware specification.
  155. */
  156. #define MAX_READ_SIZE 256
  157. struct cmd_read_write_memory {
  158. struct wl1271_cmd_header header;
  159. /* The address of the memory to read from or write to.*/
  160. __le32 addr;
  161. /* The amount of data in bytes to read from or write to the WiLink
  162. * device.*/
  163. __le32 size;
  164. /* The actual value read from or written to the Wilink. The source
  165. of this field is the Host in WRITE command or the Wilink in READ
  166. command. */
  167. u8 value[MAX_READ_SIZE];
  168. };
  169. #define CMDMBOX_HEADER_LEN 4
  170. #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
  171. enum {
  172. BSS_TYPE_IBSS = 0,
  173. BSS_TYPE_STA_BSS = 2,
  174. BSS_TYPE_AP_BSS = 3,
  175. MAX_BSS_TYPE = 0xFF
  176. };
  177. #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
  178. #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
  179. #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
  180. struct wl1271_cmd_join {
  181. struct wl1271_cmd_header header;
  182. __le32 bssid_lsb;
  183. __le16 bssid_msb;
  184. __le16 beacon_interval; /* in TBTTs */
  185. __le32 rx_config_options;
  186. __le32 rx_filter_options;
  187. /*
  188. * The target uses this field to determine the rate at
  189. * which to transmit control frame responses (such as
  190. * ACK or CTS frames).
  191. */
  192. __le32 basic_rate_set;
  193. u8 dtim_interval;
  194. /*
  195. * bits 0-2: This bitwise field specifies the type
  196. * of BSS to start or join (BSS_TYPE_*).
  197. * bit 4: Band - The radio band in which to join
  198. * or start.
  199. * 0 - 2.4GHz band
  200. * 1 - 5GHz band
  201. * bits 3, 5-7: Reserved
  202. */
  203. u8 bss_type;
  204. u8 channel;
  205. u8 ssid_len;
  206. u8 ssid[IW_ESSID_MAX_SIZE];
  207. u8 ctrl; /* JOIN_CMD_CTRL_* */
  208. u8 reserved[3];
  209. } __attribute__ ((packed));
  210. struct cmd_enabledisable_path {
  211. struct wl1271_cmd_header header;
  212. u8 channel;
  213. u8 padding[3];
  214. } __attribute__ ((packed));
  215. struct wl1271_cmd_template_set {
  216. struct wl1271_cmd_header header;
  217. __le16 len;
  218. u8 template_type;
  219. u8 index; /* relevant only for KLV_TEMPLATE type */
  220. __le32 enabled_rates;
  221. u8 short_retry_limit;
  222. u8 long_retry_limit;
  223. u8 aflags;
  224. u8 reserved;
  225. u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
  226. } __attribute__ ((packed));
  227. #define TIM_ELE_ID 5
  228. #define PARTIAL_VBM_MAX 251
  229. struct wl1271_tim {
  230. u8 identity;
  231. u8 length;
  232. u8 dtim_count;
  233. u8 dtim_period;
  234. u8 bitmap_ctrl;
  235. u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
  236. } __attribute__ ((packed));
  237. enum wl1271_cmd_ps_mode {
  238. STATION_ACTIVE_MODE,
  239. STATION_POWER_SAVE_MODE
  240. };
  241. struct wl1271_cmd_ps_params {
  242. struct wl1271_cmd_header header;
  243. u8 ps_mode; /* STATION_* */
  244. u8 send_null_data; /* Do we have to send NULL data packet ? */
  245. u8 retries; /* Number of retires for the initial NULL data packet */
  246. /*
  247. * TUs during which the target stays awake after switching
  248. * to power save mode.
  249. */
  250. u8 hang_over_period;
  251. __le32 null_data_rate;
  252. } __attribute__ ((packed));
  253. /* HW encryption keys */
  254. #define NUM_ACCESS_CATEGORIES_COPY 4
  255. #define MAX_KEY_SIZE 32
  256. enum wl1271_cmd_key_action {
  257. KEY_ADD_OR_REPLACE = 1,
  258. KEY_REMOVE = 2,
  259. KEY_SET_ID = 3,
  260. MAX_KEY_ACTION = 0xffff,
  261. };
  262. enum wl1271_cmd_key_type {
  263. KEY_NONE = 0,
  264. KEY_WEP = 1,
  265. KEY_TKIP = 2,
  266. KEY_AES = 3,
  267. KEY_GEM = 4
  268. };
  269. /* FIXME: Add description for key-types */
  270. struct wl1271_cmd_set_keys {
  271. struct wl1271_cmd_header header;
  272. /* Ignored for default WEP key */
  273. u8 addr[ETH_ALEN];
  274. /* key_action_e */
  275. __le16 key_action;
  276. __le16 reserved_1;
  277. /* key size in bytes */
  278. u8 key_size;
  279. /* key_type_e */
  280. u8 key_type;
  281. u8 ssid_profile;
  282. /*
  283. * TKIP, AES: frame's key id field.
  284. * For WEP default key: key id;
  285. */
  286. u8 id;
  287. u8 reserved_2[6];
  288. u8 key[MAX_KEY_SIZE];
  289. __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
  290. __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
  291. } __attribute__ ((packed));
  292. #define WL1271_SCAN_MAX_CHANNELS 24
  293. #define WL1271_SCAN_DEFAULT_TAG 1
  294. #define WL1271_SCAN_CURRENT_TX_PWR 0
  295. #define WL1271_SCAN_OPT_ACTIVE 0
  296. #define WL1271_SCAN_OPT_PASSIVE 1
  297. #define WL1271_SCAN_OPT_PRIORITY_HIGH 4
  298. #define WL1271_SCAN_CHAN_MIN_DURATION 30000 /* TU */
  299. #define WL1271_SCAN_CHAN_MAX_DURATION 60000 /* TU */
  300. #define WL1271_SCAN_BAND_2_4_GHZ 0
  301. #define WL1271_SCAN_BAND_5_GHZ 1
  302. #define WL1271_SCAN_BAND_DUAL 2
  303. struct basic_scan_params {
  304. __le32 rx_config_options;
  305. __le32 rx_filter_options;
  306. /* Scan option flags (WL1271_SCAN_OPT_*) */
  307. __le16 scan_options;
  308. /* Number of scan channels in the list (maximum 30) */
  309. u8 num_channels;
  310. /* This field indicates the number of probe requests to send
  311. per channel for an active scan */
  312. u8 num_probe_requests;
  313. /* Rate bit field for sending the probes */
  314. __le32 tx_rate;
  315. u8 tid_trigger;
  316. u8 ssid_len;
  317. /* in order to align */
  318. u8 padding1[2];
  319. u8 ssid[IW_ESSID_MAX_SIZE];
  320. /* Band to scan */
  321. u8 band;
  322. u8 use_ssid_list;
  323. u8 scan_tag;
  324. u8 padding2;
  325. } __attribute__ ((packed));
  326. struct basic_scan_channel_params {
  327. /* Duration in TU to wait for frames on a channel for active scan */
  328. __le32 min_duration;
  329. __le32 max_duration;
  330. __le32 bssid_lsb;
  331. __le16 bssid_msb;
  332. u8 early_termination;
  333. u8 tx_power_att;
  334. u8 channel;
  335. /* FW internal use only! */
  336. u8 dfs_candidate;
  337. u8 activity_detected;
  338. u8 pad;
  339. } __attribute__ ((packed));
  340. struct wl1271_cmd_scan {
  341. struct wl1271_cmd_header header;
  342. struct basic_scan_params params;
  343. struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
  344. } __attribute__ ((packed));
  345. struct wl1271_cmd_trigger_scan_to {
  346. struct wl1271_cmd_header header;
  347. __le32 timeout;
  348. };
  349. struct wl1271_cmd_test_header {
  350. u8 id;
  351. u8 padding[3];
  352. };
  353. enum wl1271_channel_tune_bands {
  354. WL1271_CHANNEL_TUNE_BAND_2_4,
  355. WL1271_CHANNEL_TUNE_BAND_5,
  356. WL1271_CHANNEL_TUNE_BAND_4_9
  357. };
  358. #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
  359. #define TEST_CMD_P2G_CAL 0x02
  360. #define TEST_CMD_CHANNEL_TUNE 0x0d
  361. #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
  362. struct wl1271_cmd_cal_channel_tune {
  363. struct wl1271_cmd_header header;
  364. struct wl1271_cmd_test_header test;
  365. u8 band;
  366. u8 channel;
  367. __le16 radio_status;
  368. } __attribute__ ((packed));
  369. struct wl1271_cmd_cal_update_ref_point {
  370. struct wl1271_cmd_header header;
  371. struct wl1271_cmd_test_header test;
  372. __le32 ref_power;
  373. __le32 ref_detector;
  374. u8 sub_band;
  375. u8 padding[3];
  376. } __attribute__ ((packed));
  377. #define MAX_TLV_LENGTH 400
  378. #define MAX_NVS_VERSION_LENGTH 12
  379. #define WL1271_CAL_P2G_BAND_B_G BIT(0)
  380. struct wl1271_cmd_cal_p2g {
  381. struct wl1271_cmd_header header;
  382. struct wl1271_cmd_test_header test;
  383. __le16 len;
  384. u8 buf[MAX_TLV_LENGTH];
  385. u8 type;
  386. u8 padding;
  387. __le16 radio_status;
  388. u8 nvs_version[MAX_NVS_VERSION_LENGTH];
  389. u8 sub_band_mask;
  390. u8 padding2;
  391. } __attribute__ ((packed));
  392. /*
  393. * There are three types of disconnections:
  394. *
  395. * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
  396. * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
  397. * we have passed
  398. * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
  399. * we have passed
  400. */
  401. enum wl1271_disconnect_type {
  402. DISCONNECT_IMMEDIATE,
  403. DISCONNECT_DEAUTH,
  404. DISCONNECT_DISASSOC
  405. };
  406. struct wl1271_cmd_disconnect {
  407. __le32 rx_config_options;
  408. __le32 rx_filter_options;
  409. __le16 reason;
  410. u8 type;
  411. u8 padding;
  412. } __attribute__ ((packed));
  413. #endif /* __WL1271_CMD_H__ */