acx.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  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");
  669. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  670. if (!acx) {
  671. ret = -ENOMEM;
  672. goto out;
  673. }
  674. acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
  675. acx->rate_policy.short_retry_limit = c->short_retry_limit;
  676. acx->rate_policy.long_retry_limit = c->long_retry_limit;
  677. acx->rate_policy.aflags = c->aflags;
  678. acx->rate_policy_idx = cpu_to_le32(idx);
  679. ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
  680. if (ret < 0) {
  681. wl1271_warning("Setting of ap rate policy failed: %d", ret);
  682. goto out;
  683. }
  684. out:
  685. kfree(acx);
  686. return ret;
  687. }
  688. int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
  689. u8 aifsn, u16 txop)
  690. {
  691. struct acx_ac_cfg *acx;
  692. int ret = 0;
  693. wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
  694. "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
  695. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  696. if (!acx) {
  697. ret = -ENOMEM;
  698. goto out;
  699. }
  700. acx->ac = ac;
  701. acx->cw_min = cw_min;
  702. acx->cw_max = cpu_to_le16(cw_max);
  703. acx->aifsn = aifsn;
  704. acx->tx_op_limit = cpu_to_le16(txop);
  705. ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
  706. if (ret < 0) {
  707. wl1271_warning("acx ac cfg failed: %d", ret);
  708. goto out;
  709. }
  710. out:
  711. kfree(acx);
  712. return ret;
  713. }
  714. int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
  715. u8 tsid, u8 ps_scheme, u8 ack_policy,
  716. u32 apsd_conf0, u32 apsd_conf1)
  717. {
  718. struct acx_tid_config *acx;
  719. int ret = 0;
  720. wl1271_debug(DEBUG_ACX, "acx tid config");
  721. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  722. if (!acx) {
  723. ret = -ENOMEM;
  724. goto out;
  725. }
  726. acx->queue_id = queue_id;
  727. acx->channel_type = channel_type;
  728. acx->tsid = tsid;
  729. acx->ps_scheme = ps_scheme;
  730. acx->ack_policy = ack_policy;
  731. acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
  732. acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
  733. ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
  734. if (ret < 0) {
  735. wl1271_warning("Setting of tid config failed: %d", ret);
  736. goto out;
  737. }
  738. out:
  739. kfree(acx);
  740. return ret;
  741. }
  742. int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
  743. {
  744. struct acx_frag_threshold *acx;
  745. int ret = 0;
  746. /*
  747. * If the fragmentation is not configured or out of range, use the
  748. * default value.
  749. */
  750. if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
  751. frag_threshold = wl->conf.tx.frag_threshold;
  752. wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
  753. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  754. if (!acx) {
  755. ret = -ENOMEM;
  756. goto out;
  757. }
  758. acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
  759. ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
  760. if (ret < 0) {
  761. wl1271_warning("Setting of frag threshold failed: %d", ret);
  762. goto out;
  763. }
  764. out:
  765. kfree(acx);
  766. return ret;
  767. }
  768. int wl1271_acx_tx_config_options(struct wl1271 *wl)
  769. {
  770. struct acx_tx_config_options *acx;
  771. int ret = 0;
  772. wl1271_debug(DEBUG_ACX, "acx tx config options");
  773. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  774. if (!acx) {
  775. ret = -ENOMEM;
  776. goto out;
  777. }
  778. acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
  779. acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
  780. ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
  781. if (ret < 0) {
  782. wl1271_warning("Setting of tx options failed: %d", ret);
  783. goto out;
  784. }
  785. out:
  786. kfree(acx);
  787. return ret;
  788. }
  789. int wl1271_acx_ap_mem_cfg(struct wl1271 *wl)
  790. {
  791. struct wl1271_acx_ap_config_memory *mem_conf;
  792. struct conf_memory_settings *mem;
  793. int ret;
  794. wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
  795. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  796. if (!mem_conf) {
  797. ret = -ENOMEM;
  798. goto out;
  799. }
  800. if (wl->chip.id == CHIP_ID_1283_PG20)
  801. /*
  802. * FIXME: The 128x AP FW does not yet support dynamic memory.
  803. * Use the base memory configuration for 128x for now. This
  804. * should be fine tuned in the future.
  805. */
  806. mem = &wl->conf.mem_wl128x;
  807. else
  808. mem = &wl->conf.mem_wl127x;
  809. /* memory config */
  810. mem_conf->num_stations = mem->num_stations;
  811. mem_conf->rx_mem_block_num = mem->rx_block_num;
  812. mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
  813. mem_conf->num_ssid_profiles = mem->ssid_profiles;
  814. mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
  815. ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  816. sizeof(*mem_conf));
  817. if (ret < 0) {
  818. wl1271_warning("wl1271 mem config failed: %d", ret);
  819. goto out;
  820. }
  821. out:
  822. kfree(mem_conf);
  823. return ret;
  824. }
  825. int wl1271_acx_sta_mem_cfg(struct wl1271 *wl)
  826. {
  827. struct wl1271_acx_sta_config_memory *mem_conf;
  828. struct conf_memory_settings *mem;
  829. int ret;
  830. wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
  831. mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
  832. if (!mem_conf) {
  833. ret = -ENOMEM;
  834. goto out;
  835. }
  836. if (wl->chip.id == CHIP_ID_1283_PG20)
  837. mem = &wl->conf.mem_wl128x;
  838. else
  839. mem = &wl->conf.mem_wl127x;
  840. /* memory config */
  841. mem_conf->num_stations = mem->num_stations;
  842. mem_conf->rx_mem_block_num = mem->rx_block_num;
  843. mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
  844. mem_conf->num_ssid_profiles = mem->ssid_profiles;
  845. mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
  846. mem_conf->dyn_mem_enable = mem->dynamic_memory;
  847. mem_conf->tx_free_req = mem->min_req_tx_blocks;
  848. mem_conf->rx_free_req = mem->min_req_rx_blocks;
  849. mem_conf->tx_min = mem->tx_min;
  850. ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
  851. sizeof(*mem_conf));
  852. if (ret < 0) {
  853. wl1271_warning("wl1271 mem config failed: %d", ret);
  854. goto out;
  855. }
  856. out:
  857. kfree(mem_conf);
  858. return ret;
  859. }
  860. int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
  861. {
  862. struct wl1271_acx_host_config_bitmap *bitmap_conf;
  863. int ret;
  864. bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
  865. if (!bitmap_conf) {
  866. ret = -ENOMEM;
  867. goto out;
  868. }
  869. bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
  870. ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
  871. bitmap_conf, sizeof(*bitmap_conf));
  872. if (ret < 0) {
  873. wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
  874. goto out;
  875. }
  876. out:
  877. kfree(bitmap_conf);
  878. return ret;
  879. }
  880. int wl1271_acx_init_mem_config(struct wl1271 *wl)
  881. {
  882. int ret;
  883. wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
  884. GFP_KERNEL);
  885. if (!wl->target_mem_map) {
  886. wl1271_error("couldn't allocate target memory map");
  887. return -ENOMEM;
  888. }
  889. /* we now ask for the firmware built memory map */
  890. ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
  891. sizeof(struct wl1271_acx_mem_map));
  892. if (ret < 0) {
  893. wl1271_error("couldn't retrieve firmware memory map");
  894. kfree(wl->target_mem_map);
  895. wl->target_mem_map = NULL;
  896. return ret;
  897. }
  898. /* initialize TX block book keeping */
  899. wl->tx_blocks_available =
  900. le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
  901. wl1271_debug(DEBUG_TX, "available tx blocks: %d",
  902. wl->tx_blocks_available);
  903. return 0;
  904. }
  905. int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
  906. {
  907. struct wl1271_acx_rx_config_opt *rx_conf;
  908. int ret;
  909. wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
  910. rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
  911. if (!rx_conf) {
  912. ret = -ENOMEM;
  913. goto out;
  914. }
  915. rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
  916. rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
  917. rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
  918. rx_conf->queue_type = wl->conf.rx.queue_type;
  919. ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
  920. sizeof(*rx_conf));
  921. if (ret < 0) {
  922. wl1271_warning("wl1271 rx config opt failed: %d", ret);
  923. goto out;
  924. }
  925. out:
  926. kfree(rx_conf);
  927. return ret;
  928. }
  929. int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
  930. {
  931. struct wl1271_acx_bet_enable *acx = NULL;
  932. int ret = 0;
  933. wl1271_debug(DEBUG_ACX, "acx bet enable");
  934. if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
  935. goto out;
  936. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  937. if (!acx) {
  938. ret = -ENOMEM;
  939. goto out;
  940. }
  941. acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
  942. acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
  943. ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
  944. if (ret < 0) {
  945. wl1271_warning("acx bet enable failed: %d", ret);
  946. goto out;
  947. }
  948. out:
  949. kfree(acx);
  950. return ret;
  951. }
  952. int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address)
  953. {
  954. struct wl1271_acx_arp_filter *acx;
  955. int ret;
  956. wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
  957. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  958. if (!acx) {
  959. ret = -ENOMEM;
  960. goto out;
  961. }
  962. acx->version = ACX_IPV4_VERSION;
  963. acx->enable = enable;
  964. if (enable)
  965. memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
  966. ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
  967. acx, sizeof(*acx));
  968. if (ret < 0) {
  969. wl1271_warning("failed to set arp ip filter: %d", ret);
  970. goto out;
  971. }
  972. out:
  973. kfree(acx);
  974. return ret;
  975. }
  976. int wl1271_acx_pm_config(struct wl1271 *wl)
  977. {
  978. struct wl1271_acx_pm_config *acx = NULL;
  979. struct conf_pm_config_settings *c = &wl->conf.pm_config;
  980. int ret = 0;
  981. wl1271_debug(DEBUG_ACX, "acx pm config");
  982. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  983. if (!acx) {
  984. ret = -ENOMEM;
  985. goto out;
  986. }
  987. acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
  988. acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
  989. ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
  990. if (ret < 0) {
  991. wl1271_warning("acx pm config failed: %d", ret);
  992. goto out;
  993. }
  994. out:
  995. kfree(acx);
  996. return ret;
  997. }
  998. int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
  999. {
  1000. struct wl1271_acx_keep_alive_mode *acx = NULL;
  1001. int ret = 0;
  1002. wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
  1003. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1004. if (!acx) {
  1005. ret = -ENOMEM;
  1006. goto out;
  1007. }
  1008. acx->enabled = enable;
  1009. ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
  1010. if (ret < 0) {
  1011. wl1271_warning("acx keep alive mode failed: %d", ret);
  1012. goto out;
  1013. }
  1014. out:
  1015. kfree(acx);
  1016. return ret;
  1017. }
  1018. int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
  1019. {
  1020. struct wl1271_acx_keep_alive_config *acx = NULL;
  1021. int ret = 0;
  1022. wl1271_debug(DEBUG_ACX, "acx keep alive config");
  1023. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1024. if (!acx) {
  1025. ret = -ENOMEM;
  1026. goto out;
  1027. }
  1028. acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
  1029. acx->index = index;
  1030. acx->tpl_validation = tpl_valid;
  1031. acx->trigger = ACX_KEEP_ALIVE_NO_TX;
  1032. ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
  1033. acx, sizeof(*acx));
  1034. if (ret < 0) {
  1035. wl1271_warning("acx keep alive config failed: %d", ret);
  1036. goto out;
  1037. }
  1038. out:
  1039. kfree(acx);
  1040. return ret;
  1041. }
  1042. int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable,
  1043. s16 thold, u8 hyst)
  1044. {
  1045. struct wl1271_acx_rssi_snr_trigger *acx = NULL;
  1046. int ret = 0;
  1047. wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
  1048. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1049. if (!acx) {
  1050. ret = -ENOMEM;
  1051. goto out;
  1052. }
  1053. wl->last_rssi_event = -1;
  1054. acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
  1055. acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
  1056. acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
  1057. if (enable)
  1058. acx->enable = WL1271_ACX_TRIG_ENABLE;
  1059. else
  1060. acx->enable = WL1271_ACX_TRIG_DISABLE;
  1061. acx->index = WL1271_ACX_TRIG_IDX_RSSI;
  1062. acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
  1063. acx->threshold = cpu_to_le16(thold);
  1064. acx->hysteresis = hyst;
  1065. ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
  1066. if (ret < 0) {
  1067. wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
  1068. goto out;
  1069. }
  1070. out:
  1071. kfree(acx);
  1072. return ret;
  1073. }
  1074. int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl)
  1075. {
  1076. struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
  1077. struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
  1078. int ret = 0;
  1079. wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
  1080. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1081. if (!acx) {
  1082. ret = -ENOMEM;
  1083. goto out;
  1084. }
  1085. acx->rssi_beacon = c->avg_weight_rssi_beacon;
  1086. acx->rssi_data = c->avg_weight_rssi_data;
  1087. acx->snr_beacon = c->avg_weight_snr_beacon;
  1088. acx->snr_data = c->avg_weight_snr_data;
  1089. ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
  1090. if (ret < 0) {
  1091. wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
  1092. goto out;
  1093. }
  1094. out:
  1095. kfree(acx);
  1096. return ret;
  1097. }
  1098. int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
  1099. struct ieee80211_sta_ht_cap *ht_cap,
  1100. bool allow_ht_operation)
  1101. {
  1102. struct wl1271_acx_ht_capabilities *acx;
  1103. u8 mac_address[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  1104. int ret = 0;
  1105. u32 ht_capabilites = 0;
  1106. wl1271_debug(DEBUG_ACX, "acx ht capabilities setting");
  1107. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1108. if (!acx) {
  1109. ret = -ENOMEM;
  1110. goto out;
  1111. }
  1112. /* Allow HT Operation ? */
  1113. if (allow_ht_operation) {
  1114. ht_capabilites =
  1115. WL1271_ACX_FW_CAP_HT_OPERATION;
  1116. if (ht_cap->cap & IEEE80211_HT_CAP_GRN_FLD)
  1117. ht_capabilites |=
  1118. WL1271_ACX_FW_CAP_GREENFIELD_FRAME_FORMAT;
  1119. if (ht_cap->cap & IEEE80211_HT_CAP_SGI_20)
  1120. ht_capabilites |=
  1121. WL1271_ACX_FW_CAP_SHORT_GI_FOR_20MHZ_PACKETS;
  1122. if (ht_cap->cap & IEEE80211_HT_CAP_LSIG_TXOP_PROT)
  1123. ht_capabilites |=
  1124. WL1271_ACX_FW_CAP_LSIG_TXOP_PROTECTION;
  1125. /* get data from A-MPDU parameters field */
  1126. acx->ampdu_max_length = ht_cap->ampdu_factor;
  1127. acx->ampdu_min_spacing = ht_cap->ampdu_density;
  1128. }
  1129. memcpy(acx->mac_address, mac_address, ETH_ALEN);
  1130. acx->ht_capabilites = cpu_to_le32(ht_capabilites);
  1131. ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
  1132. if (ret < 0) {
  1133. wl1271_warning("acx ht capabilities setting failed: %d", ret);
  1134. goto out;
  1135. }
  1136. out:
  1137. kfree(acx);
  1138. return ret;
  1139. }
  1140. int wl1271_acx_set_ht_information(struct wl1271 *wl,
  1141. u16 ht_operation_mode)
  1142. {
  1143. struct wl1271_acx_ht_information *acx;
  1144. int ret = 0;
  1145. wl1271_debug(DEBUG_ACX, "acx ht information setting");
  1146. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1147. if (!acx) {
  1148. ret = -ENOMEM;
  1149. goto out;
  1150. }
  1151. acx->ht_protection =
  1152. (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
  1153. acx->rifs_mode = 0;
  1154. acx->gf_protection =
  1155. !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  1156. acx->ht_tx_burst_limit = 0;
  1157. acx->dual_cts_protection = 0;
  1158. ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
  1159. if (ret < 0) {
  1160. wl1271_warning("acx ht information setting failed: %d", ret);
  1161. goto out;
  1162. }
  1163. out:
  1164. kfree(acx);
  1165. return ret;
  1166. }
  1167. /* Configure BA session initiator/receiver parameters setting in the FW. */
  1168. int wl1271_acx_set_ba_session(struct wl1271 *wl,
  1169. enum ieee80211_back_parties direction,
  1170. u8 tid_index, u8 policy)
  1171. {
  1172. struct wl1271_acx_ba_session_policy *acx;
  1173. int ret;
  1174. wl1271_debug(DEBUG_ACX, "acx ba session setting");
  1175. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1176. if (!acx) {
  1177. ret = -ENOMEM;
  1178. goto out;
  1179. }
  1180. /* ANY role */
  1181. acx->role_id = 0xff;
  1182. acx->tid = tid_index;
  1183. acx->enable = policy;
  1184. acx->ba_direction = direction;
  1185. switch (direction) {
  1186. case WLAN_BACK_INITIATOR:
  1187. acx->win_size = wl->conf.ht.tx_ba_win_size;
  1188. acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
  1189. break;
  1190. case WLAN_BACK_RECIPIENT:
  1191. acx->win_size = RX_BA_WIN_SIZE;
  1192. acx->inactivity_timeout = 0;
  1193. break;
  1194. default:
  1195. wl1271_error("Incorrect acx command id=%x\n", direction);
  1196. ret = -EINVAL;
  1197. goto out;
  1198. }
  1199. ret = wl1271_cmd_configure(wl,
  1200. ACX_BA_SESSION_POLICY_CFG,
  1201. acx,
  1202. sizeof(*acx));
  1203. if (ret < 0) {
  1204. wl1271_warning("acx ba session setting failed: %d", ret);
  1205. goto out;
  1206. }
  1207. out:
  1208. kfree(acx);
  1209. return ret;
  1210. }
  1211. /* setup BA session receiver setting in the FW. */
  1212. int wl1271_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn,
  1213. bool enable)
  1214. {
  1215. struct wl1271_acx_ba_receiver_setup *acx;
  1216. int ret;
  1217. wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
  1218. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1219. if (!acx) {
  1220. ret = -ENOMEM;
  1221. goto out;
  1222. }
  1223. /* Single link for now */
  1224. acx->link_id = 1;
  1225. acx->tid = tid_index;
  1226. acx->enable = enable;
  1227. acx->win_size = 0;
  1228. acx->ssn = ssn;
  1229. ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
  1230. sizeof(*acx));
  1231. if (ret < 0) {
  1232. wl1271_warning("acx ba receiver session failed: %d", ret);
  1233. goto out;
  1234. }
  1235. out:
  1236. kfree(acx);
  1237. return ret;
  1238. }
  1239. int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
  1240. {
  1241. struct wl1271_acx_fw_tsf_information *tsf_info;
  1242. int ret;
  1243. tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
  1244. if (!tsf_info) {
  1245. ret = -ENOMEM;
  1246. goto out;
  1247. }
  1248. ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
  1249. tsf_info, sizeof(*tsf_info));
  1250. if (ret < 0) {
  1251. wl1271_warning("acx tsf info interrogate failed");
  1252. goto out;
  1253. }
  1254. *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
  1255. ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
  1256. out:
  1257. kfree(tsf_info);
  1258. return ret;
  1259. }
  1260. int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl)
  1261. {
  1262. struct wl1271_acx_ap_max_tx_retry *acx = NULL;
  1263. int ret;
  1264. wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
  1265. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1266. if (!acx)
  1267. return -ENOMEM;
  1268. acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
  1269. ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
  1270. if (ret < 0) {
  1271. wl1271_warning("acx ap max tx retry failed: %d", ret);
  1272. goto out;
  1273. }
  1274. out:
  1275. kfree(acx);
  1276. return ret;
  1277. }
  1278. int wl1271_acx_sta_max_tx_retry(struct wl1271 *wl)
  1279. {
  1280. struct wl1271_acx_sta_max_tx_retry *acx = NULL;
  1281. int ret;
  1282. wl1271_debug(DEBUG_ACX, "acx sta max tx retry");
  1283. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1284. if (!acx)
  1285. return -ENOMEM;
  1286. acx->max_tx_retry = wl->conf.tx.max_tx_retries;
  1287. ret = wl1271_cmd_configure(wl, ACX_CONS_TX_FAILURE, acx, sizeof(*acx));
  1288. if (ret < 0) {
  1289. wl1271_warning("acx sta max tx retry failed: %d", ret);
  1290. goto out;
  1291. }
  1292. out:
  1293. kfree(acx);
  1294. return ret;
  1295. }
  1296. int wl1271_acx_config_ps(struct wl1271 *wl)
  1297. {
  1298. struct wl1271_acx_config_ps *config_ps;
  1299. int ret;
  1300. wl1271_debug(DEBUG_ACX, "acx config ps");
  1301. config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
  1302. if (!config_ps) {
  1303. ret = -ENOMEM;
  1304. goto out;
  1305. }
  1306. config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
  1307. config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
  1308. config_ps->null_data_rate = cpu_to_le32(wl->basic_rate);
  1309. ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
  1310. sizeof(*config_ps));
  1311. if (ret < 0) {
  1312. wl1271_warning("acx config ps failed: %d", ret);
  1313. goto out;
  1314. }
  1315. out:
  1316. kfree(config_ps);
  1317. return ret;
  1318. }
  1319. int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
  1320. {
  1321. struct wl1271_acx_inconnection_sta *acx = NULL;
  1322. int ret;
  1323. wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
  1324. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1325. if (!acx)
  1326. return -ENOMEM;
  1327. memcpy(acx->addr, addr, ETH_ALEN);
  1328. ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
  1329. acx, sizeof(*acx));
  1330. if (ret < 0) {
  1331. wl1271_warning("acx set inconnaction sta failed: %d", ret);
  1332. goto out;
  1333. }
  1334. out:
  1335. kfree(acx);
  1336. return ret;
  1337. }
  1338. int wl1271_acx_set_ap_beacon_filter(struct wl1271 *wl, bool enable)
  1339. {
  1340. struct acx_ap_beacon_filter *acx = NULL;
  1341. int ret;
  1342. wl1271_debug(DEBUG_ACX, "acx set ap beacon filter: %d", enable);
  1343. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1344. if (!acx)
  1345. return -ENOMEM;
  1346. acx->enable = enable ? 1 : 0;
  1347. ret = wl1271_cmd_configure(wl, ACX_AP_BEACON_FILTER_OPT,
  1348. acx, sizeof(*acx));
  1349. if (ret < 0) {
  1350. wl1271_warning("acx set ap beacon filter failed: %d", ret);
  1351. goto out;
  1352. }
  1353. out:
  1354. kfree(acx);
  1355. return ret;
  1356. }
  1357. int wl1271_acx_fm_coex(struct wl1271 *wl)
  1358. {
  1359. struct wl1271_acx_fm_coex *acx;
  1360. int ret;
  1361. wl1271_debug(DEBUG_ACX, "acx fm coex setting");
  1362. acx = kzalloc(sizeof(*acx), GFP_KERNEL);
  1363. if (!acx) {
  1364. ret = -ENOMEM;
  1365. goto out;
  1366. }
  1367. acx->enable = wl->conf.fm_coex.enable;
  1368. acx->swallow_period = wl->conf.fm_coex.swallow_period;
  1369. acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
  1370. acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
  1371. acx->m_divider_fref_set_1 =
  1372. cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
  1373. acx->m_divider_fref_set_2 =
  1374. cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
  1375. acx->coex_pll_stabilization_time =
  1376. cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
  1377. acx->ldo_stabilization_time =
  1378. cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
  1379. acx->fm_disturbed_band_margin =
  1380. wl->conf.fm_coex.fm_disturbed_band_margin;
  1381. acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
  1382. ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
  1383. if (ret < 0) {
  1384. wl1271_warning("acx fm coex setting failed: %d", ret);
  1385. goto out;
  1386. }
  1387. out:
  1388. kfree(acx);
  1389. return ret;
  1390. }