]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
wlcore/wl18xx: handle smart config events
authorEliad Peller <eliad@wizery.com>
Fri, 11 Jul 2014 00:01:33 +0000 (03:01 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 15 Jul 2014 19:59:57 +0000 (15:59 -0400)
add defintions and handling for smart config events
(SMART_CONFIG_SYNC_EVENT_ID and SMART_CONFIG_DECODE_EVENT_ID)

parse the relevant info and send it to userspace as
vendor event.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ti/wl18xx/event.c
drivers/net/wireless/ti/wl18xx/event.h
drivers/net/wireless/ti/wl18xx/main.c
drivers/net/wireless/ti/wlcore/vendor_cmd.c
drivers/net/wireless/ti/wlcore/vendor_cmd.h

index c9199d7804c634380c25bcb5c126f1ebb22f40fd..eb1848e084242f24e220a3d721b2da51df322b02 100644 (file)
  *
  */
 
+#include <net/genetlink.h>
 #include "event.h"
 #include "scan.h"
 #include "../wlcore/cmd.h"
 #include "../wlcore/debug.h"
+#include "../wlcore/vendor_cmd.h"
 
 int wl18xx_wait_for_event(struct wl1271 *wl, enum wlcore_wait_event event,
                          bool *timeout)
@@ -45,6 +47,58 @@ int wl18xx_wait_for_event(struct wl1271 *wl, enum wlcore_wait_event event,
        return wlcore_cmd_wait_for_event_or_timeout(wl, local_event, timeout);
 }
 
+static int wlcore_smart_config_sync_event(struct wl1271 *wl, u8 sync_channel,
+                                         u8 sync_band)
+{
+       struct sk_buff *skb;
+       enum ieee80211_band band;
+       int freq;
+
+       if (sync_band == WLCORE_BAND_5GHZ)
+               band = IEEE80211_BAND_5GHZ;
+       else
+               band = IEEE80211_BAND_2GHZ;
+
+       freq = ieee80211_channel_to_frequency(sync_channel, band);
+
+       wl1271_debug(DEBUG_EVENT,
+                    "SMART_CONFIG_SYNC_EVENT_ID, freq: %d (chan: %d band %d)",
+                    freq, sync_channel, sync_band);
+       skb = cfg80211_vendor_event_alloc(wl->hw->wiphy, 20,
+                                         WLCORE_VENDOR_EVENT_SC_SYNC,
+                                         GFP_KERNEL);
+
+       if (nla_put_u32(skb, WLCORE_VENDOR_ATTR_FREQ, freq)) {
+               kfree_skb(skb);
+               return -EMSGSIZE;
+       }
+       cfg80211_vendor_event(skb, GFP_KERNEL);
+       return 0;
+}
+
+static int wlcore_smart_config_decode_event(struct wl1271 *wl,
+                                           u8 ssid_len, u8 *ssid,
+                                           u8 pwd_len, u8 *pwd)
+{
+       struct sk_buff *skb;
+
+       wl1271_debug(DEBUG_EVENT, "SMART_CONFIG_DECODE_EVENT_ID");
+       wl1271_dump_ascii(DEBUG_EVENT, "SSID:", ssid, ssid_len);
+
+       skb = cfg80211_vendor_event_alloc(wl->hw->wiphy,
+                                         ssid_len + pwd_len + 20,
+                                         WLCORE_VENDOR_EVENT_SC_DECODE,
+                                         GFP_KERNEL);
+
+       if (nla_put(skb, WLCORE_VENDOR_ATTR_SSID, ssid_len, ssid) ||
+           nla_put(skb, WLCORE_VENDOR_ATTR_PSK, pwd_len, pwd)) {
+               kfree_skb(skb);
+               return -EMSGSIZE;
+       }
+       cfg80211_vendor_event(skb, GFP_KERNEL);
+       return 0;
+}
+
 int wl18xx_process_mailbox_events(struct wl1271 *wl)
 {
        struct wl18xx_event_mailbox *mbox = wl->mbox;
@@ -107,5 +161,16 @@ int wl18xx_process_mailbox_events(struct wl1271 *wl)
        if (vector & REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID)
                wlcore_event_roc_complete(wl);
 
+       if (vector & SMART_CONFIG_SYNC_EVENT_ID)
+               wlcore_smart_config_sync_event(wl, mbox->sc_sync_channel,
+                                              mbox->sc_sync_band);
+
+       if (vector & SMART_CONFIG_DECODE_EVENT_ID)
+               wlcore_smart_config_decode_event(wl,
+                                                mbox->sc_ssid_len,
+                                                mbox->sc_ssid,
+                                                mbox->sc_pwd_len,
+                                                mbox->sc_pwd);
+
        return 0;
 }
index a76e98eb8372a9c2f7ff205e87e8a5667a48de38..0680312d49439ca1fe8ea181855c54cb656117be 100644 (file)
@@ -38,6 +38,8 @@ enum {
        REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID      = BIT(18),
        DFS_CHANNELS_CONFIG_COMPLETE_EVENT       = BIT(19),
        PERIODIC_SCAN_REPORT_EVENT_ID            = BIT(20),
+       SMART_CONFIG_SYNC_EVENT_ID               = BIT(22),
+       SMART_CONFIG_DECODE_EVENT_ID             = BIT(23),
 };
 
 struct wl18xx_event_mailbox {
index 2727ca38807c34650e19d7724bb28fb249330e53..4422ecf0e72659d4f6f81e720d5e484ea84b484e 100644 (file)
@@ -992,7 +992,10 @@ static int wl18xx_boot(struct wl1271 *wl)
                REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID |
                INACTIVE_STA_EVENT_ID |
                CHANNEL_SWITCH_COMPLETE_EVENT_ID |
-               DFS_CHANNELS_CONFIG_COMPLETE_EVENT;
+               DFS_CHANNELS_CONFIG_COMPLETE_EVENT |
+               SMART_CONFIG_SYNC_EVENT_ID |
+               SMART_CONFIG_DECODE_EVENT_ID;
+;
 
        wl->ap_event_mask = MAX_TX_FAILURE_EVENT_ID;
 
index 98852b2ceb4d0af34bb2e8ab04f9e82835f5b8b4..ad86a48dcfcbe80d8609952cd32a97b62f3c528b 100644 (file)
@@ -177,8 +177,21 @@ static const struct wiphy_vendor_command wlcore_vendor_commands[] = {
        },
 };
 
+static const struct nl80211_vendor_cmd_info wlcore_vendor_events[] = {
+       {
+               .vendor_id = TI_OUI,
+               .subcmd = WLCORE_VENDOR_EVENT_SC_SYNC,
+       },
+       {
+               .vendor_id = TI_OUI,
+               .subcmd = WLCORE_VENDOR_EVENT_SC_DECODE,
+       },
+};
+
 void wlcore_set_vendor_commands(struct wiphy *wiphy)
 {
        wiphy->vendor_commands = wlcore_vendor_commands;
        wiphy->n_vendor_commands = ARRAY_SIZE(wlcore_vendor_commands);
+       wiphy->vendor_events = wlcore_vendor_events;
+       wiphy->n_vendor_events = ARRAY_SIZE(wlcore_vendor_events);
 }
index 7e8e92fad16c459fac7d2151644728b14e3f6c09..6e0c15e30f03a0e2f1f74b6f174e0a56945473a6 100644 (file)
 #ifndef __WLCORE_VENDOR_H__
 #define __WLCORE_VENDOR_H__
 
+#ifdef __KERNEL__
+void wlcore_set_vendor_commands(struct wiphy *wiphy);
+#endif
+
 #define TI_OUI 0x080028
 
 enum wlcore_vendor_commands {
@@ -33,4 +37,9 @@ enum wlcore_vendor_attributes {
        MAX_WLCORE_VENDOR_ATTR = NUM_WLCORE_VENDOR_ATTR - 1
 };
 
+enum wlcore_vendor_events {
+       WLCORE_VENDOR_EVENT_SC_SYNC,
+       WLCORE_VENDOR_EVENT_SC_DECODE,
+};
+
 #endif /* __WLCORE_VENDOR_H__ */