Message ID | 20241122063616.2251-1-caobin_njupt@163.com |
---|---|
State | Changes Requested |
Delegated to: | Kevin Traynor |
Headers | show |
Series | [ovs-dev] vlan packet problem: | expand |
Hello, On Sat, Nov 23, 2024 at 8:37 PM caobinnjupt <caobin_njupt@163.com> wrote: > > Description: > > if packet contain vlan flag we will push vlan length in the mbuf of dp_packet; > if packet pop vlan flag we will pop vlan legth in the mbufof dp_packet; > > Author: caobinnjupt <caobin_njupt@163.com> > Signed-off-by: caobinnjupt <caobin_njupt@163.com> Could you please describe the setup and the issue you hit? > --- > lib/dp-packet.h | 24 ++++++++++++++++++++++++ > lib/packets.c | 4 ++++ > 2 files changed, 28 insertions(+) > > diff --git a/lib/dp-packet.h b/lib/dp-packet.h > index 4afbbe722..184bfb920 100644 > --- a/lib/dp-packet.h > +++ b/lib/dp-packet.h > @@ -1064,6 +1064,30 @@ dp_packet_reset_offload(struct dp_packet *p) > *dp_packet_ol_flags_ptr(p) &= ~DP_PACKET_OL_SUPPORTED_MASK; > } > > +#ifdef DPDK_NETDEV > +static inline void > +dp_packet_push_vlan_update_offload(struct dp_packet *p) > +{ > + if (p->mbuf.ol_flags & PKT_TX_L4_MASK && p->mbuf.l2_len == ETH_HEADER_LEN) { > + p->mbuf.l2_len += VLAN_HEADER_LEN; > + } > +} The mbuf l2_len is supposed to be filled by OVS before calling DPDK drivers (see netdev_dpdk_prep_hwol_packet()). Are you perhaps hitting an issue with vhost-user ports?
diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 4afbbe722..184bfb920 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -1064,6 +1064,30 @@ dp_packet_reset_offload(struct dp_packet *p) *dp_packet_ol_flags_ptr(p) &= ~DP_PACKET_OL_SUPPORTED_MASK; } +#ifdef DPDK_NETDEV +static inline void +dp_packet_push_vlan_update_offload(struct dp_packet *p) +{ + if (p->mbuf.ol_flags & PKT_TX_L4_MASK && p->mbuf.l2_len == ETH_HEADER_LEN) { + p->mbuf.l2_len += VLAN_HEADER_LEN; + } +} +#else +#define dp_packet_push_vlan_update_offload(arg) +#endif + +#ifdef DPDK_NETDEV +static inline void +dp_packet_pop_vlan_update_offload(struct dp_packet *p) +{ + if (p->mbuf.ol_flags & PKT_TX_L4_MASK && p->mbuf.l2_len == VLAN_ETH_HEADER_LEN) { + p->mbuf.l2_len -= VLAN_HEADER_LEN; + } +} +#else +#define dp_packet_pop_vlan_update_offload(arg) +#endif + static inline bool dp_packet_has_flow_mark(const struct dp_packet *p, uint32_t *mark) { diff --git a/lib/packets.c b/lib/packets.c index 91c28daf0..d475b55fd 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -242,6 +242,8 @@ eth_push_vlan(struct dp_packet *packet, ovs_be16 tpid, ovs_be16 tci) memmove(veh, (char *)veh + VLAN_HEADER_LEN, 2 * ETH_ADDR_LEN); veh->veth_type = tpid; veh->veth_tci = tci & htons(~VLAN_CFI); + /* update mbuf offload info */ + dp_packet_push_vlan_update_offload(packet); } /* Removes outermost VLAN header (if any is present) from 'packet'. @@ -258,6 +260,8 @@ eth_pop_vlan(struct dp_packet *packet) memmove((char *)veh + VLAN_HEADER_LEN, veh, 2 * ETH_ADDR_LEN); dp_packet_resize_l2(packet, -VLAN_HEADER_LEN); + /* update mbuf offload info */ + dp_packet_pop_vlan_update_offload(packet); } }
Description: if packet contain vlan flag we will push vlan length in the mbuf of dp_packet; if packet pop vlan flag we will pop vlan legth in the mbufof dp_packet; Author: caobinnjupt <caobin_njupt@163.com> Signed-off-by: caobinnjupt <caobin_njupt@163.com> --- lib/dp-packet.h | 24 ++++++++++++++++++++++++ lib/packets.c | 4 ++++ 2 files changed, 28 insertions(+)