0001
0002 #ifndef _LINUX_VIRTIO_PCI_MODERN_H
0003 #define _LINUX_VIRTIO_PCI_MODERN_H
0004
0005 #include <linux/pci.h>
0006 #include <linux/virtio_pci.h>
0007
0008 struct virtio_pci_modern_common_cfg {
0009 struct virtio_pci_common_cfg cfg;
0010
0011 __le16 queue_notify_data;
0012 __le16 queue_reset;
0013 };
0014
0015 struct virtio_pci_modern_device {
0016 struct pci_dev *pci_dev;
0017
0018 struct virtio_pci_common_cfg __iomem *common;
0019
0020 void __iomem *device;
0021
0022 void __iomem *notify_base;
0023
0024 resource_size_t notify_pa;
0025
0026 u8 __iomem *isr;
0027
0028
0029 size_t notify_len;
0030 size_t device_len;
0031
0032
0033 int notify_map_cap;
0034
0035
0036 u32 notify_offset_multiplier;
0037
0038 int modern_bars;
0039
0040 struct virtio_device_id id;
0041 };
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 static inline u8 vp_ioread8(const u8 __iomem *addr)
0052 {
0053 return ioread8(addr);
0054 }
0055 static inline u16 vp_ioread16 (const __le16 __iomem *addr)
0056 {
0057 return ioread16(addr);
0058 }
0059
0060 static inline u32 vp_ioread32(const __le32 __iomem *addr)
0061 {
0062 return ioread32(addr);
0063 }
0064
0065 static inline void vp_iowrite8(u8 value, u8 __iomem *addr)
0066 {
0067 iowrite8(value, addr);
0068 }
0069
0070 static inline void vp_iowrite16(u16 value, __le16 __iomem *addr)
0071 {
0072 iowrite16(value, addr);
0073 }
0074
0075 static inline void vp_iowrite32(u32 value, __le32 __iomem *addr)
0076 {
0077 iowrite32(value, addr);
0078 }
0079
0080 static inline void vp_iowrite64_twopart(u64 val,
0081 __le32 __iomem *lo,
0082 __le32 __iomem *hi)
0083 {
0084 vp_iowrite32((u32)val, lo);
0085 vp_iowrite32(val >> 32, hi);
0086 }
0087
0088 u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev);
0089 u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev);
0090 void vp_modern_set_features(struct virtio_pci_modern_device *mdev,
0091 u64 features);
0092 u32 vp_modern_generation(struct virtio_pci_modern_device *mdev);
0093 u8 vp_modern_get_status(struct virtio_pci_modern_device *mdev);
0094 void vp_modern_set_status(struct virtio_pci_modern_device *mdev,
0095 u8 status);
0096 u16 vp_modern_queue_vector(struct virtio_pci_modern_device *mdev,
0097 u16 idx, u16 vector);
0098 u16 vp_modern_config_vector(struct virtio_pci_modern_device *mdev,
0099 u16 vector);
0100 void vp_modern_queue_address(struct virtio_pci_modern_device *mdev,
0101 u16 index, u64 desc_addr, u64 driver_addr,
0102 u64 device_addr);
0103 void vp_modern_set_queue_enable(struct virtio_pci_modern_device *mdev,
0104 u16 idx, bool enable);
0105 bool vp_modern_get_queue_enable(struct virtio_pci_modern_device *mdev,
0106 u16 idx);
0107 void vp_modern_set_queue_size(struct virtio_pci_modern_device *mdev,
0108 u16 idx, u16 size);
0109 u16 vp_modern_get_queue_size(struct virtio_pci_modern_device *mdev,
0110 u16 idx);
0111 u16 vp_modern_get_num_queues(struct virtio_pci_modern_device *mdev);
0112 void __iomem * vp_modern_map_vq_notify(struct virtio_pci_modern_device *mdev,
0113 u16 index, resource_size_t *pa);
0114 int vp_modern_probe(struct virtio_pci_modern_device *mdev);
0115 void vp_modern_remove(struct virtio_pci_modern_device *mdev);
0116 int vp_modern_get_queue_reset(struct virtio_pci_modern_device *mdev, u16 index);
0117 void vp_modern_set_queue_reset(struct virtio_pci_modern_device *mdev, u16 index);
0118 #endif