acx.c 23 KB

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