Lines Matching +full:num +full:- +full:vectors

1 // SPDX-License-Identifier: GPL-2.0-only
25 dev_err(&pdev->dev, "%s"fmt, "eni_vdpa: ", ##__VA_ARGS__)
27 dev_dbg(&pdev->dev, "%s"fmt, "eni_vdpa: ", ##__VA_ARGS__)
29 dev_info(&pdev->dev, "%s"fmt, "eni_vdpa: ", ##__VA_ARGS__)
46 int vectors; member
58 return &eni_vdpa->ldev; in vdpa_to_ldev()
77 ENI_ERR(ldev->pci_dev, in eni_vdpa_set_driver_features()
79 return -EINVAL; in eni_vdpa_set_driver_features()
104 int irq = eni_vdpa->vring[idx].irq; in eni_vdpa_get_vq_irq()
107 return -EINVAL; in eni_vdpa_get_vq_irq()
114 struct virtio_pci_legacy_device *ldev = &eni_vdpa->ldev; in eni_vdpa_free_irq()
115 struct pci_dev *pdev = ldev->pci_dev; in eni_vdpa_free_irq()
118 for (i = 0; i < eni_vdpa->queues; i++) { in eni_vdpa_free_irq()
119 if (eni_vdpa->vring[i].irq != VIRTIO_MSI_NO_VECTOR) { in eni_vdpa_free_irq()
121 devm_free_irq(&pdev->dev, eni_vdpa->vring[i].irq, in eni_vdpa_free_irq()
122 &eni_vdpa->vring[i]); in eni_vdpa_free_irq()
123 eni_vdpa->vring[i].irq = VIRTIO_MSI_NO_VECTOR; in eni_vdpa_free_irq()
127 if (eni_vdpa->config_irq != VIRTIO_MSI_NO_VECTOR) { in eni_vdpa_free_irq()
129 devm_free_irq(&pdev->dev, eni_vdpa->config_irq, eni_vdpa); in eni_vdpa_free_irq()
130 eni_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR; in eni_vdpa_free_irq()
133 if (eni_vdpa->vectors) { in eni_vdpa_free_irq()
135 eni_vdpa->vectors = 0; in eni_vdpa_free_irq()
143 if (vring->cb.callback) in eni_vdpa_vq_handler()
144 return vring->cb.callback(vring->cb.private); in eni_vdpa_vq_handler()
153 if (eni_vdpa->config_cb.callback) in eni_vdpa_config_handler()
154 return eni_vdpa->config_cb.callback(eni_vdpa->config_cb.private); in eni_vdpa_config_handler()
161 struct virtio_pci_legacy_device *ldev = &eni_vdpa->ldev; in eni_vdpa_request_irq()
162 struct pci_dev *pdev = ldev->pci_dev; in eni_vdpa_request_irq()
164 int queues = eni_vdpa->queues; in eni_vdpa_request_irq()
165 int vectors = queues + 1; in eni_vdpa_request_irq() local
167 ret = pci_alloc_irq_vectors(pdev, vectors, vectors, PCI_IRQ_MSIX); in eni_vdpa_request_irq()
168 if (ret != vectors) { in eni_vdpa_request_irq()
170 "failed to allocate irq vectors want %d but %d\n", in eni_vdpa_request_irq()
171 vectors, ret); in eni_vdpa_request_irq()
175 eni_vdpa->vectors = vectors; in eni_vdpa_request_irq()
178 snprintf(eni_vdpa->vring[i].msix_name, ENI_MSIX_NAME_SIZE, in eni_vdpa_request_irq()
179 "eni-vdpa[%s]-%d\n", pci_name(pdev), i); in eni_vdpa_request_irq()
181 ret = devm_request_irq(&pdev->dev, irq, in eni_vdpa_request_irq()
183 0, eni_vdpa->vring[i].msix_name, in eni_vdpa_request_irq()
184 &eni_vdpa->vring[i]); in eni_vdpa_request_irq()
190 eni_vdpa->vring[i].irq = irq; in eni_vdpa_request_irq()
193 snprintf(eni_vdpa->msix_name, ENI_MSIX_NAME_SIZE, "eni-vdpa[%s]-config\n", in eni_vdpa_request_irq()
196 ret = devm_request_irq(&pdev->dev, irq, eni_vdpa_config_handler, 0, in eni_vdpa_request_irq()
197 eni_vdpa->msix_name, eni_vdpa); in eni_vdpa_request_irq()
203 eni_vdpa->config_irq = irq; in eni_vdpa_request_irq()
214 struct virtio_pci_legacy_device *ldev = &eni_vdpa->ldev; in eni_vdpa_set_status()
232 struct virtio_pci_legacy_device *ldev = &eni_vdpa->ldev; in eni_vdpa_reset()
267 return -EOPNOTSUPP; in eni_vdpa_get_vq_state()
274 const struct vdpa_vq_state_split *split = &state->split; in eni_vdpa_set_vq_state()
276 /* ENI is build upon virtio-pci specfication which not support in eni_vdpa_set_vq_state()
281 && split->avail_index == 0) in eni_vdpa_set_vq_state()
284 return -EOPNOTSUPP; in eni_vdpa_set_vq_state()
293 eni_vdpa->vring[qid].cb = *cb; in eni_vdpa_set_vq_cb()
301 /* ENI is a legacy virtio-pci device. This is not supported in eni_vdpa_set_vq_ready()
317 u32 num) in eni_vdpa_set_vq_num() argument
320 struct pci_dev *pdev = ldev->pci_dev; in eni_vdpa_set_vq_num()
323 /* ENI is a legacy virtio-pci device which not allow to change in eni_vdpa_set_vq_num()
327 if (num != n) in eni_vdpa_set_vq_num()
329 "not support to set vq %u fixed num %u to %u\n", in eni_vdpa_set_vq_num()
330 qid, n, num); in eni_vdpa_set_vq_num()
349 iowrite16(qid, eni_vdpa->vring[qid].notify); in eni_vdpa_kick_vq()
356 return ldev->id.device; in eni_vdpa_get_device_id()
363 return ldev->id.vendor; in eni_vdpa_get_vendor_id()
382 struct virtio_pci_legacy_device *ldev = &eni_vdpa->ldev; in eni_vdpa_get_config()
383 void __iomem *ioaddr = ldev->ioaddr + in eni_vdpa_get_config()
384 VIRTIO_PCI_CONFIG_OFF(eni_vdpa->vectors) + in eni_vdpa_get_config()
398 struct virtio_pci_legacy_device *ldev = &eni_vdpa->ldev; in eni_vdpa_set_config()
399 void __iomem *ioaddr = ldev->ioaddr + in eni_vdpa_set_config()
400 VIRTIO_PCI_CONFIG_OFF(eni_vdpa->vectors) + in eni_vdpa_set_config()
414 eni_vdpa->config_cb = *cb; in eni_vdpa_set_config_cb()
448 struct virtio_pci_legacy_device *ldev = &eni_vdpa->ldev; in eni_vdpa_get_num_queues()
450 u16 num = 2; in eni_vdpa_get_num_queues() local
455 eni_vdpa_get_config(&eni_vdpa->vdpa, in eni_vdpa_get_num_queues()
459 num = 2 * __virtio16_to_cpu(virtio_legacy_is_little_endian(), in eni_vdpa_get_num_queues()
464 num += 1; in eni_vdpa_get_num_queues()
466 return num; in eni_vdpa_get_num_queues()
471 struct device *dev = &pdev->dev; in eni_vdpa_probe()
487 ldev = &eni_vdpa->ldev; in eni_vdpa_probe()
488 ldev->pci_dev = pdev; in eni_vdpa_probe()
499 eni_vdpa->vdpa.dma_dev = &pdev->dev; in eni_vdpa_probe()
500 eni_vdpa->queues = eni_vdpa_get_num_queues(eni_vdpa); in eni_vdpa_probe()
502 eni_vdpa->vring = devm_kcalloc(&pdev->dev, eni_vdpa->queues, in eni_vdpa_probe()
503 sizeof(*eni_vdpa->vring), in eni_vdpa_probe()
505 if (!eni_vdpa->vring) { in eni_vdpa_probe()
506 ret = -ENOMEM; in eni_vdpa_probe()
511 for (i = 0; i < eni_vdpa->queues; i++) { in eni_vdpa_probe()
512 eni_vdpa->vring[i].irq = VIRTIO_MSI_NO_VECTOR; in eni_vdpa_probe()
513 eni_vdpa->vring[i].notify = ldev->ioaddr + VIRTIO_PCI_QUEUE_NOTIFY; in eni_vdpa_probe()
515 eni_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR; in eni_vdpa_probe()
517 ret = vdpa_register_device(&eni_vdpa->vdpa, eni_vdpa->queues); in eni_vdpa_probe()
526 vp_legacy_remove(&eni_vdpa->ldev); in eni_vdpa_probe()
528 put_device(&eni_vdpa->vdpa.dev); in eni_vdpa_probe()
536 vdpa_unregister_device(&eni_vdpa->vdpa); in eni_vdpa_remove()
537 vp_legacy_remove(&eni_vdpa->ldev); in eni_vdpa_remove()
549 .name = "alibaba-eni-vdpa",