cmd.h 14 KB

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