wl1271_cmd.h 14 KB

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