flow_table.c (cebeb0f1885fa93c44be5d4e0b9b640210ff088c) | flow_table.c (7085130bab2f9c5b8d61bff73b01dc8195d0f974) |
---|---|
1/* 2 * Copyright (c) 2007-2013 Nicira, Inc. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of version 2 of the GNU General Public 6 * License as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, but --- 43 unchanged lines hidden (view full) --- 52static u16 range_n_bytes(const struct sw_flow_key_range *range) 53{ 54 return range->end - range->start; 55} 56 57void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, 58 const struct sw_flow_mask *mask) 59{ | 1/* 2 * Copyright (c) 2007-2013 Nicira, Inc. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of version 2 of the GNU General Public 6 * License as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, but --- 43 unchanged lines hidden (view full) --- 52static u16 range_n_bytes(const struct sw_flow_key_range *range) 53{ 54 return range->end - range->start; 55} 56 57void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src, 58 const struct sw_flow_mask *mask) 59{ |
60 const long *m = (long *)((u8 *)&mask->key + mask->range.start); 61 const long *s = (long *)((u8 *)src + mask->range.start); | 60 const long *m = (const long *)((const u8 *)&mask->key + 61 mask->range.start); 62 const long *s = (const long *)((const u8 *)src + 63 mask->range.start); |
62 long *d = (long *)((u8 *)dst + mask->range.start); 63 int i; 64 65 /* The memory outside of the 'mask->range' are not set since 66 * further operations on 'dst' only uses contents within 67 * 'mask->range'. 68 */ 69 for (i = 0; i < range_n_bytes(&mask->range); i += sizeof(long)) --- 300 unchanged lines hidden (view full) --- 370 371 table_instance_destroy(old_ti, true); 372 return 0; 373} 374 375static u32 flow_hash(const struct sw_flow_key *key, int key_start, 376 int key_end) 377{ | 64 long *d = (long *)((u8 *)dst + mask->range.start); 65 int i; 66 67 /* The memory outside of the 'mask->range' are not set since 68 * further operations on 'dst' only uses contents within 69 * 'mask->range'. 70 */ 71 for (i = 0; i < range_n_bytes(&mask->range); i += sizeof(long)) --- 300 unchanged lines hidden (view full) --- 372 373 table_instance_destroy(old_ti, true); 374 return 0; 375} 376 377static u32 flow_hash(const struct sw_flow_key *key, int key_start, 378 int key_end) 379{ |
378 u32 *hash_key = (u32 *)((u8 *)key + key_start); | 380 const u32 *hash_key = (const u32 *)((const u8 *)key + key_start); |
379 int hash_u32s = (key_end - key_start) >> 2; 380 381 /* Make sure number of hash bytes are multiple of u32. */ 382 BUILD_BUG_ON(sizeof(long) % sizeof(u32)); 383 384 return arch_fast_hash2(hash_key, hash_u32s, 0); 385} 386 --- 5 unchanged lines hidden (view full) --- 392 return rounddown(offsetof(struct sw_flow_key, phy), 393 sizeof(long)); 394} 395 396static bool cmp_key(const struct sw_flow_key *key1, 397 const struct sw_flow_key *key2, 398 int key_start, int key_end) 399{ | 381 int hash_u32s = (key_end - key_start) >> 2; 382 383 /* Make sure number of hash bytes are multiple of u32. */ 384 BUILD_BUG_ON(sizeof(long) % sizeof(u32)); 385 386 return arch_fast_hash2(hash_key, hash_u32s, 0); 387} 388 --- 5 unchanged lines hidden (view full) --- 394 return rounddown(offsetof(struct sw_flow_key, phy), 395 sizeof(long)); 396} 397 398static bool cmp_key(const struct sw_flow_key *key1, 399 const struct sw_flow_key *key2, 400 int key_start, int key_end) 401{ |
400 const long *cp1 = (long *)((u8 *)key1 + key_start); 401 const long *cp2 = (long *)((u8 *)key2 + key_start); | 402 const long *cp1 = (const long *)((const u8 *)key1 + key_start); 403 const long *cp2 = (const long *)((const u8 *)key2 + key_start); |
402 long diffs = 0; 403 int i; 404 405 for (i = key_start; i < key_end; i += sizeof(long)) 406 diffs |= *cp1++ ^ *cp2++; 407 408 return diffs == 0; 409} --- 98 unchanged lines hidden (view full) --- 508 mask->ref_count = 1; 509 510 return mask; 511} 512 513static bool mask_equal(const struct sw_flow_mask *a, 514 const struct sw_flow_mask *b) 515{ | 404 long diffs = 0; 405 int i; 406 407 for (i = key_start; i < key_end; i += sizeof(long)) 408 diffs |= *cp1++ ^ *cp2++; 409 410 return diffs == 0; 411} --- 98 unchanged lines hidden (view full) --- 510 mask->ref_count = 1; 511 512 return mask; 513} 514 515static bool mask_equal(const struct sw_flow_mask *a, 516 const struct sw_flow_mask *b) 517{ |
516 u8 *a_ = (u8 *)&a->key + a->range.start; 517 u8 *b_ = (u8 *)&b->key + b->range.start; | 518 const u8 *a_ = (const u8 *)&a->key + a->range.start; 519 const u8 *b_ = (const u8 *)&b->key + b->range.start; |
518 519 return (a->range.end == b->range.end) 520 && (a->range.start == b->range.start) 521 && (memcmp(a_, b_, range_n_bytes(&a->range)) == 0); 522} 523 524static struct sw_flow_mask *flow_mask_find(const struct flow_table *tbl, 525 const struct sw_flow_mask *mask) --- 87 unchanged lines hidden --- | 520 521 return (a->range.end == b->range.end) 522 && (a->range.start == b->range.start) 523 && (memcmp(a_, b_, range_n_bytes(&a->range)) == 0); 524} 525 526static struct sw_flow_mask *flow_mask_find(const struct flow_table *tbl, 527 const struct sw_flow_mask *mask) --- 87 unchanged lines hidden --- |