blob: a784ba6a8ef61f9a9e538ae47d76e804f690eba8 [file] [log] [blame]
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001/*
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
Shahar Levi00d20102010-11-08 11:20:10 +000024#include "acx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030025
26#include <linux/module.h>
27#include <linux/platform_device.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030028#include <linux/spi/spi.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030030
Shahar Levi00d20102010-11-08 11:20:10 +000031#include "wl12xx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030032#include "wl12xx_80211.h"
Shahar Levi00d20102010-11-08 11:20:10 +000033#include "reg.h"
34#include "ps.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030035
Juuso Oikarinen51f2be22009-10-13 12:47:42 +030036int wl1271_acx_wake_up_conditions(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030037{
38 struct acx_wake_up_condition *wake_up;
39 int ret;
40
41 wl1271_debug(DEBUG_ACX, "acx wake up conditions");
42
43 wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
44 if (!wake_up) {
45 ret = -ENOMEM;
46 goto out;
47 }
48
Eliad Peller7f0979882011-08-14 13:17:06 +030049 wake_up->role_id = wl->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +030050 wake_up->wake_up_event = wl->conf.conn.wake_up_event;
51 wake_up->listen_interval = wl->conf.conn.listen_interval;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030052
53 ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
54 wake_up, sizeof(*wake_up));
55 if (ret < 0) {
56 wl1271_warning("could not set wake up conditions: %d", ret);
57 goto out;
58 }
59
60out:
61 kfree(wake_up);
62 return ret;
63}
64
65int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
66{
67 struct acx_sleep_auth *auth;
68 int ret;
69
70 wl1271_debug(DEBUG_ACX, "acx sleep auth");
71
72 auth = kzalloc(sizeof(*auth), GFP_KERNEL);
73 if (!auth) {
74 ret = -ENOMEM;
75 goto out;
76 }
77
78 auth->sleep_auth = sleep_auth;
79
80 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
81 if (ret < 0)
82 return ret;
83
84out:
85 kfree(auth);
86 return ret;
87}
88
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030089int wl1271_acx_tx_power(struct wl1271 *wl, int power)
90{
91 struct acx_current_tx_power *acx;
92 int ret;
93
Arik Nemtsov097f8822011-06-27 22:06:34 +030094 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030095
96 if (power < 0 || power > 25)
97 return -EINVAL;
98
99 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
100 if (!acx) {
101 ret = -ENOMEM;
102 goto out;
103 }
104
Eliad Peller7f0979882011-08-14 13:17:06 +0300105 acx->role_id = wl->role_id;
Juuso Oikarinen6f6b5d42010-02-22 08:38:42 +0200106 acx->current_tx_power = power * 10;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300107
108 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
109 if (ret < 0) {
110 wl1271_warning("configure of tx power failed: %d", ret);
111 goto out;
112 }
113
114out:
115 kfree(acx);
116 return ret;
117}
118
119int wl1271_acx_feature_cfg(struct wl1271 *wl)
120{
121 struct acx_feature_config *feature;
122 int ret;
123
124 wl1271_debug(DEBUG_ACX, "acx feature cfg");
125
126 feature = kzalloc(sizeof(*feature), GFP_KERNEL);
127 if (!feature) {
128 ret = -ENOMEM;
129 goto out;
130 }
131
132 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
Eliad Peller7f0979882011-08-14 13:17:06 +0300133 feature->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300134 feature->data_flow_options = 0;
135 feature->options = 0;
136
137 ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
138 feature, sizeof(*feature));
139 if (ret < 0) {
140 wl1271_error("Couldnt set HW encryption");
141 goto out;
142 }
143
144out:
145 kfree(feature);
146 return ret;
147}
148
149int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
150 size_t len)
151{
152 int ret;
153
154 wl1271_debug(DEBUG_ACX, "acx mem map");
155
156 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
157 if (ret < 0)
158 return ret;
159
160 return 0;
161}
162
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +0300163int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300164{
165 struct acx_rx_msdu_lifetime *acx;
166 int ret;
167
168 wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
169
170 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
171 if (!acx) {
172 ret = -ENOMEM;
173 goto out;
174 }
175
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300176 acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300177 ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
178 acx, sizeof(*acx));
179 if (ret < 0) {
180 wl1271_warning("failed to set rx msdu life time: %d", ret);
181 goto out;
182 }
183
184out:
185 kfree(acx);
186 return ret;
187}
188
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300189int wl1271_acx_pd_threshold(struct wl1271 *wl)
190{
191 struct acx_packet_detection *pd;
192 int ret;
193
194 wl1271_debug(DEBUG_ACX, "acx data pd threshold");
195
196 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
197 if (!pd) {
198 ret = -ENOMEM;
199 goto out;
200 }
201
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300202 pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300203
204 ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
205 if (ret < 0) {
206 wl1271_warning("failed to set pd threshold: %d", ret);
207 goto out;
208 }
209
210out:
211 kfree(pd);
Julia Lawall36d34412010-08-16 18:27:30 +0200212 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300213}
214
215int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time)
216{
217 struct acx_slot *slot;
218 int ret;
219
220 wl1271_debug(DEBUG_ACX, "acx slot");
221
222 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
223 if (!slot) {
224 ret = -ENOMEM;
225 goto out;
226 }
227
Eliad Peller7f0979882011-08-14 13:17:06 +0300228 slot->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300229 slot->wone_index = STATION_WONE_INDEX;
230 slot->slot_time = slot_time;
231
232 ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
233 if (ret < 0) {
234 wl1271_warning("failed to set slot time: %d", ret);
235 goto out;
236 }
237
238out:
239 kfree(slot);
240 return ret;
241}
242
Juuso Oikarinenc87dec92009-10-08 21:56:31 +0300243int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable,
244 void *mc_list, u32 mc_list_len)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300245{
246 struct acx_dot11_grp_addr_tbl *acx;
247 int ret;
248
249 wl1271_debug(DEBUG_ACX, "acx group address tbl");
250
251 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
252 if (!acx) {
253 ret = -ENOMEM;
254 goto out;
255 }
256
257 /* MAC filtering */
Eliad Peller7f0979882011-08-14 13:17:06 +0300258 acx->role_id = wl->role_id;
Juuso Oikarinenc87dec92009-10-08 21:56:31 +0300259 acx->enabled = enable;
260 acx->num_groups = mc_list_len;
261 memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300262
263 ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
264 acx, sizeof(*acx));
265 if (ret < 0) {
266 wl1271_warning("failed to set group addr table: %d", ret);
267 goto out;
268 }
269
270out:
271 kfree(acx);
272 return ret;
273}
274
275int wl1271_acx_service_period_timeout(struct wl1271 *wl)
276{
277 struct acx_rx_timeout *rx_timeout;
278 int ret;
279
280 rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
281 if (!rx_timeout) {
282 ret = -ENOMEM;
283 goto out;
284 }
285
286 wl1271_debug(DEBUG_ACX, "acx service period timeout");
287
Eliad Peller7f0979882011-08-14 13:17:06 +0300288 rx_timeout->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300289 rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
290 rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300291
292 ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
293 rx_timeout, sizeof(*rx_timeout));
294 if (ret < 0) {
295 wl1271_warning("failed to set service period timeout: %d",
296 ret);
297 goto out;
298 }
299
300out:
301 kfree(rx_timeout);
302 return ret;
303}
304
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300305int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300306{
307 struct acx_rts_threshold *rts;
308 int ret;
309
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300310 /*
311 * If the RTS threshold is not configured or out of range, use the
312 * default value.
313 */
314 if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
315 rts_threshold = wl->conf.rx.rts_threshold;
316
317 wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300318
319 rts = kzalloc(sizeof(*rts), GFP_KERNEL);
320 if (!rts) {
321 ret = -ENOMEM;
322 goto out;
323 }
324
Eliad Peller7f0979882011-08-14 13:17:06 +0300325 rts->role_id = wl->role_id;
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300326 rts->threshold = cpu_to_le16((u16)rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300327
328 ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
329 if (ret < 0) {
330 wl1271_warning("failed to set rts threshold: %d", ret);
331 goto out;
332 }
333
334out:
335 kfree(rts);
336 return ret;
337}
338
Luciano Coelho6e92b412009-12-11 15:40:50 +0200339int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
340{
341 struct acx_dco_itrim_params *dco;
342 struct conf_itrim_settings *c = &wl->conf.itrim;
343 int ret;
344
345 wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
346
347 dco = kzalloc(sizeof(*dco), GFP_KERNEL);
348 if (!dco) {
349 ret = -ENOMEM;
350 goto out;
351 }
352
353 dco->enable = c->enable;
354 dco->timeout = cpu_to_le32(c->timeout);
355
356 ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
357 dco, sizeof(*dco));
358 if (ret < 0) {
359 wl1271_warning("failed to set dco itrim parameters: %d", ret);
360 goto out;
361 }
362
363out:
364 kfree(dco);
365 return ret;
366}
367
Juuso Oikarinen19221672009-10-08 21:56:35 +0300368int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300369{
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300370 struct acx_beacon_filter_option *beacon_filter = NULL;
371 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300372
373 wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
374
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300375 if (enable_filter &&
376 wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
377 goto out;
378
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300379 beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
380 if (!beacon_filter) {
381 ret = -ENOMEM;
382 goto out;
383 }
384
Eliad Peller7f0979882011-08-14 13:17:06 +0300385 beacon_filter->role_id = wl->role_id;
Juuso Oikarinen19221672009-10-08 21:56:35 +0300386 beacon_filter->enable = enable_filter;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300387
388 /*
389 * When set to zero, and the filter is enabled, beacons
390 * without the unicast TIM bit set are dropped.
391 */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300392 beacon_filter->max_num_beacons = 0;
393
394 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
395 beacon_filter, sizeof(*beacon_filter));
396 if (ret < 0) {
397 wl1271_warning("failed to set beacon filter opt: %d", ret);
398 goto out;
399 }
400
401out:
402 kfree(beacon_filter);
403 return ret;
404}
405
406int wl1271_acx_beacon_filter_table(struct wl1271 *wl)
407{
408 struct acx_beacon_filter_ie_table *ie_table;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300409 int i, idx = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300410 int ret;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300411 bool vendor_spec = false;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300412
413 wl1271_debug(DEBUG_ACX, "acx beacon filter table");
414
415 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
416 if (!ie_table) {
417 ret = -ENOMEM;
418 goto out;
419 }
420
Juuso Oikarinen19221672009-10-08 21:56:35 +0300421 /* configure default beacon pass-through rules */
Eliad Peller7f0979882011-08-14 13:17:06 +0300422 ie_table->role_id = wl->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300423 ie_table->num_ie = 0;
424 for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
425 struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
426 ie_table->table[idx++] = r->ie;
427 ie_table->table[idx++] = r->rule;
428
429 if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
430 /* only one vendor specific ie allowed */
431 if (vendor_spec)
432 continue;
433
434 /* for vendor specific rules configure the
435 additional fields */
436 memcpy(&(ie_table->table[idx]), r->oui,
437 CONF_BCN_IE_OUI_LEN);
438 idx += CONF_BCN_IE_OUI_LEN;
439 ie_table->table[idx++] = r->type;
440 memcpy(&(ie_table->table[idx]), r->version,
441 CONF_BCN_IE_VER_LEN);
442 idx += CONF_BCN_IE_VER_LEN;
443 vendor_spec = true;
444 }
445
446 ie_table->num_ie++;
447 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300448
449 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
450 ie_table, sizeof(*ie_table));
451 if (ret < 0) {
452 wl1271_warning("failed to set beacon filter table: %d", ret);
453 goto out;
454 }
455
456out:
457 kfree(ie_table);
458 return ret;
459}
460
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200461#define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
462
463int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable)
Juuso Oikarinen34415232009-10-08 21:56:33 +0300464{
465 struct acx_conn_monit_params *acx;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200466 u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
467 u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
Juuso Oikarinen34415232009-10-08 21:56:33 +0300468 int ret;
469
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200470 wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
471 enable ? "enabled" : "disabled");
Juuso Oikarinen34415232009-10-08 21:56:33 +0300472
473 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
474 if (!acx) {
475 ret = -ENOMEM;
476 goto out;
477 }
478
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200479 if (enable) {
480 threshold = wl->conf.conn.synch_fail_thold;
481 timeout = wl->conf.conn.bss_lose_timeout;
482 }
483
Eliad Peller7f0979882011-08-14 13:17:06 +0300484 acx->role_id = wl->role_id;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200485 acx->synch_fail_thold = cpu_to_le32(threshold);
486 acx->bss_lose_timeout = cpu_to_le32(timeout);
Juuso Oikarinen34415232009-10-08 21:56:33 +0300487
488 ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
489 acx, sizeof(*acx));
490 if (ret < 0) {
491 wl1271_warning("failed to set connection monitor "
492 "parameters: %d", ret);
493 goto out;
494 }
495
496out:
497 kfree(acx);
498 return ret;
499}
500
501
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200502int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300503{
504 struct acx_bt_wlan_coex *pta;
505 int ret;
506
507 wl1271_debug(DEBUG_ACX, "acx sg enable");
508
509 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
510 if (!pta) {
511 ret = -ENOMEM;
512 goto out;
513 }
514
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200515 if (enable)
516 pta->enable = wl->conf.sg.state;
517 else
518 pta->enable = CONF_SG_DISABLE;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300519
520 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
521 if (ret < 0) {
522 wl1271_warning("failed to set softgemini enable: %d", ret);
523 goto out;
524 }
525
526out:
527 kfree(pta);
528 return ret;
529}
530
Arik Nemtsov801f8702011-04-18 14:15:20 +0300531int wl1271_acx_sta_sg_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300532{
Arik Nemtsov801f8702011-04-18 14:15:20 +0300533 struct acx_sta_bt_wlan_coex_param *param;
Juuso Oikarinen2b60100b2009-10-13 12:47:39 +0300534 struct conf_sg_settings *c = &wl->conf.sg;
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200535 int i, ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300536
Arik Nemtsov801f8702011-04-18 14:15:20 +0300537 wl1271_debug(DEBUG_ACX, "acx sg sta cfg");
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300538
539 param = kzalloc(sizeof(*param), GFP_KERNEL);
540 if (!param) {
541 ret = -ENOMEM;
542 goto out;
543 }
544
545 /* BT-WLAN coext parameters */
Arik Nemtsov801f8702011-04-18 14:15:20 +0300546 for (i = 0; i < CONF_SG_STA_PARAMS_MAX; i++)
547 param->params[i] = cpu_to_le32(c->sta_params[i]);
548 param->param_idx = CONF_SG_PARAMS_ALL;
549
550 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
551 if (ret < 0) {
552 wl1271_warning("failed to set sg config: %d", ret);
553 goto out;
554 }
555
556out:
557 kfree(param);
558 return ret;
559}
560
561int wl1271_acx_ap_sg_cfg(struct wl1271 *wl)
562{
563 struct acx_ap_bt_wlan_coex_param *param;
564 struct conf_sg_settings *c = &wl->conf.sg;
565 int i, ret;
566
567 wl1271_debug(DEBUG_ACX, "acx sg ap cfg");
568
569 param = kzalloc(sizeof(*param), GFP_KERNEL);
570 if (!param) {
571 ret = -ENOMEM;
572 goto out;
573 }
574
575 /* BT-WLAN coext parameters */
576 for (i = 0; i < CONF_SG_AP_PARAMS_MAX; i++)
577 param->params[i] = cpu_to_le32(c->ap_params[i]);
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200578 param->param_idx = CONF_SG_PARAMS_ALL;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300579
580 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
581 if (ret < 0) {
582 wl1271_warning("failed to set sg config: %d", ret);
583 goto out;
584 }
585
586out:
587 kfree(param);
588 return ret;
589}
590
591int wl1271_acx_cca_threshold(struct wl1271 *wl)
592{
593 struct acx_energy_detection *detection;
594 int ret;
595
596 wl1271_debug(DEBUG_ACX, "acx cca threshold");
597
598 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
599 if (!detection) {
600 ret = -ENOMEM;
601 goto out;
602 }
603
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300604 detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
Juuso Oikarinen45b531a2009-10-13 12:47:41 +0300605 detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300606
607 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
608 detection, sizeof(*detection));
609 if (ret < 0) {
610 wl1271_warning("failed to set cca threshold: %d", ret);
611 return ret;
612 }
613
614out:
615 kfree(detection);
616 return ret;
617}
618
619int wl1271_acx_bcn_dtim_options(struct wl1271 *wl)
620{
621 struct acx_beacon_broadcast *bb;
622 int ret;
623
624 wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
625
626 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
627 if (!bb) {
628 ret = -ENOMEM;
629 goto out;
630 }
631
Eliad Peller7f0979882011-08-14 13:17:06 +0300632 bb->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300633 bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
634 bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300635 bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
636 bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300637
638 ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
639 if (ret < 0) {
640 wl1271_warning("failed to set rx config: %d", ret);
641 goto out;
642 }
643
644out:
645 kfree(bb);
646 return ret;
647}
648
649int wl1271_acx_aid(struct wl1271 *wl, u16 aid)
650{
651 struct acx_aid *acx_aid;
652 int ret;
653
654 wl1271_debug(DEBUG_ACX, "acx aid");
655
656 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
657 if (!acx_aid) {
658 ret = -ENOMEM;
659 goto out;
660 }
661
Eliad Peller7f0979882011-08-14 13:17:06 +0300662 acx_aid->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300663 acx_aid->aid = cpu_to_le16(aid);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300664
665 ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
666 if (ret < 0) {
667 wl1271_warning("failed to set aid: %d", ret);
668 goto out;
669 }
670
671out:
672 kfree(acx_aid);
673 return ret;
674}
675
676int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
677{
678 struct acx_event_mask *mask;
679 int ret;
680
681 wl1271_debug(DEBUG_ACX, "acx event mbox mask");
682
683 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
684 if (!mask) {
685 ret = -ENOMEM;
686 goto out;
687 }
688
689 /* high event mask is unused */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300690 mask->high_event_mask = cpu_to_le32(0xffffffff);
691 mask->event_mask = cpu_to_le32(event_mask);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300692
693 ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
694 mask, sizeof(*mask));
695 if (ret < 0) {
696 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
697 goto out;
698 }
699
700out:
701 kfree(mask);
702 return ret;
703}
704
705int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble)
706{
707 struct acx_preamble *acx;
708 int ret;
709
710 wl1271_debug(DEBUG_ACX, "acx_set_preamble");
711
712 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
713 if (!acx) {
714 ret = -ENOMEM;
715 goto out;
716 }
717
Eliad Peller7f0979882011-08-14 13:17:06 +0300718 acx->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300719 acx->preamble = preamble;
720
721 ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
722 if (ret < 0) {
723 wl1271_warning("Setting of preamble failed: %d", ret);
724 goto out;
725 }
726
727out:
728 kfree(acx);
729 return ret;
730}
731
732int wl1271_acx_cts_protect(struct wl1271 *wl,
733 enum acx_ctsprotect_type ctsprotect)
734{
735 struct acx_ctsprotect *acx;
736 int ret;
737
738 wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
739
740 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
741 if (!acx) {
742 ret = -ENOMEM;
743 goto out;
744 }
745
Eliad Peller7f0979882011-08-14 13:17:06 +0300746 acx->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300747 acx->ctsprotect = ctsprotect;
748
749 ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
750 if (ret < 0) {
751 wl1271_warning("Setting of ctsprotect failed: %d", ret);
752 goto out;
753 }
754
755out:
756 kfree(acx);
757 return ret;
758}
759
760int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
761{
762 int ret;
763
764 wl1271_debug(DEBUG_ACX, "acx statistics");
765
766 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
767 sizeof(*stats));
768 if (ret < 0) {
769 wl1271_warning("acx statistics failed: %d", ret);
770 return -ENOMEM;
771 }
772
773 return 0;
774}
775
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200776int wl1271_acx_sta_rate_policies(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300777{
Eliad Peller7f0979882011-08-14 13:17:06 +0300778 struct acx_rate_policy *acx;
Arik Nemtsov1e05a812010-10-16 17:44:51 +0200779 struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300780 int ret = 0;
781
782 wl1271_debug(DEBUG_ACX, "acx rate policies");
783
784 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
785
786 if (!acx) {
787 ret = -ENOMEM;
788 goto out;
789 }
790
Eliad Peller7f0979882011-08-14 13:17:06 +0300791 wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
792 wl->basic_rate, wl->rate_set);
793
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200794 /* configure one basic rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300795 acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE);
796 acx->rate_policy.enabled_rates = cpu_to_le32(wl->basic_rate);
797 acx->rate_policy.short_retry_limit = c->short_retry_limit;
798 acx->rate_policy.long_retry_limit = c->long_retry_limit;
799 acx->rate_policy.aflags = c->aflags;
800
801 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
802 if (ret < 0) {
803 wl1271_warning("Setting of rate policies failed: %d", ret);
804 goto out;
805 }
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200806
807 /* configure one AP supported rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300808 acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE);
809 acx->rate_policy.enabled_rates = cpu_to_le32(wl->rate_set);
810 acx->rate_policy.short_retry_limit = c->short_retry_limit;
811 acx->rate_policy.long_retry_limit = c->long_retry_limit;
812 acx->rate_policy.aflags = c->aflags;
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200813
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300814
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200815
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300816 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
817 if (ret < 0) {
818 wl1271_warning("Setting of rate policies failed: %d", ret);
819 goto out;
820 }
821
822out:
823 kfree(acx);
824 return ret;
825}
826
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200827int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
828 u8 idx)
829{
Eliad Peller7f0979882011-08-14 13:17:06 +0300830 struct acx_rate_policy *acx;
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200831 int ret = 0;
832
Arik Nemtsov70f47422011-04-18 14:15:25 +0300833 wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
834 idx, c->enabled_rates);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200835
836 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
837 if (!acx) {
838 ret = -ENOMEM;
839 goto out;
840 }
841
842 acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
843 acx->rate_policy.short_retry_limit = c->short_retry_limit;
844 acx->rate_policy.long_retry_limit = c->long_retry_limit;
845 acx->rate_policy.aflags = c->aflags;
846
Eliad Peller1d4801f2011-01-16 10:07:10 +0100847 acx->rate_policy_idx = cpu_to_le32(idx);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200848
849 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
850 if (ret < 0) {
851 wl1271_warning("Setting of ap rate policy failed: %d", ret);
852 goto out;
853 }
854
855out:
856 kfree(acx);
857 return ret;
858}
859
Kalle Valo243eeb52010-02-18 13:25:39 +0200860int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
861 u8 aifsn, u16 txop)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300862{
863 struct acx_ac_cfg *acx;
Kalle Valo243eeb52010-02-18 13:25:39 +0200864 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300865
Kalle Valo243eeb52010-02-18 13:25:39 +0200866 wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
867 "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300868
869 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
870
871 if (!acx) {
872 ret = -ENOMEM;
873 goto out;
874 }
875
Eliad Peller7f0979882011-08-14 13:17:06 +0300876 acx->role_id = wl->role_id;
Kalle Valo243eeb52010-02-18 13:25:39 +0200877 acx->ac = ac;
878 acx->cw_min = cw_min;
879 acx->cw_max = cpu_to_le16(cw_max);
880 acx->aifsn = aifsn;
881 acx->tx_op_limit = cpu_to_le16(txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300882
Kalle Valo243eeb52010-02-18 13:25:39 +0200883 ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
884 if (ret < 0) {
885 wl1271_warning("acx ac cfg failed: %d", ret);
886 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300887 }
888
889out:
890 kfree(acx);
891 return ret;
892}
893
Kalle Valof2054df2010-02-18 13:25:40 +0200894int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
895 u8 tsid, u8 ps_scheme, u8 ack_policy,
896 u32 apsd_conf0, u32 apsd_conf1)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300897{
898 struct acx_tid_config *acx;
Kalle Valof2054df2010-02-18 13:25:40 +0200899 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300900
901 wl1271_debug(DEBUG_ACX, "acx tid config");
902
903 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
904
905 if (!acx) {
906 ret = -ENOMEM;
907 goto out;
908 }
909
Eliad Peller7f0979882011-08-14 13:17:06 +0300910 acx->role_id = wl->role_id;
Kalle Valof2054df2010-02-18 13:25:40 +0200911 acx->queue_id = queue_id;
912 acx->channel_type = channel_type;
913 acx->tsid = tsid;
914 acx->ps_scheme = ps_scheme;
915 acx->ack_policy = ack_policy;
916 acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
917 acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300918
Kalle Valof2054df2010-02-18 13:25:40 +0200919 ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
920 if (ret < 0) {
921 wl1271_warning("Setting of tid config failed: %d", ret);
922 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300923 }
924
925out:
926 kfree(acx);
927 return ret;
928}
929
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300930int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300931{
932 struct acx_frag_threshold *acx;
933 int ret = 0;
934
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300935 /*
936 * If the fragmentation is not configured or out of range, use the
937 * default value.
938 */
939 if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
940 frag_threshold = wl->conf.tx.frag_threshold;
941
942 wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300943
944 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
945
946 if (!acx) {
947 ret = -ENOMEM;
948 goto out;
949 }
950
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300951 acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300952 ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
953 if (ret < 0) {
954 wl1271_warning("Setting of frag threshold failed: %d", ret);
955 goto out;
956 }
957
958out:
959 kfree(acx);
960 return ret;
961}
962
963int wl1271_acx_tx_config_options(struct wl1271 *wl)
964{
965 struct acx_tx_config_options *acx;
966 int ret = 0;
967
968 wl1271_debug(DEBUG_ACX, "acx tx config options");
969
970 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
971
972 if (!acx) {
973 ret = -ENOMEM;
974 goto out;
975 }
976
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300977 acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
978 acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300979 ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
980 if (ret < 0) {
981 wl1271_warning("Setting of tx options failed: %d", ret);
982 goto out;
983 }
984
985out:
986 kfree(acx);
987 return ret;
988}
989
Eliad Peller7f0979882011-08-14 13:17:06 +0300990int wl12xx_acx_mem_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300991{
Eliad Peller7f0979882011-08-14 13:17:06 +0300992 struct wl12xx_acx_config_memory *mem_conf;
Shahar Levi13b107d2011-03-06 16:32:12 +0200993 struct conf_memory_settings *mem;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200994 int ret;
995
996 wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
997
998 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
999 if (!mem_conf) {
1000 ret = -ENOMEM;
1001 goto out;
1002 }
1003
Shahar Levi13b107d2011-03-06 16:32:12 +02001004 if (wl->chip.id == CHIP_ID_1283_PG20)
1005 mem = &wl->conf.mem_wl128x;
1006 else
1007 mem = &wl->conf.mem_wl127x;
1008
Eliad Pellerc8bde242011-02-02 09:59:35 +02001009 /* memory config */
Shahar Levi13b107d2011-03-06 16:32:12 +02001010 mem_conf->num_stations = mem->num_stations;
1011 mem_conf->rx_mem_block_num = mem->rx_block_num;
1012 mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
1013 mem_conf->num_ssid_profiles = mem->ssid_profiles;
Eliad Pellerc8bde242011-02-02 09:59:35 +02001014 mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
Shahar Levi13b107d2011-03-06 16:32:12 +02001015 mem_conf->dyn_mem_enable = mem->dynamic_memory;
1016 mem_conf->tx_free_req = mem->min_req_tx_blocks;
1017 mem_conf->rx_free_req = mem->min_req_rx_blocks;
1018 mem_conf->tx_min = mem->tx_min;
Ido Yariv95dac04f2011-06-06 14:57:06 +03001019 mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks;
Eliad Pellerc8bde242011-02-02 09:59:35 +02001020
1021 ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
1022 sizeof(*mem_conf));
1023 if (ret < 0) {
1024 wl1271_warning("wl1271 mem config failed: %d", ret);
1025 goto out;
1026 }
1027
1028out:
1029 kfree(mem_conf);
1030 return ret;
1031}
1032
Shahar Levi48a61472011-03-06 16:32:08 +02001033int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
1034{
1035 struct wl1271_acx_host_config_bitmap *bitmap_conf;
1036 int ret;
1037
1038 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
1039 if (!bitmap_conf) {
1040 ret = -ENOMEM;
1041 goto out;
1042 }
1043
1044 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
1045
1046 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
1047 bitmap_conf, sizeof(*bitmap_conf));
1048 if (ret < 0) {
1049 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
1050 goto out;
1051 }
1052
1053out:
1054 kfree(bitmap_conf);
1055
1056 return ret;
1057}
1058
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001059int wl1271_acx_init_mem_config(struct wl1271 *wl)
1060{
1061 int ret;
1062
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001063 wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
Juuso Oikarinen45b531a2009-10-13 12:47:41 +03001064 GFP_KERNEL);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001065 if (!wl->target_mem_map) {
1066 wl1271_error("couldn't allocate target memory map");
1067 return -ENOMEM;
1068 }
1069
1070 /* we now ask for the firmware built memory map */
1071 ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
1072 sizeof(struct wl1271_acx_mem_map));
1073 if (ret < 0) {
1074 wl1271_error("couldn't retrieve firmware memory map");
1075 kfree(wl->target_mem_map);
1076 wl->target_mem_map = NULL;
1077 return ret;
1078 }
1079
1080 /* initialize TX block book keeping */
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001081 wl->tx_blocks_available =
1082 le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001083 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1084 wl->tx_blocks_available);
1085
1086 return 0;
1087}
1088
1089int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
1090{
1091 struct wl1271_acx_rx_config_opt *rx_conf;
1092 int ret;
1093
1094 wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
1095
1096 rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
1097 if (!rx_conf) {
1098 ret = -ENOMEM;
1099 goto out;
1100 }
1101
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001102 rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
1103 rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
1104 rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +03001105 rx_conf->queue_type = wl->conf.rx.queue_type;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001106
1107 ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
1108 sizeof(*rx_conf));
1109 if (ret < 0) {
1110 wl1271_warning("wl1271 rx config opt failed: %d", ret);
1111 goto out;
1112 }
1113
1114out:
1115 kfree(rx_conf);
1116 return ret;
1117}
Juuso Oikarinen3cfd6cf2009-10-12 15:08:52 +03001118
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001119int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
1120{
1121 struct wl1271_acx_bet_enable *acx = NULL;
1122 int ret = 0;
1123
1124 wl1271_debug(DEBUG_ACX, "acx bet enable");
1125
1126 if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
1127 goto out;
1128
1129 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1130 if (!acx) {
1131 ret = -ENOMEM;
1132 goto out;
1133 }
1134
Eliad Peller7f0979882011-08-14 13:17:06 +03001135 acx->role_id = wl->role_id;
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001136 acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
1137 acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
1138
1139 ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
1140 if (ret < 0) {
1141 wl1271_warning("acx bet enable failed: %d", ret);
1142 goto out;
1143 }
1144
1145out:
1146 kfree(acx);
1147 return ret;
1148}
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001149
Eliad Pellerc5312772010-12-09 11:31:27 +02001150int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address)
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001151{
1152 struct wl1271_acx_arp_filter *acx;
1153 int ret;
1154
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001155 wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001156
1157 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1158 if (!acx) {
1159 ret = -ENOMEM;
1160 goto out;
1161 }
1162
Eliad Peller7f0979882011-08-14 13:17:06 +03001163 acx->role_id = wl->role_id;
Juuso Oikarineneb887df2010-07-08 17:49:58 +03001164 acx->version = ACX_IPV4_VERSION;
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001165 acx->enable = enable;
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001166
Eliad Pellerc5312772010-12-09 11:31:27 +02001167 if (enable)
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001168 memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001169
1170 ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
1171 acx, sizeof(*acx));
1172 if (ret < 0) {
1173 wl1271_warning("failed to set arp ip filter: %d", ret);
1174 goto out;
1175 }
1176
1177out:
1178 kfree(acx);
1179 return ret;
1180}
Juuso Oikarinen38ad2d82009-12-11 15:41:08 +02001181
1182int wl1271_acx_pm_config(struct wl1271 *wl)
1183{
1184 struct wl1271_acx_pm_config *acx = NULL;
1185 struct conf_pm_config_settings *c = &wl->conf.pm_config;
1186 int ret = 0;
1187
1188 wl1271_debug(DEBUG_ACX, "acx pm config");
1189
1190 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1191 if (!acx) {
1192 ret = -ENOMEM;
1193 goto out;
1194 }
1195
1196 acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
1197 acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
1198
1199 ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
1200 if (ret < 0) {
1201 wl1271_warning("acx pm config failed: %d", ret);
1202 goto out;
1203 }
1204
1205out:
1206 kfree(acx);
1207 return ret;
1208}
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001209
1210int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
1211{
1212 struct wl1271_acx_keep_alive_mode *acx = NULL;
1213 int ret = 0;
1214
1215 wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
1216
1217 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1218 if (!acx) {
1219 ret = -ENOMEM;
1220 goto out;
1221 }
1222
Eliad Peller7f0979882011-08-14 13:17:06 +03001223 acx->role_id = wl->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001224 acx->enabled = enable;
1225
1226 ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
1227 if (ret < 0) {
1228 wl1271_warning("acx keep alive mode failed: %d", ret);
1229 goto out;
1230 }
1231
1232out:
1233 kfree(acx);
1234 return ret;
1235}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001236
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001237int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
1238{
1239 struct wl1271_acx_keep_alive_config *acx = NULL;
1240 int ret = 0;
1241
1242 wl1271_debug(DEBUG_ACX, "acx keep alive config");
1243
1244 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1245 if (!acx) {
1246 ret = -ENOMEM;
1247 goto out;
1248 }
1249
Eliad Peller7f0979882011-08-14 13:17:06 +03001250 acx->role_id = wl->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001251 acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
1252 acx->index = index;
1253 acx->tpl_validation = tpl_valid;
1254 acx->trigger = ACX_KEEP_ALIVE_NO_TX;
1255
1256 ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
1257 acx, sizeof(*acx));
1258 if (ret < 0) {
1259 wl1271_warning("acx keep alive config failed: %d", ret);
1260 goto out;
1261 }
1262
1263out:
1264 kfree(acx);
1265 return ret;
1266}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001267
1268int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable,
1269 s16 thold, u8 hyst)
1270{
1271 struct wl1271_acx_rssi_snr_trigger *acx = NULL;
1272 int ret = 0;
1273
1274 wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
1275
1276 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1277 if (!acx) {
1278 ret = -ENOMEM;
1279 goto out;
1280 }
1281
1282 wl->last_rssi_event = -1;
1283
Eliad Peller7f0979882011-08-14 13:17:06 +03001284 acx->role_id = wl->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001285 acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
1286 acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
1287 acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
1288 if (enable)
1289 acx->enable = WL1271_ACX_TRIG_ENABLE;
1290 else
1291 acx->enable = WL1271_ACX_TRIG_DISABLE;
1292
1293 acx->index = WL1271_ACX_TRIG_IDX_RSSI;
1294 acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
1295 acx->threshold = cpu_to_le16(thold);
1296 acx->hysteresis = hyst;
1297
1298 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
1299 if (ret < 0) {
1300 wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
1301 goto out;
1302 }
1303
1304out:
1305 kfree(acx);
1306 return ret;
1307}
1308
1309int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl)
1310{
1311 struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
1312 struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
1313 int ret = 0;
1314
1315 wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
1316
1317 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1318 if (!acx) {
1319 ret = -ENOMEM;
1320 goto out;
1321 }
1322
Eliad Peller7f0979882011-08-14 13:17:06 +03001323 acx->role_id = wl->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001324 acx->rssi_beacon = c->avg_weight_rssi_beacon;
1325 acx->rssi_data = c->avg_weight_rssi_data;
1326 acx->snr_beacon = c->avg_weight_snr_beacon;
1327 acx->snr_data = c->avg_weight_snr_data;
1328
1329 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
1330 if (ret < 0) {
1331 wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
1332 goto out;
1333 }
1334
1335out:
1336 kfree(acx);
1337 return ret;
1338}
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001339
Shahar Levic4db1c82010-10-13 16:09:40 +02001340int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
1341 struct ieee80211_sta_ht_cap *ht_cap,
1342 bool allow_ht_operation)
1343{
1344 struct wl1271_acx_ht_capabilities *acx;
Shahar Levic4db1c82010-10-13 16:09:40 +02001345 int ret = 0;
Eliad Peller6177eae2010-12-22 12:38:52 +01001346 u32 ht_capabilites = 0;
Shahar Levic4db1c82010-10-13 16:09:40 +02001347
1348 wl1271_debug(DEBUG_ACX, "acx ht capabilities setting");
1349
1350 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1351 if (!acx) {
1352 ret = -ENOMEM;
1353 goto out;
1354 }
1355
1356 /* Allow HT Operation ? */
1357 if (allow_ht_operation) {
Eliad Peller6177eae2010-12-22 12:38:52 +01001358 ht_capabilites =
Shahar Levic4db1c82010-10-13 16:09:40 +02001359 WL1271_ACX_FW_CAP_HT_OPERATION;
1360 if (ht_cap->cap & IEEE80211_HT_CAP_GRN_FLD)
Eliad Peller6177eae2010-12-22 12:38:52 +01001361 ht_capabilites |=
Shahar Levic4db1c82010-10-13 16:09:40 +02001362 WL1271_ACX_FW_CAP_GREENFIELD_FRAME_FORMAT;
1363 if (ht_cap->cap & IEEE80211_HT_CAP_SGI_20)
Eliad Peller6177eae2010-12-22 12:38:52 +01001364 ht_capabilites |=
Shahar Levic4db1c82010-10-13 16:09:40 +02001365 WL1271_ACX_FW_CAP_SHORT_GI_FOR_20MHZ_PACKETS;
1366 if (ht_cap->cap & IEEE80211_HT_CAP_LSIG_TXOP_PROT)
Eliad Peller6177eae2010-12-22 12:38:52 +01001367 ht_capabilites |=
Shahar Levic4db1c82010-10-13 16:09:40 +02001368 WL1271_ACX_FW_CAP_LSIG_TXOP_PROTECTION;
1369
1370 /* get data from A-MPDU parameters field */
1371 acx->ampdu_max_length = ht_cap->ampdu_factor;
1372 acx->ampdu_min_spacing = ht_cap->ampdu_density;
Shahar Levic4db1c82010-10-13 16:09:40 +02001373 }
1374
Eliad Peller7f0979882011-08-14 13:17:06 +03001375 acx->hlid = wl->sta_hlid;
Eliad Peller6177eae2010-12-22 12:38:52 +01001376 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
1377
Shahar Levic4db1c82010-10-13 16:09:40 +02001378 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
1379 if (ret < 0) {
1380 wl1271_warning("acx ht capabilities setting failed: %d", ret);
1381 goto out;
1382 }
1383
1384out:
1385 kfree(acx);
1386 return ret;
1387}
1388
1389int wl1271_acx_set_ht_information(struct wl1271 *wl,
1390 u16 ht_operation_mode)
1391{
1392 struct wl1271_acx_ht_information *acx;
1393 int ret = 0;
1394
1395 wl1271_debug(DEBUG_ACX, "acx ht information setting");
1396
1397 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1398 if (!acx) {
1399 ret = -ENOMEM;
1400 goto out;
1401 }
1402
Eliad Peller7f0979882011-08-14 13:17:06 +03001403 acx->role_id = wl->role_id;
Shahar Levic4db1c82010-10-13 16:09:40 +02001404 acx->ht_protection =
1405 (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
1406 acx->rifs_mode = 0;
Helmut Schaa95a77612011-03-02 10:46:46 +01001407 acx->gf_protection =
1408 !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
Shahar Levic4db1c82010-10-13 16:09:40 +02001409 acx->ht_tx_burst_limit = 0;
1410 acx->dual_cts_protection = 0;
1411
1412 ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
1413
1414 if (ret < 0) {
1415 wl1271_warning("acx ht information setting failed: %d", ret);
1416 goto out;
1417 }
1418
1419out:
1420 kfree(acx);
1421 return ret;
1422}
1423
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001424/* Configure BA session initiator/receiver parameters setting in the FW. */
1425int wl1271_acx_set_ba_session(struct wl1271 *wl,
1426 enum ieee80211_back_parties direction,
1427 u8 tid_index, u8 policy)
1428{
1429 struct wl1271_acx_ba_session_policy *acx;
1430 int ret;
1431
1432 wl1271_debug(DEBUG_ACX, "acx ba session setting");
1433
1434 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1435 if (!acx) {
1436 ret = -ENOMEM;
1437 goto out;
1438 }
1439
1440 /* ANY role */
1441 acx->role_id = 0xff;
1442 acx->tid = tid_index;
1443 acx->enable = policy;
1444 acx->ba_direction = direction;
1445
1446 switch (direction) {
1447 case WLAN_BACK_INITIATOR:
1448 acx->win_size = wl->conf.ht.tx_ba_win_size;
1449 acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
1450 break;
1451 case WLAN_BACK_RECIPIENT:
1452 acx->win_size = RX_BA_WIN_SIZE;
1453 acx->inactivity_timeout = 0;
1454 break;
1455 default:
1456 wl1271_error("Incorrect acx command id=%x\n", direction);
1457 ret = -EINVAL;
1458 goto out;
1459 }
1460
1461 ret = wl1271_cmd_configure(wl,
1462 ACX_BA_SESSION_POLICY_CFG,
1463 acx,
1464 sizeof(*acx));
1465 if (ret < 0) {
1466 wl1271_warning("acx ba session setting failed: %d", ret);
1467 goto out;
1468 }
1469
1470out:
1471 kfree(acx);
1472 return ret;
1473}
1474
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001475/* setup BA session receiver setting in the FW. */
1476int wl1271_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn,
1477 bool enable)
1478{
1479 struct wl1271_acx_ba_receiver_setup *acx;
1480 int ret;
1481
1482 wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
1483
1484 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1485 if (!acx) {
1486 ret = -ENOMEM;
1487 goto out;
1488 }
1489
1490 /* Single link for now */
1491 acx->link_id = 1;
1492 acx->tid = tid_index;
1493 acx->enable = enable;
1494 acx->win_size = 0;
1495 acx->ssn = ssn;
1496
1497 ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
1498 sizeof(*acx));
1499 if (ret < 0) {
1500 wl1271_warning("acx ba receiver session failed: %d", ret);
1501 goto out;
1502 }
1503
1504out:
1505 kfree(acx);
1506 return ret;
1507}
1508
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001509int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
1510{
1511 struct wl1271_acx_fw_tsf_information *tsf_info;
1512 int ret;
1513
1514 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
1515 if (!tsf_info) {
1516 ret = -ENOMEM;
1517 goto out;
1518 }
1519
1520 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
1521 tsf_info, sizeof(*tsf_info));
1522 if (ret < 0) {
1523 wl1271_warning("acx tsf info interrogate failed");
1524 goto out;
1525 }
1526
1527 *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
1528 ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
1529
1530out:
1531 kfree(tsf_info);
1532 return ret;
1533}
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001534
Eliad Pellerf84673d2011-05-15 11:10:28 +03001535int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable)
1536{
1537 struct wl1271_acx_ps_rx_streaming *rx_streaming;
1538 u32 conf_queues, enable_queues;
1539 int i, ret = 0;
1540
1541 wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
1542
1543 rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
1544 if (!rx_streaming) {
1545 ret = -ENOMEM;
1546 goto out;
1547 }
1548
1549 conf_queues = wl->conf.rx_streaming.queues;
1550 if (enable)
1551 enable_queues = conf_queues;
1552 else
1553 enable_queues = 0;
1554
1555 for (i = 0; i < 8; i++) {
1556 /*
1557 * Skip non-changed queues, to avoid redundant acxs.
1558 * this check assumes conf.rx_streaming.queues can't
1559 * be changed while rx_streaming is enabled.
1560 */
1561 if (!(conf_queues & BIT(i)))
1562 continue;
1563
Eliad Peller7f0979882011-08-14 13:17:06 +03001564 rx_streaming->role_id = wl->role_id;
Eliad Pellerf84673d2011-05-15 11:10:28 +03001565 rx_streaming->tid = i;
1566 rx_streaming->enable = enable_queues & BIT(i);
1567 rx_streaming->period = wl->conf.rx_streaming.interval;
1568 rx_streaming->timeout = wl->conf.rx_streaming.interval;
1569
1570 ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
1571 rx_streaming,
1572 sizeof(*rx_streaming));
1573 if (ret < 0) {
1574 wl1271_warning("acx ps rx streaming failed: %d", ret);
1575 goto out;
1576 }
1577 }
1578out:
1579 kfree(rx_streaming);
1580 return ret;
1581}
1582
Arik Nemtsov3618f302011-06-26 10:36:03 +03001583int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl)
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001584{
Arik Nemtsov3618f302011-06-26 10:36:03 +03001585 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001586 int ret;
1587
Arik Nemtsov3618f302011-06-26 10:36:03 +03001588 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001589
1590 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1591 if (!acx)
1592 return -ENOMEM;
1593
Eliad Peller7f0979882011-08-14 13:17:06 +03001594 acx->role_id = wl->role_id;
Arik Nemtsov3618f302011-06-26 10:36:03 +03001595 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001596
1597 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1598 if (ret < 0) {
Arik Nemtsov3618f302011-06-26 10:36:03 +03001599 wl1271_warning("acx ap max tx retry failed: %d", ret);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001600 goto out;
1601 }
1602
1603out:
1604 kfree(acx);
1605 return ret;
1606}
Eliad Pelleree608332011-02-02 09:59:34 +02001607
1608int wl1271_acx_config_ps(struct wl1271 *wl)
1609{
1610 struct wl1271_acx_config_ps *config_ps;
1611 int ret;
1612
1613 wl1271_debug(DEBUG_ACX, "acx config ps");
1614
1615 config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
1616 if (!config_ps) {
1617 ret = -ENOMEM;
1618 goto out;
1619 }
1620
1621 config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
1622 config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
1623 config_ps->null_data_rate = cpu_to_le32(wl->basic_rate);
1624
1625 ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
1626 sizeof(*config_ps));
1627
1628 if (ret < 0) {
1629 wl1271_warning("acx config ps failed: %d", ret);
1630 goto out;
1631 }
1632
1633out:
1634 kfree(config_ps);
1635 return ret;
1636}
Arik Nemtsov99a27752011-02-23 00:22:25 +02001637
1638int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
1639{
1640 struct wl1271_acx_inconnection_sta *acx = NULL;
1641 int ret;
1642
1643 wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
1644
1645 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1646 if (!acx)
1647 return -ENOMEM;
1648
1649 memcpy(acx->addr, addr, ETH_ALEN);
1650
1651 ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
1652 acx, sizeof(*acx));
1653 if (ret < 0) {
1654 wl1271_warning("acx set inconnaction sta failed: %d", ret);
1655 goto out;
1656 }
1657
1658out:
1659 kfree(acx);
1660 return ret;
1661}
Shahar Leviff868432011-04-11 15:41:46 +03001662
1663int wl1271_acx_fm_coex(struct wl1271 *wl)
1664{
1665 struct wl1271_acx_fm_coex *acx;
1666 int ret;
1667
1668 wl1271_debug(DEBUG_ACX, "acx fm coex setting");
1669
1670 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1671 if (!acx) {
1672 ret = -ENOMEM;
1673 goto out;
1674 }
1675
1676 acx->enable = wl->conf.fm_coex.enable;
1677 acx->swallow_period = wl->conf.fm_coex.swallow_period;
1678 acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
1679 acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
1680 acx->m_divider_fref_set_1 =
1681 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
1682 acx->m_divider_fref_set_2 =
1683 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
1684 acx->coex_pll_stabilization_time =
1685 cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
1686 acx->ldo_stabilization_time =
1687 cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
1688 acx->fm_disturbed_band_margin =
1689 wl->conf.fm_coex.fm_disturbed_band_margin;
1690 acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
1691
1692 ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
1693 if (ret < 0) {
1694 wl1271_warning("acx fm coex setting failed: %d", ret);
1695 goto out;
1696 }
1697
1698out:
1699 kfree(acx);
1700 return ret;
1701}
Eliad Pellerfa6ad9f2011-08-14 13:17:14 +03001702
1703int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
1704{
1705 struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
1706 struct conf_rate_policy_settings *conf = &wl->conf.rate;
1707 int ret;
1708
1709 wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
1710
1711 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1712 if (!acx)
1713 return -ENOMEM;
1714
1715 acx->index = ACX_RATE_MGMT_ALL_PARAMS;
1716 acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
1717 acx->per_add = cpu_to_le16(conf->per_add);
1718 acx->per_th1 = cpu_to_le16(conf->per_th1);
1719 acx->per_th2 = cpu_to_le16(conf->per_th2);
1720 acx->max_per = cpu_to_le16(conf->max_per);
1721 acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
1722 acx->tx_fail_low_th = conf->tx_fail_low_th;
1723 acx->tx_fail_high_th = conf->tx_fail_high_th;
1724 acx->per_alpha_shift = conf->per_alpha_shift;
1725 acx->per_add_shift = conf->per_add_shift;
1726 acx->per_beta1_shift = conf->per_beta1_shift;
1727 acx->per_beta2_shift = conf->per_beta2_shift;
1728 acx->rate_check_up = conf->rate_check_up;
1729 acx->rate_check_down = conf->rate_check_down;
1730 memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
1731 sizeof(acx->rate_retry_policy));
1732
1733 ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
1734 acx, sizeof(*acx));
1735 if (ret < 0) {
1736 wl1271_warning("acx set rate mgmt params failed: %d", ret);
1737 goto out;
1738 }
1739
1740out:
1741 kfree(acx);
1742 return ret;
1743}