-----邮件原件----- 发件人: David Marchand <david.march...@redhat.com> 发送时间: 2023年9月27日 23:43 收件人: Dexia Li <dexia...@jaguarmicro.com> 抄送: ovs-dev@openvswitch.org; i.maxim...@ovn.org; Qingmin Liu <qingmin....@jaguarmicro.com>; Joey Xing <joey.x...@jaguarmicro.com>; Mike Pattrick <m...@redhat.com> 主题: Re: [PATCH v3] netdev-dpdk: Add vxlan and geneve tunnel tso.
On Wed, Sep 27, 2023 at 11:29 AM Dexia Li <dexia...@jaguarmicro.com> wrote: > > > static inline uint32_t * > > > dp_packet_ol_flags_ptr(const struct dp_packet *b) { @@ -615,9 > > > +673,10 @@ dp_packet_set_size(struct dp_packet *b, uint32_t v) > > > * (and thus 'v') will always be <= UINT16_MAX; this means that > > > there is no > > > * loss of accuracy in assigning 'v' to 'data_len'. > > > */ > > > - b->mbuf.data_len = (uint16_t)v; /* Current seg length. */ > > > - b->mbuf.pkt_len = v; /* Total length of all segments > > > linked to > > > - * this segment. */ > > > + /* Current seg length. */ > > > + b->mbuf.data_len += (uint16_t)(v - b->mbuf.pkt_len); > > > > What is this change for? > > For multi-seg packets, pkt_len and data_len of the first seg are resized > because tunnel encap. OVS userspace (datapath) code does not support multi segments packets. Besides, the default headroom of a dp-packet is enough for most tunnel headers. "Non DPDK" dp-packet can be adjusted dynamically with dp_packet_resize(), only DPDK dp-packet has some limitation (for which I have a pending patch). > The 128 Bytes headroom are reserved between buff_addr and data_off of > mbuf. Then data_off move forward for the len of tunnel encap. So the first > seg of the multi-seg packet should resize for data_len. > At this time, the data_len of the first seg is > 2048(RTE_MBUF_DEFAULT_DATAROOM) plus tunnel encap len. > Before the resize, the data_len of the first seg is 2048. The dataroom is > full of the first seg. > > It will result in tunnel packets tso error if the data_len of the > first seg equals pkt_len. In my test, This will result in the last packet of > seg packets can not appear. I am not following. There is no first segment to consider because there is only one segment/buffer in OVS dp-packets. When encapsulating, OVS checks if current headroom is enough. If not, it allocates a bigger buffer and copies data into it. In vxlan tunnel case, netdev_push_header - netdev_tnl_push_udp_header - netdev_tnl_push_ip_header - dp_packet_push_uninit - dp_packet_prealloc_headroom(b, size); - dp_packet_resize(b, MAX(size, 64), dp_packet_tailroom(b)); - https://github.com/openvswitch/ovs/blob/master/lib/dp-packet.c#L253 - dp_packet_set_data(b, (char*)dp_packet_data(b) - size); - dp_packet_set_size(b, dp_packet_size(b) + size); For DPDK-source dp-packets, as long as the headroom is big enough, the current code should handle this situation fine. If the headroom is not big enough, well, you may have a look at below link, but that required at least 3 levels of encapsulations iirc. https://patchwork.ozlabs.org/project/openvswitch/patch/20220318153339.31083-1-david.march...@redhat.com/ Did I miss something? No, I did not make it clear. we can look at the graph in the attachment When using dpdk dp packet, dp_packet_set_size will set wrong data_len of first seg of rte mbuf. It will result in tso error. -- David Marchand _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev