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