wl1271_cmd.h 14 KB

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