Lines Matching full:vdev

61 	int (*devcmd_rtn)(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
70 void *vnic_dev_priv(struct vnic_dev *vdev) in vnic_dev_priv() argument
72 return vdev->priv; in vnic_dev_priv()
75 static int vnic_dev_discover_res(struct vnic_dev *vdev, in vnic_dev_discover_res() argument
142 vdev->res[type].count = count; in vnic_dev_discover_res()
143 vdev->res[type].vaddr = (char __iomem *)bar->vaddr + bar_offset; in vnic_dev_discover_res()
147 vdev->res[RES_TYPE_WQ].count, vdev->res[RES_TYPE_RQ].count, in vnic_dev_discover_res()
148 vdev->res[RES_TYPE_CQ].count, vdev->res[RES_TYPE_INTR_CTRL].count); in vnic_dev_discover_res()
153 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev, in vnic_dev_get_res_count() argument
156 return vdev->res[type].count; in vnic_dev_get_res_count()
159 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type, in vnic_dev_get_res() argument
162 if (!vdev->res[type].vaddr) in vnic_dev_get_res()
170 return (char __iomem *)vdev->res[type].vaddr + in vnic_dev_get_res()
173 return (char __iomem *)vdev->res[type].vaddr; in vnic_dev_get_res()
210 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, in vnic_dev_alloc_desc_ring() argument
215 ring->descs_unaligned = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_alloc_desc_ring()
238 void vnic_dev_free_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring) in vnic_dev_free_desc_ring() argument
241 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_free_desc_ring()
249 static int vnic_dev_cmd1(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, int wait) in vnic_dev_cmd1() argument
251 struct vnic_devcmd __iomem *devcmd = vdev->devcmd; in vnic_dev_cmd1()
263 u64 *a0 = &vdev->args[0]; in vnic_dev_cmd1()
264 u64 *a1 = &vdev->args[1]; in vnic_dev_cmd1()
311 static int vnic_dev_cmd2(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, in vnic_dev_cmd2() argument
314 struct devcmd2_controller *dc2c = vdev->devcmd2; in vnic_dev_cmd2()
330 pci_name(vdev->pdev), _CMD_N(cmd)); in vnic_dev_cmd2()
332 pci_name(vdev->pdev), fetch_index, posted); in vnic_dev_cmd2()
342 pci_name(vdev->pdev), _CMD_N(cmd)); in vnic_dev_cmd2()
344 pci_name(vdev->pdev), fetch_index, posted); in vnic_dev_cmd2()
355 dc2c->cmd_ring[posted].args[i] = vdev->args[i]; in vnic_dev_cmd2()
387 pci_name(vdev->pdev), in vnic_dev_cmd2()
394 vdev->args[i] = result->results[i]; in vnic_dev_cmd2()
400 pr_err("%s:Timed out devcmd %d\n", pci_name(vdev->pdev), _CMD_N(cmd)); in vnic_dev_cmd2()
406 static int vnic_dev_init_devcmd1(struct vnic_dev *vdev) in vnic_dev_init_devcmd1() argument
408 vdev->devcmd = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD, 0); in vnic_dev_init_devcmd1()
409 if (!vdev->devcmd) in vnic_dev_init_devcmd1()
412 vdev->devcmd_rtn = &vnic_dev_cmd1; in vnic_dev_init_devcmd1()
417 static int vnic_dev_init_devcmd2(struct vnic_dev *vdev) in vnic_dev_init_devcmd2() argument
422 if (vdev->devcmd2) in vnic_dev_init_devcmd2()
425 vdev->devcmd2 = kzalloc(sizeof(*vdev->devcmd2), GFP_ATOMIC); in vnic_dev_init_devcmd2()
426 if (!vdev->devcmd2) in vnic_dev_init_devcmd2()
429 vdev->devcmd2->color = 1; in vnic_dev_init_devcmd2()
430 vdev->devcmd2->result_size = DEVCMD2_RING_SIZE; in vnic_dev_init_devcmd2()
431 err = vnic_wq_devcmd2_alloc(vdev, &vdev->devcmd2->wq, in vnic_dev_init_devcmd2()
436 fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index); in vnic_dev_init_devcmd2()
448 vnic_wq_init_start(&vdev->devcmd2->wq, 0, fetch_index, in vnic_dev_init_devcmd2()
451 vnic_wq_enable(&vdev->devcmd2->wq); in vnic_dev_init_devcmd2()
453 err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring, in vnic_dev_init_devcmd2()
458 vdev->devcmd2->result = in vnic_dev_init_devcmd2()
459 (struct devcmd2_result *) vdev->devcmd2->results_ring.descs; in vnic_dev_init_devcmd2()
460 vdev->devcmd2->cmd_ring = in vnic_dev_init_devcmd2()
461 (struct vnic_devcmd2 *) vdev->devcmd2->wq.ring.descs; in vnic_dev_init_devcmd2()
462 vdev->devcmd2->wq_ctrl = vdev->devcmd2->wq.ctrl; in vnic_dev_init_devcmd2()
463 vdev->args[0] = (u64) vdev->devcmd2->results_ring.base_addr | in vnic_dev_init_devcmd2()
465 vdev->args[1] = DEVCMD2_RING_SIZE; in vnic_dev_init_devcmd2()
467 err = vnic_dev_cmd2(vdev, CMD_INITIALIZE_DEVCMD2, 1000); in vnic_dev_init_devcmd2()
471 vdev->devcmd_rtn = &vnic_dev_cmd2; in vnic_dev_init_devcmd2()
476 vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring); in vnic_dev_init_devcmd2()
478 vnic_wq_disable(&vdev->devcmd2->wq); in vnic_dev_init_devcmd2()
480 vnic_wq_free(&vdev->devcmd2->wq); in vnic_dev_init_devcmd2()
482 kfree(vdev->devcmd2); in vnic_dev_init_devcmd2()
483 vdev->devcmd2 = NULL; in vnic_dev_init_devcmd2()
489 static void vnic_dev_deinit_devcmd2(struct vnic_dev *vdev) in vnic_dev_deinit_devcmd2() argument
491 vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring); in vnic_dev_deinit_devcmd2()
492 vnic_wq_disable(&vdev->devcmd2->wq); in vnic_dev_deinit_devcmd2()
493 vnic_wq_free(&vdev->devcmd2->wq); in vnic_dev_deinit_devcmd2()
494 kfree(vdev->devcmd2); in vnic_dev_deinit_devcmd2()
495 vdev->devcmd2 = NULL; in vnic_dev_deinit_devcmd2()
496 vdev->devcmd_rtn = &vnic_dev_cmd1; in vnic_dev_deinit_devcmd2()
500 static int vnic_dev_cmd_no_proxy(struct vnic_dev *vdev, in vnic_dev_cmd_no_proxy() argument
505 vdev->args[0] = *a0; in vnic_dev_cmd_no_proxy()
506 vdev->args[1] = *a1; in vnic_dev_cmd_no_proxy()
508 err = (*vdev->devcmd_rtn)(vdev, cmd, wait); in vnic_dev_cmd_no_proxy()
510 *a0 = vdev->args[0]; in vnic_dev_cmd_no_proxy()
511 *a1 = vdev->args[1]; in vnic_dev_cmd_no_proxy()
517 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, in vnic_dev_cmd() argument
520 memset(vdev->args, 0, sizeof(vdev->args)); in vnic_dev_cmd()
522 switch (vdev->proxy) { in vnic_dev_cmd()
525 return vnic_dev_cmd_no_proxy(vdev, cmd, a0, a1, wait); in vnic_dev_cmd()
530 int vnic_dev_fw_info(struct vnic_dev *vdev, in vnic_dev_fw_info() argument
537 if (!vdev->fw_info) { in vnic_dev_fw_info()
538 vdev->fw_info = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_fw_info()
540 &vdev->fw_info_pa, GFP_KERNEL); in vnic_dev_fw_info()
541 if (!vdev->fw_info) in vnic_dev_fw_info()
544 a0 = vdev->fw_info_pa; in vnic_dev_fw_info()
547 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait); in vnic_dev_fw_info()
550 *fw_info = vdev->fw_info; in vnic_dev_fw_info()
555 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size, in vnic_dev_spec() argument
565 err = vnic_dev_cmd(vdev, CMD_DEV_SPEC, &a0, &a1, wait); in vnic_dev_spec()
588 int vnic_dev_stats_clear(struct vnic_dev *vdev) in vnic_dev_stats_clear() argument
592 return vnic_dev_cmd(vdev, CMD_STATS_CLEAR, &a0, &a1, wait); in vnic_dev_stats_clear()
595 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats) in vnic_dev_stats_dump() argument
600 if (!vdev->stats) { in vnic_dev_stats_dump()
601 vdev->stats = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_stats_dump()
602 sizeof(struct vnic_stats), &vdev->stats_pa, GFP_KERNEL); in vnic_dev_stats_dump()
603 if (!vdev->stats) in vnic_dev_stats_dump()
607 *stats = vdev->stats; in vnic_dev_stats_dump()
608 a0 = vdev->stats_pa; in vnic_dev_stats_dump()
611 return vnic_dev_cmd(vdev, CMD_STATS_DUMP, &a0, &a1, wait); in vnic_dev_stats_dump()
614 int vnic_dev_close(struct vnic_dev *vdev) in vnic_dev_close() argument
618 return vnic_dev_cmd(vdev, CMD_CLOSE, &a0, &a1, wait); in vnic_dev_close()
621 int vnic_dev_enable(struct vnic_dev *vdev) in vnic_dev_enable() argument
625 return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait); in vnic_dev_enable()
628 int vnic_dev_disable(struct vnic_dev *vdev) in vnic_dev_disable() argument
632 return vnic_dev_cmd(vdev, CMD_DISABLE, &a0, &a1, wait); in vnic_dev_disable()
635 int vnic_dev_open(struct vnic_dev *vdev, int arg) in vnic_dev_open() argument
639 return vnic_dev_cmd(vdev, CMD_OPEN, &a0, &a1, wait); in vnic_dev_open()
642 int vnic_dev_open_done(struct vnic_dev *vdev, int *done) in vnic_dev_open_done() argument
650 err = vnic_dev_cmd(vdev, CMD_OPEN_STATUS, &a0, &a1, wait); in vnic_dev_open_done()
659 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg) in vnic_dev_soft_reset() argument
663 return vnic_dev_cmd(vdev, CMD_SOFT_RESET, &a0, &a1, wait); in vnic_dev_soft_reset()
666 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done) in vnic_dev_soft_reset_done() argument
674 err = vnic_dev_cmd(vdev, CMD_SOFT_RESET_STATUS, &a0, &a1, wait); in vnic_dev_soft_reset_done()
683 int vnic_dev_hang_notify(struct vnic_dev *vdev) in vnic_dev_hang_notify() argument
687 return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait); in vnic_dev_hang_notify()
690 int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr) in vnic_dev_mac_addr() argument
699 err = vnic_dev_cmd(vdev, CMD_MAC_ADDR, &a[0], &a[1], wait); in vnic_dev_mac_addr()
709 void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast, in vnic_dev_packet_filter() argument
722 err = vnic_dev_cmd(vdev, CMD_PACKET_FILTER, &a0, &a1, wait); in vnic_dev_packet_filter()
727 void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr) in vnic_dev_add_addr() argument
737 err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a[0], &a[1], wait); in vnic_dev_add_addr()
742 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr) in vnic_dev_del_addr() argument
752 err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a[0], &a[1], wait); in vnic_dev_del_addr()
757 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr) in vnic_dev_notify_set() argument
762 if (!vdev->notify) { in vnic_dev_notify_set()
763 vdev->notify = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_notify_set()
765 &vdev->notify_pa, GFP_KERNEL); in vnic_dev_notify_set()
766 if (!vdev->notify) in vnic_dev_notify_set()
770 a0 = vdev->notify_pa; in vnic_dev_notify_set()
774 return vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); in vnic_dev_notify_set()
777 void vnic_dev_notify_unset(struct vnic_dev *vdev) in vnic_dev_notify_unset() argument
786 vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); in vnic_dev_notify_unset()
789 static int vnic_dev_notify_ready(struct vnic_dev *vdev) in vnic_dev_notify_ready() argument
796 if (!vdev->notify) in vnic_dev_notify_ready()
801 memcpy(&vdev->notify_copy, vdev->notify, in vnic_dev_notify_ready()
803 words = (u32 *)&vdev->notify_copy; in vnic_dev_notify_ready()
811 int vnic_dev_init(struct vnic_dev *vdev, int arg) in vnic_dev_init() argument
815 return vnic_dev_cmd(vdev, CMD_INIT, &a0, &a1, wait); in vnic_dev_init()
818 u16 vnic_dev_set_default_vlan(struct vnic_dev *vdev, u16 new_default_vlan) in vnic_dev_set_default_vlan() argument
824 old_vlan = vnic_dev_cmd(vdev, CMD_SET_DEFAULT_VLAN, &a0, &a1, wait); in vnic_dev_set_default_vlan()
828 int vnic_dev_link_status(struct vnic_dev *vdev) in vnic_dev_link_status() argument
830 if (vdev->linkstatus) in vnic_dev_link_status()
831 return *vdev->linkstatus; in vnic_dev_link_status()
833 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_link_status()
836 return vdev->notify_copy.link_state; in vnic_dev_link_status()
839 u32 vnic_dev_port_speed(struct vnic_dev *vdev) in vnic_dev_port_speed() argument
841 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_port_speed()
844 return vdev->notify_copy.port_speed; in vnic_dev_port_speed()
847 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev) in vnic_dev_msg_lvl() argument
849 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_msg_lvl()
852 return vdev->notify_copy.msglvl; in vnic_dev_msg_lvl()
855 u32 vnic_dev_mtu(struct vnic_dev *vdev) in vnic_dev_mtu() argument
857 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_mtu()
860 return vdev->notify_copy.mtu; in vnic_dev_mtu()
863 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev) in vnic_dev_link_down_cnt() argument
865 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_link_down_cnt()
868 return vdev->notify_copy.link_down_cnt; in vnic_dev_link_down_cnt()
871 void vnic_dev_set_intr_mode(struct vnic_dev *vdev, in vnic_dev_set_intr_mode() argument
874 vdev->intr_mode = intr_mode; in vnic_dev_set_intr_mode()
878 struct vnic_dev *vdev) in vnic_dev_get_intr_mode() argument
880 return vdev->intr_mode; in vnic_dev_get_intr_mode()
883 void vnic_dev_unregister(struct vnic_dev *vdev) in vnic_dev_unregister() argument
885 if (vdev) { in vnic_dev_unregister()
886 if (vdev->notify) in vnic_dev_unregister()
887 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
889 vdev->notify, in vnic_dev_unregister()
890 vdev->notify_pa); in vnic_dev_unregister()
891 if (vdev->linkstatus) in vnic_dev_unregister()
892 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
894 vdev->linkstatus, in vnic_dev_unregister()
895 vdev->linkstatus_pa); in vnic_dev_unregister()
896 if (vdev->stats) in vnic_dev_unregister()
897 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
899 vdev->stats, vdev->stats_pa); in vnic_dev_unregister()
900 if (vdev->fw_info) in vnic_dev_unregister()
901 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
903 vdev->fw_info, vdev->fw_info_pa); in vnic_dev_unregister()
904 if (vdev->devcmd2) in vnic_dev_unregister()
905 vnic_dev_deinit_devcmd2(vdev); in vnic_dev_unregister()
906 kfree(vdev); in vnic_dev_unregister()
910 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, in vnic_dev_register() argument
913 if (!vdev) { in vnic_dev_register()
914 vdev = kzalloc(sizeof(struct vnic_dev), GFP_KERNEL); in vnic_dev_register()
915 if (!vdev) in vnic_dev_register()
919 vdev->priv = priv; in vnic_dev_register()
920 vdev->pdev = pdev; in vnic_dev_register()
922 if (vnic_dev_discover_res(vdev, bar)) in vnic_dev_register()
925 return vdev; in vnic_dev_register()
928 vnic_dev_unregister(vdev); in vnic_dev_register()
932 int vnic_dev_cmd_init(struct vnic_dev *vdev) in vnic_dev_cmd_init() argument
937 p = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD2, 0); in vnic_dev_cmd_init()
940 err = vnic_dev_init_devcmd2(vdev); in vnic_dev_cmd_init()
943 err = vnic_dev_init_devcmd1(vdev); in vnic_dev_cmd_init()