blob: 399849eeb247cd3014d3827654b14e28dbeaa184 [file] [log] [blame]
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 2008-2009 Nokia Corporation
5 *
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
Shahar Levi00d20102010-11-08 11:20:10 +000024#include "acx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030025
26#include <linux/module.h>
27#include <linux/platform_device.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030028#include <linux/spi/spi.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030030
Shahar Levi00d20102010-11-08 11:20:10 +000031#include "wl12xx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030032#include "wl12xx_80211.h"
Shahar Levi00d20102010-11-08 11:20:10 +000033#include "reg.h"
34#include "ps.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030035
Juuso Oikarinen51f2be22009-10-13 12:47:42 +030036int wl1271_acx_wake_up_conditions(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030037{
38 struct acx_wake_up_condition *wake_up;
39 int ret;
40
41 wl1271_debug(DEBUG_ACX, "acx wake up conditions");
42
43 wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
44 if (!wake_up) {
45 ret = -ENOMEM;
46 goto out;
47 }
48
Eliad Peller7f0979882011-08-14 13:17:06 +030049 wake_up->role_id = wl->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +030050 wake_up->wake_up_event = wl->conf.conn.wake_up_event;
51 wake_up->listen_interval = wl->conf.conn.listen_interval;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030052
53 ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
54 wake_up, sizeof(*wake_up));
55 if (ret < 0) {
56 wl1271_warning("could not set wake up conditions: %d", ret);
57 goto out;
58 }
59
60out:
61 kfree(wake_up);
62 return ret;
63}
64
65int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
66{
67 struct acx_sleep_auth *auth;
68 int ret;
69
70 wl1271_debug(DEBUG_ACX, "acx sleep auth");
71
72 auth = kzalloc(sizeof(*auth), GFP_KERNEL);
73 if (!auth) {
74 ret = -ENOMEM;
75 goto out;
76 }
77
78 auth->sleep_auth = sleep_auth;
79
80 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030081
82out:
83 kfree(auth);
84 return ret;
85}
86
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030087int wl1271_acx_tx_power(struct wl1271 *wl, int power)
88{
89 struct acx_current_tx_power *acx;
90 int ret;
91
Arik Nemtsov097f8822011-06-27 22:06:34 +030092 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030093
94 if (power < 0 || power > 25)
95 return -EINVAL;
96
97 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
98 if (!acx) {
99 ret = -ENOMEM;
100 goto out;
101 }
102
Eliad Peller7f0979882011-08-14 13:17:06 +0300103 acx->role_id = wl->role_id;
Juuso Oikarinen6f6b5d42010-02-22 08:38:42 +0200104 acx->current_tx_power = power * 10;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300105
106 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
107 if (ret < 0) {
108 wl1271_warning("configure of tx power failed: %d", ret);
109 goto out;
110 }
111
112out:
113 kfree(acx);
114 return ret;
115}
116
117int wl1271_acx_feature_cfg(struct wl1271 *wl)
118{
119 struct acx_feature_config *feature;
120 int ret;
121
122 wl1271_debug(DEBUG_ACX, "acx feature cfg");
123
124 feature = kzalloc(sizeof(*feature), GFP_KERNEL);
125 if (!feature) {
126 ret = -ENOMEM;
127 goto out;
128 }
129
130 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
Eliad Peller7f0979882011-08-14 13:17:06 +0300131 feature->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300132 feature->data_flow_options = 0;
133 feature->options = 0;
134
135 ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
136 feature, sizeof(*feature));
137 if (ret < 0) {
138 wl1271_error("Couldnt set HW encryption");
139 goto out;
140 }
141
142out:
143 kfree(feature);
144 return ret;
145}
146
147int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
148 size_t len)
149{
150 int ret;
151
152 wl1271_debug(DEBUG_ACX, "acx mem map");
153
154 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
155 if (ret < 0)
156 return ret;
157
158 return 0;
159}
160
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +0300161int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300162{
163 struct acx_rx_msdu_lifetime *acx;
164 int ret;
165
166 wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
167
168 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
169 if (!acx) {
170 ret = -ENOMEM;
171 goto out;
172 }
173
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300174 acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300175 ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
176 acx, sizeof(*acx));
177 if (ret < 0) {
178 wl1271_warning("failed to set rx msdu life time: %d", ret);
179 goto out;
180 }
181
182out:
183 kfree(acx);
184 return ret;
185}
186
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300187int wl1271_acx_pd_threshold(struct wl1271 *wl)
188{
189 struct acx_packet_detection *pd;
190 int ret;
191
192 wl1271_debug(DEBUG_ACX, "acx data pd threshold");
193
194 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
195 if (!pd) {
196 ret = -ENOMEM;
197 goto out;
198 }
199
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300200 pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300201
202 ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
203 if (ret < 0) {
204 wl1271_warning("failed to set pd threshold: %d", ret);
205 goto out;
206 }
207
208out:
209 kfree(pd);
Julia Lawall36d34412010-08-16 18:27:30 +0200210 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300211}
212
213int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time)
214{
215 struct acx_slot *slot;
216 int ret;
217
218 wl1271_debug(DEBUG_ACX, "acx slot");
219
220 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
221 if (!slot) {
222 ret = -ENOMEM;
223 goto out;
224 }
225
Eliad Peller7f0979882011-08-14 13:17:06 +0300226 slot->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300227 slot->wone_index = STATION_WONE_INDEX;
228 slot->slot_time = slot_time;
229
230 ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
231 if (ret < 0) {
232 wl1271_warning("failed to set slot time: %d", ret);
233 goto out;
234 }
235
236out:
237 kfree(slot);
238 return ret;
239}
240
Juuso Oikarinenc87dec92009-10-08 21:56:31 +0300241int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable,
242 void *mc_list, u32 mc_list_len)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300243{
244 struct acx_dot11_grp_addr_tbl *acx;
245 int ret;
246
247 wl1271_debug(DEBUG_ACX, "acx group address tbl");
248
249 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
250 if (!acx) {
251 ret = -ENOMEM;
252 goto out;
253 }
254
255 /* MAC filtering */
Eliad Peller7f0979882011-08-14 13:17:06 +0300256 acx->role_id = wl->role_id;
Juuso Oikarinenc87dec92009-10-08 21:56:31 +0300257 acx->enabled = enable;
258 acx->num_groups = mc_list_len;
259 memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300260
261 ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
262 acx, sizeof(*acx));
263 if (ret < 0) {
264 wl1271_warning("failed to set group addr table: %d", ret);
265 goto out;
266 }
267
268out:
269 kfree(acx);
270 return ret;
271}
272
273int wl1271_acx_service_period_timeout(struct wl1271 *wl)
274{
275 struct acx_rx_timeout *rx_timeout;
276 int ret;
277
278 rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
279 if (!rx_timeout) {
280 ret = -ENOMEM;
281 goto out;
282 }
283
284 wl1271_debug(DEBUG_ACX, "acx service period timeout");
285
Eliad Peller7f0979882011-08-14 13:17:06 +0300286 rx_timeout->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300287 rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
288 rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300289
290 ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
291 rx_timeout, sizeof(*rx_timeout));
292 if (ret < 0) {
293 wl1271_warning("failed to set service period timeout: %d",
294 ret);
295 goto out;
296 }
297
298out:
299 kfree(rx_timeout);
300 return ret;
301}
302
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300303int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300304{
305 struct acx_rts_threshold *rts;
306 int ret;
307
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300308 /*
309 * If the RTS threshold is not configured or out of range, use the
310 * default value.
311 */
312 if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
313 rts_threshold = wl->conf.rx.rts_threshold;
314
315 wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300316
317 rts = kzalloc(sizeof(*rts), GFP_KERNEL);
318 if (!rts) {
319 ret = -ENOMEM;
320 goto out;
321 }
322
Eliad Peller7f0979882011-08-14 13:17:06 +0300323 rts->role_id = wl->role_id;
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300324 rts->threshold = cpu_to_le16((u16)rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300325
326 ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
327 if (ret < 0) {
328 wl1271_warning("failed to set rts threshold: %d", ret);
329 goto out;
330 }
331
332out:
333 kfree(rts);
334 return ret;
335}
336
Luciano Coelho6e92b412009-12-11 15:40:50 +0200337int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
338{
339 struct acx_dco_itrim_params *dco;
340 struct conf_itrim_settings *c = &wl->conf.itrim;
341 int ret;
342
343 wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
344
345 dco = kzalloc(sizeof(*dco), GFP_KERNEL);
346 if (!dco) {
347 ret = -ENOMEM;
348 goto out;
349 }
350
351 dco->enable = c->enable;
352 dco->timeout = cpu_to_le32(c->timeout);
353
354 ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
355 dco, sizeof(*dco));
356 if (ret < 0) {
357 wl1271_warning("failed to set dco itrim parameters: %d", ret);
358 goto out;
359 }
360
361out:
362 kfree(dco);
363 return ret;
364}
365
Juuso Oikarinen19221672009-10-08 21:56:35 +0300366int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300367{
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300368 struct acx_beacon_filter_option *beacon_filter = NULL;
369 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300370
371 wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
372
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300373 if (enable_filter &&
374 wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
375 goto out;
376
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300377 beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
378 if (!beacon_filter) {
379 ret = -ENOMEM;
380 goto out;
381 }
382
Eliad Peller7f0979882011-08-14 13:17:06 +0300383 beacon_filter->role_id = wl->role_id;
Juuso Oikarinen19221672009-10-08 21:56:35 +0300384 beacon_filter->enable = enable_filter;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300385
386 /*
387 * When set to zero, and the filter is enabled, beacons
388 * without the unicast TIM bit set are dropped.
389 */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300390 beacon_filter->max_num_beacons = 0;
391
392 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
393 beacon_filter, sizeof(*beacon_filter));
394 if (ret < 0) {
395 wl1271_warning("failed to set beacon filter opt: %d", ret);
396 goto out;
397 }
398
399out:
400 kfree(beacon_filter);
401 return ret;
402}
403
404int wl1271_acx_beacon_filter_table(struct wl1271 *wl)
405{
406 struct acx_beacon_filter_ie_table *ie_table;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300407 int i, idx = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300408 int ret;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300409 bool vendor_spec = false;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300410
411 wl1271_debug(DEBUG_ACX, "acx beacon filter table");
412
413 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
414 if (!ie_table) {
415 ret = -ENOMEM;
416 goto out;
417 }
418
Juuso Oikarinen19221672009-10-08 21:56:35 +0300419 /* configure default beacon pass-through rules */
Eliad Peller7f0979882011-08-14 13:17:06 +0300420 ie_table->role_id = wl->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300421 ie_table->num_ie = 0;
422 for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
423 struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
424 ie_table->table[idx++] = r->ie;
425 ie_table->table[idx++] = r->rule;
426
427 if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
428 /* only one vendor specific ie allowed */
429 if (vendor_spec)
430 continue;
431
432 /* for vendor specific rules configure the
433 additional fields */
434 memcpy(&(ie_table->table[idx]), r->oui,
435 CONF_BCN_IE_OUI_LEN);
436 idx += CONF_BCN_IE_OUI_LEN;
437 ie_table->table[idx++] = r->type;
438 memcpy(&(ie_table->table[idx]), r->version,
439 CONF_BCN_IE_VER_LEN);
440 idx += CONF_BCN_IE_VER_LEN;
441 vendor_spec = true;
442 }
443
444 ie_table->num_ie++;
445 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300446
447 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
448 ie_table, sizeof(*ie_table));
449 if (ret < 0) {
450 wl1271_warning("failed to set beacon filter table: %d", ret);
451 goto out;
452 }
453
454out:
455 kfree(ie_table);
456 return ret;
457}
458
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200459#define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
460
461int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable)
Juuso Oikarinen34415232009-10-08 21:56:33 +0300462{
463 struct acx_conn_monit_params *acx;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200464 u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
465 u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
Juuso Oikarinen34415232009-10-08 21:56:33 +0300466 int ret;
467
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200468 wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
469 enable ? "enabled" : "disabled");
Juuso Oikarinen34415232009-10-08 21:56:33 +0300470
471 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
472 if (!acx) {
473 ret = -ENOMEM;
474 goto out;
475 }
476
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200477 if (enable) {
478 threshold = wl->conf.conn.synch_fail_thold;
479 timeout = wl->conf.conn.bss_lose_timeout;
480 }
481
Eliad Peller7f0979882011-08-14 13:17:06 +0300482 acx->role_id = wl->role_id;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200483 acx->synch_fail_thold = cpu_to_le32(threshold);
484 acx->bss_lose_timeout = cpu_to_le32(timeout);
Juuso Oikarinen34415232009-10-08 21:56:33 +0300485
486 ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
487 acx, sizeof(*acx));
488 if (ret < 0) {
489 wl1271_warning("failed to set connection monitor "
490 "parameters: %d", ret);
491 goto out;
492 }
493
494out:
495 kfree(acx);
496 return ret;
497}
498
499
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200500int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300501{
502 struct acx_bt_wlan_coex *pta;
503 int ret;
504
505 wl1271_debug(DEBUG_ACX, "acx sg enable");
506
507 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
508 if (!pta) {
509 ret = -ENOMEM;
510 goto out;
511 }
512
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200513 if (enable)
514 pta->enable = wl->conf.sg.state;
515 else
516 pta->enable = CONF_SG_DISABLE;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300517
518 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
519 if (ret < 0) {
520 wl1271_warning("failed to set softgemini enable: %d", ret);
521 goto out;
522 }
523
524out:
525 kfree(pta);
526 return ret;
527}
528
Eliad Peller3be41122011-08-14 13:17:19 +0300529int wl12xx_acx_sg_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300530{
Eliad Peller3be41122011-08-14 13:17:19 +0300531 struct acx_bt_wlan_coex_param *param;
Juuso Oikarinen2b60100b2009-10-13 12:47:39 +0300532 struct conf_sg_settings *c = &wl->conf.sg;
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200533 int i, ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300534
Eliad Peller3be41122011-08-14 13:17:19 +0300535 wl1271_debug(DEBUG_ACX, "acx sg cfg");
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300536
537 param = kzalloc(sizeof(*param), GFP_KERNEL);
538 if (!param) {
539 ret = -ENOMEM;
540 goto out;
541 }
542
543 /* BT-WLAN coext parameters */
Eliad Peller3be41122011-08-14 13:17:19 +0300544 for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
545 param->params[i] = cpu_to_le32(c->params[i]);
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200546 param->param_idx = CONF_SG_PARAMS_ALL;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300547
548 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
549 if (ret < 0) {
550 wl1271_warning("failed to set sg config: %d", ret);
551 goto out;
552 }
553
554out:
555 kfree(param);
556 return ret;
557}
558
559int wl1271_acx_cca_threshold(struct wl1271 *wl)
560{
561 struct acx_energy_detection *detection;
562 int ret;
563
564 wl1271_debug(DEBUG_ACX, "acx cca threshold");
565
566 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
567 if (!detection) {
568 ret = -ENOMEM;
569 goto out;
570 }
571
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300572 detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
Juuso Oikarinen45b531a2009-10-13 12:47:41 +0300573 detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300574
575 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
576 detection, sizeof(*detection));
Julia Lawallf8afdf42011-08-12 13:31:30 -0400577 if (ret < 0)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300578 wl1271_warning("failed to set cca threshold: %d", ret);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300579
580out:
581 kfree(detection);
582 return ret;
583}
584
585int wl1271_acx_bcn_dtim_options(struct wl1271 *wl)
586{
587 struct acx_beacon_broadcast *bb;
588 int ret;
589
590 wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
591
592 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
593 if (!bb) {
594 ret = -ENOMEM;
595 goto out;
596 }
597
Eliad Peller7f0979882011-08-14 13:17:06 +0300598 bb->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300599 bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
600 bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300601 bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
602 bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300603
604 ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
605 if (ret < 0) {
606 wl1271_warning("failed to set rx config: %d", ret);
607 goto out;
608 }
609
610out:
611 kfree(bb);
612 return ret;
613}
614
615int wl1271_acx_aid(struct wl1271 *wl, u16 aid)
616{
617 struct acx_aid *acx_aid;
618 int ret;
619
620 wl1271_debug(DEBUG_ACX, "acx aid");
621
622 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
623 if (!acx_aid) {
624 ret = -ENOMEM;
625 goto out;
626 }
627
Eliad Peller7f0979882011-08-14 13:17:06 +0300628 acx_aid->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300629 acx_aid->aid = cpu_to_le16(aid);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300630
631 ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
632 if (ret < 0) {
633 wl1271_warning("failed to set aid: %d", ret);
634 goto out;
635 }
636
637out:
638 kfree(acx_aid);
639 return ret;
640}
641
642int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
643{
644 struct acx_event_mask *mask;
645 int ret;
646
647 wl1271_debug(DEBUG_ACX, "acx event mbox mask");
648
649 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
650 if (!mask) {
651 ret = -ENOMEM;
652 goto out;
653 }
654
655 /* high event mask is unused */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300656 mask->high_event_mask = cpu_to_le32(0xffffffff);
657 mask->event_mask = cpu_to_le32(event_mask);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300658
659 ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
660 mask, sizeof(*mask));
661 if (ret < 0) {
662 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
663 goto out;
664 }
665
666out:
667 kfree(mask);
668 return ret;
669}
670
671int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble)
672{
673 struct acx_preamble *acx;
674 int ret;
675
676 wl1271_debug(DEBUG_ACX, "acx_set_preamble");
677
678 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
679 if (!acx) {
680 ret = -ENOMEM;
681 goto out;
682 }
683
Eliad Peller7f0979882011-08-14 13:17:06 +0300684 acx->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300685 acx->preamble = preamble;
686
687 ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
688 if (ret < 0) {
689 wl1271_warning("Setting of preamble failed: %d", ret);
690 goto out;
691 }
692
693out:
694 kfree(acx);
695 return ret;
696}
697
698int wl1271_acx_cts_protect(struct wl1271 *wl,
699 enum acx_ctsprotect_type ctsprotect)
700{
701 struct acx_ctsprotect *acx;
702 int ret;
703
704 wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
705
706 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
707 if (!acx) {
708 ret = -ENOMEM;
709 goto out;
710 }
711
Eliad Peller7f0979882011-08-14 13:17:06 +0300712 acx->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300713 acx->ctsprotect = ctsprotect;
714
715 ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
716 if (ret < 0) {
717 wl1271_warning("Setting of ctsprotect failed: %d", ret);
718 goto out;
719 }
720
721out:
722 kfree(acx);
723 return ret;
724}
725
726int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
727{
728 int ret;
729
730 wl1271_debug(DEBUG_ACX, "acx statistics");
731
732 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
733 sizeof(*stats));
734 if (ret < 0) {
735 wl1271_warning("acx statistics failed: %d", ret);
736 return -ENOMEM;
737 }
738
739 return 0;
740}
741
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200742int wl1271_acx_sta_rate_policies(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300743{
Eliad Peller7f0979882011-08-14 13:17:06 +0300744 struct acx_rate_policy *acx;
Arik Nemtsov1e05a812010-10-16 17:44:51 +0200745 struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300746 int ret = 0;
747
748 wl1271_debug(DEBUG_ACX, "acx rate policies");
749
750 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
751
752 if (!acx) {
753 ret = -ENOMEM;
754 goto out;
755 }
756
Eliad Peller7f0979882011-08-14 13:17:06 +0300757 wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
758 wl->basic_rate, wl->rate_set);
759
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200760 /* configure one basic rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300761 acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE);
762 acx->rate_policy.enabled_rates = cpu_to_le32(wl->basic_rate);
763 acx->rate_policy.short_retry_limit = c->short_retry_limit;
764 acx->rate_policy.long_retry_limit = c->long_retry_limit;
765 acx->rate_policy.aflags = c->aflags;
766
767 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
768 if (ret < 0) {
769 wl1271_warning("Setting of rate policies failed: %d", ret);
770 goto out;
771 }
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200772
773 /* configure one AP supported rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300774 acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE);
775 acx->rate_policy.enabled_rates = cpu_to_le32(wl->rate_set);
776 acx->rate_policy.short_retry_limit = c->short_retry_limit;
777 acx->rate_policy.long_retry_limit = c->long_retry_limit;
778 acx->rate_policy.aflags = c->aflags;
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200779
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300780
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200781
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300782 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
783 if (ret < 0) {
784 wl1271_warning("Setting of rate policies failed: %d", ret);
785 goto out;
786 }
787
788out:
789 kfree(acx);
790 return ret;
791}
792
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200793int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
794 u8 idx)
795{
Eliad Peller7f0979882011-08-14 13:17:06 +0300796 struct acx_rate_policy *acx;
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200797 int ret = 0;
798
Arik Nemtsov70f47422011-04-18 14:15:25 +0300799 wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
800 idx, c->enabled_rates);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200801
802 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
803 if (!acx) {
804 ret = -ENOMEM;
805 goto out;
806 }
807
808 acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
809 acx->rate_policy.short_retry_limit = c->short_retry_limit;
810 acx->rate_policy.long_retry_limit = c->long_retry_limit;
811 acx->rate_policy.aflags = c->aflags;
812
Eliad Peller1d4801f2011-01-16 10:07:10 +0100813 acx->rate_policy_idx = cpu_to_le32(idx);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200814
815 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
816 if (ret < 0) {
817 wl1271_warning("Setting of ap rate policy failed: %d", ret);
818 goto out;
819 }
820
821out:
822 kfree(acx);
823 return ret;
824}
825
Kalle Valo243eeb52010-02-18 13:25:39 +0200826int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
827 u8 aifsn, u16 txop)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300828{
829 struct acx_ac_cfg *acx;
Kalle Valo243eeb52010-02-18 13:25:39 +0200830 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300831
Kalle Valo243eeb52010-02-18 13:25:39 +0200832 wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
833 "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300834
835 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
836
837 if (!acx) {
838 ret = -ENOMEM;
839 goto out;
840 }
841
Eliad Peller7f0979882011-08-14 13:17:06 +0300842 acx->role_id = wl->role_id;
Kalle Valo243eeb52010-02-18 13:25:39 +0200843 acx->ac = ac;
844 acx->cw_min = cw_min;
845 acx->cw_max = cpu_to_le16(cw_max);
846 acx->aifsn = aifsn;
847 acx->tx_op_limit = cpu_to_le16(txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300848
Kalle Valo243eeb52010-02-18 13:25:39 +0200849 ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
850 if (ret < 0) {
851 wl1271_warning("acx ac cfg failed: %d", ret);
852 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300853 }
854
855out:
856 kfree(acx);
857 return ret;
858}
859
Kalle Valof2054df2010-02-18 13:25:40 +0200860int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
861 u8 tsid, u8 ps_scheme, u8 ack_policy,
862 u32 apsd_conf0, u32 apsd_conf1)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300863{
864 struct acx_tid_config *acx;
Kalle Valof2054df2010-02-18 13:25:40 +0200865 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300866
867 wl1271_debug(DEBUG_ACX, "acx tid config");
868
869 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
870
871 if (!acx) {
872 ret = -ENOMEM;
873 goto out;
874 }
875
Eliad Peller7f0979882011-08-14 13:17:06 +0300876 acx->role_id = wl->role_id;
Kalle Valof2054df2010-02-18 13:25:40 +0200877 acx->queue_id = queue_id;
878 acx->channel_type = channel_type;
879 acx->tsid = tsid;
880 acx->ps_scheme = ps_scheme;
881 acx->ack_policy = ack_policy;
882 acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
883 acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300884
Kalle Valof2054df2010-02-18 13:25:40 +0200885 ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
886 if (ret < 0) {
887 wl1271_warning("Setting of tid config failed: %d", ret);
888 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300889 }
890
891out:
892 kfree(acx);
893 return ret;
894}
895
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300896int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300897{
898 struct acx_frag_threshold *acx;
899 int ret = 0;
900
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300901 /*
902 * If the fragmentation is not configured or out of range, use the
903 * default value.
904 */
905 if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
906 frag_threshold = wl->conf.tx.frag_threshold;
907
908 wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300909
910 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
911
912 if (!acx) {
913 ret = -ENOMEM;
914 goto out;
915 }
916
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300917 acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300918 ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
919 if (ret < 0) {
920 wl1271_warning("Setting of frag threshold failed: %d", ret);
921 goto out;
922 }
923
924out:
925 kfree(acx);
926 return ret;
927}
928
929int wl1271_acx_tx_config_options(struct wl1271 *wl)
930{
931 struct acx_tx_config_options *acx;
932 int ret = 0;
933
934 wl1271_debug(DEBUG_ACX, "acx tx config options");
935
936 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
937
938 if (!acx) {
939 ret = -ENOMEM;
940 goto out;
941 }
942
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300943 acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
944 acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300945 ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
946 if (ret < 0) {
947 wl1271_warning("Setting of tx options failed: %d", ret);
948 goto out;
949 }
950
951out:
952 kfree(acx);
953 return ret;
954}
955
Eliad Peller7f0979882011-08-14 13:17:06 +0300956int wl12xx_acx_mem_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300957{
Eliad Peller7f0979882011-08-14 13:17:06 +0300958 struct wl12xx_acx_config_memory *mem_conf;
Shahar Levi13b107d2011-03-06 16:32:12 +0200959 struct conf_memory_settings *mem;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200960 int ret;
961
962 wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
963
964 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
965 if (!mem_conf) {
966 ret = -ENOMEM;
967 goto out;
968 }
969
Shahar Levi13b107d2011-03-06 16:32:12 +0200970 if (wl->chip.id == CHIP_ID_1283_PG20)
971 mem = &wl->conf.mem_wl128x;
972 else
973 mem = &wl->conf.mem_wl127x;
974
Eliad Pellerc8bde242011-02-02 09:59:35 +0200975 /* memory config */
Shahar Levi13b107d2011-03-06 16:32:12 +0200976 mem_conf->num_stations = mem->num_stations;
977 mem_conf->rx_mem_block_num = mem->rx_block_num;
978 mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
979 mem_conf->num_ssid_profiles = mem->ssid_profiles;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200980 mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
Shahar Levi13b107d2011-03-06 16:32:12 +0200981 mem_conf->dyn_mem_enable = mem->dynamic_memory;
982 mem_conf->tx_free_req = mem->min_req_tx_blocks;
983 mem_conf->rx_free_req = mem->min_req_rx_blocks;
984 mem_conf->tx_min = mem->tx_min;
Ido Yariv95dac04f2011-06-06 14:57:06 +0300985 mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200986
987 ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
988 sizeof(*mem_conf));
989 if (ret < 0) {
990 wl1271_warning("wl1271 mem config failed: %d", ret);
991 goto out;
992 }
993
994out:
995 kfree(mem_conf);
996 return ret;
997}
998
Shahar Levi48a61472011-03-06 16:32:08 +0200999int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
1000{
1001 struct wl1271_acx_host_config_bitmap *bitmap_conf;
1002 int ret;
1003
1004 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
1005 if (!bitmap_conf) {
1006 ret = -ENOMEM;
1007 goto out;
1008 }
1009
1010 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
1011
1012 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
1013 bitmap_conf, sizeof(*bitmap_conf));
1014 if (ret < 0) {
1015 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
1016 goto out;
1017 }
1018
1019out:
1020 kfree(bitmap_conf);
1021
1022 return ret;
1023}
1024
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001025int wl1271_acx_init_mem_config(struct wl1271 *wl)
1026{
1027 int ret;
1028
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001029 wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
Juuso Oikarinen45b531a2009-10-13 12:47:41 +03001030 GFP_KERNEL);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001031 if (!wl->target_mem_map) {
1032 wl1271_error("couldn't allocate target memory map");
1033 return -ENOMEM;
1034 }
1035
1036 /* we now ask for the firmware built memory map */
1037 ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
1038 sizeof(struct wl1271_acx_mem_map));
1039 if (ret < 0) {
1040 wl1271_error("couldn't retrieve firmware memory map");
1041 kfree(wl->target_mem_map);
1042 wl->target_mem_map = NULL;
1043 return ret;
1044 }
1045
1046 /* initialize TX block book keeping */
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001047 wl->tx_blocks_available =
1048 le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001049 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1050 wl->tx_blocks_available);
1051
1052 return 0;
1053}
1054
1055int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
1056{
1057 struct wl1271_acx_rx_config_opt *rx_conf;
1058 int ret;
1059
1060 wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
1061
1062 rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
1063 if (!rx_conf) {
1064 ret = -ENOMEM;
1065 goto out;
1066 }
1067
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001068 rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
1069 rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
1070 rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +03001071 rx_conf->queue_type = wl->conf.rx.queue_type;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001072
1073 ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
1074 sizeof(*rx_conf));
1075 if (ret < 0) {
1076 wl1271_warning("wl1271 rx config opt failed: %d", ret);
1077 goto out;
1078 }
1079
1080out:
1081 kfree(rx_conf);
1082 return ret;
1083}
Juuso Oikarinen3cfd6cf2009-10-12 15:08:52 +03001084
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001085int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
1086{
1087 struct wl1271_acx_bet_enable *acx = NULL;
1088 int ret = 0;
1089
1090 wl1271_debug(DEBUG_ACX, "acx bet enable");
1091
1092 if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
1093 goto out;
1094
1095 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1096 if (!acx) {
1097 ret = -ENOMEM;
1098 goto out;
1099 }
1100
Eliad Peller7f0979882011-08-14 13:17:06 +03001101 acx->role_id = wl->role_id;
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001102 acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
1103 acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
1104
1105 ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
1106 if (ret < 0) {
1107 wl1271_warning("acx bet enable failed: %d", ret);
1108 goto out;
1109 }
1110
1111out:
1112 kfree(acx);
1113 return ret;
1114}
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001115
Eliad Pellerc5312772010-12-09 11:31:27 +02001116int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address)
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001117{
1118 struct wl1271_acx_arp_filter *acx;
1119 int ret;
1120
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001121 wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001122
1123 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1124 if (!acx) {
1125 ret = -ENOMEM;
1126 goto out;
1127 }
1128
Eliad Peller7f0979882011-08-14 13:17:06 +03001129 acx->role_id = wl->role_id;
Juuso Oikarineneb887df2010-07-08 17:49:58 +03001130 acx->version = ACX_IPV4_VERSION;
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001131 acx->enable = enable;
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001132
Eliad Pellerc5312772010-12-09 11:31:27 +02001133 if (enable)
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001134 memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001135
1136 ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
1137 acx, sizeof(*acx));
1138 if (ret < 0) {
1139 wl1271_warning("failed to set arp ip filter: %d", ret);
1140 goto out;
1141 }
1142
1143out:
1144 kfree(acx);
1145 return ret;
1146}
Juuso Oikarinen38ad2d82009-12-11 15:41:08 +02001147
1148int wl1271_acx_pm_config(struct wl1271 *wl)
1149{
1150 struct wl1271_acx_pm_config *acx = NULL;
1151 struct conf_pm_config_settings *c = &wl->conf.pm_config;
1152 int ret = 0;
1153
1154 wl1271_debug(DEBUG_ACX, "acx pm config");
1155
1156 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1157 if (!acx) {
1158 ret = -ENOMEM;
1159 goto out;
1160 }
1161
1162 acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
1163 acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
1164
1165 ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
1166 if (ret < 0) {
1167 wl1271_warning("acx pm config failed: %d", ret);
1168 goto out;
1169 }
1170
1171out:
1172 kfree(acx);
1173 return ret;
1174}
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001175
1176int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
1177{
1178 struct wl1271_acx_keep_alive_mode *acx = NULL;
1179 int ret = 0;
1180
1181 wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
1182
1183 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1184 if (!acx) {
1185 ret = -ENOMEM;
1186 goto out;
1187 }
1188
Eliad Peller7f0979882011-08-14 13:17:06 +03001189 acx->role_id = wl->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001190 acx->enabled = enable;
1191
1192 ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
1193 if (ret < 0) {
1194 wl1271_warning("acx keep alive mode failed: %d", ret);
1195 goto out;
1196 }
1197
1198out:
1199 kfree(acx);
1200 return ret;
1201}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001202
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001203int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
1204{
1205 struct wl1271_acx_keep_alive_config *acx = NULL;
1206 int ret = 0;
1207
1208 wl1271_debug(DEBUG_ACX, "acx keep alive config");
1209
1210 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1211 if (!acx) {
1212 ret = -ENOMEM;
1213 goto out;
1214 }
1215
Eliad Peller7f0979882011-08-14 13:17:06 +03001216 acx->role_id = wl->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001217 acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
1218 acx->index = index;
1219 acx->tpl_validation = tpl_valid;
1220 acx->trigger = ACX_KEEP_ALIVE_NO_TX;
1221
1222 ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
1223 acx, sizeof(*acx));
1224 if (ret < 0) {
1225 wl1271_warning("acx keep alive config failed: %d", ret);
1226 goto out;
1227 }
1228
1229out:
1230 kfree(acx);
1231 return ret;
1232}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001233
1234int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable,
1235 s16 thold, u8 hyst)
1236{
1237 struct wl1271_acx_rssi_snr_trigger *acx = NULL;
1238 int ret = 0;
1239
1240 wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
1241
1242 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1243 if (!acx) {
1244 ret = -ENOMEM;
1245 goto out;
1246 }
1247
1248 wl->last_rssi_event = -1;
1249
Eliad Peller7f0979882011-08-14 13:17:06 +03001250 acx->role_id = wl->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001251 acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
1252 acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
1253 acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
1254 if (enable)
1255 acx->enable = WL1271_ACX_TRIG_ENABLE;
1256 else
1257 acx->enable = WL1271_ACX_TRIG_DISABLE;
1258
1259 acx->index = WL1271_ACX_TRIG_IDX_RSSI;
1260 acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
1261 acx->threshold = cpu_to_le16(thold);
1262 acx->hysteresis = hyst;
1263
1264 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
1265 if (ret < 0) {
1266 wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
1267 goto out;
1268 }
1269
1270out:
1271 kfree(acx);
1272 return ret;
1273}
1274
1275int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl)
1276{
1277 struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
1278 struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
1279 int ret = 0;
1280
1281 wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
1282
1283 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1284 if (!acx) {
1285 ret = -ENOMEM;
1286 goto out;
1287 }
1288
Eliad Peller7f0979882011-08-14 13:17:06 +03001289 acx->role_id = wl->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001290 acx->rssi_beacon = c->avg_weight_rssi_beacon;
1291 acx->rssi_data = c->avg_weight_rssi_data;
1292 acx->snr_beacon = c->avg_weight_snr_beacon;
1293 acx->snr_data = c->avg_weight_snr_data;
1294
1295 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
1296 if (ret < 0) {
1297 wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
1298 goto out;
1299 }
1300
1301out:
1302 kfree(acx);
1303 return ret;
1304}
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001305
Shahar Levic4db1c82010-10-13 16:09:40 +02001306int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
1307 struct ieee80211_sta_ht_cap *ht_cap,
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001308 bool allow_ht_operation, u8 hlid)
Shahar Levic4db1c82010-10-13 16:09:40 +02001309{
1310 struct wl1271_acx_ht_capabilities *acx;
Shahar Levic4db1c82010-10-13 16:09:40 +02001311 int ret = 0;
Eliad Peller6177eae2010-12-22 12:38:52 +01001312 u32 ht_capabilites = 0;
Shahar Levic4db1c82010-10-13 16:09:40 +02001313
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001314 wl1271_debug(DEBUG_ACX, "acx ht capabilities setting "
1315 "sta supp: %d sta cap: %d", ht_cap->ht_supported,
1316 ht_cap->cap);
Shahar Levic4db1c82010-10-13 16:09:40 +02001317
1318 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1319 if (!acx) {
1320 ret = -ENOMEM;
1321 goto out;
1322 }
1323
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001324 if (allow_ht_operation && ht_cap->ht_supported) {
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001325 /* no need to translate capabilities - use the spec values */
1326 ht_capabilites = ht_cap->cap;
1327
1328 /*
1329 * this bit is not employed by the spec but only by FW to
1330 * indicate peer HT support
1331 */
1332 ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
Shahar Levic4db1c82010-10-13 16:09:40 +02001333
1334 /* get data from A-MPDU parameters field */
1335 acx->ampdu_max_length = ht_cap->ampdu_factor;
1336 acx->ampdu_min_spacing = ht_cap->ampdu_density;
Shahar Levic4db1c82010-10-13 16:09:40 +02001337 }
1338
Arik Nemtsov0b932ab2011-08-14 13:17:27 +03001339 acx->hlid = hlid;
Eliad Peller6177eae2010-12-22 12:38:52 +01001340 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
1341
Shahar Levic4db1c82010-10-13 16:09:40 +02001342 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
1343 if (ret < 0) {
1344 wl1271_warning("acx ht capabilities setting failed: %d", ret);
1345 goto out;
1346 }
1347
1348out:
1349 kfree(acx);
1350 return ret;
1351}
1352
1353int wl1271_acx_set_ht_information(struct wl1271 *wl,
1354 u16 ht_operation_mode)
1355{
1356 struct wl1271_acx_ht_information *acx;
1357 int ret = 0;
1358
1359 wl1271_debug(DEBUG_ACX, "acx ht information setting");
1360
1361 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1362 if (!acx) {
1363 ret = -ENOMEM;
1364 goto out;
1365 }
1366
Eliad Peller7f0979882011-08-14 13:17:06 +03001367 acx->role_id = wl->role_id;
Shahar Levic4db1c82010-10-13 16:09:40 +02001368 acx->ht_protection =
1369 (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
1370 acx->rifs_mode = 0;
Helmut Schaa95a77612011-03-02 10:46:46 +01001371 acx->gf_protection =
1372 !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
Shahar Levic4db1c82010-10-13 16:09:40 +02001373 acx->ht_tx_burst_limit = 0;
1374 acx->dual_cts_protection = 0;
1375
1376 ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
1377
1378 if (ret < 0) {
1379 wl1271_warning("acx ht information setting failed: %d", ret);
1380 goto out;
1381 }
1382
1383out:
1384 kfree(acx);
1385 return ret;
1386}
1387
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001388/* Configure BA session initiator/receiver parameters setting in the FW. */
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001389int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl)
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001390{
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001391 struct wl1271_acx_ba_initiator_policy *acx;
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001392 int ret;
1393
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001394 wl1271_debug(DEBUG_ACX, "acx ba initiator policy");
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001395
1396 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1397 if (!acx) {
1398 ret = -ENOMEM;
1399 goto out;
1400 }
1401
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001402 /* set for the current role */
1403 acx->role_id = wl->role_id;
1404 acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap;
1405 acx->win_size = wl->conf.ht.tx_ba_win_size;
1406 acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001407
1408 ret = wl1271_cmd_configure(wl,
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001409 ACX_BA_SESSION_INIT_POLICY,
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001410 acx,
1411 sizeof(*acx));
1412 if (ret < 0) {
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001413 wl1271_warning("acx ba initiator policy failed: %d", ret);
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001414 goto out;
1415 }
1416
1417out:
1418 kfree(acx);
1419 return ret;
1420}
1421
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001422/* setup BA session receiver setting in the FW. */
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001423int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index,
1424 u16 ssn, bool enable, u8 peer_hlid)
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001425{
1426 struct wl1271_acx_ba_receiver_setup *acx;
1427 int ret;
1428
1429 wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
1430
1431 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1432 if (!acx) {
1433 ret = -ENOMEM;
1434 goto out;
1435 }
1436
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001437 acx->hlid = peer_hlid;
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001438 acx->tid = tid_index;
1439 acx->enable = enable;
Arik Nemtsov0f9c8252011-08-17 10:45:49 +03001440 acx->win_size = wl->conf.ht.rx_ba_win_size;
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001441 acx->ssn = ssn;
1442
1443 ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
1444 sizeof(*acx));
1445 if (ret < 0) {
1446 wl1271_warning("acx ba receiver session failed: %d", ret);
1447 goto out;
1448 }
1449
1450out:
1451 kfree(acx);
1452 return ret;
1453}
1454
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001455int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
1456{
1457 struct wl1271_acx_fw_tsf_information *tsf_info;
1458 int ret;
1459
1460 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
1461 if (!tsf_info) {
1462 ret = -ENOMEM;
1463 goto out;
1464 }
1465
1466 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
1467 tsf_info, sizeof(*tsf_info));
1468 if (ret < 0) {
1469 wl1271_warning("acx tsf info interrogate failed");
1470 goto out;
1471 }
1472
1473 *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
1474 ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
1475
1476out:
1477 kfree(tsf_info);
1478 return ret;
1479}
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001480
Eliad Pellerf84673d2011-05-15 11:10:28 +03001481int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable)
1482{
1483 struct wl1271_acx_ps_rx_streaming *rx_streaming;
1484 u32 conf_queues, enable_queues;
1485 int i, ret = 0;
1486
1487 wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
1488
1489 rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
1490 if (!rx_streaming) {
1491 ret = -ENOMEM;
1492 goto out;
1493 }
1494
1495 conf_queues = wl->conf.rx_streaming.queues;
1496 if (enable)
1497 enable_queues = conf_queues;
1498 else
1499 enable_queues = 0;
1500
1501 for (i = 0; i < 8; i++) {
1502 /*
1503 * Skip non-changed queues, to avoid redundant acxs.
1504 * this check assumes conf.rx_streaming.queues can't
1505 * be changed while rx_streaming is enabled.
1506 */
1507 if (!(conf_queues & BIT(i)))
1508 continue;
1509
Eliad Peller7f0979882011-08-14 13:17:06 +03001510 rx_streaming->role_id = wl->role_id;
Eliad Pellerf84673d2011-05-15 11:10:28 +03001511 rx_streaming->tid = i;
1512 rx_streaming->enable = enable_queues & BIT(i);
1513 rx_streaming->period = wl->conf.rx_streaming.interval;
1514 rx_streaming->timeout = wl->conf.rx_streaming.interval;
1515
1516 ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
1517 rx_streaming,
1518 sizeof(*rx_streaming));
1519 if (ret < 0) {
1520 wl1271_warning("acx ps rx streaming failed: %d", ret);
1521 goto out;
1522 }
1523 }
1524out:
1525 kfree(rx_streaming);
1526 return ret;
1527}
1528
Arik Nemtsov3618f302011-06-26 10:36:03 +03001529int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl)
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001530{
Arik Nemtsov3618f302011-06-26 10:36:03 +03001531 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001532 int ret;
1533
Arik Nemtsov3618f302011-06-26 10:36:03 +03001534 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001535
1536 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1537 if (!acx)
1538 return -ENOMEM;
1539
Eliad Peller7f0979882011-08-14 13:17:06 +03001540 acx->role_id = wl->role_id;
Arik Nemtsov3618f302011-06-26 10:36:03 +03001541 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001542
1543 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1544 if (ret < 0) {
Arik Nemtsov3618f302011-06-26 10:36:03 +03001545 wl1271_warning("acx ap max tx retry failed: %d", ret);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001546 goto out;
1547 }
1548
1549out:
1550 kfree(acx);
1551 return ret;
1552}
Eliad Pelleree608332011-02-02 09:59:34 +02001553
1554int wl1271_acx_config_ps(struct wl1271 *wl)
1555{
1556 struct wl1271_acx_config_ps *config_ps;
1557 int ret;
1558
1559 wl1271_debug(DEBUG_ACX, "acx config ps");
1560
1561 config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
1562 if (!config_ps) {
1563 ret = -ENOMEM;
1564 goto out;
1565 }
1566
1567 config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
1568 config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
1569 config_ps->null_data_rate = cpu_to_le32(wl->basic_rate);
1570
1571 ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
1572 sizeof(*config_ps));
1573
1574 if (ret < 0) {
1575 wl1271_warning("acx config ps failed: %d", ret);
1576 goto out;
1577 }
1578
1579out:
1580 kfree(config_ps);
1581 return ret;
1582}
Arik Nemtsov99a27752011-02-23 00:22:25 +02001583
1584int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
1585{
1586 struct wl1271_acx_inconnection_sta *acx = NULL;
1587 int ret;
1588
1589 wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
1590
1591 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1592 if (!acx)
1593 return -ENOMEM;
1594
1595 memcpy(acx->addr, addr, ETH_ALEN);
1596
1597 ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
1598 acx, sizeof(*acx));
1599 if (ret < 0) {
1600 wl1271_warning("acx set inconnaction sta failed: %d", ret);
1601 goto out;
1602 }
1603
1604out:
1605 kfree(acx);
1606 return ret;
1607}
Shahar Leviff868432011-04-11 15:41:46 +03001608
1609int wl1271_acx_fm_coex(struct wl1271 *wl)
1610{
1611 struct wl1271_acx_fm_coex *acx;
1612 int ret;
1613
1614 wl1271_debug(DEBUG_ACX, "acx fm coex setting");
1615
1616 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1617 if (!acx) {
1618 ret = -ENOMEM;
1619 goto out;
1620 }
1621
1622 acx->enable = wl->conf.fm_coex.enable;
1623 acx->swallow_period = wl->conf.fm_coex.swallow_period;
1624 acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
1625 acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
1626 acx->m_divider_fref_set_1 =
1627 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
1628 acx->m_divider_fref_set_2 =
1629 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
1630 acx->coex_pll_stabilization_time =
1631 cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
1632 acx->ldo_stabilization_time =
1633 cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
1634 acx->fm_disturbed_band_margin =
1635 wl->conf.fm_coex.fm_disturbed_band_margin;
1636 acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
1637
1638 ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
1639 if (ret < 0) {
1640 wl1271_warning("acx fm coex setting failed: %d", ret);
1641 goto out;
1642 }
1643
1644out:
1645 kfree(acx);
1646 return ret;
1647}
Eliad Pellerfa6ad9f2011-08-14 13:17:14 +03001648
1649int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
1650{
1651 struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
1652 struct conf_rate_policy_settings *conf = &wl->conf.rate;
1653 int ret;
1654
1655 wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
1656
1657 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1658 if (!acx)
1659 return -ENOMEM;
1660
1661 acx->index = ACX_RATE_MGMT_ALL_PARAMS;
1662 acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
1663 acx->per_add = cpu_to_le16(conf->per_add);
1664 acx->per_th1 = cpu_to_le16(conf->per_th1);
1665 acx->per_th2 = cpu_to_le16(conf->per_th2);
1666 acx->max_per = cpu_to_le16(conf->max_per);
1667 acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
1668 acx->tx_fail_low_th = conf->tx_fail_low_th;
1669 acx->tx_fail_high_th = conf->tx_fail_high_th;
1670 acx->per_alpha_shift = conf->per_alpha_shift;
1671 acx->per_add_shift = conf->per_add_shift;
1672 acx->per_beta1_shift = conf->per_beta1_shift;
1673 acx->per_beta2_shift = conf->per_beta2_shift;
1674 acx->rate_check_up = conf->rate_check_up;
1675 acx->rate_check_down = conf->rate_check_down;
1676 memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
1677 sizeof(acx->rate_retry_policy));
1678
1679 ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
1680 acx, sizeof(*acx));
1681 if (ret < 0) {
1682 wl1271_warning("acx set rate mgmt params failed: %d", ret);
1683 goto out;
1684 }
1685
1686out:
1687 kfree(acx);
1688 return ret;
1689}
Eliad Peller94877752011-08-28 15:11:56 +03001690
1691int wl12xx_acx_config_hangover(struct wl1271 *wl)
1692{
1693 struct wl12xx_acx_config_hangover *acx;
1694 struct conf_hangover_settings *conf = &wl->conf.hangover;
1695 int ret;
1696
1697 wl1271_debug(DEBUG_ACX, "acx config hangover");
1698
1699 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1700 if (!acx) {
1701 ret = -ENOMEM;
1702 goto out;
1703 }
1704
1705 acx->recover_time = cpu_to_le32(conf->recover_time);
1706 acx->hangover_period = conf->hangover_period;
1707 acx->dynamic_mode = conf->dynamic_mode;
1708 acx->early_termination_mode = conf->early_termination_mode;
1709 acx->max_period = conf->max_period;
1710 acx->min_period = conf->min_period;
1711 acx->increase_delta = conf->increase_delta;
1712 acx->decrease_delta = conf->decrease_delta;
1713 acx->quiet_time = conf->quiet_time;
1714 acx->increase_time = conf->increase_time;
1715 acx->window_size = acx->window_size;
1716
1717 ret = wl1271_cmd_configure(wl, ACX_CONFIG_HANGOVER, acx,
1718 sizeof(*acx));
1719
1720 if (ret < 0) {
1721 wl1271_warning("acx config hangover failed: %d", ret);
1722 goto out;
1723 }
1724
1725out:
1726 kfree(acx);
1727 return ret;
1728
1729}