wl1271_acx.c 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  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 "wl1271_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 "wl1271.h"
  29. #include "wl12xx_80211.h"
  30. #include "wl1271_reg.h"
  31. #include "wl1271_ps.h"
  32. int wl1271_acx_wake_up_conditions(struct wl1271 *wl)
  33. {
  34. struct acx_wake_up_condition *wake_up;
  35. int ret;
  36. wl1271_debug(DEBUG_ACX, "acx wake up conditions");
  37. wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
  38. if (!wake_up) {
  39. ret = -ENOMEM;
  40. goto out;
  41. }
  42. wake_up->wake_up_event = wl->conf.conn.wake_up_event;
  43. wake_up->listen_interval = wl->conf.conn.listen_interval;
  44. ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
  45. wake_up, sizeof(*wake_up));
  46. if (ret < 0) {
  47. wl1271_warning("could not set wake up conditions: %d", ret);
  48. goto out;
  49. }
  50. out:
  51. kfree(wake_up);
  52. return ret;
  53. }
  54. int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
  55. {
  56. struct acx_sleep_auth *auth;
  57. int ret;
  58. wl1271_debug(DEBUG_ACX, "acx sleep auth");
  59. auth = kzalloc(sizeof(*auth), GFP_KERNEL);
  60. if (!auth) {
  61. ret = -ENOMEM;
  62. goto out;
  63. }
  64. auth->sleep_auth = sleep_auth;
  65. ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
  66. if (ret < 0)
  67. return ret;
  68. out:
  69. kfree(auth);
  70. return ret;
  71. }
  72. int wl1271_acx_fw_version(struct wl1271 *wl, char *buf, size_t len)
  73. {
  74. struct acx_revision *rev;
  75. int ret;
  76. wl1271_debug(DEBUG_ACX, "acx fw rev");
  77. rev = kzalloc(sizeof(*rev), GFP_KERNEL);
  78. if (!rev) {
  79. ret = -ENOMEM;
  80. goto out;
  81. }
  82. ret = wl1271_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev));
  83. if (ret < 0) {
  84. wl1271_warning("ACX_FW_REV interrogate failed");
  85. goto out;
  86. }
  87. /* be careful with the buffer sizes */
  88. strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
  89. /*
  90. * if the firmware version string is exactly
  91. * sizeof(rev->fw_version) long or fw_len is less than
  92. * sizeof(rev->fw_version) it won't be null terminated
  93. */
  94. buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
  95. out:
  96. kfree(rev);
  97. return ret;
  98. }
  99. int wl1271_acx_tx_power(struct wl1271 *wl, int power)
  100. {
  101. struct acx_current_tx_power *acx;
  102. int ret;
  103. wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr");
  104. if (power < 0 || power > 25)
  105. return -EINVAL;
  106. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  107. if (!acx) {
  108. ret = -ENOMEM;
  109. goto out;
  110. }
  111. acx->current_tx_power = power * 10;
  112. ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
  113. if (ret < 0) {
  114. wl1271_warning("configure of tx power failed: %d", ret);
  115. goto out;
  116. }
  117. out:
  118. kfree(acx);
  119. return ret;
  120. }
  121. int wl1271_acx_feature_cfg(struct wl1271 *wl)
  122. {
  123. struct acx_feature_config *feature;
  124. int ret;
  125. wl1271_debug(DEBUG_ACX, "acx feature cfg");
  126. feature = kzalloc(sizeof(*feature), GFP_KERNEL);
  127. if (!feature) {
  128. ret = -ENOMEM;
  129. goto out;
  130. }
  131. /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
  132. feature->data_flow_options = 0;
  133. feature->options = 0;
  134. ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
  135. feature, sizeof(*feature));
  136. if (ret < 0) {
  137. wl1271_error("Couldnt set HW encryption");
  138. goto out;
  139. }
  140. out:
  141. kfree(feature);
  142. return ret;
  143. }
  144. int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
  145. size_t len)
  146. {
  147. int ret;
  148. wl1271_debug(DEBUG_ACX, "acx mem map");
  149. ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
  150. if (ret < 0)
  151. return ret;
  152. return 0;
  153. }
  154. int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
  155. {
  156. struct acx_rx_msdu_lifetime *acx;
  157. int ret;
  158. wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
  159. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  160. if (!acx) {
  161. ret = -ENOMEM;
  162. goto out;
  163. }
  164. acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
  165. ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
  166. acx, sizeof(*acx));
  167. if (ret < 0) {
  168. wl1271_warning("failed to set rx msdu life time: %d", ret);
  169. goto out;
  170. }
  171. out:
  172. kfree(acx);
  173. return ret;
  174. }
  175. int wl1271_acx_rx_config(struct wl1271 *wl, u32 config, u32 filter)
  176. {
  177. struct acx_rx_config *rx_config;
  178. int ret;
  179. wl1271_debug(DEBUG_ACX, "acx rx config");
  180. rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL);
  181. if (!rx_config) {
  182. ret = -ENOMEM;
  183. goto out;
  184. }
  185. rx_config->config_options = cpu_to_le32(config);
  186. rx_config->filter_options = cpu_to_le32(filter);
  187. ret = wl1271_cmd_configure(wl, ACX_RX_CFG,
  188. rx_config, sizeof(*rx_config));
  189. if (ret < 0) {
  190. wl1271_warning("failed to set rx config: %d", ret);
  191. goto out;
  192. }
  193. out:
  194. kfree(rx_config);
  195. return ret;
  196. }
  197. int wl1271_acx_pd_threshold(struct wl1271 *wl)
  198. {
  199. struct acx_packet_detection *pd;
  200. int ret;
  201. wl1271_debug(DEBUG_ACX, "acx data pd threshold");
  202. pd = kzalloc(sizeof(*pd), GFP_KERNEL);
  203. if (!pd) {
  204. ret = -ENOMEM;
  205. goto out;
  206. }
  207. pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold);
  208. ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
  209. if (ret < 0) {
  210. wl1271_warning("failed to set pd threshold: %d", ret);
  211. goto out;
  212. }
  213. out:
  214. kfree(pd);
  215. return 0;
  216. }
  217. int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time)
  218. {
  219. struct acx_slot *slot;
  220. int ret;
  221. wl1271_debug(DEBUG_ACX, "acx slot");
  222. slot = kzalloc(sizeof(*slot), GFP_KERNEL);
  223. if (!slot) {
  224. ret = -ENOMEM;
  225. goto out;
  226. }
  227. slot->wone_index = STATION_WONE_INDEX;
  228. slot->slot_time = slot_time;
  229. ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
  230. if (ret < 0) {
  231. wl1271_warning("failed to set slot time: %d", ret);
  232. goto out;
  233. }
  234. out:
  235. kfree(slot);
  236. return ret;
  237. }
  238. int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable,
  239. void *mc_list, u32 mc_list_len)
  240. {
  241. struct acx_dot11_grp_addr_tbl *acx;
  242. int ret;
  243. wl1271_debug(DEBUG_ACX, "acx group address tbl");
  244. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  245. if (!acx) {
  246. ret = -ENOMEM;
  247. goto out;
  248. }
  249. /* MAC filtering */
  250. acx->enabled = enable;
  251. acx->num_groups = mc_list_len;
  252. memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
  253. ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
  254. acx, sizeof(*acx));
  255. if (ret < 0) {
  256. wl1271_warning("failed to set group addr table: %d", ret);
  257. goto out;
  258. }
  259. out:
  260. kfree(acx);
  261. return ret;
  262. }
  263. int wl1271_acx_service_period_timeout(struct wl1271 *wl)
  264. {
  265. struct acx_rx_timeout *rx_timeout;
  266. int ret;
  267. rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
  268. if (!rx_timeout) {
  269. ret = -ENOMEM;
  270. goto out;
  271. }
  272. wl1271_debug(DEBUG_ACX, "acx service period timeout");
  273. rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
  274. rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
  275. ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
  276. rx_timeout, sizeof(*rx_timeout));
  277. if (ret < 0) {
  278. wl1271_warning("failed to set service period timeout: %d",
  279. ret);
  280. goto out;
  281. }
  282. out:
  283. kfree(rx_timeout);
  284. return ret;
  285. }
  286. int wl1271_acx_rts_threshold(struct wl1271 *wl, u16 rts_threshold)
  287. {
  288. struct acx_rts_threshold *rts;
  289. int ret;
  290. wl1271_debug(DEBUG_ACX, "acx rts threshold");
  291. rts = kzalloc(sizeof(*rts), GFP_KERNEL);
  292. if (!rts) {
  293. ret = -ENOMEM;
  294. goto out;
  295. }
  296. rts->threshold = cpu_to_le16(rts_threshold);
  297. ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
  298. if (ret < 0) {
  299. wl1271_warning("failed to set rts threshold: %d", ret);
  300. goto out;
  301. }
  302. out:
  303. kfree(rts);
  304. return ret;
  305. }
  306. int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
  307. {
  308. struct acx_dco_itrim_params *dco;
  309. struct conf_itrim_settings *c = &wl->conf.itrim;
  310. int ret;
  311. wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
  312. dco = kzalloc(sizeof(*dco), GFP_KERNEL);
  313. if (!dco) {
  314. ret = -ENOMEM;
  315. goto out;
  316. }
  317. dco->enable = c->enable;
  318. dco->timeout = cpu_to_le32(c->timeout);
  319. ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
  320. dco, sizeof(*dco));
  321. if (ret < 0) {
  322. wl1271_warning("failed to set dco itrim parameters: %d", ret);
  323. goto out;
  324. }
  325. out:
  326. kfree(dco);
  327. return ret;
  328. }
  329. int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter)
  330. {
  331. struct acx_beacon_filter_option *beacon_filter = NULL;
  332. int ret = 0;
  333. wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
  334. if (enable_filter &&
  335. wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
  336. goto out;
  337. beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
  338. if (!beacon_filter) {
  339. ret = -ENOMEM;
  340. goto out;
  341. }
  342. beacon_filter->enable = enable_filter;
  343. /*
  344. * When set to zero, and the filter is enabled, beacons
  345. * without the unicast TIM bit set are dropped.
  346. */
  347. beacon_filter->max_num_beacons = 0;
  348. ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
  349. beacon_filter, sizeof(*beacon_filter));
  350. if (ret < 0) {
  351. wl1271_warning("failed to set beacon filter opt: %d", ret);
  352. goto out;
  353. }
  354. out:
  355. kfree(beacon_filter);
  356. return ret;
  357. }
  358. int wl1271_acx_beacon_filter_table(struct wl1271 *wl)
  359. {
  360. struct acx_beacon_filter_ie_table *ie_table;
  361. int i, idx = 0;
  362. int ret;
  363. bool vendor_spec = false;
  364. wl1271_debug(DEBUG_ACX, "acx beacon filter table");
  365. ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
  366. if (!ie_table) {
  367. ret = -ENOMEM;
  368. goto out;
  369. }
  370. /* configure default beacon pass-through rules */
  371. ie_table->num_ie = 0;
  372. for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
  373. struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
  374. ie_table->table[idx++] = r->ie;
  375. ie_table->table[idx++] = r->rule;
  376. if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
  377. /* only one vendor specific ie allowed */
  378. if (vendor_spec)
  379. continue;
  380. /* for vendor specific rules configure the
  381. additional fields */
  382. memcpy(&(ie_table->table[idx]), r->oui,
  383. CONF_BCN_IE_OUI_LEN);
  384. idx += CONF_BCN_IE_OUI_LEN;
  385. ie_table->table[idx++] = r->type;
  386. memcpy(&(ie_table->table[idx]), r->version,
  387. CONF_BCN_IE_VER_LEN);
  388. idx += CONF_BCN_IE_VER_LEN;
  389. vendor_spec = true;
  390. }
  391. ie_table->num_ie++;
  392. }
  393. ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
  394. ie_table, sizeof(*ie_table));
  395. if (ret < 0) {
  396. wl1271_warning("failed to set beacon filter table: %d", ret);
  397. goto out;
  398. }
  399. out:
  400. kfree(ie_table);
  401. return ret;
  402. }
  403. #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
  404. int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable)
  405. {
  406. struct acx_conn_monit_params *acx;
  407. u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
  408. u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
  409. int ret;
  410. wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
  411. enable ? "enabled" : "disabled");
  412. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  413. if (!acx) {
  414. ret = -ENOMEM;
  415. goto out;
  416. }
  417. if (enable) {
  418. threshold = wl->conf.conn.synch_fail_thold;
  419. timeout = wl->conf.conn.bss_lose_timeout;
  420. }
  421. acx->synch_fail_thold = cpu_to_le32(threshold);
  422. acx->bss_lose_timeout = cpu_to_le32(timeout);
  423. ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
  424. acx, sizeof(*acx));
  425. if (ret < 0) {
  426. wl1271_warning("failed to set connection monitor "
  427. "parameters: %d", ret);
  428. goto out;
  429. }
  430. out:
  431. kfree(acx);
  432. return ret;
  433. }
  434. int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
  435. {
  436. struct acx_bt_wlan_coex *pta;
  437. int ret;
  438. wl1271_debug(DEBUG_ACX, "acx sg enable");
  439. pta = kzalloc(sizeof(*pta), GFP_KERNEL);
  440. if (!pta) {
  441. ret = -ENOMEM;
  442. goto out;
  443. }
  444. if (enable)
  445. pta->enable = wl->conf.sg.state;
  446. else
  447. pta->enable = CONF_SG_DISABLE;
  448. ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
  449. if (ret < 0) {
  450. wl1271_warning("failed to set softgemini enable: %d", ret);
  451. goto out;
  452. }
  453. out:
  454. kfree(pta);
  455. return ret;
  456. }
  457. int wl1271_acx_sg_cfg(struct wl1271 *wl)
  458. {
  459. struct acx_bt_wlan_coex_param *param;
  460. struct conf_sg_settings *c = &wl->conf.sg;
  461. int i, ret;
  462. wl1271_debug(DEBUG_ACX, "acx sg cfg");
  463. param = kzalloc(sizeof(*param), GFP_KERNEL);
  464. if (!param) {
  465. ret = -ENOMEM;
  466. goto out;
  467. }
  468. /* BT-WLAN coext parameters */
  469. for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
  470. param->params[i] = c->params[i];
  471. param->param_idx = CONF_SG_PARAMS_ALL;
  472. ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
  473. if (ret < 0) {
  474. wl1271_warning("failed to set sg config: %d", ret);
  475. goto out;
  476. }
  477. out:
  478. kfree(param);
  479. return ret;
  480. }
  481. int wl1271_acx_cca_threshold(struct wl1271 *wl)
  482. {
  483. struct acx_energy_detection *detection;
  484. int ret;
  485. wl1271_debug(DEBUG_ACX, "acx cca threshold");
  486. detection = kzalloc(sizeof(*detection), GFP_KERNEL);
  487. if (!detection) {
  488. ret = -ENOMEM;
  489. goto out;
  490. }
  491. detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
  492. detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
  493. ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
  494. detection, sizeof(*detection));
  495. if (ret < 0) {
  496. wl1271_warning("failed to set cca threshold: %d", ret);
  497. return ret;
  498. }
  499. out:
  500. kfree(detection);
  501. return ret;
  502. }
  503. int wl1271_acx_bcn_dtim_options(struct wl1271 *wl)
  504. {
  505. struct acx_beacon_broadcast *bb;
  506. int ret;
  507. wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
  508. bb = kzalloc(sizeof(*bb), GFP_KERNEL);
  509. if (!bb) {
  510. ret = -ENOMEM;
  511. goto out;
  512. }
  513. bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
  514. bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
  515. bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
  516. bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
  517. ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
  518. if (ret < 0) {
  519. wl1271_warning("failed to set rx config: %d", ret);
  520. goto out;
  521. }
  522. out:
  523. kfree(bb);
  524. return ret;
  525. }
  526. int wl1271_acx_aid(struct wl1271 *wl, u16 aid)
  527. {
  528. struct acx_aid *acx_aid;
  529. int ret;
  530. wl1271_debug(DEBUG_ACX, "acx aid");
  531. acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
  532. if (!acx_aid) {
  533. ret = -ENOMEM;
  534. goto out;
  535. }
  536. acx_aid->aid = cpu_to_le16(aid);
  537. ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
  538. if (ret < 0) {
  539. wl1271_warning("failed to set aid: %d", ret);
  540. goto out;
  541. }
  542. out:
  543. kfree(acx_aid);
  544. return ret;
  545. }
  546. int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
  547. {
  548. struct acx_event_mask *mask;
  549. int ret;
  550. wl1271_debug(DEBUG_ACX, "acx event mbox mask");
  551. mask = kzalloc(sizeof(*mask), GFP_KERNEL);
  552. if (!mask) {
  553. ret = -ENOMEM;
  554. goto out;
  555. }
  556. /* high event mask is unused */
  557. mask->high_event_mask = cpu_to_le32(0xffffffff);
  558. mask->event_mask = cpu_to_le32(event_mask);
  559. ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
  560. mask, sizeof(*mask));
  561. if (ret < 0) {
  562. wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
  563. goto out;
  564. }
  565. out:
  566. kfree(mask);
  567. return ret;
  568. }
  569. int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble)
  570. {
  571. struct acx_preamble *acx;
  572. int ret;
  573. wl1271_debug(DEBUG_ACX, "acx_set_preamble");
  574. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  575. if (!acx) {
  576. ret = -ENOMEM;
  577. goto out;
  578. }
  579. acx->preamble = preamble;
  580. ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
  581. if (ret < 0) {
  582. wl1271_warning("Setting of preamble failed: %d", ret);
  583. goto out;
  584. }
  585. out:
  586. kfree(acx);
  587. return ret;
  588. }
  589. int wl1271_acx_cts_protect(struct wl1271 *wl,
  590. enum acx_ctsprotect_type ctsprotect)
  591. {
  592. struct acx_ctsprotect *acx;
  593. int ret;
  594. wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
  595. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  596. if (!acx) {
  597. ret = -ENOMEM;
  598. goto out;
  599. }
  600. acx->ctsprotect = ctsprotect;
  601. ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
  602. if (ret < 0) {
  603. wl1271_warning("Setting of ctsprotect failed: %d", ret);
  604. goto out;
  605. }
  606. out:
  607. kfree(acx);
  608. return ret;
  609. }
  610. int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
  611. {
  612. int ret;
  613. wl1271_debug(DEBUG_ACX, "acx statistics");
  614. ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
  615. sizeof(*stats));
  616. if (ret < 0) {
  617. wl1271_warning("acx statistics failed: %d", ret);
  618. return -ENOMEM;
  619. }
  620. return 0;
  621. }
  622. int wl1271_acx_rate_policies(struct wl1271 *wl)
  623. {
  624. struct acx_rate_policy *acx;
  625. struct conf_tx_rate_class *c = &wl->conf.tx.rc_conf;
  626. int idx = 0;
  627. int ret = 0;
  628. wl1271_debug(DEBUG_ACX, "acx rate policies");
  629. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  630. if (!acx) {
  631. ret = -ENOMEM;
  632. goto out;
  633. }
  634. /* configure one basic rate class */
  635. idx = ACX_TX_BASIC_RATE;
  636. acx->rate_class[idx].enabled_rates = cpu_to_le32(wl->basic_rate_set);
  637. acx->rate_class[idx].short_retry_limit = c->short_retry_limit;
  638. acx->rate_class[idx].long_retry_limit = c->long_retry_limit;
  639. acx->rate_class[idx].aflags = c->aflags;
  640. /* configure one AP supported rate class */
  641. idx = ACX_TX_AP_FULL_RATE;
  642. acx->rate_class[idx].enabled_rates = cpu_to_le32(wl->rate_set);
  643. acx->rate_class[idx].short_retry_limit = c->short_retry_limit;
  644. acx->rate_class[idx].long_retry_limit = c->long_retry_limit;
  645. acx->rate_class[idx].aflags = c->aflags;
  646. acx->rate_class_cnt = cpu_to_le32(ACX_TX_RATE_POLICY_CNT);
  647. ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  648. if (ret < 0) {
  649. wl1271_warning("Setting of rate policies failed: %d", ret);
  650. goto out;
  651. }
  652. out:
  653. kfree(acx);
  654. return ret;
  655. }
  656. int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
  657. u8 aifsn, u16 txop)
  658. {
  659. struct acx_ac_cfg *acx;
  660. int ret = 0;
  661. wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
  662. "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
  663. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  664. if (!acx) {
  665. ret = -ENOMEM;
  666. goto out;
  667. }
  668. acx->ac = ac;
  669. acx->cw_min = cw_min;
  670. acx->cw_max = cpu_to_le16(cw_max);
  671. acx->aifsn = aifsn;
  672. acx->tx_op_limit = cpu_to_le16(txop);
  673. ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
  674. if (ret < 0) {
  675. wl1271_warning("acx ac cfg failed: %d", ret);
  676. goto out;
  677. }
  678. out:
  679. kfree(acx);
  680. return ret;
  681. }
  682. int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
  683. u8 tsid, u8 ps_scheme, u8 ack_policy,
  684. u32 apsd_conf0, u32 apsd_conf1)
  685. {
  686. struct acx_tid_config *acx;
  687. int ret = 0;
  688. wl1271_debug(DEBUG_ACX, "acx tid config");
  689. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  690. if (!acx) {
  691. ret = -ENOMEM;
  692. goto out;
  693. }
  694. acx->queue_id = queue_id;
  695. acx->channel_type = channel_type;
  696. acx->tsid = tsid;
  697. acx->ps_scheme = ps_scheme;
  698. acx->ack_policy = ack_policy;
  699. acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
  700. acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
  701. ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
  702. if (ret < 0) {
  703. wl1271_warning("Setting of tid config failed: %d", ret);
  704. goto out;
  705. }
  706. out:
  707. kfree(acx);
  708. return ret;
  709. }
  710. int wl1271_acx_frag_threshold(struct wl1271 *wl)
  711. {
  712. struct acx_frag_threshold *acx;
  713. int ret = 0;
  714. wl1271_debug(DEBUG_ACX, "acx frag threshold");
  715. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  716. if (!acx) {
  717. ret = -ENOMEM;
  718. goto out;
  719. }
  720. acx->frag_threshold = cpu_to_le16(wl->conf.tx.frag_threshold);
  721. ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
  722. if (ret < 0) {
  723. wl1271_warning("Setting of frag threshold failed: %d", ret);
  724. goto out;
  725. }
  726. out:
  727. kfree(acx);
  728. return ret;
  729. }
  730. int wl1271_acx_tx_config_options(struct wl1271 *wl)
  731. {
  732. struct acx_tx_config_options *acx;
  733. int ret = 0;
  734. wl1271_debug(DEBUG_ACX, "acx tx config options");
  735. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  736. if (!acx) {
  737. ret = -ENOMEM;
  738. goto out;
  739. }
  740. acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
  741. acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
  742. ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
  743. if (ret < 0) {
  744. wl1271_warning("Setting of tx options failed: %d", ret);
  745. goto out;
  746. }
  747. out:
  748. kfree(acx);
  749. return ret;
  750. }
  751. int wl1271_acx_mem_cfg(struct wl1271 *wl)
  752. {
  753. struct wl1271_acx_config_memory *mem_conf;
  754. int ret;
  755. wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
  756. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  757. if (!mem_conf) {
  758. ret = -ENOMEM;
  759. goto out;
  760. }
  761. /* memory config */
  762. mem_conf->num_stations = DEFAULT_NUM_STATIONS;
  763. mem_conf->rx_mem_block_num = ACX_RX_MEM_BLOCKS;
  764. mem_conf->tx_min_mem_block_num = ACX_TX_MIN_MEM_BLOCKS;
  765. mem_conf->num_ssid_profiles = ACX_NUM_SSID_PROFILES;
  766. mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
  767. ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  768. sizeof(*mem_conf));
  769. if (ret < 0) {
  770. wl1271_warning("wl1271 mem config failed: %d", ret);
  771. goto out;
  772. }
  773. out:
  774. kfree(mem_conf);
  775. return ret;
  776. }
  777. int wl1271_acx_init_mem_config(struct wl1271 *wl)
  778. {
  779. int ret;
  780. ret = wl1271_acx_mem_cfg(wl);
  781. if (ret < 0)
  782. return ret;
  783. wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
  784. GFP_KERNEL);
  785. if (!wl->target_mem_map) {
  786. wl1271_error("couldn't allocate target memory map");
  787. return -ENOMEM;
  788. }
  789. /* we now ask for the firmware built memory map */
  790. ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
  791. sizeof(struct wl1271_acx_mem_map));
  792. if (ret < 0) {
  793. wl1271_error("couldn't retrieve firmware memory map");
  794. kfree(wl->target_mem_map);
  795. wl->target_mem_map = NULL;
  796. return ret;
  797. }
  798. /* initialize TX block book keeping */
  799. wl->tx_blocks_available =
  800. le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
  801. wl1271_debug(DEBUG_TX, "available tx blocks: %d",
  802. wl->tx_blocks_available);
  803. return 0;
  804. }
  805. int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
  806. {
  807. struct wl1271_acx_rx_config_opt *rx_conf;
  808. int ret;
  809. wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
  810. rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
  811. if (!rx_conf) {
  812. ret = -ENOMEM;
  813. goto out;
  814. }
  815. rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
  816. rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
  817. rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
  818. rx_conf->queue_type = wl->conf.rx.queue_type;
  819. ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
  820. sizeof(*rx_conf));
  821. if (ret < 0) {
  822. wl1271_warning("wl1271 rx config opt failed: %d", ret);
  823. goto out;
  824. }
  825. out:
  826. kfree(rx_conf);
  827. return ret;
  828. }
  829. int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
  830. {
  831. struct wl1271_acx_bet_enable *acx = NULL;
  832. int ret = 0;
  833. wl1271_debug(DEBUG_ACX, "acx bet enable");
  834. if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
  835. goto out;
  836. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  837. if (!acx) {
  838. ret = -ENOMEM;
  839. goto out;
  840. }
  841. acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
  842. acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
  843. ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
  844. if (ret < 0) {
  845. wl1271_warning("acx bet enable failed: %d", ret);
  846. goto out;
  847. }
  848. out:
  849. kfree(acx);
  850. return ret;
  851. }
  852. int wl1271_acx_arp_ip_filter(struct wl1271 *wl, bool enable, u8 *address,
  853. u8 version)
  854. {
  855. struct wl1271_acx_arp_filter *acx;
  856. int ret;
  857. wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
  858. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  859. if (!acx) {
  860. ret = -ENOMEM;
  861. goto out;
  862. }
  863. acx->version = version;
  864. acx->enable = enable;
  865. if (enable == true) {
  866. if (version == ACX_IPV4_VERSION)
  867. memcpy(acx->address, address, ACX_IPV4_ADDR_SIZE);
  868. else if (version == ACX_IPV6_VERSION)
  869. memcpy(acx->address, address, sizeof(acx->address));
  870. else
  871. wl1271_error("Invalid IP version");
  872. }
  873. ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
  874. acx, sizeof(*acx));
  875. if (ret < 0) {
  876. wl1271_warning("failed to set arp ip filter: %d", ret);
  877. goto out;
  878. }
  879. out:
  880. kfree(acx);
  881. return ret;
  882. }
  883. int wl1271_acx_pm_config(struct wl1271 *wl)
  884. {
  885. struct wl1271_acx_pm_config *acx = NULL;
  886. struct conf_pm_config_settings *c = &wl->conf.pm_config;
  887. int ret = 0;
  888. wl1271_debug(DEBUG_ACX, "acx pm config");
  889. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  890. if (!acx) {
  891. ret = -ENOMEM;
  892. goto out;
  893. }
  894. acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
  895. acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
  896. ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
  897. if (ret < 0) {
  898. wl1271_warning("acx pm config failed: %d", ret);
  899. goto out;
  900. }
  901. out:
  902. kfree(acx);
  903. return ret;
  904. }
  905. int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
  906. {
  907. struct wl1271_acx_keep_alive_mode *acx = NULL;
  908. int ret = 0;
  909. wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
  910. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  911. if (!acx) {
  912. ret = -ENOMEM;
  913. goto out;
  914. }
  915. acx->enabled = enable;
  916. ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
  917. if (ret < 0) {
  918. wl1271_warning("acx keep alive mode failed: %d", ret);
  919. goto out;
  920. }
  921. out:
  922. kfree(acx);
  923. return ret;
  924. }
  925. int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
  926. {
  927. struct wl1271_acx_keep_alive_config *acx = NULL;
  928. int ret = 0;
  929. wl1271_debug(DEBUG_ACX, "acx keep alive config");
  930. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  931. if (!acx) {
  932. ret = -ENOMEM;
  933. goto out;
  934. }
  935. acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
  936. acx->index = index;
  937. acx->tpl_validation = tpl_valid;
  938. acx->trigger = ACX_KEEP_ALIVE_NO_TX;
  939. ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
  940. acx, sizeof(*acx));
  941. if (ret < 0) {
  942. wl1271_warning("acx keep alive config failed: %d", ret);
  943. goto out;
  944. }
  945. out:
  946. kfree(acx);
  947. return ret;
  948. }