acx.c 41 KB

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