acx.c 41 KB

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