acx.c 39 KB

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