acx.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569
  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, u16 rts_threshold)
  261. {
  262. struct acx_rts_threshold *rts;
  263. int ret;
  264. wl1271_debug(DEBUG_ACX, "acx rts threshold");
  265. rts = kzalloc(sizeof(*rts), GFP_KERNEL);
  266. if (!rts) {
  267. ret = -ENOMEM;
  268. goto out;
  269. }
  270. rts->threshold = cpu_to_le16(rts_threshold);
  271. ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
  272. if (ret < 0) {
  273. wl1271_warning("failed to set rts threshold: %d", ret);
  274. goto out;
  275. }
  276. out:
  277. kfree(rts);
  278. return ret;
  279. }
  280. int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
  281. {
  282. struct acx_dco_itrim_params *dco;
  283. struct conf_itrim_settings *c = &wl->conf.itrim;
  284. int ret;
  285. wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
  286. dco = kzalloc(sizeof(*dco), GFP_KERNEL);
  287. if (!dco) {
  288. ret = -ENOMEM;
  289. goto out;
  290. }
  291. dco->enable = c->enable;
  292. dco->timeout = cpu_to_le32(c->timeout);
  293. ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
  294. dco, sizeof(*dco));
  295. if (ret < 0) {
  296. wl1271_warning("failed to set dco itrim parameters: %d", ret);
  297. goto out;
  298. }
  299. out:
  300. kfree(dco);
  301. return ret;
  302. }
  303. int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter)
  304. {
  305. struct acx_beacon_filter_option *beacon_filter = NULL;
  306. int ret = 0;
  307. wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
  308. if (enable_filter &&
  309. wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
  310. goto out;
  311. beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
  312. if (!beacon_filter) {
  313. ret = -ENOMEM;
  314. goto out;
  315. }
  316. beacon_filter->enable = enable_filter;
  317. /*
  318. * When set to zero, and the filter is enabled, beacons
  319. * without the unicast TIM bit set are dropped.
  320. */
  321. beacon_filter->max_num_beacons = 0;
  322. ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
  323. beacon_filter, sizeof(*beacon_filter));
  324. if (ret < 0) {
  325. wl1271_warning("failed to set beacon filter opt: %d", ret);
  326. goto out;
  327. }
  328. out:
  329. kfree(beacon_filter);
  330. return ret;
  331. }
  332. int wl1271_acx_beacon_filter_table(struct wl1271 *wl)
  333. {
  334. struct acx_beacon_filter_ie_table *ie_table;
  335. int i, idx = 0;
  336. int ret;
  337. bool vendor_spec = false;
  338. wl1271_debug(DEBUG_ACX, "acx beacon filter table");
  339. ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
  340. if (!ie_table) {
  341. ret = -ENOMEM;
  342. goto out;
  343. }
  344. /* configure default beacon pass-through rules */
  345. ie_table->num_ie = 0;
  346. for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
  347. struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
  348. ie_table->table[idx++] = r->ie;
  349. ie_table->table[idx++] = r->rule;
  350. if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
  351. /* only one vendor specific ie allowed */
  352. if (vendor_spec)
  353. continue;
  354. /* for vendor specific rules configure the
  355. additional fields */
  356. memcpy(&(ie_table->table[idx]), r->oui,
  357. CONF_BCN_IE_OUI_LEN);
  358. idx += CONF_BCN_IE_OUI_LEN;
  359. ie_table->table[idx++] = r->type;
  360. memcpy(&(ie_table->table[idx]), r->version,
  361. CONF_BCN_IE_VER_LEN);
  362. idx += CONF_BCN_IE_VER_LEN;
  363. vendor_spec = true;
  364. }
  365. ie_table->num_ie++;
  366. }
  367. ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
  368. ie_table, sizeof(*ie_table));
  369. if (ret < 0) {
  370. wl1271_warning("failed to set beacon filter table: %d", ret);
  371. goto out;
  372. }
  373. out:
  374. kfree(ie_table);
  375. return ret;
  376. }
  377. #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
  378. int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable)
  379. {
  380. struct acx_conn_monit_params *acx;
  381. u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
  382. u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
  383. int ret;
  384. wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
  385. enable ? "enabled" : "disabled");
  386. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  387. if (!acx) {
  388. ret = -ENOMEM;
  389. goto out;
  390. }
  391. if (enable) {
  392. threshold = wl->conf.conn.synch_fail_thold;
  393. timeout = wl->conf.conn.bss_lose_timeout;
  394. }
  395. acx->synch_fail_thold = cpu_to_le32(threshold);
  396. acx->bss_lose_timeout = cpu_to_le32(timeout);
  397. ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
  398. acx, sizeof(*acx));
  399. if (ret < 0) {
  400. wl1271_warning("failed to set connection monitor "
  401. "parameters: %d", ret);
  402. goto out;
  403. }
  404. out:
  405. kfree(acx);
  406. return ret;
  407. }
  408. int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
  409. {
  410. struct acx_bt_wlan_coex *pta;
  411. int ret;
  412. wl1271_debug(DEBUG_ACX, "acx sg enable");
  413. pta = kzalloc(sizeof(*pta), GFP_KERNEL);
  414. if (!pta) {
  415. ret = -ENOMEM;
  416. goto out;
  417. }
  418. if (enable)
  419. pta->enable = wl->conf.sg.state;
  420. else
  421. pta->enable = CONF_SG_DISABLE;
  422. ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
  423. if (ret < 0) {
  424. wl1271_warning("failed to set softgemini enable: %d", ret);
  425. goto out;
  426. }
  427. out:
  428. kfree(pta);
  429. return ret;
  430. }
  431. int wl1271_acx_sg_cfg(struct wl1271 *wl)
  432. {
  433. struct acx_bt_wlan_coex_param *param;
  434. struct conf_sg_settings *c = &wl->conf.sg;
  435. int i, ret;
  436. wl1271_debug(DEBUG_ACX, "acx sg cfg");
  437. param = kzalloc(sizeof(*param), GFP_KERNEL);
  438. if (!param) {
  439. ret = -ENOMEM;
  440. goto out;
  441. }
  442. /* BT-WLAN coext parameters */
  443. for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
  444. param->params[i] = cpu_to_le32(c->params[i]);
  445. param->param_idx = CONF_SG_PARAMS_ALL;
  446. ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
  447. if (ret < 0) {
  448. wl1271_warning("failed to set sg config: %d", ret);
  449. goto out;
  450. }
  451. out:
  452. kfree(param);
  453. return ret;
  454. }
  455. int wl1271_acx_cca_threshold(struct wl1271 *wl)
  456. {
  457. struct acx_energy_detection *detection;
  458. int ret;
  459. wl1271_debug(DEBUG_ACX, "acx cca threshold");
  460. detection = kzalloc(sizeof(*detection), GFP_KERNEL);
  461. if (!detection) {
  462. ret = -ENOMEM;
  463. goto out;
  464. }
  465. detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
  466. detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
  467. ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
  468. detection, sizeof(*detection));
  469. if (ret < 0) {
  470. wl1271_warning("failed to set cca threshold: %d", ret);
  471. return ret;
  472. }
  473. out:
  474. kfree(detection);
  475. return ret;
  476. }
  477. int wl1271_acx_bcn_dtim_options(struct wl1271 *wl)
  478. {
  479. struct acx_beacon_broadcast *bb;
  480. int ret;
  481. wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
  482. bb = kzalloc(sizeof(*bb), GFP_KERNEL);
  483. if (!bb) {
  484. ret = -ENOMEM;
  485. goto out;
  486. }
  487. bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
  488. bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
  489. bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
  490. bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
  491. ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
  492. if (ret < 0) {
  493. wl1271_warning("failed to set rx config: %d", ret);
  494. goto out;
  495. }
  496. out:
  497. kfree(bb);
  498. return ret;
  499. }
  500. int wl1271_acx_aid(struct wl1271 *wl, u16 aid)
  501. {
  502. struct acx_aid *acx_aid;
  503. int ret;
  504. wl1271_debug(DEBUG_ACX, "acx aid");
  505. acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
  506. if (!acx_aid) {
  507. ret = -ENOMEM;
  508. goto out;
  509. }
  510. acx_aid->aid = cpu_to_le16(aid);
  511. ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
  512. if (ret < 0) {
  513. wl1271_warning("failed to set aid: %d", ret);
  514. goto out;
  515. }
  516. out:
  517. kfree(acx_aid);
  518. return ret;
  519. }
  520. int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
  521. {
  522. struct acx_event_mask *mask;
  523. int ret;
  524. wl1271_debug(DEBUG_ACX, "acx event mbox mask");
  525. mask = kzalloc(sizeof(*mask), GFP_KERNEL);
  526. if (!mask) {
  527. ret = -ENOMEM;
  528. goto out;
  529. }
  530. /* high event mask is unused */
  531. mask->high_event_mask = cpu_to_le32(0xffffffff);
  532. mask->event_mask = cpu_to_le32(event_mask);
  533. ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
  534. mask, sizeof(*mask));
  535. if (ret < 0) {
  536. wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
  537. goto out;
  538. }
  539. out:
  540. kfree(mask);
  541. return ret;
  542. }
  543. int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble)
  544. {
  545. struct acx_preamble *acx;
  546. int ret;
  547. wl1271_debug(DEBUG_ACX, "acx_set_preamble");
  548. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  549. if (!acx) {
  550. ret = -ENOMEM;
  551. goto out;
  552. }
  553. acx->preamble = preamble;
  554. ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
  555. if (ret < 0) {
  556. wl1271_warning("Setting of preamble failed: %d", ret);
  557. goto out;
  558. }
  559. out:
  560. kfree(acx);
  561. return ret;
  562. }
  563. int wl1271_acx_cts_protect(struct wl1271 *wl,
  564. enum acx_ctsprotect_type ctsprotect)
  565. {
  566. struct acx_ctsprotect *acx;
  567. int ret;
  568. wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
  569. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  570. if (!acx) {
  571. ret = -ENOMEM;
  572. goto out;
  573. }
  574. acx->ctsprotect = ctsprotect;
  575. ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
  576. if (ret < 0) {
  577. wl1271_warning("Setting of ctsprotect failed: %d", ret);
  578. goto out;
  579. }
  580. out:
  581. kfree(acx);
  582. return ret;
  583. }
  584. int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
  585. {
  586. int ret;
  587. wl1271_debug(DEBUG_ACX, "acx statistics");
  588. ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
  589. sizeof(*stats));
  590. if (ret < 0) {
  591. wl1271_warning("acx statistics failed: %d", ret);
  592. return -ENOMEM;
  593. }
  594. return 0;
  595. }
  596. int wl1271_acx_sta_rate_policies(struct wl1271 *wl)
  597. {
  598. struct acx_sta_rate_policy *acx;
  599. struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
  600. int idx = 0;
  601. int ret = 0;
  602. wl1271_debug(DEBUG_ACX, "acx rate policies");
  603. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  604. if (!acx) {
  605. ret = -ENOMEM;
  606. goto out;
  607. }
  608. /* configure one basic rate class */
  609. idx = ACX_TX_BASIC_RATE;
  610. acx->rate_class[idx].enabled_rates = cpu_to_le32(wl->basic_rate);
  611. acx->rate_class[idx].short_retry_limit = c->short_retry_limit;
  612. acx->rate_class[idx].long_retry_limit = c->long_retry_limit;
  613. acx->rate_class[idx].aflags = c->aflags;
  614. /* configure one AP supported rate class */
  615. idx = ACX_TX_AP_FULL_RATE;
  616. acx->rate_class[idx].enabled_rates = cpu_to_le32(wl->rate_set);
  617. acx->rate_class[idx].short_retry_limit = c->short_retry_limit;
  618. acx->rate_class[idx].long_retry_limit = c->long_retry_limit;
  619. acx->rate_class[idx].aflags = c->aflags;
  620. acx->rate_class_cnt = cpu_to_le32(ACX_TX_RATE_POLICY_CNT);
  621. wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
  622. acx->rate_class[ACX_TX_BASIC_RATE].enabled_rates,
  623. acx->rate_class[ACX_TX_AP_FULL_RATE].enabled_rates);
  624. ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  625. if (ret < 0) {
  626. wl1271_warning("Setting of rate policies failed: %d", ret);
  627. goto out;
  628. }
  629. out:
  630. kfree(acx);
  631. return ret;
  632. }
  633. int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
  634. u8 idx)
  635. {
  636. struct acx_ap_rate_policy *acx;
  637. int ret = 0;
  638. wl1271_debug(DEBUG_ACX, "acx ap rate policy");
  639. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  640. if (!acx) {
  641. ret = -ENOMEM;
  642. goto out;
  643. }
  644. acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
  645. acx->rate_policy.short_retry_limit = c->short_retry_limit;
  646. acx->rate_policy.long_retry_limit = c->long_retry_limit;
  647. acx->rate_policy.aflags = c->aflags;
  648. acx->rate_policy_idx = cpu_to_le32(idx);
  649. ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  650. if (ret < 0) {
  651. wl1271_warning("Setting of ap rate policy failed: %d", ret);
  652. goto out;
  653. }
  654. out:
  655. kfree(acx);
  656. return ret;
  657. }
  658. int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
  659. u8 aifsn, u16 txop)
  660. {
  661. struct acx_ac_cfg *acx;
  662. int ret = 0;
  663. wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
  664. "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
  665. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  666. if (!acx) {
  667. ret = -ENOMEM;
  668. goto out;
  669. }
  670. acx->ac = ac;
  671. acx->cw_min = cw_min;
  672. acx->cw_max = cpu_to_le16(cw_max);
  673. acx->aifsn = aifsn;
  674. acx->tx_op_limit = cpu_to_le16(txop);
  675. ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
  676. if (ret < 0) {
  677. wl1271_warning("acx ac cfg failed: %d", ret);
  678. goto out;
  679. }
  680. out:
  681. kfree(acx);
  682. return ret;
  683. }
  684. int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
  685. u8 tsid, u8 ps_scheme, u8 ack_policy,
  686. u32 apsd_conf0, u32 apsd_conf1)
  687. {
  688. struct acx_tid_config *acx;
  689. int ret = 0;
  690. wl1271_debug(DEBUG_ACX, "acx tid config");
  691. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  692. if (!acx) {
  693. ret = -ENOMEM;
  694. goto out;
  695. }
  696. acx->queue_id = queue_id;
  697. acx->channel_type = channel_type;
  698. acx->tsid = tsid;
  699. acx->ps_scheme = ps_scheme;
  700. acx->ack_policy = ack_policy;
  701. acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
  702. acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
  703. ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
  704. if (ret < 0) {
  705. wl1271_warning("Setting of tid config failed: %d", ret);
  706. goto out;
  707. }
  708. out:
  709. kfree(acx);
  710. return ret;
  711. }
  712. int wl1271_acx_frag_threshold(struct wl1271 *wl, u16 frag_threshold)
  713. {
  714. struct acx_frag_threshold *acx;
  715. int ret = 0;
  716. wl1271_debug(DEBUG_ACX, "acx frag threshold");
  717. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  718. if (!acx) {
  719. ret = -ENOMEM;
  720. goto out;
  721. }
  722. acx->frag_threshold = cpu_to_le16(frag_threshold);
  723. ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
  724. if (ret < 0) {
  725. wl1271_warning("Setting of frag threshold failed: %d", ret);
  726. goto out;
  727. }
  728. out:
  729. kfree(acx);
  730. return ret;
  731. }
  732. int wl1271_acx_tx_config_options(struct wl1271 *wl)
  733. {
  734. struct acx_tx_config_options *acx;
  735. int ret = 0;
  736. wl1271_debug(DEBUG_ACX, "acx tx config options");
  737. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  738. if (!acx) {
  739. ret = -ENOMEM;
  740. goto out;
  741. }
  742. acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
  743. acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
  744. ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
  745. if (ret < 0) {
  746. wl1271_warning("Setting of tx options failed: %d", ret);
  747. goto out;
  748. }
  749. out:
  750. kfree(acx);
  751. return ret;
  752. }
  753. int wl1271_acx_ap_mem_cfg(struct wl1271 *wl)
  754. {
  755. struct wl1271_acx_ap_config_memory *mem_conf;
  756. int ret;
  757. wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
  758. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  759. if (!mem_conf) {
  760. ret = -ENOMEM;
  761. goto out;
  762. }
  763. /* memory config */
  764. mem_conf->num_stations = wl->conf.mem.num_stations;
  765. mem_conf->rx_mem_block_num = wl->conf.mem.rx_block_num;
  766. mem_conf->tx_min_mem_block_num = wl->conf.mem.tx_min_block_num;
  767. mem_conf->num_ssid_profiles = wl->conf.mem.ssid_profiles;
  768. mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
  769. ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  770. sizeof(*mem_conf));
  771. if (ret < 0) {
  772. wl1271_warning("wl1271 mem config failed: %d", ret);
  773. goto out;
  774. }
  775. out:
  776. kfree(mem_conf);
  777. return ret;
  778. }
  779. int wl1271_acx_sta_mem_cfg(struct wl1271 *wl)
  780. {
  781. struct wl1271_acx_sta_config_memory *mem_conf;
  782. int ret;
  783. wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
  784. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  785. if (!mem_conf) {
  786. ret = -ENOMEM;
  787. goto out;
  788. }
  789. /* memory config */
  790. mem_conf->num_stations = wl->conf.mem.num_stations;
  791. mem_conf->rx_mem_block_num = wl->conf.mem.rx_block_num;
  792. mem_conf->tx_min_mem_block_num = wl->conf.mem.tx_min_block_num;
  793. mem_conf->num_ssid_profiles = wl->conf.mem.ssid_profiles;
  794. mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
  795. mem_conf->dyn_mem_enable = wl->conf.mem.dynamic_memory;
  796. mem_conf->tx_free_req = wl->conf.mem.min_req_tx_blocks;
  797. mem_conf->rx_free_req = wl->conf.mem.min_req_rx_blocks;
  798. mem_conf->tx_min = wl->conf.mem.tx_min;
  799. ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  800. sizeof(*mem_conf));
  801. if (ret < 0) {
  802. wl1271_warning("wl1271 mem config failed: %d", ret);
  803. goto out;
  804. }
  805. out:
  806. kfree(mem_conf);
  807. return ret;
  808. }
  809. int wl1271_acx_init_mem_config(struct wl1271 *wl)
  810. {
  811. int ret;
  812. wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
  813. GFP_KERNEL);
  814. if (!wl->target_mem_map) {
  815. wl1271_error("couldn't allocate target memory map");
  816. return -ENOMEM;
  817. }
  818. /* we now ask for the firmware built memory map */
  819. ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
  820. sizeof(struct wl1271_acx_mem_map));
  821. if (ret < 0) {
  822. wl1271_error("couldn't retrieve firmware memory map");
  823. kfree(wl->target_mem_map);
  824. wl->target_mem_map = NULL;
  825. return ret;
  826. }
  827. /* initialize TX block book keeping */
  828. wl->tx_blocks_available =
  829. le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
  830. wl1271_debug(DEBUG_TX, "available tx blocks: %d",
  831. wl->tx_blocks_available);
  832. return 0;
  833. }
  834. int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
  835. {
  836. struct wl1271_acx_rx_config_opt *rx_conf;
  837. int ret;
  838. wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
  839. rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
  840. if (!rx_conf) {
  841. ret = -ENOMEM;
  842. goto out;
  843. }
  844. rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
  845. rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
  846. rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
  847. rx_conf->queue_type = wl->conf.rx.queue_type;
  848. ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
  849. sizeof(*rx_conf));
  850. if (ret < 0) {
  851. wl1271_warning("wl1271 rx config opt failed: %d", ret);
  852. goto out;
  853. }
  854. out:
  855. kfree(rx_conf);
  856. return ret;
  857. }
  858. int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
  859. {
  860. struct wl1271_acx_bet_enable *acx = NULL;
  861. int ret = 0;
  862. wl1271_debug(DEBUG_ACX, "acx bet enable");
  863. if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
  864. goto out;
  865. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  866. if (!acx) {
  867. ret = -ENOMEM;
  868. goto out;
  869. }
  870. acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
  871. acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
  872. ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
  873. if (ret < 0) {
  874. wl1271_warning("acx bet enable failed: %d", ret);
  875. goto out;
  876. }
  877. out:
  878. kfree(acx);
  879. return ret;
  880. }
  881. int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address)
  882. {
  883. struct wl1271_acx_arp_filter *acx;
  884. int ret;
  885. wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
  886. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  887. if (!acx) {
  888. ret = -ENOMEM;
  889. goto out;
  890. }
  891. acx->version = ACX_IPV4_VERSION;
  892. acx->enable = enable;
  893. if (enable)
  894. memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
  895. ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
  896. acx, sizeof(*acx));
  897. if (ret < 0) {
  898. wl1271_warning("failed to set arp ip filter: %d", ret);
  899. goto out;
  900. }
  901. out:
  902. kfree(acx);
  903. return ret;
  904. }
  905. int wl1271_acx_pm_config(struct wl1271 *wl)
  906. {
  907. struct wl1271_acx_pm_config *acx = NULL;
  908. struct conf_pm_config_settings *c = &wl->conf.pm_config;
  909. int ret = 0;
  910. wl1271_debug(DEBUG_ACX, "acx pm config");
  911. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  912. if (!acx) {
  913. ret = -ENOMEM;
  914. goto out;
  915. }
  916. acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
  917. acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
  918. ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
  919. if (ret < 0) {
  920. wl1271_warning("acx pm config failed: %d", ret);
  921. goto out;
  922. }
  923. out:
  924. kfree(acx);
  925. return ret;
  926. }
  927. int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
  928. {
  929. struct wl1271_acx_keep_alive_mode *acx = NULL;
  930. int ret = 0;
  931. wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
  932. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  933. if (!acx) {
  934. ret = -ENOMEM;
  935. goto out;
  936. }
  937. acx->enabled = enable;
  938. ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
  939. if (ret < 0) {
  940. wl1271_warning("acx keep alive mode failed: %d", ret);
  941. goto out;
  942. }
  943. out:
  944. kfree(acx);
  945. return ret;
  946. }
  947. int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
  948. {
  949. struct wl1271_acx_keep_alive_config *acx = NULL;
  950. int ret = 0;
  951. wl1271_debug(DEBUG_ACX, "acx keep alive config");
  952. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  953. if (!acx) {
  954. ret = -ENOMEM;
  955. goto out;
  956. }
  957. acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
  958. acx->index = index;
  959. acx->tpl_validation = tpl_valid;
  960. acx->trigger = ACX_KEEP_ALIVE_NO_TX;
  961. ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
  962. acx, sizeof(*acx));
  963. if (ret < 0) {
  964. wl1271_warning("acx keep alive config failed: %d", ret);
  965. goto out;
  966. }
  967. out:
  968. kfree(acx);
  969. return ret;
  970. }
  971. int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable,
  972. s16 thold, u8 hyst)
  973. {
  974. struct wl1271_acx_rssi_snr_trigger *acx = NULL;
  975. int ret = 0;
  976. wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
  977. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  978. if (!acx) {
  979. ret = -ENOMEM;
  980. goto out;
  981. }
  982. wl->last_rssi_event = -1;
  983. acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
  984. acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
  985. acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
  986. if (enable)
  987. acx->enable = WL1271_ACX_TRIG_ENABLE;
  988. else
  989. acx->enable = WL1271_ACX_TRIG_DISABLE;
  990. acx->index = WL1271_ACX_TRIG_IDX_RSSI;
  991. acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
  992. acx->threshold = cpu_to_le16(thold);
  993. acx->hysteresis = hyst;
  994. ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
  995. if (ret < 0) {
  996. wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
  997. goto out;
  998. }
  999. out:
  1000. kfree(acx);
  1001. return ret;
  1002. }
  1003. int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl)
  1004. {
  1005. struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
  1006. struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
  1007. int ret = 0;
  1008. wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
  1009. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1010. if (!acx) {
  1011. ret = -ENOMEM;
  1012. goto out;
  1013. }
  1014. acx->rssi_beacon = c->avg_weight_rssi_beacon;
  1015. acx->rssi_data = c->avg_weight_rssi_data;
  1016. acx->snr_beacon = c->avg_weight_snr_beacon;
  1017. acx->snr_data = c->avg_weight_snr_data;
  1018. ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
  1019. if (ret < 0) {
  1020. wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
  1021. goto out;
  1022. }
  1023. out:
  1024. kfree(acx);
  1025. return ret;
  1026. }
  1027. int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
  1028. struct ieee80211_sta_ht_cap *ht_cap,
  1029. bool allow_ht_operation)
  1030. {
  1031. struct wl1271_acx_ht_capabilities *acx;
  1032. u8 mac_address[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  1033. int ret = 0;
  1034. u32 ht_capabilites = 0;
  1035. wl1271_debug(DEBUG_ACX, "acx ht capabilities setting");
  1036. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1037. if (!acx) {
  1038. ret = -ENOMEM;
  1039. goto out;
  1040. }
  1041. /* Allow HT Operation ? */
  1042. if (allow_ht_operation) {
  1043. ht_capabilites =
  1044. WL1271_ACX_FW_CAP_HT_OPERATION;
  1045. if (ht_cap->cap & IEEE80211_HT_CAP_GRN_FLD)
  1046. ht_capabilites |=
  1047. WL1271_ACX_FW_CAP_GREENFIELD_FRAME_FORMAT;
  1048. if (ht_cap->cap & IEEE80211_HT_CAP_SGI_20)
  1049. ht_capabilites |=
  1050. WL1271_ACX_FW_CAP_SHORT_GI_FOR_20MHZ_PACKETS;
  1051. if (ht_cap->cap & IEEE80211_HT_CAP_LSIG_TXOP_PROT)
  1052. ht_capabilites |=
  1053. WL1271_ACX_FW_CAP_LSIG_TXOP_PROTECTION;
  1054. /* get data from A-MPDU parameters field */
  1055. acx->ampdu_max_length = ht_cap->ampdu_factor;
  1056. acx->ampdu_min_spacing = ht_cap->ampdu_density;
  1057. }
  1058. memcpy(acx->mac_address, mac_address, ETH_ALEN);
  1059. acx->ht_capabilites = cpu_to_le32(ht_capabilites);
  1060. ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
  1061. if (ret < 0) {
  1062. wl1271_warning("acx ht capabilities setting failed: %d", ret);
  1063. goto out;
  1064. }
  1065. out:
  1066. kfree(acx);
  1067. return ret;
  1068. }
  1069. int wl1271_acx_set_ht_information(struct wl1271 *wl,
  1070. u16 ht_operation_mode)
  1071. {
  1072. struct wl1271_acx_ht_information *acx;
  1073. int ret = 0;
  1074. wl1271_debug(DEBUG_ACX, "acx ht information setting");
  1075. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1076. if (!acx) {
  1077. ret = -ENOMEM;
  1078. goto out;
  1079. }
  1080. acx->ht_protection =
  1081. (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
  1082. acx->rifs_mode = 0;
  1083. acx->gf_protection =
  1084. !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  1085. acx->ht_tx_burst_limit = 0;
  1086. acx->dual_cts_protection = 0;
  1087. ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
  1088. if (ret < 0) {
  1089. wl1271_warning("acx ht information setting failed: %d", ret);
  1090. goto out;
  1091. }
  1092. out:
  1093. kfree(acx);
  1094. return ret;
  1095. }
  1096. /* Configure BA session initiator/receiver parameters setting in the FW. */
  1097. int wl1271_acx_set_ba_session(struct wl1271 *wl,
  1098. enum ieee80211_back_parties direction,
  1099. u8 tid_index, u8 policy)
  1100. {
  1101. struct wl1271_acx_ba_session_policy *acx;
  1102. int ret;
  1103. wl1271_debug(DEBUG_ACX, "acx ba session setting");
  1104. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1105. if (!acx) {
  1106. ret = -ENOMEM;
  1107. goto out;
  1108. }
  1109. /* ANY role */
  1110. acx->role_id = 0xff;
  1111. acx->tid = tid_index;
  1112. acx->enable = policy;
  1113. acx->ba_direction = direction;
  1114. switch (direction) {
  1115. case WLAN_BACK_INITIATOR:
  1116. acx->win_size = wl->conf.ht.tx_ba_win_size;
  1117. acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
  1118. break;
  1119. case WLAN_BACK_RECIPIENT:
  1120. acx->win_size = RX_BA_WIN_SIZE;
  1121. acx->inactivity_timeout = 0;
  1122. break;
  1123. default:
  1124. wl1271_error("Incorrect acx command id=%x\n", direction);
  1125. ret = -EINVAL;
  1126. goto out;
  1127. }
  1128. ret = wl1271_cmd_configure(wl,
  1129. ACX_BA_SESSION_POLICY_CFG,
  1130. acx,
  1131. sizeof(*acx));
  1132. if (ret < 0) {
  1133. wl1271_warning("acx ba session setting failed: %d", ret);
  1134. goto out;
  1135. }
  1136. out:
  1137. kfree(acx);
  1138. return ret;
  1139. }
  1140. /* setup BA session receiver setting in the FW. */
  1141. int wl1271_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn,
  1142. bool enable)
  1143. {
  1144. struct wl1271_acx_ba_receiver_setup *acx;
  1145. int ret;
  1146. wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
  1147. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1148. if (!acx) {
  1149. ret = -ENOMEM;
  1150. goto out;
  1151. }
  1152. /* Single link for now */
  1153. acx->link_id = 1;
  1154. acx->tid = tid_index;
  1155. acx->enable = enable;
  1156. acx->win_size = 0;
  1157. acx->ssn = ssn;
  1158. ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
  1159. sizeof(*acx));
  1160. if (ret < 0) {
  1161. wl1271_warning("acx ba receiver session failed: %d", ret);
  1162. goto out;
  1163. }
  1164. out:
  1165. kfree(acx);
  1166. return ret;
  1167. }
  1168. int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
  1169. {
  1170. struct wl1271_acx_fw_tsf_information *tsf_info;
  1171. int ret;
  1172. tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
  1173. if (!tsf_info) {
  1174. ret = -ENOMEM;
  1175. goto out;
  1176. }
  1177. ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
  1178. tsf_info, sizeof(*tsf_info));
  1179. if (ret < 0) {
  1180. wl1271_warning("acx tsf info interrogate failed");
  1181. goto out;
  1182. }
  1183. *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
  1184. ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
  1185. out:
  1186. kfree(tsf_info);
  1187. return ret;
  1188. }
  1189. int wl1271_acx_max_tx_retry(struct wl1271 *wl)
  1190. {
  1191. struct wl1271_acx_max_tx_retry *acx = NULL;
  1192. int ret;
  1193. wl1271_debug(DEBUG_ACX, "acx max tx retry");
  1194. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1195. if (!acx)
  1196. return -ENOMEM;
  1197. acx->max_tx_retry = cpu_to_le16(wl->conf.tx.ap_max_tx_retries);
  1198. ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
  1199. if (ret < 0) {
  1200. wl1271_warning("acx max tx retry failed: %d", ret);
  1201. goto out;
  1202. }
  1203. out:
  1204. kfree(acx);
  1205. return ret;
  1206. }
  1207. int wl1271_acx_config_ps(struct wl1271 *wl)
  1208. {
  1209. struct wl1271_acx_config_ps *config_ps;
  1210. int ret;
  1211. wl1271_debug(DEBUG_ACX, "acx config ps");
  1212. config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
  1213. if (!config_ps) {
  1214. ret = -ENOMEM;
  1215. goto out;
  1216. }
  1217. config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
  1218. config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
  1219. config_ps->null_data_rate = cpu_to_le32(wl->basic_rate);
  1220. ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
  1221. sizeof(*config_ps));
  1222. if (ret < 0) {
  1223. wl1271_warning("acx config ps failed: %d", ret);
  1224. goto out;
  1225. }
  1226. out:
  1227. kfree(config_ps);
  1228. return ret;
  1229. }
  1230. int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
  1231. {
  1232. struct wl1271_acx_inconnection_sta *acx = NULL;
  1233. int ret;
  1234. wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
  1235. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1236. if (!acx)
  1237. return -ENOMEM;
  1238. memcpy(acx->addr, addr, ETH_ALEN);
  1239. ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
  1240. acx, sizeof(*acx));
  1241. if (ret < 0) {
  1242. wl1271_warning("acx set inconnaction sta failed: %d", ret);
  1243. goto out;
  1244. }
  1245. out:
  1246. kfree(acx);
  1247. return ret;
  1248. }