acx.c 38 KB

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