From 61559029dacaac95b410fcb39e93134ee4858591 Mon Sep 17 00:00:00 2001 From: Nathan Skrzypczak Date: Mon, 23 Nov 2020 16:25:21 +0100 Subject: buffers: add page-size config Type: feature Add a `buffers {page-size}` parameter to specify page size for buffers. This also fixes an issue with the parsing in unformat_log2_page_size. Change-Id: I7d7b1fa0bb7febaa7509cf2c625882f07eeafaad Signed-off-by: Nathan Skrzypczak --- src/vppinfra/std-formats.c | 49 +++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'src/vppinfra') diff --git a/src/vppinfra/std-formats.c b/src/vppinfra/std-formats.c index 1667c93fd88..1616001f9c5 100644 --- a/src/vppinfra/std-formats.c +++ b/src/vppinfra/std-formats.c @@ -299,40 +299,27 @@ format_log2_page_size (u8 * s, va_list * va) __clib_export uword unformat_log2_page_size (unformat_input_t * input, va_list * va) { - uword amount, shift, c; + uword amount; clib_mem_page_sz_t *result = va_arg (*va, clib_mem_page_sz_t *); - if (unformat (input, "default")) - return CLIB_MEM_PAGE_SZ_DEFAULT; - if (unformat (input, "default-hugepage")) - return CLIB_MEM_PAGE_SZ_DEFAULT_HUGE; - - if (!unformat (input, "%wd%_", &amount)) - return CLIB_MEM_PAGE_SZ_UNKNOWN; - - c = unformat_get_input (input); - switch (c) - { - case 'k': - case 'K': - shift = 10; - break; - case 'm': - case 'M': - shift = 20; - break; - case 'g': - case 'G': - shift = 30; - break; - default: - shift = 0; - unformat_put_input (input); - break; - } - - *result = min_log2 (amount) + shift; + *result = CLIB_MEM_PAGE_SZ_DEFAULT_HUGE; + else if (unformat (input, "default")) + *result = CLIB_MEM_PAGE_SZ_DEFAULT; + else if (unformat (input, "%wdk", &amount)) + *result = min_log2 (amount) + 10; + else if (unformat (input, "%wdK", &amount)) + *result = min_log2 (amount) + 10; + else if (unformat (input, "%wdm", &amount)) + *result = min_log2 (amount) + 20; + else if (unformat (input, "%wdM", &amount)) + *result = min_log2 (amount) + 20; + else if (unformat (input, "%wdg", &amount)) + *result = min_log2 (amount) + 30; + else if (unformat (input, "%wdG", &amount)) + *result = min_log2 (amount) + 30; + else + return 0; return 1; } -- cgit 1.2.3-korg