qtnfmac: advertise netdev port parent ID
authorIgor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Mon, 18 Nov 2019 08:23:10 +0000 (08:23 +0000)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 20 Nov 2019 07:42:58 +0000 (09:42 +0200)
Use MAC address of the first active radio as a unique device ID.

Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/quantenna/qtnfmac/bus.h
drivers/net/wireless/quantenna/qtnfmac/commands.c
drivers/net/wireless/quantenna/qtnfmac/core.c
drivers/net/wireless/quantenna/qtnfmac/core.h

index 49372d42e4714d1037e05dc8984501521558f1b6..87d048df09d17a7781ee640b4f649db732c9c0ef 100644 (file)
@@ -67,6 +67,7 @@ struct qtnf_bus {
        struct mutex bus_lock; /* lock during command/event processing */
        struct dentry *dbg_dir;
        struct notifier_block netdev_nb;
+       u8 hw_id[ETH_ALEN];
        /* bus private data */
        char bus_priv[0] __aligned(sizeof(void *));
 };
index cbc56464220ec372b0f25137f4c886bd269425e0..1c1b377932cfbabb18cf35d3fcca262ba4fb18f3 100644 (file)
@@ -1242,10 +1242,7 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac,
        mac_info = &mac->macinfo;
 
        mac_info->bands_cap = resp_info->bands_cap;
-       memcpy(&mac_info->dev_mac, &resp_info->dev_mac,
-              sizeof(mac_info->dev_mac));
-
-       ether_addr_copy(mac->macaddr, mac_info->dev_mac);
+       ether_addr_copy(mac->macaddr, resp_info->dev_mac);
 
        vif = qtnf_mac_get_base_vif(mac);
        if (vif)
index 7300ab407cd6e3b1a5d2e05bac049a2cf8cf759b..a709e378928dfac5d8fe48806049aeee5a47da97 100644 (file)
@@ -204,6 +204,21 @@ static int qtnf_netdev_set_mac_address(struct net_device *ndev, void *addr)
        return ret;
 }
 
+static int qtnf_netdev_port_parent_id(struct net_device *ndev,
+                                     struct netdev_phys_item_id *ppid)
+{
+       const struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
+       const struct qtnf_bus *bus = vif->mac->bus;
+
+       if (!(bus->hw_info.hw_capab & QLINK_HW_CAPAB_HW_BRIDGE))
+               return -EOPNOTSUPP;
+
+       ppid->id_len = sizeof(bus->hw_id);
+       memcpy(&ppid->id, bus->hw_id, ppid->id_len);
+
+       return 0;
+}
+
 /* Network device ops handlers */
 const struct net_device_ops qtnf_netdev_ops = {
        .ndo_open = qtnf_netdev_open,
@@ -212,6 +227,7 @@ const struct net_device_ops qtnf_netdev_ops = {
        .ndo_tx_timeout = qtnf_netdev_tx_timeout,
        .ndo_get_stats64 = qtnf_netdev_get_stats64,
        .ndo_set_mac_address = qtnf_netdev_set_mac_address,
+       .ndo_get_port_parent_id = qtnf_netdev_port_parent_id,
 };
 
 static int qtnf_mac_init_single_band(struct wiphy *wiphy,
@@ -565,6 +581,10 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
                goto error;
        }
 
+       /* Use MAC address of the first active radio as a unique device ID */
+       if (is_zero_ether_addr(mac->bus->hw_id))
+               ether_addr_copy(mac->bus->hw_id, mac->macaddr);
+
        vif = qtnf_mac_get_base_vif(mac);
        if (!vif) {
                pr_err("MAC%u: primary VIF is not ready\n", macid);
index 75b70f0c2b8ead31a5a0ef7b82d49704f4c11411..116ec16aa15b629b9e39cdc3c12e29bc47b22080 100644 (file)
@@ -74,7 +74,6 @@ struct qtnf_vif {
 
 struct qtnf_mac_info {
        u8 bands_cap;
-       u8 dev_mac[ETH_ALEN];
        u8 num_tx_chain;
        u8 num_rx_chain;
        u16 max_ap_assoc_sta;