wl1251_acx.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. #include "wl1251_acx.h"
  2. #include <linux/module.h>
  3. #include <linux/crc7.h>
  4. #include <linux/spi/spi.h>
  5. #include "wl1251.h"
  6. #include "reg.h"
  7. #include "wl1251_spi.h"
  8. #include "wl1251_ps.h"
  9. int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod,
  10. u8 mgt_rate, u8 mgt_mod)
  11. {
  12. struct acx_fw_gen_frame_rates *rates;
  13. int ret;
  14. wl1251_debug(DEBUG_ACX, "acx frame rates");
  15. rates = kzalloc(sizeof(*rates), GFP_KERNEL);
  16. if (!rates) {
  17. ret = -ENOMEM;
  18. goto out;
  19. }
  20. rates->tx_ctrl_frame_rate = ctrl_rate;
  21. rates->tx_ctrl_frame_mod = ctrl_mod;
  22. rates->tx_mgt_frame_rate = mgt_rate;
  23. rates->tx_mgt_frame_mod = mgt_mod;
  24. ret = wl1251_cmd_configure(wl, ACX_FW_GEN_FRAME_RATES,
  25. rates, sizeof(*rates));
  26. if (ret < 0) {
  27. wl1251_error("Failed to set FW rates and modulation");
  28. goto out;
  29. }
  30. out:
  31. kfree(rates);
  32. return ret;
  33. }
  34. int wl1251_acx_station_id(struct wl1251 *wl)
  35. {
  36. struct acx_dot11_station_id *mac;
  37. int ret, i;
  38. wl1251_debug(DEBUG_ACX, "acx dot11_station_id");
  39. mac = kzalloc(sizeof(*mac), GFP_KERNEL);
  40. if (!mac) {
  41. ret = -ENOMEM;
  42. goto out;
  43. }
  44. for (i = 0; i < ETH_ALEN; i++)
  45. mac->mac[i] = wl->mac_addr[ETH_ALEN - 1 - i];
  46. ret = wl1251_cmd_configure(wl, DOT11_STATION_ID, mac, sizeof(*mac));
  47. if (ret < 0)
  48. goto out;
  49. out:
  50. kfree(mac);
  51. return ret;
  52. }
  53. int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id)
  54. {
  55. struct acx_dot11_default_key *default_key;
  56. int ret;
  57. wl1251_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id);
  58. default_key = kzalloc(sizeof(*default_key), GFP_KERNEL);
  59. if (!default_key) {
  60. ret = -ENOMEM;
  61. goto out;
  62. }
  63. default_key->id = key_id;
  64. ret = wl1251_cmd_configure(wl, DOT11_DEFAULT_KEY,
  65. default_key, sizeof(*default_key));
  66. if (ret < 0) {
  67. wl1251_error("Couldn't set default key");
  68. goto out;
  69. }
  70. wl->default_key = key_id;
  71. out:
  72. kfree(default_key);
  73. return ret;
  74. }
  75. int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event,
  76. u8 listen_interval)
  77. {
  78. struct acx_wake_up_condition *wake_up;
  79. int ret;
  80. wl1251_debug(DEBUG_ACX, "acx wake up conditions");
  81. wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
  82. if (!wake_up) {
  83. ret = -ENOMEM;
  84. goto out;
  85. }
  86. wake_up->wake_up_event = wake_up_event;
  87. wake_up->listen_interval = listen_interval;
  88. ret = wl1251_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
  89. wake_up, sizeof(*wake_up));
  90. if (ret < 0) {
  91. wl1251_warning("could not set wake up conditions: %d", ret);
  92. goto out;
  93. }
  94. out:
  95. kfree(wake_up);
  96. return ret;
  97. }
  98. int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth)
  99. {
  100. struct acx_sleep_auth *auth;
  101. int ret;
  102. wl1251_debug(DEBUG_ACX, "acx sleep auth");
  103. auth = kzalloc(sizeof(*auth), GFP_KERNEL);
  104. if (!auth) {
  105. ret = -ENOMEM;
  106. goto out;
  107. }
  108. auth->sleep_auth = sleep_auth;
  109. ret = wl1251_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
  110. if (ret < 0)
  111. return ret;
  112. out:
  113. kfree(auth);
  114. return ret;
  115. }
  116. int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len)
  117. {
  118. struct acx_revision *rev;
  119. int ret;
  120. wl1251_debug(DEBUG_ACX, "acx fw rev");
  121. rev = kzalloc(sizeof(*rev), GFP_KERNEL);
  122. if (!rev) {
  123. ret = -ENOMEM;
  124. goto out;
  125. }
  126. ret = wl1251_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev));
  127. if (ret < 0) {
  128. wl1251_warning("ACX_FW_REV interrogate failed");
  129. goto out;
  130. }
  131. /* be careful with the buffer sizes */
  132. strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
  133. /*
  134. * if the firmware version string is exactly
  135. * sizeof(rev->fw_version) long or fw_len is less than
  136. * sizeof(rev->fw_version) it won't be null terminated
  137. */
  138. buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
  139. out:
  140. kfree(rev);
  141. return ret;
  142. }
  143. int wl1251_acx_tx_power(struct wl1251 *wl, int power)
  144. {
  145. struct acx_current_tx_power *acx;
  146. int ret;
  147. wl1251_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr");
  148. if (power < 0 || power > 25)
  149. return -EINVAL;
  150. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  151. if (!acx) {
  152. ret = -ENOMEM;
  153. goto out;
  154. }
  155. acx->current_tx_power = power * 10;
  156. ret = wl1251_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
  157. if (ret < 0) {
  158. wl1251_warning("configure of tx power failed: %d", ret);
  159. goto out;
  160. }
  161. out:
  162. kfree(acx);
  163. return ret;
  164. }
  165. int wl1251_acx_feature_cfg(struct wl1251 *wl)
  166. {
  167. struct acx_feature_config *feature;
  168. int ret;
  169. wl1251_debug(DEBUG_ACX, "acx feature cfg");
  170. feature = kzalloc(sizeof(*feature), GFP_KERNEL);
  171. if (!feature) {
  172. ret = -ENOMEM;
  173. goto out;
  174. }
  175. /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
  176. feature->data_flow_options = 0;
  177. feature->options = 0;
  178. ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG,
  179. feature, sizeof(*feature));
  180. if (ret < 0) {
  181. wl1251_error("Couldn't set HW encryption");
  182. goto out;
  183. }
  184. out:
  185. kfree(feature);
  186. return ret;
  187. }
  188. int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map,
  189. size_t len)
  190. {
  191. int ret;
  192. wl1251_debug(DEBUG_ACX, "acx mem map");
  193. ret = wl1251_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
  194. if (ret < 0)
  195. return ret;
  196. return 0;
  197. }
  198. int wl1251_acx_data_path_params(struct wl1251 *wl,
  199. struct acx_data_path_params_resp *resp)
  200. {
  201. struct acx_data_path_params *params;
  202. int ret;
  203. wl1251_debug(DEBUG_ACX, "acx data path params");
  204. params = kzalloc(sizeof(*params), GFP_KERNEL);
  205. if (!params) {
  206. ret = -ENOMEM;
  207. goto out;
  208. }
  209. params->rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE;
  210. params->tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE;
  211. params->rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM;
  212. params->tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM;
  213. params->tx_complete_threshold = 1;
  214. params->tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE;
  215. params->tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT;
  216. ret = wl1251_cmd_configure(wl, ACX_DATA_PATH_PARAMS,
  217. params, sizeof(*params));
  218. if (ret < 0)
  219. goto out;
  220. /* FIXME: shouldn't this be ACX_DATA_PATH_RESP_PARAMS? */
  221. ret = wl1251_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS,
  222. resp, sizeof(*resp));
  223. if (ret < 0) {
  224. wl1251_warning("failed to read data path parameters: %d", ret);
  225. goto out;
  226. } else if (resp->header.cmd.status != CMD_STATUS_SUCCESS) {
  227. wl1251_warning("data path parameter acx status failed");
  228. ret = -EIO;
  229. goto out;
  230. }
  231. out:
  232. kfree(params);
  233. return ret;
  234. }
  235. int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time)
  236. {
  237. struct acx_rx_msdu_lifetime *acx;
  238. int ret;
  239. wl1251_debug(DEBUG_ACX, "acx rx msdu life time");
  240. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  241. if (!acx) {
  242. ret = -ENOMEM;
  243. goto out;
  244. }
  245. acx->lifetime = life_time;
  246. ret = wl1251_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
  247. acx, sizeof(*acx));
  248. if (ret < 0) {
  249. wl1251_warning("failed to set rx msdu life time: %d", ret);
  250. goto out;
  251. }
  252. out:
  253. kfree(acx);
  254. return ret;
  255. }
  256. int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter)
  257. {
  258. struct acx_rx_config *rx_config;
  259. int ret;
  260. wl1251_debug(DEBUG_ACX, "acx rx config");
  261. rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL);
  262. if (!rx_config) {
  263. ret = -ENOMEM;
  264. goto out;
  265. }
  266. rx_config->config_options = config;
  267. rx_config->filter_options = filter;
  268. ret = wl1251_cmd_configure(wl, ACX_RX_CFG,
  269. rx_config, sizeof(*rx_config));
  270. if (ret < 0) {
  271. wl1251_warning("failed to set rx config: %d", ret);
  272. goto out;
  273. }
  274. out:
  275. kfree(rx_config);
  276. return ret;
  277. }
  278. int wl1251_acx_pd_threshold(struct wl1251 *wl)
  279. {
  280. struct acx_packet_detection *pd;
  281. int ret;
  282. wl1251_debug(DEBUG_ACX, "acx data pd threshold");
  283. pd = kzalloc(sizeof(*pd), GFP_KERNEL);
  284. if (!pd) {
  285. ret = -ENOMEM;
  286. goto out;
  287. }
  288. /* FIXME: threshold value not set */
  289. ret = wl1251_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
  290. if (ret < 0) {
  291. wl1251_warning("failed to set pd threshold: %d", ret);
  292. goto out;
  293. }
  294. out:
  295. kfree(pd);
  296. return 0;
  297. }
  298. int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time)
  299. {
  300. struct acx_slot *slot;
  301. int ret;
  302. wl1251_debug(DEBUG_ACX, "acx slot");
  303. slot = kzalloc(sizeof(*slot), GFP_KERNEL);
  304. if (!slot) {
  305. ret = -ENOMEM;
  306. goto out;
  307. }
  308. slot->wone_index = STATION_WONE_INDEX;
  309. slot->slot_time = slot_time;
  310. ret = wl1251_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
  311. if (ret < 0) {
  312. wl1251_warning("failed to set slot time: %d", ret);
  313. goto out;
  314. }
  315. out:
  316. kfree(slot);
  317. return ret;
  318. }
  319. int wl1251_acx_group_address_tbl(struct wl1251 *wl)
  320. {
  321. struct acx_dot11_grp_addr_tbl *acx;
  322. int ret;
  323. wl1251_debug(DEBUG_ACX, "acx group address tbl");
  324. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  325. if (!acx) {
  326. ret = -ENOMEM;
  327. goto out;
  328. }
  329. /* MAC filtering */
  330. acx->enabled = 0;
  331. acx->num_groups = 0;
  332. memset(acx->mac_table, 0, ADDRESS_GROUP_MAX_LEN);
  333. ret = wl1251_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
  334. acx, sizeof(*acx));
  335. if (ret < 0) {
  336. wl1251_warning("failed to set group addr table: %d", ret);
  337. goto out;
  338. }
  339. out:
  340. kfree(acx);
  341. return ret;
  342. }
  343. int wl1251_acx_service_period_timeout(struct wl1251 *wl)
  344. {
  345. struct acx_rx_timeout *rx_timeout;
  346. int ret;
  347. rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
  348. if (!rx_timeout) {
  349. ret = -ENOMEM;
  350. goto out;
  351. }
  352. wl1251_debug(DEBUG_ACX, "acx service period timeout");
  353. rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF;
  354. rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF;
  355. ret = wl1251_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
  356. rx_timeout, sizeof(*rx_timeout));
  357. if (ret < 0) {
  358. wl1251_warning("failed to set service period timeout: %d",
  359. ret);
  360. goto out;
  361. }
  362. out:
  363. kfree(rx_timeout);
  364. return ret;
  365. }
  366. int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold)
  367. {
  368. struct acx_rts_threshold *rts;
  369. int ret;
  370. wl1251_debug(DEBUG_ACX, "acx rts threshold");
  371. rts = kzalloc(sizeof(*rts), GFP_KERNEL);
  372. if (!rts) {
  373. ret = -ENOMEM;
  374. goto out;
  375. }
  376. rts->threshold = rts_threshold;
  377. ret = wl1251_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
  378. if (ret < 0) {
  379. wl1251_warning("failed to set rts threshold: %d", ret);
  380. goto out;
  381. }
  382. out:
  383. kfree(rts);
  384. return ret;
  385. }
  386. int wl1251_acx_beacon_filter_opt(struct wl1251 *wl)
  387. {
  388. struct acx_beacon_filter_option *beacon_filter;
  389. int ret;
  390. wl1251_debug(DEBUG_ACX, "acx beacon filter opt");
  391. beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
  392. if (!beacon_filter) {
  393. ret = -ENOMEM;
  394. goto out;
  395. }
  396. beacon_filter->enable = 0;
  397. beacon_filter->max_num_beacons = 0;
  398. ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
  399. beacon_filter, sizeof(*beacon_filter));
  400. if (ret < 0) {
  401. wl1251_warning("failed to set beacon filter opt: %d", ret);
  402. goto out;
  403. }
  404. out:
  405. kfree(beacon_filter);
  406. return ret;
  407. }
  408. int wl1251_acx_beacon_filter_table(struct wl1251 *wl)
  409. {
  410. struct acx_beacon_filter_ie_table *ie_table;
  411. int ret;
  412. wl1251_debug(DEBUG_ACX, "acx beacon filter table");
  413. ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
  414. if (!ie_table) {
  415. ret = -ENOMEM;
  416. goto out;
  417. }
  418. ie_table->num_ie = 0;
  419. memset(ie_table->table, 0, BEACON_FILTER_TABLE_MAX_SIZE);
  420. ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
  421. ie_table, sizeof(*ie_table));
  422. if (ret < 0) {
  423. wl1251_warning("failed to set beacon filter table: %d", ret);
  424. goto out;
  425. }
  426. out:
  427. kfree(ie_table);
  428. return ret;
  429. }
  430. int wl1251_acx_sg_enable(struct wl1251 *wl)
  431. {
  432. struct acx_bt_wlan_coex *pta;
  433. int ret;
  434. wl1251_debug(DEBUG_ACX, "acx sg enable");
  435. pta = kzalloc(sizeof(*pta), GFP_KERNEL);
  436. if (!pta) {
  437. ret = -ENOMEM;
  438. goto out;
  439. }
  440. pta->enable = SG_ENABLE;
  441. ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
  442. if (ret < 0) {
  443. wl1251_warning("failed to set softgemini enable: %d", ret);
  444. goto out;
  445. }
  446. out:
  447. kfree(pta);
  448. return ret;
  449. }
  450. int wl1251_acx_sg_cfg(struct wl1251 *wl)
  451. {
  452. struct acx_bt_wlan_coex_param *param;
  453. int ret;
  454. wl1251_debug(DEBUG_ACX, "acx sg cfg");
  455. param = kzalloc(sizeof(*param), GFP_KERNEL);
  456. if (!param) {
  457. ret = -ENOMEM;
  458. goto out;
  459. }
  460. /* BT-WLAN coext parameters */
  461. param->min_rate = RATE_INDEX_24MBPS;
  462. param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
  463. param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
  464. param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
  465. param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
  466. param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
  467. param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
  468. param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
  469. param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
  470. param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
  471. param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
  472. param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
  473. param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
  474. param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
  475. param->antenna_type = PTA_ANTENNA_TYPE_DEF;
  476. param->signal_type = PTA_SIGNALING_TYPE_DEF;
  477. param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
  478. param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
  479. param->max_cts = PTA_MAX_NUM_CTS_DEF;
  480. param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
  481. param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
  482. param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
  483. param->wlan_elp_hp = PTA_ELP_HP_DEF;
  484. param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
  485. param->ack_mode_dual_ant = PTA_ACK_MODE_DEF;
  486. param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
  487. param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
  488. param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
  489. ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
  490. if (ret < 0) {
  491. wl1251_warning("failed to set sg config: %d", ret);
  492. goto out;
  493. }
  494. out:
  495. kfree(param);
  496. return ret;
  497. }
  498. int wl1251_acx_cca_threshold(struct wl1251 *wl)
  499. {
  500. struct acx_energy_detection *detection;
  501. int ret;
  502. wl1251_debug(DEBUG_ACX, "acx cca threshold");
  503. detection = kzalloc(sizeof(*detection), GFP_KERNEL);
  504. if (!detection) {
  505. ret = -ENOMEM;
  506. goto out;
  507. }
  508. detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
  509. detection->tx_energy_detection = 0;
  510. ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD,
  511. detection, sizeof(*detection));
  512. if (ret < 0) {
  513. wl1251_warning("failed to set cca threshold: %d", ret);
  514. return ret;
  515. }
  516. out:
  517. kfree(detection);
  518. return ret;
  519. }
  520. int wl1251_acx_bcn_dtim_options(struct wl1251 *wl)
  521. {
  522. struct acx_beacon_broadcast *bb;
  523. int ret;
  524. wl1251_debug(DEBUG_ACX, "acx bcn dtim options");
  525. bb = kzalloc(sizeof(*bb), GFP_KERNEL);
  526. if (!bb) {
  527. ret = -ENOMEM;
  528. goto out;
  529. }
  530. bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
  531. bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
  532. bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
  533. bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
  534. ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
  535. if (ret < 0) {
  536. wl1251_warning("failed to set rx config: %d", ret);
  537. goto out;
  538. }
  539. out:
  540. kfree(bb);
  541. return ret;
  542. }
  543. int wl1251_acx_aid(struct wl1251 *wl, u16 aid)
  544. {
  545. struct acx_aid *acx_aid;
  546. int ret;
  547. wl1251_debug(DEBUG_ACX, "acx aid");
  548. acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
  549. if (!acx_aid) {
  550. ret = -ENOMEM;
  551. goto out;
  552. }
  553. acx_aid->aid = aid;
  554. ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
  555. if (ret < 0) {
  556. wl1251_warning("failed to set aid: %d", ret);
  557. goto out;
  558. }
  559. out:
  560. kfree(acx_aid);
  561. return ret;
  562. }
  563. int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask)
  564. {
  565. struct acx_event_mask *mask;
  566. int ret;
  567. wl1251_debug(DEBUG_ACX, "acx event mbox mask");
  568. mask = kzalloc(sizeof(*mask), GFP_KERNEL);
  569. if (!mask) {
  570. ret = -ENOMEM;
  571. goto out;
  572. }
  573. /* high event mask is unused */
  574. mask->high_event_mask = 0xffffffff;
  575. mask->event_mask = event_mask;
  576. ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
  577. mask, sizeof(*mask));
  578. if (ret < 0) {
  579. wl1251_warning("failed to set acx_event_mbox_mask: %d", ret);
  580. goto out;
  581. }
  582. out:
  583. kfree(mask);
  584. return ret;
  585. }
  586. int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble)
  587. {
  588. struct acx_preamble *acx;
  589. int ret;
  590. wl1251_debug(DEBUG_ACX, "acx_set_preamble");
  591. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  592. if (!acx) {
  593. ret = -ENOMEM;
  594. goto out;
  595. }
  596. acx->preamble = preamble;
  597. ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
  598. if (ret < 0) {
  599. wl1251_warning("Setting of preamble failed: %d", ret);
  600. goto out;
  601. }
  602. out:
  603. kfree(acx);
  604. return ret;
  605. }
  606. int wl1251_acx_cts_protect(struct wl1251 *wl,
  607. enum acx_ctsprotect_type ctsprotect)
  608. {
  609. struct acx_ctsprotect *acx;
  610. int ret;
  611. wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect");
  612. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  613. if (!acx) {
  614. ret = -ENOMEM;
  615. goto out;
  616. }
  617. acx->ctsprotect = ctsprotect;
  618. ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
  619. if (ret < 0) {
  620. wl1251_warning("Setting of ctsprotect failed: %d", ret);
  621. goto out;
  622. }
  623. out:
  624. kfree(acx);
  625. return ret;
  626. }
  627. int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime)
  628. {
  629. struct acx_tsf_info *tsf_info;
  630. int ret;
  631. tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
  632. if (!tsf_info) {
  633. ret = -ENOMEM;
  634. goto out;
  635. }
  636. ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO,
  637. tsf_info, sizeof(*tsf_info));
  638. if (ret < 0) {
  639. wl1251_warning("ACX_FW_REV interrogate failed");
  640. goto out;
  641. }
  642. *mactime = tsf_info->current_tsf_lsb |
  643. (tsf_info->current_tsf_msb << 31);
  644. out:
  645. kfree(tsf_info);
  646. return ret;
  647. }
  648. int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats)
  649. {
  650. int ret;
  651. wl1251_debug(DEBUG_ACX, "acx statistics");
  652. ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats,
  653. sizeof(*stats));
  654. if (ret < 0) {
  655. wl1251_warning("acx statistics failed: %d", ret);
  656. return -ENOMEM;
  657. }
  658. return 0;
  659. }