/*-
* BSD LICENSE
- *
- * Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ *
+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
* are met:
- *
- * * Redistributions of source code must retain the above copyright
+ *
+ * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
* distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * version: DPDK.L.1.2.3-3
*/
#ifndef _RTE_JHASH_H
rte_jhash(const void *key, uint32_t length, uint32_t initval)
{
uint32_t a, b, c, len;
- const uint8_t *k = (const uint8_t *) key;
+ const uint8_t *k = (const uint8_t *)key;
+ const uint32_t *k32 = (const uint32_t *)key;
len = length;
a = b = RTE_JHASH_GOLDEN_RATIO;
c = initval;
while (len >= 12) {
- a += (k[0] + ((uint32_t)k[1] << 8) + ((uint32_t)k[2] << 16) +
- ((uint32_t)k[3] << 24));
- b += (k[4] + ((uint32_t)k[5] << 8) + ((uint32_t)k[6] << 16) +
- ((uint32_t)k[7] << 24));
- c += (k[8] + ((uint32_t)k[9] << 8) + ((uint32_t)k[10] << 16) +
- ((uint32_t)k[11] << 24));
+ a += k32[0];
+ b += k32[1];
+ c += k32[2];
__rte_jhash_mix(a,b,c);
- k += 12;
- len -= 12;
+ k += (3 * sizeof(uint32_t)), k32 += 3;
+ len -= (3 * sizeof(uint32_t));
}
c += length;
* Calculated hash value.
*/
static inline uint32_t
-rte_jhash2(uint32_t *k, uint32_t length, uint32_t initval)
+rte_jhash2(const uint32_t *k, uint32_t length, uint32_t initval)
{
uint32_t a, b, c, len;
* A special ultra-optimized versions that knows it is hashing exactly
* 2 words.
*
- * NOTE: In partilar the "c += length; __rte_jhash_mix(a,b,c);" normally
- * done at the end is not done here.
- *
* @param a
* First word to calcuate hash of.
* @param b
* A special ultra-optimized versions that knows it is hashing exactly
* 1 word.
*
- * NOTE: In partilar the "c += length; __rte_jhash_mix(a,b,c);" normally
- * done at the end is not done here.
- *
* @param a
* Word to calcuate hash of.
* @param initval