wl1271_cmd.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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, u8 bss_type, u8 dtim_interval,
  30. u16 beacon_interval, u8 wait);
  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 num_channels,
  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. 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. enum wl1271_commands {
  50. CMD_INTERROGATE = 1, /*use this to read information elements*/
  51. CMD_CONFIGURE = 2, /*use this to write information elements*/
  52. CMD_ENABLE_RX = 3,
  53. CMD_ENABLE_TX = 4,
  54. CMD_DISABLE_RX = 5,
  55. CMD_DISABLE_TX = 6,
  56. CMD_SCAN = 8,
  57. CMD_STOP_SCAN = 9,
  58. CMD_START_JOIN = 11,
  59. CMD_SET_KEYS = 12,
  60. CMD_READ_MEMORY = 13,
  61. CMD_WRITE_MEMORY = 14,
  62. CMD_SET_TEMPLATE = 19,
  63. CMD_TEST = 23,
  64. CMD_NOISE_HIST = 28,
  65. CMD_LNA_CONTROL = 32,
  66. CMD_SET_BCN_MODE = 33,
  67. CMD_MEASUREMENT = 34,
  68. CMD_STOP_MEASUREMENT = 35,
  69. CMD_DISCONNECT = 36,
  70. CMD_SET_PS_MODE = 37,
  71. CMD_CHANNEL_SWITCH = 38,
  72. CMD_STOP_CHANNEL_SWICTH = 39,
  73. CMD_AP_DISCOVERY = 40,
  74. CMD_STOP_AP_DISCOVERY = 41,
  75. CMD_SPS_SCAN = 42,
  76. CMD_STOP_SPS_SCAN = 43,
  77. CMD_HEALTH_CHECK = 45,
  78. CMD_DEBUG = 46,
  79. CMD_TRIGGER_SCAN_TO = 47,
  80. CMD_CONNECTION_SCAN_CFG = 48,
  81. CMD_CONNECTION_SCAN_SSID_CFG = 49,
  82. CMD_START_PERIODIC_SCAN = 50,
  83. CMD_STOP_PERIODIC_SCAN = 51,
  84. CMD_SET_STA_STATE = 52,
  85. NUM_COMMANDS,
  86. MAX_COMMAND_ID = 0xFFFF,
  87. };
  88. #define MAX_CMD_PARAMS 572
  89. enum cmd_templ {
  90. CMD_TEMPL_NULL_DATA = 0,
  91. CMD_TEMPL_BEACON,
  92. CMD_TEMPL_CFG_PROBE_REQ_2_4,
  93. CMD_TEMPL_CFG_PROBE_REQ_5,
  94. CMD_TEMPL_PROBE_RESPONSE,
  95. CMD_TEMPL_QOS_NULL_DATA,
  96. CMD_TEMPL_PS_POLL,
  97. CMD_TEMPL_KLV,
  98. CMD_TEMPL_DISCONNECT,
  99. CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
  100. CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
  101. CMD_TEMPL_BAR, /* for firmware internal use only */
  102. CMD_TEMPL_CTS, /*
  103. * For CTS-to-self (FastCTS) mechanism
  104. * for BT/WLAN coexistence (SoftGemini). */
  105. CMD_TEMPL_MAX = 0xff
  106. };
  107. /* unit ms */
  108. #define WL1271_COMMAND_TIMEOUT 2000
  109. #define WL1271_CMD_TEMPL_MAX_SIZE 252
  110. struct wl1271_cmd_header {
  111. u16 id;
  112. u16 status;
  113. /* payload */
  114. u8 data[0];
  115. } __attribute__ ((packed));
  116. #define WL1271_CMD_MAX_PARAMS 572
  117. struct wl1271_command {
  118. struct wl1271_cmd_header header;
  119. u8 parameters[WL1271_CMD_MAX_PARAMS];
  120. } __attribute__ ((packed));
  121. enum {
  122. CMD_MAILBOX_IDLE = 0,
  123. CMD_STATUS_SUCCESS = 1,
  124. CMD_STATUS_UNKNOWN_CMD = 2,
  125. CMD_STATUS_UNKNOWN_IE = 3,
  126. CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
  127. CMD_STATUS_RX_BUSY = 13,
  128. CMD_STATUS_INVALID_PARAM = 14,
  129. CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
  130. CMD_STATUS_OUT_OF_MEMORY = 16,
  131. CMD_STATUS_STA_TABLE_FULL = 17,
  132. CMD_STATUS_RADIO_ERROR = 18,
  133. CMD_STATUS_WRONG_NESTING = 19,
  134. CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
  135. CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
  136. MAX_COMMAND_STATUS = 0xff
  137. };
  138. /*
  139. * CMD_READ_MEMORY
  140. *
  141. * The host issues this command to read the WiLink device memory/registers.
  142. *
  143. * Note: The Base Band address has special handling (16 bits registers and
  144. * addresses). For more information, see the hardware specification.
  145. */
  146. /*
  147. * CMD_WRITE_MEMORY
  148. *
  149. * The host issues this command to write the WiLink device memory/registers.
  150. *
  151. * The Base Band address has special handling (16 bits registers and
  152. * addresses). For more information, see the hardware specification.
  153. */
  154. #define MAX_READ_SIZE 256
  155. struct cmd_read_write_memory {
  156. struct wl1271_cmd_header header;
  157. /* The address of the memory to read from or write to.*/
  158. u32 addr;
  159. /* The amount of data in bytes to read from or write to the WiLink
  160. * device.*/
  161. u32 size;
  162. /* The actual value read from or written to the Wilink. The source
  163. of this field is the Host in WRITE command or the Wilink in READ
  164. command. */
  165. u8 value[MAX_READ_SIZE];
  166. };
  167. #define CMDMBOX_HEADER_LEN 4
  168. #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
  169. enum {
  170. BSS_TYPE_IBSS = 0,
  171. BSS_TYPE_STA_BSS = 2,
  172. BSS_TYPE_AP_BSS = 3,
  173. MAX_BSS_TYPE = 0xFF
  174. };
  175. #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
  176. #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
  177. struct wl1271_cmd_join {
  178. struct wl1271_cmd_header header;
  179. u32 bssid_lsb;
  180. u16 bssid_msb;
  181. u16 beacon_interval; /* in TBTTs */
  182. u32 rx_config_options;
  183. u32 rx_filter_options;
  184. /*
  185. * The target uses this field to determine the rate at
  186. * which to transmit control frame responses (such as
  187. * ACK or CTS frames).
  188. */
  189. u32 basic_rate_set;
  190. u8 dtim_interval;
  191. /*
  192. * bits 0-2: This bitwise field specifies the type
  193. * of BSS to start or join (BSS_TYPE_*).
  194. * bit 4: Band - The radio band in which to join
  195. * or start.
  196. * 0 - 2.4GHz band
  197. * 1 - 5GHz band
  198. * bits 3, 5-7: Reserved
  199. */
  200. u8 bss_type;
  201. u8 channel;
  202. u8 ssid_len;
  203. u8 ssid[IW_ESSID_MAX_SIZE];
  204. u8 ctrl; /* JOIN_CMD_CTRL_* */
  205. u8 reserved[3];
  206. } __attribute__ ((packed));
  207. struct cmd_enabledisable_path {
  208. struct wl1271_cmd_header header;
  209. u8 channel;
  210. u8 padding[3];
  211. } __attribute__ ((packed));
  212. struct wl1271_cmd_template_set {
  213. struct wl1271_cmd_header header;
  214. u16 len;
  215. u8 template_type;
  216. u8 index; /* relevant only for KLV_TEMPLATE type */
  217. u32 enabled_rates;
  218. u8 short_retry_limit;
  219. u8 long_retry_limit;
  220. u8 aflags;
  221. u8 reserved;
  222. u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
  223. } __attribute__ ((packed));
  224. #define TIM_ELE_ID 5
  225. #define PARTIAL_VBM_MAX 251
  226. struct wl1271_tim {
  227. u8 identity;
  228. u8 length;
  229. u8 dtim_count;
  230. u8 dtim_period;
  231. u8 bitmap_ctrl;
  232. u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
  233. } __attribute__ ((packed));
  234. enum wl1271_cmd_ps_mode {
  235. STATION_ACTIVE_MODE,
  236. STATION_POWER_SAVE_MODE
  237. };
  238. struct wl1271_cmd_ps_params {
  239. struct wl1271_cmd_header header;
  240. u8 ps_mode; /* STATION_* */
  241. u8 send_null_data; /* Do we have to send NULL data packet ? */
  242. u8 retries; /* Number of retires for the initial NULL data packet */
  243. /*
  244. * TUs during which the target stays awake after switching
  245. * to power save mode.
  246. */
  247. u8 hang_over_period;
  248. u32 null_data_rate;
  249. } __attribute__ ((packed));
  250. /* HW encryption keys */
  251. #define NUM_ACCESS_CATEGORIES_COPY 4
  252. #define MAX_KEY_SIZE 32
  253. /* When set, disable HW encryption */
  254. #define DF_ENCRYPTION_DISABLE 0x01
  255. /* When set, disable HW decryption */
  256. #define DF_SNIFF_MODE_ENABLE 0x80
  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. u16 key_action;
  277. u16 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. u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
  291. u32 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. struct basic_scan_params {
  302. u32 rx_config_options;
  303. u32 rx_filter_options;
  304. /* Scan option flags (WL1271_SCAN_OPT_*) */
  305. u16 scan_options;
  306. /* Number of scan channels in the list (maximum 30) */
  307. u8 num_channels;
  308. /* This field indicates the number of probe requests to send
  309. per channel for an active scan */
  310. u8 num_probe_requests;
  311. /* Rate bit field for sending the probes */
  312. u32 tx_rate;
  313. u8 tid_trigger;
  314. u8 ssid_len;
  315. /* in order to align */
  316. u8 padding1[2];
  317. u8 ssid[IW_ESSID_MAX_SIZE];
  318. /* Band to scan */
  319. u8 band;
  320. u8 use_ssid_list;
  321. u8 scan_tag;
  322. u8 padding2;
  323. } __attribute__ ((packed));
  324. struct basic_scan_channel_params {
  325. /* Duration in TU to wait for frames on a channel for active scan */
  326. u32 min_duration;
  327. u32 max_duration;
  328. u32 bssid_lsb;
  329. u16 bssid_msb;
  330. u8 early_termination;
  331. u8 tx_power_att;
  332. u8 channel;
  333. /* FW internal use only! */
  334. u8 dfs_candidate;
  335. u8 activity_detected;
  336. u8 pad;
  337. } __attribute__ ((packed));
  338. struct wl1271_cmd_scan {
  339. struct wl1271_cmd_header header;
  340. struct basic_scan_params params;
  341. struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
  342. } __attribute__ ((packed));
  343. struct wl1271_cmd_trigger_scan_to {
  344. struct wl1271_cmd_header header;
  345. u32 timeout;
  346. };
  347. struct wl1271_cmd_test_header {
  348. u8 id;
  349. u8 padding[3];
  350. };
  351. enum wl1271_channel_tune_bands {
  352. WL1271_CHANNEL_TUNE_BAND_2_4,
  353. WL1271_CHANNEL_TUNE_BAND_5,
  354. WL1271_CHANNEL_TUNE_BAND_4_9
  355. };
  356. #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
  357. #define TEST_CMD_P2G_CAL 0x02
  358. #define TEST_CMD_CHANNEL_TUNE 0x0d
  359. #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
  360. struct wl1271_cmd_cal_channel_tune {
  361. struct wl1271_cmd_header header;
  362. struct wl1271_cmd_test_header test;
  363. u8 band;
  364. u8 channel;
  365. u16 radio_status;
  366. } __attribute__ ((packed));
  367. struct wl1271_cmd_cal_update_ref_point {
  368. struct wl1271_cmd_header header;
  369. struct wl1271_cmd_test_header test;
  370. s32 ref_power;
  371. s32 ref_detector;
  372. u8 sub_band;
  373. u8 padding[3];
  374. } __attribute__ ((packed));
  375. #define MAX_TLV_LENGTH 400
  376. #define MAX_NVS_VERSION_LENGTH 12
  377. #define WL1271_CAL_P2G_BAND_B_G BIT(0)
  378. struct wl1271_cmd_cal_p2g {
  379. struct wl1271_cmd_header header;
  380. struct wl1271_cmd_test_header test;
  381. u16 len;
  382. u8 buf[MAX_TLV_LENGTH];
  383. u8 type;
  384. u8 padding;
  385. s16 radio_status;
  386. u8 nvs_version[MAX_NVS_VERSION_LENGTH];
  387. u8 sub_band_mask;
  388. u8 padding2;
  389. } __attribute__ ((packed));
  390. #endif /* __WL1271_CMD_H__ */