cmd.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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_default_wep_key(struct wl1271 *wl, u8 id);
  54. int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
  55. u8 key_size, const u8 *key, const u8 *addr,
  56. u32 tx_seq_32, u16 tx_seq_16);
  57. int wl1271_cmd_disconnect(struct wl1271 *wl);
  58. int wl1271_cmd_set_sta_state(struct wl1271 *wl);
  59. enum wl1271_commands {
  60. CMD_INTERROGATE = 1, /*use this to read information elements*/
  61. CMD_CONFIGURE = 2, /*use this to write information elements*/
  62. CMD_ENABLE_RX = 3,
  63. CMD_ENABLE_TX = 4,
  64. CMD_DISABLE_RX = 5,
  65. CMD_DISABLE_TX = 6,
  66. CMD_SCAN = 8,
  67. CMD_STOP_SCAN = 9,
  68. CMD_START_JOIN = 11,
  69. CMD_SET_KEYS = 12,
  70. CMD_READ_MEMORY = 13,
  71. CMD_WRITE_MEMORY = 14,
  72. CMD_SET_TEMPLATE = 19,
  73. CMD_TEST = 23,
  74. CMD_NOISE_HIST = 28,
  75. CMD_LNA_CONTROL = 32,
  76. CMD_SET_BCN_MODE = 33,
  77. CMD_MEASUREMENT = 34,
  78. CMD_STOP_MEASUREMENT = 35,
  79. CMD_DISCONNECT = 36,
  80. CMD_SET_PS_MODE = 37,
  81. CMD_CHANNEL_SWITCH = 38,
  82. CMD_STOP_CHANNEL_SWICTH = 39,
  83. CMD_AP_DISCOVERY = 40,
  84. CMD_STOP_AP_DISCOVERY = 41,
  85. CMD_SPS_SCAN = 42,
  86. CMD_STOP_SPS_SCAN = 43,
  87. CMD_HEALTH_CHECK = 45,
  88. CMD_DEBUG = 46,
  89. CMD_TRIGGER_SCAN_TO = 47,
  90. CMD_CONNECTION_SCAN_CFG = 48,
  91. CMD_CONNECTION_SCAN_SSID_CFG = 49,
  92. CMD_START_PERIODIC_SCAN = 50,
  93. CMD_STOP_PERIODIC_SCAN = 51,
  94. CMD_SET_STA_STATE = 52,
  95. NUM_COMMANDS,
  96. MAX_COMMAND_ID = 0xFFFF,
  97. };
  98. #define MAX_CMD_PARAMS 572
  99. enum {
  100. CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
  101. CMD_TEMPL_KLV_IDX_MAX = 4
  102. };
  103. enum cmd_templ {
  104. CMD_TEMPL_NULL_DATA = 0,
  105. CMD_TEMPL_BEACON,
  106. CMD_TEMPL_CFG_PROBE_REQ_2_4,
  107. CMD_TEMPL_CFG_PROBE_REQ_5,
  108. CMD_TEMPL_PROBE_RESPONSE,
  109. CMD_TEMPL_QOS_NULL_DATA,
  110. CMD_TEMPL_PS_POLL,
  111. CMD_TEMPL_KLV,
  112. CMD_TEMPL_DISCONNECT,
  113. CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
  114. CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
  115. CMD_TEMPL_BAR, /* for firmware internal use only */
  116. CMD_TEMPL_CTS, /*
  117. * For CTS-to-self (FastCTS) mechanism
  118. * for BT/WLAN coexistence (SoftGemini). */
  119. CMD_TEMPL_ARP_RSP,
  120. CMD_TEMPL_MAX = 0xff
  121. };
  122. /* unit ms */
  123. #define WL1271_COMMAND_TIMEOUT 2000
  124. #define WL1271_CMD_TEMPL_MAX_SIZE 252
  125. #define WL1271_EVENT_TIMEOUT 750
  126. struct wl1271_cmd_header {
  127. __le16 id;
  128. __le16 status;
  129. /* payload */
  130. u8 data[0];
  131. } __packed;
  132. #define WL1271_CMD_MAX_PARAMS 572
  133. struct wl1271_command {
  134. struct wl1271_cmd_header header;
  135. u8 parameters[WL1271_CMD_MAX_PARAMS];
  136. } __packed;
  137. enum {
  138. CMD_MAILBOX_IDLE = 0,
  139. CMD_STATUS_SUCCESS = 1,
  140. CMD_STATUS_UNKNOWN_CMD = 2,
  141. CMD_STATUS_UNKNOWN_IE = 3,
  142. CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
  143. CMD_STATUS_RX_BUSY = 13,
  144. CMD_STATUS_INVALID_PARAM = 14,
  145. CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
  146. CMD_STATUS_OUT_OF_MEMORY = 16,
  147. CMD_STATUS_STA_TABLE_FULL = 17,
  148. CMD_STATUS_RADIO_ERROR = 18,
  149. CMD_STATUS_WRONG_NESTING = 19,
  150. CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
  151. CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
  152. MAX_COMMAND_STATUS = 0xff
  153. };
  154. #define CMDMBOX_HEADER_LEN 4
  155. #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
  156. enum {
  157. BSS_TYPE_IBSS = 0,
  158. BSS_TYPE_STA_BSS = 2,
  159. BSS_TYPE_AP_BSS = 3,
  160. MAX_BSS_TYPE = 0xFF
  161. };
  162. #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
  163. #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
  164. #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
  165. struct wl1271_cmd_join {
  166. struct wl1271_cmd_header header;
  167. __le32 bssid_lsb;
  168. __le16 bssid_msb;
  169. __le16 beacon_interval; /* in TBTTs */
  170. __le32 rx_config_options;
  171. __le32 rx_filter_options;
  172. /*
  173. * The target uses this field to determine the rate at
  174. * which to transmit control frame responses (such as
  175. * ACK or CTS frames).
  176. */
  177. __le32 basic_rate_set;
  178. u8 dtim_interval;
  179. /*
  180. * bits 0-2: This bitwise field specifies the type
  181. * of BSS to start or join (BSS_TYPE_*).
  182. * bit 4: Band - The radio band in which to join
  183. * or start.
  184. * 0 - 2.4GHz band
  185. * 1 - 5GHz band
  186. * bits 3, 5-7: Reserved
  187. */
  188. u8 bss_type;
  189. u8 channel;
  190. u8 ssid_len;
  191. u8 ssid[IW_ESSID_MAX_SIZE];
  192. u8 ctrl; /* JOIN_CMD_CTRL_* */
  193. u8 reserved[3];
  194. } __packed;
  195. struct cmd_enabledisable_path {
  196. struct wl1271_cmd_header header;
  197. u8 channel;
  198. u8 padding[3];
  199. } __packed;
  200. #define WL1271_RATE_AUTOMATIC 0
  201. struct wl1271_cmd_template_set {
  202. struct wl1271_cmd_header header;
  203. __le16 len;
  204. u8 template_type;
  205. u8 index; /* relevant only for KLV_TEMPLATE type */
  206. __le32 enabled_rates;
  207. u8 short_retry_limit;
  208. u8 long_retry_limit;
  209. u8 aflags;
  210. u8 reserved;
  211. u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
  212. } __packed;
  213. #define TIM_ELE_ID 5
  214. #define PARTIAL_VBM_MAX 251
  215. struct wl1271_tim {
  216. u8 identity;
  217. u8 length;
  218. u8 dtim_count;
  219. u8 dtim_period;
  220. u8 bitmap_ctrl;
  221. u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
  222. } __packed;
  223. enum wl1271_cmd_ps_mode {
  224. STATION_ACTIVE_MODE,
  225. STATION_POWER_SAVE_MODE
  226. };
  227. struct wl1271_cmd_ps_params {
  228. struct wl1271_cmd_header header;
  229. u8 ps_mode; /* STATION_* */
  230. u8 send_null_data; /* Do we have to send NULL data packet ? */
  231. u8 retries; /* Number of retires for the initial NULL data packet */
  232. /*
  233. * TUs during which the target stays awake after switching
  234. * to power save mode.
  235. */
  236. u8 hang_over_period;
  237. __le32 null_data_rate;
  238. } __packed;
  239. /* HW encryption keys */
  240. #define NUM_ACCESS_CATEGORIES_COPY 4
  241. #define MAX_KEY_SIZE 32
  242. enum wl1271_cmd_key_action {
  243. KEY_ADD_OR_REPLACE = 1,
  244. KEY_REMOVE = 2,
  245. KEY_SET_ID = 3,
  246. MAX_KEY_ACTION = 0xffff,
  247. };
  248. enum wl1271_cmd_key_type {
  249. KEY_NONE = 0,
  250. KEY_WEP = 1,
  251. KEY_TKIP = 2,
  252. KEY_AES = 3,
  253. KEY_GEM = 4,
  254. };
  255. /* FIXME: Add description for key-types */
  256. struct wl1271_cmd_set_keys {
  257. struct wl1271_cmd_header header;
  258. /* Ignored for default WEP key */
  259. u8 addr[ETH_ALEN];
  260. /* key_action_e */
  261. __le16 key_action;
  262. __le16 reserved_1;
  263. /* key size in bytes */
  264. u8 key_size;
  265. /* key_type_e */
  266. u8 key_type;
  267. u8 ssid_profile;
  268. /*
  269. * TKIP, AES: frame's key id field.
  270. * For WEP default key: key id;
  271. */
  272. u8 id;
  273. u8 reserved_2[6];
  274. u8 key[MAX_KEY_SIZE];
  275. __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
  276. __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
  277. } __packed;
  278. struct wl1271_cmd_test_header {
  279. u8 id;
  280. u8 padding[3];
  281. } __packed;
  282. enum wl1271_channel_tune_bands {
  283. WL1271_CHANNEL_TUNE_BAND_2_4,
  284. WL1271_CHANNEL_TUNE_BAND_5,
  285. WL1271_CHANNEL_TUNE_BAND_4_9
  286. };
  287. #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
  288. #define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
  289. #define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
  290. #define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
  291. struct wl1271_general_parms_cmd {
  292. struct wl1271_cmd_header header;
  293. struct wl1271_cmd_test_header test;
  294. struct wl1271_ini_general_params general_params;
  295. u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
  296. u8 sr_sen_n_p;
  297. u8 sr_sen_n_p_gain;
  298. u8 sr_sen_nrn;
  299. u8 sr_sen_prn;
  300. u8 padding[3];
  301. } __packed;
  302. struct wl1271_radio_parms_cmd {
  303. struct wl1271_cmd_header header;
  304. struct wl1271_cmd_test_header test;
  305. /* Static radio parameters */
  306. struct wl1271_ini_band_params_2 static_params_2;
  307. struct wl1271_ini_band_params_5 static_params_5;
  308. /* Dynamic radio parameters */
  309. struct wl1271_ini_fem_params_2 dyn_params_2;
  310. u8 padding2;
  311. struct wl1271_ini_fem_params_5 dyn_params_5;
  312. u8 padding3[2];
  313. } __packed;
  314. struct wl1271_ext_radio_parms_cmd {
  315. struct wl1271_cmd_header header;
  316. struct wl1271_cmd_test_header test;
  317. u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
  318. u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
  319. u8 padding[3];
  320. } __packed;
  321. /*
  322. * There are three types of disconnections:
  323. *
  324. * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
  325. * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
  326. * we have passed
  327. * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
  328. * we have passed
  329. */
  330. enum wl1271_disconnect_type {
  331. DISCONNECT_IMMEDIATE,
  332. DISCONNECT_DEAUTH,
  333. DISCONNECT_DISASSOC
  334. };
  335. struct wl1271_cmd_disconnect {
  336. struct wl1271_cmd_header header;
  337. __le32 rx_config_options;
  338. __le32 rx_filter_options;
  339. __le16 reason;
  340. u8 type;
  341. u8 padding;
  342. } __packed;
  343. #define WL1271_CMD_STA_STATE_CONNECTED 1
  344. struct wl1271_cmd_set_sta_state {
  345. struct wl1271_cmd_header header;
  346. u8 state;
  347. u8 padding[3];
  348. } __packed;
  349. #endif /* __WL1271_CMD_H__ */