acx.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2008-2009 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #include "acx.h"
  24. #include <linux/module.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/slab.h>
  28. #include "wl12xx.h"
  29. #include "wl12xx_80211.h"
  30. #include "reg.h"
  31. #include "ps.h"
  32. int wl1271_acx_wake_up_conditions(struct wl1271 *wl)
  33. {
  34. struct acx_wake_up_condition *wake_up;
  35. int ret;
  36. wl1271_debug(DEBUG_ACX, "acx wake up conditions");
  37. wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
  38. if (!wake_up) {
  39. ret = -ENOMEM;
  40. goto out;
  41. }
  42. wake_up->role_id = wl->role_id;
  43. wake_up->wake_up_event = wl->conf.conn.wake_up_event;
  44. wake_up->listen_interval = wl->conf.conn.listen_interval;
  45. ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
  46. wake_up, sizeof(*wake_up));
  47. if (ret < 0) {
  48. wl1271_warning("could not set wake up conditions: %d", ret);
  49. goto out;
  50. }
  51. out:
  52. kfree(wake_up);
  53. return ret;
  54. }
  55. int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
  56. {
  57. struct acx_sleep_auth *auth;
  58. int ret;
  59. wl1271_debug(DEBUG_ACX, "acx sleep auth");
  60. auth = kzalloc(sizeof(*auth), GFP_KERNEL);
  61. if (!auth) {
  62. ret = -ENOMEM;
  63. goto out;
  64. }
  65. auth->sleep_auth = sleep_auth;
  66. ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
  67. if (ret < 0)
  68. return ret;
  69. out:
  70. kfree(auth);
  71. return ret;
  72. }
  73. int wl1271_acx_tx_power(struct wl1271 *wl, int power)
  74. {
  75. struct acx_current_tx_power *acx;
  76. int ret;
  77. wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
  78. if (power < 0 || power > 25)
  79. return -EINVAL;
  80. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  81. if (!acx) {
  82. ret = -ENOMEM;
  83. goto out;
  84. }
  85. acx->role_id = wl->role_id;
  86. acx->current_tx_power = power * 10;
  87. ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
  88. if (ret < 0) {
  89. wl1271_warning("configure of tx power failed: %d", ret);
  90. goto out;
  91. }
  92. out:
  93. kfree(acx);
  94. return ret;
  95. }
  96. int wl1271_acx_feature_cfg(struct wl1271 *wl)
  97. {
  98. struct acx_feature_config *feature;
  99. int ret;
  100. wl1271_debug(DEBUG_ACX, "acx feature cfg");
  101. feature = kzalloc(sizeof(*feature), GFP_KERNEL);
  102. if (!feature) {
  103. ret = -ENOMEM;
  104. goto out;
  105. }
  106. /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
  107. feature->role_id = wl->role_id;
  108. feature->data_flow_options = 0;
  109. feature->options = 0;
  110. ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
  111. feature, sizeof(*feature));
  112. if (ret < 0) {
  113. wl1271_error("Couldnt set HW encryption");
  114. goto out;
  115. }
  116. out:
  117. kfree(feature);
  118. return ret;
  119. }
  120. int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
  121. size_t len)
  122. {
  123. int ret;
  124. wl1271_debug(DEBUG_ACX, "acx mem map");
  125. ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
  126. if (ret < 0)
  127. return ret;
  128. return 0;
  129. }
  130. int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
  131. {
  132. struct acx_rx_msdu_lifetime *acx;
  133. int ret;
  134. wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
  135. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  136. if (!acx) {
  137. ret = -ENOMEM;
  138. goto out;
  139. }
  140. acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
  141. ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
  142. acx, sizeof(*acx));
  143. if (ret < 0) {
  144. wl1271_warning("failed to set rx msdu life time: %d", ret);
  145. goto out;
  146. }
  147. out:
  148. kfree(acx);
  149. return ret;
  150. }
  151. int wl1271_acx_pd_threshold(struct wl1271 *wl)
  152. {
  153. struct acx_packet_detection *pd;
  154. int ret;
  155. wl1271_debug(DEBUG_ACX, "acx data pd threshold");
  156. pd = kzalloc(sizeof(*pd), GFP_KERNEL);
  157. if (!pd) {
  158. ret = -ENOMEM;
  159. goto out;
  160. }
  161. pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold);
  162. ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
  163. if (ret < 0) {
  164. wl1271_warning("failed to set pd threshold: %d", ret);
  165. goto out;
  166. }
  167. out:
  168. kfree(pd);
  169. return ret;
  170. }
  171. int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time)
  172. {
  173. struct acx_slot *slot;
  174. int ret;
  175. wl1271_debug(DEBUG_ACX, "acx slot");
  176. slot = kzalloc(sizeof(*slot), GFP_KERNEL);
  177. if (!slot) {
  178. ret = -ENOMEM;
  179. goto out;
  180. }
  181. slot->role_id = wl->role_id;
  182. slot->wone_index = STATION_WONE_INDEX;
  183. slot->slot_time = slot_time;
  184. ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
  185. if (ret < 0) {
  186. wl1271_warning("failed to set slot time: %d", ret);
  187. goto out;
  188. }
  189. out:
  190. kfree(slot);
  191. return ret;
  192. }
  193. int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable,
  194. void *mc_list, u32 mc_list_len)
  195. {
  196. struct acx_dot11_grp_addr_tbl *acx;
  197. int ret;
  198. wl1271_debug(DEBUG_ACX, "acx group address tbl");
  199. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  200. if (!acx) {
  201. ret = -ENOMEM;
  202. goto out;
  203. }
  204. /* MAC filtering */
  205. acx->role_id = wl->role_id;
  206. acx->enabled = enable;
  207. acx->num_groups = mc_list_len;
  208. memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
  209. ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
  210. acx, sizeof(*acx));
  211. if (ret < 0) {
  212. wl1271_warning("failed to set group addr table: %d", ret);
  213. goto out;
  214. }
  215. out:
  216. kfree(acx);
  217. return ret;
  218. }
  219. int wl1271_acx_service_period_timeout(struct wl1271 *wl)
  220. {
  221. struct acx_rx_timeout *rx_timeout;
  222. int ret;
  223. rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
  224. if (!rx_timeout) {
  225. ret = -ENOMEM;
  226. goto out;
  227. }
  228. wl1271_debug(DEBUG_ACX, "acx service period timeout");
  229. rx_timeout->role_id = wl->role_id;
  230. rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
  231. rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
  232. ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
  233. rx_timeout, sizeof(*rx_timeout));
  234. if (ret < 0) {
  235. wl1271_warning("failed to set service period timeout: %d",
  236. ret);
  237. goto out;
  238. }
  239. out:
  240. kfree(rx_timeout);
  241. return ret;
  242. }
  243. int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold)
  244. {
  245. struct acx_rts_threshold *rts;
  246. int ret;
  247. /*
  248. * If the RTS threshold is not configured or out of range, use the
  249. * default value.
  250. */
  251. if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
  252. rts_threshold = wl->conf.rx.rts_threshold;
  253. wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
  254. rts = kzalloc(sizeof(*rts), GFP_KERNEL);
  255. if (!rts) {
  256. ret = -ENOMEM;
  257. goto out;
  258. }
  259. rts->role_id = wl->role_id;
  260. rts->threshold = cpu_to_le16((u16)rts_threshold);
  261. ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
  262. if (ret < 0) {
  263. wl1271_warning("failed to set rts threshold: %d", ret);
  264. goto out;
  265. }
  266. out:
  267. kfree(rts);
  268. return ret;
  269. }
  270. int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
  271. {
  272. struct acx_dco_itrim_params *dco;
  273. struct conf_itrim_settings *c = &wl->conf.itrim;
  274. int ret;
  275. wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
  276. dco = kzalloc(sizeof(*dco), GFP_KERNEL);
  277. if (!dco) {
  278. ret = -ENOMEM;
  279. goto out;
  280. }
  281. dco->enable = c->enable;
  282. dco->timeout = cpu_to_le32(c->timeout);
  283. ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
  284. dco, sizeof(*dco));
  285. if (ret < 0) {
  286. wl1271_warning("failed to set dco itrim parameters: %d", ret);
  287. goto out;
  288. }
  289. out:
  290. kfree(dco);
  291. return ret;
  292. }
  293. int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter)
  294. {
  295. struct acx_beacon_filter_option *beacon_filter = NULL;
  296. int ret = 0;
  297. wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
  298. if (enable_filter &&
  299. wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
  300. goto out;
  301. beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
  302. if (!beacon_filter) {
  303. ret = -ENOMEM;
  304. goto out;
  305. }
  306. beacon_filter->role_id = wl->role_id;
  307. beacon_filter->enable = enable_filter;
  308. /*
  309. * When set to zero, and the filter is enabled, beacons
  310. * without the unicast TIM bit set are dropped.
  311. */
  312. beacon_filter->max_num_beacons = 0;
  313. ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
  314. beacon_filter, sizeof(*beacon_filter));
  315. if (ret < 0) {
  316. wl1271_warning("failed to set beacon filter opt: %d", ret);
  317. goto out;
  318. }
  319. out:
  320. kfree(beacon_filter);
  321. return ret;
  322. }
  323. int wl1271_acx_beacon_filter_table(struct wl1271 *wl)
  324. {
  325. struct acx_beacon_filter_ie_table *ie_table;
  326. int i, idx = 0;
  327. int ret;
  328. bool vendor_spec = false;
  329. wl1271_debug(DEBUG_ACX, "acx beacon filter table");
  330. ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
  331. if (!ie_table) {
  332. ret = -ENOMEM;
  333. goto out;
  334. }
  335. /* configure default beacon pass-through rules */
  336. ie_table->role_id = wl->role_id;
  337. ie_table->num_ie = 0;
  338. for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
  339. struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
  340. ie_table->table[idx++] = r->ie;
  341. ie_table->table[idx++] = r->rule;
  342. if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
  343. /* only one vendor specific ie allowed */
  344. if (vendor_spec)
  345. continue;
  346. /* for vendor specific rules configure the
  347. additional fields */
  348. memcpy(&(ie_table->table[idx]), r->oui,
  349. CONF_BCN_IE_OUI_LEN);
  350. idx += CONF_BCN_IE_OUI_LEN;
  351. ie_table->table[idx++] = r->type;
  352. memcpy(&(ie_table->table[idx]), r->version,
  353. CONF_BCN_IE_VER_LEN);
  354. idx += CONF_BCN_IE_VER_LEN;
  355. vendor_spec = true;
  356. }
  357. ie_table->num_ie++;
  358. }
  359. ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
  360. ie_table, sizeof(*ie_table));
  361. if (ret < 0) {
  362. wl1271_warning("failed to set beacon filter table: %d", ret);
  363. goto out;
  364. }
  365. out:
  366. kfree(ie_table);
  367. return ret;
  368. }
  369. #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
  370. int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable)
  371. {
  372. struct acx_conn_monit_params *acx;
  373. u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
  374. u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
  375. int ret;
  376. wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
  377. enable ? "enabled" : "disabled");
  378. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  379. if (!acx) {
  380. ret = -ENOMEM;
  381. goto out;
  382. }
  383. if (enable) {
  384. threshold = wl->conf.conn.synch_fail_thold;
  385. timeout = wl->conf.conn.bss_lose_timeout;
  386. }
  387. acx->role_id = wl->role_id;
  388. acx->synch_fail_thold = cpu_to_le32(threshold);
  389. acx->bss_lose_timeout = cpu_to_le32(timeout);
  390. ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
  391. acx, sizeof(*acx));
  392. if (ret < 0) {
  393. wl1271_warning("failed to set connection monitor "
  394. "parameters: %d", ret);
  395. goto out;
  396. }
  397. out:
  398. kfree(acx);
  399. return ret;
  400. }
  401. int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
  402. {
  403. struct acx_bt_wlan_coex *pta;
  404. int ret;
  405. wl1271_debug(DEBUG_ACX, "acx sg enable");
  406. pta = kzalloc(sizeof(*pta), GFP_KERNEL);
  407. if (!pta) {
  408. ret = -ENOMEM;
  409. goto out;
  410. }
  411. if (enable)
  412. pta->enable = wl->conf.sg.state;
  413. else
  414. pta->enable = CONF_SG_DISABLE;
  415. ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
  416. if (ret < 0) {
  417. wl1271_warning("failed to set softgemini enable: %d", ret);
  418. goto out;
  419. }
  420. out:
  421. kfree(pta);
  422. return ret;
  423. }
  424. int wl12xx_acx_sg_cfg(struct wl1271 *wl)
  425. {
  426. struct acx_bt_wlan_coex_param *param;
  427. struct conf_sg_settings *c = &wl->conf.sg;
  428. int i, ret;
  429. wl1271_debug(DEBUG_ACX, "acx sg cfg");
  430. param = kzalloc(sizeof(*param), GFP_KERNEL);
  431. if (!param) {
  432. ret = -ENOMEM;
  433. goto out;
  434. }
  435. /* BT-WLAN coext parameters */
  436. for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
  437. param->params[i] = cpu_to_le32(c->params[i]);
  438. param->param_idx = CONF_SG_PARAMS_ALL;
  439. ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
  440. if (ret < 0) {
  441. wl1271_warning("failed to set sg config: %d", ret);
  442. goto out;
  443. }
  444. out:
  445. kfree(param);
  446. return ret;
  447. }
  448. int wl1271_acx_cca_threshold(struct wl1271 *wl)
  449. {
  450. struct acx_energy_detection *detection;
  451. int ret;
  452. wl1271_debug(DEBUG_ACX, "acx cca threshold");
  453. detection = kzalloc(sizeof(*detection), GFP_KERNEL);
  454. if (!detection) {
  455. ret = -ENOMEM;
  456. goto out;
  457. }
  458. detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
  459. detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
  460. ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
  461. detection, sizeof(*detection));
  462. if (ret < 0) {
  463. wl1271_warning("failed to set cca threshold: %d", ret);
  464. return ret;
  465. }
  466. out:
  467. kfree(detection);
  468. return ret;
  469. }
  470. int wl1271_acx_bcn_dtim_options(struct wl1271 *wl)
  471. {
  472. struct acx_beacon_broadcast *bb;
  473. int ret;
  474. wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
  475. bb = kzalloc(sizeof(*bb), GFP_KERNEL);
  476. if (!bb) {
  477. ret = -ENOMEM;
  478. goto out;
  479. }
  480. bb->role_id = wl->role_id;
  481. bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
  482. bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
  483. bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
  484. bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
  485. ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
  486. if (ret < 0) {
  487. wl1271_warning("failed to set rx config: %d", ret);
  488. goto out;
  489. }
  490. out:
  491. kfree(bb);
  492. return ret;
  493. }
  494. int wl1271_acx_aid(struct wl1271 *wl, u16 aid)
  495. {
  496. struct acx_aid *acx_aid;
  497. int ret;
  498. wl1271_debug(DEBUG_ACX, "acx aid");
  499. acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
  500. if (!acx_aid) {
  501. ret = -ENOMEM;
  502. goto out;
  503. }
  504. acx_aid->role_id = wl->role_id;
  505. acx_aid->aid = cpu_to_le16(aid);
  506. ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
  507. if (ret < 0) {
  508. wl1271_warning("failed to set aid: %d", ret);
  509. goto out;
  510. }
  511. out:
  512. kfree(acx_aid);
  513. return ret;
  514. }
  515. int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
  516. {
  517. struct acx_event_mask *mask;
  518. int ret;
  519. wl1271_debug(DEBUG_ACX, "acx event mbox mask");
  520. mask = kzalloc(sizeof(*mask), GFP_KERNEL);
  521. if (!mask) {
  522. ret = -ENOMEM;
  523. goto out;
  524. }
  525. /* high event mask is unused */
  526. mask->high_event_mask = cpu_to_le32(0xffffffff);
  527. mask->event_mask = cpu_to_le32(event_mask);
  528. ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
  529. mask, sizeof(*mask));
  530. if (ret < 0) {
  531. wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
  532. goto out;
  533. }
  534. out:
  535. kfree(mask);
  536. return ret;
  537. }
  538. int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble)
  539. {
  540. struct acx_preamble *acx;
  541. int ret;
  542. wl1271_debug(DEBUG_ACX, "acx_set_preamble");
  543. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  544. if (!acx) {
  545. ret = -ENOMEM;
  546. goto out;
  547. }
  548. acx->role_id = wl->role_id;
  549. acx->preamble = preamble;
  550. ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
  551. if (ret < 0) {
  552. wl1271_warning("Setting of preamble failed: %d", ret);
  553. goto out;
  554. }
  555. out:
  556. kfree(acx);
  557. return ret;
  558. }
  559. int wl1271_acx_cts_protect(struct wl1271 *wl,
  560. enum acx_ctsprotect_type ctsprotect)
  561. {
  562. struct acx_ctsprotect *acx;
  563. int ret;
  564. wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
  565. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  566. if (!acx) {
  567. ret = -ENOMEM;
  568. goto out;
  569. }
  570. acx->role_id = wl->role_id;
  571. acx->ctsprotect = ctsprotect;
  572. ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
  573. if (ret < 0) {
  574. wl1271_warning("Setting of ctsprotect failed: %d", ret);
  575. goto out;
  576. }
  577. out:
  578. kfree(acx);
  579. return ret;
  580. }
  581. int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
  582. {
  583. int ret;
  584. wl1271_debug(DEBUG_ACX, "acx statistics");
  585. ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
  586. sizeof(*stats));
  587. if (ret < 0) {
  588. wl1271_warning("acx statistics failed: %d", ret);
  589. return -ENOMEM;
  590. }
  591. return 0;
  592. }
  593. int wl1271_acx_sta_rate_policies(struct wl1271 *wl)
  594. {
  595. struct acx_rate_policy *acx;
  596. struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
  597. int ret = 0;
  598. wl1271_debug(DEBUG_ACX, "acx rate policies");
  599. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  600. if (!acx) {
  601. ret = -ENOMEM;
  602. goto out;
  603. }
  604. wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
  605. wl->basic_rate, wl->rate_set);
  606. /* configure one basic rate class */
  607. acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE);
  608. acx->rate_policy.enabled_rates = cpu_to_le32(wl->basic_rate);
  609. acx->rate_policy.short_retry_limit = c->short_retry_limit;
  610. acx->rate_policy.long_retry_limit = c->long_retry_limit;
  611. acx->rate_policy.aflags = c->aflags;
  612. ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  613. if (ret < 0) {
  614. wl1271_warning("Setting of rate policies failed: %d", ret);
  615. goto out;
  616. }
  617. /* configure one AP supported rate class */
  618. acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE);
  619. acx->rate_policy.enabled_rates = cpu_to_le32(wl->rate_set);
  620. acx->rate_policy.short_retry_limit = c->short_retry_limit;
  621. acx->rate_policy.long_retry_limit = c->long_retry_limit;
  622. acx->rate_policy.aflags = c->aflags;
  623. ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  624. if (ret < 0) {
  625. wl1271_warning("Setting of rate policies failed: %d", ret);
  626. goto out;
  627. }
  628. out:
  629. kfree(acx);
  630. return ret;
  631. }
  632. int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
  633. u8 idx)
  634. {
  635. struct acx_rate_policy *acx;
  636. int ret = 0;
  637. wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
  638. idx, c->enabled_rates);
  639. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  640. if (!acx) {
  641. ret = -ENOMEM;
  642. goto out;
  643. }
  644. acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
  645. acx->rate_policy.short_retry_limit = c->short_retry_limit;
  646. acx->rate_policy.long_retry_limit = c->long_retry_limit;
  647. acx->rate_policy.aflags = c->aflags;
  648. acx->rate_policy_idx = cpu_to_le32(idx);
  649. ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  650. if (ret < 0) {
  651. wl1271_warning("Setting of ap rate policy failed: %d", ret);
  652. goto out;
  653. }
  654. out:
  655. kfree(acx);
  656. return ret;
  657. }
  658. int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
  659. u8 aifsn, u16 txop)
  660. {
  661. struct acx_ac_cfg *acx;
  662. int ret = 0;
  663. wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
  664. "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
  665. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  666. if (!acx) {
  667. ret = -ENOMEM;
  668. goto out;
  669. }
  670. acx->role_id = wl->role_id;
  671. acx->ac = ac;
  672. acx->cw_min = cw_min;
  673. acx->cw_max = cpu_to_le16(cw_max);
  674. acx->aifsn = aifsn;
  675. acx->tx_op_limit = cpu_to_le16(txop);
  676. ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
  677. if (ret < 0) {
  678. wl1271_warning("acx ac cfg failed: %d", ret);
  679. goto out;
  680. }
  681. out:
  682. kfree(acx);
  683. return ret;
  684. }
  685. int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
  686. u8 tsid, u8 ps_scheme, u8 ack_policy,
  687. u32 apsd_conf0, u32 apsd_conf1)
  688. {
  689. struct acx_tid_config *acx;
  690. int ret = 0;
  691. wl1271_debug(DEBUG_ACX, "acx tid config");
  692. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  693. if (!acx) {
  694. ret = -ENOMEM;
  695. goto out;
  696. }
  697. acx->role_id = wl->role_id;
  698. acx->queue_id = queue_id;
  699. acx->channel_type = channel_type;
  700. acx->tsid = tsid;
  701. acx->ps_scheme = ps_scheme;
  702. acx->ack_policy = ack_policy;
  703. acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
  704. acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
  705. ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
  706. if (ret < 0) {
  707. wl1271_warning("Setting of tid config failed: %d", ret);
  708. goto out;
  709. }
  710. out:
  711. kfree(acx);
  712. return ret;
  713. }
  714. int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
  715. {
  716. struct acx_frag_threshold *acx;
  717. int ret = 0;
  718. /*
  719. * If the fragmentation is not configured or out of range, use the
  720. * default value.
  721. */
  722. if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
  723. frag_threshold = wl->conf.tx.frag_threshold;
  724. wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
  725. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  726. if (!acx) {
  727. ret = -ENOMEM;
  728. goto out;
  729. }
  730. acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
  731. ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
  732. if (ret < 0) {
  733. wl1271_warning("Setting of frag threshold failed: %d", ret);
  734. goto out;
  735. }
  736. out:
  737. kfree(acx);
  738. return ret;
  739. }
  740. int wl1271_acx_tx_config_options(struct wl1271 *wl)
  741. {
  742. struct acx_tx_config_options *acx;
  743. int ret = 0;
  744. wl1271_debug(DEBUG_ACX, "acx tx config options");
  745. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  746. if (!acx) {
  747. ret = -ENOMEM;
  748. goto out;
  749. }
  750. acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
  751. acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
  752. ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
  753. if (ret < 0) {
  754. wl1271_warning("Setting of tx options failed: %d", ret);
  755. goto out;
  756. }
  757. out:
  758. kfree(acx);
  759. return ret;
  760. }
  761. int wl12xx_acx_mem_cfg(struct wl1271 *wl)
  762. {
  763. struct wl12xx_acx_config_memory *mem_conf;
  764. struct conf_memory_settings *mem;
  765. int ret;
  766. wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
  767. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  768. if (!mem_conf) {
  769. ret = -ENOMEM;
  770. goto out;
  771. }
  772. if (wl->chip.id == CHIP_ID_1283_PG20)
  773. mem = &wl->conf.mem_wl128x;
  774. else
  775. mem = &wl->conf.mem_wl127x;
  776. /* memory config */
  777. mem_conf->num_stations = mem->num_stations;
  778. mem_conf->rx_mem_block_num = mem->rx_block_num;
  779. mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
  780. mem_conf->num_ssid_profiles = mem->ssid_profiles;
  781. mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
  782. mem_conf->dyn_mem_enable = mem->dynamic_memory;
  783. mem_conf->tx_free_req = mem->min_req_tx_blocks;
  784. mem_conf->rx_free_req = mem->min_req_rx_blocks;
  785. mem_conf->tx_min = mem->tx_min;
  786. mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks;
  787. ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  788. sizeof(*mem_conf));
  789. if (ret < 0) {
  790. wl1271_warning("wl1271 mem config failed: %d", ret);
  791. goto out;
  792. }
  793. out:
  794. kfree(mem_conf);
  795. return ret;
  796. }
  797. int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
  798. {
  799. struct wl1271_acx_host_config_bitmap *bitmap_conf;
  800. int ret;
  801. bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
  802. if (!bitmap_conf) {
  803. ret = -ENOMEM;
  804. goto out;
  805. }
  806. bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
  807. ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
  808. bitmap_conf, sizeof(*bitmap_conf));
  809. if (ret < 0) {
  810. wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
  811. goto out;
  812. }
  813. out:
  814. kfree(bitmap_conf);
  815. return ret;
  816. }
  817. int wl1271_acx_init_mem_config(struct wl1271 *wl)
  818. {
  819. int ret;
  820. wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
  821. GFP_KERNEL);
  822. if (!wl->target_mem_map) {
  823. wl1271_error("couldn't allocate target memory map");
  824. return -ENOMEM;
  825. }
  826. /* we now ask for the firmware built memory map */
  827. ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
  828. sizeof(struct wl1271_acx_mem_map));
  829. if (ret < 0) {
  830. wl1271_error("couldn't retrieve firmware memory map");
  831. kfree(wl->target_mem_map);
  832. wl->target_mem_map = NULL;
  833. return ret;
  834. }
  835. /* initialize TX block book keeping */
  836. wl->tx_blocks_available =
  837. le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
  838. wl1271_debug(DEBUG_TX, "available tx blocks: %d",
  839. wl->tx_blocks_available);
  840. return 0;
  841. }
  842. int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
  843. {
  844. struct wl1271_acx_rx_config_opt *rx_conf;
  845. int ret;
  846. wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
  847. rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
  848. if (!rx_conf) {
  849. ret = -ENOMEM;
  850. goto out;
  851. }
  852. rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
  853. rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
  854. rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
  855. rx_conf->queue_type = wl->conf.rx.queue_type;
  856. ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
  857. sizeof(*rx_conf));
  858. if (ret < 0) {
  859. wl1271_warning("wl1271 rx config opt failed: %d", ret);
  860. goto out;
  861. }
  862. out:
  863. kfree(rx_conf);
  864. return ret;
  865. }
  866. int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
  867. {
  868. struct wl1271_acx_bet_enable *acx = NULL;
  869. int ret = 0;
  870. wl1271_debug(DEBUG_ACX, "acx bet enable");
  871. if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
  872. goto out;
  873. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  874. if (!acx) {
  875. ret = -ENOMEM;
  876. goto out;
  877. }
  878. acx->role_id = wl->role_id;
  879. acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
  880. acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
  881. ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
  882. if (ret < 0) {
  883. wl1271_warning("acx bet enable failed: %d", ret);
  884. goto out;
  885. }
  886. out:
  887. kfree(acx);
  888. return ret;
  889. }
  890. int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address)
  891. {
  892. struct wl1271_acx_arp_filter *acx;
  893. int ret;
  894. wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
  895. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  896. if (!acx) {
  897. ret = -ENOMEM;
  898. goto out;
  899. }
  900. acx->role_id = wl->role_id;
  901. acx->version = ACX_IPV4_VERSION;
  902. acx->enable = enable;
  903. if (enable)
  904. memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
  905. ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
  906. acx, sizeof(*acx));
  907. if (ret < 0) {
  908. wl1271_warning("failed to set arp ip filter: %d", ret);
  909. goto out;
  910. }
  911. out:
  912. kfree(acx);
  913. return ret;
  914. }
  915. int wl1271_acx_pm_config(struct wl1271 *wl)
  916. {
  917. struct wl1271_acx_pm_config *acx = NULL;
  918. struct conf_pm_config_settings *c = &wl->conf.pm_config;
  919. int ret = 0;
  920. wl1271_debug(DEBUG_ACX, "acx pm config");
  921. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  922. if (!acx) {
  923. ret = -ENOMEM;
  924. goto out;
  925. }
  926. acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
  927. acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
  928. ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
  929. if (ret < 0) {
  930. wl1271_warning("acx pm config failed: %d", ret);
  931. goto out;
  932. }
  933. out:
  934. kfree(acx);
  935. return ret;
  936. }
  937. int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
  938. {
  939. struct wl1271_acx_keep_alive_mode *acx = NULL;
  940. int ret = 0;
  941. wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
  942. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  943. if (!acx) {
  944. ret = -ENOMEM;
  945. goto out;
  946. }
  947. acx->role_id = wl->role_id;
  948. acx->enabled = enable;
  949. ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
  950. if (ret < 0) {
  951. wl1271_warning("acx keep alive mode failed: %d", ret);
  952. goto out;
  953. }
  954. out:
  955. kfree(acx);
  956. return ret;
  957. }
  958. int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
  959. {
  960. struct wl1271_acx_keep_alive_config *acx = NULL;
  961. int ret = 0;
  962. wl1271_debug(DEBUG_ACX, "acx keep alive config");
  963. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  964. if (!acx) {
  965. ret = -ENOMEM;
  966. goto out;
  967. }
  968. acx->role_id = wl->role_id;
  969. acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
  970. acx->index = index;
  971. acx->tpl_validation = tpl_valid;
  972. acx->trigger = ACX_KEEP_ALIVE_NO_TX;
  973. ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
  974. acx, sizeof(*acx));
  975. if (ret < 0) {
  976. wl1271_warning("acx keep alive config failed: %d", ret);
  977. goto out;
  978. }
  979. out:
  980. kfree(acx);
  981. return ret;
  982. }
  983. int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable,
  984. s16 thold, u8 hyst)
  985. {
  986. struct wl1271_acx_rssi_snr_trigger *acx = NULL;
  987. int ret = 0;
  988. wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
  989. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  990. if (!acx) {
  991. ret = -ENOMEM;
  992. goto out;
  993. }
  994. wl->last_rssi_event = -1;
  995. acx->role_id = wl->role_id;
  996. acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
  997. acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
  998. acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
  999. if (enable)
  1000. acx->enable = WL1271_ACX_TRIG_ENABLE;
  1001. else
  1002. acx->enable = WL1271_ACX_TRIG_DISABLE;
  1003. acx->index = WL1271_ACX_TRIG_IDX_RSSI;
  1004. acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
  1005. acx->threshold = cpu_to_le16(thold);
  1006. acx->hysteresis = hyst;
  1007. ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
  1008. if (ret < 0) {
  1009. wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
  1010. goto out;
  1011. }
  1012. out:
  1013. kfree(acx);
  1014. return ret;
  1015. }
  1016. int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl)
  1017. {
  1018. struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
  1019. struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
  1020. int ret = 0;
  1021. wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
  1022. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1023. if (!acx) {
  1024. ret = -ENOMEM;
  1025. goto out;
  1026. }
  1027. acx->role_id = wl->role_id;
  1028. acx->rssi_beacon = c->avg_weight_rssi_beacon;
  1029. acx->rssi_data = c->avg_weight_rssi_data;
  1030. acx->snr_beacon = c->avg_weight_snr_beacon;
  1031. acx->snr_data = c->avg_weight_snr_data;
  1032. ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
  1033. if (ret < 0) {
  1034. wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
  1035. goto out;
  1036. }
  1037. out:
  1038. kfree(acx);
  1039. return ret;
  1040. }
  1041. int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
  1042. struct ieee80211_sta_ht_cap *ht_cap,
  1043. bool allow_ht_operation, u8 hlid)
  1044. {
  1045. struct wl1271_acx_ht_capabilities *acx;
  1046. int ret = 0;
  1047. u32 ht_capabilites = 0;
  1048. wl1271_debug(DEBUG_ACX, "acx ht capabilities setting "
  1049. "sta supp: %d sta cap: %d", ht_cap->ht_supported,
  1050. ht_cap->cap);
  1051. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1052. if (!acx) {
  1053. ret = -ENOMEM;
  1054. goto out;
  1055. }
  1056. if (allow_ht_operation && ht_cap->ht_supported) {
  1057. /* no need to translate capabilities - use the spec values */
  1058. ht_capabilites = ht_cap->cap;
  1059. /*
  1060. * this bit is not employed by the spec but only by FW to
  1061. * indicate peer HT support
  1062. */
  1063. ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
  1064. /* get data from A-MPDU parameters field */
  1065. acx->ampdu_max_length = ht_cap->ampdu_factor;
  1066. acx->ampdu_min_spacing = ht_cap->ampdu_density;
  1067. }
  1068. acx->hlid = hlid;
  1069. acx->ht_capabilites = cpu_to_le32(ht_capabilites);
  1070. ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
  1071. if (ret < 0) {
  1072. wl1271_warning("acx ht capabilities setting failed: %d", ret);
  1073. goto out;
  1074. }
  1075. out:
  1076. kfree(acx);
  1077. return ret;
  1078. }
  1079. int wl1271_acx_set_ht_information(struct wl1271 *wl,
  1080. u16 ht_operation_mode)
  1081. {
  1082. struct wl1271_acx_ht_information *acx;
  1083. int ret = 0;
  1084. wl1271_debug(DEBUG_ACX, "acx ht information setting");
  1085. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1086. if (!acx) {
  1087. ret = -ENOMEM;
  1088. goto out;
  1089. }
  1090. acx->role_id = wl->role_id;
  1091. acx->ht_protection =
  1092. (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
  1093. acx->rifs_mode = 0;
  1094. acx->gf_protection =
  1095. !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  1096. acx->ht_tx_burst_limit = 0;
  1097. acx->dual_cts_protection = 0;
  1098. ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
  1099. if (ret < 0) {
  1100. wl1271_warning("acx ht information setting failed: %d", ret);
  1101. goto out;
  1102. }
  1103. out:
  1104. kfree(acx);
  1105. return ret;
  1106. }
  1107. /* Configure BA session initiator/receiver parameters setting in the FW. */
  1108. int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl)
  1109. {
  1110. struct wl1271_acx_ba_initiator_policy *acx;
  1111. int ret;
  1112. wl1271_debug(DEBUG_ACX, "acx ba initiator policy");
  1113. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1114. if (!acx) {
  1115. ret = -ENOMEM;
  1116. goto out;
  1117. }
  1118. /* set for the current role */
  1119. acx->role_id = wl->role_id;
  1120. acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap;
  1121. acx->win_size = wl->conf.ht.tx_ba_win_size;
  1122. acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
  1123. ret = wl1271_cmd_configure(wl,
  1124. ACX_BA_SESSION_INIT_POLICY,
  1125. acx,
  1126. sizeof(*acx));
  1127. if (ret < 0) {
  1128. wl1271_warning("acx ba initiator policy failed: %d", ret);
  1129. goto out;
  1130. }
  1131. out:
  1132. kfree(acx);
  1133. return ret;
  1134. }
  1135. /* setup BA session receiver setting in the FW. */
  1136. int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index,
  1137. u16 ssn, bool enable, u8 peer_hlid)
  1138. {
  1139. struct wl1271_acx_ba_receiver_setup *acx;
  1140. int ret;
  1141. wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
  1142. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1143. if (!acx) {
  1144. ret = -ENOMEM;
  1145. goto out;
  1146. }
  1147. acx->hlid = peer_hlid;
  1148. acx->tid = tid_index;
  1149. acx->enable = enable;
  1150. acx->win_size = wl->conf.ht.rx_ba_win_size;
  1151. acx->ssn = ssn;
  1152. ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
  1153. sizeof(*acx));
  1154. if (ret < 0) {
  1155. wl1271_warning("acx ba receiver session failed: %d", ret);
  1156. goto out;
  1157. }
  1158. out:
  1159. kfree(acx);
  1160. return ret;
  1161. }
  1162. int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
  1163. {
  1164. struct wl1271_acx_fw_tsf_information *tsf_info;
  1165. int ret;
  1166. tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
  1167. if (!tsf_info) {
  1168. ret = -ENOMEM;
  1169. goto out;
  1170. }
  1171. ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
  1172. tsf_info, sizeof(*tsf_info));
  1173. if (ret < 0) {
  1174. wl1271_warning("acx tsf info interrogate failed");
  1175. goto out;
  1176. }
  1177. *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
  1178. ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
  1179. out:
  1180. kfree(tsf_info);
  1181. return ret;
  1182. }
  1183. int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable)
  1184. {
  1185. struct wl1271_acx_ps_rx_streaming *rx_streaming;
  1186. u32 conf_queues, enable_queues;
  1187. int i, ret = 0;
  1188. wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
  1189. rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
  1190. if (!rx_streaming) {
  1191. ret = -ENOMEM;
  1192. goto out;
  1193. }
  1194. conf_queues = wl->conf.rx_streaming.queues;
  1195. if (enable)
  1196. enable_queues = conf_queues;
  1197. else
  1198. enable_queues = 0;
  1199. for (i = 0; i < 8; i++) {
  1200. /*
  1201. * Skip non-changed queues, to avoid redundant acxs.
  1202. * this check assumes conf.rx_streaming.queues can't
  1203. * be changed while rx_streaming is enabled.
  1204. */
  1205. if (!(conf_queues & BIT(i)))
  1206. continue;
  1207. rx_streaming->role_id = wl->role_id;
  1208. rx_streaming->tid = i;
  1209. rx_streaming->enable = enable_queues & BIT(i);
  1210. rx_streaming->period = wl->conf.rx_streaming.interval;
  1211. rx_streaming->timeout = wl->conf.rx_streaming.interval;
  1212. ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
  1213. rx_streaming,
  1214. sizeof(*rx_streaming));
  1215. if (ret < 0) {
  1216. wl1271_warning("acx ps rx streaming failed: %d", ret);
  1217. goto out;
  1218. }
  1219. }
  1220. out:
  1221. kfree(rx_streaming);
  1222. return ret;
  1223. }
  1224. int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl)
  1225. {
  1226. struct wl1271_acx_ap_max_tx_retry *acx = NULL;
  1227. int ret;
  1228. wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
  1229. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1230. if (!acx)
  1231. return -ENOMEM;
  1232. acx->role_id = wl->role_id;
  1233. acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
  1234. ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
  1235. if (ret < 0) {
  1236. wl1271_warning("acx ap max tx retry failed: %d", ret);
  1237. goto out;
  1238. }
  1239. out:
  1240. kfree(acx);
  1241. return ret;
  1242. }
  1243. int wl1271_acx_config_ps(struct wl1271 *wl)
  1244. {
  1245. struct wl1271_acx_config_ps *config_ps;
  1246. int ret;
  1247. wl1271_debug(DEBUG_ACX, "acx config ps");
  1248. config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
  1249. if (!config_ps) {
  1250. ret = -ENOMEM;
  1251. goto out;
  1252. }
  1253. config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
  1254. config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
  1255. config_ps->null_data_rate = cpu_to_le32(wl->basic_rate);
  1256. ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
  1257. sizeof(*config_ps));
  1258. if (ret < 0) {
  1259. wl1271_warning("acx config ps failed: %d", ret);
  1260. goto out;
  1261. }
  1262. out:
  1263. kfree(config_ps);
  1264. return ret;
  1265. }
  1266. int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
  1267. {
  1268. struct wl1271_acx_inconnection_sta *acx = NULL;
  1269. int ret;
  1270. wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
  1271. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1272. if (!acx)
  1273. return -ENOMEM;
  1274. memcpy(acx->addr, addr, ETH_ALEN);
  1275. ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
  1276. acx, sizeof(*acx));
  1277. if (ret < 0) {
  1278. wl1271_warning("acx set inconnaction sta failed: %d", ret);
  1279. goto out;
  1280. }
  1281. out:
  1282. kfree(acx);
  1283. return ret;
  1284. }
  1285. int wl1271_acx_fm_coex(struct wl1271 *wl)
  1286. {
  1287. struct wl1271_acx_fm_coex *acx;
  1288. int ret;
  1289. wl1271_debug(DEBUG_ACX, "acx fm coex setting");
  1290. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1291. if (!acx) {
  1292. ret = -ENOMEM;
  1293. goto out;
  1294. }
  1295. acx->enable = wl->conf.fm_coex.enable;
  1296. acx->swallow_period = wl->conf.fm_coex.swallow_period;
  1297. acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
  1298. acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
  1299. acx->m_divider_fref_set_1 =
  1300. cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
  1301. acx->m_divider_fref_set_2 =
  1302. cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
  1303. acx->coex_pll_stabilization_time =
  1304. cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
  1305. acx->ldo_stabilization_time =
  1306. cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
  1307. acx->fm_disturbed_band_margin =
  1308. wl->conf.fm_coex.fm_disturbed_band_margin;
  1309. acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
  1310. ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
  1311. if (ret < 0) {
  1312. wl1271_warning("acx fm coex setting failed: %d", ret);
  1313. goto out;
  1314. }
  1315. out:
  1316. kfree(acx);
  1317. return ret;
  1318. }
  1319. int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
  1320. {
  1321. struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
  1322. struct conf_rate_policy_settings *conf = &wl->conf.rate;
  1323. int ret;
  1324. wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
  1325. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1326. if (!acx)
  1327. return -ENOMEM;
  1328. acx->index = ACX_RATE_MGMT_ALL_PARAMS;
  1329. acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
  1330. acx->per_add = cpu_to_le16(conf->per_add);
  1331. acx->per_th1 = cpu_to_le16(conf->per_th1);
  1332. acx->per_th2 = cpu_to_le16(conf->per_th2);
  1333. acx->max_per = cpu_to_le16(conf->max_per);
  1334. acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
  1335. acx->tx_fail_low_th = conf->tx_fail_low_th;
  1336. acx->tx_fail_high_th = conf->tx_fail_high_th;
  1337. acx->per_alpha_shift = conf->per_alpha_shift;
  1338. acx->per_add_shift = conf->per_add_shift;
  1339. acx->per_beta1_shift = conf->per_beta1_shift;
  1340. acx->per_beta2_shift = conf->per_beta2_shift;
  1341. acx->rate_check_up = conf->rate_check_up;
  1342. acx->rate_check_down = conf->rate_check_down;
  1343. memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
  1344. sizeof(acx->rate_retry_policy));
  1345. ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
  1346. acx, sizeof(*acx));
  1347. if (ret < 0) {
  1348. wl1271_warning("acx set rate mgmt params failed: %d", ret);
  1349. goto out;
  1350. }
  1351. out:
  1352. kfree(acx);
  1353. return ret;
  1354. }