acx.c 41 KB

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