blob: 21e74ca4ddb29ab8e4544feb91749764b37ffaae [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
Eliad Peller0603d892011-10-05 11:55:51 +020036int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif)
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 Peller0603d892011-10-05 11:55:51 +020049 wake_up->role_id = wlvif->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));
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030081
82out:
83 kfree(auth);
84 return ret;
85}
86
Eliad Peller0603d892011-10-05 11:55:51 +020087int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif,
88 int power)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030089{
90 struct acx_current_tx_power *acx;
91 int ret;
92
Arik Nemtsov097f8822011-06-27 22:06:34 +030093 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030094
95 if (power < 0 || power > 25)
96 return -EINVAL;
97
98 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
99 if (!acx) {
100 ret = -ENOMEM;
101 goto out;
102 }
103
Eliad Peller0603d892011-10-05 11:55:51 +0200104 acx->role_id = wlvif->role_id;
Juuso Oikarinen6f6b5d42010-02-22 08:38:42 +0200105 acx->current_tx_power = power * 10;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300106
107 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
108 if (ret < 0) {
109 wl1271_warning("configure of tx power failed: %d", ret);
110 goto out;
111 }
112
113out:
114 kfree(acx);
115 return ret;
116}
117
Eliad Peller0603d892011-10-05 11:55:51 +0200118int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300119{
120 struct acx_feature_config *feature;
121 int ret;
122
123 wl1271_debug(DEBUG_ACX, "acx feature cfg");
124
125 feature = kzalloc(sizeof(*feature), GFP_KERNEL);
126 if (!feature) {
127 ret = -ENOMEM;
128 goto out;
129 }
130
131 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
Eliad Peller0603d892011-10-05 11:55:51 +0200132 feature->role_id = wlvif->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300133 feature->data_flow_options = 0;
134 feature->options = 0;
135
136 ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
137 feature, sizeof(*feature));
138 if (ret < 0) {
139 wl1271_error("Couldnt set HW encryption");
140 goto out;
141 }
142
143out:
144 kfree(feature);
145 return ret;
146}
147
148int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
149 size_t len)
150{
151 int ret;
152
153 wl1271_debug(DEBUG_ACX, "acx mem map");
154
155 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
156 if (ret < 0)
157 return ret;
158
159 return 0;
160}
161
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +0300162int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300163{
164 struct acx_rx_msdu_lifetime *acx;
165 int ret;
166
167 wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
168
169 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
170 if (!acx) {
171 ret = -ENOMEM;
172 goto out;
173 }
174
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300175 acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300176 ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
177 acx, sizeof(*acx));
178 if (ret < 0) {
179 wl1271_warning("failed to set rx msdu life time: %d", ret);
180 goto out;
181 }
182
183out:
184 kfree(acx);
185 return ret;
186}
187
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300188int wl1271_acx_pd_threshold(struct wl1271 *wl)
189{
190 struct acx_packet_detection *pd;
191 int ret;
192
193 wl1271_debug(DEBUG_ACX, "acx data pd threshold");
194
195 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
196 if (!pd) {
197 ret = -ENOMEM;
198 goto out;
199 }
200
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300201 pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300202
203 ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
204 if (ret < 0) {
205 wl1271_warning("failed to set pd threshold: %d", ret);
206 goto out;
207 }
208
209out:
210 kfree(pd);
Julia Lawall36d34412010-08-16 18:27:30 +0200211 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300212}
213
Eliad Peller0603d892011-10-05 11:55:51 +0200214int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif,
215 enum acx_slot_type slot_time)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300216{
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 Peller0603d892011-10-05 11:55:51 +0200228 slot->role_id = wlvif->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
Eliad Peller0603d892011-10-05 11:55:51 +0200243int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif,
244 bool enable, 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 Peller0603d892011-10-05 11:55:51 +0200258 acx->role_id = wlvif->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
Eliad Peller0603d892011-10-05 11:55:51 +0200275int wl1271_acx_service_period_timeout(struct wl1271 *wl,
276 struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300277{
278 struct acx_rx_timeout *rx_timeout;
279 int ret;
280
281 rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
282 if (!rx_timeout) {
283 ret = -ENOMEM;
284 goto out;
285 }
286
287 wl1271_debug(DEBUG_ACX, "acx service period timeout");
288
Eliad Peller0603d892011-10-05 11:55:51 +0200289 rx_timeout->role_id = wlvif->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300290 rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
291 rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300292
293 ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
294 rx_timeout, sizeof(*rx_timeout));
295 if (ret < 0) {
296 wl1271_warning("failed to set service period timeout: %d",
297 ret);
298 goto out;
299 }
300
301out:
302 kfree(rx_timeout);
303 return ret;
304}
305
Eliad Peller0603d892011-10-05 11:55:51 +0200306int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif,
307 u32 rts_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300308{
309 struct acx_rts_threshold *rts;
310 int ret;
311
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300312 /*
313 * If the RTS threshold is not configured or out of range, use the
314 * default value.
315 */
316 if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
317 rts_threshold = wl->conf.rx.rts_threshold;
318
319 wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300320
321 rts = kzalloc(sizeof(*rts), GFP_KERNEL);
322 if (!rts) {
323 ret = -ENOMEM;
324 goto out;
325 }
326
Eliad Peller0603d892011-10-05 11:55:51 +0200327 rts->role_id = wlvif->role_id;
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300328 rts->threshold = cpu_to_le16((u16)rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300329
330 ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
331 if (ret < 0) {
332 wl1271_warning("failed to set rts threshold: %d", ret);
333 goto out;
334 }
335
336out:
337 kfree(rts);
338 return ret;
339}
340
Luciano Coelho6e92b412009-12-11 15:40:50 +0200341int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
342{
343 struct acx_dco_itrim_params *dco;
344 struct conf_itrim_settings *c = &wl->conf.itrim;
345 int ret;
346
347 wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
348
349 dco = kzalloc(sizeof(*dco), GFP_KERNEL);
350 if (!dco) {
351 ret = -ENOMEM;
352 goto out;
353 }
354
355 dco->enable = c->enable;
356 dco->timeout = cpu_to_le32(c->timeout);
357
358 ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
359 dco, sizeof(*dco));
360 if (ret < 0) {
361 wl1271_warning("failed to set dco itrim parameters: %d", ret);
362 goto out;
363 }
364
365out:
366 kfree(dco);
367 return ret;
368}
369
Eliad Peller0603d892011-10-05 11:55:51 +0200370int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif,
371 bool enable_filter)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300372{
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300373 struct acx_beacon_filter_option *beacon_filter = NULL;
374 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300375
376 wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
377
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300378 if (enable_filter &&
379 wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
380 goto out;
381
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300382 beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
383 if (!beacon_filter) {
384 ret = -ENOMEM;
385 goto out;
386 }
387
Eliad Peller0603d892011-10-05 11:55:51 +0200388 beacon_filter->role_id = wlvif->role_id;
Juuso Oikarinen19221672009-10-08 21:56:35 +0300389 beacon_filter->enable = enable_filter;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300390
391 /*
392 * When set to zero, and the filter is enabled, beacons
393 * without the unicast TIM bit set are dropped.
394 */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300395 beacon_filter->max_num_beacons = 0;
396
397 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
398 beacon_filter, sizeof(*beacon_filter));
399 if (ret < 0) {
400 wl1271_warning("failed to set beacon filter opt: %d", ret);
401 goto out;
402 }
403
404out:
405 kfree(beacon_filter);
406 return ret;
407}
408
Eliad Peller0603d892011-10-05 11:55:51 +0200409int wl1271_acx_beacon_filter_table(struct wl1271 *wl,
410 struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300411{
412 struct acx_beacon_filter_ie_table *ie_table;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300413 int i, idx = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300414 int ret;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300415 bool vendor_spec = false;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300416
417 wl1271_debug(DEBUG_ACX, "acx beacon filter table");
418
419 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
420 if (!ie_table) {
421 ret = -ENOMEM;
422 goto out;
423 }
424
Juuso Oikarinen19221672009-10-08 21:56:35 +0300425 /* configure default beacon pass-through rules */
Eliad Peller0603d892011-10-05 11:55:51 +0200426 ie_table->role_id = wlvif->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300427 ie_table->num_ie = 0;
428 for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
429 struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
430 ie_table->table[idx++] = r->ie;
431 ie_table->table[idx++] = r->rule;
432
433 if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
434 /* only one vendor specific ie allowed */
435 if (vendor_spec)
436 continue;
437
438 /* for vendor specific rules configure the
439 additional fields */
440 memcpy(&(ie_table->table[idx]), r->oui,
441 CONF_BCN_IE_OUI_LEN);
442 idx += CONF_BCN_IE_OUI_LEN;
443 ie_table->table[idx++] = r->type;
444 memcpy(&(ie_table->table[idx]), r->version,
445 CONF_BCN_IE_VER_LEN);
446 idx += CONF_BCN_IE_VER_LEN;
447 vendor_spec = true;
448 }
449
450 ie_table->num_ie++;
451 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300452
453 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
454 ie_table, sizeof(*ie_table));
455 if (ret < 0) {
456 wl1271_warning("failed to set beacon filter table: %d", ret);
457 goto out;
458 }
459
460out:
461 kfree(ie_table);
462 return ret;
463}
464
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200465#define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
466
Eliad Peller0603d892011-10-05 11:55:51 +0200467int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif,
468 bool enable)
Juuso Oikarinen34415232009-10-08 21:56:33 +0300469{
470 struct acx_conn_monit_params *acx;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200471 u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
472 u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
Juuso Oikarinen34415232009-10-08 21:56:33 +0300473 int ret;
474
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200475 wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
476 enable ? "enabled" : "disabled");
Juuso Oikarinen34415232009-10-08 21:56:33 +0300477
478 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
479 if (!acx) {
480 ret = -ENOMEM;
481 goto out;
482 }
483
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200484 if (enable) {
485 threshold = wl->conf.conn.synch_fail_thold;
486 timeout = wl->conf.conn.bss_lose_timeout;
487 }
488
Eliad Peller0603d892011-10-05 11:55:51 +0200489 acx->role_id = wlvif->role_id;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200490 acx->synch_fail_thold = cpu_to_le32(threshold);
491 acx->bss_lose_timeout = cpu_to_le32(timeout);
Juuso Oikarinen34415232009-10-08 21:56:33 +0300492
493 ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
494 acx, sizeof(*acx));
495 if (ret < 0) {
496 wl1271_warning("failed to set connection monitor "
497 "parameters: %d", ret);
498 goto out;
499 }
500
501out:
502 kfree(acx);
503 return ret;
504}
505
506
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200507int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300508{
509 struct acx_bt_wlan_coex *pta;
510 int ret;
511
512 wl1271_debug(DEBUG_ACX, "acx sg enable");
513
514 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
515 if (!pta) {
516 ret = -ENOMEM;
517 goto out;
518 }
519
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200520 if (enable)
521 pta->enable = wl->conf.sg.state;
522 else
523 pta->enable = CONF_SG_DISABLE;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300524
525 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
526 if (ret < 0) {
527 wl1271_warning("failed to set softgemini enable: %d", ret);
528 goto out;
529 }
530
531out:
532 kfree(pta);
533 return ret;
534}
535
Eliad Peller3be41122011-08-14 13:17:19 +0300536int wl12xx_acx_sg_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300537{
Eliad Peller3be41122011-08-14 13:17:19 +0300538 struct acx_bt_wlan_coex_param *param;
Juuso Oikarinen2b60100b2009-10-13 12:47:39 +0300539 struct conf_sg_settings *c = &wl->conf.sg;
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200540 int i, ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300541
Eliad Peller3be41122011-08-14 13:17:19 +0300542 wl1271_debug(DEBUG_ACX, "acx sg cfg");
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300543
544 param = kzalloc(sizeof(*param), GFP_KERNEL);
545 if (!param) {
546 ret = -ENOMEM;
547 goto out;
548 }
549
550 /* BT-WLAN coext parameters */
Eliad Peller3be41122011-08-14 13:17:19 +0300551 for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
552 param->params[i] = cpu_to_le32(c->params[i]);
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200553 param->param_idx = CONF_SG_PARAMS_ALL;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300554
555 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
556 if (ret < 0) {
557 wl1271_warning("failed to set sg config: %d", ret);
558 goto out;
559 }
560
561out:
562 kfree(param);
563 return ret;
564}
565
566int wl1271_acx_cca_threshold(struct wl1271 *wl)
567{
568 struct acx_energy_detection *detection;
569 int ret;
570
571 wl1271_debug(DEBUG_ACX, "acx cca threshold");
572
573 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
574 if (!detection) {
575 ret = -ENOMEM;
576 goto out;
577 }
578
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300579 detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
Juuso Oikarinen45b531a2009-10-13 12:47:41 +0300580 detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300581
582 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
583 detection, sizeof(*detection));
Julia Lawallf8afdf42011-08-12 13:31:30 -0400584 if (ret < 0)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300585 wl1271_warning("failed to set cca threshold: %d", ret);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300586
587out:
588 kfree(detection);
589 return ret;
590}
591
Eliad Peller0603d892011-10-05 11:55:51 +0200592int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300593{
594 struct acx_beacon_broadcast *bb;
595 int ret;
596
597 wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
598
599 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
600 if (!bb) {
601 ret = -ENOMEM;
602 goto out;
603 }
604
Eliad Peller0603d892011-10-05 11:55:51 +0200605 bb->role_id = wlvif->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300606 bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
607 bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300608 bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
609 bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300610
611 ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
612 if (ret < 0) {
613 wl1271_warning("failed to set rx config: %d", ret);
614 goto out;
615 }
616
617out:
618 kfree(bb);
619 return ret;
620}
621
Eliad Peller0603d892011-10-05 11:55:51 +0200622int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300623{
624 struct acx_aid *acx_aid;
625 int ret;
626
627 wl1271_debug(DEBUG_ACX, "acx aid");
628
629 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
630 if (!acx_aid) {
631 ret = -ENOMEM;
632 goto out;
633 }
634
Eliad Peller0603d892011-10-05 11:55:51 +0200635 acx_aid->role_id = wlvif->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300636 acx_aid->aid = cpu_to_le16(aid);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300637
638 ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
639 if (ret < 0) {
640 wl1271_warning("failed to set aid: %d", ret);
641 goto out;
642 }
643
644out:
645 kfree(acx_aid);
646 return ret;
647}
648
649int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
650{
651 struct acx_event_mask *mask;
652 int ret;
653
654 wl1271_debug(DEBUG_ACX, "acx event mbox mask");
655
656 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
657 if (!mask) {
658 ret = -ENOMEM;
659 goto out;
660 }
661
662 /* high event mask is unused */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300663 mask->high_event_mask = cpu_to_le32(0xffffffff);
664 mask->event_mask = cpu_to_le32(event_mask);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300665
666 ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
667 mask, sizeof(*mask));
668 if (ret < 0) {
669 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
670 goto out;
671 }
672
673out:
674 kfree(mask);
675 return ret;
676}
677
Eliad Peller0603d892011-10-05 11:55:51 +0200678int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif,
679 enum acx_preamble_type preamble)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300680{
681 struct acx_preamble *acx;
682 int ret;
683
684 wl1271_debug(DEBUG_ACX, "acx_set_preamble");
685
686 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
687 if (!acx) {
688 ret = -ENOMEM;
689 goto out;
690 }
691
Eliad Peller0603d892011-10-05 11:55:51 +0200692 acx->role_id = wlvif->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300693 acx->preamble = preamble;
694
695 ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
696 if (ret < 0) {
697 wl1271_warning("Setting of preamble failed: %d", ret);
698 goto out;
699 }
700
701out:
702 kfree(acx);
703 return ret;
704}
705
Eliad Peller0603d892011-10-05 11:55:51 +0200706int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif,
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300707 enum acx_ctsprotect_type ctsprotect)
708{
709 struct acx_ctsprotect *acx;
710 int ret;
711
712 wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
713
714 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
715 if (!acx) {
716 ret = -ENOMEM;
717 goto out;
718 }
719
Eliad Peller0603d892011-10-05 11:55:51 +0200720 acx->role_id = wlvif->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300721 acx->ctsprotect = ctsprotect;
722
723 ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
724 if (ret < 0) {
725 wl1271_warning("Setting of ctsprotect failed: %d", ret);
726 goto out;
727 }
728
729out:
730 kfree(acx);
731 return ret;
732}
733
734int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
735{
736 int ret;
737
738 wl1271_debug(DEBUG_ACX, "acx statistics");
739
740 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
741 sizeof(*stats));
742 if (ret < 0) {
743 wl1271_warning("acx statistics failed: %d", ret);
744 return -ENOMEM;
745 }
746
747 return 0;
748}
749
Eliad Peller30d0c8f2011-10-05 11:55:42 +0200750int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300751{
Eliad Peller7f0979882011-08-14 13:17:06 +0300752 struct acx_rate_policy *acx;
Arik Nemtsov1e05a812010-10-16 17:44:51 +0200753 struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300754 int ret = 0;
755
756 wl1271_debug(DEBUG_ACX, "acx rate policies");
757
758 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
759
760 if (!acx) {
761 ret = -ENOMEM;
762 goto out;
763 }
764
Eliad Peller7f0979882011-08-14 13:17:06 +0300765 wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
Eliad Pellerd2d66c52011-10-05 11:55:43 +0200766 wlvif->basic_rate, wlvif->rate_set);
Eliad Peller7f0979882011-08-14 13:17:06 +0300767
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200768 /* configure one basic rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300769 acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE);
Eliad Pellerd2d66c52011-10-05 11:55:43 +0200770 acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->basic_rate);
Eliad Peller7f0979882011-08-14 13:17:06 +0300771 acx->rate_policy.short_retry_limit = c->short_retry_limit;
772 acx->rate_policy.long_retry_limit = c->long_retry_limit;
773 acx->rate_policy.aflags = c->aflags;
774
775 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
776 if (ret < 0) {
777 wl1271_warning("Setting of rate policies failed: %d", ret);
778 goto out;
779 }
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200780
781 /* configure one AP supported rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300782 acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE);
Eliad Peller30d0c8f2011-10-05 11:55:42 +0200783 acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set);
Eliad Peller7f0979882011-08-14 13:17:06 +0300784 acx->rate_policy.short_retry_limit = c->short_retry_limit;
785 acx->rate_policy.long_retry_limit = c->long_retry_limit;
786 acx->rate_policy.aflags = c->aflags;
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200787
Eliad Peller4b298862011-10-03 12:06:36 +0200788 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
789 if (ret < 0) {
790 wl1271_warning("Setting of rate policies failed: %d", ret);
791 goto out;
792 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300793
Eliad Peller4b298862011-10-03 12:06:36 +0200794 /*
795 * configure one rate class for basic p2p operations.
796 * (p2p packets should always go out with OFDM rates, even
797 * if we are currently connected to 11b AP)
798 */
799 acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE_P2P);
800 acx->rate_policy.enabled_rates =
801 cpu_to_le32(CONF_TX_RATE_MASK_BASIC_P2P);
802 acx->rate_policy.short_retry_limit = c->short_retry_limit;
803 acx->rate_policy.long_retry_limit = c->long_retry_limit;
804 acx->rate_policy.aflags = c->aflags;
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200805
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300806 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
807 if (ret < 0) {
808 wl1271_warning("Setting of rate policies failed: %d", ret);
809 goto out;
810 }
811
812out:
813 kfree(acx);
814 return ret;
815}
816
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200817int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
818 u8 idx)
819{
Eliad Peller7f0979882011-08-14 13:17:06 +0300820 struct acx_rate_policy *acx;
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200821 int ret = 0;
822
Arik Nemtsov70f47422011-04-18 14:15:25 +0300823 wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
824 idx, c->enabled_rates);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200825
826 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
827 if (!acx) {
828 ret = -ENOMEM;
829 goto out;
830 }
831
832 acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
833 acx->rate_policy.short_retry_limit = c->short_retry_limit;
834 acx->rate_policy.long_retry_limit = c->long_retry_limit;
835 acx->rate_policy.aflags = c->aflags;
836
Eliad Peller1d4801f2011-01-16 10:07:10 +0100837 acx->rate_policy_idx = cpu_to_le32(idx);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200838
839 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
840 if (ret < 0) {
841 wl1271_warning("Setting of ap rate policy failed: %d", ret);
842 goto out;
843 }
844
845out:
846 kfree(acx);
847 return ret;
848}
849
Eliad Peller0603d892011-10-05 11:55:51 +0200850int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif,
851 u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300852{
853 struct acx_ac_cfg *acx;
Kalle Valo243eeb52010-02-18 13:25:39 +0200854 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300855
Kalle Valo243eeb52010-02-18 13:25:39 +0200856 wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
857 "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300858
859 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
860
861 if (!acx) {
862 ret = -ENOMEM;
863 goto out;
864 }
865
Eliad Peller0603d892011-10-05 11:55:51 +0200866 acx->role_id = wlvif->role_id;
Kalle Valo243eeb52010-02-18 13:25:39 +0200867 acx->ac = ac;
868 acx->cw_min = cw_min;
869 acx->cw_max = cpu_to_le16(cw_max);
870 acx->aifsn = aifsn;
871 acx->tx_op_limit = cpu_to_le16(txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300872
Kalle Valo243eeb52010-02-18 13:25:39 +0200873 ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
874 if (ret < 0) {
875 wl1271_warning("acx ac cfg failed: %d", ret);
876 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300877 }
878
879out:
880 kfree(acx);
881 return ret;
882}
883
Eliad Peller0603d892011-10-05 11:55:51 +0200884int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif,
885 u8 queue_id, u8 channel_type,
Kalle Valof2054df2010-02-18 13:25:40 +0200886 u8 tsid, u8 ps_scheme, u8 ack_policy,
887 u32 apsd_conf0, u32 apsd_conf1)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300888{
889 struct acx_tid_config *acx;
Kalle Valof2054df2010-02-18 13:25:40 +0200890 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300891
892 wl1271_debug(DEBUG_ACX, "acx tid config");
893
894 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
895
896 if (!acx) {
897 ret = -ENOMEM;
898 goto out;
899 }
900
Eliad Peller0603d892011-10-05 11:55:51 +0200901 acx->role_id = wlvif->role_id;
Kalle Valof2054df2010-02-18 13:25:40 +0200902 acx->queue_id = queue_id;
903 acx->channel_type = channel_type;
904 acx->tsid = tsid;
905 acx->ps_scheme = ps_scheme;
906 acx->ack_policy = ack_policy;
907 acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
908 acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300909
Kalle Valof2054df2010-02-18 13:25:40 +0200910 ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
911 if (ret < 0) {
912 wl1271_warning("Setting of tid config failed: %d", ret);
913 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300914 }
915
916out:
917 kfree(acx);
918 return ret;
919}
920
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300921int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300922{
923 struct acx_frag_threshold *acx;
924 int ret = 0;
925
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300926 /*
927 * If the fragmentation is not configured or out of range, use the
928 * default value.
929 */
930 if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
931 frag_threshold = wl->conf.tx.frag_threshold;
932
933 wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300934
935 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
936
937 if (!acx) {
938 ret = -ENOMEM;
939 goto out;
940 }
941
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300942 acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300943 ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
944 if (ret < 0) {
945 wl1271_warning("Setting of frag threshold failed: %d", ret);
946 goto out;
947 }
948
949out:
950 kfree(acx);
951 return ret;
952}
953
954int wl1271_acx_tx_config_options(struct wl1271 *wl)
955{
956 struct acx_tx_config_options *acx;
957 int ret = 0;
958
959 wl1271_debug(DEBUG_ACX, "acx tx config options");
960
961 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
962
963 if (!acx) {
964 ret = -ENOMEM;
965 goto out;
966 }
967
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300968 acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
969 acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300970 ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
971 if (ret < 0) {
972 wl1271_warning("Setting of tx options failed: %d", ret);
973 goto out;
974 }
975
976out:
977 kfree(acx);
978 return ret;
979}
980
Eliad Peller7f0979882011-08-14 13:17:06 +0300981int wl12xx_acx_mem_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300982{
Eliad Peller7f0979882011-08-14 13:17:06 +0300983 struct wl12xx_acx_config_memory *mem_conf;
Shahar Levi13b107d2011-03-06 16:32:12 +0200984 struct conf_memory_settings *mem;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200985 int ret;
986
987 wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
988
989 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
990 if (!mem_conf) {
991 ret = -ENOMEM;
992 goto out;
993 }
994
Shahar Levi13b107d2011-03-06 16:32:12 +0200995 if (wl->chip.id == CHIP_ID_1283_PG20)
996 mem = &wl->conf.mem_wl128x;
997 else
998 mem = &wl->conf.mem_wl127x;
999
Eliad Pellerc8bde242011-02-02 09:59:35 +02001000 /* memory config */
Shahar Levi13b107d2011-03-06 16:32:12 +02001001 mem_conf->num_stations = mem->num_stations;
1002 mem_conf->rx_mem_block_num = mem->rx_block_num;
1003 mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
1004 mem_conf->num_ssid_profiles = mem->ssid_profiles;
Eliad Pellerc8bde242011-02-02 09:59:35 +02001005 mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
Shahar Levi13b107d2011-03-06 16:32:12 +02001006 mem_conf->dyn_mem_enable = mem->dynamic_memory;
1007 mem_conf->tx_free_req = mem->min_req_tx_blocks;
1008 mem_conf->rx_free_req = mem->min_req_rx_blocks;
1009 mem_conf->tx_min = mem->tx_min;
Ido Yariv95dac04f2011-06-06 14:57:06 +03001010 mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks;
Eliad Pellerc8bde242011-02-02 09:59:35 +02001011
1012 ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
1013 sizeof(*mem_conf));
1014 if (ret < 0) {
1015 wl1271_warning("wl1271 mem config failed: %d", ret);
1016 goto out;
1017 }
1018
1019out:
1020 kfree(mem_conf);
1021 return ret;
1022}
1023
Shahar Levi48a61472011-03-06 16:32:08 +02001024int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
1025{
1026 struct wl1271_acx_host_config_bitmap *bitmap_conf;
1027 int ret;
1028
1029 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
1030 if (!bitmap_conf) {
1031 ret = -ENOMEM;
1032 goto out;
1033 }
1034
1035 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
1036
1037 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
1038 bitmap_conf, sizeof(*bitmap_conf));
1039 if (ret < 0) {
1040 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
1041 goto out;
1042 }
1043
1044out:
1045 kfree(bitmap_conf);
1046
1047 return ret;
1048}
1049
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001050int wl1271_acx_init_mem_config(struct wl1271 *wl)
1051{
1052 int ret;
1053
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001054 wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
Juuso Oikarinen45b531a2009-10-13 12:47:41 +03001055 GFP_KERNEL);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001056 if (!wl->target_mem_map) {
1057 wl1271_error("couldn't allocate target memory map");
1058 return -ENOMEM;
1059 }
1060
1061 /* we now ask for the firmware built memory map */
1062 ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
1063 sizeof(struct wl1271_acx_mem_map));
1064 if (ret < 0) {
1065 wl1271_error("couldn't retrieve firmware memory map");
1066 kfree(wl->target_mem_map);
1067 wl->target_mem_map = NULL;
1068 return ret;
1069 }
1070
1071 /* initialize TX block book keeping */
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001072 wl->tx_blocks_available =
1073 le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001074 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1075 wl->tx_blocks_available);
1076
1077 return 0;
1078}
1079
1080int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
1081{
1082 struct wl1271_acx_rx_config_opt *rx_conf;
1083 int ret;
1084
1085 wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
1086
1087 rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
1088 if (!rx_conf) {
1089 ret = -ENOMEM;
1090 goto out;
1091 }
1092
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001093 rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
1094 rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
1095 rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +03001096 rx_conf->queue_type = wl->conf.rx.queue_type;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001097
1098 ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
1099 sizeof(*rx_conf));
1100 if (ret < 0) {
1101 wl1271_warning("wl1271 rx config opt failed: %d", ret);
1102 goto out;
1103 }
1104
1105out:
1106 kfree(rx_conf);
1107 return ret;
1108}
Juuso Oikarinen3cfd6cf2009-10-12 15:08:52 +03001109
Eliad Peller0603d892011-10-05 11:55:51 +02001110int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1111 bool enable)
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001112{
1113 struct wl1271_acx_bet_enable *acx = NULL;
1114 int ret = 0;
1115
1116 wl1271_debug(DEBUG_ACX, "acx bet enable");
1117
1118 if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
1119 goto out;
1120
1121 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1122 if (!acx) {
1123 ret = -ENOMEM;
1124 goto out;
1125 }
1126
Eliad Peller0603d892011-10-05 11:55:51 +02001127 acx->role_id = wlvif->role_id;
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001128 acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
1129 acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
1130
1131 ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
1132 if (ret < 0) {
1133 wl1271_warning("acx bet enable failed: %d", ret);
1134 goto out;
1135 }
1136
1137out:
1138 kfree(acx);
1139 return ret;
1140}
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001141
Eliad Peller0603d892011-10-05 11:55:51 +02001142int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1143 u8 enable, __be32 address)
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001144{
1145 struct wl1271_acx_arp_filter *acx;
1146 int ret;
1147
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001148 wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001149
1150 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1151 if (!acx) {
1152 ret = -ENOMEM;
1153 goto out;
1154 }
1155
Eliad Peller0603d892011-10-05 11:55:51 +02001156 acx->role_id = wlvif->role_id;
Juuso Oikarineneb887df2010-07-08 17:49:58 +03001157 acx->version = ACX_IPV4_VERSION;
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001158 acx->enable = enable;
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001159
Eliad Pellerc5312772010-12-09 11:31:27 +02001160 if (enable)
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001161 memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001162
1163 ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
1164 acx, sizeof(*acx));
1165 if (ret < 0) {
1166 wl1271_warning("failed to set arp ip filter: %d", ret);
1167 goto out;
1168 }
1169
1170out:
1171 kfree(acx);
1172 return ret;
1173}
Juuso Oikarinen38ad2d82009-12-11 15:41:08 +02001174
1175int wl1271_acx_pm_config(struct wl1271 *wl)
1176{
1177 struct wl1271_acx_pm_config *acx = NULL;
1178 struct conf_pm_config_settings *c = &wl->conf.pm_config;
1179 int ret = 0;
1180
1181 wl1271_debug(DEBUG_ACX, "acx pm config");
1182
1183 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1184 if (!acx) {
1185 ret = -ENOMEM;
1186 goto out;
1187 }
1188
1189 acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
1190 acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
1191
1192 ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
1193 if (ret < 0) {
1194 wl1271_warning("acx pm config failed: %d", ret);
1195 goto out;
1196 }
1197
1198out:
1199 kfree(acx);
1200 return ret;
1201}
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001202
Eliad Peller0603d892011-10-05 11:55:51 +02001203int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1204 bool enable)
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001205{
1206 struct wl1271_acx_keep_alive_mode *acx = NULL;
1207 int ret = 0;
1208
1209 wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
1210
1211 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1212 if (!acx) {
1213 ret = -ENOMEM;
1214 goto out;
1215 }
1216
Eliad Peller0603d892011-10-05 11:55:51 +02001217 acx->role_id = wlvif->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001218 acx->enabled = enable;
1219
1220 ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
1221 if (ret < 0) {
1222 wl1271_warning("acx keep alive mode failed: %d", ret);
1223 goto out;
1224 }
1225
1226out:
1227 kfree(acx);
1228 return ret;
1229}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001230
Eliad Peller0603d892011-10-05 11:55:51 +02001231int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1232 u8 index, u8 tpl_valid)
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001233{
1234 struct wl1271_acx_keep_alive_config *acx = NULL;
1235 int ret = 0;
1236
1237 wl1271_debug(DEBUG_ACX, "acx keep alive config");
1238
1239 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1240 if (!acx) {
1241 ret = -ENOMEM;
1242 goto out;
1243 }
1244
Eliad Peller0603d892011-10-05 11:55:51 +02001245 acx->role_id = wlvif->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001246 acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
1247 acx->index = index;
1248 acx->tpl_validation = tpl_valid;
1249 acx->trigger = ACX_KEEP_ALIVE_NO_TX;
1250
1251 ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
1252 acx, sizeof(*acx));
1253 if (ret < 0) {
1254 wl1271_warning("acx keep alive config failed: %d", ret);
1255 goto out;
1256 }
1257
1258out:
1259 kfree(acx);
1260 return ret;
1261}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001262
Eliad Peller0603d892011-10-05 11:55:51 +02001263int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1264 bool enable, s16 thold, u8 hyst)
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001265{
1266 struct wl1271_acx_rssi_snr_trigger *acx = NULL;
1267 int ret = 0;
1268
1269 wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
1270
1271 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1272 if (!acx) {
1273 ret = -ENOMEM;
1274 goto out;
1275 }
1276
Eliad Peller04324d92011-10-05 11:56:03 +02001277 wlvif->last_rssi_event = -1;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001278
Eliad Peller0603d892011-10-05 11:55:51 +02001279 acx->role_id = wlvif->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001280 acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
1281 acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
1282 acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
1283 if (enable)
1284 acx->enable = WL1271_ACX_TRIG_ENABLE;
1285 else
1286 acx->enable = WL1271_ACX_TRIG_DISABLE;
1287
1288 acx->index = WL1271_ACX_TRIG_IDX_RSSI;
1289 acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
1290 acx->threshold = cpu_to_le16(thold);
1291 acx->hysteresis = hyst;
1292
1293 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
1294 if (ret < 0) {
1295 wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
1296 goto out;
1297 }
1298
1299out:
1300 kfree(acx);
1301 return ret;
1302}
1303
Eliad Peller0603d892011-10-05 11:55:51 +02001304int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl,
1305 struct wl12xx_vif *wlvif)
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001306{
1307 struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
1308 struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
1309 int ret = 0;
1310
1311 wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
1312
1313 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1314 if (!acx) {
1315 ret = -ENOMEM;
1316 goto out;
1317 }
1318
Eliad Peller0603d892011-10-05 11:55:51 +02001319 acx->role_id = wlvif->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001320 acx->rssi_beacon = c->avg_weight_rssi_beacon;
1321 acx->rssi_data = c->avg_weight_rssi_data;
1322 acx->snr_beacon = c->avg_weight_snr_beacon;
1323 acx->snr_data = c->avg_weight_snr_data;
1324
1325 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
1326 if (ret < 0) {
1327 wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
1328 goto out;
1329 }
1330
1331out:
1332 kfree(acx);
1333 return ret;
1334}
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001335
Shahar Levic4db1c82010-10-13 16:09:40 +02001336int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
1337 struct ieee80211_sta_ht_cap *ht_cap,
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001338 bool allow_ht_operation, u8 hlid)
Shahar Levic4db1c82010-10-13 16:09:40 +02001339{
1340 struct wl1271_acx_ht_capabilities *acx;
Shahar Levic4db1c82010-10-13 16:09:40 +02001341 int ret = 0;
Eliad Peller6177eae2010-12-22 12:38:52 +01001342 u32 ht_capabilites = 0;
Shahar Levic4db1c82010-10-13 16:09:40 +02001343
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001344 wl1271_debug(DEBUG_ACX, "acx ht capabilities setting "
1345 "sta supp: %d sta cap: %d", ht_cap->ht_supported,
1346 ht_cap->cap);
Shahar Levic4db1c82010-10-13 16:09:40 +02001347
1348 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1349 if (!acx) {
1350 ret = -ENOMEM;
1351 goto out;
1352 }
1353
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001354 if (allow_ht_operation && ht_cap->ht_supported) {
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001355 /* no need to translate capabilities - use the spec values */
1356 ht_capabilites = ht_cap->cap;
1357
1358 /*
1359 * this bit is not employed by the spec but only by FW to
1360 * indicate peer HT support
1361 */
1362 ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
Shahar Levic4db1c82010-10-13 16:09:40 +02001363
1364 /* get data from A-MPDU parameters field */
1365 acx->ampdu_max_length = ht_cap->ampdu_factor;
1366 acx->ampdu_min_spacing = ht_cap->ampdu_density;
Shahar Levic4db1c82010-10-13 16:09:40 +02001367 }
1368
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001369 acx->hlid = hlid;
Eliad Peller6177eae2010-12-22 12:38:52 +01001370 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
1371
Shahar Levic4db1c82010-10-13 16:09:40 +02001372 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
1373 if (ret < 0) {
1374 wl1271_warning("acx ht capabilities setting failed: %d", ret);
1375 goto out;
1376 }
1377
1378out:
1379 kfree(acx);
1380 return ret;
1381}
1382
1383int wl1271_acx_set_ht_information(struct wl1271 *wl,
Eliad Peller0603d892011-10-05 11:55:51 +02001384 struct wl12xx_vif *wlvif,
Shahar Levic4db1c82010-10-13 16:09:40 +02001385 u16 ht_operation_mode)
1386{
1387 struct wl1271_acx_ht_information *acx;
1388 int ret = 0;
1389
1390 wl1271_debug(DEBUG_ACX, "acx ht information setting");
1391
1392 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1393 if (!acx) {
1394 ret = -ENOMEM;
1395 goto out;
1396 }
1397
Eliad Peller0603d892011-10-05 11:55:51 +02001398 acx->role_id = wlvif->role_id;
Shahar Levic4db1c82010-10-13 16:09:40 +02001399 acx->ht_protection =
1400 (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
1401 acx->rifs_mode = 0;
Helmut Schaa95a77612011-03-02 10:46:46 +01001402 acx->gf_protection =
1403 !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
Shahar Levic4db1c82010-10-13 16:09:40 +02001404 acx->ht_tx_burst_limit = 0;
1405 acx->dual_cts_protection = 0;
1406
1407 ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
1408
1409 if (ret < 0) {
1410 wl1271_warning("acx ht information setting failed: %d", ret);
1411 goto out;
1412 }
1413
1414out:
1415 kfree(acx);
1416 return ret;
1417}
1418
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001419/* Configure BA session initiator/receiver parameters setting in the FW. */
Eliad Peller0603d892011-10-05 11:55:51 +02001420int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl,
1421 struct wl12xx_vif *wlvif)
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001422{
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001423 struct wl1271_acx_ba_initiator_policy *acx;
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001424 int ret;
1425
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001426 wl1271_debug(DEBUG_ACX, "acx ba initiator policy");
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001427
1428 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1429 if (!acx) {
1430 ret = -ENOMEM;
1431 goto out;
1432 }
1433
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001434 /* set for the current role */
Eliad Peller0603d892011-10-05 11:55:51 +02001435 acx->role_id = wlvif->role_id;
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001436 acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap;
1437 acx->win_size = wl->conf.ht.tx_ba_win_size;
1438 acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001439
1440 ret = wl1271_cmd_configure(wl,
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001441 ACX_BA_SESSION_INIT_POLICY,
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001442 acx,
1443 sizeof(*acx));
1444 if (ret < 0) {
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001445 wl1271_warning("acx ba initiator policy failed: %d", ret);
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001446 goto out;
1447 }
1448
1449out:
1450 kfree(acx);
1451 return ret;
1452}
1453
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001454/* setup BA session receiver setting in the FW. */
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001455int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index,
1456 u16 ssn, bool enable, u8 peer_hlid)
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001457{
1458 struct wl1271_acx_ba_receiver_setup *acx;
1459 int ret;
1460
1461 wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
1462
1463 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1464 if (!acx) {
1465 ret = -ENOMEM;
1466 goto out;
1467 }
1468
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001469 acx->hlid = peer_hlid;
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001470 acx->tid = tid_index;
1471 acx->enable = enable;
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001472 acx->win_size = wl->conf.ht.rx_ba_win_size;
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001473 acx->ssn = ssn;
1474
1475 ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
1476 sizeof(*acx));
1477 if (ret < 0) {
1478 wl1271_warning("acx ba receiver session failed: %d", ret);
1479 goto out;
1480 }
1481
1482out:
1483 kfree(acx);
1484 return ret;
1485}
1486
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001487int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
1488{
1489 struct wl1271_acx_fw_tsf_information *tsf_info;
1490 int ret;
1491
1492 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
1493 if (!tsf_info) {
1494 ret = -ENOMEM;
1495 goto out;
1496 }
1497
1498 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
1499 tsf_info, sizeof(*tsf_info));
1500 if (ret < 0) {
1501 wl1271_warning("acx tsf info interrogate failed");
1502 goto out;
1503 }
1504
1505 *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
1506 ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
1507
1508out:
1509 kfree(tsf_info);
1510 return ret;
1511}
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001512
Eliad Peller9eb599e2011-10-10 10:12:59 +02001513int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1514 bool enable)
Eliad Pellerf84673d2011-05-15 11:10:28 +03001515{
1516 struct wl1271_acx_ps_rx_streaming *rx_streaming;
1517 u32 conf_queues, enable_queues;
1518 int i, ret = 0;
1519
1520 wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
1521
1522 rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
1523 if (!rx_streaming) {
1524 ret = -ENOMEM;
1525 goto out;
1526 }
1527
1528 conf_queues = wl->conf.rx_streaming.queues;
1529 if (enable)
1530 enable_queues = conf_queues;
1531 else
1532 enable_queues = 0;
1533
1534 for (i = 0; i < 8; i++) {
1535 /*
1536 * Skip non-changed queues, to avoid redundant acxs.
1537 * this check assumes conf.rx_streaming.queues can't
1538 * be changed while rx_streaming is enabled.
1539 */
1540 if (!(conf_queues & BIT(i)))
1541 continue;
1542
Eliad Peller0603d892011-10-05 11:55:51 +02001543 rx_streaming->role_id = wlvif->role_id;
Eliad Pellerf84673d2011-05-15 11:10:28 +03001544 rx_streaming->tid = i;
1545 rx_streaming->enable = enable_queues & BIT(i);
1546 rx_streaming->period = wl->conf.rx_streaming.interval;
1547 rx_streaming->timeout = wl->conf.rx_streaming.interval;
1548
1549 ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
1550 rx_streaming,
1551 sizeof(*rx_streaming));
1552 if (ret < 0) {
1553 wl1271_warning("acx ps rx streaming failed: %d", ret);
1554 goto out;
1555 }
1556 }
1557out:
1558 kfree(rx_streaming);
1559 return ret;
1560}
1561
Eliad Peller0603d892011-10-05 11:55:51 +02001562int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001563{
Arik Nemtsov3618f302011-06-26 10:36:03 +03001564 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001565 int ret;
1566
Arik Nemtsov3618f302011-06-26 10:36:03 +03001567 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001568
1569 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1570 if (!acx)
1571 return -ENOMEM;
1572
Eliad Peller0603d892011-10-05 11:55:51 +02001573 acx->role_id = wlvif->role_id;
Arik Nemtsov3618f302011-06-26 10:36:03 +03001574 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001575
1576 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1577 if (ret < 0) {
Arik Nemtsov3618f302011-06-26 10:36:03 +03001578 wl1271_warning("acx ap max tx retry failed: %d", ret);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001579 goto out;
1580 }
1581
1582out:
1583 kfree(acx);
1584 return ret;
1585}
Eliad Pelleree608332011-02-02 09:59:34 +02001586
Eliad Pellerd2d66c52011-10-05 11:55:43 +02001587int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Eliad Pelleree608332011-02-02 09:59:34 +02001588{
1589 struct wl1271_acx_config_ps *config_ps;
1590 int ret;
1591
1592 wl1271_debug(DEBUG_ACX, "acx config ps");
1593
1594 config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
1595 if (!config_ps) {
1596 ret = -ENOMEM;
1597 goto out;
1598 }
1599
1600 config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
1601 config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
Eliad Pellerd2d66c52011-10-05 11:55:43 +02001602 config_ps->null_data_rate = cpu_to_le32(wlvif->basic_rate);
Eliad Pelleree608332011-02-02 09:59:34 +02001603
1604 ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
1605 sizeof(*config_ps));
1606
1607 if (ret < 0) {
1608 wl1271_warning("acx config ps failed: %d", ret);
1609 goto out;
1610 }
1611
1612out:
1613 kfree(config_ps);
1614 return ret;
1615}
Arik Nemtsov99a27752011-02-23 00:22:25 +02001616
1617int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
1618{
1619 struct wl1271_acx_inconnection_sta *acx = NULL;
1620 int ret;
1621
1622 wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
1623
1624 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1625 if (!acx)
1626 return -ENOMEM;
1627
1628 memcpy(acx->addr, addr, ETH_ALEN);
1629
1630 ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
1631 acx, sizeof(*acx));
1632 if (ret < 0) {
1633 wl1271_warning("acx set inconnaction sta failed: %d", ret);
1634 goto out;
1635 }
1636
1637out:
1638 kfree(acx);
1639 return ret;
1640}
Shahar Leviff868432011-04-11 15:41:46 +03001641
1642int wl1271_acx_fm_coex(struct wl1271 *wl)
1643{
1644 struct wl1271_acx_fm_coex *acx;
1645 int ret;
1646
1647 wl1271_debug(DEBUG_ACX, "acx fm coex setting");
1648
1649 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1650 if (!acx) {
1651 ret = -ENOMEM;
1652 goto out;
1653 }
1654
1655 acx->enable = wl->conf.fm_coex.enable;
1656 acx->swallow_period = wl->conf.fm_coex.swallow_period;
1657 acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
1658 acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
1659 acx->m_divider_fref_set_1 =
1660 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
1661 acx->m_divider_fref_set_2 =
1662 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
1663 acx->coex_pll_stabilization_time =
1664 cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
1665 acx->ldo_stabilization_time =
1666 cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
1667 acx->fm_disturbed_band_margin =
1668 wl->conf.fm_coex.fm_disturbed_band_margin;
1669 acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
1670
1671 ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
1672 if (ret < 0) {
1673 wl1271_warning("acx fm coex setting failed: %d", ret);
1674 goto out;
1675 }
1676
1677out:
1678 kfree(acx);
1679 return ret;
1680}
Eliad Pellerfa6ad9f2011-08-14 13:17:14 +03001681
1682int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
1683{
1684 struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
1685 struct conf_rate_policy_settings *conf = &wl->conf.rate;
1686 int ret;
1687
1688 wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
1689
1690 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1691 if (!acx)
1692 return -ENOMEM;
1693
1694 acx->index = ACX_RATE_MGMT_ALL_PARAMS;
1695 acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
1696 acx->per_add = cpu_to_le16(conf->per_add);
1697 acx->per_th1 = cpu_to_le16(conf->per_th1);
1698 acx->per_th2 = cpu_to_le16(conf->per_th2);
1699 acx->max_per = cpu_to_le16(conf->max_per);
1700 acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
1701 acx->tx_fail_low_th = conf->tx_fail_low_th;
1702 acx->tx_fail_high_th = conf->tx_fail_high_th;
1703 acx->per_alpha_shift = conf->per_alpha_shift;
1704 acx->per_add_shift = conf->per_add_shift;
1705 acx->per_beta1_shift = conf->per_beta1_shift;
1706 acx->per_beta2_shift = conf->per_beta2_shift;
1707 acx->rate_check_up = conf->rate_check_up;
1708 acx->rate_check_down = conf->rate_check_down;
1709 memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
1710 sizeof(acx->rate_retry_policy));
1711
1712 ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
1713 acx, sizeof(*acx));
1714 if (ret < 0) {
1715 wl1271_warning("acx set rate mgmt params failed: %d", ret);
1716 goto out;
1717 }
1718
1719out:
1720 kfree(acx);
1721 return ret;
1722}
Eliad Peller94877752011-08-28 15:11:56 +03001723
1724int wl12xx_acx_config_hangover(struct wl1271 *wl)
1725{
1726 struct wl12xx_acx_config_hangover *acx;
1727 struct conf_hangover_settings *conf = &wl->conf.hangover;
1728 int ret;
1729
1730 wl1271_debug(DEBUG_ACX, "acx config hangover");
1731
1732 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1733 if (!acx) {
1734 ret = -ENOMEM;
1735 goto out;
1736 }
1737
1738 acx->recover_time = cpu_to_le32(conf->recover_time);
1739 acx->hangover_period = conf->hangover_period;
1740 acx->dynamic_mode = conf->dynamic_mode;
1741 acx->early_termination_mode = conf->early_termination_mode;
1742 acx->max_period = conf->max_period;
1743 acx->min_period = conf->min_period;
1744 acx->increase_delta = conf->increase_delta;
1745 acx->decrease_delta = conf->decrease_delta;
1746 acx->quiet_time = conf->quiet_time;
1747 acx->increase_time = conf->increase_time;
1748 acx->window_size = acx->window_size;
1749
1750 ret = wl1271_cmd_configure(wl, ACX_CONFIG_HANGOVER, acx,
1751 sizeof(*acx));
1752
1753 if (ret < 0) {
1754 wl1271_warning("acx config hangover failed: %d", ret);
1755 goto out;
1756 }
1757
1758out:
1759 kfree(acx);
1760 return ret;
1761
1762}