diff options
author | Nathan Skrzypczak <nathan.skrzypczak@gmail.com> | 2020-11-23 16:25:21 +0100 |
---|---|---|
committer | Nathan Skrzypczak <nathan.skrzypczak@gmail.com> | 2020-11-24 15:56:08 +0100 |
commit | 61559029dacaac95b410fcb39e93134ee4858591 (patch) | |
tree | 04af1a895c008f9f9b2cce70faf80e2b4e1ae65d /src/vppinfra | |
parent | f06b3bdd9232e722c04062de58da5b45a115bc34 (diff) |
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 <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/std-formats.c | 49 |
1 files changed, 18 insertions, 31 deletions
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; } |