acx.c 39 KB

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