summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/std-formats.c49
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;
}