wl1271_cmd.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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_template_set(struct wl1271 *wl, u16 template_id,
  41. void *buf, size_t buf_len, int index, u32 rates);
  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,
  45. const u8 *ssid, size_t ssid_len,
  46. const u8 *ie, size_t ie_len, u8 band);
  47. int wl1271_build_qos_null_data(struct wl1271 *wl);
  48. int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
  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 {
  95. CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
  96. CMD_TEMPL_KLV_IDX_MAX = 4
  97. };
  98. enum cmd_templ {
  99. CMD_TEMPL_NULL_DATA = 0,
  100. CMD_TEMPL_BEACON,
  101. CMD_TEMPL_CFG_PROBE_REQ_2_4,
  102. CMD_TEMPL_CFG_PROBE_REQ_5,
  103. CMD_TEMPL_PROBE_RESPONSE,
  104. CMD_TEMPL_QOS_NULL_DATA,
  105. CMD_TEMPL_PS_POLL,
  106. CMD_TEMPL_KLV,
  107. CMD_TEMPL_DISCONNECT,
  108. CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
  109. CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
  110. CMD_TEMPL_BAR, /* for firmware internal use only */
  111. CMD_TEMPL_CTS, /*
  112. * For CTS-to-self (FastCTS) mechanism
  113. * for BT/WLAN coexistence (SoftGemini). */
  114. CMD_TEMPL_MAX = 0xff
  115. };
  116. /* unit ms */
  117. #define WL1271_COMMAND_TIMEOUT 2000
  118. #define WL1271_CMD_TEMPL_MAX_SIZE 252
  119. #define WL1271_EVENT_TIMEOUT 750
  120. struct wl1271_cmd_header {
  121. __le16 id;
  122. __le16 status;
  123. /* payload */
  124. u8 data[0];
  125. } __packed;
  126. #define WL1271_CMD_MAX_PARAMS 572
  127. struct wl1271_command {
  128. struct wl1271_cmd_header header;
  129. u8 parameters[WL1271_CMD_MAX_PARAMS];
  130. } __packed;
  131. enum {
  132. CMD_MAILBOX_IDLE = 0,
  133. CMD_STATUS_SUCCESS = 1,
  134. CMD_STATUS_UNKNOWN_CMD = 2,
  135. CMD_STATUS_UNKNOWN_IE = 3,
  136. CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
  137. CMD_STATUS_RX_BUSY = 13,
  138. CMD_STATUS_INVALID_PARAM = 14,
  139. CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
  140. CMD_STATUS_OUT_OF_MEMORY = 16,
  141. CMD_STATUS_STA_TABLE_FULL = 17,
  142. CMD_STATUS_RADIO_ERROR = 18,
  143. CMD_STATUS_WRONG_NESTING = 19,
  144. CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
  145. CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
  146. MAX_COMMAND_STATUS = 0xff
  147. };
  148. /*
  149. * CMD_READ_MEMORY
  150. *
  151. * The host issues this command to read the WiLink device memory/registers.
  152. *
  153. * Note: The Base Band address has special handling (16 bits registers and
  154. * addresses). For more information, see the hardware specification.
  155. */
  156. /*
  157. * CMD_WRITE_MEMORY
  158. *
  159. * The host issues this command to write the WiLink device memory/registers.
  160. *
  161. * The Base Band address has special handling (16 bits registers and
  162. * addresses). For more information, see the hardware specification.
  163. */
  164. #define MAX_READ_SIZE 256
  165. struct cmd_read_write_memory {
  166. struct wl1271_cmd_header header;
  167. /* The address of the memory to read from or write to.*/
  168. __le32 addr;
  169. /* The amount of data in bytes to read from or write to the WiLink
  170. * device.*/
  171. __le32 size;
  172. /* The actual value read from or written to the Wilink. The source
  173. of this field is the Host in WRITE command or the Wilink in READ
  174. command. */
  175. u8 value[MAX_READ_SIZE];
  176. } __packed;
  177. #define CMDMBOX_HEADER_LEN 4
  178. #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
  179. enum {
  180. BSS_TYPE_IBSS = 0,
  181. BSS_TYPE_STA_BSS = 2,
  182. BSS_TYPE_AP_BSS = 3,
  183. MAX_BSS_TYPE = 0xFF
  184. };
  185. #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
  186. #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
  187. #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
  188. struct wl1271_cmd_join {
  189. struct wl1271_cmd_header header;
  190. __le32 bssid_lsb;
  191. __le16 bssid_msb;
  192. __le16 beacon_interval; /* in TBTTs */
  193. __le32 rx_config_options;
  194. __le32 rx_filter_options;
  195. /*
  196. * The target uses this field to determine the rate at
  197. * which to transmit control frame responses (such as
  198. * ACK or CTS frames).
  199. */
  200. __le32 basic_rate_set;
  201. u8 dtim_interval;
  202. /*
  203. * bits 0-2: This bitwise field specifies the type
  204. * of BSS to start or join (BSS_TYPE_*).
  205. * bit 4: Band - The radio band in which to join
  206. * or start.
  207. * 0 - 2.4GHz band
  208. * 1 - 5GHz band
  209. * bits 3, 5-7: Reserved
  210. */
  211. u8 bss_type;
  212. u8 channel;
  213. u8 ssid_len;
  214. u8 ssid[IW_ESSID_MAX_SIZE];
  215. u8 ctrl; /* JOIN_CMD_CTRL_* */
  216. u8 reserved[3];
  217. } __packed;
  218. struct cmd_enabledisable_path {
  219. struct wl1271_cmd_header header;
  220. u8 channel;
  221. u8 padding[3];
  222. } __packed;
  223. #define WL1271_RATE_AUTOMATIC 0
  224. struct wl1271_cmd_template_set {
  225. struct wl1271_cmd_header header;
  226. __le16 len;
  227. u8 template_type;
  228. u8 index; /* relevant only for KLV_TEMPLATE type */
  229. __le32 enabled_rates;
  230. u8 short_retry_limit;
  231. u8 long_retry_limit;
  232. u8 aflags;
  233. u8 reserved;
  234. u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
  235. } __packed;
  236. #define TIM_ELE_ID 5
  237. #define PARTIAL_VBM_MAX 251
  238. struct wl1271_tim {
  239. u8 identity;
  240. u8 length;
  241. u8 dtim_count;
  242. u8 dtim_period;
  243. u8 bitmap_ctrl;
  244. u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
  245. } __packed;
  246. enum wl1271_cmd_ps_mode {
  247. STATION_ACTIVE_MODE,
  248. STATION_POWER_SAVE_MODE
  249. };
  250. struct wl1271_cmd_ps_params {
  251. struct wl1271_cmd_header header;
  252. u8 ps_mode; /* STATION_* */
  253. u8 send_null_data; /* Do we have to send NULL data packet ? */
  254. u8 retries; /* Number of retires for the initial NULL data packet */
  255. /*
  256. * TUs during which the target stays awake after switching
  257. * to power save mode.
  258. */
  259. u8 hang_over_period;
  260. __le32 null_data_rate;
  261. } __packed;
  262. /* HW encryption keys */
  263. #define NUM_ACCESS_CATEGORIES_COPY 4
  264. #define MAX_KEY_SIZE 32
  265. enum wl1271_cmd_key_action {
  266. KEY_ADD_OR_REPLACE = 1,
  267. KEY_REMOVE = 2,
  268. KEY_SET_ID = 3,
  269. MAX_KEY_ACTION = 0xffff,
  270. };
  271. enum wl1271_cmd_key_type {
  272. KEY_NONE = 0,
  273. KEY_WEP = 1,
  274. KEY_TKIP = 2,
  275. KEY_AES = 3,
  276. KEY_GEM = 4
  277. };
  278. /* FIXME: Add description for key-types */
  279. struct wl1271_cmd_set_keys {
  280. struct wl1271_cmd_header header;
  281. /* Ignored for default WEP key */
  282. u8 addr[ETH_ALEN];
  283. /* key_action_e */
  284. __le16 key_action;
  285. __le16 reserved_1;
  286. /* key size in bytes */
  287. u8 key_size;
  288. /* key_type_e */
  289. u8 key_type;
  290. u8 ssid_profile;
  291. /*
  292. * TKIP, AES: frame's key id field.
  293. * For WEP default key: key id;
  294. */
  295. u8 id;
  296. u8 reserved_2[6];
  297. u8 key[MAX_KEY_SIZE];
  298. __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
  299. __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
  300. } __packed;
  301. struct wl1271_cmd_test_header {
  302. u8 id;
  303. u8 padding[3];
  304. } __packed;
  305. enum wl1271_channel_tune_bands {
  306. WL1271_CHANNEL_TUNE_BAND_2_4,
  307. WL1271_CHANNEL_TUNE_BAND_5,
  308. WL1271_CHANNEL_TUNE_BAND_4_9
  309. };
  310. #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
  311. #define TEST_CMD_P2G_CAL 0x02
  312. #define TEST_CMD_CHANNEL_TUNE 0x0d
  313. #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
  314. #define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
  315. #define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
  316. struct wl1271_general_parms_cmd {
  317. struct wl1271_cmd_header header;
  318. struct wl1271_cmd_test_header test;
  319. struct wl1271_ini_general_params general_params;
  320. u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
  321. u8 sr_sen_n_p;
  322. u8 sr_sen_n_p_gain;
  323. u8 sr_sen_nrn;
  324. u8 sr_sen_prn;
  325. u8 padding[3];
  326. } __packed;
  327. struct wl1271_radio_parms_cmd {
  328. struct wl1271_cmd_header header;
  329. struct wl1271_cmd_test_header test;
  330. /* Static radio parameters */
  331. struct wl1271_ini_band_params_2 static_params_2;
  332. struct wl1271_ini_band_params_5 static_params_5;
  333. /* Dynamic radio parameters */
  334. struct wl1271_ini_fem_params_2 dyn_params_2;
  335. u8 padding2;
  336. struct wl1271_ini_fem_params_5 dyn_params_5;
  337. u8 padding3[2];
  338. } __packed;
  339. struct wl1271_cmd_cal_channel_tune {
  340. struct wl1271_cmd_header header;
  341. struct wl1271_cmd_test_header test;
  342. u8 band;
  343. u8 channel;
  344. __le16 radio_status;
  345. } __packed;
  346. struct wl1271_cmd_cal_update_ref_point {
  347. struct wl1271_cmd_header header;
  348. struct wl1271_cmd_test_header test;
  349. __le32 ref_power;
  350. __le32 ref_detector;
  351. u8 sub_band;
  352. u8 padding[3];
  353. } __packed;
  354. #define MAX_TLV_LENGTH 400
  355. #define MAX_NVS_VERSION_LENGTH 12
  356. #define WL1271_CAL_P2G_BAND_B_G BIT(0)
  357. struct wl1271_cmd_cal_p2g {
  358. struct wl1271_cmd_header header;
  359. struct wl1271_cmd_test_header test;
  360. __le16 len;
  361. u8 buf[MAX_TLV_LENGTH];
  362. u8 type;
  363. u8 padding;
  364. __le16 radio_status;
  365. u8 nvs_version[MAX_NVS_VERSION_LENGTH];
  366. u8 sub_band_mask;
  367. u8 padding2;
  368. } __packed;
  369. /*
  370. * There are three types of disconnections:
  371. *
  372. * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
  373. * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
  374. * we have passed
  375. * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
  376. * we have passed
  377. */
  378. enum wl1271_disconnect_type {
  379. DISCONNECT_IMMEDIATE,
  380. DISCONNECT_DEAUTH,
  381. DISCONNECT_DISASSOC
  382. };
  383. struct wl1271_cmd_disconnect {
  384. struct wl1271_cmd_header header;
  385. __le32 rx_config_options;
  386. __le32 rx_filter_options;
  387. __le16 reason;
  388. u8 type;
  389. u8 padding;
  390. } __packed;
  391. #endif /* __WL1271_CMD_H__ */