brcmfmac: add support for manual TDLS operations
authorArend van Spriel <arend@broadcom.com>
Sat, 10 Aug 2013 10:27:25 +0000 (12:27 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 15 Aug 2013 20:07:54 +0000 (16:07 -0400)
Implement the .tdls_oper() callback and indicate TDLS support
in the wiphy flags.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c

index 665ef69e974b43c05ca802677fd6c36ce677baf9..ecabb04f33c3059c603513511cfd2679d23d6bb0 100644 (file)
@@ -69,4 +69,25 @@ struct brcmf_fil_bss_enable_le {
        __le32 enable;
 };
 
+/**
+ * struct tdls_iovar - common structure for tdls iovars.
+ *
+ * @ea: ether address of peer station.
+ * @mode: mode value depending on specific tdls iovar.
+ * @chanspec: channel specification.
+ * @pad: unused (for future use).
+ */
+struct brcmf_tdls_iovar_le {
+       u8 ea[ETH_ALEN];                /* Station address */
+       u8 mode;                        /* mode: depends on iovar */
+       __le16 chanspec;
+       __le32 pad;                     /* future */
+};
+
+enum brcmf_tdls_manual_ep_ops {
+       BRCMF_TDLS_MANUAL_EP_CREATE = 1,
+       BRCMF_TDLS_MANUAL_EP_DELETE = 3,
+       BRCMF_TDLS_MANUAL_EP_DISCOVERY = 6
+};
+
 #endif /* FWIL_TYPES_H_ */
index c3dfea3f307d931c7b8dadfe48d4891d24a2724f..0370e44cec111348f33c60c3e09a4e268fe36a29 100644 (file)
@@ -4126,6 +4126,53 @@ static void brcmf_cfg80211_crit_proto_stop(struct wiphy *wiphy,
        clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status);
 }
 
+static int brcmf_convert_nl80211_tdls_oper(enum nl80211_tdls_operation oper)
+{
+       int ret;
+
+       switch (oper) {
+       case NL80211_TDLS_DISCOVERY_REQ:
+               ret = BRCMF_TDLS_MANUAL_EP_DISCOVERY;
+               break;
+       case NL80211_TDLS_SETUP:
+               ret = BRCMF_TDLS_MANUAL_EP_CREATE;
+               break;
+       case NL80211_TDLS_TEARDOWN:
+               ret = BRCMF_TDLS_MANUAL_EP_DELETE;
+               break;
+       default:
+               brcmf_err("unsupported operation: %d\n", oper);
+               ret = -EOPNOTSUPP;
+       }
+       return ret;
+}
+
+static int brcmf_cfg80211_tdls_oper(struct wiphy *wiphy,
+                                   struct net_device *ndev, u8 *peer,
+                                   enum nl80211_tdls_operation oper)
+{
+       struct brcmf_if *ifp;
+       struct brcmf_tdls_iovar_le info;
+       int ret = 0;
+
+       ret = brcmf_convert_nl80211_tdls_oper(oper);
+       if (ret < 0)
+               return ret;
+
+       ifp = netdev_priv(ndev);
+       memset(&info, 0, sizeof(info));
+       info.mode = (u8)ret;
+       if (peer)
+               memcpy(info.ea, peer, ETH_ALEN);
+
+       ret = brcmf_fil_iovar_data_set(ifp, "tdls_endpoint",
+                                      &info, sizeof(info));
+       if (ret < 0)
+               brcmf_err("tdls_endpoint iovar failed: ret=%d\n", ret);
+
+       return ret;
+}
+
 static struct cfg80211_ops wl_cfg80211_ops = {
        .add_virtual_intf = brcmf_cfg80211_add_iface,
        .del_virtual_intf = brcmf_cfg80211_del_iface,
@@ -4164,6 +4211,7 @@ static struct cfg80211_ops wl_cfg80211_ops = {
        .stop_p2p_device = brcmf_p2p_stop_device,
        .crit_proto_start = brcmf_cfg80211_crit_proto_start,
        .crit_proto_stop = brcmf_cfg80211_crit_proto_stop,
+       .tdls_oper = brcmf_cfg80211_tdls_oper,
        CFG80211_TESTMODE_CMD(brcmf_cfg80211_testmode)
 };
 
@@ -4285,7 +4333,8 @@ static struct wiphy *brcmf_setup_wiphy(struct device *phydev)
        wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
        wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT |
                        WIPHY_FLAG_OFFCHAN_TX |
-                       WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
+                       WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
+                       WIPHY_FLAG_SUPPORTS_TDLS;
        wiphy->mgmt_stypes = brcmf_txrx_stypes;
        wiphy->max_remain_on_channel_duration = 5000;
        brcmf_wiphy_pno_params(wiphy);
@@ -4906,6 +4955,12 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
                goto cfg80211_p2p_attach_out;
        }
 
+       err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1);
+       if (err) {
+               brcmf_dbg(INFO, "TDLS not enabled (%d)\n", err);
+               wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_TDLS;
+       }
+
        err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION,
                                    &io_type);
        if (err) {