LCOV - code coverage report
Current view: top level - vppinfra - lb_hash_hash.h (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 13 13 100.0 %
Date: 2023-07-05 22:20:52 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2018 Cisco and/or its affiliates.
       3             :  * Licensed under the Apache License, Version 2.0 (the "License");
       4             :  * you may not use this file except in compliance with the License.
       5             :  * You may obtain a copy of the License at:
       6             :  *
       7             :  *     http://www.apache.org/licenses/LICENSE-2.0
       8             :  *
       9             :  * Unless required by applicable law or agreed to in writing, software
      10             :  * distributed under the License is distributed on an "AS IS" BASIS,
      11             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             :  * See the License for the specific language governing permissions and
      13             :  * limitations under the License.
      14             :  */
      15             : 
      16             : #ifndef __included_lb_hash_hash_h__
      17             : #define __included_lb_hash_hash_h__
      18             : 
      19             : #include <vppinfra/crc32.h>
      20             : #include <vppinfra/xxhash.h>
      21             : 
      22             : #if defined(clib_crc32c_uses_intrinsics) && !defined (__i386__)
      23             : static_always_inline u32
      24        1300 : lb_hash_hash (u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
      25             : {
      26        1300 :   u64 val = 0;
      27        1300 :   val = clib_crc32c_u64 (val, k0);
      28        1300 :   val = clib_crc32c_u64 (val, k1);
      29        1300 :   val = clib_crc32c_u64 (val, k2);
      30        1300 :   val = clib_crc32c_u64 (val, k3);
      31        1300 :   val = clib_crc32c_u64 (val, k4);
      32        1300 :   return (u32) val;
      33             : }
      34             : 
      35             : /* Note: k0 is u64 and k1 is u32 */
      36             : static_always_inline u32
      37           2 : lb_hash_hash_2_tuples (u64 k0, u32 k1)
      38             : {
      39           2 :   u64 val = 0;
      40           2 :   val = clib_crc32c_u64 (val, k0);
      41           2 :   val = clib_crc32c_u32 (val, k1);
      42           2 :   return (u32) val;
      43             : }
      44             : #else
      45             : static_always_inline u32
      46             : lb_hash_hash (u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
      47             : {
      48             :   u64 tmp = k0 ^ k1 ^ k2 ^ k3 ^ k4;
      49             :   return (u32) clib_xxhash (tmp);
      50             : }
      51             : 
      52             : /* Note: k0 is u64 and k1 is u32 */
      53             : static_always_inline u32
      54             : lb_hash_hash_2_tuples (u64 k0, u32 k1)
      55             : {
      56             :   u64 tmp = k0 ^ k1;
      57             :   return (u32) clib_xxhash (tmp);
      58             : }
      59             : #endif
      60             : 
      61             : #endif /* __included_lb_hash_hash_h__ */
      62             : 
      63             : /*
      64             :  * fd.io coding-style-patch-verification: ON
      65             :  *
      66             :  * Local Variables:
      67             :  * eval: (c-set-style "gnu")
      68             :  * End:
      69             :  */

Generated by: LCOV version 1.14