Lines Matching full:vdev
54 int (*devcmd_rtn)(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
63 void *svnic_dev_priv(struct vnic_dev *vdev) in svnic_dev_priv() argument
65 return vdev->priv; in svnic_dev_priv()
68 static int vnic_dev_discover_res(struct vnic_dev *vdev, in vnic_dev_discover_res() argument
144 vdev->res[type].count = count; in vnic_dev_discover_res()
145 vdev->res[type].vaddr = (char __iomem *)bar->vaddr + bar_offset; in vnic_dev_discover_res()
151 unsigned int svnic_dev_get_res_count(struct vnic_dev *vdev, in svnic_dev_get_res_count() argument
154 return vdev->res[type].count; in svnic_dev_get_res_count()
157 void __iomem *svnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type, in svnic_dev_get_res() argument
160 if (!vdev->res[type].vaddr) in svnic_dev_get_res()
168 return (char __iomem *)vdev->res[type].vaddr + in svnic_dev_get_res()
172 return (char __iomem *)vdev->res[type].vaddr; in svnic_dev_get_res()
209 int svnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, in svnic_dev_alloc_desc_ring() argument
214 ring->descs_unaligned = dma_alloc_coherent(&vdev->pdev->dev, in svnic_dev_alloc_desc_ring()
236 void svnic_dev_free_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring) in svnic_dev_free_desc_ring() argument
239 dma_free_coherent(&vdev->pdev->dev, in svnic_dev_free_desc_ring()
247 static int _svnic_dev_cmd2(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, in _svnic_dev_cmd2() argument
250 struct devcmd2_controller *dc2c = vdev->devcmd2; in _svnic_dev_cmd2()
276 pci_name(vdev->pdev), _CMD_N(cmd), fetch_idx, posted); in _svnic_dev_cmd2()
289 dc2c->cmd_ring[posted].args[i] = vdev->args[i]; in _svnic_dev_cmd2()
329 vdev->args[i] = result->results[i]; in _svnic_dev_cmd2()
341 static int svnic_dev_init_devcmd2(struct vnic_dev *vdev) in svnic_dev_init_devcmd2() argument
348 if (vdev->devcmd2) in svnic_dev_init_devcmd2()
351 p = svnic_dev_get_res(vdev, RES_TYPE_DEVCMD2, 0); in svnic_dev_init_devcmd2()
359 vdev->devcmd2 = dc2c; in svnic_dev_init_devcmd2()
364 ret = vnic_wq_devcmd2_alloc(vdev, in svnic_dev_init_devcmd2()
384 ret = svnic_dev_alloc_desc_ring(vdev, in svnic_dev_init_devcmd2()
394 vdev->args[0] = (u64) dc2c->results_ring.base_addr | VNIC_PADDR_TARGET; in svnic_dev_init_devcmd2()
395 vdev->args[1] = DEVCMD2_RING_SIZE; in svnic_dev_init_devcmd2()
397 ret = _svnic_dev_cmd2(vdev, CMD_INITIALIZE_DEVCMD2, VNIC_DVCMD_TMO); in svnic_dev_init_devcmd2()
401 vdev->devcmd_rtn = &_svnic_dev_cmd2; in svnic_dev_init_devcmd2()
407 svnic_dev_free_desc_ring(vdev, &dc2c->results_ring); in svnic_dev_init_devcmd2()
415 vdev->devcmd2 = NULL; in svnic_dev_init_devcmd2()
420 static void vnic_dev_deinit_devcmd2(struct vnic_dev *vdev) in vnic_dev_deinit_devcmd2() argument
422 struct devcmd2_controller *dc2c = vdev->devcmd2; in vnic_dev_deinit_devcmd2()
424 vdev->devcmd2 = NULL; in vnic_dev_deinit_devcmd2()
425 vdev->devcmd_rtn = NULL; in vnic_dev_deinit_devcmd2()
427 svnic_dev_free_desc_ring(vdev, &dc2c->results_ring); in vnic_dev_deinit_devcmd2()
433 int svnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, in svnic_dev_cmd() argument
438 memset(vdev->args, 0, sizeof(vdev->args)); in svnic_dev_cmd()
439 vdev->args[0] = *a0; in svnic_dev_cmd()
440 vdev->args[1] = *a1; in svnic_dev_cmd()
442 err = (*vdev->devcmd_rtn)(vdev, cmd, wait); in svnic_dev_cmd()
444 *a0 = vdev->args[0]; in svnic_dev_cmd()
445 *a1 = vdev->args[1]; in svnic_dev_cmd()
450 int svnic_dev_fw_info(struct vnic_dev *vdev, in svnic_dev_fw_info() argument
457 if (!vdev->fw_info) { in svnic_dev_fw_info()
458 vdev->fw_info = dma_alloc_coherent(&vdev->pdev->dev, in svnic_dev_fw_info()
460 &vdev->fw_info_pa, GFP_KERNEL); in svnic_dev_fw_info()
461 if (!vdev->fw_info) in svnic_dev_fw_info()
464 a0 = vdev->fw_info_pa; in svnic_dev_fw_info()
467 err = svnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait); in svnic_dev_fw_info()
470 *fw_info = vdev->fw_info; in svnic_dev_fw_info()
475 int svnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, in svnic_dev_spec() argument
485 err = svnic_dev_cmd(vdev, CMD_DEV_SPEC, &a0, &a1, wait); in svnic_dev_spec()
508 int svnic_dev_stats_clear(struct vnic_dev *vdev) in svnic_dev_stats_clear() argument
513 return svnic_dev_cmd(vdev, CMD_STATS_CLEAR, &a0, &a1, wait); in svnic_dev_stats_clear()
516 int svnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats) in svnic_dev_stats_dump() argument
521 if (!vdev->stats) { in svnic_dev_stats_dump()
522 vdev->stats = dma_alloc_coherent(&vdev->pdev->dev, in svnic_dev_stats_dump()
523 sizeof(struct vnic_stats), &vdev->stats_pa, GFP_KERNEL); in svnic_dev_stats_dump()
524 if (!vdev->stats) in svnic_dev_stats_dump()
528 *stats = vdev->stats; in svnic_dev_stats_dump()
529 a0 = vdev->stats_pa; in svnic_dev_stats_dump()
532 return svnic_dev_cmd(vdev, CMD_STATS_DUMP, &a0, &a1, wait); in svnic_dev_stats_dump()
535 int svnic_dev_close(struct vnic_dev *vdev) in svnic_dev_close() argument
540 return svnic_dev_cmd(vdev, CMD_CLOSE, &a0, &a1, wait); in svnic_dev_close()
543 int svnic_dev_enable_wait(struct vnic_dev *vdev) in svnic_dev_enable_wait() argument
549 err = svnic_dev_cmd(vdev, CMD_ENABLE_WAIT, &a0, &a1, wait); in svnic_dev_enable_wait()
551 return svnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait); in svnic_dev_enable_wait()
556 int svnic_dev_disable(struct vnic_dev *vdev) in svnic_dev_disable() argument
561 return svnic_dev_cmd(vdev, CMD_DISABLE, &a0, &a1, wait); in svnic_dev_disable()
564 int svnic_dev_open(struct vnic_dev *vdev, int arg) in svnic_dev_open() argument
569 return svnic_dev_cmd(vdev, CMD_OPEN, &a0, &a1, wait); in svnic_dev_open()
572 int svnic_dev_open_done(struct vnic_dev *vdev, int *done) in svnic_dev_open_done() argument
580 err = svnic_dev_cmd(vdev, CMD_OPEN_STATUS, &a0, &a1, wait); in svnic_dev_open_done()
589 int svnic_dev_notify_set(struct vnic_dev *vdev, u16 intr) in svnic_dev_notify_set() argument
594 if (!vdev->notify) { in svnic_dev_notify_set()
595 vdev->notify = dma_alloc_coherent(&vdev->pdev->dev, in svnic_dev_notify_set()
597 &vdev->notify_pa, GFP_KERNEL); in svnic_dev_notify_set()
598 if (!vdev->notify) in svnic_dev_notify_set()
602 a0 = vdev->notify_pa; in svnic_dev_notify_set()
606 return svnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); in svnic_dev_notify_set()
609 void svnic_dev_notify_unset(struct vnic_dev *vdev) in svnic_dev_notify_unset() argument
618 svnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); in svnic_dev_notify_unset()
621 static int vnic_dev_notify_ready(struct vnic_dev *vdev) in vnic_dev_notify_ready() argument
628 if (!vdev->notify) in vnic_dev_notify_ready()
633 memcpy(&vdev->notify_copy, vdev->notify, in vnic_dev_notify_ready()
635 words = (u32 *)&vdev->notify_copy; in vnic_dev_notify_ready()
643 int svnic_dev_init(struct vnic_dev *vdev, int arg) in svnic_dev_init() argument
648 return svnic_dev_cmd(vdev, CMD_INIT, &a0, &a1, wait); in svnic_dev_init()
651 int svnic_dev_link_status(struct vnic_dev *vdev) in svnic_dev_link_status() argument
653 if (vdev->linkstatus) in svnic_dev_link_status()
654 return *vdev->linkstatus; in svnic_dev_link_status()
656 if (!vnic_dev_notify_ready(vdev)) in svnic_dev_link_status()
659 return vdev->notify_copy.link_state; in svnic_dev_link_status()
662 u32 svnic_dev_link_down_cnt(struct vnic_dev *vdev) in svnic_dev_link_down_cnt() argument
664 if (!vnic_dev_notify_ready(vdev)) in svnic_dev_link_down_cnt()
667 return vdev->notify_copy.link_down_cnt; in svnic_dev_link_down_cnt()
670 void svnic_dev_set_intr_mode(struct vnic_dev *vdev, in svnic_dev_set_intr_mode() argument
673 vdev->intr_mode = intr_mode; in svnic_dev_set_intr_mode()
676 enum vnic_dev_intr_mode svnic_dev_get_intr_mode(struct vnic_dev *vdev) in svnic_dev_get_intr_mode() argument
678 return vdev->intr_mode; in svnic_dev_get_intr_mode()
681 void svnic_dev_unregister(struct vnic_dev *vdev) in svnic_dev_unregister() argument
683 if (vdev) { in svnic_dev_unregister()
684 if (vdev->notify) in svnic_dev_unregister()
685 dma_free_coherent(&vdev->pdev->dev, in svnic_dev_unregister()
687 vdev->notify, in svnic_dev_unregister()
688 vdev->notify_pa); in svnic_dev_unregister()
689 if (vdev->linkstatus) in svnic_dev_unregister()
690 dma_free_coherent(&vdev->pdev->dev, in svnic_dev_unregister()
692 vdev->linkstatus, in svnic_dev_unregister()
693 vdev->linkstatus_pa); in svnic_dev_unregister()
694 if (vdev->stats) in svnic_dev_unregister()
695 dma_free_coherent(&vdev->pdev->dev, in svnic_dev_unregister()
697 vdev->stats, vdev->stats_pa); in svnic_dev_unregister()
698 if (vdev->fw_info) in svnic_dev_unregister()
699 dma_free_coherent(&vdev->pdev->dev, in svnic_dev_unregister()
701 vdev->fw_info, vdev->fw_info_pa); in svnic_dev_unregister()
702 if (vdev->devcmd2) in svnic_dev_unregister()
703 vnic_dev_deinit_devcmd2(vdev); in svnic_dev_unregister()
704 kfree(vdev); in svnic_dev_unregister()
708 struct vnic_dev *svnic_dev_alloc_discover(struct vnic_dev *vdev, in svnic_dev_alloc_discover() argument
714 if (!vdev) { in svnic_dev_alloc_discover()
715 vdev = kzalloc(sizeof(struct vnic_dev), GFP_ATOMIC); in svnic_dev_alloc_discover()
716 if (!vdev) in svnic_dev_alloc_discover()
720 vdev->priv = priv; in svnic_dev_alloc_discover()
721 vdev->pdev = pdev; in svnic_dev_alloc_discover()
723 if (vnic_dev_discover_res(vdev, bar, num_bars)) in svnic_dev_alloc_discover()
726 return vdev; in svnic_dev_alloc_discover()
729 svnic_dev_unregister(vdev); in svnic_dev_alloc_discover()
737 int svnic_dev_cmd_init(struct vnic_dev *vdev, int fallback) in svnic_dev_cmd_init() argument
742 p = svnic_dev_get_res(vdev, RES_TYPE_DEVCMD2, 0); in svnic_dev_cmd_init()
744 err = svnic_dev_init_devcmd2(vdev); in svnic_dev_cmd_init()