[ovs-dev] [PATCH 4/5] lib/dp-packet: copy multi-segments data from DPDK mbuf

Kavanagh, Mark B mark.b.kavanagh at intel.com
Wed Jul 5 14:28:53 UTC 2017


>From: Michael Qiu [mailto:qdy220091330 at gmail.com]
>Sent: Monday, June 19, 2017 6:29 AM
>To: dev at openvswitch.org
>Cc: Kavanagh, Mark B <mark.b.kavanagh at intel.com>; blp at ovn.org;
>dball at vmware.com; Michael Qiu <qiudayu at chinac.com>
>Subject: [PATCH 4/5] lib/dp-packet: copy multi-segments data from DPDK mbuf
>
>From: Michael Qiu <qiudayu at chinac.com>
>
>When doing packet clone, if packet source is from DPDK driver,
>multi-segment must be considered, and copy the segment's
>data one by one.
>
>Signed-off-by: Michael Qiu <qiudayu at chinac.com>

Hi Michael,

Apologies for the delay in reviewing the remainder of your patchset.

One minor comment below.

Thanks,
Mark


>---
> lib/dp-packet.c | 27 ++++++++++++++++++++++++---
> 1 file changed, 24 insertions(+), 3 deletions(-)
>
>diff --git a/lib/dp-packet.c b/lib/dp-packet.c
>index 9f872a1..278706e 100644
>--- a/lib/dp-packet.c
>+++ b/lib/dp-packet.c
>@@ -167,9 +167,30 @@ dp_packet_clone_with_headroom(const struct dp_packet
>*buffer, size_t headroom)
> {
>     struct dp_packet *new_buffer;
>
>-    new_buffer = dp_packet_clone_data_with_headroom(dp_packet_data(buffer),
>-                                                 dp_packet_size(buffer),
>-                                                 headroom);
>+    uint32_t size = dp_packet_size(buffer);
>+
>+    /* copy multi-seg data */
>+#ifdef DPDK_NETDEV
>+    if (buffer->source == DPBUF_DPDK && buffer->mbuf.nb_segs > 1) {
>+        uint32_t off_set = 0;

<micro-nit>
	This is spelled as 'offset' throughout the rest of the file - may as well remain consistent...
</micro-nit>


>+        void *dst = NULL;
>+        struct rte_mbuf *tmbuf = CONST_CAST(struct rte_mbuf *, &(buffer-
>>mbuf));
>+
>+        new_buffer = dp_packet_new_with_headroom(size, headroom);
>+        dst = dp_packet_put_uninit(new_buffer, size);
>+
>+        while (tmbuf) {
>+            rte_memcpy((char *)dst + off_set,
>+                       rte_pktmbuf_mtod(tmbuf, void *), tmbuf->data_len);
>+            off_set += tmbuf->data_len;
>+            tmbuf = tmbuf->next;
>+        }
>+    }
>+    else
>+#endif
>+        new_buffer =
>dp_packet_clone_data_with_headroom(dp_packet_data(buffer),
>+                                                        size, headroom);
>+
>     new_buffer->l2_pad_size = buffer->l2_pad_size;
>     new_buffer->l2_5_ofs = buffer->l2_5_ofs;
>     new_buffer->l3_ofs = buffer->l3_ofs;
>--
>1.8.3.1



More information about the dev mailing list