Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / vdpa / ifcvf / ifcvf_base.h
blobaa36de361c10ec5f559ec3b4fbfc1b980c07dd23
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Intel IFC VF NIC driver for virtio dataplane offloading
5 * Copyright (C) 2020 Intel Corporation.
7 * Author: Zhu Lingshan <lingshan.zhu@intel.com>
9 */
11 #ifndef _IFCVF_H_
12 #define _IFCVF_H_
14 #include <linux/pci.h>
15 #include <linux/pci_regs.h>
16 #include <linux/vdpa.h>
17 #include <linux/virtio_pci_modern.h>
18 #include <uapi/linux/virtio_net.h>
19 #include <uapi/linux/virtio_blk.h>
20 #include <uapi/linux/virtio_config.h>
21 #include <uapi/linux/virtio_pci.h>
22 #include <uapi/linux/vdpa.h>
24 #define N3000_DEVICE_ID 0x1041
25 #define N3000_SUBSYS_DEVICE_ID 0x001A
27 #define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE
28 #define IFCVF_PCI_MAX_RESOURCE 6
30 #define IFCVF_LM_BAR 4
31 #define IFCVF_MIN_VQ_SIZE 64
33 #define IFCVF_ERR(pdev, fmt, ...) dev_err(&pdev->dev, fmt, ##__VA_ARGS__)
34 #define IFCVF_DBG(pdev, fmt, ...) dev_dbg(&pdev->dev, fmt, ##__VA_ARGS__)
35 #define IFCVF_INFO(pdev, fmt, ...) dev_info(&pdev->dev, fmt, ##__VA_ARGS__)
37 /* all vqs and config interrupt has its own vector */
38 #define MSIX_VECTOR_PER_VQ_AND_CONFIG 1
39 /* all vqs share a vector, and config interrupt has a separate vector */
40 #define MSIX_VECTOR_SHARED_VQ_AND_CONFIG 2
41 /* all vqs and config interrupt share a vector */
42 #define MSIX_VECTOR_DEV_SHARED 3
44 struct vring_info {
45 u16 last_avail_idx;
46 void __iomem *notify_addr;
47 phys_addr_t notify_pa;
48 u32 irq;
49 struct vdpa_callback cb;
50 char msix_name[256];
53 struct ifcvf_lm_cfg {
54 __le64 control;
55 __le64 status;
56 __le64 lm_mem_log_start_addr;
57 __le64 lm_mem_log_end_addr;
58 __le16 vq_state_region;
61 struct ifcvf_hw {
62 u8 __iomem *isr;
63 /* Live migration */
64 struct ifcvf_lm_cfg __iomem *lm_cfg;
65 /* Notification bar number */
66 u8 notify_bar;
67 u8 msix_vector_status;
68 /* virtio-net or virtio-blk device config size */
69 u32 config_size;
70 /* Notificaiton bar address */
71 void __iomem *notify_base;
72 phys_addr_t notify_base_pa;
73 u32 notify_off_multiplier;
74 u32 dev_type;
75 u64 hw_features;
76 /* provisioned device features */
77 u64 dev_features;
78 struct virtio_pci_common_cfg __iomem *common_cfg;
79 void __iomem *dev_cfg;
80 struct vring_info *vring;
81 void __iomem * const *base;
82 char config_msix_name[256];
83 struct vdpa_callback config_cb;
84 int config_irq;
85 int vqs_reused_irq;
86 u16 nr_vring;
87 /* VIRTIO_PCI_CAP_DEVICE_CFG size */
88 u32 num_msix_vectors;
89 u32 cap_dev_config_size;
90 struct pci_dev *pdev;
93 struct ifcvf_adapter {
94 struct vdpa_device vdpa;
95 struct pci_dev *pdev;
96 struct ifcvf_hw *vf;
99 struct ifcvf_vdpa_mgmt_dev {
100 struct vdpa_mgmt_dev mdev;
101 struct ifcvf_hw vf;
102 struct ifcvf_adapter *adapter;
103 struct pci_dev *pdev;
106 int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *dev);
107 void ifcvf_stop(struct ifcvf_hw *hw);
108 void ifcvf_notify_queue(struct ifcvf_hw *hw, u16 qid);
109 void ifcvf_read_dev_config(struct ifcvf_hw *hw, u64 offset,
110 void *dst, int length);
111 void ifcvf_write_dev_config(struct ifcvf_hw *hw, u64 offset,
112 const void *src, int length);
113 u8 ifcvf_get_status(struct ifcvf_hw *hw);
114 void ifcvf_set_status(struct ifcvf_hw *hw, u8 status);
115 void ifcvf_reset(struct ifcvf_hw *hw);
116 u64 ifcvf_get_dev_features(struct ifcvf_hw *hw);
117 u64 ifcvf_get_hw_features(struct ifcvf_hw *hw);
118 int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features);
119 u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid);
120 int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num);
121 u32 ifcvf_get_config_size(struct ifcvf_hw *hw);
122 u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector);
123 u16 ifcvf_set_config_vector(struct ifcvf_hw *hw, int vector);
124 void ifcvf_set_vq_num(struct ifcvf_hw *hw, u16 qid, u32 num);
125 int ifcvf_set_vq_address(struct ifcvf_hw *hw, u16 qid, u64 desc_area,
126 u64 driver_area, u64 device_area);
127 bool ifcvf_get_vq_ready(struct ifcvf_hw *hw, u16 qid);
128 void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready);
129 void ifcvf_set_driver_features(struct ifcvf_hw *hw, u64 features);
130 u64 ifcvf_get_driver_features(struct ifcvf_hw *hw);
131 u16 ifcvf_get_max_vq_size(struct ifcvf_hw *hw);
132 u16 ifcvf_get_vq_size(struct ifcvf_hw *hw, u16 qid);
133 #endif /* _IFCVF_H_ */