// SPDX-License-Identifier: GPL-2.0-or-later #include <linux/virtio_pci_modern.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/delay.h> /* * vp_modern_map_capability - map a part of virtio pci capability * @mdev: the modern virtio-pci device * @off: offset of the capability * @minlen: minimal length of the capability * @align: align requirement * @start: start from the capability * @size: map size * @len: the length that is actually mapped * @pa: physical address of the capability * * Returns the io address of for the part of the capability */ static void __iomem * vp_modern_map_capability(struct virtio_pci_modern_device *mdev, int off, size_t minlen, u32 align, u32 start, u32 size, size_t *len, resource_size_t *pa) { … } /** * virtio_pci_find_capability - walk capabilities to find device info. * @dev: the pci device * @cfg_type: the VIRTIO_PCI_CAP_* value we seek * @ioresource_types: IORESOURCE_MEM and/or IORESOURCE_IO. * @bars: the bitmask of BARs * * Returns offset of the capability, or 0. */ static inline int virtio_pci_find_capability(struct pci_dev *dev, u8 cfg_type, u32 ioresource_types, int *bars) { … } /* This is part of the ABI. Don't screw with it. */ static inline void check_offsets(void) { … } /* * vp_modern_probe: probe the modern virtio pci device, note that the * caller is required to enable PCI device before calling this function. * @mdev: the modern virtio-pci device * * Return 0 on succeed otherwise fail */ int vp_modern_probe(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_remove: remove and cleanup the modern virtio pci device * @mdev: the modern virtio-pci device */ void vp_modern_remove(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_features - get features from device * @mdev: the modern virtio-pci device * * Returns the features read from the device */ u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_driver_features - get driver features from device * @mdev: the modern virtio-pci device * * Returns the driver features read from the device */ u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_set_features - set features to device * @mdev: the modern virtio-pci device * @features: the features set to device */ void vp_modern_set_features(struct virtio_pci_modern_device *mdev, u64 features) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_generation - get the device genreation * @mdev: the modern virtio-pci device * * Returns the genreation read from device */ u32 vp_modern_generation(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_status - get the device status * @mdev: the modern virtio-pci device * * Returns the status read from device */ u8 vp_modern_get_status(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_set_status - set status to device * @mdev: the modern virtio-pci device * @status: the status set to device */ void vp_modern_set_status(struct virtio_pci_modern_device *mdev, u8 status) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_queue_reset - get the queue reset status * @mdev: the modern virtio-pci device * @index: queue index */ int vp_modern_get_queue_reset(struct virtio_pci_modern_device *mdev, u16 index) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_set_queue_reset - reset the queue * @mdev: the modern virtio-pci device * @index: queue index */ void vp_modern_set_queue_reset(struct virtio_pci_modern_device *mdev, u16 index) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_queue_vector - set the MSIX vector for a specific virtqueue * @mdev: the modern virtio-pci device * @index: queue index * @vector: the config vector * * Returns the config vector read from the device */ u16 vp_modern_queue_vector(struct virtio_pci_modern_device *mdev, u16 index, u16 vector) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_config_vector - set the vector for config interrupt * @mdev: the modern virtio-pci device * @vector: the config vector * * Returns the config vector read from the device */ u16 vp_modern_config_vector(struct virtio_pci_modern_device *mdev, u16 vector) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_queue_address - set the virtqueue address * @mdev: the modern virtio-pci device * @index: the queue index * @desc_addr: address of the descriptor area * @driver_addr: address of the driver area * @device_addr: address of the device area */ void vp_modern_queue_address(struct virtio_pci_modern_device *mdev, u16 index, u64 desc_addr, u64 driver_addr, u64 device_addr) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_set_queue_enable - enable a virtqueue * @mdev: the modern virtio-pci device * @index: the queue index * @enable: whether the virtqueue is enable or not */ void vp_modern_set_queue_enable(struct virtio_pci_modern_device *mdev, u16 index, bool enable) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_queue_enable - enable a virtqueue * @mdev: the modern virtio-pci device * @index: the queue index * * Returns whether a virtqueue is enabled or not */ bool vp_modern_get_queue_enable(struct virtio_pci_modern_device *mdev, u16 index) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_set_queue_size - set size for a virtqueue * @mdev: the modern virtio-pci device * @index: the queue index * @size: the size of the virtqueue */ void vp_modern_set_queue_size(struct virtio_pci_modern_device *mdev, u16 index, u16 size) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_queue_size - get size for a virtqueue * @mdev: the modern virtio-pci device * @index: the queue index * * Returns the size of the virtqueue */ u16 vp_modern_get_queue_size(struct virtio_pci_modern_device *mdev, u16 index) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_num_queues - get the number of virtqueues * @mdev: the modern virtio-pci device * * Returns the number of virtqueues */ u16 vp_modern_get_num_queues(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); /* * vp_modern_get_queue_notify_off - get notification offset for a virtqueue * @mdev: the modern virtio-pci device * @index: the queue index * * Returns the notification offset for a virtqueue */ static u16 vp_modern_get_queue_notify_off(struct virtio_pci_modern_device *mdev, u16 index) { … } /* * vp_modern_map_vq_notify - map notification area for a * specific virtqueue * @mdev: the modern virtio-pci device * @index: the queue index * @pa: the pointer to the physical address of the nofity area * * Returns the address of the notification area */ void __iomem *vp_modern_map_vq_notify(struct virtio_pci_modern_device *mdev, u16 index, resource_size_t *pa) { … } EXPORT_SYMBOL_GPL(…); u16 vp_modern_avq_num(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); u16 vp_modern_avq_index(struct virtio_pci_modern_device *mdev) { … } EXPORT_SYMBOL_GPL(…); MODULE_VERSION(…) …; MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;