28 size_t vdata_size =
num *
sizeof(
void *);
29 size_t queue_size = ring_size + vdata_size + header_size;
74 DBG(
"VIRTIO-PCI ERROR: queue size is 0\n");
81 DBG(
"VIRTIO-PCI ERROR: queue already active\n");
91 DBG(
"VIRTIO-PCI ERROR: failed to allocate queue memory\n");
106#define CFG_POS(vdev, field) \
107 (vdev->cfg_cap_pos + offsetof(struct virtio_pci_cfg_cap, field))
269 if (
type == cfg_type) {
291 DBG(
"VIRTIO-PCI bad capability len %d (>%d expected)\n",
length,
start);
295 DBG(
"VIRTIO-PCI bad capability len %d (>=%zd expected)\n",
length, minlen);
304 if (
offset & (align - 1)) {
305 DBG(
"VIRTIO-PCI offset %d not aligned to %d\n",
offset, align);
312 if (minlen +
offset < minlen ||
314 DBG(
"VIRTIO-PCI map virtio %zd@%d out of range on bar %i length %ld\n",
362 struct dma_device *dma_dev,
size_t header_size)
367 u32 notify_offset_multiplier;
377 notify_off_multiplier),
378 ¬ify_offset_multiplier);
380 for (i = 0; i < nvqs; i++) {
393 DBG(
"VIRTIO-PCI %p: bad queue size %d\n", vdev,
size);
413 DBG(
"VIRTIO-PCI %p: failed to allocate queue memory\n", vdev);
436 off * notify_offset_multiplier, 2,
446 for (i = 0; i < nvqs; i++) {
#define NULL
NULL pointer (VOID *)
struct arbelprm_rc_send_wqe rc
#define PAGE_SHIFT
Page shift.
#define assert(condition)
Assert a condition at run-time.
uint16_t offset
Offset to command line.
static unsigned long ioaddr
uint32_t type
Operating system type.
uint8_t data[48]
Additional event data.
#define DBG(...)
Print a debugging message.
uint32_t start
Starting offset.
uint16_t size
Buffer size.
#define ENOENT
No such file or directory.
#define EINVAL
Invalid argument.
#define ENOMEM
Not enough space.
#define le16_to_cpu(value)
#define le32_to_cpu(value)
#define cpu_to_le32(value)
#define cpu_to_le16(value)
#define outb(data, io_addr)
#define outw(data, io_addr)
#define outl(data, io_addr)
#define PAGE_MASK
Page mask.
void iounmap(volatile const void *io_addr)
Unmap I/O address.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
void * memset(void *dest, int character, size_t len) __nonnull
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
void * dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer.
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Get the size of a PCI BAR.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
#define PCI_BASE_ADDRESS_SPACE_IO
I/O BAR.
#define PCI_CAP_ID_VNDR
Vendor-specific.
#define PCI_BASE_ADDRESS(n)
PCI base address registers.
#define offsetof(type, field)
Get offset of a field within a structure.
struct virtio_pci_region common
struct virtio_net_hdr_modern * empty_header
struct virtio_pci_region notification
struct vring_avail * avail
u8 vpm_ioread8(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, size_t offset)
void vpm_iowrite32(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, u32 data, size_t offset)
void vp_free_vq(struct vring_virtqueue *vq)
#define CFG_POS(vdev, field)
void vpm_iowrite16(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, u16 data, size_t offset)
static void prep_pci_cfg_cap(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, size_t offset, u32 length)
int virtio_pci_map_capability(struct pci_device *pci, int cap, size_t minlen, u32 align, u32 start, u32 size, struct virtio_pci_region *region)
int vp_find_vq(unsigned int ioaddr, int queue_index, struct vring_virtqueue *vq, struct dma_device *dma_dev, size_t header_size)
void vpm_notify(struct virtio_pci_modern_device *vdev, struct vring_virtqueue *vq)
u32 vpm_ioread32(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, size_t offset)
void virtio_pci_unmap_capability(struct virtio_pci_region *region)
u16 vpm_ioread16(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, size_t offset)
static int vp_alloc_vq(struct vring_virtqueue *vq, u16 num, size_t header_size)
int virtio_pci_find_capability(struct pci_device *pci, uint8_t cfg_type)
int vpm_find_vqs(struct virtio_pci_modern_device *vdev, unsigned nvqs, struct vring_virtqueue *vqs, struct dma_device *dma_dev, size_t header_size)
void vpm_iowrite8(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, u8 data, size_t offset)
#define VIRTIO_PCI_REGION_TYPE_MASK
#define VIRTIO_PCI_QUEUE_NUM
#define VIRTIO_PCI_REGION_MEMORY
#define VIRTIO_PCI_QUEUE_SEL
#define VIRTIO_PCI_REGION_PCI_CONFIG
#define COMMON_OFFSET(field)
static void vpm_iowrite64(struct virtio_pci_modern_device *vdev, struct virtio_pci_region *region, u64 data, size_t offset_lo, size_t offset_hi)
#define VIRTIO_PCI_QUEUE_PFN
#define VIRTIO_PCI_REGION_PORT
static void vring_init(struct vring *vr, unsigned int num, unsigned char *queue)