LCOV - code coverage report
Current view: top level - lib/hash - compare_signatures_x86.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 9 12 75.0 %
Date: 2025-02-01 18:54:23 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 4 25.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2010-2016 Intel Corporation
       3                 :            :  * Copyright(c) 2018-2024 Arm Limited
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef COMPARE_SIGNATURES_X86_H
       7                 :            : #define COMPARE_SIGNATURES_X86_H
       8                 :            : 
       9                 :            : #include <inttypes.h>
      10                 :            : 
      11                 :            : #include <rte_common.h>
      12                 :            : #include <rte_vect.h>
      13                 :            : 
      14                 :            : #include "rte_cuckoo_hash.h"
      15                 :            : 
      16                 :            : /* x86's version uses a sparsely packed hitmask buffer: every other bit is padding. */
      17                 :            : #define DENSE_HASH_BULK_LOOKUP 0
      18                 :            : 
      19                 :            : static inline void
      20                 :        294 : compare_signatures_sparse(uint32_t *prim_hash_matches, uint32_t *sec_hash_matches,
      21                 :            :                         const struct rte_hash_bucket *prim_bkt,
      22                 :            :                         const struct rte_hash_bucket *sec_bkt,
      23                 :            :                         uint16_t sig,
      24                 :            :                         enum rte_hash_sig_compare_function sig_cmp_fn)
      25                 :            : {
      26                 :            :         unsigned int i;
      27                 :            : 
      28                 :            :         /* For match mask the first bit of every two bits indicates the match */
      29         [ +  - ]:        294 :         switch (sig_cmp_fn) {
      30                 :            : #if defined(__SSE2__) && RTE_HASH_BUCKET_ENTRIES <= 8
      31                 :        294 :         case RTE_HASH_COMPARE_SSE:
      32                 :            :                 /* Compare all signatures in the bucket */
      33                 :        294 :                 *prim_hash_matches = _mm_movemask_epi8(_mm_cmpeq_epi16(_mm_load_si128(
      34                 :            :                         (__m128i const *)prim_bkt->sig_current), _mm_set1_epi16(sig)));
      35                 :            :                 /* Extract the even-index bits only */
      36                 :        294 :                 *prim_hash_matches &= 0x5555;
      37                 :            :                 /* Compare all signatures in the bucket */
      38                 :        294 :                 *sec_hash_matches = _mm_movemask_epi8(_mm_cmpeq_epi16(_mm_load_si128(
      39                 :            :                         (__m128i const *)sec_bkt->sig_current), _mm_set1_epi16(sig)));
      40                 :            :                 /* Extract the even-index bits only */
      41                 :        294 :                 *sec_hash_matches &= 0x5555;
      42                 :        294 :                 break;
      43                 :            : #endif
      44                 :            :         default:
      45         [ #  # ]:          0 :                 for (i = 0; i < RTE_HASH_BUCKET_ENTRIES; i++) {
      46                 :          0 :                         *prim_hash_matches |= (sig == prim_bkt->sig_current[i]) << (i << 1);
      47                 :          0 :                         *sec_hash_matches |= (sig == sec_bkt->sig_current[i]) << (i << 1);
      48                 :            :                 }
      49                 :            :         }
      50                 :        294 : }
      51                 :            : #endif /* COMPARE_SIGNATURES_X86_H */

Generated by: LCOV version 1.14