diff options
author | Yi He <yi.he@arm.com> | 2018-07-17 14:18:41 +0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-08-01 20:41:04 +0000 |
commit | e4a9eb7873f140f88be7fffb83e1215fbf181116 (patch) | |
tree | c2fdc9a699a06d1aa085ee767044fd1352ea9469 /src/vppinfra | |
parent | cc4a5e8089967f0c266e9c5ed319c38c111004cd (diff) |
Improve cpu { coremask-% } configure option
Accept any sized hexadecimal bitmask specification to
support platforms with hundreds of cores.
Change-Id: Ib881db0cf60f78bdeffa13acfc2fc7fe7e128cc4
Signed-off-by: Yi He <yi.he@arm.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/bitmap.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h index 0e94d028ee3..4f340079d36 100644 --- a/src/vppinfra/bitmap.h +++ b/src/vppinfra/bitmap.h @@ -735,6 +735,42 @@ clib_bitmap_next_clear (uword * ai, uword i) return i; } +/** unformat an any sized hexadecimal bitmask into a bitmap + + uword * bitmap; + rv = unformat ("%U", unformat_bitmap_mask, &bitmap); + + Standard unformat_function_t arguments + + @param input - pointer an unformat_input_t + @param va - varargs list comprising a single uword ** + @returns 1 on success, 0 on failure +*/ +static inline uword +unformat_bitmap_mask (unformat_input_t * input, va_list * va) +{ + u8 *v = 0; /* hexadecimal vector */ + uword **bitmap_return = va_arg (*va, uword **); + uword *bitmap = 0; + + if (unformat (input, "%U", unformat_hex_string, &v)) + { + int i, s = vec_len (v) - 1; /* 's' for significance or shift */ + + /* v[0] holds the most significant byte */ + for (i = 0; s >= 0; i++, s--) + bitmap = clib_bitmap_set_multiple (bitmap, + s * BITS (v[i]), v[i], + BITS (v[i])); + + vec_free (v); + *bitmap_return = bitmap; + return 1; + } + + return 0; +} + /** unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" ) uword * bitmap; |