blob: d783fce4561354575d0be0cabfce0ed3da568646 [file] [log] [blame]
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 2008-2009 Nokia Corporation
5 *
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
Shahar Levi00d20102010-11-08 11:20:10 +000024#include "acx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030025
26#include <linux/module.h>
27#include <linux/platform_device.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030028#include <linux/spi/spi.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030030
Shahar Levi00d20102010-11-08 11:20:10 +000031#include "wl12xx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030032#include "wl12xx_80211.h"
Shahar Levi00d20102010-11-08 11:20:10 +000033#include "reg.h"
34#include "ps.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030035
Juuso Oikarinen51f2be22009-10-13 12:47:42 +030036int wl1271_acx_wake_up_conditions(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030037{
38 struct acx_wake_up_condition *wake_up;
39 int ret;
40
41 wl1271_debug(DEBUG_ACX, "acx wake up conditions");
42
43 wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
44 if (!wake_up) {
45 ret = -ENOMEM;
46 goto out;
47 }
48
Eliad Peller7f0979882011-08-14 13:17:06 +030049 wake_up->role_id = wl->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +030050 wake_up->wake_up_event = wl->conf.conn.wake_up_event;
51 wake_up->listen_interval = wl->conf.conn.listen_interval;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030052
53 ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
54 wake_up, sizeof(*wake_up));
55 if (ret < 0) {
56 wl1271_warning("could not set wake up conditions: %d", ret);
57 goto out;
58 }
59
60out:
61 kfree(wake_up);
62 return ret;
63}
64
65int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
66{
67 struct acx_sleep_auth *auth;
68 int ret;
69
70 wl1271_debug(DEBUG_ACX, "acx sleep auth");
71
72 auth = kzalloc(sizeof(*auth), GFP_KERNEL);
73 if (!auth) {
74 ret = -ENOMEM;
75 goto out;
76 }
77
78 auth->sleep_auth = sleep_auth;
79
80 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
81 if (ret < 0)
82 return ret;
83
84out:
85 kfree(auth);
86 return ret;
87}
88
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030089int wl1271_acx_tx_power(struct wl1271 *wl, int power)
90{
91 struct acx_current_tx_power *acx;
92 int ret;
93
Arik Nemtsov097f8822011-06-27 22:06:34 +030094 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030095
96 if (power < 0 || power > 25)
97 return -EINVAL;
98
99 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
100 if (!acx) {
101 ret = -ENOMEM;
102 goto out;
103 }
104
Eliad Peller7f0979882011-08-14 13:17:06 +0300105 acx->role_id = wl->role_id;
Juuso Oikarinen6f6b5d42010-02-22 08:38:42 +0200106 acx->current_tx_power = power * 10;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300107
108 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
109 if (ret < 0) {
110 wl1271_warning("configure of tx power failed: %d", ret);
111 goto out;
112 }
113
114out:
115 kfree(acx);
116 return ret;
117}
118
119int wl1271_acx_feature_cfg(struct wl1271 *wl)
120{
121 struct acx_feature_config *feature;
122 int ret;
123
124 wl1271_debug(DEBUG_ACX, "acx feature cfg");
125
126 feature = kzalloc(sizeof(*feature), GFP_KERNEL);
127 if (!feature) {
128 ret = -ENOMEM;
129 goto out;
130 }
131
132 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
Eliad Peller7f0979882011-08-14 13:17:06 +0300133 feature->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300134 feature->data_flow_options = 0;
135 feature->options = 0;
136
137 ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
138 feature, sizeof(*feature));
139 if (ret < 0) {
140 wl1271_error("Couldnt set HW encryption");
141 goto out;
142 }
143
144out:
145 kfree(feature);
146 return ret;
147}
148
149int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
150 size_t len)
151{
152 int ret;
153
154 wl1271_debug(DEBUG_ACX, "acx mem map");
155
156 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
157 if (ret < 0)
158 return ret;
159
160 return 0;
161}
162
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +0300163int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300164{
165 struct acx_rx_msdu_lifetime *acx;
166 int ret;
167
168 wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
169
170 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
171 if (!acx) {
172 ret = -ENOMEM;
173 goto out;
174 }
175
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300176 acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300177 ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
178 acx, sizeof(*acx));
179 if (ret < 0) {
180 wl1271_warning("failed to set rx msdu life time: %d", ret);
181 goto out;
182 }
183
184out:
185 kfree(acx);
186 return ret;
187}
188
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300189int wl1271_acx_pd_threshold(struct wl1271 *wl)
190{
191 struct acx_packet_detection *pd;
192 int ret;
193
194 wl1271_debug(DEBUG_ACX, "acx data pd threshold");
195
196 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
197 if (!pd) {
198 ret = -ENOMEM;
199 goto out;
200 }
201
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300202 pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300203
204 ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
205 if (ret < 0) {
206 wl1271_warning("failed to set pd threshold: %d", ret);
207 goto out;
208 }
209
210out:
211 kfree(pd);
Julia Lawall36d34412010-08-16 18:27:30 +0200212 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300213}
214
215int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time)
216{
217 struct acx_slot *slot;
218 int ret;
219
220 wl1271_debug(DEBUG_ACX, "acx slot");
221
222 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
223 if (!slot) {
224 ret = -ENOMEM;
225 goto out;
226 }
227
Eliad Peller7f0979882011-08-14 13:17:06 +0300228 slot->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300229 slot->wone_index = STATION_WONE_INDEX;
230 slot->slot_time = slot_time;
231
232 ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
233 if (ret < 0) {
234 wl1271_warning("failed to set slot time: %d", ret);
235 goto out;
236 }
237
238out:
239 kfree(slot);
240 return ret;
241}
242
Juuso Oikarinenc87dec92009-10-08 21:56:31 +0300243int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable,
244 void *mc_list, u32 mc_list_len)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300245{
246 struct acx_dot11_grp_addr_tbl *acx;
247 int ret;
248
249 wl1271_debug(DEBUG_ACX, "acx group address tbl");
250
251 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
252 if (!acx) {
253 ret = -ENOMEM;
254 goto out;
255 }
256
257 /* MAC filtering */
Eliad Peller7f0979882011-08-14 13:17:06 +0300258 acx->role_id = wl->role_id;
Juuso Oikarinenc87dec92009-10-08 21:56:31 +0300259 acx->enabled = enable;
260 acx->num_groups = mc_list_len;
261 memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300262
263 ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
264 acx, sizeof(*acx));
265 if (ret < 0) {
266 wl1271_warning("failed to set group addr table: %d", ret);
267 goto out;
268 }
269
270out:
271 kfree(acx);
272 return ret;
273}
274
275int wl1271_acx_service_period_timeout(struct wl1271 *wl)
276{
277 struct acx_rx_timeout *rx_timeout;
278 int ret;
279
280 rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
281 if (!rx_timeout) {
282 ret = -ENOMEM;
283 goto out;
284 }
285
286 wl1271_debug(DEBUG_ACX, "acx service period timeout");
287
Eliad Peller7f0979882011-08-14 13:17:06 +0300288 rx_timeout->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300289 rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
290 rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300291
292 ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
293 rx_timeout, sizeof(*rx_timeout));
294 if (ret < 0) {
295 wl1271_warning("failed to set service period timeout: %d",
296 ret);
297 goto out;
298 }
299
300out:
301 kfree(rx_timeout);
302 return ret;
303}
304
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300305int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300306{
307 struct acx_rts_threshold *rts;
308 int ret;
309
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300310 /*
311 * If the RTS threshold is not configured or out of range, use the
312 * default value.
313 */
314 if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
315 rts_threshold = wl->conf.rx.rts_threshold;
316
317 wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300318
319 rts = kzalloc(sizeof(*rts), GFP_KERNEL);
320 if (!rts) {
321 ret = -ENOMEM;
322 goto out;
323 }
324
Eliad Peller7f0979882011-08-14 13:17:06 +0300325 rts->role_id = wl->role_id;
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300326 rts->threshold = cpu_to_le16((u16)rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300327
328 ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
329 if (ret < 0) {
330 wl1271_warning("failed to set rts threshold: %d", ret);
331 goto out;
332 }
333
334out:
335 kfree(rts);
336 return ret;
337}
338
Luciano Coelho6e92b412009-12-11 15:40:50 +0200339int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
340{
341 struct acx_dco_itrim_params *dco;
342 struct conf_itrim_settings *c = &wl->conf.itrim;
343 int ret;
344
345 wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
346
347 dco = kzalloc(sizeof(*dco), GFP_KERNEL);
348 if (!dco) {
349 ret = -ENOMEM;
350 goto out;
351 }
352
353 dco->enable = c->enable;
354 dco->timeout = cpu_to_le32(c->timeout);
355
356 ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
357 dco, sizeof(*dco));
358 if (ret < 0) {
359 wl1271_warning("failed to set dco itrim parameters: %d", ret);
360 goto out;
361 }
362
363out:
364 kfree(dco);
365 return ret;
366}
367
Juuso Oikarinen19221672009-10-08 21:56:35 +0300368int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300369{
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300370 struct acx_beacon_filter_option *beacon_filter = NULL;
371 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300372
373 wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
374
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300375 if (enable_filter &&
376 wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
377 goto out;
378
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300379 beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
380 if (!beacon_filter) {
381 ret = -ENOMEM;
382 goto out;
383 }
384
Eliad Peller7f0979882011-08-14 13:17:06 +0300385 beacon_filter->role_id = wl->role_id;
Juuso Oikarinen19221672009-10-08 21:56:35 +0300386 beacon_filter->enable = enable_filter;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300387
388 /*
389 * When set to zero, and the filter is enabled, beacons
390 * without the unicast TIM bit set are dropped.
391 */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300392 beacon_filter->max_num_beacons = 0;
393
394 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
395 beacon_filter, sizeof(*beacon_filter));
396 if (ret < 0) {
397 wl1271_warning("failed to set beacon filter opt: %d", ret);
398 goto out;
399 }
400
401out:
402 kfree(beacon_filter);
403 return ret;
404}
405
406int wl1271_acx_beacon_filter_table(struct wl1271 *wl)
407{
408 struct acx_beacon_filter_ie_table *ie_table;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300409 int i, idx = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300410 int ret;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300411 bool vendor_spec = false;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300412
413 wl1271_debug(DEBUG_ACX, "acx beacon filter table");
414
415 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
416 if (!ie_table) {
417 ret = -ENOMEM;
418 goto out;
419 }
420
Juuso Oikarinen19221672009-10-08 21:56:35 +0300421 /* configure default beacon pass-through rules */
Eliad Peller7f0979882011-08-14 13:17:06 +0300422 ie_table->role_id = wl->role_id;
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300423 ie_table->num_ie = 0;
424 for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
425 struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
426 ie_table->table[idx++] = r->ie;
427 ie_table->table[idx++] = r->rule;
428
429 if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
430 /* only one vendor specific ie allowed */
431 if (vendor_spec)
432 continue;
433
434 /* for vendor specific rules configure the
435 additional fields */
436 memcpy(&(ie_table->table[idx]), r->oui,
437 CONF_BCN_IE_OUI_LEN);
438 idx += CONF_BCN_IE_OUI_LEN;
439 ie_table->table[idx++] = r->type;
440 memcpy(&(ie_table->table[idx]), r->version,
441 CONF_BCN_IE_VER_LEN);
442 idx += CONF_BCN_IE_VER_LEN;
443 vendor_spec = true;
444 }
445
446 ie_table->num_ie++;
447 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300448
449 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
450 ie_table, sizeof(*ie_table));
451 if (ret < 0) {
452 wl1271_warning("failed to set beacon filter table: %d", ret);
453 goto out;
454 }
455
456out:
457 kfree(ie_table);
458 return ret;
459}
460
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200461#define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
462
463int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable)
Juuso Oikarinen34415232009-10-08 21:56:33 +0300464{
465 struct acx_conn_monit_params *acx;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200466 u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
467 u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
Juuso Oikarinen34415232009-10-08 21:56:33 +0300468 int ret;
469
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200470 wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
471 enable ? "enabled" : "disabled");
Juuso Oikarinen34415232009-10-08 21:56:33 +0300472
473 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
474 if (!acx) {
475 ret = -ENOMEM;
476 goto out;
477 }
478
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200479 if (enable) {
480 threshold = wl->conf.conn.synch_fail_thold;
481 timeout = wl->conf.conn.bss_lose_timeout;
482 }
483
Eliad Peller7f0979882011-08-14 13:17:06 +0300484 acx->role_id = wl->role_id;
Juuso Oikarinen6ccbb922010-03-26 12:53:23 +0200485 acx->synch_fail_thold = cpu_to_le32(threshold);
486 acx->bss_lose_timeout = cpu_to_le32(timeout);
Juuso Oikarinen34415232009-10-08 21:56:33 +0300487
488 ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
489 acx, sizeof(*acx));
490 if (ret < 0) {
491 wl1271_warning("failed to set connection monitor "
492 "parameters: %d", ret);
493 goto out;
494 }
495
496out:
497 kfree(acx);
498 return ret;
499}
500
501
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200502int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300503{
504 struct acx_bt_wlan_coex *pta;
505 int ret;
506
507 wl1271_debug(DEBUG_ACX, "acx sg enable");
508
509 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
510 if (!pta) {
511 ret = -ENOMEM;
512 goto out;
513 }
514
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200515 if (enable)
516 pta->enable = wl->conf.sg.state;
517 else
518 pta->enable = CONF_SG_DISABLE;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300519
520 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
521 if (ret < 0) {
522 wl1271_warning("failed to set softgemini enable: %d", ret);
523 goto out;
524 }
525
526out:
527 kfree(pta);
528 return ret;
529}
530
Eliad Peller3be41122011-08-14 13:17:19 +0300531int wl12xx_acx_sg_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300532{
Eliad Peller3be41122011-08-14 13:17:19 +0300533 struct acx_bt_wlan_coex_param *param;
Juuso Oikarinen2b60100b2009-10-13 12:47:39 +0300534 struct conf_sg_settings *c = &wl->conf.sg;
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200535 int i, ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300536
Eliad Peller3be41122011-08-14 13:17:19 +0300537 wl1271_debug(DEBUG_ACX, "acx sg cfg");
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300538
539 param = kzalloc(sizeof(*param), GFP_KERNEL);
540 if (!param) {
541 ret = -ENOMEM;
542 goto out;
543 }
544
545 /* BT-WLAN coext parameters */
Eliad Peller3be41122011-08-14 13:17:19 +0300546 for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
547 param->params[i] = cpu_to_le32(c->params[i]);
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200548 param->param_idx = CONF_SG_PARAMS_ALL;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300549
550 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
551 if (ret < 0) {
552 wl1271_warning("failed to set sg config: %d", ret);
553 goto out;
554 }
555
556out:
557 kfree(param);
558 return ret;
559}
560
561int wl1271_acx_cca_threshold(struct wl1271 *wl)
562{
563 struct acx_energy_detection *detection;
564 int ret;
565
566 wl1271_debug(DEBUG_ACX, "acx cca threshold");
567
568 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
569 if (!detection) {
570 ret = -ENOMEM;
571 goto out;
572 }
573
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300574 detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
Juuso Oikarinen45b531a2009-10-13 12:47:41 +0300575 detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300576
577 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
578 detection, sizeof(*detection));
579 if (ret < 0) {
580 wl1271_warning("failed to set cca threshold: %d", ret);
581 return ret;
582 }
583
584out:
585 kfree(detection);
586 return ret;
587}
588
589int wl1271_acx_bcn_dtim_options(struct wl1271 *wl)
590{
591 struct acx_beacon_broadcast *bb;
592 int ret;
593
594 wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
595
596 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
597 if (!bb) {
598 ret = -ENOMEM;
599 goto out;
600 }
601
Eliad Peller7f0979882011-08-14 13:17:06 +0300602 bb->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300603 bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
604 bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300605 bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
606 bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300607
608 ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
609 if (ret < 0) {
610 wl1271_warning("failed to set rx config: %d", ret);
611 goto out;
612 }
613
614out:
615 kfree(bb);
616 return ret;
617}
618
619int wl1271_acx_aid(struct wl1271 *wl, u16 aid)
620{
621 struct acx_aid *acx_aid;
622 int ret;
623
624 wl1271_debug(DEBUG_ACX, "acx aid");
625
626 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
627 if (!acx_aid) {
628 ret = -ENOMEM;
629 goto out;
630 }
631
Eliad Peller7f0979882011-08-14 13:17:06 +0300632 acx_aid->role_id = wl->role_id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300633 acx_aid->aid = cpu_to_le16(aid);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300634
635 ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
636 if (ret < 0) {
637 wl1271_warning("failed to set aid: %d", ret);
638 goto out;
639 }
640
641out:
642 kfree(acx_aid);
643 return ret;
644}
645
646int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
647{
648 struct acx_event_mask *mask;
649 int ret;
650
651 wl1271_debug(DEBUG_ACX, "acx event mbox mask");
652
653 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
654 if (!mask) {
655 ret = -ENOMEM;
656 goto out;
657 }
658
659 /* high event mask is unused */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300660 mask->high_event_mask = cpu_to_le32(0xffffffff);
661 mask->event_mask = cpu_to_le32(event_mask);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300662
663 ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
664 mask, sizeof(*mask));
665 if (ret < 0) {
666 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
667 goto out;
668 }
669
670out:
671 kfree(mask);
672 return ret;
673}
674
675int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble)
676{
677 struct acx_preamble *acx;
678 int ret;
679
680 wl1271_debug(DEBUG_ACX, "acx_set_preamble");
681
682 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
683 if (!acx) {
684 ret = -ENOMEM;
685 goto out;
686 }
687
Eliad Peller7f0979882011-08-14 13:17:06 +0300688 acx->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300689 acx->preamble = preamble;
690
691 ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
692 if (ret < 0) {
693 wl1271_warning("Setting of preamble failed: %d", ret);
694 goto out;
695 }
696
697out:
698 kfree(acx);
699 return ret;
700}
701
702int wl1271_acx_cts_protect(struct wl1271 *wl,
703 enum acx_ctsprotect_type ctsprotect)
704{
705 struct acx_ctsprotect *acx;
706 int ret;
707
708 wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
709
710 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
711 if (!acx) {
712 ret = -ENOMEM;
713 goto out;
714 }
715
Eliad Peller7f0979882011-08-14 13:17:06 +0300716 acx->role_id = wl->role_id;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300717 acx->ctsprotect = ctsprotect;
718
719 ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
720 if (ret < 0) {
721 wl1271_warning("Setting of ctsprotect failed: %d", ret);
722 goto out;
723 }
724
725out:
726 kfree(acx);
727 return ret;
728}
729
730int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
731{
732 int ret;
733
734 wl1271_debug(DEBUG_ACX, "acx statistics");
735
736 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
737 sizeof(*stats));
738 if (ret < 0) {
739 wl1271_warning("acx statistics failed: %d", ret);
740 return -ENOMEM;
741 }
742
743 return 0;
744}
745
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200746int wl1271_acx_sta_rate_policies(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300747{
Eliad Peller7f0979882011-08-14 13:17:06 +0300748 struct acx_rate_policy *acx;
Arik Nemtsov1e05a812010-10-16 17:44:51 +0200749 struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300750 int ret = 0;
751
752 wl1271_debug(DEBUG_ACX, "acx rate policies");
753
754 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
755
756 if (!acx) {
757 ret = -ENOMEM;
758 goto out;
759 }
760
Eliad Peller7f0979882011-08-14 13:17:06 +0300761 wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
762 wl->basic_rate, wl->rate_set);
763
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200764 /* configure one basic rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300765 acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE);
766 acx->rate_policy.enabled_rates = cpu_to_le32(wl->basic_rate);
767 acx->rate_policy.short_retry_limit = c->short_retry_limit;
768 acx->rate_policy.long_retry_limit = c->long_retry_limit;
769 acx->rate_policy.aflags = c->aflags;
770
771 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
772 if (ret < 0) {
773 wl1271_warning("Setting of rate policies failed: %d", ret);
774 goto out;
775 }
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200776
777 /* configure one AP supported rate class */
Eliad Peller7f0979882011-08-14 13:17:06 +0300778 acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE);
779 acx->rate_policy.enabled_rates = cpu_to_le32(wl->rate_set);
780 acx->rate_policy.short_retry_limit = c->short_retry_limit;
781 acx->rate_policy.long_retry_limit = c->long_retry_limit;
782 acx->rate_policy.aflags = c->aflags;
Juuso Oikarinen830fb672009-12-11 15:41:06 +0200783
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300784
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200785
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300786 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
787 if (ret < 0) {
788 wl1271_warning("Setting of rate policies failed: %d", ret);
789 goto out;
790 }
791
792out:
793 kfree(acx);
794 return ret;
795}
796
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200797int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
798 u8 idx)
799{
Eliad Peller7f0979882011-08-14 13:17:06 +0300800 struct acx_rate_policy *acx;
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200801 int ret = 0;
802
Arik Nemtsov70f47422011-04-18 14:15:25 +0300803 wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
804 idx, c->enabled_rates);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200805
806 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
807 if (!acx) {
808 ret = -ENOMEM;
809 goto out;
810 }
811
812 acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
813 acx->rate_policy.short_retry_limit = c->short_retry_limit;
814 acx->rate_policy.long_retry_limit = c->long_retry_limit;
815 acx->rate_policy.aflags = c->aflags;
816
Eliad Peller1d4801f2011-01-16 10:07:10 +0100817 acx->rate_policy_idx = cpu_to_le32(idx);
Arik Nemtsov79b223f2010-10-16 17:52:59 +0200818
819 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
820 if (ret < 0) {
821 wl1271_warning("Setting of ap rate policy failed: %d", ret);
822 goto out;
823 }
824
825out:
826 kfree(acx);
827 return ret;
828}
829
Kalle Valo243eeb52010-02-18 13:25:39 +0200830int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
831 u8 aifsn, u16 txop)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300832{
833 struct acx_ac_cfg *acx;
Kalle Valo243eeb52010-02-18 13:25:39 +0200834 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300835
Kalle Valo243eeb52010-02-18 13:25:39 +0200836 wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
837 "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300838
839 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
840
841 if (!acx) {
842 ret = -ENOMEM;
843 goto out;
844 }
845
Eliad Peller7f0979882011-08-14 13:17:06 +0300846 acx->role_id = wl->role_id;
Kalle Valo243eeb52010-02-18 13:25:39 +0200847 acx->ac = ac;
848 acx->cw_min = cw_min;
849 acx->cw_max = cpu_to_le16(cw_max);
850 acx->aifsn = aifsn;
851 acx->tx_op_limit = cpu_to_le16(txop);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300852
Kalle Valo243eeb52010-02-18 13:25:39 +0200853 ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
854 if (ret < 0) {
855 wl1271_warning("acx ac cfg failed: %d", ret);
856 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300857 }
858
859out:
860 kfree(acx);
861 return ret;
862}
863
Kalle Valof2054df2010-02-18 13:25:40 +0200864int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
865 u8 tsid, u8 ps_scheme, u8 ack_policy,
866 u32 apsd_conf0, u32 apsd_conf1)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300867{
868 struct acx_tid_config *acx;
Kalle Valof2054df2010-02-18 13:25:40 +0200869 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300870
871 wl1271_debug(DEBUG_ACX, "acx tid config");
872
873 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
874
875 if (!acx) {
876 ret = -ENOMEM;
877 goto out;
878 }
879
Eliad Peller7f0979882011-08-14 13:17:06 +0300880 acx->role_id = wl->role_id;
Kalle Valof2054df2010-02-18 13:25:40 +0200881 acx->queue_id = queue_id;
882 acx->channel_type = channel_type;
883 acx->tsid = tsid;
884 acx->ps_scheme = ps_scheme;
885 acx->ack_policy = ack_policy;
886 acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
887 acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300888
Kalle Valof2054df2010-02-18 13:25:40 +0200889 ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
890 if (ret < 0) {
891 wl1271_warning("Setting of tid config failed: %d", ret);
892 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300893 }
894
895out:
896 kfree(acx);
897 return ret;
898}
899
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300900int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300901{
902 struct acx_frag_threshold *acx;
903 int ret = 0;
904
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300905 /*
906 * If the fragmentation is not configured or out of range, use the
907 * default value.
908 */
909 if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
910 frag_threshold = wl->conf.tx.frag_threshold;
911
912 wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300913
914 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
915
916 if (!acx) {
917 ret = -ENOMEM;
918 goto out;
919 }
920
Arik Nemtsov5f704d12011-04-18 14:15:21 +0300921 acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300922 ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
923 if (ret < 0) {
924 wl1271_warning("Setting of frag threshold failed: %d", ret);
925 goto out;
926 }
927
928out:
929 kfree(acx);
930 return ret;
931}
932
933int wl1271_acx_tx_config_options(struct wl1271 *wl)
934{
935 struct acx_tx_config_options *acx;
936 int ret = 0;
937
938 wl1271_debug(DEBUG_ACX, "acx tx config options");
939
940 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
941
942 if (!acx) {
943 ret = -ENOMEM;
944 goto out;
945 }
946
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300947 acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
948 acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300949 ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
950 if (ret < 0) {
951 wl1271_warning("Setting of tx options failed: %d", ret);
952 goto out;
953 }
954
955out:
956 kfree(acx);
957 return ret;
958}
959
Eliad Peller7f0979882011-08-14 13:17:06 +0300960int wl12xx_acx_mem_cfg(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300961{
Eliad Peller7f0979882011-08-14 13:17:06 +0300962 struct wl12xx_acx_config_memory *mem_conf;
Shahar Levi13b107d2011-03-06 16:32:12 +0200963 struct conf_memory_settings *mem;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200964 int ret;
965
966 wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
967
968 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
969 if (!mem_conf) {
970 ret = -ENOMEM;
971 goto out;
972 }
973
Shahar Levi13b107d2011-03-06 16:32:12 +0200974 if (wl->chip.id == CHIP_ID_1283_PG20)
975 mem = &wl->conf.mem_wl128x;
976 else
977 mem = &wl->conf.mem_wl127x;
978
Eliad Pellerc8bde242011-02-02 09:59:35 +0200979 /* memory config */
Shahar Levi13b107d2011-03-06 16:32:12 +0200980 mem_conf->num_stations = mem->num_stations;
981 mem_conf->rx_mem_block_num = mem->rx_block_num;
982 mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
983 mem_conf->num_ssid_profiles = mem->ssid_profiles;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200984 mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
Shahar Levi13b107d2011-03-06 16:32:12 +0200985 mem_conf->dyn_mem_enable = mem->dynamic_memory;
986 mem_conf->tx_free_req = mem->min_req_tx_blocks;
987 mem_conf->rx_free_req = mem->min_req_rx_blocks;
988 mem_conf->tx_min = mem->tx_min;
Ido Yariv95dac04f2011-06-06 14:57:06 +0300989 mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200990
991 ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
992 sizeof(*mem_conf));
993 if (ret < 0) {
994 wl1271_warning("wl1271 mem config failed: %d", ret);
995 goto out;
996 }
997
998out:
999 kfree(mem_conf);
1000 return ret;
1001}
1002
Shahar Levi48a61472011-03-06 16:32:08 +02001003int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
1004{
1005 struct wl1271_acx_host_config_bitmap *bitmap_conf;
1006 int ret;
1007
1008 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
1009 if (!bitmap_conf) {
1010 ret = -ENOMEM;
1011 goto out;
1012 }
1013
1014 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
1015
1016 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
1017 bitmap_conf, sizeof(*bitmap_conf));
1018 if (ret < 0) {
1019 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
1020 goto out;
1021 }
1022
1023out:
1024 kfree(bitmap_conf);
1025
1026 return ret;
1027}
1028
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001029int wl1271_acx_init_mem_config(struct wl1271 *wl)
1030{
1031 int ret;
1032
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001033 wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
Juuso Oikarinen45b531a2009-10-13 12:47:41 +03001034 GFP_KERNEL);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001035 if (!wl->target_mem_map) {
1036 wl1271_error("couldn't allocate target memory map");
1037 return -ENOMEM;
1038 }
1039
1040 /* we now ask for the firmware built memory map */
1041 ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
1042 sizeof(struct wl1271_acx_mem_map));
1043 if (ret < 0) {
1044 wl1271_error("couldn't retrieve firmware memory map");
1045 kfree(wl->target_mem_map);
1046 wl->target_mem_map = NULL;
1047 return ret;
1048 }
1049
1050 /* initialize TX block book keeping */
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001051 wl->tx_blocks_available =
1052 le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001053 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1054 wl->tx_blocks_available);
1055
1056 return 0;
1057}
1058
1059int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
1060{
1061 struct wl1271_acx_rx_config_opt *rx_conf;
1062 int ret;
1063
1064 wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
1065
1066 rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
1067 if (!rx_conf) {
1068 ret = -ENOMEM;
1069 goto out;
1070 }
1071
Luciano Coelhod0f63b22009-10-15 10:33:29 +03001072 rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
1073 rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
1074 rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +03001075 rx_conf->queue_type = wl->conf.rx.queue_type;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001076
1077 ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
1078 sizeof(*rx_conf));
1079 if (ret < 0) {
1080 wl1271_warning("wl1271 rx config opt failed: %d", ret);
1081 goto out;
1082 }
1083
1084out:
1085 kfree(rx_conf);
1086 return ret;
1087}
Juuso Oikarinen3cfd6cf2009-10-12 15:08:52 +03001088
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001089int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
1090{
1091 struct wl1271_acx_bet_enable *acx = NULL;
1092 int ret = 0;
1093
1094 wl1271_debug(DEBUG_ACX, "acx bet enable");
1095
1096 if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
1097 goto out;
1098
1099 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1100 if (!acx) {
1101 ret = -ENOMEM;
1102 goto out;
1103 }
1104
Eliad Peller7f0979882011-08-14 13:17:06 +03001105 acx->role_id = wl->role_id;
Juuso Oikarinen11f70f92009-10-13 12:47:46 +03001106 acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
1107 acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
1108
1109 ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
1110 if (ret < 0) {
1111 wl1271_warning("acx bet enable failed: %d", ret);
1112 goto out;
1113 }
1114
1115out:
1116 kfree(acx);
1117 return ret;
1118}
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001119
Eliad Pellerc5312772010-12-09 11:31:27 +02001120int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address)
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001121{
1122 struct wl1271_acx_arp_filter *acx;
1123 int ret;
1124
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001125 wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001126
1127 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1128 if (!acx) {
1129 ret = -ENOMEM;
1130 goto out;
1131 }
1132
Eliad Peller7f0979882011-08-14 13:17:06 +03001133 acx->role_id = wl->role_id;
Juuso Oikarineneb887df2010-07-08 17:49:58 +03001134 acx->version = ACX_IPV4_VERSION;
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001135 acx->enable = enable;
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001136
Eliad Pellerc5312772010-12-09 11:31:27 +02001137 if (enable)
Juuso Oikarinenca52a5e2010-07-08 17:50:02 +03001138 memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
Juuso Oikarinen01c09162009-10-13 12:47:55 +03001139
1140 ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
1141 acx, sizeof(*acx));
1142 if (ret < 0) {
1143 wl1271_warning("failed to set arp ip filter: %d", ret);
1144 goto out;
1145 }
1146
1147out:
1148 kfree(acx);
1149 return ret;
1150}
Juuso Oikarinen38ad2d82009-12-11 15:41:08 +02001151
1152int wl1271_acx_pm_config(struct wl1271 *wl)
1153{
1154 struct wl1271_acx_pm_config *acx = NULL;
1155 struct conf_pm_config_settings *c = &wl->conf.pm_config;
1156 int ret = 0;
1157
1158 wl1271_debug(DEBUG_ACX, "acx pm config");
1159
1160 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1161 if (!acx) {
1162 ret = -ENOMEM;
1163 goto out;
1164 }
1165
1166 acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
1167 acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
1168
1169 ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
1170 if (ret < 0) {
1171 wl1271_warning("acx pm config failed: %d", ret);
1172 goto out;
1173 }
1174
1175out:
1176 kfree(acx);
1177 return ret;
1178}
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001179
1180int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
1181{
1182 struct wl1271_acx_keep_alive_mode *acx = NULL;
1183 int ret = 0;
1184
1185 wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
1186
1187 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1188 if (!acx) {
1189 ret = -ENOMEM;
1190 goto out;
1191 }
1192
Eliad Peller7f0979882011-08-14 13:17:06 +03001193 acx->role_id = wl->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001194 acx->enabled = enable;
1195
1196 ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
1197 if (ret < 0) {
1198 wl1271_warning("acx keep alive mode failed: %d", ret);
1199 goto out;
1200 }
1201
1202out:
1203 kfree(acx);
1204 return ret;
1205}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001206
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001207int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
1208{
1209 struct wl1271_acx_keep_alive_config *acx = NULL;
1210 int ret = 0;
1211
1212 wl1271_debug(DEBUG_ACX, "acx keep alive config");
1213
1214 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1215 if (!acx) {
1216 ret = -ENOMEM;
1217 goto out;
1218 }
1219
Eliad Peller7f0979882011-08-14 13:17:06 +03001220 acx->role_id = wl->role_id;
Juuso Oikarinenc1899552010-03-26 12:53:32 +02001221 acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
1222 acx->index = index;
1223 acx->tpl_validation = tpl_valid;
1224 acx->trigger = ACX_KEEP_ALIVE_NO_TX;
1225
1226 ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
1227 acx, sizeof(*acx));
1228 if (ret < 0) {
1229 wl1271_warning("acx keep alive config failed: %d", ret);
1230 goto out;
1231 }
1232
1233out:
1234 kfree(acx);
1235 return ret;
1236}
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001237
1238int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable,
1239 s16 thold, u8 hyst)
1240{
1241 struct wl1271_acx_rssi_snr_trigger *acx = NULL;
1242 int ret = 0;
1243
1244 wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
1245
1246 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1247 if (!acx) {
1248 ret = -ENOMEM;
1249 goto out;
1250 }
1251
1252 wl->last_rssi_event = -1;
1253
Eliad Peller7f0979882011-08-14 13:17:06 +03001254 acx->role_id = wl->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001255 acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
1256 acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
1257 acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
1258 if (enable)
1259 acx->enable = WL1271_ACX_TRIG_ENABLE;
1260 else
1261 acx->enable = WL1271_ACX_TRIG_DISABLE;
1262
1263 acx->index = WL1271_ACX_TRIG_IDX_RSSI;
1264 acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
1265 acx->threshold = cpu_to_le16(thold);
1266 acx->hysteresis = hyst;
1267
1268 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
1269 if (ret < 0) {
1270 wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
1271 goto out;
1272 }
1273
1274out:
1275 kfree(acx);
1276 return ret;
1277}
1278
1279int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl)
1280{
1281 struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
1282 struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
1283 int ret = 0;
1284
1285 wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
1286
1287 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1288 if (!acx) {
1289 ret = -ENOMEM;
1290 goto out;
1291 }
1292
Eliad Peller7f0979882011-08-14 13:17:06 +03001293 acx->role_id = wl->role_id;
Juuso Oikarinen00236aed2010-04-09 11:07:30 +03001294 acx->rssi_beacon = c->avg_weight_rssi_beacon;
1295 acx->rssi_data = c->avg_weight_rssi_data;
1296 acx->snr_beacon = c->avg_weight_snr_beacon;
1297 acx->snr_data = c->avg_weight_snr_data;
1298
1299 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
1300 if (ret < 0) {
1301 wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
1302 goto out;
1303 }
1304
1305out:
1306 kfree(acx);
1307 return ret;
1308}
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001309
Shahar Levic4db1c82010-10-13 16:09:40 +02001310int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
1311 struct ieee80211_sta_ht_cap *ht_cap,
1312 bool allow_ht_operation)
1313{
1314 struct wl1271_acx_ht_capabilities *acx;
Shahar Levic4db1c82010-10-13 16:09:40 +02001315 int ret = 0;
Eliad Peller6177eae2010-12-22 12:38:52 +01001316 u32 ht_capabilites = 0;
Shahar Levic4db1c82010-10-13 16:09:40 +02001317
1318 wl1271_debug(DEBUG_ACX, "acx ht capabilities setting");
1319
1320 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1321 if (!acx) {
1322 ret = -ENOMEM;
1323 goto out;
1324 }
1325
1326 /* Allow HT Operation ? */
1327 if (allow_ht_operation) {
Eliad Peller6177eae2010-12-22 12:38:52 +01001328 ht_capabilites =
Shahar Levic4db1c82010-10-13 16:09:40 +02001329 WL1271_ACX_FW_CAP_HT_OPERATION;
1330 if (ht_cap->cap & IEEE80211_HT_CAP_GRN_FLD)
Eliad Peller6177eae2010-12-22 12:38:52 +01001331 ht_capabilites |=
Shahar Levic4db1c82010-10-13 16:09:40 +02001332 WL1271_ACX_FW_CAP_GREENFIELD_FRAME_FORMAT;
1333 if (ht_cap->cap & IEEE80211_HT_CAP_SGI_20)
Eliad Peller6177eae2010-12-22 12:38:52 +01001334 ht_capabilites |=
Shahar Levic4db1c82010-10-13 16:09:40 +02001335 WL1271_ACX_FW_CAP_SHORT_GI_FOR_20MHZ_PACKETS;
1336 if (ht_cap->cap & IEEE80211_HT_CAP_LSIG_TXOP_PROT)
Eliad Peller6177eae2010-12-22 12:38:52 +01001337 ht_capabilites |=
Shahar Levic4db1c82010-10-13 16:09:40 +02001338 WL1271_ACX_FW_CAP_LSIG_TXOP_PROTECTION;
1339
1340 /* get data from A-MPDU parameters field */
1341 acx->ampdu_max_length = ht_cap->ampdu_factor;
1342 acx->ampdu_min_spacing = ht_cap->ampdu_density;
Shahar Levic4db1c82010-10-13 16:09:40 +02001343 }
1344
Eliad Peller7f0979882011-08-14 13:17:06 +03001345 acx->hlid = wl->sta_hlid;
Eliad Peller6177eae2010-12-22 12:38:52 +01001346 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
1347
Shahar Levic4db1c82010-10-13 16:09:40 +02001348 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
1349 if (ret < 0) {
1350 wl1271_warning("acx ht capabilities setting failed: %d", ret);
1351 goto out;
1352 }
1353
1354out:
1355 kfree(acx);
1356 return ret;
1357}
1358
1359int wl1271_acx_set_ht_information(struct wl1271 *wl,
1360 u16 ht_operation_mode)
1361{
1362 struct wl1271_acx_ht_information *acx;
1363 int ret = 0;
1364
1365 wl1271_debug(DEBUG_ACX, "acx ht information setting");
1366
1367 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1368 if (!acx) {
1369 ret = -ENOMEM;
1370 goto out;
1371 }
1372
Eliad Peller7f0979882011-08-14 13:17:06 +03001373 acx->role_id = wl->role_id;
Shahar Levic4db1c82010-10-13 16:09:40 +02001374 acx->ht_protection =
1375 (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
1376 acx->rifs_mode = 0;
Helmut Schaa95a77612011-03-02 10:46:46 +01001377 acx->gf_protection =
1378 !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
Shahar Levic4db1c82010-10-13 16:09:40 +02001379 acx->ht_tx_burst_limit = 0;
1380 acx->dual_cts_protection = 0;
1381
1382 ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
1383
1384 if (ret < 0) {
1385 wl1271_warning("acx ht information setting failed: %d", ret);
1386 goto out;
1387 }
1388
1389out:
1390 kfree(acx);
1391 return ret;
1392}
1393
Levi, Shahar4b7fac72011-01-23 07:27:22 +01001394/* Configure BA session initiator/receiver parameters setting in the FW. */
1395int wl1271_acx_set_ba_session(struct wl1271 *wl,
1396 enum ieee80211_back_parties direction,
1397 u8 tid_index, u8 policy)
1398{
1399 struct wl1271_acx_ba_session_policy *acx;
1400 int ret;
1401
1402 wl1271_debug(DEBUG_ACX, "acx ba session setting");
1403
1404 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1405 if (!acx) {
1406 ret = -ENOMEM;
1407 goto out;
1408 }
1409
1410 /* ANY role */
1411 acx->role_id = 0xff;
1412 acx->tid = tid_index;
1413 acx->enable = policy;
1414 acx->ba_direction = direction;
1415
1416 switch (direction) {
1417 case WLAN_BACK_INITIATOR:
1418 acx->win_size = wl->conf.ht.tx_ba_win_size;
1419 acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
1420 break;
1421 case WLAN_BACK_RECIPIENT:
1422 acx->win_size = RX_BA_WIN_SIZE;
1423 acx->inactivity_timeout = 0;
1424 break;
1425 default:
1426 wl1271_error("Incorrect acx command id=%x\n", direction);
1427 ret = -EINVAL;
1428 goto out;
1429 }
1430
1431 ret = wl1271_cmd_configure(wl,
1432 ACX_BA_SESSION_POLICY_CFG,
1433 acx,
1434 sizeof(*acx));
1435 if (ret < 0) {
1436 wl1271_warning("acx ba session setting failed: %d", ret);
1437 goto out;
1438 }
1439
1440out:
1441 kfree(acx);
1442 return ret;
1443}
1444
Levi, Shaharbbba3e62011-01-23 07:27:23 +01001445/* setup BA session receiver setting in the FW. */
1446int wl1271_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn,
1447 bool enable)
1448{
1449 struct wl1271_acx_ba_receiver_setup *acx;
1450 int ret;
1451
1452 wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
1453
1454 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1455 if (!acx) {
1456 ret = -ENOMEM;
1457 goto out;
1458 }
1459
1460 /* Single link for now */
1461 acx->link_id = 1;
1462 acx->tid = tid_index;
1463 acx->enable = enable;
1464 acx->win_size = 0;
1465 acx->ssn = ssn;
1466
1467 ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
1468 sizeof(*acx));
1469 if (ret < 0) {
1470 wl1271_warning("acx ba receiver session failed: %d", ret);
1471 goto out;
1472 }
1473
1474out:
1475 kfree(acx);
1476 return ret;
1477}
1478
Juuso Oikarinenbbbb5382010-07-08 17:49:57 +03001479int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
1480{
1481 struct wl1271_acx_fw_tsf_information *tsf_info;
1482 int ret;
1483
1484 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
1485 if (!tsf_info) {
1486 ret = -ENOMEM;
1487 goto out;
1488 }
1489
1490 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
1491 tsf_info, sizeof(*tsf_info));
1492 if (ret < 0) {
1493 wl1271_warning("acx tsf info interrogate failed");
1494 goto out;
1495 }
1496
1497 *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
1498 ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
1499
1500out:
1501 kfree(tsf_info);
1502 return ret;
1503}
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001504
Eliad Pellerf84673d2011-05-15 11:10:28 +03001505int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable)
1506{
1507 struct wl1271_acx_ps_rx_streaming *rx_streaming;
1508 u32 conf_queues, enable_queues;
1509 int i, ret = 0;
1510
1511 wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
1512
1513 rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
1514 if (!rx_streaming) {
1515 ret = -ENOMEM;
1516 goto out;
1517 }
1518
1519 conf_queues = wl->conf.rx_streaming.queues;
1520 if (enable)
1521 enable_queues = conf_queues;
1522 else
1523 enable_queues = 0;
1524
1525 for (i = 0; i < 8; i++) {
1526 /*
1527 * Skip non-changed queues, to avoid redundant acxs.
1528 * this check assumes conf.rx_streaming.queues can't
1529 * be changed while rx_streaming is enabled.
1530 */
1531 if (!(conf_queues & BIT(i)))
1532 continue;
1533
Eliad Peller7f0979882011-08-14 13:17:06 +03001534 rx_streaming->role_id = wl->role_id;
Eliad Pellerf84673d2011-05-15 11:10:28 +03001535 rx_streaming->tid = i;
1536 rx_streaming->enable = enable_queues & BIT(i);
1537 rx_streaming->period = wl->conf.rx_streaming.interval;
1538 rx_streaming->timeout = wl->conf.rx_streaming.interval;
1539
1540 ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
1541 rx_streaming,
1542 sizeof(*rx_streaming));
1543 if (ret < 0) {
1544 wl1271_warning("acx ps rx streaming failed: %d", ret);
1545 goto out;
1546 }
1547 }
1548out:
1549 kfree(rx_streaming);
1550 return ret;
1551}
1552
Arik Nemtsov3618f302011-06-26 10:36:03 +03001553int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl)
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001554{
Arik Nemtsov3618f302011-06-26 10:36:03 +03001555 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001556 int ret;
1557
Arik Nemtsov3618f302011-06-26 10:36:03 +03001558 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001559
1560 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1561 if (!acx)
1562 return -ENOMEM;
1563
Eliad Peller7f0979882011-08-14 13:17:06 +03001564 acx->role_id = wl->role_id;
Arik Nemtsov3618f302011-06-26 10:36:03 +03001565 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001566
1567 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1568 if (ret < 0) {
Arik Nemtsov3618f302011-06-26 10:36:03 +03001569 wl1271_warning("acx ap max tx retry failed: %d", ret);
Arik Nemtsov79b223f2010-10-16 17:52:59 +02001570 goto out;
1571 }
1572
1573out:
1574 kfree(acx);
1575 return ret;
1576}
Eliad Pelleree608332011-02-02 09:59:34 +02001577
1578int wl1271_acx_config_ps(struct wl1271 *wl)
1579{
1580 struct wl1271_acx_config_ps *config_ps;
1581 int ret;
1582
1583 wl1271_debug(DEBUG_ACX, "acx config ps");
1584
1585 config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
1586 if (!config_ps) {
1587 ret = -ENOMEM;
1588 goto out;
1589 }
1590
1591 config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
1592 config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
1593 config_ps->null_data_rate = cpu_to_le32(wl->basic_rate);
1594
1595 ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
1596 sizeof(*config_ps));
1597
1598 if (ret < 0) {
1599 wl1271_warning("acx config ps failed: %d", ret);
1600 goto out;
1601 }
1602
1603out:
1604 kfree(config_ps);
1605 return ret;
1606}
Arik Nemtsov99a27752011-02-23 00:22:25 +02001607
1608int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
1609{
1610 struct wl1271_acx_inconnection_sta *acx = NULL;
1611 int ret;
1612
1613 wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
1614
1615 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1616 if (!acx)
1617 return -ENOMEM;
1618
1619 memcpy(acx->addr, addr, ETH_ALEN);
1620
1621 ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
1622 acx, sizeof(*acx));
1623 if (ret < 0) {
1624 wl1271_warning("acx set inconnaction sta failed: %d", ret);
1625 goto out;
1626 }
1627
1628out:
1629 kfree(acx);
1630 return ret;
1631}
Shahar Leviff868432011-04-11 15:41:46 +03001632
1633int wl1271_acx_fm_coex(struct wl1271 *wl)
1634{
1635 struct wl1271_acx_fm_coex *acx;
1636 int ret;
1637
1638 wl1271_debug(DEBUG_ACX, "acx fm coex setting");
1639
1640 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1641 if (!acx) {
1642 ret = -ENOMEM;
1643 goto out;
1644 }
1645
1646 acx->enable = wl->conf.fm_coex.enable;
1647 acx->swallow_period = wl->conf.fm_coex.swallow_period;
1648 acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
1649 acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
1650 acx->m_divider_fref_set_1 =
1651 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
1652 acx->m_divider_fref_set_2 =
1653 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
1654 acx->coex_pll_stabilization_time =
1655 cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
1656 acx->ldo_stabilization_time =
1657 cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
1658 acx->fm_disturbed_band_margin =
1659 wl->conf.fm_coex.fm_disturbed_band_margin;
1660 acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
1661
1662 ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
1663 if (ret < 0) {
1664 wl1271_warning("acx fm coex setting failed: %d", ret);
1665 goto out;
1666 }
1667
1668out:
1669 kfree(acx);
1670 return ret;
1671}
Eliad Pellerfa6ad9f2011-08-14 13:17:14 +03001672
1673int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
1674{
1675 struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
1676 struct conf_rate_policy_settings *conf = &wl->conf.rate;
1677 int ret;
1678
1679 wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
1680
1681 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1682 if (!acx)
1683 return -ENOMEM;
1684
1685 acx->index = ACX_RATE_MGMT_ALL_PARAMS;
1686 acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
1687 acx->per_add = cpu_to_le16(conf->per_add);
1688 acx->per_th1 = cpu_to_le16(conf->per_th1);
1689 acx->per_th2 = cpu_to_le16(conf->per_th2);
1690 acx->max_per = cpu_to_le16(conf->max_per);
1691 acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
1692 acx->tx_fail_low_th = conf->tx_fail_low_th;
1693 acx->tx_fail_high_th = conf->tx_fail_high_th;
1694 acx->per_alpha_shift = conf->per_alpha_shift;
1695 acx->per_add_shift = conf->per_add_shift;
1696 acx->per_beta1_shift = conf->per_beta1_shift;
1697 acx->per_beta2_shift = conf->per_beta2_shift;
1698 acx->rate_check_up = conf->rate_check_up;
1699 acx->rate_check_down = conf->rate_check_down;
1700 memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
1701 sizeof(acx->rate_retry_policy));
1702
1703 ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
1704 acx, sizeof(*acx));
1705 if (ret < 0) {
1706 wl1271_warning("acx set rate mgmt params failed: %d", ret);
1707 goto out;
1708 }
1709
1710out:
1711 kfree(acx);
1712 return ret;
1713}