From c4f8dc7a9c5c1802f6b185b2440f9245a719f73b Mon Sep 17 00:00:00 2001 From: Anand Kumar via dev Date: Wed, 20 Mar 2019 16:54:30 -0700 Subject: datapath-windows: Address memory allocation issues for OVS_BUFFER_CONTEXT With current implementation, when nbl pool is allocated, context size is specified as 64 bytes, while the OVS_BUFFER_CONTEXT size is only 32 bytes. Since context size is never changed, additional memory is not required. This patch makes it simpler to allocate memory for OVS_BUFFER_CONTEXT so that it is always aligned to MEMORY_ALLOCATION_ALIGNMENT. This is acheived by updating "value" field in the context structure, so that number of elements in array is always a multiple of MEMORY_ALLOCATION_ALIGNMENT. Also change the DEFAULT_CONTEXT_SIZE to accomodate OVS_BUFFER_CONTEXT size. Signed-off-by: Anand Kumar Acked-by: Alin Gabriel Serdean Signed-off-by: Alin Gabriel Serdean --- datapath-windows/ovsext/BufferMgmt.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'datapath-windows') diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h index dcf310a27..2a74988b8 100644 --- a/datapath-windows/ovsext/BufferMgmt.h +++ b/datapath-windows/ovsext/BufferMgmt.h @@ -20,11 +20,8 @@ #define MEM_ALIGN MEMORY_ALLOCATION_ALIGNMENT #define MEM_ALIGN_SIZE(_x) ((MEM_ALIGN - 1 + (_x))/MEM_ALIGN * MEM_ALIGN) #define OVS_CTX_MAGIC 0xabcd - -#define OVS_DEFAULT_NBL_CONTEXT_SIZE MEM_ALIGN_SIZE(64) -#define OVS_DEFAULT_NBL_CONTEXT_FILL \ - (OVS_DEFAULT_NBL_CONTEXT_SIZE - sizeof (OVS_BUFFER_CONTEXT)) - +#define OVS_DEFAULT_NBL_CONTEXT_SIZE sizeof(OVS_BUFFER_CONTEXT) +#define OVS_DEFAULT_NBL_CONTEXT_FILL 0 #define OVS_DEFAULT_DATA_SIZE 256 #define OVS_DEFAULT_HEADROOM_SIZE 128 #define OVS_FIX_NBL_DATA_SIZE (OVS_DEFAULT_DATA_SIZE + OVS_DEFAULT_HEADROOM_SIZE) @@ -49,7 +46,7 @@ enum { }; typedef union _OVS_BUFFER_CONTEXT { - struct { + struct dummy { UINT16 magic; UINT16 flags; UINT32 srcPortNo; @@ -61,7 +58,7 @@ typedef union _OVS_BUFFER_CONTEXT { UINT16 mru; }; - UINT64 value[MEM_ALIGN_SIZE(32) >> 3]; + CHAR value[MEM_ALIGN_SIZE(sizeof(struct dummy))]; } OVS_BUFFER_CONTEXT, *POVS_BUFFER_CONTEXT; typedef struct _OVS_NBL_POOL { -- cgit v1.2.1