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()
135 static int ifcvf_alloc_vectors(struct ifcvf_hw *vf) in ifcvf_alloc_vectors() argument
137 struct pci_dev *pdev = vf->pdev; in ifcvf_alloc_vectors()
141 max_intr = vf->nr_vring + 1; in ifcvf_alloc_vectors()
157 static int ifcvf_request_per_vq_irq(struct ifcvf_hw *vf) in ifcvf_request_per_vq_irq() argument
159 struct pci_dev *pdev = vf->pdev; in ifcvf_request_per_vq_irq()
162 vf->vqs_reused_irq = -EINVAL; in ifcvf_request_per_vq_irq()
163 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_request_per_vq_irq()
164 snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n", pci_name(pdev), i); in ifcvf_request_per_vq_irq()
169 vf->vring[i].msix_name, in ifcvf_request_per_vq_irq()
170 &vf->vring[i]); in ifcvf_request_per_vq_irq()
176 vf->vring[i].irq = irq; in ifcvf_request_per_vq_irq()
177 ret = ifcvf_set_vq_vector(vf, i, vector); in ifcvf_request_per_vq_irq()
186 ifcvf_free_irq(vf); in ifcvf_request_per_vq_irq()
191 static int ifcvf_request_vqs_reused_irq(struct ifcvf_hw *vf) in ifcvf_request_vqs_reused_irq() argument
193 struct pci_dev *pdev = vf->pdev; in ifcvf_request_vqs_reused_irq()
197 snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-vqs-reused-irq\n", pci_name(pdev)); in ifcvf_request_vqs_reused_irq()
201 vf->vring[0].msix_name, vf); in ifcvf_request_vqs_reused_irq()
207 vf->vqs_reused_irq = irq; in ifcvf_request_vqs_reused_irq()
208 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_request_vqs_reused_irq()
209 vf->vring[i].irq = -EINVAL; in ifcvf_request_vqs_reused_irq()
210 ret = ifcvf_set_vq_vector(vf, i, vector); in ifcvf_request_vqs_reused_irq()
219 ifcvf_free_irq(vf); in ifcvf_request_vqs_reused_irq()
224 static int ifcvf_request_dev_irq(struct ifcvf_hw *vf) in ifcvf_request_dev_irq() argument
226 struct pci_dev *pdev = vf->pdev; in ifcvf_request_dev_irq()
230 snprintf(vf->vring[0].msix_name, 256, "ifcvf[%s]-dev-irq\n", pci_name(pdev)); in ifcvf_request_dev_irq()
234 vf->vring[0].msix_name, vf); in ifcvf_request_dev_irq()
240 vf->vqs_reused_irq = irq; in ifcvf_request_dev_irq()
241 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_request_dev_irq()
242 vf->vring[i].irq = -EINVAL; in ifcvf_request_dev_irq()
243 ret = ifcvf_set_vq_vector(vf, i, vector); in ifcvf_request_dev_irq()
250 vf->config_irq = irq; in ifcvf_request_dev_irq()
251 ret = ifcvf_set_config_vector(vf, vector); in ifcvf_request_dev_irq()
259 ifcvf_free_irq(vf); in ifcvf_request_dev_irq()
265 static int ifcvf_request_vq_irq(struct ifcvf_hw *vf) in ifcvf_request_vq_irq() argument
269 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) in ifcvf_request_vq_irq()
270 ret = ifcvf_request_per_vq_irq(vf); in ifcvf_request_vq_irq()
272 ret = ifcvf_request_vqs_reused_irq(vf); in ifcvf_request_vq_irq()
277 static int ifcvf_request_config_irq(struct ifcvf_hw *vf) in ifcvf_request_config_irq() argument
279 struct pci_dev *pdev = vf->pdev; in ifcvf_request_config_irq()
282 if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) in ifcvf_request_config_irq()
283 config_vector = vf->nr_vring; in ifcvf_request_config_irq()
284 else if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG) in ifcvf_request_config_irq()
287 else if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED) in ifcvf_request_config_irq()
293 snprintf(vf->config_msix_name, 256, "ifcvf[%s]-config\n", in ifcvf_request_config_irq()
295 vf->config_irq = pci_irq_vector(pdev, config_vector); in ifcvf_request_config_irq()
296 ret = devm_request_irq(&pdev->dev, vf->config_irq, in ifcvf_request_config_irq()
298 vf->config_msix_name, vf); in ifcvf_request_config_irq()
304 ret = ifcvf_set_config_vector(vf, config_vector); in ifcvf_request_config_irq()
312 ifcvf_free_irq(vf); in ifcvf_request_config_irq()
317 static int ifcvf_request_irq(struct ifcvf_hw *vf) in ifcvf_request_irq() argument
321 nvectors = ifcvf_alloc_vectors(vf); in ifcvf_request_irq()
325 vf->msix_vector_status = MSIX_VECTOR_PER_VQ_AND_CONFIG; in ifcvf_request_irq()
326 max_intr = vf->nr_vring + 1; in ifcvf_request_irq()
328 vf->msix_vector_status = MSIX_VECTOR_SHARED_VQ_AND_CONFIG; in ifcvf_request_irq()
331 vf->msix_vector_status = MSIX_VECTOR_DEV_SHARED; in ifcvf_request_irq()
332 ret = ifcvf_request_dev_irq(vf); in ifcvf_request_irq()
337 ret = ifcvf_request_vq_irq(vf); in ifcvf_request_irq()
341 ret = ifcvf_request_config_irq(vf); in ifcvf_request_irq()
351 struct ifcvf_hw *vf = adapter->vf; in ifcvf_start_datapath() local
355 ret = ifcvf_start_hw(vf); in ifcvf_start_datapath()
357 status = ifcvf_get_status(vf); in ifcvf_start_datapath()
359 ifcvf_set_status(vf, status); in ifcvf_start_datapath()
367 struct ifcvf_hw *vf = adapter->vf; in ifcvf_stop_datapath() local
370 for (i = 0; i < vf->nr_vring; i++) in ifcvf_stop_datapath()
371 vf->vring[i].cb.callback = NULL; in ifcvf_stop_datapath()
373 ifcvf_stop_hw(vf); in ifcvf_stop_datapath()
380 struct ifcvf_hw *vf = adapter->vf; in ifcvf_reset_vring() local
383 for (i = 0; i < vf->nr_vring; i++) { in ifcvf_reset_vring()
384 vf->vring[i].last_avail_idx = 0; in ifcvf_reset_vring()
385 vf->vring[i].desc = 0; in ifcvf_reset_vring()
386 vf->vring[i].avail = 0; in ifcvf_reset_vring()
387 vf->vring[i].used = 0; in ifcvf_reset_vring()
388 vf->vring[i].ready = 0; in ifcvf_reset_vring()
389 vf->vring[i].cb.callback = NULL; in ifcvf_reset_vring()
390 vf->vring[i].cb.private = NULL; in ifcvf_reset_vring()
393 ifcvf_reset(vf); in ifcvf_reset_vring()
405 return adapter->vf; in vdpa_to_vf()
411 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_device_features() local
413 u32 type = vf->dev_type; in ifcvf_vdpa_get_device_features()
417 features = ifcvf_get_features(vf); in ifcvf_vdpa_get_device_features()
420 IFCVF_ERR(pdev, "VIRTIO ID %u not supported\n", vf->dev_type); in ifcvf_vdpa_get_device_features()
428 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_driver_features() local
431 ret = ifcvf_verify_min_features(vf, features); in ifcvf_vdpa_set_driver_features()
435 vf->req_features = features; in ifcvf_vdpa_set_driver_features()
442 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_driver_features() local
444 return vf->req_features; in ifcvf_vdpa_get_driver_features()
449 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_status() local
451 return ifcvf_get_status(vf); in ifcvf_vdpa_get_status()
457 struct ifcvf_hw *vf; in ifcvf_vdpa_set_status() local
461 vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_status()
463 status_old = ifcvf_get_status(vf); in ifcvf_vdpa_set_status()
470 ret = ifcvf_request_irq(vf); in ifcvf_vdpa_set_status()
472 status = ifcvf_get_status(vf); in ifcvf_vdpa_set_status()
474 ifcvf_set_status(vf, status); in ifcvf_vdpa_set_status()
484 ifcvf_set_status(vf, status); in ifcvf_vdpa_set_status()
490 struct ifcvf_hw *vf; in ifcvf_vdpa_reset() local
493 vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_reset()
495 status_old = ifcvf_get_status(vf); in ifcvf_vdpa_reset()
502 ifcvf_free_irq(vf); in ifcvf_vdpa_reset()
518 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_state() local
520 state->split.avail_index = ifcvf_get_vq_state(vf, qid); in ifcvf_vdpa_get_vq_state()
527 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_state() local
529 return ifcvf_set_vq_state(vf, qid, state->split.avail_index); in ifcvf_vdpa_set_vq_state()
535 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_cb() local
537 vf->vring[qid].cb = *cb; in ifcvf_vdpa_set_vq_cb()
543 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_ready() local
545 vf->vring[qid].ready = ready; in ifcvf_vdpa_set_vq_ready()
550 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_ready() local
552 return vf->vring[qid].ready; in ifcvf_vdpa_get_vq_ready()
558 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_num() local
560 vf->vring[qid].size = num; in ifcvf_vdpa_set_vq_num()
567 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_vq_address() local
569 vf->vring[qid].desc = desc_area; in ifcvf_vdpa_set_vq_address()
570 vf->vring[qid].avail = driver_area; in ifcvf_vdpa_set_vq_address()
571 vf->vring[qid].used = device_area; in ifcvf_vdpa_set_vq_address()
578 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_kick_vq() local
580 ifcvf_notify_queue(vf, qid); in ifcvf_vdpa_kick_vq()
585 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_generation() local
587 return vp_ioread8(&vf->common_cfg->config_generation); in ifcvf_vdpa_get_generation()
592 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_device_id() local
594 return vf->dev_type; in ifcvf_vdpa_get_device_id()
612 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_config_size() local
614 return vf->config_size; in ifcvf_vdpa_get_config_size()
626 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_config() local
628 ifcvf_read_dev_config(vf, offset, buf, len); in ifcvf_vdpa_get_config()
635 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_config() local
637 ifcvf_write_dev_config(vf, offset, buf, len); in ifcvf_vdpa_set_config()
643 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_set_config_cb() local
645 vf->config_cb.callback = cb->callback; in ifcvf_vdpa_set_config_cb()
646 vf->config_cb.private = cb->private; in ifcvf_vdpa_set_config_cb()
652 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_vdpa_get_vq_irq() local
654 if (vf->vqs_reused_irq < 0) in ifcvf_vdpa_get_vq_irq()
655 return vf->vring[qid].irq; in ifcvf_vdpa_get_vq_irq()
663 struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); in ifcvf_get_vq_notification() local
666 area.addr = vf->vring[idx].notify_pa; in ifcvf_get_vq_notification()
667 if (!vf->notify_off_multiplier) in ifcvf_get_vq_notification()
670 area.size = vf->notify_off_multiplier; in ifcvf_get_vq_notification()
745 struct ifcvf_hw *vf; in ifcvf_vdpa_dev_add() local
750 vf = &ifcvf_mgmt_dev->vf; in ifcvf_vdpa_dev_add()
751 pdev = vf->pdev; in ifcvf_vdpa_dev_add()
763 adapter->vf = vf; in ifcvf_vdpa_dev_add()
766 device_features = vf->hw_features; in ifcvf_vdpa_dev_add()
775 vf->dev_features = device_features; in ifcvf_vdpa_dev_add()
782 ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring); in ifcvf_vdpa_dev_add()
810 struct ifcvf_hw *vf; in ifcvf_probe() local
846 vf = &ifcvf_mgmt_dev->vf; in ifcvf_probe()
847 vf->dev_type = get_dev_type(pdev); in ifcvf_probe()
848 vf->base = pcim_iomap_table(pdev); in ifcvf_probe()
849 vf->pdev = pdev; in ifcvf_probe()
851 ret = ifcvf_init_hw(vf, pdev); in ifcvf_probe()
857 for (i = 0; i < vf->nr_vring; i++) in ifcvf_probe()
858 vf->vring[i].irq = -EINVAL; in ifcvf_probe()
860 vf->hw_features = ifcvf_get_hw_features(vf); in ifcvf_probe()
861 vf->config_size = ifcvf_get_config_size(vf); in ifcvf_probe()
879 ifcvf_mgmt_dev->mdev.max_supported_vqs = vf->nr_vring; in ifcvf_probe()
880 ifcvf_mgmt_dev->mdev.supported_features = vf->hw_features; in ifcvf_probe()