LCOV - code coverage report
Current view: top level - drivers/common/cnxk - roc_dev_priv.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 3 0.0 %
Date: 2024-01-22 16:26:08 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 9 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _ROC_DEV_PRIV_H
       6                 :            : #define _ROC_DEV_PRIV_H
       7                 :            : 
       8                 :            : #define DEV_HWCAP_F_VF BIT_ULL(0) /* VF device */
       9                 :            : 
      10                 :            : #define RVU_PFVF_PF_SHIFT   10
      11                 :            : #define RVU_PFVF_PF_MASK    0x3F
      12                 :            : #define RVU_PFVF_FUNC_SHIFT 0
      13                 :            : #define RVU_PFVF_FUNC_MASK  0x3FF
      14                 :            : #define RVU_MAX_VF          64 /* RVU_PF_VFPF_MBOX_INT(0..1) */
      15                 :            : #define RVU_MAX_INT_RETRY   3
      16                 :            : 
      17                 :            : /* PF/VF message handling timer */
      18                 :            : #define VF_PF_MBOX_TIMER_MS (20 * 1000)
      19                 :            : 
      20                 :            : typedef struct {
      21                 :            : /* 128 devices translate to two 64 bits dwords */
      22                 :            : #define MAX_VFPF_DWORD_BITS 2
      23                 :            :         uint64_t bits[MAX_VFPF_DWORD_BITS];
      24                 :            : } dev_intr_t;
      25                 :            : 
      26                 :            : /* Link status update callback */
      27                 :            : typedef void (*link_info_t)(void *roc_nix,
      28                 :            :                             struct cgx_link_user_info *link);
      29                 :            : 
      30                 :            : /* PTP info callback */
      31                 :            : typedef int (*ptp_info_t)(void *roc_nix, bool enable);
      32                 :            : 
      33                 :            : /* Queue Error get callback */
      34                 :            : typedef void (*q_err_cb_t)(void *roc_nix, void *data);
      35                 :            : 
      36                 :            : /* Link status get callback */
      37                 :            : typedef void (*link_status_get_t)(void *roc_nix,
      38                 :            :                                   struct cgx_link_user_info *link);
      39                 :            : 
      40                 :            : struct dev_ops {
      41                 :            :         link_info_t link_status_update;
      42                 :            :         ptp_info_t ptp_info_update;
      43                 :            :         link_status_get_t link_status_get;
      44                 :            :         q_err_cb_t q_err_cb;
      45                 :            : };
      46                 :            : 
      47                 :            : #define dev_is_vf(dev) ((dev)->hwcap & DEV_HWCAP_F_VF)
      48                 :            : 
      49                 :            : static inline int
      50                 :            : dev_get_vf(uint16_t pf_func)
      51                 :            : {
      52                 :          0 :         return (((pf_func >> RVU_PFVF_FUNC_SHIFT) & RVU_PFVF_FUNC_MASK) - 1);
      53                 :            : }
      54                 :            : 
      55                 :            : static inline int
      56                 :            : dev_get_pf(uint16_t pf_func)
      57                 :            : {
      58   [ #  #  #  # ]:          0 :         return (pf_func >> RVU_PFVF_PF_SHIFT) & RVU_PFVF_PF_MASK;
      59                 :            : }
      60                 :            : 
      61                 :            : static inline int
      62                 :            : dev_pf_func(int pf, int vf)
      63                 :            : {
      64   [ #  #  #  #  :          0 :         return (pf << RVU_PFVF_PF_SHIFT) | ((vf << RVU_PFVF_FUNC_SHIFT) + 1);
                      # ]
      65                 :            : }
      66                 :            : 
      67                 :            : static inline int
      68                 :            : dev_is_afvf(uint16_t pf_func)
      69                 :            : {
      70                 :            :         return !(pf_func & ~RVU_PFVF_FUNC_MASK);
      71                 :            : }
      72                 :            : 
      73                 :            : struct mbox_sync {
      74                 :            :         bool start_thread;
      75                 :            :         uint8_t msg_avail;
      76                 :            :         plt_thread_t pfvf_msg_thread;
      77                 :            :         pthread_cond_t pfvf_msg_cond;
      78                 :            :         pthread_mutex_t mutex;
      79                 :            : };
      80                 :            : 
      81                 :            : struct dev {
      82                 :            :         uint16_t pf;
      83                 :            :         int16_t vf;
      84                 :            :         uint16_t pf_func;
      85                 :            :         uint8_t mbox_active;
      86                 :            :         bool drv_inited;
      87                 :            :         uint64_t active_vfs[MAX_VFPF_DWORD_BITS];
      88                 :            :         uintptr_t bar2;
      89                 :            :         uintptr_t bar4;
      90                 :            :         uintptr_t lmt_base;
      91                 :            :         struct mbox mbox_local;
      92                 :            :         struct mbox mbox_up;
      93                 :            :         struct mbox mbox_vfpf;
      94                 :            :         struct mbox mbox_vfpf_up;
      95                 :            :         dev_intr_t intr;
      96                 :            :         dev_intr_t flr;
      97                 :            :         uint64_t hwcap;
      98                 :            :         struct npa_lf npa;
      99                 :            :         struct mbox *mbox;
     100                 :            :         uint16_t maxvf;
     101                 :            :         struct dev_ops *ops;
     102                 :            :         void *roc_nix;
     103                 :            :         void *roc_cpt;
     104                 :            :         void *roc_tim;
     105                 :            :         void *roc_ml;
     106                 :            :         bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
     107                 :            :         const struct plt_memzone *lmt_mz;
     108                 :            :         struct mbox_sync sync;
     109                 :            : } __plt_cache_aligned;
     110                 :            : 
     111                 :            : struct npa {
     112                 :            :         struct plt_pci_device *pci_dev;
     113                 :            :         struct dev dev;
     114                 :            : } __plt_cache_aligned;
     115                 :            : 
     116                 :            : extern uint16_t dev_rclk_freq;
     117                 :            : extern uint16_t dev_sclk_freq;
     118                 :            : 
     119                 :            : int dev_init(struct dev *dev, struct plt_pci_device *pci_dev);
     120                 :            : int dev_fini(struct dev *dev, struct plt_pci_device *pci_dev);
     121                 :            : int dev_active_vfs(struct dev *dev);
     122                 :            : 
     123                 :            : int dev_irq_register(struct plt_intr_handle *intr_handle,
     124                 :            :                      plt_intr_callback_fn cb, void *data, unsigned int vec);
     125                 :            : void dev_irq_unregister(struct plt_intr_handle *intr_handle,
     126                 :            :                         plt_intr_callback_fn cb, void *data, unsigned int vec);
     127                 :            : int dev_irqs_disable(struct plt_intr_handle *intr_handle);
     128                 :            : int dev_irq_reconfigure(struct plt_intr_handle *intr_handle, uint16_t max_intr);
     129                 :            : 
     130                 :            : int dev_mbox_register_irq(struct plt_pci_device *pci_dev, struct dev *dev);
     131                 :            : int dev_vf_flr_register_irqs(struct plt_pci_device *pci_dev, struct dev *dev);
     132                 :            : 
     133                 :            : #endif /* _ROC_DEV_PRIV_H */

Generated by: LCOV version 1.14