acx.c 39 KB

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