Message ID | 1497850143-3116-4-git-send-email-qdy220091330@gmail.com |
---|---|
State | Deferred |
Headers | show |
>From: Michael Qiu [mailto:qdy220091330@gmail.com] >Sent: Monday, June 19, 2017 6:29 AM >To: dev@openvswitch.org >Cc: Kavanagh, Mark B <mark.b.kavanagh@intel.com>; blp@ovn.org; dball@vmware.com; Michael Qiu ><qiudayu@chinac.com>; Ksiadz, MarcinX <marcinx.ksiadz@intel.com>; Lal, PrzemyslawX ><przemyslawx.lal@intel.com>; Yuanhan Liu <yuanhan.liu@linux.intel.com> >Subject: [PATCH 3/5] lib/dp-packet: Fix data_len issue with multi-segments > >From: Michael Qiu <qiudayu@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. > >Co-authored-by: Mark Kavanagh <mark.b.kavanagh@intel.com> >Co-authored-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> >Co-authored-by: Przemyslaw Lal <przemyslawx.lal@intel.com> Missing co-authors here (each 'Signed-off-by' tag requires a corresponding 'Co-authored-by' tag ). > >Signed-off-by: Michael Qiu <qiudayu@chinac.com> >Signed-off-by: Marcin Ksiadz <marcinx.ksiadz@intel.com> >Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com> >Signed-off-by: Przemyslaw Lal <przemyslawx.lal@intel.com> >Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> >--- > lib/dp-packet.h | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > >diff --git a/lib/dp-packet.h b/lib/dp-packet.h >index d2549b1..fc0b0b4 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" >@@ -425,17 +426,14 @@ 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. */ >+ b->mbuf.data_len = MIN(v, b->mbuf.buf_len - b->mbuf.data_off); >+ >+ /* Total length of all segments linked to this segment. */ >+ b->mbuf.pkt_len = v; > } > > static inline uint16_t >-- >1.8.3.1
在 2017/6/26 23:08, Kavanagh, Mark B 写道: >> From: Michael Qiu [mailto:qdy220091330@gmail.com] >> Sent: Monday, June 19, 2017 6:29 AM >> To: dev@openvswitch.org >> Cc: Kavanagh, Mark B <mark.b.kavanagh@intel.com>; blp@ovn.org; dball@vmware.com; Michael Qiu >> <qiudayu@chinac.com>; Ksiadz, MarcinX <marcinx.ksiadz@intel.com>; Lal, PrzemyslawX >> <przemyslawx.lal@intel.com>; Yuanhan Liu <yuanhan.liu@linux.intel.com> >> Subject: [PATCH 3/5] lib/dp-packet: Fix data_len issue with multi-segments >> >> From: Michael Qiu <qiudayu@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. >> >> Co-authored-by: Mark Kavanagh <mark.b.kavanagh@intel.com> >> Co-authored-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> >> Co-authored-by: Przemyslaw Lal <przemyslawx.lal@intel.com> > Missing co-authors here (each 'Signed-off-by' tag requires a corresponding 'Co-authored-by' tag ). OK, I just copy them from the original patch, I will add all tags. >> Signed-off-by: Michael Qiu <qiudayu@chinac.com> >> Signed-off-by: Marcin Ksiadz <marcinx.ksiadz@intel.com> >> Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com> >> Signed-off-by: Przemyslaw Lal <przemyslawx.lal@intel.com> >> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> >> --- >> lib/dp-packet.h | 18 ++++++++---------- >> 1 file changed, 8 insertions(+), 10 deletions(-) >> >> diff --git a/lib/dp-packet.h b/lib/dp-packet.h >> index d2549b1..fc0b0b4 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" >> @@ -425,17 +426,14 @@ 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. */ >> + b->mbuf.data_len = MIN(v, b->mbuf.buf_len - b->mbuf.data_off); >> + >> + /* Total length of all segments linked to this segment. */ >> + b->mbuf.pkt_len = v; >> } >> >> static inline uint16_t >> -- >> 1.8.3.1 >
diff --git a/lib/dp-packet.h b/lib/dp-packet.h index d2549b1..fc0b0b4 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" @@ -425,17 +426,14 @@ 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. */ + b->mbuf.data_len = MIN(v, b->mbuf.buf_len - b->mbuf.data_off); + + /* Total length of all segments linked to this segment. */ + b->mbuf.pkt_len = v; } static inline uint16_t