acx.c 37 KB

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