acx.c 41 KB

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