diff options
author | Larysa Zaremba <larysa.zaremba@intel.com> | 2023-12-05 22:08:41 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-12-13 16:16:41 -0800 |
commit | fca783799f64ac0a4f20228ff6a6d7598db11e64 (patch) | |
tree | 22fb9f6aeb6601ff0869eedee019beedfb2a0335 /drivers/net/veth.c | |
parent | b591137c4ec35ed3f8478f5bb69a22ef4834f04a (diff) |
veth: Implement VLAN tag XDP hint
In order to test VLAN tag hint in hardware-independent selftests, implement
newly added hint in veth driver.
Acked-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
Link: https://lore.kernel.org/r/20231205210847.28460-13-larysa.zaremba@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'drivers/net/veth.c')
-rw-r--r-- | drivers/net/veth.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 57efb3454c57..1efdbe4b92f5 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1722,6 +1722,24 @@ static int veth_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash, return 0; } +static int veth_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto, + u16 *vlan_tci) +{ + const struct veth_xdp_buff *_ctx = (void *)ctx; + const struct sk_buff *skb = _ctx->skb; + int err; + + if (!skb) + return -ENODATA; + + err = __vlan_hwaccel_get_tag(skb, vlan_tci); + if (err) + return err; + + *vlan_proto = skb->vlan_proto; + return err; +} + static const struct net_device_ops veth_netdev_ops = { .ndo_init = veth_dev_init, .ndo_open = veth_open, @@ -1746,6 +1764,7 @@ static const struct net_device_ops veth_netdev_ops = { static const struct xdp_metadata_ops veth_xdp_metadata_ops = { .xmo_rx_timestamp = veth_xdp_rx_timestamp, .xmo_rx_hash = veth_xdp_rx_hash, + .xmo_rx_vlan_tag = veth_xdp_rx_vlan_tag, }; #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \ |