c0308e70c4a7a6361cb568346f0fc573023a582a
[dpdk.git] / drivers / common / cnxk / roc_dev_priv.h
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 RVU_PFVF_PF_SHIFT   10
9 #define RVU_PFVF_PF_MASK    0x3F
10 #define RVU_PFVF_FUNC_SHIFT 0
11 #define RVU_PFVF_FUNC_MASK  0x3FF
12 #define RVU_MAX_INT_RETRY   3
13
14 static inline int
15 dev_get_vf(uint16_t pf_func)
16 {
17         return (((pf_func >> RVU_PFVF_FUNC_SHIFT) & RVU_PFVF_FUNC_MASK) - 1);
18 }
19
20 static inline int
21 dev_get_pf(uint16_t pf_func)
22 {
23         return (pf_func >> RVU_PFVF_PF_SHIFT) & RVU_PFVF_PF_MASK;
24 }
25
26 static inline int
27 dev_pf_func(int pf, int vf)
28 {
29         return (pf << RVU_PFVF_PF_SHIFT) | ((vf << RVU_PFVF_FUNC_SHIFT) + 1);
30 }
31
32 struct dev {
33         uint16_t pf;
34         uint16_t pf_func;
35         uint8_t mbox_active;
36         bool drv_inited;
37         uintptr_t bar2;
38         uintptr_t bar4;
39         uintptr_t lmt_base;
40         struct mbox mbox_local;
41         struct mbox mbox_up;
42         uint64_t hwcap;
43         struct mbox *mbox;
44         bool disable_shared_lmt; /* false(default): shared lmt mode enabled */
45 } __plt_cache_aligned;
46
47 extern uint16_t dev_rclk_freq;
48 extern uint16_t dev_sclk_freq;
49
50 int dev_init(struct dev *dev, struct plt_pci_device *pci_dev);
51 int dev_fini(struct dev *dev, struct plt_pci_device *pci_dev);
52
53 int dev_irq_register(struct plt_intr_handle *intr_handle,
54                      plt_intr_callback_fn cb, void *data, unsigned int vec);
55 void dev_irq_unregister(struct plt_intr_handle *intr_handle,
56                         plt_intr_callback_fn cb, void *data, unsigned int vec);
57 int dev_irqs_disable(struct plt_intr_handle *intr_handle);
58
59 #endif /* _ROC_DEV_PRIV_H */