[ovs-dev] [PATCH] dpif-netdev: reduce netdev_flow_key size

Daniele Di Proietto ddiproietto at vmware.com
Fri Sep 19 23:30:02 UTC 2014


Signed-off-by: Daniele Di Proietto <ddiproietto at vmware.com>
Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
This is based on a previous patch by Jarno
---
 lib/dpif-netdev.c |  9 +--------
 lib/flow.h        | 13 +++++++++++++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 90fe01c..20d2cd2 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -90,16 +90,9 @@ static struct vlog_rate_limit upcall_rl = VLOG_RATE_LIMIT_INIT(600, 600);
 
 /* Stores a miniflow with inline values */
 
-/* There are fields in the flow structure that we never use. Therefore we can
- * save a few words of memory */
-#define NETDEV_KEY_BUF_SIZE_U32 (FLOW_U32S                 \
-                                 - MINI_N_INLINE           \
-                                 - FLOW_U32_SIZE(regs)     \
-                                 - FLOW_U32_SIZE(metadata) \
-                                )
 struct netdev_flow_key {
     struct miniflow flow;
-    uint32_t buf[NETDEV_KEY_BUF_SIZE_U32];
+    uint32_t buf[FLOW_MAX_PACKET_U32S - MINI_N_INLINE];
 };
 
 /* Exact match cache for frequently used flows
diff --git a/lib/flow.h b/lib/flow.h
index 2764916..b4f417c 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -138,6 +138,19 @@ BUILD_ASSERT_DECL(sizeof(struct flow) % 4 == 0);
 
 #define FLOW_U32S (sizeof(struct flow) / 4)
 
+/* Some flow fields are mutually exclusive or only appear within the flow
+ * pipeline.  IPv6 headers are bigger than IPv4 and MPLS, and IPv6 ND packets
+ * are bigger than TCP,UDP and IGMP packets. */
+#define FLOW_MAX_PACKET_U32S (FLOW_U32S                                   \
+    /* Unused in datapath */  - FLOW_U32_SIZE(regs)                       \
+                              - FLOW_U32_SIZE(metadata)                   \
+    /* L2.5/3 */              - FLOW_U32_SIZE(nw_src)                     \
+                              - FLOW_U32_SIZE(nw_dst)                     \
+                              - FLOW_U32_SIZE(mpls_lse)                   \
+    /* L4 */                  - FLOW_U32_SIZE(tcp_flags) /* incl. pad. */ \
+                              - FLOW_U32_SIZE(igmp_group_ip4)             \
+                             )
+
 /* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */
 BUILD_ASSERT_DECL(offsetof(struct flow, dp_hash) + sizeof(uint32_t)
                   == sizeof(struct flow_tnl) + 176
-- 
2.1.0.rc1




More information about the dev mailing list