From: Jianfeng Tan Date: Tue, 17 Jan 2017 07:10:24 +0000 (+0000) Subject: net/virtio: add PCI operation for queue/irq binding X-Git-Tag: spdx-start~5153 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c49526acec773f51161ecf993e0a1926a6c4b1ef;p=dpdk.git net/virtio: add PCI operation for queue/irq binding Add handler in virtio_pci_ops to set queue/irq bind. Signed-off-by: Jianfeng Tan Tested-by: Lei Yao Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 040f1b5fee..8daeb95224 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -219,6 +219,19 @@ legacy_set_config_irq(struct virtio_hw *hw, uint16_t vec) return dst; } +static uint16_t +legacy_set_queue_irq(struct virtio_hw *hw, struct virtqueue *vq, uint16_t vec) +{ + uint16_t dst; + + rte_eal_pci_ioport_write(VTPCI_IO(hw), &vq->vq_queue_index, 2, + VIRTIO_PCI_QUEUE_SEL); + rte_eal_pci_ioport_write(VTPCI_IO(hw), &vec, 2, + VIRTIO_MSI_QUEUE_VECTOR); + rte_eal_pci_ioport_read(VTPCI_IO(hw), &dst, 2, VIRTIO_MSI_QUEUE_VECTOR); + return dst; +} + static uint16_t legacy_get_queue_num(struct virtio_hw *hw, uint16_t queue_id) { @@ -314,6 +327,7 @@ const struct virtio_pci_ops legacy_ops = { .set_features = legacy_set_features, .get_isr = legacy_get_isr, .set_config_irq = legacy_set_config_irq, + .set_queue_irq = legacy_set_queue_irq, .get_queue_num = legacy_get_queue_num, .setup_queue = legacy_setup_queue, .del_queue = legacy_del_queue, @@ -452,6 +466,14 @@ modern_set_config_irq(struct virtio_hw *hw, uint16_t vec) return io_read16(&hw->common_cfg->msix_config); } +static uint16_t +modern_set_queue_irq(struct virtio_hw *hw, struct virtqueue *vq, uint16_t vec) +{ + io_write16(vq->vq_queue_index, &hw->common_cfg->queue_select); + io_write16(vec, &hw->common_cfg->queue_msix_vector); + return io_read16(&hw->common_cfg->queue_msix_vector); +} + static uint16_t modern_get_queue_num(struct virtio_hw *hw, uint16_t queue_id) { @@ -530,6 +552,7 @@ const struct virtio_pci_ops modern_ops = { .set_features = modern_set_features, .get_isr = modern_get_isr, .set_config_irq = modern_set_config_irq, + .set_queue_irq = modern_set_queue_irq, .get_queue_num = modern_get_queue_num, .setup_queue = modern_setup_queue, .del_queue = modern_del_queue, diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index 588d41f365..59e45c4d33 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -235,6 +235,9 @@ struct virtio_pci_ops { uint16_t (*set_config_irq)(struct virtio_hw *hw, uint16_t vec); + uint16_t (*set_queue_irq)(struct virtio_hw *hw, struct virtqueue *vq, + uint16_t vec); + uint16_t (*get_queue_num)(struct virtio_hw *hw, uint16_t queue_id); int (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq); void (*del_queue)(struct virtio_hw *hw, struct virtqueue *vq);