diff options
author | Jarno Rajahalme <jrajahalme@nicira.com> | 2014-08-26 15:11:39 -0700 |
---|---|---|
committer | Jarno Rajahalme <jrajahalme@nicira.com> | 2014-08-26 15:51:29 -0700 |
commit | 3c30d1118e2e28cad795f342c984acb5e89431d7 (patch) | |
tree | adda092f00af2cab5536982c9404fbcf635eaa14 /lib/flow.h | |
parent | 097673a636ad7684d89ed3a9a858f6afae586822 (diff) | |
download | openvswitch-3c30d1118e2e28cad795f342c984acb5e89431d7.tar.gz |
lib/flow.h: Improve struct miniflow comment and definition.
Miniflows can nowadays be dynamically allocated to different inline
sizes, as done by lib/classifier.c, but this had not been documented
at the struct miniflow definition.
Also, MINI_N_INLINE had a different value for 32-bit and 64-bit builds
due to a historical reason. Now we use 8 for both.
Finally, use change the storage type of 'values_inline' to uint8_t, as
uint64_t looks kind of wide for a boolean, even though we intend the
bit be carved out from the uint64_t where 'map' resides.
Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Diffstat (limited to 'lib/flow.h')
-rw-r--r-- | lib/flow.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/flow.h b/lib/flow.h index 3b8d24d8f..2891d60a9 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -346,7 +346,10 @@ bool flow_equal_except(const struct flow *a, const struct flow *b, /* Compressed flow. */ -#define MINI_N_INLINE (sizeof(void *) == 4 ? 7 : 8) +/* Number of 32-bit words present in struct miniflow. */ +#define MINI_N_INLINE 8 + +/* Maximum number of 32-bit words supported. */ BUILD_ASSERT_DECL(FLOW_U32S <= 63); /* A sparse representation of a "struct flow". @@ -367,6 +370,11 @@ BUILD_ASSERT_DECL(FLOW_U32S <= 63); * the first element of the values array, the next 1-bit is in the next array * element, and so on. * + * MINI_N_INLINE is the default number of inline words. When a miniflow is + * dynamically allocated the actual amount of inline storage may be different. + * In that case 'inline_values' contains storage at least for the number + * of words indicated by 'map' (one uint32_t for each 1-bit in the map). + * * Elements in values array are allowed to be zero. This is useful for "struct * minimatch", for which ensuring that the miniflow and minimask members have * same 'map' allows optimization. This allowance applies only to a miniflow @@ -375,12 +383,14 @@ BUILD_ASSERT_DECL(FLOW_U32S <= 63); */ struct miniflow { uint64_t map:63; - uint64_t values_inline:1; + uint8_t values_inline:1; union { uint32_t *offline_values; - uint32_t inline_values[MINI_N_INLINE]; + uint32_t inline_values[MINI_N_INLINE]; /* Minimum inline size. */ }; }; +BUILD_ASSERT_DECL(sizeof(struct miniflow) + == sizeof(uint64_t) + MINI_N_INLINE * sizeof(uint32_t)); #define MINIFLOW_VALUES_SIZE(COUNT) ((COUNT) * sizeof(uint32_t)) |