LCOV - code coverage report
Current view: top level - drivers/net/intel/ixgbe - ixgbe_osdep.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1 0.0 %
Date: 2026-10-01 18:19:24 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) 2001-2024 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _IXGBE_OS_H_
       6                 :            : #define _IXGBE_OS_H_
       7                 :            : 
       8                 :            : /* File containing OS dependencies for base code */
       9                 :            : 
      10                 :            : #include <pthread.h>
      11                 :            : #include <string.h>
      12                 :            : #include <stdint.h>
      13                 :            : #include <stdio.h>
      14                 :            : #include <stdarg.h>
      15                 :            : #include <stdbool.h>
      16                 :            : #include <malloc.h>
      17                 :            : 
      18                 :            : #include <rte_common.h>
      19                 :            : #include <rte_debug.h>
      20                 :            : #include <rte_cycles.h>
      21                 :            : #include <rte_log.h>
      22                 :            : #include <rte_byteorder.h>
      23                 :            : #include <rte_io.h>
      24                 :            : #include <rte_ip.h>
      25                 :            : 
      26                 :            : #include "../ixgbe_logs.h"
      27                 :            : #include "../ixgbe_bypass_defines.h"
      28                 :            : 
      29                 :            : #ifndef IPPROTO_SCTP
      30                 :            : #define IPPROTO_SCTP 132
      31                 :            : #endif
      32                 :            : 
      33                 :            : #define ASSERT(x) if(!(x)) rte_panic("IXGBE: x")
      34                 :            : 
      35                 :            : #define DELAY(x) rte_delay_us_sleep(x)
      36                 :            : #define usec_delay(x) DELAY(x)
      37                 :            : #define msec_delay(x) DELAY(1000*(x))
      38                 :            : 
      39                 :            : #define DEBUGFUNC(F)            DEBUGOUT(F "\n");
      40                 :            : #define DEBUGOUT(S, ...)        RTE_LOG(DEBUG, IXGBE_DRIVER, "%s(): " S, __func__, ## __VA_ARGS__)
      41                 :            : #define DEBUGOUT1(S, ...)       DEBUGOUT(S, ##__VA_ARGS__)
      42                 :            : #define DEBUGOUT2(S, ...)       DEBUGOUT(S, ##__VA_ARGS__)
      43                 :            : #define DEBUGOUT3(S, ...)       DEBUGOUT(S, ##__VA_ARGS__)
      44                 :            : #define DEBUGOUT4(S, ...)       DEBUGOUT(S, ##__VA_ARGS__)
      45                 :            : #define DEBUGOUT6(S, ...)       DEBUGOUT(S, ##__VA_ARGS__)
      46                 :            : #define DEBUGOUT7(S, ...)       DEBUGOUT(S, ##__VA_ARGS__)
      47                 :            : 
      48                 :            : #define ERROR_REPORT1(e, S, ...) DEBUGOUT(S, ##__VA_ARGS__)
      49                 :            : #define ERROR_REPORT2(e, S, ...) DEBUGOUT(S, ##__VA_ARGS__)
      50                 :            : #define ERROR_REPORT3(e, S, ...) DEBUGOUT(S, ##__VA_ARGS__)
      51                 :            : 
      52                 :            : #define FALSE               0
      53                 :            : #define TRUE                1
      54                 :            : 
      55                 :            : #define false               0
      56                 :            : #define true                1
      57                 :            : #ifndef RTE_EXEC_ENV_WINDOWS
      58                 :            : #define min(a,b)        RTE_MIN(a,b)
      59                 :            : #endif
      60                 :            : 
      61                 :            : #define EWARN(hw, S, ...)         DEBUGOUT1(S, ##__VA_ARGS__)
      62                 :            : 
      63                 :            : /* Bunch of defines for shared code bogosity */
      64                 :            : #ifndef UNREFERENCED_PARAMETER
      65                 :            : #define UNREFERENCED_PARAMETER(_p) (void)(_p)
      66                 :            : #endif
      67                 :            : #define UNREFERENCED_1PARAMETER(_p) (void)(_p)
      68                 :            : #define UNREFERENCED_2PARAMETER(_p, _q) do { (void)(_p); (void)(_q); } while(0)
      69                 :            : #define UNREFERENCED_3PARAMETER(_p, _q, _r) \
      70                 :            :         do { (void)(_p); (void)(_q); (void)(_r); } while(0)
      71                 :            : #define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) \
      72                 :            :         do { (void)(_p); (void)(_q); (void)(_r); (void)(_s); } while(0)
      73                 :            : #define UNREFERENCED_5PARAMETER(_p, _q, _r, _s, _t) \
      74                 :            :         do { (void)(_p); (void)(_q); (void)(_r); (void)(_s); (void)(_t); } while(0)
      75                 :            : 
      76                 :            : /* Shared code error reporting */
      77                 :            : enum {
      78                 :            :         IXGBE_ERROR_SOFTWARE,
      79                 :            :         IXGBE_ERROR_POLLING,
      80                 :            :         IXGBE_ERROR_INVALID_STATE,
      81                 :            :         IXGBE_ERROR_UNSUPPORTED,
      82                 :            :         IXGBE_ERROR_ARGUMENT,
      83                 :            :         IXGBE_ERROR_CAUTION,
      84                 :            : };
      85                 :            : 
      86                 :            : #define STATIC static
      87                 :            : #define IXGBE_NTOHL(_i) rte_be_to_cpu_32(_i)
      88                 :            : #define IXGBE_NTOHS(_i) rte_be_to_cpu_16(_i)
      89                 :            : #define IXGBE_CPU_TO_LE16(_i)  rte_cpu_to_le_16(_i)
      90                 :            : #define IXGBE_CPU_TO_LE32(_i)  rte_cpu_to_le_32(_i)
      91                 :            : #define IXGBE_LE16_TO_CPU(_i)  rte_le_to_cpu_16(_i)
      92                 :            : #define IXGBE_LE32_TO_CPU(_i)  rte_le_to_cpu_32(_i)
      93                 :            : #define IXGBE_LE64_TO_CPU(_i)  rte_le_to_cpu_64(_i)
      94                 :            : #define IXGBE_LE32_TO_CPUS(_i) do { *_i = rte_le_to_cpu_32(*_i); } while(0)
      95                 :            : #define IXGBE_CPU_TO_BE16(_i)  rte_cpu_to_be_16(_i)
      96                 :            : #define IXGBE_CPU_TO_BE32(_i)  rte_cpu_to_be_32(_i)
      97                 :            : #define IXGBE_BE32_TO_CPU(_i)  rte_be_to_cpu_32(_i)
      98                 :            : 
      99                 :            : typedef uint8_t         u8;
     100                 :            : typedef int8_t          s8;
     101                 :            : typedef uint16_t        u16;
     102                 :            : typedef int16_t         s16;
     103                 :            : typedef uint32_t        u32;
     104                 :            : typedef int32_t         s32;
     105                 :            : typedef uint64_t        u64;
     106                 :            : 
     107                 :            : #define mb()    rte_mb()
     108                 :            : #define wmb()   rte_wmb()
     109                 :            : #define rmb()   rte_rmb()
     110                 :            : 
     111                 :            : #define IOMEM
     112                 :            : 
     113                 :            : #define prefetch(x) rte_prefetch0(x)
     114                 :            : 
     115                 :            : #define IXGBE_PCI_REG(reg) rte_read32(reg)
     116                 :            : 
     117                 :            : static inline uint32_t ixgbe_read_addr(volatile void* addr)
     118                 :            : {
     119                 :          0 :         return rte_le_to_cpu_32(IXGBE_PCI_REG(addr));
     120                 :            : }
     121                 :            : 
     122                 :            : #define IXGBE_PCI_REG_WRITE(reg, value)                 \
     123                 :            :         rte_write32((rte_cpu_to_le_32(value)), reg)
     124                 :            : 
     125                 :            : #define IXGBE_PCI_REG_WRITE_RELAXED(reg, value)         \
     126                 :            :         rte_write32_relaxed((rte_cpu_to_le_32(value)), reg)
     127                 :            : 
     128                 :            : #define IXGBE_PCI_REG_WC_WRITE(reg, value)                      \
     129                 :            :         rte_write32_wc((rte_cpu_to_le_32(value)), reg)
     130                 :            : 
     131                 :            : #define IXGBE_PCI_REG_WC_WRITE_RELAXED(reg, value)              \
     132                 :            :         rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg)
     133                 :            : 
     134                 :            : #define IXGBE_PCI_REG_ADDR(hw, reg) \
     135                 :            :         ((volatile void *)((char *)(hw)->hw_addr + (reg)))
     136                 :            : 
     137                 :            : #define IXGBE_PCI_REG_ARRAY_ADDR(hw, reg, index) \
     138                 :            :         IXGBE_PCI_REG_ADDR((hw), (reg) + ((index) << 2))
     139                 :            : 
     140                 :            : /* Not implemented !! */
     141                 :            : #define IXGBE_READ_PCIE_WORD(hw, reg)  ((void)hw, (void)(reg), 0)
     142                 :            : #define IXGBE_WRITE_PCIE_WORD(hw, reg, value) do { (void)hw; (void)reg; (void)value; } while(0)
     143                 :            : 
     144                 :            : #define IXGBE_WRITE_FLUSH(a) IXGBE_READ_REG(a, IXGBE_STATUS)
     145                 :            : 
     146                 :            : #define IXGBE_READ_REG(hw, reg) \
     147                 :            :         ixgbe_read_addr(IXGBE_PCI_REG_ADDR((hw), (reg)))
     148                 :            : 
     149                 :            : #define IXGBE_WRITE_REG(hw, reg, value) \
     150                 :            :         IXGBE_PCI_REG_WRITE(IXGBE_PCI_REG_ADDR((hw), (reg)), (value))
     151                 :            : 
     152                 :            : #define IXGBE_READ_REG_ARRAY(hw, reg, index) \
     153                 :            :         IXGBE_PCI_REG(IXGBE_PCI_REG_ARRAY_ADDR((hw), (reg), (index)))
     154                 :            : 
     155                 :            : #define IXGBE_WRITE_REG_ARRAY(hw, reg, index, value) \
     156                 :            :         IXGBE_PCI_REG_WRITE(IXGBE_PCI_REG_ARRAY_ADDR((hw), (reg), (index)), (value))
     157                 :            : 
     158                 :            : #define IXGBE_WRITE_REG_THEN_POLL_MASK(hw, reg, val, mask, poll_ms)     \
     159                 :            : do {                                                                    \
     160                 :            :         uint32_t cnt = poll_ms;                                         \
     161                 :            :         IXGBE_WRITE_REG(hw, (reg), (val));                              \
     162                 :            :         while (((IXGBE_READ_REG(hw, (reg))) & (mask)) && (cnt--))   \
     163                 :            :                 rte_delay_ms(1);                                        \
     164                 :            : } while (0)
     165                 :            : 
     166                 :            : struct ixgbe_hw;
     167                 :            : struct ixgbe_lock {
     168                 :            :         pthread_mutex_t mutex;
     169                 :            : };
     170                 :            : 
     171                 :            : #define ixgbe_calloc(hw, c, s) ((void)hw, calloc(c, s))
     172                 :            : #define ixgbe_malloc(hw, s) ((void)hw, malloc(s))
     173                 :            : #define ixgbe_free(hw, a) ((void)hw, free(a))
     174                 :            : 
     175                 :            : #define ixgbe_init_lock(lock) pthread_mutex_init(&(lock)->mutex, NULL)
     176                 :            : #define ixgbe_destroy_lock(lock) pthread_mutex_destroy(&(lock)->mutex)
     177                 :            : #define ixgbe_acquire_lock(lock) pthread_mutex_lock(&(lock)->mutex)
     178                 :            : #define ixgbe_release_lock(lock)        pthread_mutex_unlock(&(lock)->mutex)
     179                 :            : 
     180                 :            : #endif /* _IXGBE_OS_H_ */

Generated by: LCOV version 1.14