在 2017年5月3日,下午11:33,Kavanagh, Mark B <mark.b.kavan...@intel.com> 写道:
>> From: Michael Qiu <qiud...@chinac.com> >> >> When a packet is from DPDK source, and it contains >> multiple segments, data_len is not equal to the >> packet size. This patch fix this issue. >> >> Signed-off-by: Michael Qiu <qiud...@chinac.com> >> Signed-off-by: Marcin Ksiadz <marcinx.ksi...@intel.com> >> Signed-off-by: Mark Kavanagh <mark.b.kavan...@intel.com> >> Signed-off-by: Przemyslaw Lal <przemyslawx....@intel.com> >> Signed-off-by: Yuanhan Liu <yuanhan....@linux.intel.com> >> --- >> lib/dp-packet.h | 23 +++++++++++++---------- >> 1 file changed, 13 insertions(+), 10 deletions(-) >> >> diff --git a/lib/dp-packet.h b/lib/dp-packet.h >> index c73ca19..337a600 100644 >> --- a/lib/dp-packet.h >> +++ b/lib/dp-packet.h >> @@ -23,6 +23,7 @@ >> #ifdef DPDK_NETDEV >> #include <rte_config.h> >> #include <rte_mbuf.h> >> +#include "rte_ether.h" >> #endif >> >> #include "netdev-dpdk.h" >> @@ -415,17 +416,19 @@ dp_packet_size(const struct dp_packet *b) >> static inline void >> dp_packet_set_size(struct dp_packet *b, uint32_t v) >> { >> - /* netdev-dpdk does not currently support segmentation; consequently, >> for >> - * all intents and purposes, 'data_len' (16 bit) and 'pkt_len' (32 bit) >> may >> - * be used interchangably. >> - * >> - * On the datapath, it is expected that the size of packets >> - * (and thus 'v') will always be <= UINT16_MAX; this means that there >> is no >> - * loss of accuracy in assigning 'v' to 'data_len'. >> + /* >> + * Assign current segment length. If total length is greater than >> + * max data length in a segment, additional calculation is needed >> */ >> - b->mbuf.data_len = (uint16_t)v; /* Current seg length. */ >> - b->mbuf.pkt_len = v; /* Total length of all segments linked >> to >> - * this segment. */ >> + if (v > (b->mbuf.buf_len - b->mbuf.data_off)) { > > You could insert '(OVS_UNLIKELY' after the 'if' What I consider is that after enable hw offloading, multiple segments should be unlikely? But anyway, before enable it, unlikely could be right thing. > >> + b->mbuf.data_len = >> + (uint16_t) (b->mbuf.buf_len - b->mbuf.data_off); >> + } else { >> + b->mbuf.data_len = (uint16_t) v; >> + } >> + >> + /* Total length of all segments linked to this segment. */ >> + b->mbuf.pkt_len = v; >> } >> >> static inline uint16_t >> -- >> 1.8.3.1 > > _______________________________________________ > dev mailing list > d...@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev