DPDK v1.8.0-rc4 makes significant changes to struct rte_mbuf, including
removal of the 'pkt' and 'data' fields. These fields are referenced
by OVS when accessing the data section of an ofpbuf.

Update any relevant functions to accomodate the new rte_mbuf layout.

Signed-off-by: Mark Kavanagh <mark.b.kavan...@intel.com>
Signed-off-by: Rory Sexton <rory.sex...@intel.com>

Reviewed-by: Ciara Loftus <ciara.lof...@intel.com>
Reviewed-by: Stephen Finucane <stephen.finuc...@intel.com>
Signed-off-by: Mark Kavanagh <mark.b.kavan...@intel.com>
---
 lib/netdev-dpdk.c | 13 ++++++++-----
 lib/ofpbuf.h      | 23 +++++++++++++++++------
 lib/packet-dpif.h |  4 ++--
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 9c42756..c3733b1 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -28,6 +28,9 @@
 #include <unistd.h>
 #include <stdio.h>
 
+#include <rte_config.h>
+#include <rte_mbuf.h>
+
 #include "dpif-netdev.h"
 #include "list.h"
 #include "netdev-dpdk.h"
@@ -265,13 +268,12 @@ __rte_pktmbuf_init(struct rte_mempool *mp,
     m->buf_len = (uint16_t)buf_len;
 
     /* keep some headroom between start of buffer and data */
-    m->pkt.data = (char*) m->buf_addr + RTE_MIN(RTE_PKTMBUF_HEADROOM, 
m->buf_len);
+    m->data_off = RTE_MIN(RTE_PKTMBUF_HEADROOM, m->buf_len);
 
     /* init some constant fields */
-    m->type = RTE_MBUF_PKT;
     m->pool = mp;
-    m->pkt.nb_segs = 1;
-    m->pkt.in_port = 0xff;
+    m->nb_segs = 1;
+    m->port = 0xff;
 }
 
 static void
@@ -825,7 +827,8 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct 
dpif_packet ** pkts,
         }
 
         /* We have to do a copy for now */
-        memcpy(mbufs[newcnt]->pkt.data, ofpbuf_data(&pkts[i]->ofpbuf), size);
+        memcpy(rte_pktmbuf_mtod(mbufs[newcnt], char *),
+               ofpbuf_data(&pkts[i]->ofpbuf), size);
 
         rte_pktmbuf_data_len(mbufs[newcnt]) = size;
         rte_pktmbuf_pkt_len(mbufs[newcnt]) = size;
diff --git a/lib/ofpbuf.h b/lib/ofpbuf.h
index ea03c9d..820c242 100644
--- a/lib/ofpbuf.h
+++ b/lib/ofpbuf.h
@@ -19,6 +19,11 @@
 
 #include <stddef.h>
 #include <stdint.h>
+
+#ifdef DPDK_NETDEV
+#include <rte_common.h>
+#endif
+
 #include "list.h"
 #include "packets.h"
 #include "util.h"
@@ -379,12 +384,18 @@ BUILD_ASSERT_DECL(offsetof(struct ofpbuf, mbuf) == 0);
 
 static inline void * ofpbuf_data(const struct ofpbuf *b)
 {
-    return b->mbuf.pkt.data;
+    return rte_pktmbuf_mtod(&(b->mbuf), void *);
 }
 
 static inline void ofpbuf_set_data(struct ofpbuf *b, void *d)
 {
-    b->mbuf.pkt.data = d;
+    if (d == NULL) {
+        /* NULL 'd' value is valid */
+        b->mbuf.data_off = 0;
+    } else {
+        /* Work out the offset between the start of segment buffer and 'd' */
+        b->mbuf.data_off = RTE_PTR_DIFF(d, b->mbuf.buf_addr);
+    }
 }
 
 static inline void * ofpbuf_base(const struct ofpbuf *b)
@@ -399,14 +410,14 @@ static inline void ofpbuf_set_base(struct ofpbuf *b, void 
*d)
 
 static inline uint32_t ofpbuf_size(const struct ofpbuf *b)
 {
-    return b->mbuf.pkt.pkt_len;
+    return b->mbuf.pkt_len;
 }
 
 static inline void ofpbuf_set_size(struct ofpbuf *b, uint32_t v)
 {
-    b->mbuf.pkt.data_len = v;    /* Current seg length. */
-    b->mbuf.pkt.pkt_len = v;     /* Total length of all segments linked to
-                                  * this segment. */
+    b->mbuf.data_len = v;    /* Current seg length. */
+    b->mbuf.pkt_len = v;     /* Total length of all segments linked to
+                              * this segment. */
 }
 
 #else
diff --git a/lib/packet-dpif.h b/lib/packet-dpif.h
index 1a5efb6..692a81a 100644
--- a/lib/packet-dpif.h
+++ b/lib/packet-dpif.h
@@ -50,7 +50,7 @@ static inline void dpif_packet_delete(struct dpif_packet *p)
 static inline uint32_t dpif_packet_get_dp_hash(struct dpif_packet *p)
 {
 #ifdef DPDK_NETDEV
-    return p->ofpbuf.mbuf.pkt.hash.rss;
+    return p->ofpbuf.mbuf.hash.rss;
 #else
     return p->dp_hash;
 #endif
@@ -60,7 +60,7 @@ static inline void dpif_packet_set_dp_hash(struct dpif_packet 
*p,
                                            uint32_t hash)
 {
 #ifdef DPDK_NETDEV
-    p->ofpbuf.mbuf.pkt.hash.rss = hash;
+    p->ofpbuf.mbuf.hash.rss = hash;
 #else
     p->dp_hash = hash;
 #endif
-- 
1.9.3

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to