2 * This file is part of wl1271
4 * Copyright (C) 2009-2010 Nokia Corporation
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
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.
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.
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
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
26 #include <linux/spi/spi.h>
27 #include <linux/etherdevice.h>
28 #include <linux/ieee80211.h>
29 #include <linux/slab.h>
36 #include "wl12xx_80211.h"
41 #define WL1271_CMD_FAST_POLL_COUNT 50
44 * send command to firmware
48 * @buf: buffer containing the command, must work with dma
49 * @len: length of the buffer
51 int wl1271_cmd_send(struct wl1271
*wl
, u16 id
, void *buf
, size_t len
,
54 struct wl1271_cmd_header
*cmd
;
55 unsigned long timeout
;
62 cmd
->id
= cpu_to_le16(id
);
65 WARN_ON(len
% 4 != 0);
66 WARN_ON(test_bit(WL1271_FLAG_IN_ELP
, &wl
->flags
));
68 wl1271_write(wl
, wl
->cmd_box_addr
, buf
, len
, false);
70 wl1271_write32(wl
, ACX_REG_INTERRUPT_TRIG
, INTR_TRIG_CMD
);
72 timeout
= jiffies
+ msecs_to_jiffies(WL1271_COMMAND_TIMEOUT
);
74 intr
= wl1271_read32(wl
, ACX_REG_INTERRUPT_NO_CLEAR
);
75 while (!(intr
& WL1271_ACX_INTR_CMD_COMPLETE
)) {
76 if (time_after(jiffies
, timeout
)) {
77 wl1271_error("command complete timeout");
83 if (poll_count
< WL1271_CMD_FAST_POLL_COUNT
)
88 intr
= wl1271_read32(wl
, ACX_REG_INTERRUPT_NO_CLEAR
);
91 /* read back the status code of the command */
93 res_len
= sizeof(struct wl1271_cmd_header
);
94 wl1271_read(wl
, wl
->cmd_box_addr
, cmd
, res_len
, false);
96 status
= le16_to_cpu(cmd
->status
);
97 if (status
!= CMD_STATUS_SUCCESS
) {
98 wl1271_error("command execute failure %d", status
);
103 wl1271_write32(wl
, ACX_REG_INTERRUPT_ACK
,
104 WL1271_ACX_INTR_CMD_COMPLETE
);
109 wl12xx_queue_recovery_work(wl
);
113 int wl1271_cmd_general_parms(struct wl1271
*wl
)
115 struct wl1271_general_parms_cmd
*gen_parms
;
116 struct wl1271_ini_general_params
*gp
=
117 &((struct wl1271_nvs_file
*)wl
->nvs
)->general_params
;
124 gen_parms
= kzalloc(sizeof(*gen_parms
), GFP_KERNEL
);
128 gen_parms
->test
.id
= TEST_CMD_INI_FILE_GENERAL_PARAM
;
130 memcpy(&gen_parms
->general_params
, gp
, sizeof(*gp
));
132 if (gp
->tx_bip_fem_auto_detect
)
135 /* Override the REF CLK from the NVS with the one from platform data */
136 gen_parms
->general_params
.ref_clock
= wl
->ref_clock
;
138 ret
= wl1271_cmd_test(wl
, gen_parms
, sizeof(*gen_parms
), answer
);
140 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
144 gp
->tx_bip_fem_manufacturer
=
145 gen_parms
->general_params
.tx_bip_fem_manufacturer
;
147 wl1271_debug(DEBUG_CMD
, "FEM autodetect: %s, manufacturer: %d\n",
148 answer
? "auto" : "manual", gp
->tx_bip_fem_manufacturer
);
155 int wl128x_cmd_general_parms(struct wl1271
*wl
)
157 struct wl128x_general_parms_cmd
*gen_parms
;
158 struct wl128x_ini_general_params
*gp
=
159 &((struct wl128x_nvs_file
*)wl
->nvs
)->general_params
;
166 gen_parms
= kzalloc(sizeof(*gen_parms
), GFP_KERNEL
);
170 gen_parms
->test
.id
= TEST_CMD_INI_FILE_GENERAL_PARAM
;
172 memcpy(&gen_parms
->general_params
, gp
, sizeof(*gp
));
174 if (gp
->tx_bip_fem_auto_detect
)
177 /* Replace REF and TCXO CLKs with the ones from platform data */
178 gen_parms
->general_params
.ref_clock
= wl
->ref_clock
;
179 gen_parms
->general_params
.tcxo_ref_clock
= wl
->tcxo_clock
;
181 ret
= wl1271_cmd_test(wl
, gen_parms
, sizeof(*gen_parms
), answer
);
183 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
187 gp
->tx_bip_fem_manufacturer
=
188 gen_parms
->general_params
.tx_bip_fem_manufacturer
;
190 wl1271_debug(DEBUG_CMD
, "FEM autodetect: %s, manufacturer: %d\n",
191 answer
? "auto" : "manual", gp
->tx_bip_fem_manufacturer
);
198 int wl1271_cmd_radio_parms(struct wl1271
*wl
)
200 struct wl1271_nvs_file
*nvs
= (struct wl1271_nvs_file
*)wl
->nvs
;
201 struct wl1271_radio_parms_cmd
*radio_parms
;
202 struct wl1271_ini_general_params
*gp
= &nvs
->general_params
;
208 radio_parms
= kzalloc(sizeof(*radio_parms
), GFP_KERNEL
);
212 radio_parms
->test
.id
= TEST_CMD_INI_FILE_RADIO_PARAM
;
214 /* 2.4GHz parameters */
215 memcpy(&radio_parms
->static_params_2
, &nvs
->stat_radio_params_2
,
216 sizeof(struct wl1271_ini_band_params_2
));
217 memcpy(&radio_parms
->dyn_params_2
,
218 &nvs
->dyn_radio_params_2
[gp
->tx_bip_fem_manufacturer
].params
,
219 sizeof(struct wl1271_ini_fem_params_2
));
221 /* 5GHz parameters */
222 memcpy(&radio_parms
->static_params_5
,
223 &nvs
->stat_radio_params_5
,
224 sizeof(struct wl1271_ini_band_params_5
));
225 memcpy(&radio_parms
->dyn_params_5
,
226 &nvs
->dyn_radio_params_5
[gp
->tx_bip_fem_manufacturer
].params
,
227 sizeof(struct wl1271_ini_fem_params_5
));
229 wl1271_dump(DEBUG_CMD
, "TEST_CMD_INI_FILE_RADIO_PARAM: ",
230 radio_parms
, sizeof(*radio_parms
));
232 ret
= wl1271_cmd_test(wl
, radio_parms
, sizeof(*radio_parms
), 0);
234 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
240 int wl128x_cmd_radio_parms(struct wl1271
*wl
)
242 struct wl128x_nvs_file
*nvs
= (struct wl128x_nvs_file
*)wl
->nvs
;
243 struct wl128x_radio_parms_cmd
*radio_parms
;
244 struct wl128x_ini_general_params
*gp
= &nvs
->general_params
;
250 radio_parms
= kzalloc(sizeof(*radio_parms
), GFP_KERNEL
);
254 radio_parms
->test
.id
= TEST_CMD_INI_FILE_RADIO_PARAM
;
256 /* 2.4GHz parameters */
257 memcpy(&radio_parms
->static_params_2
, &nvs
->stat_radio_params_2
,
258 sizeof(struct wl128x_ini_band_params_2
));
259 memcpy(&radio_parms
->dyn_params_2
,
260 &nvs
->dyn_radio_params_2
[gp
->tx_bip_fem_manufacturer
].params
,
261 sizeof(struct wl128x_ini_fem_params_2
));
263 /* 5GHz parameters */
264 memcpy(&radio_parms
->static_params_5
,
265 &nvs
->stat_radio_params_5
,
266 sizeof(struct wl128x_ini_band_params_5
));
267 memcpy(&radio_parms
->dyn_params_5
,
268 &nvs
->dyn_radio_params_5
[gp
->tx_bip_fem_manufacturer
].params
,
269 sizeof(struct wl128x_ini_fem_params_5
));
271 radio_parms
->fem_vendor_and_options
= nvs
->fem_vendor_and_options
;
273 wl1271_dump(DEBUG_CMD
, "TEST_CMD_INI_FILE_RADIO_PARAM: ",
274 radio_parms
, sizeof(*radio_parms
));
276 ret
= wl1271_cmd_test(wl
, radio_parms
, sizeof(*radio_parms
), 0);
278 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
284 int wl1271_cmd_ext_radio_parms(struct wl1271
*wl
)
286 struct wl1271_ext_radio_parms_cmd
*ext_radio_parms
;
287 struct conf_rf_settings
*rf
= &wl
->conf
.rf
;
293 ext_radio_parms
= kzalloc(sizeof(*ext_radio_parms
), GFP_KERNEL
);
294 if (!ext_radio_parms
)
297 ext_radio_parms
->test
.id
= TEST_CMD_INI_FILE_RF_EXTENDED_PARAM
;
299 memcpy(ext_radio_parms
->tx_per_channel_power_compensation_2
,
300 rf
->tx_per_channel_power_compensation_2
,
301 CONF_TX_PWR_COMPENSATION_LEN_2
);
302 memcpy(ext_radio_parms
->tx_per_channel_power_compensation_5
,
303 rf
->tx_per_channel_power_compensation_5
,
304 CONF_TX_PWR_COMPENSATION_LEN_5
);
306 wl1271_dump(DEBUG_CMD
, "TEST_CMD_INI_FILE_EXT_RADIO_PARAM: ",
307 ext_radio_parms
, sizeof(*ext_radio_parms
));
309 ret
= wl1271_cmd_test(wl
, ext_radio_parms
, sizeof(*ext_radio_parms
), 0);
311 wl1271_warning("TEST_CMD_INI_FILE_RF_EXTENDED_PARAM failed");
313 kfree(ext_radio_parms
);
318 * Poll the mailbox event field until any of the bits in the mask is set or a
319 * timeout occurs (WL1271_EVENT_TIMEOUT in msecs)
321 static int wl1271_cmd_wait_for_event_or_timeout(struct wl1271
*wl
, u32 mask
)
323 u32 events_vector
, event
;
324 unsigned long timeout
;
326 timeout
= jiffies
+ msecs_to_jiffies(WL1271_EVENT_TIMEOUT
);
329 if (time_after(jiffies
, timeout
)) {
330 wl1271_debug(DEBUG_CMD
, "timeout waiting for event %d",
337 /* read from both event fields */
338 wl1271_read(wl
, wl
->mbox_ptr
[0], &events_vector
,
339 sizeof(events_vector
), false);
340 event
= events_vector
& mask
;
341 wl1271_read(wl
, wl
->mbox_ptr
[1], &events_vector
,
342 sizeof(events_vector
), false);
343 event
|= events_vector
& mask
;
349 static int wl1271_cmd_wait_for_event(struct wl1271
*wl
, u32 mask
)
353 ret
= wl1271_cmd_wait_for_event_or_timeout(wl
, mask
);
355 wl12xx_queue_recovery_work(wl
);
362 int wl12xx_cmd_role_enable(struct wl1271
*wl
, u8
*addr
, u8 role_type
,
365 struct wl12xx_cmd_role_enable
*cmd
;
368 wl1271_debug(DEBUG_CMD
, "cmd role enable");
370 if (WARN_ON(*role_id
!= WL12XX_INVALID_ROLE_ID
))
373 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
380 cmd
->role_id
= find_first_zero_bit(wl
->roles_map
, WL12XX_MAX_ROLES
);
381 if (cmd
->role_id
>= WL12XX_MAX_ROLES
) {
386 memcpy(cmd
->mac_address
, addr
, ETH_ALEN
);
387 cmd
->role_type
= role_type
;
389 ret
= wl1271_cmd_send(wl
, CMD_ROLE_ENABLE
, cmd
, sizeof(*cmd
), 0);
391 wl1271_error("failed to initiate cmd role enable");
395 __set_bit(cmd
->role_id
, wl
->roles_map
);
396 *role_id
= cmd
->role_id
;
405 int wl12xx_cmd_role_disable(struct wl1271
*wl
, u8
*role_id
)
407 struct wl12xx_cmd_role_disable
*cmd
;
410 wl1271_debug(DEBUG_CMD
, "cmd role disable");
412 if (WARN_ON(*role_id
== WL12XX_INVALID_ROLE_ID
))
415 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
420 cmd
->role_id
= *role_id
;
422 ret
= wl1271_cmd_send(wl
, CMD_ROLE_DISABLE
, cmd
, sizeof(*cmd
), 0);
424 wl1271_error("failed to initiate cmd role disable");
428 __clear_bit(*role_id
, wl
->roles_map
);
429 *role_id
= WL12XX_INVALID_ROLE_ID
;
438 int wl12xx_allocate_link(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
, u8
*hlid
)
440 u8 link
= find_first_zero_bit(wl
->links_map
, WL12XX_MAX_LINKS
);
441 if (link
>= WL12XX_MAX_LINKS
)
444 __set_bit(link
, wl
->links_map
);
445 __set_bit(link
, wlvif
->links_map
);
450 void wl12xx_free_link(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
, u8
*hlid
)
452 if (*hlid
== WL12XX_INVALID_LINK_ID
)
455 __clear_bit(*hlid
, wl
->links_map
);
456 __clear_bit(*hlid
, wlvif
->links_map
);
457 *hlid
= WL12XX_INVALID_LINK_ID
;
460 static int wl12xx_get_new_session_id(struct wl1271
*wl
,
461 struct wl12xx_vif
*wlvif
)
463 if (wlvif
->session_counter
>= SESSION_COUNTER_MAX
)
464 wlvif
->session_counter
= 0;
466 wlvif
->session_counter
++;
468 return wlvif
->session_counter
;
471 int wl12xx_cmd_role_start_dev(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
473 struct wl12xx_cmd_role_start
*cmd
;
476 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
482 wl1271_debug(DEBUG_CMD
, "cmd role start dev %d", wlvif
->dev_role_id
);
484 cmd
->role_id
= wlvif
->dev_role_id
;
485 if (wlvif
->band
== IEEE80211_BAND_5GHZ
)
486 cmd
->band
= WL12XX_BAND_5GHZ
;
487 cmd
->channel
= wlvif
->channel
;
489 if (wlvif
->dev_hlid
== WL12XX_INVALID_LINK_ID
) {
490 ret
= wl12xx_allocate_link(wl
, wlvif
, &wlvif
->dev_hlid
);
494 cmd
->device
.hlid
= wlvif
->dev_hlid
;
495 cmd
->device
.session
= wlvif
->session_counter
;
497 wl1271_debug(DEBUG_CMD
, "role start: roleid=%d, hlid=%d, session=%d",
498 cmd
->role_id
, cmd
->device
.hlid
, cmd
->device
.session
);
500 ret
= wl1271_cmd_send(wl
, CMD_ROLE_START
, cmd
, sizeof(*cmd
), 0);
502 wl1271_error("failed to initiate cmd role enable");
509 /* clear links on error */
510 wl12xx_free_link(wl
, wlvif
, &wlvif
->dev_hlid
);
519 int wl12xx_cmd_role_stop_dev(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
521 struct wl12xx_cmd_role_stop
*cmd
;
524 if (WARN_ON(wlvif
->dev_hlid
== WL12XX_INVALID_LINK_ID
))
527 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
533 wl1271_debug(DEBUG_CMD
, "cmd role stop dev");
535 cmd
->role_id
= wlvif
->dev_role_id
;
536 cmd
->disc_type
= DISCONNECT_IMMEDIATE
;
537 cmd
->reason
= cpu_to_le16(WLAN_REASON_UNSPECIFIED
);
539 ret
= wl1271_cmd_send(wl
, CMD_ROLE_STOP
, cmd
, sizeof(*cmd
), 0);
541 wl1271_error("failed to initiate cmd role stop");
545 ret
= wl1271_cmd_wait_for_event(wl
, DISCONNECT_EVENT_COMPLETE_ID
);
547 wl1271_error("cmd role stop dev event completion error");
551 wl12xx_free_link(wl
, wlvif
, &wlvif
->dev_hlid
);
560 int wl12xx_cmd_role_start_sta(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
562 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
563 struct wl12xx_cmd_role_start
*cmd
;
566 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
572 wl1271_debug(DEBUG_CMD
, "cmd role start sta %d", wlvif
->role_id
);
574 cmd
->role_id
= wlvif
->role_id
;
575 if (wlvif
->band
== IEEE80211_BAND_5GHZ
)
576 cmd
->band
= WL12XX_BAND_5GHZ
;
577 cmd
->channel
= wlvif
->channel
;
578 cmd
->sta
.basic_rate_set
= cpu_to_le32(wlvif
->basic_rate_set
);
579 cmd
->sta
.beacon_interval
= cpu_to_le16(wlvif
->beacon_int
);
580 cmd
->sta
.ssid_type
= WL12XX_SSID_TYPE_ANY
;
581 cmd
->sta
.ssid_len
= wlvif
->ssid_len
;
582 memcpy(cmd
->sta
.ssid
, wlvif
->ssid
, wlvif
->ssid_len
);
583 memcpy(cmd
->sta
.bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
584 cmd
->sta
.local_rates
= cpu_to_le32(wlvif
->rate_set
);
586 if (wlvif
->sta
.hlid
== WL12XX_INVALID_LINK_ID
) {
587 ret
= wl12xx_allocate_link(wl
, wlvif
, &wlvif
->sta
.hlid
);
591 cmd
->sta
.hlid
= wlvif
->sta
.hlid
;
592 cmd
->sta
.session
= wl12xx_get_new_session_id(wl
, wlvif
);
593 cmd
->sta
.remote_rates
= cpu_to_le32(wlvif
->rate_set
);
595 wl1271_debug(DEBUG_CMD
, "role start: roleid=%d, hlid=%d, session=%d "
596 "basic_rate_set: 0x%x, remote_rates: 0x%x",
597 wlvif
->role_id
, cmd
->sta
.hlid
, cmd
->sta
.session
,
598 wlvif
->basic_rate_set
, wlvif
->rate_set
);
600 ret
= wl1271_cmd_send(wl
, CMD_ROLE_START
, cmd
, sizeof(*cmd
), 0);
602 wl1271_error("failed to initiate cmd role start sta");
609 /* clear links on error. */
610 wl12xx_free_link(wl
, wlvif
, &wlvif
->sta
.hlid
);
619 /* use this function to stop ibss as well */
620 int wl12xx_cmd_role_stop_sta(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
622 struct wl12xx_cmd_role_stop
*cmd
;
625 if (WARN_ON(wlvif
->sta
.hlid
== WL12XX_INVALID_LINK_ID
))
628 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
634 wl1271_debug(DEBUG_CMD
, "cmd role stop sta %d", wlvif
->role_id
);
636 cmd
->role_id
= wlvif
->role_id
;
637 cmd
->disc_type
= DISCONNECT_IMMEDIATE
;
638 cmd
->reason
= cpu_to_le16(WLAN_REASON_UNSPECIFIED
);
640 ret
= wl1271_cmd_send(wl
, CMD_ROLE_STOP
, cmd
, sizeof(*cmd
), 0);
642 wl1271_error("failed to initiate cmd role stop sta");
646 wl12xx_free_link(wl
, wlvif
, &wlvif
->sta
.hlid
);
655 int wl12xx_cmd_role_start_ap(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
657 struct wl12xx_cmd_role_start
*cmd
;
658 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
659 struct ieee80211_bss_conf
*bss_conf
= &vif
->bss_conf
;
662 wl1271_debug(DEBUG_CMD
, "cmd role start ap %d", wlvif
->role_id
);
664 /* trying to use hidden SSID with an old hostapd version */
665 if (wlvif
->ssid_len
== 0 && !bss_conf
->hidden_ssid
) {
666 wl1271_error("got a null SSID from beacon/bss");
671 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
677 ret
= wl12xx_allocate_link(wl
, wlvif
, &wlvif
->ap
.global_hlid
);
681 ret
= wl12xx_allocate_link(wl
, wlvif
, &wlvif
->ap
.bcast_hlid
);
683 goto out_free_global
;
685 cmd
->role_id
= wlvif
->role_id
;
686 cmd
->ap
.aging_period
= cpu_to_le16(wl
->conf
.tx
.ap_aging_period
);
687 cmd
->ap
.bss_index
= WL1271_AP_BSS_INDEX
;
688 cmd
->ap
.global_hlid
= wlvif
->ap
.global_hlid
;
689 cmd
->ap
.broadcast_hlid
= wlvif
->ap
.bcast_hlid
;
690 cmd
->ap
.basic_rate_set
= cpu_to_le32(wlvif
->basic_rate_set
);
691 cmd
->ap
.beacon_interval
= cpu_to_le16(wlvif
->beacon_int
);
692 cmd
->ap
.dtim_interval
= bss_conf
->dtim_period
;
693 cmd
->ap
.beacon_expiry
= WL1271_AP_DEF_BEACON_EXP
;
694 cmd
->channel
= wlvif
->channel
;
696 if (!bss_conf
->hidden_ssid
) {
697 /* take the SSID from the beacon for backward compatibility */
698 cmd
->ap
.ssid_type
= WL12XX_SSID_TYPE_PUBLIC
;
699 cmd
->ap
.ssid_len
= wlvif
->ssid_len
;
700 memcpy(cmd
->ap
.ssid
, wlvif
->ssid
, wlvif
->ssid_len
);
702 cmd
->ap
.ssid_type
= WL12XX_SSID_TYPE_HIDDEN
;
703 cmd
->ap
.ssid_len
= bss_conf
->ssid_len
;
704 memcpy(cmd
->ap
.ssid
, bss_conf
->ssid
, bss_conf
->ssid_len
);
707 cmd
->ap
.local_rates
= cpu_to_le32(0xffffffff);
709 switch (wlvif
->band
) {
710 case IEEE80211_BAND_2GHZ
:
711 cmd
->band
= RADIO_BAND_2_4GHZ
;
713 case IEEE80211_BAND_5GHZ
:
714 cmd
->band
= RADIO_BAND_5GHZ
;
717 wl1271_warning("ap start - unknown band: %d", (int)wlvif
->band
);
718 cmd
->band
= RADIO_BAND_2_4GHZ
;
722 ret
= wl1271_cmd_send(wl
, CMD_ROLE_START
, cmd
, sizeof(*cmd
), 0);
724 wl1271_error("failed to initiate cmd role start ap");
731 wl12xx_free_link(wl
, wlvif
, &wlvif
->ap
.bcast_hlid
);
734 wl12xx_free_link(wl
, wlvif
, &wlvif
->ap
.global_hlid
);
743 int wl12xx_cmd_role_stop_ap(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
745 struct wl12xx_cmd_role_stop
*cmd
;
748 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
754 wl1271_debug(DEBUG_CMD
, "cmd role stop ap %d", wlvif
->role_id
);
756 cmd
->role_id
= wlvif
->role_id
;
758 ret
= wl1271_cmd_send(wl
, CMD_ROLE_STOP
, cmd
, sizeof(*cmd
), 0);
760 wl1271_error("failed to initiate cmd role stop ap");
764 wl12xx_free_link(wl
, wlvif
, &wlvif
->ap
.bcast_hlid
);
765 wl12xx_free_link(wl
, wlvif
, &wlvif
->ap
.global_hlid
);
774 int wl12xx_cmd_role_start_ibss(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
776 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
777 struct wl12xx_cmd_role_start
*cmd
;
778 struct ieee80211_bss_conf
*bss_conf
= &vif
->bss_conf
;
781 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
787 wl1271_debug(DEBUG_CMD
, "cmd role start ibss %d", wlvif
->role_id
);
789 cmd
->role_id
= wlvif
->role_id
;
790 if (wlvif
->band
== IEEE80211_BAND_5GHZ
)
791 cmd
->band
= WL12XX_BAND_5GHZ
;
792 cmd
->channel
= wlvif
->channel
;
793 cmd
->ibss
.basic_rate_set
= cpu_to_le32(wlvif
->basic_rate_set
);
794 cmd
->ibss
.beacon_interval
= cpu_to_le16(wlvif
->beacon_int
);
795 cmd
->ibss
.dtim_interval
= bss_conf
->dtim_period
;
796 cmd
->ibss
.ssid_type
= WL12XX_SSID_TYPE_ANY
;
797 cmd
->ibss
.ssid_len
= wlvif
->ssid_len
;
798 memcpy(cmd
->ibss
.ssid
, wlvif
->ssid
, wlvif
->ssid_len
);
799 memcpy(cmd
->ibss
.bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
800 cmd
->sta
.local_rates
= cpu_to_le32(wlvif
->rate_set
);
802 if (wlvif
->sta
.hlid
== WL12XX_INVALID_LINK_ID
) {
803 ret
= wl12xx_allocate_link(wl
, wlvif
, &wlvif
->sta
.hlid
);
807 cmd
->ibss
.hlid
= wlvif
->sta
.hlid
;
808 cmd
->ibss
.remote_rates
= cpu_to_le32(wlvif
->rate_set
);
810 wl1271_debug(DEBUG_CMD
, "role start: roleid=%d, hlid=%d, session=%d "
811 "basic_rate_set: 0x%x, remote_rates: 0x%x",
812 wlvif
->role_id
, cmd
->sta
.hlid
, cmd
->sta
.session
,
813 wlvif
->basic_rate_set
, wlvif
->rate_set
);
815 wl1271_debug(DEBUG_CMD
, "vif->bss_conf.bssid = %pM",
816 vif
->bss_conf
.bssid
);
818 ret
= wl1271_cmd_send(wl
, CMD_ROLE_START
, cmd
, sizeof(*cmd
), 0);
820 wl1271_error("failed to initiate cmd role enable");
827 /* clear links on error. */
828 wl12xx_free_link(wl
, wlvif
, &wlvif
->sta
.hlid
);
839 * send test command to firmware
842 * @buf: buffer containing the command, with all headers, must work with dma
843 * @len: length of the buffer
844 * @answer: is answer needed
846 int wl1271_cmd_test(struct wl1271
*wl
, void *buf
, size_t buf_len
, u8 answer
)
851 wl1271_debug(DEBUG_CMD
, "cmd test");
856 ret
= wl1271_cmd_send(wl
, CMD_TEST
, buf
, buf_len
, res_len
);
859 wl1271_warning("TEST command failed");
867 * read acx from firmware
871 * @buf: buffer for the response, including all headers, must work with dma
872 * @len: length of buf
874 int wl1271_cmd_interrogate(struct wl1271
*wl
, u16 id
, void *buf
, size_t len
)
876 struct acx_header
*acx
= buf
;
879 wl1271_debug(DEBUG_CMD
, "cmd interrogate");
881 acx
->id
= cpu_to_le16(id
);
883 /* payload length, does not include any headers */
884 acx
->len
= cpu_to_le16(len
- sizeof(*acx
));
886 ret
= wl1271_cmd_send(wl
, CMD_INTERROGATE
, acx
, sizeof(*acx
), len
);
888 wl1271_error("INTERROGATE command failed");
894 * write acx value to firmware
898 * @buf: buffer containing acx, including all headers, must work with dma
899 * @len: length of buf
901 int wl1271_cmd_configure(struct wl1271
*wl
, u16 id
, void *buf
, size_t len
)
903 struct acx_header
*acx
= buf
;
906 wl1271_debug(DEBUG_CMD
, "cmd configure (%d)", id
);
908 acx
->id
= cpu_to_le16(id
);
910 /* payload length, does not include any headers */
911 acx
->len
= cpu_to_le16(len
- sizeof(*acx
));
913 ret
= wl1271_cmd_send(wl
, CMD_CONFIGURE
, acx
, len
, 0);
915 wl1271_warning("CONFIGURE command NOK");
922 int wl1271_cmd_data_path(struct wl1271
*wl
, bool enable
)
924 struct cmd_enabledisable_path
*cmd
;
928 wl1271_debug(DEBUG_CMD
, "cmd data path");
930 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
936 /* the channel here is only used for calibration, so hardcoded to 1 */
940 cmd_rx
= CMD_ENABLE_RX
;
941 cmd_tx
= CMD_ENABLE_TX
;
943 cmd_rx
= CMD_DISABLE_RX
;
944 cmd_tx
= CMD_DISABLE_TX
;
947 ret
= wl1271_cmd_send(wl
, cmd_rx
, cmd
, sizeof(*cmd
), 0);
949 wl1271_error("rx %s cmd for channel %d failed",
950 enable
? "start" : "stop", cmd
->channel
);
954 wl1271_debug(DEBUG_BOOT
, "rx %s cmd channel %d",
955 enable
? "start" : "stop", cmd
->channel
);
957 ret
= wl1271_cmd_send(wl
, cmd_tx
, cmd
, sizeof(*cmd
), 0);
959 wl1271_error("tx %s cmd for channel %d failed",
960 enable
? "start" : "stop", cmd
->channel
);
964 wl1271_debug(DEBUG_BOOT
, "tx %s cmd channel %d",
965 enable
? "start" : "stop", cmd
->channel
);
972 int wl1271_cmd_ps_mode(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
975 struct wl1271_cmd_ps_params
*ps_params
= NULL
;
978 wl1271_debug(DEBUG_CMD
, "cmd set ps mode");
980 ps_params
= kzalloc(sizeof(*ps_params
), GFP_KERNEL
);
986 ps_params
->role_id
= wlvif
->role_id
;
987 ps_params
->ps_mode
= ps_mode
;
989 ret
= wl1271_cmd_send(wl
, CMD_SET_PS_MODE
, ps_params
,
990 sizeof(*ps_params
), 0);
992 wl1271_error("cmd set_ps_mode failed");
1001 int wl1271_cmd_template_set(struct wl1271
*wl
, u16 template_id
,
1002 void *buf
, size_t buf_len
, int index
, u32 rates
)
1004 struct wl1271_cmd_template_set
*cmd
;
1007 wl1271_debug(DEBUG_CMD
, "cmd template_set %d", template_id
);
1009 WARN_ON(buf_len
> WL1271_CMD_TEMPL_MAX_SIZE
);
1010 buf_len
= min_t(size_t, buf_len
, WL1271_CMD_TEMPL_MAX_SIZE
);
1012 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1018 cmd
->len
= cpu_to_le16(buf_len
);
1019 cmd
->template_type
= template_id
;
1020 cmd
->enabled_rates
= cpu_to_le32(rates
);
1021 cmd
->short_retry_limit
= wl
->conf
.tx
.tmpl_short_retry_limit
;
1022 cmd
->long_retry_limit
= wl
->conf
.tx
.tmpl_long_retry_limit
;
1026 memcpy(cmd
->template_data
, buf
, buf_len
);
1028 ret
= wl1271_cmd_send(wl
, CMD_SET_TEMPLATE
, cmd
, sizeof(*cmd
), 0);
1030 wl1271_warning("cmd set_template failed: %d", ret
);
1041 int wl12xx_cmd_build_null_data(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
)
1043 struct sk_buff
*skb
= NULL
;
1049 if (wlvif
->bss_type
== BSS_TYPE_IBSS
) {
1050 size
= sizeof(struct wl12xx_null_data_template
);
1053 skb
= ieee80211_nullfunc_get(wl
->hw
,
1054 wl12xx_wlvif_to_vif(wlvif
));
1061 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_NULL_DATA
, ptr
, size
, 0,
1067 wl1271_warning("cmd buld null data failed %d", ret
);
1073 int wl12xx_cmd_build_klv_null_data(struct wl1271
*wl
,
1074 struct wl12xx_vif
*wlvif
)
1076 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
1077 struct sk_buff
*skb
= NULL
;
1080 skb
= ieee80211_nullfunc_get(wl
->hw
, vif
);
1084 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_KLV
,
1085 skb
->data
, skb
->len
,
1086 CMD_TEMPL_KLV_IDX_NULL_DATA
,
1092 wl1271_warning("cmd build klv null data failed %d", ret
);
1098 int wl1271_cmd_build_ps_poll(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
1101 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
1102 struct sk_buff
*skb
;
1105 skb
= ieee80211_pspoll_get(wl
->hw
, vif
);
1109 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_PS_POLL
, skb
->data
,
1110 skb
->len
, 0, wlvif
->basic_rate_set
);
1117 int wl1271_cmd_build_probe_req(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
1118 const u8
*ssid
, size_t ssid_len
,
1119 const u8
*ie
, size_t ie_len
, u8 band
)
1121 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
1122 struct sk_buff
*skb
;
1126 skb
= ieee80211_probereq_get(wl
->hw
, vif
, ssid
, ssid_len
,
1133 wl1271_dump(DEBUG_SCAN
, "PROBE REQ: ", skb
->data
, skb
->len
);
1135 rate
= wl1271_tx_min_rate_get(wl
, wlvif
->bitrate_masks
[band
]);
1136 if (band
== IEEE80211_BAND_2GHZ
)
1137 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_CFG_PROBE_REQ_2_4
,
1138 skb
->data
, skb
->len
, 0, rate
);
1140 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_CFG_PROBE_REQ_5
,
1141 skb
->data
, skb
->len
, 0, rate
);
1148 struct sk_buff
*wl1271_cmd_build_ap_probe_req(struct wl1271
*wl
,
1149 struct wl12xx_vif
*wlvif
,
1150 struct sk_buff
*skb
)
1152 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
1157 skb
= ieee80211_ap_probereq_get(wl
->hw
, vif
);
1161 wl1271_dump(DEBUG_SCAN
, "AP PROBE REQ: ", skb
->data
, skb
->len
);
1163 rate
= wl1271_tx_min_rate_get(wl
, wlvif
->bitrate_masks
[wlvif
->band
]);
1164 if (wlvif
->band
== IEEE80211_BAND_2GHZ
)
1165 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_CFG_PROBE_REQ_2_4
,
1166 skb
->data
, skb
->len
, 0, rate
);
1168 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_CFG_PROBE_REQ_5
,
1169 skb
->data
, skb
->len
, 0, rate
);
1172 wl1271_error("Unable to set ap probe request template.");
1178 int wl1271_cmd_build_arp_rsp(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
1182 struct ieee80211_vif
*vif
= wl12xx_wlvif_to_vif(wlvif
);
1183 struct wl12xx_arp_rsp_template tmpl
;
1184 struct ieee80211_hdr_3addr
*hdr
;
1185 struct arphdr
*arp_hdr
;
1187 memset(&tmpl
, 0, sizeof(tmpl
));
1189 /* mac80211 header */
1191 hdr
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_DATA
|
1192 IEEE80211_STYPE_DATA
|
1193 IEEE80211_FCTL_TODS
);
1194 memcpy(hdr
->addr1
, vif
->bss_conf
.bssid
, ETH_ALEN
);
1195 memcpy(hdr
->addr2
, vif
->addr
, ETH_ALEN
);
1196 memset(hdr
->addr3
, 0xff, ETH_ALEN
);
1199 memcpy(tmpl
.llc_hdr
, rfc1042_header
, sizeof(rfc1042_header
));
1200 tmpl
.llc_type
= cpu_to_be16(ETH_P_ARP
);
1203 arp_hdr
= &tmpl
.arp_hdr
;
1204 arp_hdr
->ar_hrd
= cpu_to_be16(ARPHRD_ETHER
);
1205 arp_hdr
->ar_pro
= cpu_to_be16(ETH_P_IP
);
1206 arp_hdr
->ar_hln
= ETH_ALEN
;
1207 arp_hdr
->ar_pln
= 4;
1208 arp_hdr
->ar_op
= cpu_to_be16(ARPOP_REPLY
);
1211 memcpy(tmpl
.sender_hw
, vif
->addr
, ETH_ALEN
);
1212 tmpl
.sender_ip
= ip_addr
;
1214 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_ARP_RSP
,
1215 &tmpl
, sizeof(tmpl
), 0,
1221 int wl1271_build_qos_null_data(struct wl1271
*wl
, struct ieee80211_vif
*vif
)
1223 struct wl12xx_vif
*wlvif
= wl12xx_vif_to_data(vif
);
1224 struct ieee80211_qos_hdr
template;
1226 memset(&template, 0, sizeof(template));
1228 memcpy(template.addr1
, vif
->bss_conf
.bssid
, ETH_ALEN
);
1229 memcpy(template.addr2
, vif
->addr
, ETH_ALEN
);
1230 memcpy(template.addr3
, vif
->bss_conf
.bssid
, ETH_ALEN
);
1232 template.frame_control
= cpu_to_le16(IEEE80211_FTYPE_DATA
|
1233 IEEE80211_STYPE_QOS_NULLFUNC
|
1234 IEEE80211_FCTL_TODS
);
1236 /* FIXME: not sure what priority to use here */
1237 template.qos_ctrl
= cpu_to_le16(0);
1239 return wl1271_cmd_template_set(wl
, CMD_TEMPL_QOS_NULL_DATA
, &template,
1240 sizeof(template), 0,
1244 int wl12xx_cmd_set_default_wep_key(struct wl1271
*wl
, u8 id
, u8 hlid
)
1246 struct wl1271_cmd_set_keys
*cmd
;
1249 wl1271_debug(DEBUG_CMD
, "cmd set_default_wep_key %d", id
);
1251 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1259 cmd
->lid_key_type
= WEP_DEFAULT_LID_TYPE
;
1260 cmd
->key_action
= cpu_to_le16(KEY_SET_ID
);
1261 cmd
->key_type
= KEY_WEP
;
1263 ret
= wl1271_cmd_send(wl
, CMD_SET_KEYS
, cmd
, sizeof(*cmd
), 0);
1265 wl1271_warning("cmd set_default_wep_key failed: %d", ret
);
1275 int wl1271_cmd_set_sta_key(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
1276 u16 action
, u8 id
, u8 key_type
,
1277 u8 key_size
, const u8
*key
, const u8
*addr
,
1278 u32 tx_seq_32
, u16 tx_seq_16
)
1280 struct wl1271_cmd_set_keys
*cmd
;
1283 /* hlid might have already been deleted */
1284 if (wlvif
->sta
.hlid
== WL12XX_INVALID_LINK_ID
)
1287 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1293 cmd
->hlid
= wlvif
->sta
.hlid
;
1295 if (key_type
== KEY_WEP
)
1296 cmd
->lid_key_type
= WEP_DEFAULT_LID_TYPE
;
1297 else if (is_broadcast_ether_addr(addr
))
1298 cmd
->lid_key_type
= BROADCAST_LID_TYPE
;
1300 cmd
->lid_key_type
= UNICAST_LID_TYPE
;
1302 cmd
->key_action
= cpu_to_le16(action
);
1303 cmd
->key_size
= key_size
;
1304 cmd
->key_type
= key_type
;
1306 cmd
->ac_seq_num16
[0] = cpu_to_le16(tx_seq_16
);
1307 cmd
->ac_seq_num32
[0] = cpu_to_le32(tx_seq_32
);
1311 if (key_type
== KEY_TKIP
) {
1313 * We get the key in the following form:
1314 * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes)
1315 * but the target is expecting:
1316 * TKIP - RX MIC - TX MIC
1318 memcpy(cmd
->key
, key
, 16);
1319 memcpy(cmd
->key
+ 16, key
+ 24, 8);
1320 memcpy(cmd
->key
+ 24, key
+ 16, 8);
1323 memcpy(cmd
->key
, key
, key_size
);
1326 wl1271_dump(DEBUG_CRYPT
, "TARGET KEY: ", cmd
, sizeof(*cmd
));
1328 ret
= wl1271_cmd_send(wl
, CMD_SET_KEYS
, cmd
, sizeof(*cmd
), 0);
1330 wl1271_warning("could not set keys");
1341 * TODO: merge with sta/ibss into 1 set_key function.
1342 * note there are slight diffs
1344 int wl1271_cmd_set_ap_key(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
1345 u16 action
, u8 id
, u8 key_type
,
1346 u8 key_size
, const u8
*key
, u8 hlid
, u32 tx_seq_32
,
1349 struct wl1271_cmd_set_keys
*cmd
;
1353 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1357 if (hlid
== wlvif
->ap
.bcast_hlid
) {
1358 if (key_type
== KEY_WEP
)
1359 lid_type
= WEP_DEFAULT_LID_TYPE
;
1361 lid_type
= BROADCAST_LID_TYPE
;
1363 lid_type
= UNICAST_LID_TYPE
;
1366 wl1271_debug(DEBUG_CRYPT
, "ap key action: %d id: %d lid: %d type: %d"
1367 " hlid: %d", (int)action
, (int)id
, (int)lid_type
,
1368 (int)key_type
, (int)hlid
);
1370 cmd
->lid_key_type
= lid_type
;
1372 cmd
->key_action
= cpu_to_le16(action
);
1373 cmd
->key_size
= key_size
;
1374 cmd
->key_type
= key_type
;
1376 cmd
->ac_seq_num16
[0] = cpu_to_le16(tx_seq_16
);
1377 cmd
->ac_seq_num32
[0] = cpu_to_le32(tx_seq_32
);
1379 if (key_type
== KEY_TKIP
) {
1381 * We get the key in the following form:
1382 * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes)
1383 * but the target is expecting:
1384 * TKIP - RX MIC - TX MIC
1386 memcpy(cmd
->key
, key
, 16);
1387 memcpy(cmd
->key
+ 16, key
+ 24, 8);
1388 memcpy(cmd
->key
+ 24, key
+ 16, 8);
1390 memcpy(cmd
->key
, key
, key_size
);
1393 wl1271_dump(DEBUG_CRYPT
, "TARGET AP KEY: ", cmd
, sizeof(*cmd
));
1395 ret
= wl1271_cmd_send(wl
, CMD_SET_KEYS
, cmd
, sizeof(*cmd
), 0);
1397 wl1271_warning("could not set ap keys");
1406 int wl12xx_cmd_set_peer_state(struct wl1271
*wl
, u8 hlid
)
1408 struct wl12xx_cmd_set_peer_state
*cmd
;
1411 wl1271_debug(DEBUG_CMD
, "cmd set peer state (hlid=%d)", hlid
);
1413 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1420 cmd
->state
= WL1271_CMD_STA_STATE_CONNECTED
;
1422 ret
= wl1271_cmd_send(wl
, CMD_SET_PEER_STATE
, cmd
, sizeof(*cmd
), 0);
1424 wl1271_error("failed to send set peer state command");
1435 int wl12xx_cmd_add_peer(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
1436 struct ieee80211_sta
*sta
, u8 hlid
)
1438 struct wl12xx_cmd_add_peer
*cmd
;
1442 wl1271_debug(DEBUG_CMD
, "cmd add peer %d", (int)hlid
);
1444 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1450 memcpy(cmd
->addr
, sta
->addr
, ETH_ALEN
);
1451 cmd
->bss_index
= WL1271_AP_BSS_INDEX
;
1452 cmd
->aid
= sta
->aid
;
1454 cmd
->sp_len
= sta
->max_sp
;
1455 cmd
->wmm
= sta
->wme
? 1 : 0;
1457 for (i
= 0; i
< NUM_ACCESS_CATEGORIES_COPY
; i
++)
1458 if (sta
->wme
&& (sta
->uapsd_queues
& BIT(i
)))
1459 cmd
->psd_type
[i
] = WL1271_PSD_UPSD_TRIGGER
;
1461 cmd
->psd_type
[i
] = WL1271_PSD_LEGACY
;
1463 sta_rates
= sta
->supp_rates
[wlvif
->band
];
1464 if (sta
->ht_cap
.ht_supported
)
1465 sta_rates
|= sta
->ht_cap
.mcs
.rx_mask
[0] << HW_HT_RATES_OFFSET
;
1467 cmd
->supported_rates
=
1468 cpu_to_le32(wl1271_tx_enabled_rates_get(wl
, sta_rates
,
1471 wl1271_debug(DEBUG_CMD
, "new peer rates=0x%x queues=0x%x",
1472 cmd
->supported_rates
, sta
->uapsd_queues
);
1474 ret
= wl1271_cmd_send(wl
, CMD_ADD_PEER
, cmd
, sizeof(*cmd
), 0);
1476 wl1271_error("failed to initiate cmd add peer");
1487 int wl12xx_cmd_remove_peer(struct wl1271
*wl
, u8 hlid
)
1489 struct wl12xx_cmd_remove_peer
*cmd
;
1492 wl1271_debug(DEBUG_CMD
, "cmd remove peer %d", (int)hlid
);
1494 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1501 /* We never send a deauth, mac80211 is in charge of this */
1502 cmd
->reason_opcode
= 0;
1503 cmd
->send_deauth_flag
= 0;
1505 ret
= wl1271_cmd_send(wl
, CMD_REMOVE_PEER
, cmd
, sizeof(*cmd
), 0);
1507 wl1271_error("failed to initiate cmd remove peer");
1512 * We are ok with a timeout here. The event is sometimes not sent
1513 * due to a firmware bug.
1515 wl1271_cmd_wait_for_event_or_timeout(wl
,
1516 PEER_REMOVE_COMPLETE_EVENT_ID
);
1525 int wl12xx_cmd_config_fwlog(struct wl1271
*wl
)
1527 struct wl12xx_cmd_config_fwlog
*cmd
;
1530 wl1271_debug(DEBUG_CMD
, "cmd config firmware logger");
1532 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1538 cmd
->logger_mode
= wl
->conf
.fwlog
.mode
;
1539 cmd
->log_severity
= wl
->conf
.fwlog
.severity
;
1540 cmd
->timestamp
= wl
->conf
.fwlog
.timestamp
;
1541 cmd
->output
= wl
->conf
.fwlog
.output
;
1542 cmd
->threshold
= wl
->conf
.fwlog
.threshold
;
1544 ret
= wl1271_cmd_send(wl
, CMD_CONFIG_FWLOGGER
, cmd
, sizeof(*cmd
), 0);
1546 wl1271_error("failed to send config firmware logger command");
1557 int wl12xx_cmd_start_fwlog(struct wl1271
*wl
)
1559 struct wl12xx_cmd_start_fwlog
*cmd
;
1562 wl1271_debug(DEBUG_CMD
, "cmd start firmware logger");
1564 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1570 ret
= wl1271_cmd_send(wl
, CMD_START_FWLOGGER
, cmd
, sizeof(*cmd
), 0);
1572 wl1271_error("failed to send start firmware logger command");
1583 int wl12xx_cmd_stop_fwlog(struct wl1271
*wl
)
1585 struct wl12xx_cmd_stop_fwlog
*cmd
;
1588 wl1271_debug(DEBUG_CMD
, "cmd stop firmware logger");
1590 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1596 ret
= wl1271_cmd_send(wl
, CMD_STOP_FWLOGGER
, cmd
, sizeof(*cmd
), 0);
1598 wl1271_error("failed to send stop firmware logger command");
1609 static int wl12xx_cmd_roc(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
1612 struct wl12xx_cmd_roc
*cmd
;
1615 wl1271_debug(DEBUG_CMD
, "cmd roc %d (%d)", wlvif
->channel
, role_id
);
1617 if (WARN_ON(role_id
== WL12XX_INVALID_ROLE_ID
))
1620 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1626 cmd
->role_id
= role_id
;
1627 cmd
->channel
= wlvif
->channel
;
1628 switch (wlvif
->band
) {
1629 case IEEE80211_BAND_2GHZ
:
1630 cmd
->band
= RADIO_BAND_2_4GHZ
;
1632 case IEEE80211_BAND_5GHZ
:
1633 cmd
->band
= RADIO_BAND_5GHZ
;
1636 wl1271_error("roc - unknown band: %d", (int)wlvif
->band
);
1642 ret
= wl1271_cmd_send(wl
, CMD_REMAIN_ON_CHANNEL
, cmd
, sizeof(*cmd
), 0);
1644 wl1271_error("failed to send ROC command");
1655 static int wl12xx_cmd_croc(struct wl1271
*wl
, u8 role_id
)
1657 struct wl12xx_cmd_croc
*cmd
;
1660 wl1271_debug(DEBUG_CMD
, "cmd croc (%d)", role_id
);
1662 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1667 cmd
->role_id
= role_id
;
1669 ret
= wl1271_cmd_send(wl
, CMD_CANCEL_REMAIN_ON_CHANNEL
, cmd
,
1672 wl1271_error("failed to send ROC command");
1683 int wl12xx_roc(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
, u8 role_id
)
1687 if (WARN_ON(test_bit(role_id
, wl
->roc_map
)))
1690 ret
= wl12xx_cmd_roc(wl
, wlvif
, role_id
);
1694 ret
= wl1271_cmd_wait_for_event(wl
,
1695 REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID
);
1697 wl1271_error("cmd roc event completion error");
1701 __set_bit(role_id
, wl
->roc_map
);
1706 int wl12xx_croc(struct wl1271
*wl
, u8 role_id
)
1710 if (WARN_ON(!test_bit(role_id
, wl
->roc_map
)))
1713 ret
= wl12xx_cmd_croc(wl
, role_id
);
1717 __clear_bit(role_id
, wl
->roc_map
);
1722 int wl12xx_cmd_channel_switch(struct wl1271
*wl
,
1723 struct ieee80211_channel_switch
*ch_switch
)
1725 struct wl12xx_cmd_channel_switch
*cmd
;
1728 wl1271_debug(DEBUG_ACX
, "cmd channel switch");
1730 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1736 cmd
->channel
= ch_switch
->channel
->hw_value
;
1737 cmd
->switch_time
= ch_switch
->count
;
1738 cmd
->tx_suspend
= ch_switch
->block_tx
;
1739 cmd
->flush
= 0; /* this value is ignored by the FW */
1741 ret
= wl1271_cmd_send(wl
, CMD_CHANNEL_SWITCH
, cmd
, sizeof(*cmd
), 0);
1743 wl1271_error("failed to send channel switch command");
1754 int wl12xx_cmd_stop_channel_switch(struct wl1271
*wl
)
1756 struct wl12xx_cmd_stop_channel_switch
*cmd
;
1759 wl1271_debug(DEBUG_ACX
, "cmd stop channel switch");
1761 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1767 ret
= wl1271_cmd_send(wl
, CMD_STOP_CHANNEL_SWICTH
, cmd
, sizeof(*cmd
), 0);
1769 wl1271_error("failed to stop channel switch command");