acx.c 17 KB

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