LCOV - code coverage report
Current view: top level - drivers/net/ntnic/ntutil - nt_util.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * SPDX-License-Identifier: BSD-3-Clause
       3                 :            :  * Copyright(c) 2023 Napatech A/S
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef NTOSS_SYSTEM_NT_UTIL_H
       7                 :            : #define NTOSS_SYSTEM_NT_UTIL_H
       8                 :            : 
       9                 :            : #include <stdint.h>
      10                 :            : #include "nt4ga_link.h"
      11                 :            : 
      12                 :            : /* Total max VDPA ports */
      13                 :            : #define MAX_VDPA_PORTS 128UL
      14                 :            : 
      15                 :            : #ifndef ARRAY_SIZE
      16                 :            : #define ARRAY_SIZE(arr) RTE_DIM(arr)
      17                 :            : #endif
      18                 :            : 
      19                 :            : /*
      20                 :            :  * Windows size in seconds for measuring FLM load
      21                 :            :  * and Port load.
      22                 :            :  * The windows size must max be 3 min in order to
      23                 :            :  * prevent overflow.
      24                 :            :  */
      25                 :            : #define PORT_LOAD_WINDOWS_SIZE 2ULL
      26                 :            : #define FLM_LOAD_WINDOWS_SIZE 2ULL
      27                 :            : 
      28                 :            : #define PCIIDENT_TO_DOMAIN(pci_ident) ((uint16_t)(((unsigned int)(pci_ident) >> 16) & 0xFFFFU))
      29                 :            : #define PCIIDENT_TO_BUSNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 8) & 0xFFU))
      30                 :            : #define PCIIDENT_TO_DEVNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 3) & 0x1FU))
      31                 :            : #define PCIIDENT_TO_FUNCNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 0) & 0x7U))
      32                 :            : #define PCIIDENT_PRINT_STR "%04x:%02x:%02x.%x"
      33                 :            : #define BDF_TO_PCIIDENT(dom, bus, dev, fnc) (((dom) << 16) | ((bus) << 8) | ((dev) << 3) | (fnc))
      34                 :            : 
      35                 :            : uint64_t nt_os_get_time_monotonic_counter(void);
      36                 :            : void nt_os_wait_usec(int val);
      37                 :            : void nt_os_wait_usec_poll(int val);
      38                 :            : 
      39                 :            : static inline int min(int a, int b)
      40                 :            : {
      41         [ #  # ]:          0 :         return (a < b) ? a : b;
      42                 :            : }
      43                 :            : 
      44                 :            : uint64_t nt_util_align_size(uint64_t size);
      45                 :            : 
      46                 :            : struct nt_dma_s {
      47                 :            :         uint64_t iova;
      48                 :            :         uint64_t addr;
      49                 :            :         uint64_t size;
      50                 :            : };
      51                 :            : 
      52                 :            : struct port_link_speed {
      53                 :            :         int port_id;
      54                 :            :         int link_speed;
      55                 :            : };
      56                 :            : 
      57                 :            : struct nt_dma_s *nt_dma_alloc(uint64_t size, uint64_t align, int numa);
      58                 :            : void nt_dma_free(struct nt_dma_s *vfio_addr);
      59                 :            : 
      60                 :            : struct nt_util_vfio_impl {
      61                 :            :         int (*vfio_dma_map)(int vf_num, void *virt_addr, uint64_t *iova_addr, uint64_t size);
      62                 :            :         int (*vfio_dma_unmap)(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size);
      63                 :            : };
      64                 :            : 
      65                 :            : void nt_util_vfio_init(struct nt_util_vfio_impl *impl);
      66                 :            : 
      67                 :            : int nt_link_speed_to_eth_speed_num(enum nt_link_speed_e nt_link_speed);
      68                 :            : uint32_t nt_link_speed_capa_to_eth_speed_capa(int nt_link_speed_capa);
      69                 :            : nt_link_speed_t convert_link_speed(int link_speed_mbps);
      70                 :            : int nt_link_duplex_to_eth_duplex(enum nt_link_duplex_e nt_link_duplex);
      71                 :            : 
      72                 :            : int string_to_u32(const char *key_str __rte_unused, const char *value_str, void *extra_args);
      73                 :            : 
      74                 :            : #endif  /* NTOSS_SYSTEM_NT_UTIL_H */

Generated by: LCOV version 1.14