acx.c 23 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. #include "acx.h"
  2. #include <linux/module.h>
  3. #include <linux/slab.h>
  4. #include <linux/crc7.h>
  5. #include "wl1251.h"
  6. #include "reg.h"
  7. #include "cmd.h"
  8. #include "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 ret;
  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, bool enable_filter)
  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 = enable_filter;
  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 idx = 0;
  412. int ret;
  413. wl1251_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. /* configure default beacon pass-through rules */
  420. ie_table->num_ie = 1;
  421. ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN;
  422. ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE;
  423. ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
  424. ie_table, sizeof(*ie_table));
  425. if (ret < 0) {
  426. wl1251_warning("failed to set beacon filter table: %d", ret);
  427. goto out;
  428. }
  429. out:
  430. kfree(ie_table);
  431. return ret;
  432. }
  433. int wl1251_acx_conn_monit_params(struct wl1251 *wl)
  434. {
  435. struct acx_conn_monit_params *acx;
  436. int ret;
  437. wl1251_debug(DEBUG_ACX, "acx connection monitor parameters");
  438. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  439. if (!acx) {
  440. ret = -ENOMEM;
  441. goto out;
  442. }
  443. acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD;
  444. acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT;
  445. ret = wl1251_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
  446. acx, sizeof(*acx));
  447. if (ret < 0) {
  448. wl1251_warning("failed to set connection monitor "
  449. "parameters: %d", ret);
  450. goto out;
  451. }
  452. out:
  453. kfree(acx);
  454. return ret;
  455. }
  456. int wl1251_acx_sg_enable(struct wl1251 *wl)
  457. {
  458. struct acx_bt_wlan_coex *pta;
  459. int ret;
  460. wl1251_debug(DEBUG_ACX, "acx sg enable");
  461. pta = kzalloc(sizeof(*pta), GFP_KERNEL);
  462. if (!pta) {
  463. ret = -ENOMEM;
  464. goto out;
  465. }
  466. pta->enable = SG_ENABLE;
  467. ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
  468. if (ret < 0) {
  469. wl1251_warning("failed to set softgemini enable: %d", ret);
  470. goto out;
  471. }
  472. out:
  473. kfree(pta);
  474. return ret;
  475. }
  476. int wl1251_acx_sg_cfg(struct wl1251 *wl)
  477. {
  478. struct acx_bt_wlan_coex_param *param;
  479. int ret;
  480. wl1251_debug(DEBUG_ACX, "acx sg cfg");
  481. param = kzalloc(sizeof(*param), GFP_KERNEL);
  482. if (!param) {
  483. ret = -ENOMEM;
  484. goto out;
  485. }
  486. /* BT-WLAN coext parameters */
  487. param->min_rate = RATE_INDEX_24MBPS;
  488. param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
  489. param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
  490. param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
  491. param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
  492. param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
  493. param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
  494. param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
  495. param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
  496. param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
  497. param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
  498. param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
  499. param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
  500. param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
  501. param->antenna_type = PTA_ANTENNA_TYPE_DEF;
  502. param->signal_type = PTA_SIGNALING_TYPE_DEF;
  503. param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
  504. param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
  505. param->max_cts = PTA_MAX_NUM_CTS_DEF;
  506. param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
  507. param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
  508. param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
  509. param->wlan_elp_hp = PTA_ELP_HP_DEF;
  510. param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
  511. param->ack_mode_dual_ant = PTA_ACK_MODE_DEF;
  512. param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
  513. param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
  514. param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
  515. ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
  516. if (ret < 0) {
  517. wl1251_warning("failed to set sg config: %d", ret);
  518. goto out;
  519. }
  520. out:
  521. kfree(param);
  522. return ret;
  523. }
  524. int wl1251_acx_cca_threshold(struct wl1251 *wl)
  525. {
  526. struct acx_energy_detection *detection;
  527. int ret;
  528. wl1251_debug(DEBUG_ACX, "acx cca threshold");
  529. detection = kzalloc(sizeof(*detection), GFP_KERNEL);
  530. if (!detection) {
  531. ret = -ENOMEM;
  532. goto out;
  533. }
  534. detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
  535. detection->tx_energy_detection = 0;
  536. ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD,
  537. detection, sizeof(*detection));
  538. if (ret < 0) {
  539. wl1251_warning("failed to set cca threshold: %d", ret);
  540. return ret;
  541. }
  542. out:
  543. kfree(detection);
  544. return ret;
  545. }
  546. int wl1251_acx_bcn_dtim_options(struct wl1251 *wl)
  547. {
  548. struct acx_beacon_broadcast *bb;
  549. int ret;
  550. wl1251_debug(DEBUG_ACX, "acx bcn dtim options");
  551. bb = kzalloc(sizeof(*bb), GFP_KERNEL);
  552. if (!bb) {
  553. ret = -ENOMEM;
  554. goto out;
  555. }
  556. bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
  557. bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
  558. bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
  559. bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
  560. ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
  561. if (ret < 0) {
  562. wl1251_warning("failed to set rx config: %d", ret);
  563. goto out;
  564. }
  565. out:
  566. kfree(bb);
  567. return ret;
  568. }
  569. int wl1251_acx_aid(struct wl1251 *wl, u16 aid)
  570. {
  571. struct acx_aid *acx_aid;
  572. int ret;
  573. wl1251_debug(DEBUG_ACX, "acx aid");
  574. acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
  575. if (!acx_aid) {
  576. ret = -ENOMEM;
  577. goto out;
  578. }
  579. acx_aid->aid = aid;
  580. ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
  581. if (ret < 0) {
  582. wl1251_warning("failed to set aid: %d", ret);
  583. goto out;
  584. }
  585. out:
  586. kfree(acx_aid);
  587. return ret;
  588. }
  589. int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask)
  590. {
  591. struct acx_event_mask *mask;
  592. int ret;
  593. wl1251_debug(DEBUG_ACX, "acx event mbox mask");
  594. mask = kzalloc(sizeof(*mask), GFP_KERNEL);
  595. if (!mask) {
  596. ret = -ENOMEM;
  597. goto out;
  598. }
  599. /* high event mask is unused */
  600. mask->high_event_mask = 0xffffffff;
  601. mask->event_mask = event_mask;
  602. ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
  603. mask, sizeof(*mask));
  604. if (ret < 0) {
  605. wl1251_warning("failed to set acx_event_mbox_mask: %d", ret);
  606. goto out;
  607. }
  608. out:
  609. kfree(mask);
  610. return ret;
  611. }
  612. int wl1251_acx_low_rssi(struct wl1251 *wl, s8 threshold, u8 weight,
  613. u8 depth, enum wl1251_acx_low_rssi_type type)
  614. {
  615. struct acx_low_rssi *rssi;
  616. int ret;
  617. wl1251_debug(DEBUG_ACX, "acx low rssi");
  618. rssi = kzalloc(sizeof(*rssi), GFP_KERNEL);
  619. if (!rssi)
  620. return -ENOMEM;
  621. rssi->threshold = threshold;
  622. rssi->weight = weight;
  623. rssi->depth = depth;
  624. rssi->type = type;
  625. ret = wl1251_cmd_configure(wl, ACX_LOW_RSSI, rssi, sizeof(*rssi));
  626. if (ret < 0)
  627. wl1251_warning("failed to set low rssi threshold: %d", ret);
  628. kfree(rssi);
  629. return ret;
  630. }
  631. int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble)
  632. {
  633. struct acx_preamble *acx;
  634. int ret;
  635. wl1251_debug(DEBUG_ACX, "acx_set_preamble");
  636. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  637. if (!acx) {
  638. ret = -ENOMEM;
  639. goto out;
  640. }
  641. acx->preamble = preamble;
  642. ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
  643. if (ret < 0) {
  644. wl1251_warning("Setting of preamble failed: %d", ret);
  645. goto out;
  646. }
  647. out:
  648. kfree(acx);
  649. return ret;
  650. }
  651. int wl1251_acx_cts_protect(struct wl1251 *wl,
  652. enum acx_ctsprotect_type ctsprotect)
  653. {
  654. struct acx_ctsprotect *acx;
  655. int ret;
  656. wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect");
  657. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  658. if (!acx) {
  659. ret = -ENOMEM;
  660. goto out;
  661. }
  662. acx->ctsprotect = ctsprotect;
  663. ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
  664. if (ret < 0) {
  665. wl1251_warning("Setting of ctsprotect failed: %d", ret);
  666. goto out;
  667. }
  668. out:
  669. kfree(acx);
  670. return ret;
  671. }
  672. int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime)
  673. {
  674. struct acx_tsf_info *tsf_info;
  675. int ret;
  676. tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
  677. if (!tsf_info) {
  678. ret = -ENOMEM;
  679. goto out;
  680. }
  681. ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO,
  682. tsf_info, sizeof(*tsf_info));
  683. if (ret < 0) {
  684. wl1251_warning("ACX_FW_REV interrogate failed");
  685. goto out;
  686. }
  687. *mactime = tsf_info->current_tsf_lsb |
  688. (tsf_info->current_tsf_msb << 31);
  689. out:
  690. kfree(tsf_info);
  691. return ret;
  692. }
  693. int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats)
  694. {
  695. int ret;
  696. wl1251_debug(DEBUG_ACX, "acx statistics");
  697. ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats,
  698. sizeof(*stats));
  699. if (ret < 0) {
  700. wl1251_warning("acx statistics failed: %d", ret);
  701. return -ENOMEM;
  702. }
  703. return 0;
  704. }
  705. int wl1251_acx_rate_policies(struct wl1251 *wl)
  706. {
  707. struct acx_rate_policy *acx;
  708. int ret = 0;
  709. wl1251_debug(DEBUG_ACX, "acx rate policies");
  710. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  711. if (!acx) {
  712. ret = -ENOMEM;
  713. goto out;
  714. }
  715. /* configure one default (one-size-fits-all) rate class */
  716. acx->rate_class_cnt = 1;
  717. acx->rate_class[0].enabled_rates = ACX_RATE_MASK_UNSPECIFIED;
  718. acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT;
  719. acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT;
  720. acx->rate_class[0].aflags = 0;
  721. ret = wl1251_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  722. if (ret < 0) {
  723. wl1251_warning("Setting of rate policies failed: %d", ret);
  724. goto out;
  725. }
  726. out:
  727. kfree(acx);
  728. return ret;
  729. }
  730. int wl1251_acx_mem_cfg(struct wl1251 *wl)
  731. {
  732. struct wl1251_acx_config_memory *mem_conf;
  733. int ret, i;
  734. wl1251_debug(DEBUG_ACX, "acx mem cfg");
  735. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  736. if (!mem_conf) {
  737. ret = -ENOMEM;
  738. goto out;
  739. }
  740. /* memory config */
  741. mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS);
  742. mem_conf->mem_config.rx_mem_block_num = 35;
  743. mem_conf->mem_config.tx_min_mem_block_num = 64;
  744. mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES;
  745. mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING;
  746. mem_conf->mem_config.num_ssid_profiles = 1;
  747. mem_conf->mem_config.debug_buffer_size =
  748. cpu_to_le16(TRACE_BUFFER_MAX_SIZE);
  749. /* RX queue config */
  750. mem_conf->rx_queue_config.dma_address = 0;
  751. mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF;
  752. mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY;
  753. mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE;
  754. /* TX queue config */
  755. for (i = 0; i < MAX_TX_QUEUES; i++) {
  756. mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF;
  757. mem_conf->tx_queue_config[i].attributes = i;
  758. }
  759. ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  760. sizeof(*mem_conf));
  761. if (ret < 0) {
  762. wl1251_warning("wl1251 mem config failed: %d", ret);
  763. goto out;
  764. }
  765. out:
  766. kfree(mem_conf);
  767. return ret;
  768. }
  769. int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim)
  770. {
  771. struct wl1251_acx_wr_tbtt_and_dtim *acx;
  772. int ret;
  773. wl1251_debug(DEBUG_ACX, "acx tbtt and dtim");
  774. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  775. if (!acx) {
  776. ret = -ENOMEM;
  777. goto out;
  778. }
  779. acx->tbtt = tbtt;
  780. acx->dtim = dtim;
  781. ret = wl1251_cmd_configure(wl, ACX_WR_TBTT_AND_DTIM,
  782. acx, sizeof(*acx));
  783. if (ret < 0) {
  784. wl1251_warning("failed to set tbtt and dtim: %d", ret);
  785. goto out;
  786. }
  787. out:
  788. kfree(acx);
  789. return ret;
  790. }
  791. int wl1251_acx_bet_enable(struct wl1251 *wl, enum wl1251_acx_bet_mode mode,
  792. u8 max_consecutive)
  793. {
  794. struct wl1251_acx_bet_enable *acx;
  795. int ret;
  796. wl1251_debug(DEBUG_ACX, "acx bet enable");
  797. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  798. if (!acx) {
  799. ret = -ENOMEM;
  800. goto out;
  801. }
  802. acx->enable = mode;
  803. acx->max_consecutive = max_consecutive;
  804. ret = wl1251_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
  805. if (ret < 0) {
  806. wl1251_warning("wl1251 acx bet enable failed: %d", ret);
  807. goto out;
  808. }
  809. out:
  810. kfree(acx);
  811. return ret;
  812. }
  813. int wl1251_acx_ac_cfg(struct wl1251 *wl, u8 ac, u8 cw_min, u16 cw_max,
  814. u8 aifs, u16 txop)
  815. {
  816. struct wl1251_acx_ac_cfg *acx;
  817. int ret = 0;
  818. wl1251_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
  819. "aifs %d txop %d", ac, cw_min, cw_max, aifs, txop);
  820. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  821. if (!acx) {
  822. ret = -ENOMEM;
  823. goto out;
  824. }
  825. acx->ac = ac;
  826. acx->cw_min = cw_min;
  827. acx->cw_max = cw_max;
  828. acx->aifsn = aifs;
  829. acx->txop_limit = txop;
  830. ret = wl1251_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
  831. if (ret < 0) {
  832. wl1251_warning("acx ac cfg failed: %d", ret);
  833. goto out;
  834. }
  835. out:
  836. kfree(acx);
  837. return ret;
  838. }
  839. int wl1251_acx_tid_cfg(struct wl1251 *wl, u8 queue,
  840. enum wl1251_acx_channel_type type,
  841. u8 tsid, enum wl1251_acx_ps_scheme ps_scheme,
  842. enum wl1251_acx_ack_policy ack_policy)
  843. {
  844. struct wl1251_acx_tid_cfg *acx;
  845. int ret = 0;
  846. wl1251_debug(DEBUG_ACX, "acx tid cfg %d type %d tsid %d "
  847. "ps_scheme %d ack_policy %d", queue, type, tsid,
  848. ps_scheme, ack_policy);
  849. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  850. if (!acx) {
  851. ret = -ENOMEM;
  852. goto out;
  853. }
  854. acx->queue = queue;
  855. acx->type = type;
  856. acx->tsid = tsid;
  857. acx->ps_scheme = ps_scheme;
  858. acx->ack_policy = ack_policy;
  859. ret = wl1251_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
  860. if (ret < 0) {
  861. wl1251_warning("acx tid cfg failed: %d", ret);
  862. goto out;
  863. }
  864. out:
  865. kfree(acx);
  866. return ret;
  867. }