LCOV - code coverage report
Current view: top level - drivers/common/iavf - iavf_osdep.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017-2021 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _IAVF_OSDEP_H_
       6                 :            : #define _IAVF_OSDEP_H_
       7                 :            : 
       8                 :            : #include <string.h>
       9                 :            : #include <stdint.h>
      10                 :            : #include <stdbool.h>
      11                 :            : #include <stdio.h>
      12                 :            : #include <stdarg.h>
      13                 :            : 
      14                 :            : #include <rte_common.h>
      15                 :            : #include <rte_memcpy.h>
      16                 :            : #include <rte_memzone.h>
      17                 :            : #include <rte_malloc.h>
      18                 :            : #include <rte_byteorder.h>
      19                 :            : #include <rte_cycles.h>
      20                 :            : #include <rte_spinlock.h>
      21                 :            : #include <rte_log.h>
      22                 :            : #include <rte_io.h>
      23                 :            : 
      24                 :            : #ifndef __INTEL_NET_BASE_OSDEP__
      25                 :            : #define __INTEL_NET_BASE_OSDEP__
      26                 :            : 
      27                 :            : #define INLINE inline
      28                 :            : #define STATIC static
      29                 :            : 
      30                 :            : typedef uint8_t         u8;
      31                 :            : typedef int8_t          s8;
      32                 :            : typedef uint16_t        u16;
      33                 :            : typedef int16_t         s16;
      34                 :            : typedef uint32_t        u32;
      35                 :            : typedef int32_t         s32;
      36                 :            : typedef uint64_t        u64;
      37                 :            : typedef uint64_t        s64;
      38                 :            : 
      39                 :            : #ifndef __le16
      40                 :            : #define __le16          uint16_t
      41                 :            : #endif
      42                 :            : #ifndef __le32
      43                 :            : #define __le32          uint32_t
      44                 :            : #endif
      45                 :            : #ifndef __le64
      46                 :            : #define __le64          uint64_t
      47                 :            : #endif
      48                 :            : #ifndef __be16
      49                 :            : #define __be16          uint16_t
      50                 :            : #endif
      51                 :            : #ifndef __be32
      52                 :            : #define __be32          uint32_t
      53                 :            : #endif
      54                 :            : #ifndef __be64
      55                 :            : #define __be64          uint64_t
      56                 :            : #endif
      57                 :            : 
      58                 :            : /* Avoid macro redefinition warning on Windows */
      59                 :            : #ifdef RTE_EXEC_ENV_WINDOWS
      60                 :            : #ifdef min
      61                 :            : #undef min
      62                 :            : #endif
      63                 :            : #ifdef max
      64                 :            : #undef max
      65                 :            : #endif
      66                 :            : #endif
      67                 :            : #define min(a, b) RTE_MIN(a, b)
      68                 :            : #define max(a, b) RTE_MAX(a, b)
      69                 :            : 
      70                 :            : #define FIELD_SIZEOF(t, f) RTE_SIZEOF_FIELD(t, f)
      71                 :            : #define ARRAY_SIZE(arr) RTE_DIM(arr)
      72                 :            : 
      73                 :            : #define CPU_TO_LE16(o) rte_cpu_to_le_16(o)
      74                 :            : #define CPU_TO_LE32(s) rte_cpu_to_le_32(s)
      75                 :            : #define CPU_TO_LE64(h) rte_cpu_to_le_64(h)
      76                 :            : #define LE16_TO_CPU(a) rte_le_to_cpu_16(a)
      77                 :            : #define LE32_TO_CPU(c) rte_le_to_cpu_32(c)
      78                 :            : #define LE64_TO_CPU(k) rte_le_to_cpu_64(k)
      79                 :            : 
      80                 :            : #define CPU_TO_BE16(o) rte_cpu_to_be_16(o)
      81                 :            : #define CPU_TO_BE32(o) rte_cpu_to_be_32(o)
      82                 :            : #define CPU_TO_BE64(o) rte_cpu_to_be_64(o)
      83                 :            : 
      84                 :            : #define NTOHS(a) rte_be_to_cpu_16(a)
      85                 :            : #define NTOHL(a) rte_be_to_cpu_32(a)
      86                 :            : #define HTONS(a) rte_cpu_to_be_16(a)
      87                 :            : #define HTONL(a) rte_cpu_to_be_32(a)
      88                 :            : 
      89                 :            : static __rte_always_inline uint32_t
      90                 :            : readl(volatile void *addr)
      91                 :            : {
      92                 :            :         return rte_le_to_cpu_32(rte_read32(addr));
      93                 :            : }
      94                 :            : 
      95                 :            : static __rte_always_inline void
      96                 :            : writel(uint32_t value, volatile void *addr)
      97                 :            : {
      98                 :            :         rte_write32(rte_cpu_to_le_32(value), addr);
      99                 :          0 : }
     100                 :            : 
     101                 :            : static __rte_always_inline void
     102                 :            : writel_relaxed(uint32_t value, volatile void *addr)
     103                 :            : {
     104                 :            :         rte_write32_relaxed(rte_cpu_to_le_32(value), addr);
     105                 :            : }
     106                 :            : 
     107                 :            : static __rte_always_inline uint64_t
     108                 :            : readq(volatile void *addr)
     109                 :            : {
     110                 :            :         return rte_le_to_cpu_64(rte_read64(addr));
     111                 :            : }
     112                 :            : 
     113                 :            : static __rte_always_inline void
     114                 :            : writeq(uint64_t value, volatile void *addr)
     115                 :            : {
     116                 :            :         rte_write64(rte_cpu_to_le_64(value), addr);
     117                 :            : }
     118                 :            : 
     119                 :            : #define wr32(a, reg, value) writel((value), (a)->hw_addr + (reg))
     120                 :            : #define rd32(a, reg)        readl((a)->hw_addr + (reg))
     121                 :            : #define wr64(a, reg, value) writeq((value), (a)->hw_addr + (reg))
     122                 :            : #define rd64(a, reg)        readq((a)->hw_addr + (reg))
     123                 :            : 
     124                 :            : #endif /* __INTEL_NET_BASE_OSDEP__ */
     125                 :            : 
     126                 :            : #define iavf_memset(a, b, c, d) memset((a), (b), (c))
     127                 :            : #define iavf_memcpy(a, b, c, d) rte_memcpy((a), (b), (c))
     128                 :            : 
     129                 :            : #define iavf_usec_delay(x) rte_delay_us_sleep(x)
     130                 :            : #define iavf_msec_delay(x) iavf_usec_delay(1000 * (x))
     131                 :            : 
     132                 :            : #define IAVF_PCI_REG_WRITE(reg, value)         writel(value, reg)
     133                 :            : #define IAVF_PCI_REG_WRITE_RELAXED(reg, value) writel_relaxed(value, reg)
     134                 :            : 
     135                 :            : #define IAVF_PCI_REG_WC_WRITE(reg, value) \
     136                 :            :         rte_write32_wc((rte_cpu_to_le_32(value)), reg)
     137                 :            : #define IAVF_PCI_REG_WC_WRITE_RELAXED(reg, value) \
     138                 :            :         rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg)
     139                 :            : 
     140                 :            : #define IAVF_READ_REG(hw, reg)                 rd32(hw, reg)
     141                 :            : #define IAVF_WRITE_REG(hw, reg, value)         wr32(hw, reg, value)
     142                 :            : 
     143                 :            : #define IAVF_WRITE_FLUSH(a) IAVF_READ_REG(a, IAVF_VFGEN_RSTAT)
     144                 :            : 
     145                 :            : extern int iavf_common_logger;
     146                 :            : #define RTE_LOGTYPE_IAVF_COMMON iavf_common_logger
     147                 :            : 
     148                 :            : #define DEBUGOUT(S, ...)     RTE_LOG(DEBUG, IAVF_COMMON, S, ## __VA_ARGS__)
     149                 :            : #define DEBUGOUT2(S, ...)    DEBUGOUT(S, ## __VA_ARGS__)
     150                 :            : #define DEBUGFUNC(F)         DEBUGOUT(F "\n")
     151                 :            : 
     152                 :            : #define iavf_debug(h, m, s, ...)                                \
     153                 :            : do {                                                            \
     154                 :            :         if (((m) & (h)->debug_mask))                            \
     155                 :            :                 DEBUGOUT("iavf %02x.%x " s,                      \
     156                 :            :                         (h)->bus.device, (h)->bus.func,         \
     157                 :            :                                         ##__VA_ARGS__);         \
     158                 :            : } while (0)
     159                 :            : 
     160                 :            : /* memory allocation tracking */
     161                 :            : struct __rte_packed_begin iavf_dma_mem {
     162                 :            :         void *va;
     163                 :            :         u64 pa;
     164                 :            :         u32 size;
     165                 :            :         const void *zone;
     166                 :            : } __rte_packed_end;
     167                 :            : 
     168                 :            : struct __rte_packed_begin iavf_virt_mem {
     169                 :            :         void *va;
     170                 :            :         u32 size;
     171                 :            : } __rte_packed_end;
     172                 :            : 
     173                 :            : #define iavf_allocate_dma_mem(h, m, unused, s, a) \
     174                 :            :                         iavf_allocate_dma_mem_d(h, m, s, a)
     175                 :            : #define iavf_free_dma_mem(h, m) iavf_free_dma_mem_d(h, m)
     176                 :            : 
     177                 :            : #define iavf_allocate_virt_mem(h, m, s) iavf_allocate_virt_mem_d(h, m, s)
     178                 :            : #define iavf_free_virt_mem(h, m) iavf_free_virt_mem_d(h, m)
     179                 :            : 
     180                 :            : /* SW spinlock */
     181                 :            : struct iavf_spinlock {
     182                 :            :         rte_spinlock_t spinlock;
     183                 :            : };
     184                 :            : 
     185                 :            : #define iavf_init_spinlock(sp) rte_spinlock_init(&(sp)->spinlock)
     186                 :            : #define iavf_acquire_spinlock(sp) rte_spinlock_lock(&(sp)->spinlock)
     187                 :            : #define iavf_release_spinlock(sp) rte_spinlock_unlock(&(sp)->spinlock)
     188                 :            : #define iavf_destroy_spinlock(sp) RTE_SET_USED(sp)
     189                 :            : 
     190                 :            : #endif /* _IAVF_OSDEP_H_ */

Generated by: LCOV version 1.14