Add ieee80211_vif_to_netdev utility routine to get the netdevice
pointer related to ieee80211_vif one even if the sdata has not been
inserted in the driver or running yet. ieee80211_vif_to_netdev
will be used by mt76 to properly configure xdp_rxq_info data
structure adding vif to the driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianc...@redhat.com>
---
 include/net/mac80211.h |  2 ++
 net/mac80211/util.c    | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index a91f1733ce43..f2784b36f2e2 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1603,6 +1603,8 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct 
wireless_dev *wdev);
  */
 struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
 
+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif);
+
 /**
  * enum ieee80211_key_flags - key flags
  *
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index bec424316ea4..a98293d71818 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -827,6 +827,18 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct 
ieee80211_vif *vif)
 }
 EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
 
+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif)
+{
+       struct ieee80211_sub_if_data *sdata;
+
+       if (!vif)
+               return NULL;
+
+       sdata = vif_to_sdata(vif);
+       return sdata->dev;
+}
+EXPORT_SYMBOL_GPL(ieee80211_vif_to_netdev);
+
 /*
  * Nothing should have been stuffed into the workqueue during
  * the suspend->resume cycle. Since we can't check each caller
-- 
2.19.1

Reply via email to