wl1251_acx.c 19 KB

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