diff mbox series

[RFC,2/5] mac80211: introduce ieee80211_vif_to_netdev routine

Message ID 0db1977129e87685d66b2e9d6ddd821fe8d9fcf7.1543343124.git.lorenzo.bianconi@redhat.com (mailing list archive)
State RFC
Delegated to: Johannes Berg
Headers show
Series add XDP support to mt76x2e/mt76x0e drivers | expand

Commit Message

Lorenzo Bianconi Nov. 27, 2018, 10:21 p.m. UTC
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.bianconi@redhat.com>
---
 include/net/mac80211.h |  2 ++
 net/mac80211/util.c    | 12 ++++++++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

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