wl1271_cmd.h 12 KB

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