@@ -3623,6 +3623,7 @@ enum ieee80211_reconfig_type {
* skb is always a real frame, head may or may not be an A-MSDU.
* @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
* Statistics should be cumulative, currently no way to reset is provided.
+ * @xdp: main XDP handler
*/
struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -3911,6 +3912,7 @@ struct ieee80211_ops {
int (*get_ftm_responder_stats)(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct cfg80211_ftm_responder_stats *ftm_stats);
+ int (*xdp)(struct ieee80211_hw *hw, struct netdev_bpf *xdp);
};
/**
@@ -1278,4 +1278,15 @@ static inline void drv_del_nan_func(struct ieee80211_local *local,
trace_drv_return_void(local);
}
+static inline int drv_xdp(struct ieee80211_local *local,
+ struct netdev_bpf *xdp)
+{
+ might_sleep();
+
+ if (!local->ops->xdp)
+ return -EOPNOTSUPP;
+
+ return local->ops->xdp(&local->hw, xdp);
+}
+
#endif /* __MAC80211_DRIVER_OPS */
@@ -1163,6 +1163,19 @@ ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
}
}
+static int ieee80211_xdp(struct net_device *dev, struct netdev_bpf *xdp)
+{
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+ switch (xdp->command) {
+ case XDP_QUERY_PROG:
+ case XDP_SETUP_PROG:
+ return drv_xdp(sdata->local, xdp);
+ default:
+ return -EINVAL;
+ }
+}
+
static const struct net_device_ops ieee80211_dataif_ops = {
.ndo_open = ieee80211_open,
.ndo_stop = ieee80211_stop,
@@ -1172,6 +1185,7 @@ static const struct net_device_ops ieee80211_dataif_ops = {
.ndo_set_mac_address = ieee80211_change_mac,
.ndo_select_queue = ieee80211_netdev_select_queue,
.ndo_get_stats64 = ieee80211_get_stats64,
+ .ndo_bpf = ieee80211_xdp,
};
static u16 ieee80211_monitor_select_queue(struct net_device *dev,
Initialize net_device_ops ndo_bpf callback with ieee80211_xdp routine in order to load a bpf program into low level driver XDP rx hook Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> --- include/net/mac80211.h | 2 ++ net/mac80211/driver-ops.h | 11 +++++++++++ net/mac80211/iface.c | 14 ++++++++++++++ 3 files changed, 27 insertions(+)