blob: bde1d862bdd595cc88f6943d40d44f949c51b8f9 [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 Coelho0f4e3122011-10-07 11:02:42 +030032#include "debug.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030033#include "wl12xx_80211.h"
Shahar Levi00d20102010-11-08 11:20:10 +000034#include "reg.h"
35#include "ps.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030036
Eliad Peller0603d892011-10-05 11:55:51 +020037int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030038{
39 struct acx_wake_up_condition *wake_up;
40 int ret;
41
42 wl1271_debug(DEBUG_ACX, "acx wake up conditions");
43
44 wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
45 if (!wake_up) {
46 ret = -ENOMEM;
47 goto out;
48 }
49
Eliad Peller0603d892011-10-05 11:55:51 +020050 wake_up->role_id = wlvif->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +030051 wake_up->wake_up_event = wl->conf.conn.wake_up_event;
52 wake_up->listen_interval = wl->conf.conn.listen_interval;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030053
54 ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
55 wake_up, sizeof(*wake_up));
56 if (ret < 0) {
57 wl1271_warning("could not set wake up conditions: %d", ret);
58 goto out;
59 }
60
61out:
62 kfree(wake_up);
63 return ret;
64}
65
66int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
67{
68 struct acx_sleep_auth *auth;
69 int ret;
70
71 wl1271_debug(DEBUG_ACX, "acx sleep auth");
72
73 auth = kzalloc(sizeof(*auth), GFP_KERNEL);
74 if (!auth) {
75 ret = -ENOMEM;
76 goto out;
77 }
78
79 auth->sleep_auth = sleep_auth;
80
81 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030082
83out:
84 kfree(auth);
85 return ret;
86}
87
Eliad Peller0603d892011-10-05 11:55:51 +020088int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif,
89 int power)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030090{
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 Peller0603d892011-10-05 11:55:51 +0200105 acx->role_id = wlvif->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
Eliad Peller0603d892011-10-05 11:55:51 +0200119int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300120{
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 Peller0603d892011-10-05 11:55:51 +0200133 feature->role_id = wlvif->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
Eliad Peller0603d892011-10-05 11:55:51 +0200215int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif,
216 enum acx_slot_type slot_time)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300217{
218 struct acx_slot *slot;
219 int ret;
220
221 wl1271_debug(DEBUG_ACX, "acx slot");
222
223 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
224 if (!slot) {
225 ret = -ENOMEM;
226 goto out;
227 }
228
Eliad Peller0603d892011-10-05 11:55:51 +0200229 slot->role_id = wlvif->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300230 slot->wone_index = STATION_WONE_INDEX;
231 slot->slot_time = slot_time;
232
233 ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
234 if (ret < 0) {
235 wl1271_warning("failed to set slot time: %d", ret);
236 goto out;
237 }
238
239out:
240 kfree(slot);
241 return ret;
242}
243
Eliad Peller0603d892011-10-05 11:55:51 +0200244int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif,
245 bool enable, void *mc_list, u32 mc_list_len)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300246{
247 struct acx_dot11_grp_addr_tbl *acx;
248 int ret;
249
250 wl1271_debug(DEBUG_ACX, "acx group address tbl");
251
252 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
253 if (!acx) {
254 ret = -ENOMEM;
255 goto out;
256 }
257
258 /* MAC filtering */
Eliad Peller0603d892011-10-05 11:55:51 +0200259 acx->role_id = wlvif->role_id;
Juuso Oikarinenc87dec92009-10-08 21:56:31 +0300260 acx->enabled = enable;
261 acx->num_groups = mc_list_len;
262 memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300263
264 ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
265 acx, sizeof(*acx));
266 if (ret < 0) {
267 wl1271_warning("failed to set group addr table: %d", ret);
268 goto out;
269 }
270
271out:
272 kfree(acx);
273 return ret;
274}
275
Eliad Peller0603d892011-10-05 11:55:51 +0200276int wl1271_acx_service_period_timeout(struct wl1271 *wl,
277 struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300278{
279 struct acx_rx_timeout *rx_timeout;
280 int ret;
281
282 rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
283 if (!rx_timeout) {
284 ret = -ENOMEM;
285 goto out;
286 }
287
288 wl1271_debug(DEBUG_ACX, "acx service period timeout");
289
Eliad Peller0603d892011-10-05 11:55:51 +0200290 rx_timeout->role_id = wlvif->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300291 rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
292 rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300293
294 ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
295 rx_timeout, sizeof(*rx_timeout));
296 if (ret < 0) {
297 wl1271_warning("failed to set service period timeout: %d",
298 ret);
299 goto out;
300 }
301
302out:
303 kfree(rx_timeout);
304 return ret;
305}
306
Eliad Peller0603d892011-10-05 11:55:51 +0200307int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif,
308 u32 rts_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300309{
310 struct acx_rts_threshold *rts;
311 int ret;
312
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300313 /*
314 * If the RTS threshold is not configured or out of range, use the
315 * default value.
316 */
317 if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
318 rts_threshold = wl->conf.rx.rts_threshold;
319
320 wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300321
322 rts = kzalloc(sizeof(*rts), GFP_KERNEL);
323 if (!rts) {
324 ret = -ENOMEM;
325 goto out;
326 }
327
Eliad Peller0603d892011-10-05 11:55:51 +0200328 rts->role_id = wlvif->role_id;
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300329 rts->threshold = cpu_to_le16((u16)rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300330
331 ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
332 if (ret < 0) {
333 wl1271_warning("failed to set rts threshold: %d", ret);
334 goto out;
335 }
336
337out:
338 kfree(rts);
339 return ret;
340}
341
Luciano Coelho6e92b412009-12-11 15:40:50 +0200342int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
343{
344 struct acx_dco_itrim_params *dco;
345 struct conf_itrim_settings *c = &wl->conf.itrim;
346 int ret;
347
348 wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
349
350 dco = kzalloc(sizeof(*dco), GFP_KERNEL);
351 if (!dco) {
352 ret = -ENOMEM;
353 goto out;
354 }
355
356 dco->enable = c->enable;
357 dco->timeout = cpu_to_le32(c->timeout);
358
359 ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
360 dco, sizeof(*dco));
361 if (ret < 0) {
362 wl1271_warning("failed to set dco itrim parameters: %d", ret);
363 goto out;
364 }
365
366out:
367 kfree(dco);
368 return ret;
369}
370
Eliad Peller0603d892011-10-05 11:55:51 +0200371int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif,
372 bool enable_filter)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300373{
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300374 struct acx_beacon_filter_option *beacon_filter = NULL;
375 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300376
377 wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
378
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300379 if (enable_filter &&
380 wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
381 goto out;
382
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300383 beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
384 if (!beacon_filter) {
385 ret = -ENOMEM;
386 goto out;
387 }
388
Eliad Peller0603d892011-10-05 11:55:51 +0200389 beacon_filter->role_id = wlvif->role_id;
Juuso Oikarinen19221672009-10-08 21:56:35 +0300390 beacon_filter->enable = enable_filter;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300391
392 /*
393 * When set to zero, and the filter is enabled, beacons
394 * without the unicast TIM bit set are dropped.
395 */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300396 beacon_filter->max_num_beacons = 0;
397
398 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
399 beacon_filter, sizeof(*beacon_filter));
400 if (ret < 0) {
401 wl1271_warning("failed to set beacon filter opt: %d", ret);
402 goto out;
403 }
404
405out:
406 kfree(beacon_filter);
407 return ret;
408}
409
Eliad Peller0603d892011-10-05 11:55:51 +0200410int wl1271_acx_beacon_filter_table(struct wl1271 *wl,
411 struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300412{
413 struct acx_beacon_filter_ie_table *ie_table;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300414 int i, idx = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300415 int ret;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300416 bool vendor_spec = false;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300417
418 wl1271_debug(DEBUG_ACX, "acx beacon filter table");
419
420 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
421 if (!ie_table) {
422 ret = -ENOMEM;
423 goto out;
424 }
425
Juuso Oikarinen19221672009-10-08 21:56:35 +0300426 /* configure default beacon pass-through rules */
Eliad Peller0603d892011-10-05 11:55:51 +0200427 ie_table->role_id = wlvif->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300428 ie_table->num_ie = 0;
429 for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
430 struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
431 ie_table->table[idx++] = r->ie;
432 ie_table->table[idx++] = r->rule;
433
434 if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
435 /* only one vendor specific ie allowed */
436 if (vendor_spec)
437 continue;
438
439 /* for vendor specific rules configure the
440 additional fields */
441 memcpy(&(ie_table->table[idx]), r->oui,
442 CONF_BCN_IE_OUI_LEN);
443 idx += CONF_BCN_IE_OUI_LEN;
444 ie_table->table[idx++] = r->type;
445 memcpy(&(ie_table->table[idx]), r->version,
446 CONF_BCN_IE_VER_LEN);
447 idx += CONF_BCN_IE_VER_LEN;
448 vendor_spec = true;
449 }
450
451 ie_table->num_ie++;
452 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300453
454 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
455 ie_table, sizeof(*ie_table));
456 if (ret < 0) {
457 wl1271_warning("failed to set beacon filter table: %d", ret);
458 goto out;
459 }
460
461out:
462 kfree(ie_table);
463 return ret;
464}
465
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200466#define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
467
Eliad Peller0603d892011-10-05 11:55:51 +0200468int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif,
469 bool enable)
Juuso Oikarinen34415232009-10-08 21:56:33 +0300470{
471 struct acx_conn_monit_params *acx;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200472 u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
473 u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
Juuso Oikarinen34415232009-10-08 21:56:33 +0300474 int ret;
475
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200476 wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
477 enable ? "enabled" : "disabled");
Juuso Oikarinen34415232009-10-08 21:56:33 +0300478
479 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
480 if (!acx) {
481 ret = -ENOMEM;
482 goto out;
483 }
484
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200485 if (enable) {
486 threshold = wl->conf.conn.synch_fail_thold;
487 timeout = wl->conf.conn.bss_lose_timeout;
488 }
489
Eliad Peller0603d892011-10-05 11:55:51 +0200490 acx->role_id = wlvif->role_id;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200491 acx->synch_fail_thold = cpu_to_le32(threshold);
492 acx->bss_lose_timeout = cpu_to_le32(timeout);
Juuso Oikarinen34415232009-10-08 21:56:33 +0300493
494 ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
495 acx, sizeof(*acx));
496 if (ret < 0) {
497 wl1271_warning("failed to set connection monitor "
498 "parameters: %d", ret);
499 goto out;
500 }
501
502out:
503 kfree(acx);
504 return ret;
505}
506
507
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200508int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300509{
510 struct acx_bt_wlan_coex *pta;
511 int ret;
512
513 wl1271_debug(DEBUG_ACX, "acx sg enable");
514
515 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
516 if (!pta) {
517 ret = -ENOMEM;
518 goto out;
519 }
520
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200521 if (enable)
522 pta->enable = wl->conf.sg.state;
523 else
524 pta->enable = CONF_SG_DISABLE;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300525
526 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
527 if (ret < 0) {
528 wl1271_warning("failed to set softgemini enable: %d", ret);
529 goto out;
530 }
531
532out:
533 kfree(pta);
534 return ret;
535}
536
Eliad Peller3be41122011-08-14 13:17:19 +0300537int wl12xx_acx_sg_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300538{
Eliad Peller3be41122011-08-14 13:17:19 +0300539 struct acx_bt_wlan_coex_param *param;
Juuso Oikarinen2b60100b2009-10-13 12:47:39 +0300540 struct conf_sg_settings *c = &wl->conf.sg;
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200541 int i, ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300542
Eliad Peller3be41122011-08-14 13:17:19 +0300543 wl1271_debug(DEBUG_ACX, "acx sg cfg");
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300544
545 param = kzalloc(sizeof(*param), GFP_KERNEL);
546 if (!param) {
547 ret = -ENOMEM;
548 goto out;
549 }
550
551 /* BT-WLAN coext parameters */
Eliad Peller3be41122011-08-14 13:17:19 +0300552 for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
553 param->params[i] = cpu_to_le32(c->params[i]);
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200554 param->param_idx = CONF_SG_PARAMS_ALL;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300555
556 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
557 if (ret < 0) {
558 wl1271_warning("failed to set sg config: %d", ret);
559 goto out;
560 }
561
562out:
563 kfree(param);
564 return ret;
565}
566
567int wl1271_acx_cca_threshold(struct wl1271 *wl)
568{
569 struct acx_energy_detection *detection;
570 int ret;
571
572 wl1271_debug(DEBUG_ACX, "acx cca threshold");
573
574 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
575 if (!detection) {
576 ret = -ENOMEM;
577 goto out;
578 }
579
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300580 detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
Juuso Oikarinen45b531a2009-10-13 12:47:41 +0300581 detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300582
583 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
584 detection, sizeof(*detection));
Julia Lawallf8afdf42011-08-12 13:31:30 -0400585 if (ret < 0)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300586 wl1271_warning("failed to set cca threshold: %d", ret);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300587
588out:
589 kfree(detection);
590 return ret;
591}
592
Eliad Peller0603d892011-10-05 11:55:51 +0200593int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300594{
595 struct acx_beacon_broadcast *bb;
596 int ret;
597
598 wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
599
600 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
601 if (!bb) {
602 ret = -ENOMEM;
603 goto out;
604 }
605
Eliad Peller0603d892011-10-05 11:55:51 +0200606 bb->role_id = wlvif->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300607 bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
608 bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300609 bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
610 bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300611
612 ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
613 if (ret < 0) {
614 wl1271_warning("failed to set rx config: %d", ret);
615 goto out;
616 }
617
618out:
619 kfree(bb);
620 return ret;
621}
622
Eliad Peller0603d892011-10-05 11:55:51 +0200623int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300624{
625 struct acx_aid *acx_aid;
626 int ret;
627
628 wl1271_debug(DEBUG_ACX, "acx aid");
629
630 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
631 if (!acx_aid) {
632 ret = -ENOMEM;
633 goto out;
634 }
635
Eliad Peller0603d892011-10-05 11:55:51 +0200636 acx_aid->role_id = wlvif->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300637 acx_aid->aid = cpu_to_le16(aid);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300638
639 ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
640 if (ret < 0) {
641 wl1271_warning("failed to set aid: %d", ret);
642 goto out;
643 }
644
645out:
646 kfree(acx_aid);
647 return ret;
648}
649
650int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
651{
652 struct acx_event_mask *mask;
653 int ret;
654
655 wl1271_debug(DEBUG_ACX, "acx event mbox mask");
656
657 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
658 if (!mask) {
659 ret = -ENOMEM;
660 goto out;
661 }
662
663 /* high event mask is unused */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300664 mask->high_event_mask = cpu_to_le32(0xffffffff);
665 mask->event_mask = cpu_to_le32(event_mask);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300666
667 ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
668 mask, sizeof(*mask));
669 if (ret < 0) {
670 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
671 goto out;
672 }
673
674out:
675 kfree(mask);
676 return ret;
677}
678
Eliad Peller0603d892011-10-05 11:55:51 +0200679int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif,
680 enum acx_preamble_type preamble)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300681{
682 struct acx_preamble *acx;
683 int ret;
684
685 wl1271_debug(DEBUG_ACX, "acx_set_preamble");
686
687 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
688 if (!acx) {
689 ret = -ENOMEM;
690 goto out;
691 }
692
Eliad Peller0603d892011-10-05 11:55:51 +0200693 acx->role_id = wlvif->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300694 acx->preamble = preamble;
695
696 ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
697 if (ret < 0) {
698 wl1271_warning("Setting of preamble failed: %d", ret);
699 goto out;
700 }
701
702out:
703 kfree(acx);
704 return ret;
705}
706
Eliad Peller0603d892011-10-05 11:55:51 +0200707int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif,
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300708 enum acx_ctsprotect_type ctsprotect)
709{
710 struct acx_ctsprotect *acx;
711 int ret;
712
713 wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
714
715 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
716 if (!acx) {
717 ret = -ENOMEM;
718 goto out;
719 }
720
Eliad Peller0603d892011-10-05 11:55:51 +0200721 acx->role_id = wlvif->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300722 acx->ctsprotect = ctsprotect;
723
724 ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
725 if (ret < 0) {
726 wl1271_warning("Setting of ctsprotect failed: %d", ret);
727 goto out;
728 }
729
730out:
731 kfree(acx);
732 return ret;
733}
734
735int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
736{
737 int ret;
738
739 wl1271_debug(DEBUG_ACX, "acx statistics");
740
741 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
742 sizeof(*stats));
743 if (ret < 0) {
744 wl1271_warning("acx statistics failed: %d", ret);
745 return -ENOMEM;
746 }
747
748 return 0;
749}
750
Eliad Peller30d0c8f2011-10-05 11:55:42 +0200751int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300752{
Eliad Peller7f0979882011-08-14 13:17:06 +0300753 struct acx_rate_policy *acx;
Arik Nemtsov1e05a812010-10-16 17:44:51 +0200754 struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300755 int ret = 0;
756
757 wl1271_debug(DEBUG_ACX, "acx rate policies");
758
759 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
760
761 if (!acx) {
762 ret = -ENOMEM;
763 goto out;
764 }
765
Eliad Peller7f0979882011-08-14 13:17:06 +0300766 wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
Eliad Pellerd2d66c52011-10-05 11:55:43 +0200767 wlvif->basic_rate, wlvif->rate_set);
Eliad Peller7f0979882011-08-14 13:17:06 +0300768
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200769 /* configure one basic rate class */
Eliad Pellere5a359f2011-10-10 10:13:15 +0200770 acx->rate_policy_idx = cpu_to_le32(wlvif->sta.basic_rate_idx);
Eliad Pellerd2d66c52011-10-05 11:55:43 +0200771 acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->basic_rate);
Eliad Peller7f0979882011-08-14 13:17:06 +0300772 acx->rate_policy.short_retry_limit = c->short_retry_limit;
773 acx->rate_policy.long_retry_limit = c->long_retry_limit;
774 acx->rate_policy.aflags = c->aflags;
775
776 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
777 if (ret < 0) {
778 wl1271_warning("Setting of rate policies failed: %d", ret);
779 goto out;
780 }
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200781
782 /* configure one AP supported rate class */
Eliad Pellere5a359f2011-10-10 10:13:15 +0200783 acx->rate_policy_idx = cpu_to_le32(wlvif->sta.ap_rate_idx);
Eliad Peller30d0c8f2011-10-05 11:55:42 +0200784 acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set);
Eliad Peller7f0979882011-08-14 13:17:06 +0300785 acx->rate_policy.short_retry_limit = c->short_retry_limit;
786 acx->rate_policy.long_retry_limit = c->long_retry_limit;
787 acx->rate_policy.aflags = c->aflags;
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200788
Eliad Peller4b298862011-10-03 12:06:36 +0200789 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
790 if (ret < 0) {
791 wl1271_warning("Setting of rate policies failed: %d", ret);
792 goto out;
793 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300794
Eliad Peller4b298862011-10-03 12:06:36 +0200795 /*
796 * configure one rate class for basic p2p operations.
797 * (p2p packets should always go out with OFDM rates, even
798 * if we are currently connected to 11b AP)
799 */
Eliad Pellere5a359f2011-10-10 10:13:15 +0200800 acx->rate_policy_idx = cpu_to_le32(wlvif->sta.p2p_rate_idx);
Eliad Peller4b298862011-10-03 12:06:36 +0200801 acx->rate_policy.enabled_rates =
802 cpu_to_le32(CONF_TX_RATE_MASK_BASIC_P2P);
803 acx->rate_policy.short_retry_limit = c->short_retry_limit;
804 acx->rate_policy.long_retry_limit = c->long_retry_limit;
805 acx->rate_policy.aflags = c->aflags;
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200806
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300807 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
808 if (ret < 0) {
809 wl1271_warning("Setting of rate policies failed: %d", ret);
810 goto out;
811 }
812
813out:
814 kfree(acx);
815 return ret;
816}
817
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200818int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
819 u8 idx)
820{
Eliad Peller7f0979882011-08-14 13:17:06 +0300821 struct acx_rate_policy *acx;
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200822 int ret = 0;
823
Arik Nemtsov70f47422011-04-18 14:15:25 +0300824 wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
825 idx, c->enabled_rates);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200826
827 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
828 if (!acx) {
829 ret = -ENOMEM;
830 goto out;
831 }
832
833 acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
834 acx->rate_policy.short_retry_limit = c->short_retry_limit;
835 acx->rate_policy.long_retry_limit = c->long_retry_limit;
836 acx->rate_policy.aflags = c->aflags;
837
Eliad Peller1d4801f2011-01-16 10:07:10 +0100838 acx->rate_policy_idx = cpu_to_le32(idx);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200839
840 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
841 if (ret < 0) {
842 wl1271_warning("Setting of ap rate policy failed: %d", ret);
843 goto out;
844 }
845
846out:
847 kfree(acx);
848 return ret;
849}
850
Eliad Peller0603d892011-10-05 11:55:51 +0200851int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif,
852 u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300853{
854 struct acx_ac_cfg *acx;
Kalle Valo243eeb52010-02-18 13:25:39 +0200855 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300856
Kalle Valo243eeb52010-02-18 13:25:39 +0200857 wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
858 "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300859
860 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
861
862 if (!acx) {
863 ret = -ENOMEM;
864 goto out;
865 }
866
Eliad Peller0603d892011-10-05 11:55:51 +0200867 acx->role_id = wlvif->role_id;
Kalle Valo243eeb52010-02-18 13:25:39 +0200868 acx->ac = ac;
869 acx->cw_min = cw_min;
870 acx->cw_max = cpu_to_le16(cw_max);
871 acx->aifsn = aifsn;
872 acx->tx_op_limit = cpu_to_le16(txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300873
Kalle Valo243eeb52010-02-18 13:25:39 +0200874 ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
875 if (ret < 0) {
876 wl1271_warning("acx ac cfg failed: %d", ret);
877 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300878 }
879
880out:
881 kfree(acx);
882 return ret;
883}
884
Eliad Peller0603d892011-10-05 11:55:51 +0200885int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif,
886 u8 queue_id, u8 channel_type,
Kalle Valof2054df2010-02-18 13:25:40 +0200887 u8 tsid, u8 ps_scheme, u8 ack_policy,
888 u32 apsd_conf0, u32 apsd_conf1)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300889{
890 struct acx_tid_config *acx;
Kalle Valof2054df2010-02-18 13:25:40 +0200891 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300892
893 wl1271_debug(DEBUG_ACX, "acx tid config");
894
895 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
896
897 if (!acx) {
898 ret = -ENOMEM;
899 goto out;
900 }
901
Eliad Peller0603d892011-10-05 11:55:51 +0200902 acx->role_id = wlvif->role_id;
Kalle Valof2054df2010-02-18 13:25:40 +0200903 acx->queue_id = queue_id;
904 acx->channel_type = channel_type;
905 acx->tsid = tsid;
906 acx->ps_scheme = ps_scheme;
907 acx->ack_policy = ack_policy;
908 acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
909 acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300910
Kalle Valof2054df2010-02-18 13:25:40 +0200911 ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
912 if (ret < 0) {
913 wl1271_warning("Setting of tid config failed: %d", ret);
914 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300915 }
916
917out:
918 kfree(acx);
919 return ret;
920}
921
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300922int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300923{
924 struct acx_frag_threshold *acx;
925 int ret = 0;
926
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300927 /*
928 * If the fragmentation is not configured or out of range, use the
929 * default value.
930 */
931 if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
932 frag_threshold = wl->conf.tx.frag_threshold;
933
934 wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300935
936 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
937
938 if (!acx) {
939 ret = -ENOMEM;
940 goto out;
941 }
942
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300943 acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300944 ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
945 if (ret < 0) {
946 wl1271_warning("Setting of frag threshold failed: %d", ret);
947 goto out;
948 }
949
950out:
951 kfree(acx);
952 return ret;
953}
954
955int wl1271_acx_tx_config_options(struct wl1271 *wl)
956{
957 struct acx_tx_config_options *acx;
958 int ret = 0;
959
960 wl1271_debug(DEBUG_ACX, "acx tx config options");
961
962 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
963
964 if (!acx) {
965 ret = -ENOMEM;
966 goto out;
967 }
968
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300969 acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
970 acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300971 ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
972 if (ret < 0) {
973 wl1271_warning("Setting of tx options failed: %d", ret);
974 goto out;
975 }
976
977out:
978 kfree(acx);
979 return ret;
980}
981
Eliad Peller7f0979882011-08-14 13:17:06 +0300982int wl12xx_acx_mem_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300983{
Eliad Peller7f0979882011-08-14 13:17:06 +0300984 struct wl12xx_acx_config_memory *mem_conf;
Shahar Levi13b107d2011-03-06 16:32:12 +0200985 struct conf_memory_settings *mem;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200986 int ret;
987
988 wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
989
990 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
991 if (!mem_conf) {
992 ret = -ENOMEM;
993 goto out;
994 }
995
Shahar Levi13b107d2011-03-06 16:32:12 +0200996 if (wl->chip.id == CHIP_ID_1283_PG20)
997 mem = &wl->conf.mem_wl128x;
998 else
999 mem = &wl->conf.mem_wl127x;
1000
Eliad Pellerc8bde242011-02-02 09:59:35 +02001001 /* memory config */
Shahar Levi13b107d2011-03-06 16:32:12 +02001002 mem_conf->num_stations = mem->num_stations;
1003 mem_conf->rx_mem_block_num = mem->rx_block_num;
1004 mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
1005 mem_conf->num_ssid_profiles = mem->ssid_profiles;
Eliad Pellerc8bde242011-02-02 09:59:35 +02001006 mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
Shahar Levi13b107d2011-03-06 16:32:12 +02001007 mem_conf->dyn_mem_enable = mem->dynamic_memory;
1008 mem_conf->tx_free_req = mem->min_req_tx_blocks;
1009 mem_conf->rx_free_req = mem->min_req_rx_blocks;
1010 mem_conf->tx_min = mem->tx_min;
Ido Yariv95dac04f2011-06-06 14:57:06 +03001011 mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks;
Eliad Pellerc8bde242011-02-02 09:59:35 +02001012
1013 ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
1014 sizeof(*mem_conf));
1015 if (ret < 0) {
1016 wl1271_warning("wl1271 mem config failed: %d", ret);
1017 goto out;
1018 }
1019
1020out:
1021 kfree(mem_conf);
1022 return ret;
1023}
1024
Shahar Levi48a61472011-03-06 16:32:08 +02001025int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
1026{
1027 struct wl1271_acx_host_config_bitmap *bitmap_conf;
1028 int ret;
1029
1030 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
1031 if (!bitmap_conf) {
1032 ret = -ENOMEM;
1033 goto out;
1034 }
1035
1036 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
1037
1038 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
1039 bitmap_conf, sizeof(*bitmap_conf));
1040 if (ret < 0) {
1041 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
1042 goto out;
1043 }
1044
1045out:
1046 kfree(bitmap_conf);
1047
1048 return ret;
1049}
1050
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001051int wl1271_acx_init_mem_config(struct wl1271 *wl)
1052{
1053 int ret;
1054
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001055 wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
Juuso Oikarinen45b531a2009-10-13 12:47:41 +03001056 GFP_KERNEL);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001057 if (!wl->target_mem_map) {
1058 wl1271_error("couldn't allocate target memory map");
1059 return -ENOMEM;
1060 }
1061
1062 /* we now ask for the firmware built memory map */
1063 ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
1064 sizeof(struct wl1271_acx_mem_map));
1065 if (ret < 0) {
1066 wl1271_error("couldn't retrieve firmware memory map");
1067 kfree(wl->target_mem_map);
1068 wl->target_mem_map = NULL;
1069 return ret;
1070 }
1071
1072 /* initialize TX block book keeping */
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001073 wl->tx_blocks_available =
1074 le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001075 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1076 wl->tx_blocks_available);
1077
1078 return 0;
1079}
1080
1081int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
1082{
1083 struct wl1271_acx_rx_config_opt *rx_conf;
1084 int ret;
1085
1086 wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
1087
1088 rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
1089 if (!rx_conf) {
1090 ret = -ENOMEM;
1091 goto out;
1092 }
1093
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001094 rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
1095 rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
1096 rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +03001097 rx_conf->queue_type = wl->conf.rx.queue_type;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001098
1099 ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
1100 sizeof(*rx_conf));
1101 if (ret < 0) {
1102 wl1271_warning("wl1271 rx config opt failed: %d", ret);
1103 goto out;
1104 }
1105
1106out:
1107 kfree(rx_conf);
1108 return ret;
1109}
Juuso Oikarinen3cfd6cf2009-10-12 15:08:52 +03001110
Eliad Peller0603d892011-10-05 11:55:51 +02001111int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1112 bool enable)
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001113{
1114 struct wl1271_acx_bet_enable *acx = NULL;
1115 int ret = 0;
1116
1117 wl1271_debug(DEBUG_ACX, "acx bet enable");
1118
1119 if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
1120 goto out;
1121
1122 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1123 if (!acx) {
1124 ret = -ENOMEM;
1125 goto out;
1126 }
1127
Eliad Peller0603d892011-10-05 11:55:51 +02001128 acx->role_id = wlvif->role_id;
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001129 acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
1130 acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
1131
1132 ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
1133 if (ret < 0) {
1134 wl1271_warning("acx bet enable failed: %d", ret);
1135 goto out;
1136 }
1137
1138out:
1139 kfree(acx);
1140 return ret;
1141}
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001142
Eliad Peller0603d892011-10-05 11:55:51 +02001143int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1144 u8 enable, __be32 address)
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001145{
1146 struct wl1271_acx_arp_filter *acx;
1147 int ret;
1148
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001149 wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001150
1151 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1152 if (!acx) {
1153 ret = -ENOMEM;
1154 goto out;
1155 }
1156
Eliad Peller0603d892011-10-05 11:55:51 +02001157 acx->role_id = wlvif->role_id;
Juuso Oikarineneb887df2010-07-08 17:49:58 +03001158 acx->version = ACX_IPV4_VERSION;
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001159 acx->enable = enable;
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001160
Eliad Pellerc5312772010-12-09 11:31:27 +02001161 if (enable)
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001162 memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001163
1164 ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
1165 acx, sizeof(*acx));
1166 if (ret < 0) {
1167 wl1271_warning("failed to set arp ip filter: %d", ret);
1168 goto out;
1169 }
1170
1171out:
1172 kfree(acx);
1173 return ret;
1174}
Juuso Oikarinen38ad2d82009-12-11 15:41:08 +02001175
1176int wl1271_acx_pm_config(struct wl1271 *wl)
1177{
1178 struct wl1271_acx_pm_config *acx = NULL;
1179 struct conf_pm_config_settings *c = &wl->conf.pm_config;
1180 int ret = 0;
1181
1182 wl1271_debug(DEBUG_ACX, "acx pm config");
1183
1184 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1185 if (!acx) {
1186 ret = -ENOMEM;
1187 goto out;
1188 }
1189
1190 acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
1191 acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
1192
1193 ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
1194 if (ret < 0) {
1195 wl1271_warning("acx pm config failed: %d", ret);
1196 goto out;
1197 }
1198
1199out:
1200 kfree(acx);
1201 return ret;
1202}
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001203
Eliad Peller0603d892011-10-05 11:55:51 +02001204int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1205 bool enable)
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001206{
1207 struct wl1271_acx_keep_alive_mode *acx = NULL;
1208 int ret = 0;
1209
1210 wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
1211
1212 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1213 if (!acx) {
1214 ret = -ENOMEM;
1215 goto out;
1216 }
1217
Eliad Peller0603d892011-10-05 11:55:51 +02001218 acx->role_id = wlvif->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001219 acx->enabled = enable;
1220
1221 ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
1222 if (ret < 0) {
1223 wl1271_warning("acx keep alive mode failed: %d", ret);
1224 goto out;
1225 }
1226
1227out:
1228 kfree(acx);
1229 return ret;
1230}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001231
Eliad Peller0603d892011-10-05 11:55:51 +02001232int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1233 u8 index, u8 tpl_valid)
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001234{
1235 struct wl1271_acx_keep_alive_config *acx = NULL;
1236 int ret = 0;
1237
1238 wl1271_debug(DEBUG_ACX, "acx keep alive config");
1239
1240 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1241 if (!acx) {
1242 ret = -ENOMEM;
1243 goto out;
1244 }
1245
Eliad Peller0603d892011-10-05 11:55:51 +02001246 acx->role_id = wlvif->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001247 acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
1248 acx->index = index;
1249 acx->tpl_validation = tpl_valid;
1250 acx->trigger = ACX_KEEP_ALIVE_NO_TX;
1251
1252 ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
1253 acx, sizeof(*acx));
1254 if (ret < 0) {
1255 wl1271_warning("acx keep alive config failed: %d", ret);
1256 goto out;
1257 }
1258
1259out:
1260 kfree(acx);
1261 return ret;
1262}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001263
Eliad Peller0603d892011-10-05 11:55:51 +02001264int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1265 bool enable, s16 thold, u8 hyst)
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001266{
1267 struct wl1271_acx_rssi_snr_trigger *acx = NULL;
1268 int ret = 0;
1269
1270 wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
1271
1272 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1273 if (!acx) {
1274 ret = -ENOMEM;
1275 goto out;
1276 }
1277
Eliad Peller04324d92011-10-05 11:56:03 +02001278 wlvif->last_rssi_event = -1;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001279
Eliad Peller0603d892011-10-05 11:55:51 +02001280 acx->role_id = wlvif->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001281 acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
1282 acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
1283 acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
1284 if (enable)
1285 acx->enable = WL1271_ACX_TRIG_ENABLE;
1286 else
1287 acx->enable = WL1271_ACX_TRIG_DISABLE;
1288
1289 acx->index = WL1271_ACX_TRIG_IDX_RSSI;
1290 acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
1291 acx->threshold = cpu_to_le16(thold);
1292 acx->hysteresis = hyst;
1293
1294 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
1295 if (ret < 0) {
1296 wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
1297 goto out;
1298 }
1299
1300out:
1301 kfree(acx);
1302 return ret;
1303}
1304
Eliad Peller0603d892011-10-05 11:55:51 +02001305int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl,
1306 struct wl12xx_vif *wlvif)
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001307{
1308 struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
1309 struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
1310 int ret = 0;
1311
1312 wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
1313
1314 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1315 if (!acx) {
1316 ret = -ENOMEM;
1317 goto out;
1318 }
1319
Eliad Peller0603d892011-10-05 11:55:51 +02001320 acx->role_id = wlvif->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001321 acx->rssi_beacon = c->avg_weight_rssi_beacon;
1322 acx->rssi_data = c->avg_weight_rssi_data;
1323 acx->snr_beacon = c->avg_weight_snr_beacon;
1324 acx->snr_data = c->avg_weight_snr_data;
1325
1326 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
1327 if (ret < 0) {
1328 wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
1329 goto out;
1330 }
1331
1332out:
1333 kfree(acx);
1334 return ret;
1335}
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001336
Shahar Levic4db1c82010-10-13 16:09:40 +02001337int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
1338 struct ieee80211_sta_ht_cap *ht_cap,
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001339 bool allow_ht_operation, u8 hlid)
Shahar Levic4db1c82010-10-13 16:09:40 +02001340{
1341 struct wl1271_acx_ht_capabilities *acx;
Shahar Levic4db1c82010-10-13 16:09:40 +02001342 int ret = 0;
Eliad Peller6177eae2010-12-22 12:38:52 +01001343 u32 ht_capabilites = 0;
Shahar Levic4db1c82010-10-13 16:09:40 +02001344
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001345 wl1271_debug(DEBUG_ACX, "acx ht capabilities setting "
1346 "sta supp: %d sta cap: %d", ht_cap->ht_supported,
1347 ht_cap->cap);
Shahar Levic4db1c82010-10-13 16:09:40 +02001348
1349 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1350 if (!acx) {
1351 ret = -ENOMEM;
1352 goto out;
1353 }
1354
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001355 if (allow_ht_operation && ht_cap->ht_supported) {
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001356 /* no need to translate capabilities - use the spec values */
1357 ht_capabilites = ht_cap->cap;
1358
1359 /*
1360 * this bit is not employed by the spec but only by FW to
1361 * indicate peer HT support
1362 */
1363 ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
Shahar Levic4db1c82010-10-13 16:09:40 +02001364
1365 /* get data from A-MPDU parameters field */
1366 acx->ampdu_max_length = ht_cap->ampdu_factor;
1367 acx->ampdu_min_spacing = ht_cap->ampdu_density;
Shahar Levic4db1c82010-10-13 16:09:40 +02001368 }
1369
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001370 acx->hlid = hlid;
Eliad Peller6177eae2010-12-22 12:38:52 +01001371 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
1372
Shahar Levic4db1c82010-10-13 16:09:40 +02001373 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
1374 if (ret < 0) {
1375 wl1271_warning("acx ht capabilities setting failed: %d", ret);
1376 goto out;
1377 }
1378
1379out:
1380 kfree(acx);
1381 return ret;
1382}
1383
1384int wl1271_acx_set_ht_information(struct wl1271 *wl,
Eliad Peller0603d892011-10-05 11:55:51 +02001385 struct wl12xx_vif *wlvif,
Shahar Levic4db1c82010-10-13 16:09:40 +02001386 u16 ht_operation_mode)
1387{
1388 struct wl1271_acx_ht_information *acx;
1389 int ret = 0;
1390
1391 wl1271_debug(DEBUG_ACX, "acx ht information setting");
1392
1393 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1394 if (!acx) {
1395 ret = -ENOMEM;
1396 goto out;
1397 }
1398
Eliad Peller0603d892011-10-05 11:55:51 +02001399 acx->role_id = wlvif->role_id;
Shahar Levic4db1c82010-10-13 16:09:40 +02001400 acx->ht_protection =
1401 (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
1402 acx->rifs_mode = 0;
Helmut Schaa95a77612011-03-02 10:46:46 +01001403 acx->gf_protection =
1404 !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
Shahar Levic4db1c82010-10-13 16:09:40 +02001405 acx->ht_tx_burst_limit = 0;
1406 acx->dual_cts_protection = 0;
1407
1408 ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
1409
1410 if (ret < 0) {
1411 wl1271_warning("acx ht information setting failed: %d", ret);
1412 goto out;
1413 }
1414
1415out:
1416 kfree(acx);
1417 return ret;
1418}
1419
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001420/* Configure BA session initiator/receiver parameters setting in the FW. */
Eliad Peller0603d892011-10-05 11:55:51 +02001421int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl,
1422 struct wl12xx_vif *wlvif)
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001423{
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001424 struct wl1271_acx_ba_initiator_policy *acx;
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001425 int ret;
1426
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001427 wl1271_debug(DEBUG_ACX, "acx ba initiator policy");
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001428
1429 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1430 if (!acx) {
1431 ret = -ENOMEM;
1432 goto out;
1433 }
1434
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001435 /* set for the current role */
Eliad Peller0603d892011-10-05 11:55:51 +02001436 acx->role_id = wlvif->role_id;
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001437 acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap;
1438 acx->win_size = wl->conf.ht.tx_ba_win_size;
1439 acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001440
1441 ret = wl1271_cmd_configure(wl,
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001442 ACX_BA_SESSION_INIT_POLICY,
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001443 acx,
1444 sizeof(*acx));
1445 if (ret < 0) {
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001446 wl1271_warning("acx ba initiator policy failed: %d", ret);
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001447 goto out;
1448 }
1449
1450out:
1451 kfree(acx);
1452 return ret;
1453}
1454
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001455/* setup BA session receiver setting in the FW. */
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001456int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index,
1457 u16 ssn, bool enable, u8 peer_hlid)
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001458{
1459 struct wl1271_acx_ba_receiver_setup *acx;
1460 int ret;
1461
1462 wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
1463
1464 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1465 if (!acx) {
1466 ret = -ENOMEM;
1467 goto out;
1468 }
1469
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001470 acx->hlid = peer_hlid;
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001471 acx->tid = tid_index;
1472 acx->enable = enable;
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001473 acx->win_size = wl->conf.ht.rx_ba_win_size;
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001474 acx->ssn = ssn;
1475
1476 ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
1477 sizeof(*acx));
1478 if (ret < 0) {
1479 wl1271_warning("acx ba receiver session failed: %d", ret);
1480 goto out;
1481 }
1482
1483out:
1484 kfree(acx);
1485 return ret;
1486}
1487
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001488int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
1489{
1490 struct wl1271_acx_fw_tsf_information *tsf_info;
1491 int ret;
1492
1493 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
1494 if (!tsf_info) {
1495 ret = -ENOMEM;
1496 goto out;
1497 }
1498
1499 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
1500 tsf_info, sizeof(*tsf_info));
1501 if (ret < 0) {
1502 wl1271_warning("acx tsf info interrogate failed");
1503 goto out;
1504 }
1505
1506 *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
1507 ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
1508
1509out:
1510 kfree(tsf_info);
1511 return ret;
1512}
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001513
Eliad Peller9eb599e2011-10-10 10:12:59 +02001514int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1515 bool enable)
Eliad Pellerf84673d2011-05-15 11:10:28 +03001516{
1517 struct wl1271_acx_ps_rx_streaming *rx_streaming;
1518 u32 conf_queues, enable_queues;
1519 int i, ret = 0;
1520
1521 wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
1522
1523 rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
1524 if (!rx_streaming) {
1525 ret = -ENOMEM;
1526 goto out;
1527 }
1528
1529 conf_queues = wl->conf.rx_streaming.queues;
1530 if (enable)
1531 enable_queues = conf_queues;
1532 else
1533 enable_queues = 0;
1534
1535 for (i = 0; i < 8; i++) {
1536 /*
1537 * Skip non-changed queues, to avoid redundant acxs.
1538 * this check assumes conf.rx_streaming.queues can't
1539 * be changed while rx_streaming is enabled.
1540 */
1541 if (!(conf_queues & BIT(i)))
1542 continue;
1543
Eliad Peller0603d892011-10-05 11:55:51 +02001544 rx_streaming->role_id = wlvif->role_id;
Eliad Pellerf84673d2011-05-15 11:10:28 +03001545 rx_streaming->tid = i;
1546 rx_streaming->enable = enable_queues & BIT(i);
1547 rx_streaming->period = wl->conf.rx_streaming.interval;
1548 rx_streaming->timeout = wl->conf.rx_streaming.interval;
1549
1550 ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
1551 rx_streaming,
1552 sizeof(*rx_streaming));
1553 if (ret < 0) {
1554 wl1271_warning("acx ps rx streaming failed: %d", ret);
1555 goto out;
1556 }
1557 }
1558out:
1559 kfree(rx_streaming);
1560 return ret;
1561}
1562
Eliad Peller0603d892011-10-05 11:55:51 +02001563int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001564{
Arik Nemtsov3618f302011-06-26 10:36:03 +03001565 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001566 int ret;
1567
Arik Nemtsov3618f302011-06-26 10:36:03 +03001568 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001569
1570 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1571 if (!acx)
1572 return -ENOMEM;
1573
Eliad Peller0603d892011-10-05 11:55:51 +02001574 acx->role_id = wlvif->role_id;
Arik Nemtsov3618f302011-06-26 10:36:03 +03001575 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001576
1577 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1578 if (ret < 0) {
Arik Nemtsov3618f302011-06-26 10:36:03 +03001579 wl1271_warning("acx ap max tx retry failed: %d", ret);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001580 goto out;
1581 }
1582
1583out:
1584 kfree(acx);
1585 return ret;
1586}
Eliad Pelleree608332011-02-02 09:59:34 +02001587
Eliad Pellerd2d66c52011-10-05 11:55:43 +02001588int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif)
Eliad Pelleree608332011-02-02 09:59:34 +02001589{
1590 struct wl1271_acx_config_ps *config_ps;
1591 int ret;
1592
1593 wl1271_debug(DEBUG_ACX, "acx config ps");
1594
1595 config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
1596 if (!config_ps) {
1597 ret = -ENOMEM;
1598 goto out;
1599 }
1600
1601 config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
1602 config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
Eliad Pellerd2d66c52011-10-05 11:55:43 +02001603 config_ps->null_data_rate = cpu_to_le32(wlvif->basic_rate);
Eliad Pelleree608332011-02-02 09:59:34 +02001604
1605 ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
1606 sizeof(*config_ps));
1607
1608 if (ret < 0) {
1609 wl1271_warning("acx config ps failed: %d", ret);
1610 goto out;
1611 }
1612
1613out:
1614 kfree(config_ps);
1615 return ret;
1616}
Arik Nemtsov99a27752011-02-23 00:22:25 +02001617
1618int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
1619{
1620 struct wl1271_acx_inconnection_sta *acx = NULL;
1621 int ret;
1622
1623 wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
1624
1625 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1626 if (!acx)
1627 return -ENOMEM;
1628
1629 memcpy(acx->addr, addr, ETH_ALEN);
1630
1631 ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
1632 acx, sizeof(*acx));
1633 if (ret < 0) {
1634 wl1271_warning("acx set inconnaction sta failed: %d", ret);
1635 goto out;
1636 }
1637
1638out:
1639 kfree(acx);
1640 return ret;
1641}
Shahar Leviff868432011-04-11 15:41:46 +03001642
1643int wl1271_acx_fm_coex(struct wl1271 *wl)
1644{
1645 struct wl1271_acx_fm_coex *acx;
1646 int ret;
1647
1648 wl1271_debug(DEBUG_ACX, "acx fm coex setting");
1649
1650 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1651 if (!acx) {
1652 ret = -ENOMEM;
1653 goto out;
1654 }
1655
1656 acx->enable = wl->conf.fm_coex.enable;
1657 acx->swallow_period = wl->conf.fm_coex.swallow_period;
1658 acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
1659 acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
1660 acx->m_divider_fref_set_1 =
1661 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
1662 acx->m_divider_fref_set_2 =
1663 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
1664 acx->coex_pll_stabilization_time =
1665 cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
1666 acx->ldo_stabilization_time =
1667 cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
1668 acx->fm_disturbed_band_margin =
1669 wl->conf.fm_coex.fm_disturbed_band_margin;
1670 acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
1671
1672 ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
1673 if (ret < 0) {
1674 wl1271_warning("acx fm coex setting failed: %d", ret);
1675 goto out;
1676 }
1677
1678out:
1679 kfree(acx);
1680 return ret;
1681}
Eliad Pellerfa6ad9f2011-08-14 13:17:14 +03001682
1683int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
1684{
1685 struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
1686 struct conf_rate_policy_settings *conf = &wl->conf.rate;
1687 int ret;
1688
1689 wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
1690
1691 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1692 if (!acx)
1693 return -ENOMEM;
1694
1695 acx->index = ACX_RATE_MGMT_ALL_PARAMS;
1696 acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
1697 acx->per_add = cpu_to_le16(conf->per_add);
1698 acx->per_th1 = cpu_to_le16(conf->per_th1);
1699 acx->per_th2 = cpu_to_le16(conf->per_th2);
1700 acx->max_per = cpu_to_le16(conf->max_per);
1701 acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
1702 acx->tx_fail_low_th = conf->tx_fail_low_th;
1703 acx->tx_fail_high_th = conf->tx_fail_high_th;
1704 acx->per_alpha_shift = conf->per_alpha_shift;
1705 acx->per_add_shift = conf->per_add_shift;
1706 acx->per_beta1_shift = conf->per_beta1_shift;
1707 acx->per_beta2_shift = conf->per_beta2_shift;
1708 acx->rate_check_up = conf->rate_check_up;
1709 acx->rate_check_down = conf->rate_check_down;
1710 memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
1711 sizeof(acx->rate_retry_policy));
1712
1713 ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
1714 acx, sizeof(*acx));
1715 if (ret < 0) {
1716 wl1271_warning("acx set rate mgmt params failed: %d", ret);
1717 goto out;
1718 }
1719
1720out:
1721 kfree(acx);
1722 return ret;
1723}
Eliad Peller94877752011-08-28 15:11:56 +03001724
1725int wl12xx_acx_config_hangover(struct wl1271 *wl)
1726{
1727 struct wl12xx_acx_config_hangover *acx;
1728 struct conf_hangover_settings *conf = &wl->conf.hangover;
1729 int ret;
1730
1731 wl1271_debug(DEBUG_ACX, "acx config hangover");
1732
1733 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1734 if (!acx) {
1735 ret = -ENOMEM;
1736 goto out;
1737 }
1738
1739 acx->recover_time = cpu_to_le32(conf->recover_time);
1740 acx->hangover_period = conf->hangover_period;
1741 acx->dynamic_mode = conf->dynamic_mode;
1742 acx->early_termination_mode = conf->early_termination_mode;
1743 acx->max_period = conf->max_period;
1744 acx->min_period = conf->min_period;
1745 acx->increase_delta = conf->increase_delta;
1746 acx->decrease_delta = conf->decrease_delta;
1747 acx->quiet_time = conf->quiet_time;
1748 acx->increase_time = conf->increase_time;
1749 acx->window_size = acx->window_size;
1750
1751 ret = wl1271_cmd_configure(wl, ACX_CONFIG_HANGOVER, acx,
1752 sizeof(*acx));
1753
1754 if (ret < 0) {
1755 wl1271_warning("acx config hangover failed: %d", ret);
1756 goto out;
1757 }
1758
1759out:
1760 kfree(acx);
1761 return ret;
1762
1763}