2 * This file is part of wl12xx
4 * Copyright (C) 2012 Texas Instruments. All rights reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include <net/genetlink.h>
25 #include "../wlcore/cmd.h"
26 #include "../wlcore/debug.h"
27 #include "../wlcore/vendor_cmd.h"
29 int wl18xx_wait_for_event(struct wl1271
*wl
, enum wlcore_wait_event event
,
35 case WLCORE_EVENT_PEER_REMOVE_COMPLETE
:
36 local_event
= PEER_REMOVE_COMPLETE_EVENT_ID
;
39 case WLCORE_EVENT_DFS_CONFIG_COMPLETE
:
40 local_event
= DFS_CHANNELS_CONFIG_COMPLETE_EVENT
;
44 /* event not implemented */
47 return wlcore_cmd_wait_for_event_or_timeout(wl
, local_event
, timeout
);
50 static int wlcore_smart_config_sync_event(struct wl1271
*wl
, u8 sync_channel
,
54 enum ieee80211_band band
;
57 if (sync_band
== WLCORE_BAND_5GHZ
)
58 band
= IEEE80211_BAND_5GHZ
;
60 band
= IEEE80211_BAND_2GHZ
;
62 freq
= ieee80211_channel_to_frequency(sync_channel
, band
);
64 wl1271_debug(DEBUG_EVENT
,
65 "SMART_CONFIG_SYNC_EVENT_ID, freq: %d (chan: %d band %d)",
66 freq
, sync_channel
, sync_band
);
67 skb
= cfg80211_vendor_event_alloc(wl
->hw
->wiphy
, 20,
68 WLCORE_VENDOR_EVENT_SC_SYNC
,
71 if (nla_put_u32(skb
, WLCORE_VENDOR_ATTR_FREQ
, freq
)) {
75 cfg80211_vendor_event(skb
, GFP_KERNEL
);
79 static int wlcore_smart_config_decode_event(struct wl1271
*wl
,
80 u8 ssid_len
, u8
*ssid
,
85 wl1271_debug(DEBUG_EVENT
, "SMART_CONFIG_DECODE_EVENT_ID");
86 wl1271_dump_ascii(DEBUG_EVENT
, "SSID:", ssid
, ssid_len
);
88 skb
= cfg80211_vendor_event_alloc(wl
->hw
->wiphy
,
89 ssid_len
+ pwd_len
+ 20,
90 WLCORE_VENDOR_EVENT_SC_DECODE
,
93 if (nla_put(skb
, WLCORE_VENDOR_ATTR_SSID
, ssid_len
, ssid
) ||
94 nla_put(skb
, WLCORE_VENDOR_ATTR_PSK
, pwd_len
, pwd
)) {
98 cfg80211_vendor_event(skb
, GFP_KERNEL
);
102 int wl18xx_process_mailbox_events(struct wl1271
*wl
)
104 struct wl18xx_event_mailbox
*mbox
= wl
->mbox
;
107 vector
= le32_to_cpu(mbox
->events_vector
);
108 wl1271_debug(DEBUG_EVENT
, "MBOX vector: 0x%x", vector
);
110 if (vector
& SCAN_COMPLETE_EVENT_ID
) {
111 wl1271_debug(DEBUG_EVENT
, "scan results: %d",
112 mbox
->number_of_scan_results
);
115 wl18xx_scan_completed(wl
, wl
->scan_wlvif
);
118 if (vector
& PERIODIC_SCAN_REPORT_EVENT_ID
) {
119 wl1271_debug(DEBUG_EVENT
,
120 "PERIODIC_SCAN_REPORT_EVENT (results %d)",
121 mbox
->number_of_sched_scan_results
);
123 wlcore_scan_sched_scan_results(wl
);
126 if (vector
& PERIODIC_SCAN_COMPLETE_EVENT_ID
)
127 wlcore_event_sched_scan_completed(wl
, 1);
129 if (vector
& RSSI_SNR_TRIGGER_0_EVENT_ID
)
130 wlcore_event_rssi_trigger(wl
, mbox
->rssi_snr_trigger_metric
);
132 if (vector
& BA_SESSION_RX_CONSTRAINT_EVENT_ID
)
133 wlcore_event_ba_rx_constraint(wl
,
134 le16_to_cpu(mbox
->rx_ba_role_id_bitmap
),
135 le16_to_cpu(mbox
->rx_ba_allowed_bitmap
));
137 if (vector
& BSS_LOSS_EVENT_ID
)
138 wlcore_event_beacon_loss(wl
,
139 le16_to_cpu(mbox
->bss_loss_bitmap
));
141 if (vector
& CHANNEL_SWITCH_COMPLETE_EVENT_ID
)
142 wlcore_event_channel_switch(wl
,
143 le16_to_cpu(mbox
->channel_switch_role_id_bitmap
),
146 if (vector
& DUMMY_PACKET_EVENT_ID
)
147 wlcore_event_dummy_packet(wl
);
150 * "TX retries exceeded" has a different meaning according to mode.
151 * In AP mode the offending station is disconnected.
153 if (vector
& MAX_TX_FAILURE_EVENT_ID
)
154 wlcore_event_max_tx_failure(wl
,
155 le32_to_cpu(mbox
->tx_retry_exceeded_bitmap
));
157 if (vector
& INACTIVE_STA_EVENT_ID
)
158 wlcore_event_inactive_sta(wl
,
159 le32_to_cpu(mbox
->inactive_sta_bitmap
));
161 if (vector
& REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID
)
162 wlcore_event_roc_complete(wl
);
164 if (vector
& SMART_CONFIG_SYNC_EVENT_ID
)
165 wlcore_smart_config_sync_event(wl
, mbox
->sc_sync_channel
,
168 if (vector
& SMART_CONFIG_DECODE_EVENT_ID
)
169 wlcore_smart_config_decode_event(wl
,