[ovs-dev] [PATCH V7 2/2] odp-util: Do not rewrite fields with the same values as matched
Ben Pfaff
blp at ovn.org
Mon Mar 25 23:32:33 UTC 2019
On Thu, Mar 21, 2019 at 07:44:16AM +0000, Eli Britstein wrote:
> To improve performance and avoid wasting resources for HW offloaded
> flows, do not rewrite fields that are matched with the same value.
>
> Signed-off-by: Eli Britstein <elibr at mellanox.com>
> Reviewed-by: Roi Dayan <roid at mellanox.com>
Thanks. I applied this series to master.
I folded in an improvement to the comment on keycmp_mask() and minor
style fixes to the same function:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 291c05f84a48..b6552c5c208a 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -7367,29 +7367,27 @@ struct offsetof_sizeof {
int size;
};
-/* Compare the keys similary to memcmp, but each field separately.
- * The offsets and sizes of each field is provided by offsetof_sizeof_arr
- * argument.
- * For fields with the same value, zero out their mask part in order not to
- * rewrite them as it's unnecessary */
+/* Compares each of the fields in 'key0' and 'key1'. The fields are specified
+ * in 'offsetof_sizeof_arr', which is an array terminated by a 0-size field.
+ * Returns true if all of the fields are equal, false if at least one differs.
+ * As a side effect, for each field that is the same in 'key0' and 'key1',
+ * zeros the corresponding bytes in 'mask'. */
static bool
keycmp_mask(const void *key0, const void *key1,
struct offsetof_sizeof *offsetof_sizeof_arr, void *mask)
{
- int field;
bool differ = false;
- for (field = 0 ; ; field++) {
+ for (int field = 0 ; ; field++) {
int size = offsetof_sizeof_arr[field].size;
int offset = offsetof_sizeof_arr[field].offset;
- char *pkey0 = ((char *)key0) + offset;
- char *pkey1 = ((char *)key1) + offset;
- char *pmask = ((char *)mask) + offset;
-
if (size == 0) {
break;
}
+ char *pkey0 = ((char *)key0) + offset;
+ char *pkey1 = ((char *)key1) + offset;
+ char *pmask = ((char *)mask) + offset;
if (memcmp(pkey0, pkey1, size) == 0) {
memset(pmask, 0, size);
} else {
More information about the dev
mailing list