From 9059454f1725397c08661590bcaf31aba09befa5 Mon Sep 17 00:00:00 2001 From: Divakar Date: Fri, 22 Apr 2016 09:30:50 +0530 Subject: [PATCH] Incasing the overflow table size of Flow and Bridge tables Currently the overflow table sizes of flow and bridge are kept at 8k and 4k respectively as constant, irrespective of the main flow table size. Now this is changed to 20% of the main table. If user specifies over flow entries as module parameter, the value is untouched and left as is. If user specifies only the main table entries, then over flow table entries are again calculated as 20% of main table. While doing the calculation, it is adjusted to upper bound 1k. Change-Id: I45bb463013f850824af050ef9fb6d86118569f52 closes-bug: #1573381 --- dp-core/vr_bridge.c | 5 ++++- dp-core/vr_flow.c | 9 ++++++++- dp-core/vr_htable.c | 7 ++----- dpdk/dpdk_vrouter.c | 7 +++++-- include/vr_bridge.h | 1 - include/vr_flow.h | 4 +--- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dp-core/vr_bridge.c b/dp-core/vr_bridge.c index ead59cb6a..9067baa63 100644 --- a/dp-core/vr_bridge.c +++ b/dp-core/vr_bridge.c @@ -39,7 +39,7 @@ struct vr_bridge_entry { } __attribute__((packed)); unsigned int vr_bridge_entries = VR_DEF_BRIDGE_ENTRIES; -unsigned int vr_bridge_oentries = VR_DEF_BRIDGE_OENTRIES; +unsigned int vr_bridge_oentries = 0; static vr_htable_t vn_rtable; char vr_bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -412,6 +412,9 @@ bridge_table_init(struct vr_rtable *rtable, struct rtable_fspec *fs) if (rtable->algo_data) return 0; + if (!vr_bridge_oentries) + vr_bridge_oentries = ((vr_bridge_entries / 5) + 1023) & ~1023; + rtable->algo_data = vr_htable_create(vrouter_get(0), vr_bridge_entries, vr_bridge_oentries, sizeof(struct vr_bridge_entry), sizeof(struct vr_bridge_entry_key), 0, bridge_entry_key); diff --git a/dp-core/vr_flow.c b/dp-core/vr_flow.c index c3685b114..9e85b5c90 100644 --- a/dp-core/vr_flow.c +++ b/dp-core/vr_flow.c @@ -26,7 +26,7 @@ #define VR_DEF_MAX_FLOW_TABLE_HOLD_COUNT 4096 unsigned int vr_flow_entries = VR_DEF_FLOW_ENTRIES; -unsigned int vr_oflow_entries = VR_DEF_OFLOW_ENTRIES; +unsigned int vr_oflow_entries = 0; /* * host can provide its own memory . Point in case is the DPDK. In DPDK, @@ -2213,6 +2213,13 @@ vr_flow_table_init(struct vrouter *router) { if (!router->vr_flow_table) { + /* + * Overflow entries is 20% of the main flow table + * adjusted to next 1k + */ + if (!vr_oflow_entries) + vr_oflow_entries = ((vr_flow_entries / 5) + 1023) & ~1023; + router->vr_flow_table = vr_htable_attach(router, vr_flow_entries, vr_flow_table, vr_oflow_entries, vr_oflow_table, sizeof(struct vr_flow_entry), 0, 0, vr_flow_get_key); diff --git a/dp-core/vr_htable.c b/dp-core/vr_htable.c index 6ef1ed176..8211daec3 100644 --- a/dp-core/vr_htable.c +++ b/dp-core/vr_htable.c @@ -650,15 +650,12 @@ __vr_htable_create(struct vrouter *router, unsigned int entries, if (!entry_size || !entries || !get_entry_key) return NULL; - /* Ceil to near upper number, which is dividable by VR_HENTRIES_PER_BUCKET. */ - entries = ((entries + VR_HENTRIES_PER_BUCKET -1) / VR_HENTRIES_PER_BUCKET) - * VR_HENTRIES_PER_BUCKET; if (!bucket_size) bucket_size = VR_HENTRIES_PER_BUCKET; - if (entries % bucket_size) - entries = (entries + bucket_size) & ~bucket_size; + /* Ceil to near upper number, which is dividable by bucket_size */ + entries = ((entries + bucket_size -1) / bucket_size) * bucket_size; table = vr_zalloc(sizeof(struct vr_htable), VR_HTABLE_OBJECT); if (!table) { diff --git a/dpdk/dpdk_vrouter.c b/dpdk/dpdk_vrouter.c index 0bbaeb5d5..5caa4fb32 100644 --- a/dpdk/dpdk_vrouter.c +++ b/dpdk/dpdk_vrouter.c @@ -955,7 +955,7 @@ parse_long_opts(int opt_flow_index, char *optarg) case BRIDGE_OENTRIES_OPT_INDEX: vr_bridge_oentries = (unsigned int)strtoul(optarg, NULL, 0); if (errno != 0) { - vr_bridge_oentries = VR_DEF_BRIDGE_OENTRIES; + vr_bridge_oentries = ((vr_bridge_entries / 5) + 1023) & ~1023; } break; @@ -969,7 +969,10 @@ parse_long_opts(int opt_flow_index, char *optarg) case OFLOW_ENTRIES_OPT_INDEX: vr_oflow_entries = (unsigned int)strtoul(optarg, NULL, 0); if (errno != 0) { - vr_oflow_entries = VR_DEF_OFLOW_ENTRIES; + /* vr_flow_entries would be either VR_DEF_FLOW_ENTRIES or + * user value + */ + vr_oflow_entries = ((vr_flow_entries / 5) + 1023) & ~1023; } break; diff --git a/include/vr_bridge.h b/include/vr_bridge.h index 54f0983b3..99a9b7f3f 100644 --- a/include/vr_bridge.h +++ b/include/vr_bridge.h @@ -8,7 +8,6 @@ #include "vrouter.h" #define VR_DEF_BRIDGE_ENTRIES (256 * 1024) -#define VR_DEF_BRIDGE_OENTRIES (4 * 1024) #define VR_MAC_COPY(dst, src) { \ ((uint16_t *)(dst))[0] = ((uint16_t *)(src))[0]; \ diff --git a/include/vr_flow.h b/include/vr_flow.h index 391113567..4887c666c 100644 --- a/include/vr_flow.h +++ b/include/vr_flow.h @@ -360,9 +360,7 @@ struct vr_flow_entry { #define VR_DNS_SERVER_PORT htons(53) -#define VR_DEF_FLOW_ENTRIES (512 * 1024) - -#define VR_DEF_OFLOW_ENTRIES (8 * 1024) +#define VR_DEF_FLOW_ENTRIES (512 * 1024) extern unsigned int vr_flow_entries, vr_oflow_entries;