qtnfmac: add support for 4addr mode
authorSergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Mon, 14 Jan 2019 09:39:38 +0000 (09:39 +0000)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 1 Feb 2019 12:11:55 +0000 (14:11 +0200)
Advertise WIPHY_FLAG_4ADDR_STATION capability to wireless core. Send
use4addr interface change flag to firmware in change_virtual_intf
cfg80211 callback.

In order to enable adding wireless station interface to bridge
one should turn on 4addr mode using the following command:
$ iw dev wlan0 set 4addr on
$ brctl addif br0 wlan0

If this commands succeeds, then interface can be added to bridge.
Note that when wireless interface is added to bridge, wpa_supplicant
should be started with appropriate -b <brname> parameter, e.g:
$ wpa_supplicant -Dnl80211 -iwlan0 -c/path/to/wpa.conf -b br0

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
drivers/net/wireless/quantenna/qtnfmac/commands.c
drivers/net/wireless/quantenna/qtnfmac/commands.h
drivers/net/wireless/quantenna/qtnfmac/core.c
drivers/net/wireless/quantenna/qtnfmac/qlink.h

index 51b33ec78facf4f9758ad383820a7a2ed7a2d097..a43f8120df3cce86cb3d61b950925c70e1547fdd 100644 (file)
@@ -122,7 +122,8 @@ qtnf_change_virtual_intf(struct wiphy *wiphy,
                         struct vif_params *params)
 {
        struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
-       u8 *mac_addr;
+       u8 *mac_addr = NULL;
+       int use4addr = 0;
        int ret;
 
        ret = qtnf_validate_iface_combinations(wiphy, vif, type);
@@ -132,14 +133,14 @@ qtnf_change_virtual_intf(struct wiphy *wiphy,
                return ret;
        }
 
-       if (params)
+       if (params) {
                mac_addr = params->macaddr;
-       else
-               mac_addr = NULL;
+               use4addr = params->use_4addr;
+       }
 
        qtnf_scan_done(vif->mac, true);
 
-       ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr);
+       ret = qtnf_cmd_send_change_intf_type(vif, type, use4addr, mac_addr);
        if (ret) {
                pr_err("VIF%u.%u: failed to change type to %d\n",
                       vif->mac->macid, vif->vifid, type);
@@ -190,6 +191,7 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
        struct qtnf_wmac *mac;
        struct qtnf_vif *vif;
        u8 *mac_addr = NULL;
+       int use4addr = 0;
        int ret;
 
        mac = wiphy_priv(wiphy);
@@ -225,10 +227,12 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
                return ERR_PTR(-ENOTSUPP);
        }
 
-       if (params)
+       if (params) {
                mac_addr = params->macaddr;
+               use4addr = params->use_4addr;
+       }
 
-       ret = qtnf_cmd_send_add_intf(vif, type, mac_addr);
+       ret = qtnf_cmd_send_add_intf(vif, type, use4addr, mac_addr);
        if (ret) {
                pr_err("VIF%u.%u: failed to add VIF %pM\n",
                       mac->macid, vif->vifid, mac_addr);
@@ -1107,7 +1111,8 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
        wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
                        WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
                        WIPHY_FLAG_AP_UAPSD |
-                       WIPHY_FLAG_HAS_CHANNEL_SWITCH;
+                       WIPHY_FLAG_HAS_CHANNEL_SWITCH |
+                       WIPHY_FLAG_4ADDR_STATION;
        wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
 
        if (hw_info->hw_capab & QLINK_HW_CAPAB_DFS_OFFLOAD)
index 6575247c8b6ba9e9d83741c21998d2b46e666ce8..d03b3d03f4cc744df5955578d10ef171959c6d07 100644 (file)
@@ -734,6 +734,7 @@ out:
 
 static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
                                         enum nl80211_iftype iftype,
+                                        int use4addr,
                                         u8 *mac_addr,
                                         enum qlink_cmd_type cmd_type)
 {
@@ -751,6 +752,7 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
        qtnf_bus_lock(vif->mac->bus);
 
        cmd = (struct qlink_cmd_manage_intf *)cmd_skb->data;
+       cmd->intf_info.use4addr = use4addr;
 
        switch (iftype) {
        case NL80211_IFTYPE_AP:
@@ -786,17 +788,19 @@ out:
        return ret;
 }
 
-int qtnf_cmd_send_add_intf(struct qtnf_vif *vif,
-                          enum nl80211_iftype iftype, u8 *mac_addr)
+int qtnf_cmd_send_add_intf(struct qtnf_vif *vif, enum nl80211_iftype iftype,
+                          int use4addr, u8 *mac_addr)
 {
-       return qtnf_cmd_send_add_change_intf(vif, iftype, mac_addr,
+       return qtnf_cmd_send_add_change_intf(vif, iftype, use4addr, mac_addr,
                        QLINK_CMD_ADD_INTF);
 }
 
 int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif,
-                                  enum nl80211_iftype iftype, u8 *mac_addr)
+                                  enum nl80211_iftype iftype,
+                                  int use4addr,
+                                  u8 *mac_addr)
 {
-       return qtnf_cmd_send_add_change_intf(vif, iftype, mac_addr,
+       return qtnf_cmd_send_add_change_intf(vif, iftype, use4addr, mac_addr,
                                             QLINK_CMD_CHANGE_INTF);
 }
 
index 1ac41156c192c083307fb4848b3a54d594b9d329..1c25e7905e9a60890bbcc90516dac8b95acb3f3f 100644 (file)
@@ -26,9 +26,11 @@ void qtnf_cmd_send_deinit_fw(struct qtnf_bus *bus);
 int qtnf_cmd_get_hw_info(struct qtnf_bus *bus);
 int qtnf_cmd_get_mac_info(struct qtnf_wmac *mac);
 int qtnf_cmd_send_add_intf(struct qtnf_vif *vif, enum nl80211_iftype iftype,
-                          u8 *mac_addr);
+                          int use4addr, u8 *mac_addr);
 int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif,
-                                  enum nl80211_iftype iftype, u8 *mac_addr);
+                                  enum nl80211_iftype iftype,
+                                  int use4addr,
+                                  u8 *mac_addr);
 int qtnf_cmd_send_del_intf(struct qtnf_vif *vif);
 int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
                           struct ieee80211_supported_band *band);
index 5d18a4a917c9041cbb3ad93596128092840642f8..29258acfa8dc0dc6368187c72d16871ef39dfcfe 100644 (file)
@@ -195,6 +195,7 @@ static int qtnf_netdev_set_mac_address(struct net_device *ndev, void *addr)
        qtnf_scan_done(vif->mac, true);
 
        ret = qtnf_cmd_send_change_intf_type(vif, vif->wdev.iftype,
+                                            vif->wdev.use_4addr,
                                             sa->sa_data);
 
        if (ret)
@@ -545,7 +546,8 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
                goto error;
        }
 
-       ret = qtnf_cmd_send_add_intf(vif, vif->wdev.iftype, vif->mac_addr);
+       ret = qtnf_cmd_send_add_intf(vif, vif->wdev.iftype,
+                                    vif->wdev.use_4addr, vif->mac_addr);
        if (ret) {
                pr_err("MAC%u: failed to add VIF\n", macid);
                goto error;
index f9c7f87afaf87e242641bf5c32d506de283e1642..a78cb9e05068a73288b191566615f8850af8f307 100644 (file)
@@ -105,7 +105,8 @@ struct qlink_intf_info {
        __le16 if_type;
        __le16 vlanid;
        u8 mac_addr[ETH_ALEN];
-       u8 rsvd[2];
+       u8 use4addr;
+       u8 rsvd[1];
 } __packed;
 
 enum qlink_sta_flags {