acx.c 39 KB

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