acx.c 23 KB

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