LCOV - code coverage report
Current view: top level - drivers/net/rnp/base - rnp_crc32.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 17 0.0 %
Date: 2025-07-01 21:32:37 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2023 Mucse IC Design Ltd.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "rnp_osdep.h"
       6                 :            : #include "rnp_crc32.h"
       7                 :            : 
       8                 :            : #define RNP_CRC32_POLY_LE 0xedb88320
       9                 :            : static inline int get_bitmask_order(u32 count)
      10                 :            : {
      11                 :            :         int order;
      12                 :            : 
      13                 :            :         order = fls(count);
      14                 :            : 
      15                 :            :         return order;   /* We could be slightly more clever with -1 here... */
      16                 :            : }
      17                 :            : 
      18                 :          0 : u32 rnp_vid_crc32_calc(u32 crc_init, u16 vid_le)
      19                 :            : {
      20                 :            :         u8 *data = (u8 *)&vid_le;
      21                 :            :         u32 crc = crc_init;
      22                 :            :         u8 data_byte = 0;
      23                 :            :         u32 temp = 0;
      24                 :            :         int i, bits;
      25                 :            : 
      26                 :            :         bits = get_bitmask_order(VLAN_VID_MASK);
      27         [ #  # ]:          0 :         for (i = 0; i < bits; i++) {
      28         [ #  # ]:          0 :                 if ((i % 8) == 0)
      29                 :          0 :                         data_byte = data[i / 8];
      30                 :          0 :                 temp = ((crc & 1) ^ data_byte) & 1;
      31                 :          0 :                 crc >>= 1;
      32                 :          0 :                 data_byte >>= 1;
      33         [ #  # ]:          0 :                 if (temp)
      34                 :          0 :                         crc ^= RNP_CRC32_POLY_LE;
      35                 :            :         }
      36                 :            : 
      37                 :          0 :         return crc;
      38                 :            : }
      39                 :            : 
      40                 :          0 : u32 rnp_calc_crc32(u32 seed, u8 *mac, u32 len)
      41                 :            : {
      42                 :            :         u32 crc = seed;
      43                 :            :         u32 i;
      44                 :            : 
      45         [ #  # ]:          0 :         while (len--) {
      46                 :          0 :                 crc ^= *mac++;
      47         [ #  # ]:          0 :                 for (i = 0; i < 8; i++)
      48                 :          0 :                         crc = (crc >> 1) ^ ((crc & 1) ?
      49         [ #  # ]:          0 :                                         RNP_CRC32_POLY_LE : 0);
      50                 :            :         }
      51                 :            : 
      52                 :          0 :         return crc;
      53                 :            : }

Generated by: LCOV version 1.14