acx.c 40 KB

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