No change in behaviour. This is so the MTU to mbuf size
calculations can be done in netdev_dpdk or dpdk code.

Signed-off-by: Kevin Traynor <ktray...@redhat.com>
---
 lib/dpdk-stub.c   |  8 ++++++++
 lib/dpdk.c        | 17 +++++++++++++++++
 lib/dpdk.h        | 18 ++++++++++++++++++
 lib/netdev-dpdk.c | 32 +-------------------------------
 4 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/lib/dpdk-stub.c b/lib/dpdk-stub.c
index 3eee1f485..3513d5640 100644
--- a/lib/dpdk-stub.c
+++ b/lib/dpdk-stub.c
@@ -19,4 +19,6 @@
 #include "dpdk.h"
 
+#include <stdint.h>
+
 #include "smap.h"
 #include "ovs-thread.h"
@@ -93,2 +95,8 @@ dpdk_status(const struct ovsrec_open_vswitch *cfg)
     }
 }
+
+uint32_t
+dpdk_buf_size(int mtu)
+{
+    return 0;
+}
diff --git a/lib/dpdk.c b/lib/dpdk.c
index 6886fbd9d..e1836a168 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -25,4 +25,5 @@
 #include <rte_cpuflags.h>
 #include <rte_errno.h>
+#include <rte_ether.h>
 #include <rte_log.h>
 #include <rte_malloc.h>
@@ -636,2 +637,18 @@ dpdk_status(const struct ovsrec_open_vswitch *cfg)
     }
 }
+
+/* DPDK NIC drivers allocate RX buffers at a particular granularity, typically
+ * aligned at 1k or less. If a declared mbuf size is not a multiple of this
+ * value, insufficient buffers are allocated to accomodate the packet in its
+ * entirety. Furthermore, certain drivers need to ensure that there is also
+ * sufficient space in the Rx buffer to accommodate two VLAN tags (for QinQ
+ * frames). If the RX buffer is too small, then the driver enables scatter RX
+ * behaviour, which reduces performance. To prevent this, use a buffer size
+ * that is closest to 'mtu', but which satisfies the aforementioned criteria.
+ */
+uint32_t
+dpdk_buf_size(int mtu)
+{
+    return ROUND_UP(MTU_TO_MAX_FRAME_LEN(mtu), NETDEV_DPDK_MBUF_ALIGN)
+            + RTE_PKTMBUF_HEADROOM;
+}
diff --git a/lib/dpdk.h b/lib/dpdk.h
index 64ebca47d..8ec43f57c 100644
--- a/lib/dpdk.h
+++ b/lib/dpdk.h
@@ -19,4 +19,5 @@
 
 #include <stdbool.h>
+#include <stdint.h>
 
 #ifdef DPDK_NETDEV
@@ -33,4 +34,20 @@
 #endif /* DPDK_NETDEV */
 
+/*
+ * need to reserve tons of extra space in the mbufs so we can align the
+ * DMA addresses to 4KB.
+ * The minimum mbuf size is limited to avoid scatter behaviour and drop in
+ * performance for standard Ethernet MTU.
+ */
+#define ETHER_HDR_MAX_LEN           (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN \
+                                     + (2 * VLAN_HEADER_LEN))
+#define MTU_TO_FRAME_LEN(mtu)       ((mtu) + RTE_ETHER_HDR_LEN + \
+                                     RTE_ETHER_CRC_LEN)
+#define MTU_TO_MAX_FRAME_LEN(mtu)   ((mtu) + ETHER_HDR_MAX_LEN)
+#define FRAME_LEN_TO_MTU(frame_len) ((frame_len)                    \
+                                     - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN)
+#define NETDEV_DPDK_MBUF_ALIGN      1024
+#define NETDEV_DPDK_MAX_PKT_LEN     9728
+
 struct smap;
 struct ovsrec_open_vswitch;
@@ -46,4 +63,5 @@ bool dpdk_available(void);
 void print_dpdk_version(void);
 void dpdk_status(const struct ovsrec_open_vswitch *);
+uint32_t dpdk_buf_size(int mtu);
 
 #endif /* dpdk.h */
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e0a2dccf5..c9877addb 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -83,19 +83,5 @@ COVERAGE_DEFINE(vhost_notification);
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
-/*
- * need to reserve tons of extra space in the mbufs so we can align the
- * DMA addresses to 4KB.
- * The minimum mbuf size is limited to avoid scatter behaviour and drop in
- * performance for standard Ethernet MTU.
- */
-#define ETHER_HDR_MAX_LEN           (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN \
-                                     + (2 * VLAN_HEADER_LEN))
-#define MTU_TO_FRAME_LEN(mtu)       ((mtu) + RTE_ETHER_HDR_LEN + \
-                                     RTE_ETHER_CRC_LEN)
-#define MTU_TO_MAX_FRAME_LEN(mtu)   ((mtu) + ETHER_HDR_MAX_LEN)
-#define FRAME_LEN_TO_MTU(frame_len) ((frame_len)                    \
-                                     - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN)
-#define NETDEV_DPDK_MBUF_ALIGN      1024
-#define NETDEV_DPDK_MAX_PKT_LEN     9728
+
 
 /* Max and min number of packets in the mempool. OVS tries to allocate a
@@ -557,20 +543,4 @@ is_dpdk_class(const struct netdev_class *class)
 }
 
-/* DPDK NIC drivers allocate RX buffers at a particular granularity, typically
- * aligned at 1k or less. If a declared mbuf size is not a multiple of this
- * value, insufficient buffers are allocated to accomodate the packet in its
- * entirety. Furthermore, certain drivers need to ensure that there is also
- * sufficient space in the Rx buffer to accommodate two VLAN tags (for QinQ
- * frames). If the RX buffer is too small, then the driver enables scatter RX
- * behaviour, which reduces performance. To prevent this, use a buffer size
- * that is closest to 'mtu', but which satisfies the aforementioned criteria.
- */
-static uint32_t
-dpdk_buf_size(int mtu)
-{
-    return ROUND_UP(MTU_TO_MAX_FRAME_LEN(mtu), NETDEV_DPDK_MBUF_ALIGN)
-            + RTE_PKTMBUF_HEADROOM;
-}
-
 /* Allocates an area of 'sz' bytes from DPDK.  The memory is zero'ed.
  *
-- 
2.34.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to