wl1251_acx.c 20 KB

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