acx.c 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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. out:
  111. kfree(auth);
  112. return ret;
  113. }
  114. int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len)
  115. {
  116. struct acx_revision *rev;
  117. int ret;
  118. wl1251_debug(DEBUG_ACX, "acx fw rev");
  119. rev = kzalloc(sizeof(*rev), GFP_KERNEL);
  120. if (!rev) {
  121. ret = -ENOMEM;
  122. goto out;
  123. }
  124. ret = wl1251_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev));
  125. if (ret < 0) {
  126. wl1251_warning("ACX_FW_REV interrogate failed");
  127. goto out;
  128. }
  129. /* be careful with the buffer sizes */
  130. strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
  131. /*
  132. * if the firmware version string is exactly
  133. * sizeof(rev->fw_version) long or fw_len is less than
  134. * sizeof(rev->fw_version) it won't be null terminated
  135. */
  136. buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
  137. out:
  138. kfree(rev);
  139. return ret;
  140. }
  141. int wl1251_acx_tx_power(struct wl1251 *wl, int power)
  142. {
  143. struct acx_current_tx_power *acx;
  144. int ret;
  145. wl1251_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr");
  146. if (power < 0 || power > 25)
  147. return -EINVAL;
  148. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  149. if (!acx) {
  150. ret = -ENOMEM;
  151. goto out;
  152. }
  153. acx->current_tx_power = power * 10;
  154. ret = wl1251_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
  155. if (ret < 0) {
  156. wl1251_warning("configure of tx power failed: %d", ret);
  157. goto out;
  158. }
  159. out:
  160. kfree(acx);
  161. return ret;
  162. }
  163. int wl1251_acx_feature_cfg(struct wl1251 *wl)
  164. {
  165. struct acx_feature_config *feature;
  166. int ret;
  167. wl1251_debug(DEBUG_ACX, "acx feature cfg");
  168. feature = kzalloc(sizeof(*feature), GFP_KERNEL);
  169. if (!feature) {
  170. ret = -ENOMEM;
  171. goto out;
  172. }
  173. /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
  174. feature->data_flow_options = 0;
  175. feature->options = 0;
  176. ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG,
  177. feature, sizeof(*feature));
  178. if (ret < 0) {
  179. wl1251_error("Couldn't set HW encryption");
  180. goto out;
  181. }
  182. out:
  183. kfree(feature);
  184. return ret;
  185. }
  186. int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map,
  187. size_t len)
  188. {
  189. int ret;
  190. wl1251_debug(DEBUG_ACX, "acx mem map");
  191. ret = wl1251_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
  192. if (ret < 0)
  193. return ret;
  194. return 0;
  195. }
  196. int wl1251_acx_data_path_params(struct wl1251 *wl,
  197. struct acx_data_path_params_resp *resp)
  198. {
  199. struct acx_data_path_params *params;
  200. int ret;
  201. wl1251_debug(DEBUG_ACX, "acx data path params");
  202. params = kzalloc(sizeof(*params), GFP_KERNEL);
  203. if (!params) {
  204. ret = -ENOMEM;
  205. goto out;
  206. }
  207. params->rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE;
  208. params->tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE;
  209. params->rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM;
  210. params->tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM;
  211. params->tx_complete_threshold = 1;
  212. params->tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE;
  213. params->tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT;
  214. ret = wl1251_cmd_configure(wl, ACX_DATA_PATH_PARAMS,
  215. params, sizeof(*params));
  216. if (ret < 0)
  217. goto out;
  218. /* FIXME: shouldn't this be ACX_DATA_PATH_RESP_PARAMS? */
  219. ret = wl1251_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS,
  220. resp, sizeof(*resp));
  221. if (ret < 0) {
  222. wl1251_warning("failed to read data path parameters: %d", ret);
  223. goto out;
  224. } else if (resp->header.cmd.status != CMD_STATUS_SUCCESS) {
  225. wl1251_warning("data path parameter acx status failed");
  226. ret = -EIO;
  227. goto out;
  228. }
  229. out:
  230. kfree(params);
  231. return ret;
  232. }
  233. int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time)
  234. {
  235. struct acx_rx_msdu_lifetime *acx;
  236. int ret;
  237. wl1251_debug(DEBUG_ACX, "acx rx msdu life time");
  238. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  239. if (!acx) {
  240. ret = -ENOMEM;
  241. goto out;
  242. }
  243. acx->lifetime = life_time;
  244. ret = wl1251_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
  245. acx, sizeof(*acx));
  246. if (ret < 0) {
  247. wl1251_warning("failed to set rx msdu life time: %d", ret);
  248. goto out;
  249. }
  250. out:
  251. kfree(acx);
  252. return ret;
  253. }
  254. int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter)
  255. {
  256. struct acx_rx_config *rx_config;
  257. int ret;
  258. wl1251_debug(DEBUG_ACX, "acx rx config");
  259. rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL);
  260. if (!rx_config) {
  261. ret = -ENOMEM;
  262. goto out;
  263. }
  264. rx_config->config_options = config;
  265. rx_config->filter_options = filter;
  266. ret = wl1251_cmd_configure(wl, ACX_RX_CFG,
  267. rx_config, sizeof(*rx_config));
  268. if (ret < 0) {
  269. wl1251_warning("failed to set rx config: %d", ret);
  270. goto out;
  271. }
  272. out:
  273. kfree(rx_config);
  274. return ret;
  275. }
  276. int wl1251_acx_pd_threshold(struct wl1251 *wl)
  277. {
  278. struct acx_packet_detection *pd;
  279. int ret;
  280. wl1251_debug(DEBUG_ACX, "acx data pd threshold");
  281. pd = kzalloc(sizeof(*pd), GFP_KERNEL);
  282. if (!pd) {
  283. ret = -ENOMEM;
  284. goto out;
  285. }
  286. /* FIXME: threshold value not set */
  287. ret = wl1251_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
  288. if (ret < 0) {
  289. wl1251_warning("failed to set pd threshold: %d", ret);
  290. goto out;
  291. }
  292. out:
  293. kfree(pd);
  294. return ret;
  295. }
  296. int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time)
  297. {
  298. struct acx_slot *slot;
  299. int ret;
  300. wl1251_debug(DEBUG_ACX, "acx slot");
  301. slot = kzalloc(sizeof(*slot), GFP_KERNEL);
  302. if (!slot) {
  303. ret = -ENOMEM;
  304. goto out;
  305. }
  306. slot->wone_index = STATION_WONE_INDEX;
  307. slot->slot_time = slot_time;
  308. ret = wl1251_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
  309. if (ret < 0) {
  310. wl1251_warning("failed to set slot time: %d", ret);
  311. goto out;
  312. }
  313. out:
  314. kfree(slot);
  315. return ret;
  316. }
  317. int wl1251_acx_group_address_tbl(struct wl1251 *wl)
  318. {
  319. struct acx_dot11_grp_addr_tbl *acx;
  320. int ret;
  321. wl1251_debug(DEBUG_ACX, "acx group address tbl");
  322. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  323. if (!acx) {
  324. ret = -ENOMEM;
  325. goto out;
  326. }
  327. /* MAC filtering */
  328. acx->enabled = 0;
  329. acx->num_groups = 0;
  330. memset(acx->mac_table, 0, ADDRESS_GROUP_MAX_LEN);
  331. ret = wl1251_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
  332. acx, sizeof(*acx));
  333. if (ret < 0) {
  334. wl1251_warning("failed to set group addr table: %d", ret);
  335. goto out;
  336. }
  337. out:
  338. kfree(acx);
  339. return ret;
  340. }
  341. int wl1251_acx_service_period_timeout(struct wl1251 *wl)
  342. {
  343. struct acx_rx_timeout *rx_timeout;
  344. int ret;
  345. rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
  346. if (!rx_timeout) {
  347. ret = -ENOMEM;
  348. goto out;
  349. }
  350. wl1251_debug(DEBUG_ACX, "acx service period timeout");
  351. rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF;
  352. rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF;
  353. ret = wl1251_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
  354. rx_timeout, sizeof(*rx_timeout));
  355. if (ret < 0) {
  356. wl1251_warning("failed to set service period timeout: %d",
  357. ret);
  358. goto out;
  359. }
  360. out:
  361. kfree(rx_timeout);
  362. return ret;
  363. }
  364. int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold)
  365. {
  366. struct acx_rts_threshold *rts;
  367. int ret;
  368. wl1251_debug(DEBUG_ACX, "acx rts threshold");
  369. rts = kzalloc(sizeof(*rts), GFP_KERNEL);
  370. if (!rts) {
  371. ret = -ENOMEM;
  372. goto out;
  373. }
  374. rts->threshold = rts_threshold;
  375. ret = wl1251_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
  376. if (ret < 0) {
  377. wl1251_warning("failed to set rts threshold: %d", ret);
  378. goto out;
  379. }
  380. out:
  381. kfree(rts);
  382. return ret;
  383. }
  384. int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter)
  385. {
  386. struct acx_beacon_filter_option *beacon_filter;
  387. int ret;
  388. wl1251_debug(DEBUG_ACX, "acx beacon filter opt");
  389. beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
  390. if (!beacon_filter) {
  391. ret = -ENOMEM;
  392. goto out;
  393. }
  394. beacon_filter->enable = enable_filter;
  395. beacon_filter->max_num_beacons = 0;
  396. ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
  397. beacon_filter, sizeof(*beacon_filter));
  398. if (ret < 0) {
  399. wl1251_warning("failed to set beacon filter opt: %d", ret);
  400. goto out;
  401. }
  402. out:
  403. kfree(beacon_filter);
  404. return ret;
  405. }
  406. int wl1251_acx_beacon_filter_table(struct wl1251 *wl)
  407. {
  408. struct acx_beacon_filter_ie_table *ie_table;
  409. int idx = 0;
  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. /* configure default beacon pass-through rules */
  418. ie_table->num_ie = 1;
  419. ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN;
  420. ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE;
  421. ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
  422. ie_table, sizeof(*ie_table));
  423. if (ret < 0) {
  424. wl1251_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 wl1251_acx_conn_monit_params(struct wl1251 *wl)
  432. {
  433. struct acx_conn_monit_params *acx;
  434. int ret;
  435. wl1251_debug(DEBUG_ACX, "acx connection monitor parameters");
  436. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  437. if (!acx) {
  438. ret = -ENOMEM;
  439. goto out;
  440. }
  441. acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD;
  442. acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT;
  443. ret = wl1251_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
  444. acx, sizeof(*acx));
  445. if (ret < 0) {
  446. wl1251_warning("failed to set connection monitor "
  447. "parameters: %d", ret);
  448. goto out;
  449. }
  450. out:
  451. kfree(acx);
  452. return ret;
  453. }
  454. int wl1251_acx_sg_enable(struct wl1251 *wl)
  455. {
  456. struct acx_bt_wlan_coex *pta;
  457. int ret;
  458. wl1251_debug(DEBUG_ACX, "acx sg enable");
  459. pta = kzalloc(sizeof(*pta), GFP_KERNEL);
  460. if (!pta) {
  461. ret = -ENOMEM;
  462. goto out;
  463. }
  464. pta->enable = SG_ENABLE;
  465. ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
  466. if (ret < 0) {
  467. wl1251_warning("failed to set softgemini enable: %d", ret);
  468. goto out;
  469. }
  470. out:
  471. kfree(pta);
  472. return ret;
  473. }
  474. int wl1251_acx_sg_cfg(struct wl1251 *wl)
  475. {
  476. struct acx_bt_wlan_coex_param *param;
  477. int ret;
  478. wl1251_debug(DEBUG_ACX, "acx sg cfg");
  479. param = kzalloc(sizeof(*param), GFP_KERNEL);
  480. if (!param) {
  481. ret = -ENOMEM;
  482. goto out;
  483. }
  484. /* BT-WLAN coext parameters */
  485. param->min_rate = RATE_INDEX_24MBPS;
  486. param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
  487. param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
  488. param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
  489. param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
  490. param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
  491. param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
  492. param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
  493. param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
  494. param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
  495. param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
  496. param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
  497. param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
  498. param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
  499. param->antenna_type = PTA_ANTENNA_TYPE_DEF;
  500. param->signal_type = PTA_SIGNALING_TYPE_DEF;
  501. param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
  502. param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
  503. param->max_cts = PTA_MAX_NUM_CTS_DEF;
  504. param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
  505. param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
  506. param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
  507. param->wlan_elp_hp = PTA_ELP_HP_DEF;
  508. param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
  509. param->ack_mode_dual_ant = PTA_ACK_MODE_DEF;
  510. param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
  511. param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
  512. param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
  513. ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
  514. if (ret < 0) {
  515. wl1251_warning("failed to set sg config: %d", ret);
  516. goto out;
  517. }
  518. out:
  519. kfree(param);
  520. return ret;
  521. }
  522. int wl1251_acx_cca_threshold(struct wl1251 *wl)
  523. {
  524. struct acx_energy_detection *detection;
  525. int ret;
  526. wl1251_debug(DEBUG_ACX, "acx cca threshold");
  527. detection = kzalloc(sizeof(*detection), GFP_KERNEL);
  528. if (!detection) {
  529. ret = -ENOMEM;
  530. goto out;
  531. }
  532. detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
  533. detection->tx_energy_detection = 0;
  534. ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD,
  535. detection, sizeof(*detection));
  536. if (ret < 0)
  537. wl1251_warning("failed to set cca threshold: %d", ret);
  538. out:
  539. kfree(detection);
  540. return ret;
  541. }
  542. int wl1251_acx_bcn_dtim_options(struct wl1251 *wl)
  543. {
  544. struct acx_beacon_broadcast *bb;
  545. int ret;
  546. wl1251_debug(DEBUG_ACX, "acx bcn dtim options");
  547. bb = kzalloc(sizeof(*bb), GFP_KERNEL);
  548. if (!bb) {
  549. ret = -ENOMEM;
  550. goto out;
  551. }
  552. bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
  553. bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
  554. bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
  555. bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
  556. ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
  557. if (ret < 0) {
  558. wl1251_warning("failed to set rx config: %d", ret);
  559. goto out;
  560. }
  561. out:
  562. kfree(bb);
  563. return ret;
  564. }
  565. int wl1251_acx_aid(struct wl1251 *wl, u16 aid)
  566. {
  567. struct acx_aid *acx_aid;
  568. int ret;
  569. wl1251_debug(DEBUG_ACX, "acx aid");
  570. acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
  571. if (!acx_aid) {
  572. ret = -ENOMEM;
  573. goto out;
  574. }
  575. acx_aid->aid = aid;
  576. ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
  577. if (ret < 0) {
  578. wl1251_warning("failed to set aid: %d", ret);
  579. goto out;
  580. }
  581. out:
  582. kfree(acx_aid);
  583. return ret;
  584. }
  585. int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask)
  586. {
  587. struct acx_event_mask *mask;
  588. int ret;
  589. wl1251_debug(DEBUG_ACX, "acx event mbox mask");
  590. mask = kzalloc(sizeof(*mask), GFP_KERNEL);
  591. if (!mask) {
  592. ret = -ENOMEM;
  593. goto out;
  594. }
  595. /* high event mask is unused */
  596. mask->high_event_mask = 0xffffffff;
  597. mask->event_mask = event_mask;
  598. ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
  599. mask, sizeof(*mask));
  600. if (ret < 0) {
  601. wl1251_warning("failed to set acx_event_mbox_mask: %d", ret);
  602. goto out;
  603. }
  604. out:
  605. kfree(mask);
  606. return ret;
  607. }
  608. int wl1251_acx_low_rssi(struct wl1251 *wl, s8 threshold, u8 weight,
  609. u8 depth, enum wl1251_acx_low_rssi_type type)
  610. {
  611. struct acx_low_rssi *rssi;
  612. int ret;
  613. wl1251_debug(DEBUG_ACX, "acx low rssi");
  614. rssi = kzalloc(sizeof(*rssi), GFP_KERNEL);
  615. if (!rssi)
  616. return -ENOMEM;
  617. rssi->threshold = threshold;
  618. rssi->weight = weight;
  619. rssi->depth = depth;
  620. rssi->type = type;
  621. ret = wl1251_cmd_configure(wl, ACX_LOW_RSSI, rssi, sizeof(*rssi));
  622. if (ret < 0)
  623. wl1251_warning("failed to set low rssi threshold: %d", ret);
  624. kfree(rssi);
  625. return ret;
  626. }
  627. int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble)
  628. {
  629. struct acx_preamble *acx;
  630. int ret;
  631. wl1251_debug(DEBUG_ACX, "acx_set_preamble");
  632. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  633. if (!acx) {
  634. ret = -ENOMEM;
  635. goto out;
  636. }
  637. acx->preamble = preamble;
  638. ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
  639. if (ret < 0) {
  640. wl1251_warning("Setting of preamble failed: %d", ret);
  641. goto out;
  642. }
  643. out:
  644. kfree(acx);
  645. return ret;
  646. }
  647. int wl1251_acx_cts_protect(struct wl1251 *wl,
  648. enum acx_ctsprotect_type ctsprotect)
  649. {
  650. struct acx_ctsprotect *acx;
  651. int ret;
  652. wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect");
  653. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  654. if (!acx) {
  655. ret = -ENOMEM;
  656. goto out;
  657. }
  658. acx->ctsprotect = ctsprotect;
  659. ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
  660. if (ret < 0) {
  661. wl1251_warning("Setting of ctsprotect failed: %d", ret);
  662. goto out;
  663. }
  664. out:
  665. kfree(acx);
  666. return ret;
  667. }
  668. int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime)
  669. {
  670. struct acx_tsf_info *tsf_info;
  671. int ret;
  672. tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
  673. if (!tsf_info) {
  674. ret = -ENOMEM;
  675. goto out;
  676. }
  677. ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO,
  678. tsf_info, sizeof(*tsf_info));
  679. if (ret < 0) {
  680. wl1251_warning("ACX_FW_REV interrogate failed");
  681. goto out;
  682. }
  683. *mactime = tsf_info->current_tsf_lsb |
  684. (tsf_info->current_tsf_msb << 31);
  685. out:
  686. kfree(tsf_info);
  687. return ret;
  688. }
  689. int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats)
  690. {
  691. int ret;
  692. wl1251_debug(DEBUG_ACX, "acx statistics");
  693. ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats,
  694. sizeof(*stats));
  695. if (ret < 0) {
  696. wl1251_warning("acx statistics failed: %d", ret);
  697. return -ENOMEM;
  698. }
  699. return 0;
  700. }
  701. int wl1251_acx_rate_policies(struct wl1251 *wl)
  702. {
  703. struct acx_rate_policy *acx;
  704. int ret = 0;
  705. wl1251_debug(DEBUG_ACX, "acx rate policies");
  706. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  707. if (!acx) {
  708. ret = -ENOMEM;
  709. goto out;
  710. }
  711. /* configure one default (one-size-fits-all) rate class */
  712. acx->rate_class_cnt = 1;
  713. acx->rate_class[0].enabled_rates = ACX_RATE_MASK_UNSPECIFIED;
  714. acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT;
  715. acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT;
  716. acx->rate_class[0].aflags = 0;
  717. ret = wl1251_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  718. if (ret < 0) {
  719. wl1251_warning("Setting of rate policies failed: %d", ret);
  720. goto out;
  721. }
  722. out:
  723. kfree(acx);
  724. return ret;
  725. }
  726. int wl1251_acx_mem_cfg(struct wl1251 *wl)
  727. {
  728. struct wl1251_acx_config_memory *mem_conf;
  729. int ret, i;
  730. wl1251_debug(DEBUG_ACX, "acx mem cfg");
  731. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  732. if (!mem_conf) {
  733. ret = -ENOMEM;
  734. goto out;
  735. }
  736. /* memory config */
  737. mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS);
  738. mem_conf->mem_config.rx_mem_block_num = 35;
  739. mem_conf->mem_config.tx_min_mem_block_num = 64;
  740. mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES;
  741. mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING;
  742. mem_conf->mem_config.num_ssid_profiles = 1;
  743. mem_conf->mem_config.debug_buffer_size =
  744. cpu_to_le16(TRACE_BUFFER_MAX_SIZE);
  745. /* RX queue config */
  746. mem_conf->rx_queue_config.dma_address = 0;
  747. mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF;
  748. mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY;
  749. mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE;
  750. /* TX queue config */
  751. for (i = 0; i < MAX_TX_QUEUES; i++) {
  752. mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF;
  753. mem_conf->tx_queue_config[i].attributes = i;
  754. }
  755. ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  756. sizeof(*mem_conf));
  757. if (ret < 0) {
  758. wl1251_warning("wl1251 mem config failed: %d", ret);
  759. goto out;
  760. }
  761. out:
  762. kfree(mem_conf);
  763. return ret;
  764. }
  765. int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim)
  766. {
  767. struct wl1251_acx_wr_tbtt_and_dtim *acx;
  768. int ret;
  769. wl1251_debug(DEBUG_ACX, "acx tbtt and dtim");
  770. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  771. if (!acx) {
  772. ret = -ENOMEM;
  773. goto out;
  774. }
  775. acx->tbtt = tbtt;
  776. acx->dtim = dtim;
  777. ret = wl1251_cmd_configure(wl, ACX_WR_TBTT_AND_DTIM,
  778. acx, sizeof(*acx));
  779. if (ret < 0) {
  780. wl1251_warning("failed to set tbtt and dtim: %d", ret);
  781. goto out;
  782. }
  783. out:
  784. kfree(acx);
  785. return ret;
  786. }
  787. int wl1251_acx_bet_enable(struct wl1251 *wl, enum wl1251_acx_bet_mode mode,
  788. u8 max_consecutive)
  789. {
  790. struct wl1251_acx_bet_enable *acx;
  791. int ret;
  792. wl1251_debug(DEBUG_ACX, "acx bet enable");
  793. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  794. if (!acx) {
  795. ret = -ENOMEM;
  796. goto out;
  797. }
  798. acx->enable = mode;
  799. acx->max_consecutive = max_consecutive;
  800. ret = wl1251_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
  801. if (ret < 0) {
  802. wl1251_warning("wl1251 acx bet enable failed: %d", ret);
  803. goto out;
  804. }
  805. out:
  806. kfree(acx);
  807. return ret;
  808. }
  809. int wl1251_acx_ac_cfg(struct wl1251 *wl, u8 ac, u8 cw_min, u16 cw_max,
  810. u8 aifs, u16 txop)
  811. {
  812. struct wl1251_acx_ac_cfg *acx;
  813. int ret = 0;
  814. wl1251_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
  815. "aifs %d txop %d", ac, cw_min, cw_max, aifs, txop);
  816. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  817. if (!acx) {
  818. ret = -ENOMEM;
  819. goto out;
  820. }
  821. acx->ac = ac;
  822. acx->cw_min = cw_min;
  823. acx->cw_max = cw_max;
  824. acx->aifsn = aifs;
  825. acx->txop_limit = txop;
  826. ret = wl1251_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
  827. if (ret < 0) {
  828. wl1251_warning("acx ac cfg failed: %d", ret);
  829. goto out;
  830. }
  831. out:
  832. kfree(acx);
  833. return ret;
  834. }
  835. int wl1251_acx_tid_cfg(struct wl1251 *wl, u8 queue,
  836. enum wl1251_acx_channel_type type,
  837. u8 tsid, enum wl1251_acx_ps_scheme ps_scheme,
  838. enum wl1251_acx_ack_policy ack_policy)
  839. {
  840. struct wl1251_acx_tid_cfg *acx;
  841. int ret = 0;
  842. wl1251_debug(DEBUG_ACX, "acx tid cfg %d type %d tsid %d "
  843. "ps_scheme %d ack_policy %d", queue, type, tsid,
  844. ps_scheme, ack_policy);
  845. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  846. if (!acx) {
  847. ret = -ENOMEM;
  848. goto out;
  849. }
  850. acx->queue = queue;
  851. acx->type = type;
  852. acx->tsid = tsid;
  853. acx->ps_scheme = ps_scheme;
  854. acx->ack_policy = ack_policy;
  855. ret = wl1251_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
  856. if (ret < 0) {
  857. wl1251_warning("acx tid cfg failed: %d", ret);
  858. goto out;
  859. }
  860. out:
  861. kfree(acx);
  862. return ret;
  863. }