Lines Matching refs:vf

22 	struct ifcvf_hw *vf = arg;  in ifcvf_config_changed()  local
24 if (vf->config_cb.callback) in ifcvf_config_changed()
25 return vf->config_cb.callback(vf->config_cb.private); in ifcvf_config_changed()
42 struct ifcvf_hw *vf = arg; in ifcvf_vqs_reused_intr_handler() local
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()
57 struct ifcvf_hw *vf = arg; in ifcvf_dev_intr_handler() local
60 isr = vp_ioread8(vf->isr); in ifcvf_dev_intr_handler()
72 static void ifcvf_free_per_vq_irq(struct ifcvf_hw *vf) in ifcvf_free_per_vq_irq() argument
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()
85 static void ifcvf_free_vqs_reused_irq(struct ifcvf_hw *vf) in ifcvf_free_vqs_reused_irq() argument
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()
96 static void ifcvf_free_vq_irq(struct ifcvf_hw *vf) in ifcvf_free_vq_irq() argument
98 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) in ifcvf_free_vq_irq()
99 ifcvf_free_per_vq_irq(vf); in ifcvf_free_vq_irq()
101 ifcvf_free_vqs_reused_irq(vf); in ifcvf_free_vq_irq()
104 static void ifcvf_free_config_irq(struct ifcvf_hw *vf) in ifcvf_free_config_irq() argument
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()
121 static void ifcvf_free_irq(struct ifcvf_hw *vf) in ifcvf_free_irq() argument
123 struct pci_dev *pdev = vf->pdev; in ifcvf_free_irq()
125 ifcvf_free_vq_irq(vf); in ifcvf_free_irq()
126 ifcvf_free_config_irq(vf); in ifcvf_free_irq()
128 vf->num_msix_vectors = 0; in ifcvf_free_irq()
136 static int ifcvf_alloc_vectors(struct ifcvf_hw *vf) in ifcvf_alloc_vectors() argument
138 struct pci_dev *pdev = vf->pdev; in ifcvf_alloc_vectors()
142 max_intr = vf->nr_vring + 1; in ifcvf_alloc_vectors()
158 static int ifcvf_request_per_vq_irq(struct ifcvf_hw *vf) in ifcvf_request_per_vq_irq() argument
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()
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()
178 ret = ifcvf_set_vq_vector(vf, i, vector); in ifcvf_request_per_vq_irq()
187 ifcvf_free_irq(vf); in ifcvf_request_per_vq_irq()
192 static int ifcvf_request_vqs_reused_irq(struct ifcvf_hw *vf) in ifcvf_request_vqs_reused_irq() argument
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()
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()
211 ret = ifcvf_set_vq_vector(vf, i, vector); in ifcvf_request_vqs_reused_irq()
220 ifcvf_free_irq(vf); in ifcvf_request_vqs_reused_irq()
225 static int ifcvf_request_dev_irq(struct ifcvf_hw *vf) in ifcvf_request_dev_irq() argument
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()
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()
244 ret = ifcvf_set_vq_vector(vf, i, vector); in ifcvf_request_dev_irq()
251 vf->config_irq = irq; in ifcvf_request_dev_irq()
252 ret = ifcvf_set_config_vector(vf, vector); in ifcvf_request_dev_irq()
260 ifcvf_free_irq(vf); in ifcvf_request_dev_irq()
266 static int ifcvf_request_vq_irq(struct ifcvf_hw *vf) in ifcvf_request_vq_irq() argument
270 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) in ifcvf_request_vq_irq()
271 ret = ifcvf_request_per_vq_irq(vf); in ifcvf_request_vq_irq()
273 ret = ifcvf_request_vqs_reused_irq(vf); in ifcvf_request_vq_irq()
278 static int ifcvf_request_config_irq(struct ifcvf_hw *vf) in ifcvf_request_config_irq() argument
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()
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()
305 ret = ifcvf_set_config_vector(vf, config_vector); in ifcvf_request_config_irq()
313 ifcvf_free_irq(vf); in ifcvf_request_config_irq()
318 static int ifcvf_request_irq(struct ifcvf_hw *vf) in ifcvf_request_irq() argument
322 nvectors = ifcvf_alloc_vectors(vf); 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()
333 ret = ifcvf_request_dev_irq(vf); in ifcvf_request_irq()
338 ret = ifcvf_request_vq_irq(vf); in ifcvf_request_irq()
342 ret = ifcvf_request_config_irq(vf); in ifcvf_request_irq()
347 vf->num_msix_vectors = nvectors; in ifcvf_request_irq()
361 return adapter->vf; in vdpa_to_vf()
367 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_device_features() local
369 u32 type = vf->dev_type; in ifcvf_vdpa_get_device_features()
373 features = ifcvf_get_dev_features(vf); 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()
384 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_driver_features() local
387 ret = ifcvf_verify_min_features(vf, features); in ifcvf_vdpa_set_driver_features()
391 ifcvf_set_driver_features(vf, features); in ifcvf_vdpa_set_driver_features()
398 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_driver_features() local
401 features = ifcvf_get_driver_features(vf); in ifcvf_vdpa_get_driver_features()
408 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_status() local
410 return ifcvf_get_status(vf); in ifcvf_vdpa_get_status()
415 struct ifcvf_hw *vf; in ifcvf_vdpa_set_status() local
419 vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_status()
420 status_old = ifcvf_get_status(vf); in ifcvf_vdpa_set_status()
427 ret = ifcvf_request_irq(vf); in ifcvf_vdpa_set_status()
429 IFCVF_ERR(vf->pdev, "failed to request irq with error %d\n", ret); in ifcvf_vdpa_set_status()
434 ifcvf_set_status(vf, status); in ifcvf_vdpa_set_status()
439 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_reset() local
440 u8 status = ifcvf_get_status(vf); in ifcvf_vdpa_reset()
442 ifcvf_stop(vf); in ifcvf_vdpa_reset()
445 ifcvf_free_irq(vf); in ifcvf_vdpa_reset()
447 ifcvf_reset(vf); in ifcvf_vdpa_reset()
454 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_num_max() local
456 return ifcvf_get_max_vq_size(vf); in ifcvf_vdpa_get_vq_num_max()
467 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_state() local
469 state->split.avail_index = ifcvf_get_vq_state(vf, qid); in ifcvf_vdpa_get_vq_state()
476 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_state() local
478 return ifcvf_set_vq_state(vf, qid, state->split.avail_index); in ifcvf_vdpa_set_vq_state()
484 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_cb() local
486 vf->vring[qid].cb = *cb; in ifcvf_vdpa_set_vq_cb()
492 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_ready() local
494 ifcvf_set_vq_ready(vf, qid, ready); in ifcvf_vdpa_set_vq_ready()
499 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_ready() local
501 return ifcvf_get_vq_ready(vf, qid); in ifcvf_vdpa_get_vq_ready()
507 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_num() local
509 ifcvf_set_vq_num(vf, qid, num); in ifcvf_vdpa_set_vq_num()
516 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_address() local
518 return ifcvf_set_vq_address(vf, qid, desc_area, driver_area, device_area); in ifcvf_vdpa_set_vq_address()
523 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_kick_vq() local
525 ifcvf_notify_queue(vf, qid); in ifcvf_vdpa_kick_vq()
530 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_generation() local
532 return vp_ioread8(&vf->common_cfg->config_generation); in ifcvf_vdpa_get_generation()
537 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_device_id() local
539 return vf->dev_type; in ifcvf_vdpa_get_device_id()
557 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_config_size() local
559 return vf->config_size; in ifcvf_vdpa_get_config_size()
571 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_config() local
573 ifcvf_read_dev_config(vf, offset, buf, len); in ifcvf_vdpa_get_config()
580 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_config() local
582 ifcvf_write_dev_config(vf, offset, buf, len); in ifcvf_vdpa_set_config()
588 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_config_cb() local
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()
597 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_irq() local
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()
608 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_size() local
610 return ifcvf_get_vq_size(vf, qid); in ifcvf_vdpa_get_vq_size()
616 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_get_vq_notification() local
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()
700 struct ifcvf_hw *vf; in ifcvf_vdpa_dev_add() local
705 vf = &ifcvf_mgmt_dev->vf; in ifcvf_vdpa_dev_add()
706 pdev = vf->pdev; in ifcvf_vdpa_dev_add()
718 adapter->vf = vf; in ifcvf_vdpa_dev_add()
721 device_features = vf->hw_features; in ifcvf_vdpa_dev_add()
730 vf->dev_features = device_features; in ifcvf_vdpa_dev_add()
737 ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring); in ifcvf_vdpa_dev_add()
765 struct ifcvf_hw *vf; in ifcvf_probe() local
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()
806 ret = ifcvf_init_hw(vf, 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()
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()
850 kfree(ifcvf_mgmt_dev->vf.vring); in ifcvf_probe()
861 kfree(ifcvf_mgmt_dev->vf.vring); in ifcvf_remove()