cmd.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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 __CMD_H__
  25. #define __CMD_H__
  26. #include "wl12xx.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_ext_radio_parms(struct wl1271 *wl);
  33. int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type);
  34. int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
  35. int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
  36. int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
  37. int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
  38. int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, u32 rates, bool send);
  39. int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
  40. size_t len);
  41. int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
  42. void *buf, size_t buf_len, int index, u32 rates);
  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,
  46. const u8 *ssid, size_t ssid_len,
  47. const u8 *ie, size_t ie_len, u8 band);
  48. struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl,
  49. struct sk_buff *skb);
  50. int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr);
  51. int wl1271_build_qos_null_data(struct wl1271 *wl);
  52. int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
  53. int wl1271_cmd_set_sta_default_wep_key(struct wl1271 *wl, u8 id);
  54. int wl1271_cmd_set_ap_default_wep_key(struct wl1271 *wl, u8 id);
  55. int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
  56. u8 key_size, const u8 *key, const u8 *addr,
  57. u32 tx_seq_32, u16 tx_seq_16);
  58. int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
  59. u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32,
  60. u16 tx_seq_16);
  61. int wl1271_cmd_disconnect(struct wl1271 *wl);
  62. int wl1271_cmd_set_sta_state(struct wl1271 *wl);
  63. int wl1271_cmd_start_bss(struct wl1271 *wl);
  64. int wl1271_cmd_stop_bss(struct wl1271 *wl);
  65. int wl1271_cmd_add_sta(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid);
  66. int wl1271_cmd_remove_sta(struct wl1271 *wl, u8 hlid);
  67. enum wl1271_commands {
  68. CMD_INTERROGATE = 1, /*use this to read information elements*/
  69. CMD_CONFIGURE = 2, /*use this to write information elements*/
  70. CMD_ENABLE_RX = 3,
  71. CMD_ENABLE_TX = 4,
  72. CMD_DISABLE_RX = 5,
  73. CMD_DISABLE_TX = 6,
  74. CMD_SCAN = 8,
  75. CMD_STOP_SCAN = 9,
  76. CMD_START_JOIN = 11,
  77. CMD_SET_KEYS = 12,
  78. CMD_READ_MEMORY = 13,
  79. CMD_WRITE_MEMORY = 14,
  80. CMD_SET_TEMPLATE = 19,
  81. CMD_TEST = 23,
  82. CMD_NOISE_HIST = 28,
  83. CMD_LNA_CONTROL = 32,
  84. CMD_SET_BCN_MODE = 33,
  85. CMD_MEASUREMENT = 34,
  86. CMD_STOP_MEASUREMENT = 35,
  87. CMD_DISCONNECT = 36,
  88. CMD_SET_PS_MODE = 37,
  89. CMD_CHANNEL_SWITCH = 38,
  90. CMD_STOP_CHANNEL_SWICTH = 39,
  91. CMD_AP_DISCOVERY = 40,
  92. CMD_STOP_AP_DISCOVERY = 41,
  93. CMD_SPS_SCAN = 42,
  94. CMD_STOP_SPS_SCAN = 43,
  95. CMD_HEALTH_CHECK = 45,
  96. CMD_DEBUG = 46,
  97. CMD_TRIGGER_SCAN_TO = 47,
  98. CMD_CONNECTION_SCAN_CFG = 48,
  99. CMD_CONNECTION_SCAN_SSID_CFG = 49,
  100. CMD_START_PERIODIC_SCAN = 50,
  101. CMD_STOP_PERIODIC_SCAN = 51,
  102. CMD_SET_STA_STATE = 52,
  103. /* AP mode commands */
  104. CMD_BSS_START = 60,
  105. CMD_BSS_STOP = 61,
  106. CMD_ADD_STA = 62,
  107. CMD_REMOVE_STA = 63,
  108. NUM_COMMANDS,
  109. MAX_COMMAND_ID = 0xFFFF,
  110. };
  111. #define MAX_CMD_PARAMS 572
  112. enum {
  113. CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
  114. CMD_TEMPL_KLV_IDX_MAX = 4
  115. };
  116. enum cmd_templ {
  117. CMD_TEMPL_NULL_DATA = 0,
  118. CMD_TEMPL_BEACON,
  119. CMD_TEMPL_CFG_PROBE_REQ_2_4,
  120. CMD_TEMPL_CFG_PROBE_REQ_5,
  121. CMD_TEMPL_PROBE_RESPONSE,
  122. CMD_TEMPL_QOS_NULL_DATA,
  123. CMD_TEMPL_PS_POLL,
  124. CMD_TEMPL_KLV,
  125. CMD_TEMPL_DISCONNECT,
  126. CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
  127. CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
  128. CMD_TEMPL_BAR, /* for firmware internal use only */
  129. CMD_TEMPL_CTS, /*
  130. * For CTS-to-self (FastCTS) mechanism
  131. * for BT/WLAN coexistence (SoftGemini). */
  132. CMD_TEMPL_ARP_RSP,
  133. /* AP-mode specific */
  134. CMD_TEMPL_AP_BEACON = 13,
  135. CMD_TEMPL_AP_PROBE_RESPONSE,
  136. CMD_TEMPL_AP_ARP_RSP,
  137. CMD_TEMPL_DEAUTH_AP,
  138. CMD_TEMPL_MAX = 0xff
  139. };
  140. /* unit ms */
  141. #define WL1271_COMMAND_TIMEOUT 2000
  142. #define WL1271_CMD_TEMPL_MAX_SIZE 252
  143. #define WL1271_EVENT_TIMEOUT 750
  144. struct wl1271_cmd_header {
  145. __le16 id;
  146. __le16 status;
  147. /* payload */
  148. u8 data[0];
  149. } __packed;
  150. #define WL1271_CMD_MAX_PARAMS 572
  151. struct wl1271_command {
  152. struct wl1271_cmd_header header;
  153. u8 parameters[WL1271_CMD_MAX_PARAMS];
  154. } __packed;
  155. enum {
  156. CMD_MAILBOX_IDLE = 0,
  157. CMD_STATUS_SUCCESS = 1,
  158. CMD_STATUS_UNKNOWN_CMD = 2,
  159. CMD_STATUS_UNKNOWN_IE = 3,
  160. CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
  161. CMD_STATUS_RX_BUSY = 13,
  162. CMD_STATUS_INVALID_PARAM = 14,
  163. CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
  164. CMD_STATUS_OUT_OF_MEMORY = 16,
  165. CMD_STATUS_STA_TABLE_FULL = 17,
  166. CMD_STATUS_RADIO_ERROR = 18,
  167. CMD_STATUS_WRONG_NESTING = 19,
  168. CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
  169. CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
  170. MAX_COMMAND_STATUS = 0xff
  171. };
  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. } __packed;
  213. struct cmd_enabledisable_path {
  214. struct wl1271_cmd_header header;
  215. u8 channel;
  216. u8 padding[3];
  217. } __packed;
  218. #define WL1271_RATE_AUTOMATIC 0
  219. struct wl1271_cmd_template_set {
  220. struct wl1271_cmd_header header;
  221. __le16 len;
  222. u8 template_type;
  223. u8 index; /* relevant only for KLV_TEMPLATE type */
  224. __le32 enabled_rates;
  225. u8 short_retry_limit;
  226. u8 long_retry_limit;
  227. u8 aflags;
  228. u8 reserved;
  229. u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
  230. } __packed;
  231. #define TIM_ELE_ID 5
  232. #define PARTIAL_VBM_MAX 251
  233. struct wl1271_tim {
  234. u8 identity;
  235. u8 length;
  236. u8 dtim_count;
  237. u8 dtim_period;
  238. u8 bitmap_ctrl;
  239. u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
  240. } __packed;
  241. enum wl1271_cmd_ps_mode {
  242. STATION_ACTIVE_MODE,
  243. STATION_POWER_SAVE_MODE
  244. };
  245. struct wl1271_cmd_ps_params {
  246. struct wl1271_cmd_header header;
  247. u8 ps_mode; /* STATION_* */
  248. u8 send_null_data; /* Do we have to send NULL data packet ? */
  249. u8 retries; /* Number of retires for the initial NULL data packet */
  250. /*
  251. * TUs during which the target stays awake after switching
  252. * to power save mode.
  253. */
  254. u8 hang_over_period;
  255. __le32 null_data_rate;
  256. } __packed;
  257. /* HW encryption keys */
  258. #define NUM_ACCESS_CATEGORIES_COPY 4
  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_sta_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. } __packed;
  295. enum wl1271_cmd_lid_key_type {
  296. UNICAST_LID_TYPE = 0,
  297. BROADCAST_LID_TYPE = 1,
  298. WEP_DEFAULT_LID_TYPE = 2
  299. };
  300. struct wl1271_cmd_set_ap_keys {
  301. struct wl1271_cmd_header header;
  302. /*
  303. * Indicates whether the HLID is a unicast key set
  304. * or broadcast key set. A special value 0xFF is
  305. * used to indicate that the HLID is on WEP-default
  306. * (multi-hlids). of type wl1271_cmd_lid_key_type.
  307. */
  308. u8 hlid;
  309. /*
  310. * In WEP-default network (hlid == 0xFF) used to
  311. * indicate which network STA/IBSS/AP role should be
  312. * changed
  313. */
  314. u8 lid_key_type;
  315. /*
  316. * Key ID - For TKIP and AES key types, this field
  317. * indicates the value that should be inserted into
  318. * the KeyID field of frames transmitted using this
  319. * key entry. For broadcast keys the index use as a
  320. * marker for TX/RX key.
  321. * For WEP default network (HLID=0xFF), this field
  322. * indicates the ID of the key to add or remove.
  323. */
  324. u8 key_id;
  325. u8 reserved_1;
  326. /* key_action_e */
  327. __le16 key_action;
  328. /* key size in bytes */
  329. u8 key_size;
  330. /* key_type_e */
  331. u8 key_type;
  332. /* This field holds the security key data to add to the STA table */
  333. u8 key[MAX_KEY_SIZE];
  334. __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
  335. __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
  336. } __packed;
  337. struct wl1271_cmd_test_header {
  338. u8 id;
  339. u8 padding[3];
  340. } __packed;
  341. enum wl1271_channel_tune_bands {
  342. WL1271_CHANNEL_TUNE_BAND_2_4,
  343. WL1271_CHANNEL_TUNE_BAND_5,
  344. WL1271_CHANNEL_TUNE_BAND_4_9
  345. };
  346. #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
  347. #define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
  348. #define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
  349. #define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
  350. struct wl1271_general_parms_cmd {
  351. struct wl1271_cmd_header header;
  352. struct wl1271_cmd_test_header test;
  353. struct wl1271_ini_general_params general_params;
  354. u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
  355. u8 sr_sen_n_p;
  356. u8 sr_sen_n_p_gain;
  357. u8 sr_sen_nrn;
  358. u8 sr_sen_prn;
  359. u8 padding[3];
  360. } __packed;
  361. struct wl1271_radio_parms_cmd {
  362. struct wl1271_cmd_header header;
  363. struct wl1271_cmd_test_header test;
  364. /* Static radio parameters */
  365. struct wl1271_ini_band_params_2 static_params_2;
  366. struct wl1271_ini_band_params_5 static_params_5;
  367. /* Dynamic radio parameters */
  368. struct wl1271_ini_fem_params_2 dyn_params_2;
  369. u8 padding2;
  370. struct wl1271_ini_fem_params_5 dyn_params_5;
  371. u8 padding3[2];
  372. } __packed;
  373. struct wl1271_ext_radio_parms_cmd {
  374. struct wl1271_cmd_header header;
  375. struct wl1271_cmd_test_header test;
  376. u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
  377. u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
  378. u8 padding[3];
  379. } __packed;
  380. /*
  381. * There are three types of disconnections:
  382. *
  383. * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
  384. * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
  385. * we have passed
  386. * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
  387. * we have passed
  388. */
  389. enum wl1271_disconnect_type {
  390. DISCONNECT_IMMEDIATE,
  391. DISCONNECT_DEAUTH,
  392. DISCONNECT_DISASSOC
  393. };
  394. struct wl1271_cmd_disconnect {
  395. struct wl1271_cmd_header header;
  396. __le32 rx_config_options;
  397. __le32 rx_filter_options;
  398. __le16 reason;
  399. u8 type;
  400. u8 padding;
  401. } __packed;
  402. #define WL1271_CMD_STA_STATE_CONNECTED 1
  403. struct wl1271_cmd_set_sta_state {
  404. struct wl1271_cmd_header header;
  405. u8 state;
  406. u8 padding[3];
  407. } __packed;
  408. enum wl1271_ssid_type {
  409. SSID_TYPE_PUBLIC = 0,
  410. SSID_TYPE_HIDDEN = 1
  411. };
  412. struct wl1271_cmd_bss_start {
  413. struct wl1271_cmd_header header;
  414. /* wl1271_ssid_type */
  415. u8 ssid_type;
  416. u8 ssid_len;
  417. u8 ssid[IW_ESSID_MAX_SIZE];
  418. u8 padding_1[2];
  419. /* Basic rate set */
  420. __le32 basic_rate_set;
  421. /* Aging period in seconds*/
  422. __le16 aging_period;
  423. /*
  424. * This field specifies the time between target beacon
  425. * transmission times (TBTTs), in time units (TUs).
  426. * Valid values are 1 to 1024.
  427. */
  428. __le16 beacon_interval;
  429. u8 bssid[ETH_ALEN];
  430. u8 bss_index;
  431. /* Radio band */
  432. u8 band;
  433. u8 channel;
  434. /* The host link id for the AP's global queue */
  435. u8 global_hlid;
  436. /* The host link id for the AP's broadcast queue */
  437. u8 broadcast_hlid;
  438. /* DTIM count */
  439. u8 dtim_interval;
  440. /* Beacon expiry time in ms */
  441. u8 beacon_expiry;
  442. u8 padding_2[3];
  443. } __packed;
  444. struct wl1271_cmd_add_sta {
  445. struct wl1271_cmd_header header;
  446. u8 addr[ETH_ALEN];
  447. u8 hlid;
  448. u8 aid;
  449. u8 psd_type[NUM_ACCESS_CATEGORIES_COPY];
  450. __le32 supported_rates;
  451. u8 bss_index;
  452. u8 sp_len;
  453. u8 wmm;
  454. u8 padding1;
  455. } __packed;
  456. struct wl1271_cmd_remove_sta {
  457. struct wl1271_cmd_header header;
  458. u8 hlid;
  459. u8 reason_opcode;
  460. u8 send_deauth_flag;
  461. u8 padding1;
  462. } __packed;
  463. #endif /* __WL1271_CMD_H__ */