@@ -545,6 +545,7 @@ static int ice_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
u16 *vlan_tci)
{
const struct ice_xdp_buff *xdp_ext = (void *)ctx;
+ struct xdp_buff *xdp = (void *)&(xdp_ext->xdp_buff);
*vlan_proto = xdp_ext->pkt_ctx->vlan_proto;
if (!*vlan_proto)
@@ -554,6 +555,8 @@ static int ice_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
if (!*vlan_tci)
return -ENODATA;
+ xdp_set_rx_meta_vlan(xdp, *vlan_proto, *vlan_tci);
+
return 0;
}
@@ -262,6 +262,7 @@ static int mlx5e_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
u16 *vlan_tci)
{
const struct mlx5e_xdp_buff *_ctx = (void *)ctx;
+ struct xdp_buff *xdp = (void *)&(_ctx->xdp);
const struct mlx5_cqe64 *cqe = _ctx->cqe;
if (!cqe_has_vlan(cqe))
@@ -269,6 +270,8 @@ static int mlx5e_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
*vlan_proto = htons(ETH_P_8021Q);
*vlan_tci = be16_to_cpu(cqe->vlan_info);
+ xdp_set_rx_meta_vlan(xdp, *vlan_proto, *vlan_tci);
+
return 0;
}
@@ -1642,6 +1642,7 @@ 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;
+ struct xdp_buff *xdp = (void *)&(_ctx->xdp);
const struct sk_buff *skb = _ctx->skb;
int err;
@@ -1653,6 +1654,8 @@ static int veth_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
return err;
*vlan_proto = skb->vlan_proto;
+ xdp_set_rx_meta_vlan(xdp, skb->vlan_proto, *vlan_tci);
+
return err;
}
@@ -219,6 +219,11 @@ static __always_inline bool xdp_frame_has_rx_meta_hash(struct xdp_frame *frame)
return !!(frame->flags & XDP_FLAGS_META_RX_HASH);
}
+static __always_inline bool xdp_frame_has_rx_meta_vlan(struct xdp_frame *frame)
+{
+ return !!(frame->flags & XDP_FLAGS_META_RX_VLAN);
+}
+
#define XDP_BULK_QUEUE_SIZE 16
struct xdp_frame_bulk {
int count;
@@ -518,6 +523,15 @@ xdp_set_rx_meta_hash(struct xdp_buff *xdp, u32 hash,
xdp->flags |= XDP_FLAGS_META_RX_HASH;
}
+static __always_inline void
+xdp_set_rx_meta_vlan(struct xdp_buff *xdp, __be16 vlan_proto,
+ u16 vlan_tci)
+{
+ xdp->rx_meta.vlan.proto = vlan_proto;
+ xdp->rx_meta.vlan.tci = vlan_tci;
+ xdp->flags |= XDP_FLAGS_META_RX_VLAN;
+}
+
#ifdef CONFIG_NET
u32 bpf_xdp_metadata_kfunc_id(int id);
bool bpf_dev_bound_kfunc_id(u32 btf_id);
@@ -652,6 +652,9 @@ struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf,
skb->protocol = eth_type_trans(skb, dev);
xdp_set_skb_rx_hash_from_meta(xdpf, skb);
+ if (xdp_frame_has_rx_meta_vlan(xdpf))
+ __vlan_hwaccel_put_tag(skb, xdpf->rx_meta.vlan.proto,
+ xdpf->rx_meta.vlan.tci);
/* Optional SKB info, currently missing:
* - HW checksum info (skb->ip_summed)
Set vlan_proto and vlan_tci in xdp_rx_meta struct of xdp_buff/xdp_frame according to the value reported by the hw. Update the xmo_rx_vlan_tag callback of xdp_metadata_ops for the following drivers: - ice - mlx5 - veth Set rx vlan_{prot, tci} reported by the hw converting the xdp_frame into a sk_buff. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> --- drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 3 +++ drivers/net/veth.c | 3 +++ include/net/xdp.h | 14 ++++++++++++++ net/core/xdp.c | 3 +++ 5 files changed, 26 insertions(+)