1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun #include "acx.h"
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun #include <linux/module.h>
5*4882a593Smuzhiyun #include <linux/slab.h>
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun #include "wl1251.h"
8*4882a593Smuzhiyun #include "reg.h"
9*4882a593Smuzhiyun #include "cmd.h"
10*4882a593Smuzhiyun #include "ps.h"
11*4882a593Smuzhiyun
wl1251_acx_frame_rates(struct wl1251 * wl,u8 ctrl_rate,u8 ctrl_mod,u8 mgt_rate,u8 mgt_mod)12*4882a593Smuzhiyun int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod,
13*4882a593Smuzhiyun u8 mgt_rate, u8 mgt_mod)
14*4882a593Smuzhiyun {
15*4882a593Smuzhiyun struct acx_fw_gen_frame_rates *rates;
16*4882a593Smuzhiyun int ret;
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx frame rates");
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun rates = kzalloc(sizeof(*rates), GFP_KERNEL);
21*4882a593Smuzhiyun if (!rates)
22*4882a593Smuzhiyun return -ENOMEM;
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun rates->tx_ctrl_frame_rate = ctrl_rate;
25*4882a593Smuzhiyun rates->tx_ctrl_frame_mod = ctrl_mod;
26*4882a593Smuzhiyun rates->tx_mgt_frame_rate = mgt_rate;
27*4882a593Smuzhiyun rates->tx_mgt_frame_mod = mgt_mod;
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_FW_GEN_FRAME_RATES,
30*4882a593Smuzhiyun rates, sizeof(*rates));
31*4882a593Smuzhiyun if (ret < 0) {
32*4882a593Smuzhiyun wl1251_error("Failed to set FW rates and modulation");
33*4882a593Smuzhiyun goto out;
34*4882a593Smuzhiyun }
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun out:
37*4882a593Smuzhiyun kfree(rates);
38*4882a593Smuzhiyun return ret;
39*4882a593Smuzhiyun }
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun
wl1251_acx_station_id(struct wl1251 * wl)42*4882a593Smuzhiyun int wl1251_acx_station_id(struct wl1251 *wl)
43*4882a593Smuzhiyun {
44*4882a593Smuzhiyun struct acx_dot11_station_id *mac;
45*4882a593Smuzhiyun int ret, i;
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx dot11_station_id");
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun mac = kzalloc(sizeof(*mac), GFP_KERNEL);
50*4882a593Smuzhiyun if (!mac)
51*4882a593Smuzhiyun return -ENOMEM;
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun for (i = 0; i < ETH_ALEN; i++)
54*4882a593Smuzhiyun mac->mac[i] = wl->mac_addr[ETH_ALEN - 1 - i];
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, DOT11_STATION_ID, mac, sizeof(*mac));
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun kfree(mac);
59*4882a593Smuzhiyun return ret;
60*4882a593Smuzhiyun }
61*4882a593Smuzhiyun
wl1251_acx_default_key(struct wl1251 * wl,u8 key_id)62*4882a593Smuzhiyun int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id)
63*4882a593Smuzhiyun {
64*4882a593Smuzhiyun struct acx_dot11_default_key *default_key;
65*4882a593Smuzhiyun int ret;
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id);
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun default_key = kzalloc(sizeof(*default_key), GFP_KERNEL);
70*4882a593Smuzhiyun if (!default_key)
71*4882a593Smuzhiyun return -ENOMEM;
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun default_key->id = key_id;
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, DOT11_DEFAULT_KEY,
76*4882a593Smuzhiyun default_key, sizeof(*default_key));
77*4882a593Smuzhiyun if (ret < 0) {
78*4882a593Smuzhiyun wl1251_error("Couldn't set default key");
79*4882a593Smuzhiyun goto out;
80*4882a593Smuzhiyun }
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun wl->default_key = key_id;
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun out:
85*4882a593Smuzhiyun kfree(default_key);
86*4882a593Smuzhiyun return ret;
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun
wl1251_acx_wake_up_conditions(struct wl1251 * wl,u8 wake_up_event,u8 listen_interval)89*4882a593Smuzhiyun int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event,
90*4882a593Smuzhiyun u8 listen_interval)
91*4882a593Smuzhiyun {
92*4882a593Smuzhiyun struct acx_wake_up_condition *wake_up;
93*4882a593Smuzhiyun int ret;
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx wake up conditions");
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
98*4882a593Smuzhiyun if (!wake_up)
99*4882a593Smuzhiyun return -ENOMEM;
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun wake_up->wake_up_event = wake_up_event;
102*4882a593Smuzhiyun wake_up->listen_interval = listen_interval;
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
105*4882a593Smuzhiyun wake_up, sizeof(*wake_up));
106*4882a593Smuzhiyun if (ret < 0) {
107*4882a593Smuzhiyun wl1251_warning("could not set wake up conditions: %d", ret);
108*4882a593Smuzhiyun goto out;
109*4882a593Smuzhiyun }
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun out:
112*4882a593Smuzhiyun kfree(wake_up);
113*4882a593Smuzhiyun return ret;
114*4882a593Smuzhiyun }
115*4882a593Smuzhiyun
wl1251_acx_sleep_auth(struct wl1251 * wl,u8 sleep_auth)116*4882a593Smuzhiyun int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth)
117*4882a593Smuzhiyun {
118*4882a593Smuzhiyun struct acx_sleep_auth *auth;
119*4882a593Smuzhiyun int ret;
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx sleep auth");
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun auth = kzalloc(sizeof(*auth), GFP_KERNEL);
124*4882a593Smuzhiyun if (!auth)
125*4882a593Smuzhiyun return -ENOMEM;
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun auth->sleep_auth = sleep_auth;
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun kfree(auth);
132*4882a593Smuzhiyun return ret;
133*4882a593Smuzhiyun }
134*4882a593Smuzhiyun
wl1251_acx_fw_version(struct wl1251 * wl,char * buf,size_t len)135*4882a593Smuzhiyun int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len)
136*4882a593Smuzhiyun {
137*4882a593Smuzhiyun struct acx_revision *rev;
138*4882a593Smuzhiyun int ret;
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx fw rev");
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun rev = kzalloc(sizeof(*rev), GFP_KERNEL);
143*4882a593Smuzhiyun if (!rev)
144*4882a593Smuzhiyun return -ENOMEM;
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun ret = wl1251_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev));
147*4882a593Smuzhiyun if (ret < 0) {
148*4882a593Smuzhiyun wl1251_warning("ACX_FW_REV interrogate failed");
149*4882a593Smuzhiyun goto out;
150*4882a593Smuzhiyun }
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun /* be careful with the buffer sizes */
153*4882a593Smuzhiyun strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun /*
156*4882a593Smuzhiyun * if the firmware version string is exactly
157*4882a593Smuzhiyun * sizeof(rev->fw_version) long or fw_len is less than
158*4882a593Smuzhiyun * sizeof(rev->fw_version) it won't be null terminated
159*4882a593Smuzhiyun */
160*4882a593Smuzhiyun buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun out:
163*4882a593Smuzhiyun kfree(rev);
164*4882a593Smuzhiyun return ret;
165*4882a593Smuzhiyun }
166*4882a593Smuzhiyun
wl1251_acx_tx_power(struct wl1251 * wl,int power)167*4882a593Smuzhiyun int wl1251_acx_tx_power(struct wl1251 *wl, int power)
168*4882a593Smuzhiyun {
169*4882a593Smuzhiyun struct acx_current_tx_power *acx;
170*4882a593Smuzhiyun int ret;
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr");
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun if (power < 0 || power > 25)
175*4882a593Smuzhiyun return -EINVAL;
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
178*4882a593Smuzhiyun if (!acx)
179*4882a593Smuzhiyun return -ENOMEM;
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun acx->current_tx_power = power * 10;
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
184*4882a593Smuzhiyun if (ret < 0) {
185*4882a593Smuzhiyun wl1251_warning("configure of tx power failed: %d", ret);
186*4882a593Smuzhiyun goto out;
187*4882a593Smuzhiyun }
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun out:
190*4882a593Smuzhiyun kfree(acx);
191*4882a593Smuzhiyun return ret;
192*4882a593Smuzhiyun }
193*4882a593Smuzhiyun
wl1251_acx_feature_cfg(struct wl1251 * wl,u32 data_flow_options)194*4882a593Smuzhiyun int wl1251_acx_feature_cfg(struct wl1251 *wl, u32 data_flow_options)
195*4882a593Smuzhiyun {
196*4882a593Smuzhiyun struct acx_feature_config *feature;
197*4882a593Smuzhiyun int ret;
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx feature cfg");
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun feature = kzalloc(sizeof(*feature), GFP_KERNEL);
202*4882a593Smuzhiyun if (!feature)
203*4882a593Smuzhiyun return -ENOMEM;
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE can be set */
206*4882a593Smuzhiyun feature->data_flow_options = data_flow_options;
207*4882a593Smuzhiyun feature->options = 0;
208*4882a593Smuzhiyun
209*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG,
210*4882a593Smuzhiyun feature, sizeof(*feature));
211*4882a593Smuzhiyun if (ret < 0) {
212*4882a593Smuzhiyun wl1251_error("Couldn't set HW encryption");
213*4882a593Smuzhiyun goto out;
214*4882a593Smuzhiyun }
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun out:
217*4882a593Smuzhiyun kfree(feature);
218*4882a593Smuzhiyun return ret;
219*4882a593Smuzhiyun }
220*4882a593Smuzhiyun
wl1251_acx_mem_map(struct wl1251 * wl,struct acx_header * mem_map,size_t len)221*4882a593Smuzhiyun int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map,
222*4882a593Smuzhiyun size_t len)
223*4882a593Smuzhiyun {
224*4882a593Smuzhiyun int ret;
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx mem map");
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun ret = wl1251_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
229*4882a593Smuzhiyun if (ret < 0)
230*4882a593Smuzhiyun return ret;
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun return 0;
233*4882a593Smuzhiyun }
234*4882a593Smuzhiyun
wl1251_acx_data_path_params(struct wl1251 * wl,struct acx_data_path_params_resp * resp)235*4882a593Smuzhiyun int wl1251_acx_data_path_params(struct wl1251 *wl,
236*4882a593Smuzhiyun struct acx_data_path_params_resp *resp)
237*4882a593Smuzhiyun {
238*4882a593Smuzhiyun struct acx_data_path_params *params;
239*4882a593Smuzhiyun int ret;
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx data path params");
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun params = kzalloc(sizeof(*params), GFP_KERNEL);
244*4882a593Smuzhiyun if (!params)
245*4882a593Smuzhiyun return -ENOMEM;
246*4882a593Smuzhiyun
247*4882a593Smuzhiyun params->rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE;
248*4882a593Smuzhiyun params->tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE;
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun params->rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM;
251*4882a593Smuzhiyun params->tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM;
252*4882a593Smuzhiyun
253*4882a593Smuzhiyun params->tx_complete_threshold = 1;
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun params->tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE;
256*4882a593Smuzhiyun
257*4882a593Smuzhiyun params->tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT;
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_DATA_PATH_PARAMS,
260*4882a593Smuzhiyun params, sizeof(*params));
261*4882a593Smuzhiyun if (ret < 0)
262*4882a593Smuzhiyun goto out;
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun /* FIXME: shouldn't this be ACX_DATA_PATH_RESP_PARAMS? */
265*4882a593Smuzhiyun ret = wl1251_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS,
266*4882a593Smuzhiyun resp, sizeof(*resp));
267*4882a593Smuzhiyun
268*4882a593Smuzhiyun if (ret < 0) {
269*4882a593Smuzhiyun wl1251_warning("failed to read data path parameters: %d", ret);
270*4882a593Smuzhiyun goto out;
271*4882a593Smuzhiyun } else if (resp->header.cmd.status != CMD_STATUS_SUCCESS) {
272*4882a593Smuzhiyun wl1251_warning("data path parameter acx status failed");
273*4882a593Smuzhiyun ret = -EIO;
274*4882a593Smuzhiyun goto out;
275*4882a593Smuzhiyun }
276*4882a593Smuzhiyun
277*4882a593Smuzhiyun out:
278*4882a593Smuzhiyun kfree(params);
279*4882a593Smuzhiyun return ret;
280*4882a593Smuzhiyun }
281*4882a593Smuzhiyun
wl1251_acx_rx_msdu_life_time(struct wl1251 * wl,u32 life_time)282*4882a593Smuzhiyun int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time)
283*4882a593Smuzhiyun {
284*4882a593Smuzhiyun struct acx_rx_msdu_lifetime *acx;
285*4882a593Smuzhiyun int ret;
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx rx msdu life time");
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
290*4882a593Smuzhiyun if (!acx)
291*4882a593Smuzhiyun return -ENOMEM;
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun acx->lifetime = life_time;
294*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
295*4882a593Smuzhiyun acx, sizeof(*acx));
296*4882a593Smuzhiyun if (ret < 0) {
297*4882a593Smuzhiyun wl1251_warning("failed to set rx msdu life time: %d", ret);
298*4882a593Smuzhiyun goto out;
299*4882a593Smuzhiyun }
300*4882a593Smuzhiyun
301*4882a593Smuzhiyun out:
302*4882a593Smuzhiyun kfree(acx);
303*4882a593Smuzhiyun return ret;
304*4882a593Smuzhiyun }
305*4882a593Smuzhiyun
wl1251_acx_rx_config(struct wl1251 * wl,u32 config,u32 filter)306*4882a593Smuzhiyun int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter)
307*4882a593Smuzhiyun {
308*4882a593Smuzhiyun struct acx_rx_config *rx_config;
309*4882a593Smuzhiyun int ret;
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx rx config");
312*4882a593Smuzhiyun
313*4882a593Smuzhiyun rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL);
314*4882a593Smuzhiyun if (!rx_config)
315*4882a593Smuzhiyun return -ENOMEM;
316*4882a593Smuzhiyun
317*4882a593Smuzhiyun rx_config->config_options = config;
318*4882a593Smuzhiyun rx_config->filter_options = filter;
319*4882a593Smuzhiyun
320*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_RX_CFG,
321*4882a593Smuzhiyun rx_config, sizeof(*rx_config));
322*4882a593Smuzhiyun if (ret < 0) {
323*4882a593Smuzhiyun wl1251_warning("failed to set rx config: %d", ret);
324*4882a593Smuzhiyun goto out;
325*4882a593Smuzhiyun }
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun out:
328*4882a593Smuzhiyun kfree(rx_config);
329*4882a593Smuzhiyun return ret;
330*4882a593Smuzhiyun }
331*4882a593Smuzhiyun
wl1251_acx_pd_threshold(struct wl1251 * wl)332*4882a593Smuzhiyun int wl1251_acx_pd_threshold(struct wl1251 *wl)
333*4882a593Smuzhiyun {
334*4882a593Smuzhiyun struct acx_packet_detection *pd;
335*4882a593Smuzhiyun int ret;
336*4882a593Smuzhiyun
337*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx data pd threshold");
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun pd = kzalloc(sizeof(*pd), GFP_KERNEL);
340*4882a593Smuzhiyun if (!pd)
341*4882a593Smuzhiyun return -ENOMEM;
342*4882a593Smuzhiyun
343*4882a593Smuzhiyun /* FIXME: threshold value not set */
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
346*4882a593Smuzhiyun if (ret < 0) {
347*4882a593Smuzhiyun wl1251_warning("failed to set pd threshold: %d", ret);
348*4882a593Smuzhiyun goto out;
349*4882a593Smuzhiyun }
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun out:
352*4882a593Smuzhiyun kfree(pd);
353*4882a593Smuzhiyun return ret;
354*4882a593Smuzhiyun }
355*4882a593Smuzhiyun
wl1251_acx_slot(struct wl1251 * wl,enum acx_slot_type slot_time)356*4882a593Smuzhiyun int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time)
357*4882a593Smuzhiyun {
358*4882a593Smuzhiyun struct acx_slot *slot;
359*4882a593Smuzhiyun int ret;
360*4882a593Smuzhiyun
361*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx slot");
362*4882a593Smuzhiyun
363*4882a593Smuzhiyun slot = kzalloc(sizeof(*slot), GFP_KERNEL);
364*4882a593Smuzhiyun if (!slot)
365*4882a593Smuzhiyun return -ENOMEM;
366*4882a593Smuzhiyun
367*4882a593Smuzhiyun slot->wone_index = STATION_WONE_INDEX;
368*4882a593Smuzhiyun slot->slot_time = slot_time;
369*4882a593Smuzhiyun
370*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
371*4882a593Smuzhiyun if (ret < 0) {
372*4882a593Smuzhiyun wl1251_warning("failed to set slot time: %d", ret);
373*4882a593Smuzhiyun goto out;
374*4882a593Smuzhiyun }
375*4882a593Smuzhiyun
376*4882a593Smuzhiyun out:
377*4882a593Smuzhiyun kfree(slot);
378*4882a593Smuzhiyun return ret;
379*4882a593Smuzhiyun }
380*4882a593Smuzhiyun
wl1251_acx_group_address_tbl(struct wl1251 * wl,bool enable,void * mc_list,u32 mc_list_len)381*4882a593Smuzhiyun int wl1251_acx_group_address_tbl(struct wl1251 *wl, bool enable,
382*4882a593Smuzhiyun void *mc_list, u32 mc_list_len)
383*4882a593Smuzhiyun {
384*4882a593Smuzhiyun struct acx_dot11_grp_addr_tbl *acx;
385*4882a593Smuzhiyun int ret;
386*4882a593Smuzhiyun
387*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx group address tbl");
388*4882a593Smuzhiyun
389*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
390*4882a593Smuzhiyun if (!acx)
391*4882a593Smuzhiyun return -ENOMEM;
392*4882a593Smuzhiyun
393*4882a593Smuzhiyun /* MAC filtering */
394*4882a593Smuzhiyun acx->enabled = enable;
395*4882a593Smuzhiyun acx->num_groups = mc_list_len;
396*4882a593Smuzhiyun memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
397*4882a593Smuzhiyun
398*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
399*4882a593Smuzhiyun acx, sizeof(*acx));
400*4882a593Smuzhiyun if (ret < 0) {
401*4882a593Smuzhiyun wl1251_warning("failed to set group addr table: %d", ret);
402*4882a593Smuzhiyun goto out;
403*4882a593Smuzhiyun }
404*4882a593Smuzhiyun
405*4882a593Smuzhiyun out:
406*4882a593Smuzhiyun kfree(acx);
407*4882a593Smuzhiyun return ret;
408*4882a593Smuzhiyun }
409*4882a593Smuzhiyun
wl1251_acx_service_period_timeout(struct wl1251 * wl)410*4882a593Smuzhiyun int wl1251_acx_service_period_timeout(struct wl1251 *wl)
411*4882a593Smuzhiyun {
412*4882a593Smuzhiyun struct acx_rx_timeout *rx_timeout;
413*4882a593Smuzhiyun int ret;
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
416*4882a593Smuzhiyun if (!rx_timeout)
417*4882a593Smuzhiyun return -ENOMEM;
418*4882a593Smuzhiyun
419*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx service period timeout");
420*4882a593Smuzhiyun
421*4882a593Smuzhiyun rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF;
422*4882a593Smuzhiyun rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF;
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
425*4882a593Smuzhiyun rx_timeout, sizeof(*rx_timeout));
426*4882a593Smuzhiyun if (ret < 0) {
427*4882a593Smuzhiyun wl1251_warning("failed to set service period timeout: %d",
428*4882a593Smuzhiyun ret);
429*4882a593Smuzhiyun goto out;
430*4882a593Smuzhiyun }
431*4882a593Smuzhiyun
432*4882a593Smuzhiyun out:
433*4882a593Smuzhiyun kfree(rx_timeout);
434*4882a593Smuzhiyun return ret;
435*4882a593Smuzhiyun }
436*4882a593Smuzhiyun
wl1251_acx_rts_threshold(struct wl1251 * wl,u16 rts_threshold)437*4882a593Smuzhiyun int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold)
438*4882a593Smuzhiyun {
439*4882a593Smuzhiyun struct acx_rts_threshold *rts;
440*4882a593Smuzhiyun int ret;
441*4882a593Smuzhiyun
442*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx rts threshold");
443*4882a593Smuzhiyun
444*4882a593Smuzhiyun rts = kzalloc(sizeof(*rts), GFP_KERNEL);
445*4882a593Smuzhiyun if (!rts)
446*4882a593Smuzhiyun return -ENOMEM;
447*4882a593Smuzhiyun
448*4882a593Smuzhiyun rts->threshold = rts_threshold;
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
451*4882a593Smuzhiyun if (ret < 0) {
452*4882a593Smuzhiyun wl1251_warning("failed to set rts threshold: %d", ret);
453*4882a593Smuzhiyun goto out;
454*4882a593Smuzhiyun }
455*4882a593Smuzhiyun
456*4882a593Smuzhiyun out:
457*4882a593Smuzhiyun kfree(rts);
458*4882a593Smuzhiyun return ret;
459*4882a593Smuzhiyun }
460*4882a593Smuzhiyun
wl1251_acx_beacon_filter_opt(struct wl1251 * wl,bool enable_filter)461*4882a593Smuzhiyun int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter)
462*4882a593Smuzhiyun {
463*4882a593Smuzhiyun struct acx_beacon_filter_option *beacon_filter;
464*4882a593Smuzhiyun int ret;
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx beacon filter opt");
467*4882a593Smuzhiyun
468*4882a593Smuzhiyun beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
469*4882a593Smuzhiyun if (!beacon_filter)
470*4882a593Smuzhiyun return -ENOMEM;
471*4882a593Smuzhiyun
472*4882a593Smuzhiyun beacon_filter->enable = enable_filter;
473*4882a593Smuzhiyun beacon_filter->max_num_beacons = 0;
474*4882a593Smuzhiyun
475*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
476*4882a593Smuzhiyun beacon_filter, sizeof(*beacon_filter));
477*4882a593Smuzhiyun if (ret < 0) {
478*4882a593Smuzhiyun wl1251_warning("failed to set beacon filter opt: %d", ret);
479*4882a593Smuzhiyun goto out;
480*4882a593Smuzhiyun }
481*4882a593Smuzhiyun
482*4882a593Smuzhiyun out:
483*4882a593Smuzhiyun kfree(beacon_filter);
484*4882a593Smuzhiyun return ret;
485*4882a593Smuzhiyun }
486*4882a593Smuzhiyun
wl1251_acx_beacon_filter_table(struct wl1251 * wl)487*4882a593Smuzhiyun int wl1251_acx_beacon_filter_table(struct wl1251 *wl)
488*4882a593Smuzhiyun {
489*4882a593Smuzhiyun struct acx_beacon_filter_ie_table *ie_table;
490*4882a593Smuzhiyun int idx = 0;
491*4882a593Smuzhiyun int ret;
492*4882a593Smuzhiyun
493*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx beacon filter table");
494*4882a593Smuzhiyun
495*4882a593Smuzhiyun ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
496*4882a593Smuzhiyun if (!ie_table)
497*4882a593Smuzhiyun return -ENOMEM;
498*4882a593Smuzhiyun
499*4882a593Smuzhiyun /* configure default beacon pass-through rules */
500*4882a593Smuzhiyun ie_table->num_ie = 1;
501*4882a593Smuzhiyun ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN;
502*4882a593Smuzhiyun ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE;
503*4882a593Smuzhiyun
504*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
505*4882a593Smuzhiyun ie_table, sizeof(*ie_table));
506*4882a593Smuzhiyun if (ret < 0) {
507*4882a593Smuzhiyun wl1251_warning("failed to set beacon filter table: %d", ret);
508*4882a593Smuzhiyun goto out;
509*4882a593Smuzhiyun }
510*4882a593Smuzhiyun
511*4882a593Smuzhiyun out:
512*4882a593Smuzhiyun kfree(ie_table);
513*4882a593Smuzhiyun return ret;
514*4882a593Smuzhiyun }
515*4882a593Smuzhiyun
wl1251_acx_conn_monit_params(struct wl1251 * wl)516*4882a593Smuzhiyun int wl1251_acx_conn_monit_params(struct wl1251 *wl)
517*4882a593Smuzhiyun {
518*4882a593Smuzhiyun struct acx_conn_monit_params *acx;
519*4882a593Smuzhiyun int ret;
520*4882a593Smuzhiyun
521*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx connection monitor parameters");
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
524*4882a593Smuzhiyun if (!acx)
525*4882a593Smuzhiyun return -ENOMEM;
526*4882a593Smuzhiyun
527*4882a593Smuzhiyun acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD;
528*4882a593Smuzhiyun acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT;
529*4882a593Smuzhiyun
530*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
531*4882a593Smuzhiyun acx, sizeof(*acx));
532*4882a593Smuzhiyun if (ret < 0) {
533*4882a593Smuzhiyun wl1251_warning("failed to set connection monitor "
534*4882a593Smuzhiyun "parameters: %d", ret);
535*4882a593Smuzhiyun goto out;
536*4882a593Smuzhiyun }
537*4882a593Smuzhiyun
538*4882a593Smuzhiyun out:
539*4882a593Smuzhiyun kfree(acx);
540*4882a593Smuzhiyun return ret;
541*4882a593Smuzhiyun }
542*4882a593Smuzhiyun
wl1251_acx_sg_enable(struct wl1251 * wl)543*4882a593Smuzhiyun int wl1251_acx_sg_enable(struct wl1251 *wl)
544*4882a593Smuzhiyun {
545*4882a593Smuzhiyun struct acx_bt_wlan_coex *pta;
546*4882a593Smuzhiyun int ret;
547*4882a593Smuzhiyun
548*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx sg enable");
549*4882a593Smuzhiyun
550*4882a593Smuzhiyun pta = kzalloc(sizeof(*pta), GFP_KERNEL);
551*4882a593Smuzhiyun if (!pta)
552*4882a593Smuzhiyun return -ENOMEM;
553*4882a593Smuzhiyun
554*4882a593Smuzhiyun pta->enable = SG_ENABLE;
555*4882a593Smuzhiyun
556*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
557*4882a593Smuzhiyun if (ret < 0) {
558*4882a593Smuzhiyun wl1251_warning("failed to set softgemini enable: %d", ret);
559*4882a593Smuzhiyun goto out;
560*4882a593Smuzhiyun }
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun out:
563*4882a593Smuzhiyun kfree(pta);
564*4882a593Smuzhiyun return ret;
565*4882a593Smuzhiyun }
566*4882a593Smuzhiyun
wl1251_acx_sg_cfg(struct wl1251 * wl)567*4882a593Smuzhiyun int wl1251_acx_sg_cfg(struct wl1251 *wl)
568*4882a593Smuzhiyun {
569*4882a593Smuzhiyun struct acx_bt_wlan_coex_param *param;
570*4882a593Smuzhiyun int ret;
571*4882a593Smuzhiyun
572*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx sg cfg");
573*4882a593Smuzhiyun
574*4882a593Smuzhiyun param = kzalloc(sizeof(*param), GFP_KERNEL);
575*4882a593Smuzhiyun if (!param)
576*4882a593Smuzhiyun return -ENOMEM;
577*4882a593Smuzhiyun
578*4882a593Smuzhiyun /* BT-WLAN coext parameters */
579*4882a593Smuzhiyun param->min_rate = RATE_INDEX_24MBPS;
580*4882a593Smuzhiyun param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
581*4882a593Smuzhiyun param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
582*4882a593Smuzhiyun param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
583*4882a593Smuzhiyun param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
584*4882a593Smuzhiyun param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
585*4882a593Smuzhiyun param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
586*4882a593Smuzhiyun param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
587*4882a593Smuzhiyun param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
588*4882a593Smuzhiyun param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
589*4882a593Smuzhiyun param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
590*4882a593Smuzhiyun param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
591*4882a593Smuzhiyun param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
592*4882a593Smuzhiyun param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
593*4882a593Smuzhiyun param->antenna_type = PTA_ANTENNA_TYPE_DEF;
594*4882a593Smuzhiyun param->signal_type = PTA_SIGNALING_TYPE_DEF;
595*4882a593Smuzhiyun param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
596*4882a593Smuzhiyun param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
597*4882a593Smuzhiyun param->max_cts = PTA_MAX_NUM_CTS_DEF;
598*4882a593Smuzhiyun param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
599*4882a593Smuzhiyun param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
600*4882a593Smuzhiyun param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
601*4882a593Smuzhiyun param->wlan_elp_hp = PTA_ELP_HP_DEF;
602*4882a593Smuzhiyun param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
603*4882a593Smuzhiyun param->ack_mode_dual_ant = PTA_ACK_MODE_DEF;
604*4882a593Smuzhiyun param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
605*4882a593Smuzhiyun param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
606*4882a593Smuzhiyun param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
607*4882a593Smuzhiyun
608*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
609*4882a593Smuzhiyun if (ret < 0) {
610*4882a593Smuzhiyun wl1251_warning("failed to set sg config: %d", ret);
611*4882a593Smuzhiyun goto out;
612*4882a593Smuzhiyun }
613*4882a593Smuzhiyun
614*4882a593Smuzhiyun out:
615*4882a593Smuzhiyun kfree(param);
616*4882a593Smuzhiyun return ret;
617*4882a593Smuzhiyun }
618*4882a593Smuzhiyun
wl1251_acx_cca_threshold(struct wl1251 * wl)619*4882a593Smuzhiyun int wl1251_acx_cca_threshold(struct wl1251 *wl)
620*4882a593Smuzhiyun {
621*4882a593Smuzhiyun struct acx_energy_detection *detection;
622*4882a593Smuzhiyun int ret;
623*4882a593Smuzhiyun
624*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx cca threshold");
625*4882a593Smuzhiyun
626*4882a593Smuzhiyun detection = kzalloc(sizeof(*detection), GFP_KERNEL);
627*4882a593Smuzhiyun if (!detection)
628*4882a593Smuzhiyun return -ENOMEM;
629*4882a593Smuzhiyun
630*4882a593Smuzhiyun detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
631*4882a593Smuzhiyun detection->tx_energy_detection = 0;
632*4882a593Smuzhiyun
633*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD,
634*4882a593Smuzhiyun detection, sizeof(*detection));
635*4882a593Smuzhiyun if (ret < 0)
636*4882a593Smuzhiyun wl1251_warning("failed to set cca threshold: %d", ret);
637*4882a593Smuzhiyun
638*4882a593Smuzhiyun kfree(detection);
639*4882a593Smuzhiyun return ret;
640*4882a593Smuzhiyun }
641*4882a593Smuzhiyun
wl1251_acx_bcn_dtim_options(struct wl1251 * wl)642*4882a593Smuzhiyun int wl1251_acx_bcn_dtim_options(struct wl1251 *wl)
643*4882a593Smuzhiyun {
644*4882a593Smuzhiyun struct acx_beacon_broadcast *bb;
645*4882a593Smuzhiyun int ret;
646*4882a593Smuzhiyun
647*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx bcn dtim options");
648*4882a593Smuzhiyun
649*4882a593Smuzhiyun bb = kzalloc(sizeof(*bb), GFP_KERNEL);
650*4882a593Smuzhiyun if (!bb)
651*4882a593Smuzhiyun return -ENOMEM;
652*4882a593Smuzhiyun
653*4882a593Smuzhiyun bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
654*4882a593Smuzhiyun bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
655*4882a593Smuzhiyun bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
656*4882a593Smuzhiyun bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
657*4882a593Smuzhiyun
658*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
659*4882a593Smuzhiyun if (ret < 0) {
660*4882a593Smuzhiyun wl1251_warning("failed to set rx config: %d", ret);
661*4882a593Smuzhiyun goto out;
662*4882a593Smuzhiyun }
663*4882a593Smuzhiyun
664*4882a593Smuzhiyun out:
665*4882a593Smuzhiyun kfree(bb);
666*4882a593Smuzhiyun return ret;
667*4882a593Smuzhiyun }
668*4882a593Smuzhiyun
wl1251_acx_aid(struct wl1251 * wl,u16 aid)669*4882a593Smuzhiyun int wl1251_acx_aid(struct wl1251 *wl, u16 aid)
670*4882a593Smuzhiyun {
671*4882a593Smuzhiyun struct acx_aid *acx_aid;
672*4882a593Smuzhiyun int ret;
673*4882a593Smuzhiyun
674*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx aid");
675*4882a593Smuzhiyun
676*4882a593Smuzhiyun acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
677*4882a593Smuzhiyun if (!acx_aid)
678*4882a593Smuzhiyun return -ENOMEM;
679*4882a593Smuzhiyun
680*4882a593Smuzhiyun acx_aid->aid = aid;
681*4882a593Smuzhiyun
682*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
683*4882a593Smuzhiyun if (ret < 0) {
684*4882a593Smuzhiyun wl1251_warning("failed to set aid: %d", ret);
685*4882a593Smuzhiyun goto out;
686*4882a593Smuzhiyun }
687*4882a593Smuzhiyun
688*4882a593Smuzhiyun out:
689*4882a593Smuzhiyun kfree(acx_aid);
690*4882a593Smuzhiyun return ret;
691*4882a593Smuzhiyun }
692*4882a593Smuzhiyun
wl1251_acx_event_mbox_mask(struct wl1251 * wl,u32 event_mask)693*4882a593Smuzhiyun int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask)
694*4882a593Smuzhiyun {
695*4882a593Smuzhiyun struct acx_event_mask *mask;
696*4882a593Smuzhiyun int ret;
697*4882a593Smuzhiyun
698*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx event mbox mask");
699*4882a593Smuzhiyun
700*4882a593Smuzhiyun mask = kzalloc(sizeof(*mask), GFP_KERNEL);
701*4882a593Smuzhiyun if (!mask)
702*4882a593Smuzhiyun return -ENOMEM;
703*4882a593Smuzhiyun
704*4882a593Smuzhiyun /* high event mask is unused */
705*4882a593Smuzhiyun mask->high_event_mask = 0xffffffff;
706*4882a593Smuzhiyun
707*4882a593Smuzhiyun mask->event_mask = event_mask;
708*4882a593Smuzhiyun
709*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
710*4882a593Smuzhiyun mask, sizeof(*mask));
711*4882a593Smuzhiyun if (ret < 0) {
712*4882a593Smuzhiyun wl1251_warning("failed to set acx_event_mbox_mask: %d", ret);
713*4882a593Smuzhiyun goto out;
714*4882a593Smuzhiyun }
715*4882a593Smuzhiyun
716*4882a593Smuzhiyun out:
717*4882a593Smuzhiyun kfree(mask);
718*4882a593Smuzhiyun return ret;
719*4882a593Smuzhiyun }
720*4882a593Smuzhiyun
wl1251_acx_low_rssi(struct wl1251 * wl,s8 threshold,u8 weight,u8 depth,enum wl1251_acx_low_rssi_type type)721*4882a593Smuzhiyun int wl1251_acx_low_rssi(struct wl1251 *wl, s8 threshold, u8 weight,
722*4882a593Smuzhiyun u8 depth, enum wl1251_acx_low_rssi_type type)
723*4882a593Smuzhiyun {
724*4882a593Smuzhiyun struct acx_low_rssi *rssi;
725*4882a593Smuzhiyun int ret;
726*4882a593Smuzhiyun
727*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx low rssi");
728*4882a593Smuzhiyun
729*4882a593Smuzhiyun rssi = kzalloc(sizeof(*rssi), GFP_KERNEL);
730*4882a593Smuzhiyun if (!rssi)
731*4882a593Smuzhiyun return -ENOMEM;
732*4882a593Smuzhiyun
733*4882a593Smuzhiyun rssi->threshold = threshold;
734*4882a593Smuzhiyun rssi->weight = weight;
735*4882a593Smuzhiyun rssi->depth = depth;
736*4882a593Smuzhiyun rssi->type = type;
737*4882a593Smuzhiyun
738*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_LOW_RSSI, rssi, sizeof(*rssi));
739*4882a593Smuzhiyun if (ret < 0)
740*4882a593Smuzhiyun wl1251_warning("failed to set low rssi threshold: %d", ret);
741*4882a593Smuzhiyun
742*4882a593Smuzhiyun kfree(rssi);
743*4882a593Smuzhiyun return ret;
744*4882a593Smuzhiyun }
745*4882a593Smuzhiyun
wl1251_acx_set_preamble(struct wl1251 * wl,enum acx_preamble_type preamble)746*4882a593Smuzhiyun int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble)
747*4882a593Smuzhiyun {
748*4882a593Smuzhiyun struct acx_preamble *acx;
749*4882a593Smuzhiyun int ret;
750*4882a593Smuzhiyun
751*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx_set_preamble");
752*4882a593Smuzhiyun
753*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
754*4882a593Smuzhiyun if (!acx)
755*4882a593Smuzhiyun return -ENOMEM;
756*4882a593Smuzhiyun
757*4882a593Smuzhiyun acx->preamble = preamble;
758*4882a593Smuzhiyun
759*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
760*4882a593Smuzhiyun if (ret < 0) {
761*4882a593Smuzhiyun wl1251_warning("Setting of preamble failed: %d", ret);
762*4882a593Smuzhiyun goto out;
763*4882a593Smuzhiyun }
764*4882a593Smuzhiyun
765*4882a593Smuzhiyun out:
766*4882a593Smuzhiyun kfree(acx);
767*4882a593Smuzhiyun return ret;
768*4882a593Smuzhiyun }
769*4882a593Smuzhiyun
wl1251_acx_cts_protect(struct wl1251 * wl,enum acx_ctsprotect_type ctsprotect)770*4882a593Smuzhiyun int wl1251_acx_cts_protect(struct wl1251 *wl,
771*4882a593Smuzhiyun enum acx_ctsprotect_type ctsprotect)
772*4882a593Smuzhiyun {
773*4882a593Smuzhiyun struct acx_ctsprotect *acx;
774*4882a593Smuzhiyun int ret;
775*4882a593Smuzhiyun
776*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect");
777*4882a593Smuzhiyun
778*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
779*4882a593Smuzhiyun if (!acx)
780*4882a593Smuzhiyun return -ENOMEM;
781*4882a593Smuzhiyun
782*4882a593Smuzhiyun acx->ctsprotect = ctsprotect;
783*4882a593Smuzhiyun
784*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
785*4882a593Smuzhiyun if (ret < 0) {
786*4882a593Smuzhiyun wl1251_warning("Setting of ctsprotect failed: %d", ret);
787*4882a593Smuzhiyun goto out;
788*4882a593Smuzhiyun }
789*4882a593Smuzhiyun
790*4882a593Smuzhiyun out:
791*4882a593Smuzhiyun kfree(acx);
792*4882a593Smuzhiyun return ret;
793*4882a593Smuzhiyun }
794*4882a593Smuzhiyun
wl1251_acx_tsf_info(struct wl1251 * wl,u64 * mactime)795*4882a593Smuzhiyun int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime)
796*4882a593Smuzhiyun {
797*4882a593Smuzhiyun struct acx_tsf_info *tsf_info;
798*4882a593Smuzhiyun int ret;
799*4882a593Smuzhiyun
800*4882a593Smuzhiyun tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
801*4882a593Smuzhiyun if (!tsf_info)
802*4882a593Smuzhiyun return -ENOMEM;
803*4882a593Smuzhiyun
804*4882a593Smuzhiyun ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO,
805*4882a593Smuzhiyun tsf_info, sizeof(*tsf_info));
806*4882a593Smuzhiyun if (ret < 0) {
807*4882a593Smuzhiyun wl1251_warning("ACX_FW_REV interrogate failed");
808*4882a593Smuzhiyun goto out;
809*4882a593Smuzhiyun }
810*4882a593Smuzhiyun
811*4882a593Smuzhiyun *mactime = tsf_info->current_tsf_lsb |
812*4882a593Smuzhiyun ((u64)tsf_info->current_tsf_msb << 32);
813*4882a593Smuzhiyun
814*4882a593Smuzhiyun out:
815*4882a593Smuzhiyun kfree(tsf_info);
816*4882a593Smuzhiyun return ret;
817*4882a593Smuzhiyun }
818*4882a593Smuzhiyun
wl1251_acx_statistics(struct wl1251 * wl,struct acx_statistics * stats)819*4882a593Smuzhiyun int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats)
820*4882a593Smuzhiyun {
821*4882a593Smuzhiyun int ret;
822*4882a593Smuzhiyun
823*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx statistics");
824*4882a593Smuzhiyun
825*4882a593Smuzhiyun ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats,
826*4882a593Smuzhiyun sizeof(*stats));
827*4882a593Smuzhiyun if (ret < 0) {
828*4882a593Smuzhiyun wl1251_warning("acx statistics failed: %d", ret);
829*4882a593Smuzhiyun return -ENOMEM;
830*4882a593Smuzhiyun }
831*4882a593Smuzhiyun
832*4882a593Smuzhiyun return 0;
833*4882a593Smuzhiyun }
834*4882a593Smuzhiyun
wl1251_acx_rate_policies(struct wl1251 * wl)835*4882a593Smuzhiyun int wl1251_acx_rate_policies(struct wl1251 *wl)
836*4882a593Smuzhiyun {
837*4882a593Smuzhiyun struct acx_rate_policy *acx;
838*4882a593Smuzhiyun int ret = 0;
839*4882a593Smuzhiyun
840*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx rate policies");
841*4882a593Smuzhiyun
842*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
843*4882a593Smuzhiyun if (!acx)
844*4882a593Smuzhiyun return -ENOMEM;
845*4882a593Smuzhiyun
846*4882a593Smuzhiyun /* configure one default (one-size-fits-all) rate class */
847*4882a593Smuzhiyun acx->rate_class_cnt = 2;
848*4882a593Smuzhiyun acx->rate_class[0].enabled_rates = ACX_RATE_MASK_UNSPECIFIED;
849*4882a593Smuzhiyun acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT;
850*4882a593Smuzhiyun acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT;
851*4882a593Smuzhiyun acx->rate_class[0].aflags = 0;
852*4882a593Smuzhiyun
853*4882a593Smuzhiyun /* no-retry rate class */
854*4882a593Smuzhiyun acx->rate_class[1].enabled_rates = ACX_RATE_MASK_UNSPECIFIED;
855*4882a593Smuzhiyun acx->rate_class[1].short_retry_limit = 0;
856*4882a593Smuzhiyun acx->rate_class[1].long_retry_limit = 0;
857*4882a593Smuzhiyun acx->rate_class[1].aflags = 0;
858*4882a593Smuzhiyun
859*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
860*4882a593Smuzhiyun if (ret < 0) {
861*4882a593Smuzhiyun wl1251_warning("Setting of rate policies failed: %d", ret);
862*4882a593Smuzhiyun goto out;
863*4882a593Smuzhiyun }
864*4882a593Smuzhiyun
865*4882a593Smuzhiyun out:
866*4882a593Smuzhiyun kfree(acx);
867*4882a593Smuzhiyun return ret;
868*4882a593Smuzhiyun }
869*4882a593Smuzhiyun
wl1251_acx_mem_cfg(struct wl1251 * wl)870*4882a593Smuzhiyun int wl1251_acx_mem_cfg(struct wl1251 *wl)
871*4882a593Smuzhiyun {
872*4882a593Smuzhiyun struct wl1251_acx_config_memory *mem_conf;
873*4882a593Smuzhiyun int ret, i;
874*4882a593Smuzhiyun
875*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx mem cfg");
876*4882a593Smuzhiyun
877*4882a593Smuzhiyun mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
878*4882a593Smuzhiyun if (!mem_conf)
879*4882a593Smuzhiyun return -ENOMEM;
880*4882a593Smuzhiyun
881*4882a593Smuzhiyun /* memory config */
882*4882a593Smuzhiyun mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS);
883*4882a593Smuzhiyun mem_conf->mem_config.rx_mem_block_num = 35;
884*4882a593Smuzhiyun mem_conf->mem_config.tx_min_mem_block_num = 64;
885*4882a593Smuzhiyun mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES;
886*4882a593Smuzhiyun mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING;
887*4882a593Smuzhiyun mem_conf->mem_config.num_ssid_profiles = 1;
888*4882a593Smuzhiyun mem_conf->mem_config.debug_buffer_size =
889*4882a593Smuzhiyun cpu_to_le16(TRACE_BUFFER_MAX_SIZE);
890*4882a593Smuzhiyun
891*4882a593Smuzhiyun /* RX queue config */
892*4882a593Smuzhiyun mem_conf->rx_queue_config.dma_address = 0;
893*4882a593Smuzhiyun mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF;
894*4882a593Smuzhiyun mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY;
895*4882a593Smuzhiyun mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE;
896*4882a593Smuzhiyun
897*4882a593Smuzhiyun /* TX queue config */
898*4882a593Smuzhiyun for (i = 0; i < MAX_TX_QUEUES; i++) {
899*4882a593Smuzhiyun mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF;
900*4882a593Smuzhiyun mem_conf->tx_queue_config[i].attributes = i;
901*4882a593Smuzhiyun }
902*4882a593Smuzhiyun
903*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
904*4882a593Smuzhiyun sizeof(*mem_conf));
905*4882a593Smuzhiyun if (ret < 0) {
906*4882a593Smuzhiyun wl1251_warning("wl1251 mem config failed: %d", ret);
907*4882a593Smuzhiyun goto out;
908*4882a593Smuzhiyun }
909*4882a593Smuzhiyun
910*4882a593Smuzhiyun out:
911*4882a593Smuzhiyun kfree(mem_conf);
912*4882a593Smuzhiyun return ret;
913*4882a593Smuzhiyun }
914*4882a593Smuzhiyun
wl1251_acx_wr_tbtt_and_dtim(struct wl1251 * wl,u16 tbtt,u8 dtim)915*4882a593Smuzhiyun int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim)
916*4882a593Smuzhiyun {
917*4882a593Smuzhiyun struct wl1251_acx_wr_tbtt_and_dtim *acx;
918*4882a593Smuzhiyun int ret;
919*4882a593Smuzhiyun
920*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx tbtt and dtim");
921*4882a593Smuzhiyun
922*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
923*4882a593Smuzhiyun if (!acx)
924*4882a593Smuzhiyun return -ENOMEM;
925*4882a593Smuzhiyun
926*4882a593Smuzhiyun acx->tbtt = tbtt;
927*4882a593Smuzhiyun acx->dtim = dtim;
928*4882a593Smuzhiyun
929*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_WR_TBTT_AND_DTIM,
930*4882a593Smuzhiyun acx, sizeof(*acx));
931*4882a593Smuzhiyun if (ret < 0) {
932*4882a593Smuzhiyun wl1251_warning("failed to set tbtt and dtim: %d", ret);
933*4882a593Smuzhiyun goto out;
934*4882a593Smuzhiyun }
935*4882a593Smuzhiyun
936*4882a593Smuzhiyun out:
937*4882a593Smuzhiyun kfree(acx);
938*4882a593Smuzhiyun return ret;
939*4882a593Smuzhiyun }
940*4882a593Smuzhiyun
wl1251_acx_bet_enable(struct wl1251 * wl,enum wl1251_acx_bet_mode mode,u8 max_consecutive)941*4882a593Smuzhiyun int wl1251_acx_bet_enable(struct wl1251 *wl, enum wl1251_acx_bet_mode mode,
942*4882a593Smuzhiyun u8 max_consecutive)
943*4882a593Smuzhiyun {
944*4882a593Smuzhiyun struct wl1251_acx_bet_enable *acx;
945*4882a593Smuzhiyun int ret;
946*4882a593Smuzhiyun
947*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx bet enable");
948*4882a593Smuzhiyun
949*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
950*4882a593Smuzhiyun if (!acx)
951*4882a593Smuzhiyun return -ENOMEM;
952*4882a593Smuzhiyun
953*4882a593Smuzhiyun acx->enable = mode;
954*4882a593Smuzhiyun acx->max_consecutive = max_consecutive;
955*4882a593Smuzhiyun
956*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
957*4882a593Smuzhiyun if (ret < 0) {
958*4882a593Smuzhiyun wl1251_warning("wl1251 acx bet enable failed: %d", ret);
959*4882a593Smuzhiyun goto out;
960*4882a593Smuzhiyun }
961*4882a593Smuzhiyun
962*4882a593Smuzhiyun out:
963*4882a593Smuzhiyun kfree(acx);
964*4882a593Smuzhiyun return ret;
965*4882a593Smuzhiyun }
966*4882a593Smuzhiyun
wl1251_acx_arp_ip_filter(struct wl1251 * wl,bool enable,__be32 address)967*4882a593Smuzhiyun int wl1251_acx_arp_ip_filter(struct wl1251 *wl, bool enable, __be32 address)
968*4882a593Smuzhiyun {
969*4882a593Smuzhiyun struct wl1251_acx_arp_filter *acx;
970*4882a593Smuzhiyun int ret;
971*4882a593Smuzhiyun
972*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
973*4882a593Smuzhiyun
974*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
975*4882a593Smuzhiyun if (!acx)
976*4882a593Smuzhiyun return -ENOMEM;
977*4882a593Smuzhiyun
978*4882a593Smuzhiyun acx->version = ACX_IPV4_VERSION;
979*4882a593Smuzhiyun acx->enable = enable;
980*4882a593Smuzhiyun
981*4882a593Smuzhiyun if (enable)
982*4882a593Smuzhiyun memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
983*4882a593Smuzhiyun
984*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_ARP_IP_FILTER,
985*4882a593Smuzhiyun acx, sizeof(*acx));
986*4882a593Smuzhiyun if (ret < 0)
987*4882a593Smuzhiyun wl1251_warning("failed to set arp ip filter: %d", ret);
988*4882a593Smuzhiyun
989*4882a593Smuzhiyun kfree(acx);
990*4882a593Smuzhiyun return ret;
991*4882a593Smuzhiyun }
992*4882a593Smuzhiyun
wl1251_acx_ac_cfg(struct wl1251 * wl,u8 ac,u8 cw_min,u16 cw_max,u8 aifs,u16 txop)993*4882a593Smuzhiyun int wl1251_acx_ac_cfg(struct wl1251 *wl, u8 ac, u8 cw_min, u16 cw_max,
994*4882a593Smuzhiyun u8 aifs, u16 txop)
995*4882a593Smuzhiyun {
996*4882a593Smuzhiyun struct wl1251_acx_ac_cfg *acx;
997*4882a593Smuzhiyun int ret = 0;
998*4882a593Smuzhiyun
999*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
1000*4882a593Smuzhiyun "aifs %d txop %d", ac, cw_min, cw_max, aifs, txop);
1001*4882a593Smuzhiyun
1002*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1003*4882a593Smuzhiyun if (!acx)
1004*4882a593Smuzhiyun return -ENOMEM;
1005*4882a593Smuzhiyun
1006*4882a593Smuzhiyun acx->ac = ac;
1007*4882a593Smuzhiyun acx->cw_min = cw_min;
1008*4882a593Smuzhiyun acx->cw_max = cw_max;
1009*4882a593Smuzhiyun acx->aifsn = aifs;
1010*4882a593Smuzhiyun acx->txop_limit = txop;
1011*4882a593Smuzhiyun
1012*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
1013*4882a593Smuzhiyun if (ret < 0) {
1014*4882a593Smuzhiyun wl1251_warning("acx ac cfg failed: %d", ret);
1015*4882a593Smuzhiyun goto out;
1016*4882a593Smuzhiyun }
1017*4882a593Smuzhiyun
1018*4882a593Smuzhiyun out:
1019*4882a593Smuzhiyun kfree(acx);
1020*4882a593Smuzhiyun return ret;
1021*4882a593Smuzhiyun }
1022*4882a593Smuzhiyun
wl1251_acx_tid_cfg(struct wl1251 * wl,u8 queue,enum wl1251_acx_channel_type type,u8 tsid,enum wl1251_acx_ps_scheme ps_scheme,enum wl1251_acx_ack_policy ack_policy)1023*4882a593Smuzhiyun int wl1251_acx_tid_cfg(struct wl1251 *wl, u8 queue,
1024*4882a593Smuzhiyun enum wl1251_acx_channel_type type,
1025*4882a593Smuzhiyun u8 tsid, enum wl1251_acx_ps_scheme ps_scheme,
1026*4882a593Smuzhiyun enum wl1251_acx_ack_policy ack_policy)
1027*4882a593Smuzhiyun {
1028*4882a593Smuzhiyun struct wl1251_acx_tid_cfg *acx;
1029*4882a593Smuzhiyun int ret = 0;
1030*4882a593Smuzhiyun
1031*4882a593Smuzhiyun wl1251_debug(DEBUG_ACX, "acx tid cfg %d type %d tsid %d "
1032*4882a593Smuzhiyun "ps_scheme %d ack_policy %d", queue, type, tsid,
1033*4882a593Smuzhiyun ps_scheme, ack_policy);
1034*4882a593Smuzhiyun
1035*4882a593Smuzhiyun acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1036*4882a593Smuzhiyun if (!acx)
1037*4882a593Smuzhiyun return -ENOMEM;
1038*4882a593Smuzhiyun
1039*4882a593Smuzhiyun acx->queue = queue;
1040*4882a593Smuzhiyun acx->type = type;
1041*4882a593Smuzhiyun acx->tsid = tsid;
1042*4882a593Smuzhiyun acx->ps_scheme = ps_scheme;
1043*4882a593Smuzhiyun acx->ack_policy = ack_policy;
1044*4882a593Smuzhiyun
1045*4882a593Smuzhiyun ret = wl1251_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
1046*4882a593Smuzhiyun if (ret < 0) {
1047*4882a593Smuzhiyun wl1251_warning("acx tid cfg failed: %d", ret);
1048*4882a593Smuzhiyun goto out;
1049*4882a593Smuzhiyun }
1050*4882a593Smuzhiyun
1051*4882a593Smuzhiyun out:
1052*4882a593Smuzhiyun kfree(acx);
1053*4882a593Smuzhiyun return ret;
1054*4882a593Smuzhiyun }
1055