Lines Matching refs:vdev
73 int (*devcmd_rtn)(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
82 void *vnic_dev_priv(struct vnic_dev *vdev) in vnic_dev_priv() argument
84 return vdev->priv; in vnic_dev_priv()
87 static int vnic_dev_discover_res(struct vnic_dev *vdev, in vnic_dev_discover_res() argument
154 vdev->res[type].count = count; in vnic_dev_discover_res()
155 vdev->res[type].vaddr = (char __iomem *)bar->vaddr + bar_offset; in vnic_dev_discover_res()
161 unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev, in vnic_dev_get_res_count() argument
164 return vdev->res[type].count; in vnic_dev_get_res_count()
167 void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type, in vnic_dev_get_res() argument
170 if (!vdev->res[type].vaddr) in vnic_dev_get_res()
178 return (char __iomem *)vdev->res[type].vaddr + in vnic_dev_get_res()
181 return (char __iomem *)vdev->res[type].vaddr; in vnic_dev_get_res()
218 int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, in vnic_dev_alloc_desc_ring() argument
223 ring->descs_unaligned = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_alloc_desc_ring()
246 void vnic_dev_free_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring) in vnic_dev_free_desc_ring() argument
249 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_free_desc_ring()
257 static int vnic_dev_cmd1(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, int wait) in vnic_dev_cmd1() argument
259 struct vnic_devcmd __iomem *devcmd = vdev->devcmd; in vnic_dev_cmd1()
271 u64 *a0 = &vdev->args[0]; in vnic_dev_cmd1()
272 u64 *a1 = &vdev->args[1]; in vnic_dev_cmd1()
319 static int vnic_dev_cmd2(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, in vnic_dev_cmd2() argument
322 struct devcmd2_controller *dc2c = vdev->devcmd2; in vnic_dev_cmd2()
338 pci_name(vdev->pdev), _CMD_N(cmd)); in vnic_dev_cmd2()
340 pci_name(vdev->pdev), fetch_index, posted); in vnic_dev_cmd2()
350 pci_name(vdev->pdev), _CMD_N(cmd)); in vnic_dev_cmd2()
352 pci_name(vdev->pdev), fetch_index, posted); in vnic_dev_cmd2()
363 dc2c->cmd_ring[posted].args[i] = vdev->args[i]; in vnic_dev_cmd2()
395 pci_name(vdev->pdev), in vnic_dev_cmd2()
402 vdev->args[i] = result->results[i]; in vnic_dev_cmd2()
408 pr_err("%s:Timed out devcmd %d\n", pci_name(vdev->pdev), _CMD_N(cmd)); in vnic_dev_cmd2()
414 static int vnic_dev_init_devcmd1(struct vnic_dev *vdev) in vnic_dev_init_devcmd1() argument
416 vdev->devcmd = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD, 0); in vnic_dev_init_devcmd1()
417 if (!vdev->devcmd) in vnic_dev_init_devcmd1()
420 vdev->devcmd_rtn = &vnic_dev_cmd1; in vnic_dev_init_devcmd1()
425 static int vnic_dev_init_devcmd2(struct vnic_dev *vdev) in vnic_dev_init_devcmd2() argument
430 if (vdev->devcmd2) in vnic_dev_init_devcmd2()
433 vdev->devcmd2 = kzalloc(sizeof(*vdev->devcmd2), GFP_ATOMIC); in vnic_dev_init_devcmd2()
434 if (!vdev->devcmd2) in vnic_dev_init_devcmd2()
437 vdev->devcmd2->color = 1; in vnic_dev_init_devcmd2()
438 vdev->devcmd2->result_size = DEVCMD2_RING_SIZE; in vnic_dev_init_devcmd2()
439 err = vnic_wq_devcmd2_alloc(vdev, &vdev->devcmd2->wq, in vnic_dev_init_devcmd2()
444 fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index); in vnic_dev_init_devcmd2()
456 vnic_wq_init_start(&vdev->devcmd2->wq, 0, fetch_index, in vnic_dev_init_devcmd2()
459 vnic_wq_enable(&vdev->devcmd2->wq); in vnic_dev_init_devcmd2()
461 err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring, in vnic_dev_init_devcmd2()
466 vdev->devcmd2->result = in vnic_dev_init_devcmd2()
467 (struct devcmd2_result *) vdev->devcmd2->results_ring.descs; in vnic_dev_init_devcmd2()
468 vdev->devcmd2->cmd_ring = in vnic_dev_init_devcmd2()
469 (struct vnic_devcmd2 *) vdev->devcmd2->wq.ring.descs; in vnic_dev_init_devcmd2()
470 vdev->devcmd2->wq_ctrl = vdev->devcmd2->wq.ctrl; in vnic_dev_init_devcmd2()
471 vdev->args[0] = (u64) vdev->devcmd2->results_ring.base_addr | in vnic_dev_init_devcmd2()
473 vdev->args[1] = DEVCMD2_RING_SIZE; in vnic_dev_init_devcmd2()
475 err = vnic_dev_cmd2(vdev, CMD_INITIALIZE_DEVCMD2, 1000); in vnic_dev_init_devcmd2()
479 vdev->devcmd_rtn = &vnic_dev_cmd2; in vnic_dev_init_devcmd2()
484 vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring); in vnic_dev_init_devcmd2()
486 vnic_wq_disable(&vdev->devcmd2->wq); in vnic_dev_init_devcmd2()
488 vnic_wq_free(&vdev->devcmd2->wq); in vnic_dev_init_devcmd2()
490 kfree(vdev->devcmd2); in vnic_dev_init_devcmd2()
491 vdev->devcmd2 = NULL; in vnic_dev_init_devcmd2()
497 static void vnic_dev_deinit_devcmd2(struct vnic_dev *vdev) in vnic_dev_deinit_devcmd2() argument
499 vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring); in vnic_dev_deinit_devcmd2()
500 vnic_wq_disable(&vdev->devcmd2->wq); in vnic_dev_deinit_devcmd2()
501 vnic_wq_free(&vdev->devcmd2->wq); in vnic_dev_deinit_devcmd2()
502 kfree(vdev->devcmd2); in vnic_dev_deinit_devcmd2()
503 vdev->devcmd2 = NULL; in vnic_dev_deinit_devcmd2()
504 vdev->devcmd_rtn = &vnic_dev_cmd1; in vnic_dev_deinit_devcmd2()
508 static int vnic_dev_cmd_no_proxy(struct vnic_dev *vdev, in vnic_dev_cmd_no_proxy() argument
513 vdev->args[0] = *a0; in vnic_dev_cmd_no_proxy()
514 vdev->args[1] = *a1; in vnic_dev_cmd_no_proxy()
516 err = (*vdev->devcmd_rtn)(vdev, cmd, wait); in vnic_dev_cmd_no_proxy()
518 *a0 = vdev->args[0]; in vnic_dev_cmd_no_proxy()
519 *a1 = vdev->args[1]; in vnic_dev_cmd_no_proxy()
525 int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, in vnic_dev_cmd() argument
528 memset(vdev->args, 0, sizeof(vdev->args)); in vnic_dev_cmd()
530 switch (vdev->proxy) { in vnic_dev_cmd()
533 return vnic_dev_cmd_no_proxy(vdev, cmd, a0, a1, wait); in vnic_dev_cmd()
538 int vnic_dev_fw_info(struct vnic_dev *vdev, in vnic_dev_fw_info() argument
545 if (!vdev->fw_info) { in vnic_dev_fw_info()
546 vdev->fw_info = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_fw_info()
548 &vdev->fw_info_pa, GFP_KERNEL); in vnic_dev_fw_info()
549 if (!vdev->fw_info) in vnic_dev_fw_info()
552 a0 = vdev->fw_info_pa; in vnic_dev_fw_info()
555 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait); in vnic_dev_fw_info()
558 *fw_info = vdev->fw_info; in vnic_dev_fw_info()
563 int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size, in vnic_dev_spec() argument
573 err = vnic_dev_cmd(vdev, CMD_DEV_SPEC, &a0, &a1, wait); in vnic_dev_spec()
596 int vnic_dev_stats_clear(struct vnic_dev *vdev) in vnic_dev_stats_clear() argument
600 return vnic_dev_cmd(vdev, CMD_STATS_CLEAR, &a0, &a1, wait); in vnic_dev_stats_clear()
603 int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats) in vnic_dev_stats_dump() argument
608 if (!vdev->stats) { in vnic_dev_stats_dump()
609 vdev->stats = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_stats_dump()
610 sizeof(struct vnic_stats), &vdev->stats_pa, GFP_KERNEL); in vnic_dev_stats_dump()
611 if (!vdev->stats) in vnic_dev_stats_dump()
615 *stats = vdev->stats; in vnic_dev_stats_dump()
616 a0 = vdev->stats_pa; in vnic_dev_stats_dump()
619 return vnic_dev_cmd(vdev, CMD_STATS_DUMP, &a0, &a1, wait); in vnic_dev_stats_dump()
622 int vnic_dev_close(struct vnic_dev *vdev) in vnic_dev_close() argument
626 return vnic_dev_cmd(vdev, CMD_CLOSE, &a0, &a1, wait); in vnic_dev_close()
629 int vnic_dev_enable(struct vnic_dev *vdev) in vnic_dev_enable() argument
633 return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait); in vnic_dev_enable()
636 int vnic_dev_disable(struct vnic_dev *vdev) in vnic_dev_disable() argument
640 return vnic_dev_cmd(vdev, CMD_DISABLE, &a0, &a1, wait); in vnic_dev_disable()
643 int vnic_dev_open(struct vnic_dev *vdev, int arg) in vnic_dev_open() argument
647 return vnic_dev_cmd(vdev, CMD_OPEN, &a0, &a1, wait); in vnic_dev_open()
650 int vnic_dev_open_done(struct vnic_dev *vdev, int *done) in vnic_dev_open_done() argument
658 err = vnic_dev_cmd(vdev, CMD_OPEN_STATUS, &a0, &a1, wait); in vnic_dev_open_done()
667 int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg) in vnic_dev_soft_reset() argument
671 return vnic_dev_cmd(vdev, CMD_SOFT_RESET, &a0, &a1, wait); in vnic_dev_soft_reset()
674 int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done) in vnic_dev_soft_reset_done() argument
682 err = vnic_dev_cmd(vdev, CMD_SOFT_RESET_STATUS, &a0, &a1, wait); in vnic_dev_soft_reset_done()
691 int vnic_dev_hang_notify(struct vnic_dev *vdev) in vnic_dev_hang_notify() argument
695 return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait); in vnic_dev_hang_notify()
698 int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr) in vnic_dev_mac_addr() argument
707 err = vnic_dev_cmd(vdev, CMD_MAC_ADDR, &a[0], &a[1], wait); in vnic_dev_mac_addr()
717 void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast, in vnic_dev_packet_filter() argument
730 err = vnic_dev_cmd(vdev, CMD_PACKET_FILTER, &a0, &a1, wait); in vnic_dev_packet_filter()
735 void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr) in vnic_dev_add_addr() argument
745 err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a[0], &a[1], wait); in vnic_dev_add_addr()
750 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr) in vnic_dev_del_addr() argument
760 err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a[0], &a[1], wait); in vnic_dev_del_addr()
765 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr) in vnic_dev_notify_set() argument
770 if (!vdev->notify) { in vnic_dev_notify_set()
771 vdev->notify = dma_alloc_coherent(&vdev->pdev->dev, in vnic_dev_notify_set()
773 &vdev->notify_pa, GFP_KERNEL); in vnic_dev_notify_set()
774 if (!vdev->notify) in vnic_dev_notify_set()
778 a0 = vdev->notify_pa; in vnic_dev_notify_set()
782 return vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); in vnic_dev_notify_set()
785 void vnic_dev_notify_unset(struct vnic_dev *vdev) in vnic_dev_notify_unset() argument
794 vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); in vnic_dev_notify_unset()
797 static int vnic_dev_notify_ready(struct vnic_dev *vdev) in vnic_dev_notify_ready() argument
804 if (!vdev->notify) in vnic_dev_notify_ready()
809 memcpy(&vdev->notify_copy, vdev->notify, in vnic_dev_notify_ready()
811 words = (u32 *)&vdev->notify_copy; in vnic_dev_notify_ready()
819 int vnic_dev_init(struct vnic_dev *vdev, int arg) in vnic_dev_init() argument
823 return vnic_dev_cmd(vdev, CMD_INIT, &a0, &a1, wait); in vnic_dev_init()
826 u16 vnic_dev_set_default_vlan(struct vnic_dev *vdev, u16 new_default_vlan) in vnic_dev_set_default_vlan() argument
832 old_vlan = vnic_dev_cmd(vdev, CMD_SET_DEFAULT_VLAN, &a0, &a1, wait); in vnic_dev_set_default_vlan()
836 int vnic_dev_link_status(struct vnic_dev *vdev) in vnic_dev_link_status() argument
838 if (vdev->linkstatus) in vnic_dev_link_status()
839 return *vdev->linkstatus; in vnic_dev_link_status()
841 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_link_status()
844 return vdev->notify_copy.link_state; in vnic_dev_link_status()
847 u32 vnic_dev_port_speed(struct vnic_dev *vdev) in vnic_dev_port_speed() argument
849 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_port_speed()
852 return vdev->notify_copy.port_speed; in vnic_dev_port_speed()
855 u32 vnic_dev_msg_lvl(struct vnic_dev *vdev) in vnic_dev_msg_lvl() argument
857 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_msg_lvl()
860 return vdev->notify_copy.msglvl; in vnic_dev_msg_lvl()
863 u32 vnic_dev_mtu(struct vnic_dev *vdev) in vnic_dev_mtu() argument
865 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_mtu()
868 return vdev->notify_copy.mtu; in vnic_dev_mtu()
871 u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev) in vnic_dev_link_down_cnt() argument
873 if (!vnic_dev_notify_ready(vdev)) in vnic_dev_link_down_cnt()
876 return vdev->notify_copy.link_down_cnt; in vnic_dev_link_down_cnt()
879 void vnic_dev_set_intr_mode(struct vnic_dev *vdev, in vnic_dev_set_intr_mode() argument
882 vdev->intr_mode = intr_mode; in vnic_dev_set_intr_mode()
886 struct vnic_dev *vdev) in vnic_dev_get_intr_mode() argument
888 return vdev->intr_mode; in vnic_dev_get_intr_mode()
891 void vnic_dev_unregister(struct vnic_dev *vdev) in vnic_dev_unregister() argument
893 if (vdev) { in vnic_dev_unregister()
894 if (vdev->notify) in vnic_dev_unregister()
895 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
897 vdev->notify, in vnic_dev_unregister()
898 vdev->notify_pa); in vnic_dev_unregister()
899 if (vdev->linkstatus) in vnic_dev_unregister()
900 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
902 vdev->linkstatus, in vnic_dev_unregister()
903 vdev->linkstatus_pa); in vnic_dev_unregister()
904 if (vdev->stats) in vnic_dev_unregister()
905 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
907 vdev->stats, vdev->stats_pa); in vnic_dev_unregister()
908 if (vdev->fw_info) in vnic_dev_unregister()
909 dma_free_coherent(&vdev->pdev->dev, in vnic_dev_unregister()
911 vdev->fw_info, vdev->fw_info_pa); in vnic_dev_unregister()
912 if (vdev->devcmd2) in vnic_dev_unregister()
913 vnic_dev_deinit_devcmd2(vdev); in vnic_dev_unregister()
914 kfree(vdev); in vnic_dev_unregister()
918 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, in vnic_dev_register() argument
921 if (!vdev) { in vnic_dev_register()
922 vdev = kzalloc(sizeof(struct vnic_dev), GFP_KERNEL); in vnic_dev_register()
923 if (!vdev) in vnic_dev_register()
927 vdev->priv = priv; in vnic_dev_register()
928 vdev->pdev = pdev; in vnic_dev_register()
930 if (vnic_dev_discover_res(vdev, bar)) in vnic_dev_register()
933 return vdev; in vnic_dev_register()
936 vnic_dev_unregister(vdev); in vnic_dev_register()
940 int vnic_dev_cmd_init(struct vnic_dev *vdev) in vnic_dev_cmd_init() argument
945 p = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD2, 0); in vnic_dev_cmd_init()
948 err = vnic_dev_init_devcmd2(vdev); in vnic_dev_cmd_init()
951 err = vnic_dev_init_devcmd1(vdev); in vnic_dev_cmd_init()