Lines Matching +full:virtio +full:- +full:iommu
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel IFC VF NIC driver for virtio dataplane offloading
24 if (vf->config_cb.callback) in ifcvf_config_changed()
25 return vf->config_cb.callback(vf->config_cb.private); in ifcvf_config_changed()
34 if (vring->cb.callback) in ifcvf_vq_intr_handler()
35 return vring->cb.callback(vring->cb.private); in ifcvf_vq_intr_handler()
46 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_vqs_reused_intr_handler()
47 vring = &vf->vring[i]; in ifcvf_vqs_reused_intr_handler()
48 if (vring->cb.callback) in ifcvf_vqs_reused_intr_handler()
49 vring->cb.callback(vring->cb.private); in ifcvf_vqs_reused_intr_handler()
60 isr = vp_ioread8(vf->isr); in ifcvf_dev_intr_handler()
74 struct pci_dev *pdev = vf->pdev; in ifcvf_free_per_vq_irq()
77 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_free_per_vq_irq()
78 if (vf->vring[i].irq != -EINVAL) { in ifcvf_free_per_vq_irq()
79 devm_free_irq(&pdev->dev, vf->vring[i].irq, &vf->vring[i]); in ifcvf_free_per_vq_irq()
80 vf->vring[i].irq = -EINVAL; in ifcvf_free_per_vq_irq()
87 struct pci_dev *pdev = vf->pdev; in ifcvf_free_vqs_reused_irq()
89 if (vf->vqs_reused_irq != -EINVAL) { in ifcvf_free_vqs_reused_irq()
90 devm_free_irq(&pdev->dev, vf->vqs_reused_irq, vf); in ifcvf_free_vqs_reused_irq()
91 vf->vqs_reused_irq = -EINVAL; in ifcvf_free_vqs_reused_irq()
98 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) in ifcvf_free_vq_irq()
106 struct pci_dev *pdev = vf->pdev; in ifcvf_free_config_irq()
108 if (vf->config_irq == -EINVAL) in ifcvf_free_config_irq()
115 if (vf->msix_vector_status != MSIX_VECTOR_DEV_SHARED) { in ifcvf_free_config_irq()
116 devm_free_irq(&pdev->dev, vf->config_irq, vf); in ifcvf_free_config_irq()
117 vf->config_irq = -EINVAL; in ifcvf_free_config_irq()
123 struct pci_dev *pdev = vf->pdev; in ifcvf_free_irq()
128 vf->num_msix_vectors = 0; in ifcvf_free_irq()
138 struct pci_dev *pdev = vf->pdev; in ifcvf_alloc_vectors()
142 max_intr = vf->nr_vring + 1; in ifcvf_alloc_vectors()
160 struct pci_dev *pdev = vf->pdev; in ifcvf_request_per_vq_irq()
163 vf->vqs_reused_irq = -EINVAL; in ifcvf_request_per_vq_irq()
164 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_request_per_vq_irq()
165 snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n", pci_name(pdev), i); in ifcvf_request_per_vq_irq()
168 ret = devm_request_irq(&pdev->dev, irq, in ifcvf_request_per_vq_irq()
170 vf->vring[i].msix_name, in ifcvf_request_per_vq_irq()
171 &vf->vring[i]); in ifcvf_request_per_vq_irq()
177 vf->vring[i].irq = irq; in ifcvf_request_per_vq_irq()
189 return -EFAULT; in ifcvf_request_per_vq_irq()
194 struct pci_dev *pdev = vf->pdev; in ifcvf_request_vqs_reused_irq()
198 snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-vqs-reused-irq\n", pci_name(pdev)); in ifcvf_request_vqs_reused_irq()
200 ret = devm_request_irq(&pdev->dev, irq, in ifcvf_request_vqs_reused_irq()
202 vf->vring[0].msix_name, vf); in ifcvf_request_vqs_reused_irq()
208 vf->vqs_reused_irq = irq; in ifcvf_request_vqs_reused_irq()
209 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_request_vqs_reused_irq()
210 vf->vring[i].irq = -EINVAL; in ifcvf_request_vqs_reused_irq()
222 return -EFAULT; in ifcvf_request_vqs_reused_irq()
227 struct pci_dev *pdev = vf->pdev; in ifcvf_request_dev_irq()
231 snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-dev-irq\n", pci_name(pdev)); in ifcvf_request_dev_irq()
233 ret = devm_request_irq(&pdev->dev, irq, in ifcvf_request_dev_irq()
235 vf->vring[0].msix_name, vf); in ifcvf_request_dev_irq()
241 vf->vqs_reused_irq = irq; in ifcvf_request_dev_irq()
242 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_request_dev_irq()
243 vf->vring[i].irq = -EINVAL; in ifcvf_request_dev_irq()
251 vf->config_irq = irq; in ifcvf_request_dev_irq()
262 return -EFAULT; in ifcvf_request_dev_irq()
270 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) in ifcvf_request_vq_irq()
280 struct pci_dev *pdev = vf->pdev; in ifcvf_request_config_irq()
283 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) in ifcvf_request_config_irq()
284 config_vector = vf->nr_vring; in ifcvf_request_config_irq()
285 else if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG) in ifcvf_request_config_irq()
288 else if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED) in ifcvf_request_config_irq()
289 /* re-use the vqs vector */ in ifcvf_request_config_irq()
292 return -EINVAL; in ifcvf_request_config_irq()
294 snprintf(vf->config_msix_name, 256, "ifcvf[%s]-config\n", in ifcvf_request_config_irq()
296 vf->config_irq = pci_irq_vector(pdev, config_vector); in ifcvf_request_config_irq()
297 ret = devm_request_irq(&pdev->dev, vf->config_irq, in ifcvf_request_config_irq()
299 vf->config_msix_name, vf); in ifcvf_request_config_irq()
315 return -EFAULT; in ifcvf_request_config_irq()
324 return -EFAULT; in ifcvf_request_irq()
326 vf->msix_vector_status = MSIX_VECTOR_PER_VQ_AND_CONFIG; in ifcvf_request_irq()
327 max_intr = vf->nr_vring + 1; in ifcvf_request_irq()
329 vf->msix_vector_status = MSIX_VECTOR_SHARED_VQ_AND_CONFIG; in ifcvf_request_irq()
332 vf->msix_vector_status = MSIX_VECTOR_DEV_SHARED; in ifcvf_request_irq()
347 vf->num_msix_vectors = nvectors; in ifcvf_request_irq()
361 return adapter->vf; in vdpa_to_vf()
368 struct pci_dev *pdev = adapter->pdev; in ifcvf_vdpa_get_device_features()
369 u32 type = vf->dev_type; in ifcvf_vdpa_get_device_features()
376 IFCVF_ERR(pdev, "VIRTIO ID %u not supported\n", vf->dev_type); in ifcvf_vdpa_get_device_features()
429 IFCVF_ERR(vf->pdev, "failed to request irq with error %d\n", ret); in ifcvf_vdpa_set_status()
469 state->split.avail_index = ifcvf_get_vq_state(vf, qid); in ifcvf_vdpa_get_vq_state()
478 return ifcvf_set_vq_state(vf, qid, state->split.avail_index); in ifcvf_vdpa_set_vq_state()
486 vf->vring[qid].cb = *cb; in ifcvf_vdpa_set_vq_cb()
532 return vp_ioread8(&vf->common_cfg->config_generation); in ifcvf_vdpa_get_generation()
539 return vf->dev_type; in ifcvf_vdpa_get_device_id()
545 struct pci_dev *pdev = adapter->pdev; in ifcvf_vdpa_get_vendor_id()
547 return pdev->subsystem_vendor; in ifcvf_vdpa_get_vendor_id()
559 return vf->config_size; in ifcvf_vdpa_get_config_size()
590 vf->config_cb.callback = cb->callback; in ifcvf_vdpa_set_config_cb()
591 vf->config_cb.private = cb->private; in ifcvf_vdpa_set_config_cb()
599 if (vf->vqs_reused_irq < 0) in ifcvf_vdpa_get_vq_irq()
600 return vf->vring[qid].irq; in ifcvf_vdpa_get_vq_irq()
602 return -EINVAL; in ifcvf_vdpa_get_vq_irq()
619 area.addr = vf->vring[idx].notify_pa; in ifcvf_get_vq_notification()
620 if (!vf->notify_off_multiplier) in ifcvf_get_vq_notification()
623 area.size = vf->notify_off_multiplier; in ifcvf_get_vq_notification()
629 * IFCVF currently doesn't have on-chip IOMMU, so not
677 /* This drirver drives both modern virtio devices and transitional in get_dev_type()
685 if (pdev->device < 0x1040) in get_dev_type()
686 dev_type = pdev->subsystem_device; in get_dev_type()
688 dev_type = pdev->device - 0x1040; in get_dev_type()
705 vf = &ifcvf_mgmt_dev->vf; in ifcvf_vdpa_dev_add()
706 pdev = vf->pdev; in ifcvf_vdpa_dev_add()
708 &pdev->dev, &ifc_vdpa_ops, 1, 1, NULL, false); in ifcvf_vdpa_dev_add()
714 ifcvf_mgmt_dev->adapter = adapter; in ifcvf_vdpa_dev_add()
715 adapter->pdev = pdev; in ifcvf_vdpa_dev_add()
716 adapter->vdpa.dma_dev = &pdev->dev; in ifcvf_vdpa_dev_add()
717 adapter->vdpa.mdev = mdev; in ifcvf_vdpa_dev_add()
718 adapter->vf = vf; in ifcvf_vdpa_dev_add()
719 vdpa_dev = &adapter->vdpa; in ifcvf_vdpa_dev_add()
721 device_features = vf->hw_features; in ifcvf_vdpa_dev_add()
722 if (config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) { in ifcvf_vdpa_dev_add()
723 if (config->device_features & ~device_features) { in ifcvf_vdpa_dev_add()
725 config->device_features, device_features); in ifcvf_vdpa_dev_add()
726 return -EINVAL; in ifcvf_vdpa_dev_add()
728 device_features &= config->device_features; in ifcvf_vdpa_dev_add()
730 vf->dev_features = device_features; in ifcvf_vdpa_dev_add()
733 ret = dev_set_name(&vdpa_dev->dev, "%s", name); in ifcvf_vdpa_dev_add()
735 ret = dev_set_name(&vdpa_dev->dev, "vdpa%u", vdpa_dev->index); in ifcvf_vdpa_dev_add()
737 ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring); in ifcvf_vdpa_dev_add()
739 put_device(&adapter->vdpa.dev); in ifcvf_vdpa_dev_add()
753 ifcvf_mgmt_dev->adapter = NULL; in ifcvf_vdpa_dev_del()
764 struct device *dev = &pdev->dev; in ifcvf_probe()
798 return -ENOMEM; in ifcvf_probe()
801 vf = &ifcvf_mgmt_dev->vf; in ifcvf_probe()
802 vf->dev_type = get_dev_type(pdev); in ifcvf_probe()
803 vf->base = pcim_iomap_table(pdev); in ifcvf_probe()
804 vf->pdev = pdev; in ifcvf_probe()
812 for (i = 0; i < vf->nr_vring; i++) in ifcvf_probe()
813 vf->vring[i].irq = -EINVAL; in ifcvf_probe()
815 vf->hw_features = ifcvf_get_hw_features(vf); in ifcvf_probe()
816 vf->config_size = ifcvf_get_config_size(vf); in ifcvf_probe()
821 ifcvf_mgmt_dev->mdev.id_table = id_table_net; in ifcvf_probe()
824 ifcvf_mgmt_dev->mdev.id_table = id_table_blk; in ifcvf_probe()
827 IFCVF_ERR(pdev, "VIRTIO ID %u not supported\n", dev_type); in ifcvf_probe()
828 ret = -EOPNOTSUPP; in ifcvf_probe()
832 ifcvf_mgmt_dev->mdev.ops = &ifcvf_vdpa_mgmt_dev_ops; in ifcvf_probe()
833 ifcvf_mgmt_dev->mdev.device = dev; in ifcvf_probe()
834 ifcvf_mgmt_dev->mdev.max_supported_vqs = vf->nr_vring; in ifcvf_probe()
835 ifcvf_mgmt_dev->mdev.supported_features = vf->hw_features; in ifcvf_probe()
836 ifcvf_mgmt_dev->mdev.config_attr_mask = (1 << VDPA_ATTR_DEV_FEATURES); in ifcvf_probe()
838 ret = vdpa_mgmtdev_register(&ifcvf_mgmt_dev->mdev); in ifcvf_probe()
850 kfree(ifcvf_mgmt_dev->vf.vring); in ifcvf_probe()
860 vdpa_mgmtdev_unregister(&ifcvf_mgmt_dev->mdev); in ifcvf_remove()
861 kfree(ifcvf_mgmt_dev->vf.vring); in ifcvf_remove()
871 /* C5000X-PL network device
872 * F2000X-PL network device
878 /* C5000X-PL block device */
897 MODULE_DESCRIPTION("Intel IFC VF NIC driver for virtio dataplane offloading");