Lines Matching refs:psnet
53 ret = readx_poll_timeout(ioread32, snet->bar + snet->psnet->cfg.msg_off, in snet_wait_for_msg_ack()
75 snet_write32(snet, snet->psnet->cfg.msg_off, msg); in snet_send_msg()
80 snet_read32(snet, snet->psnet->cfg.msg_off); in snet_send_msg()
107 struct psnet *psnet = snet->psnet; in snet_free_irqs() local
112 if (PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_IRQ_PF)) in snet_free_irqs()
365 off = snet->psnet->cfg.host_cfg_off; in snet_write_conf()
369 snet_write32(snet, off, snet->psnet->negotiated_cfg_ver); in snet_write_conf()
399 snet_write32(snet, snet->psnet->cfg.msg_off, 0); in snet_write_conf()
401 snet_write32(snet, snet->psnet->cfg.host_cfg_off, SNET_SIGNATURE); in snet_write_conf()
404 ret = readx_poll_timeout(ioread32, snet->bar + snet->psnet->cfg.host_cfg_off, in snet_write_conf()
448 struct psnet *psnet = snet->psnet; in snet_set_status() local
459 pf_irqs = PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_IRQ_PF); in snet_set_status()
542 static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) in psnet_open_pf_bar() argument
571 psnet->bars[i] = pcim_iomap_table(pdev)[i]; in psnet_open_pf_bar()
584 ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name); in snet_open_vf_bar()
590 snet->bar = pcim_iomap_table(pdev)[snet->psnet->cfg.vf_bar]; in snet_open_vf_bar()
614 static int psnet_detect_bar(struct psnet *psnet, u32 off) in psnet_detect_bar() argument
625 if (!psnet->bars[i]) in psnet_detect_bar()
628 if (ioread32(psnet->bars[i] + off) == SNET_SIGNATURE) in psnet_detect_bar()
637 static void psnet_unmap_unused_bars(struct pci_dev *pdev, struct psnet *psnet) in psnet_unmap_unused_bars() argument
642 if (psnet->bars[i] && i != psnet->barno) in psnet_unmap_unused_bars()
651 static int psnet_read_cfg(struct pci_dev *pdev, struct psnet *psnet) in psnet_read_cfg() argument
653 struct snet_cfg *cfg = &psnet->cfg; in psnet_read_cfg()
661 barno = psnet_detect_bar(psnet, off); in psnet_read_cfg()
668 psnet->barno = barno; in psnet_read_cfg()
671 psnet_unmap_unused_bars(pdev, psnet); in psnet_read_cfg()
674 cfg->key = psnet_read32(psnet, off); in psnet_read_cfg()
676 cfg->cfg_size = psnet_read32(psnet, off); in psnet_read_cfg()
678 cfg->cfg_ver = psnet_read32(psnet, off); in psnet_read_cfg()
683 psnet->negotiated_cfg_ver = min_t(u32, cfg->cfg_ver, SNET_CFG_VERSION); in psnet_read_cfg()
684 SNET_DBG(pdev, "SNET config version %u\n", psnet->negotiated_cfg_ver); in psnet_read_cfg()
686 cfg->vf_num = psnet_read32(psnet, off); in psnet_read_cfg()
688 cfg->vf_bar = psnet_read32(psnet, off); in psnet_read_cfg()
690 cfg->host_cfg_off = psnet_read32(psnet, off); in psnet_read_cfg()
692 cfg->max_size_host_cfg = psnet_read32(psnet, off); in psnet_read_cfg()
694 cfg->virtio_cfg_off = psnet_read32(psnet, off); in psnet_read_cfg()
696 cfg->kick_off = psnet_read32(psnet, off); in psnet_read_cfg()
698 cfg->hwmon_off = psnet_read32(psnet, off); in psnet_read_cfg()
700 cfg->msg_off = psnet_read32(psnet, off); in psnet_read_cfg()
702 cfg->flags = psnet_read32(psnet, off); in psnet_read_cfg()
707 cfg->devices_num = psnet_read32(psnet, off); in psnet_read_cfg()
722 cfg->devs[i]->virtio_id = psnet_read32(psnet, off); in psnet_read_cfg()
724 cfg->devs[i]->vq_num = psnet_read32(psnet, off); in psnet_read_cfg()
726 cfg->devs[i]->vq_size = psnet_read32(psnet, off); in psnet_read_cfg()
728 cfg->devs[i]->vfid = psnet_read32(psnet, off); in psnet_read_cfg()
730 cfg->devs[i]->features = psnet_read64(psnet, off); in psnet_read_cfg()
735 cfg->devs[i]->cfg_size = psnet_read32(psnet, off); in psnet_read_cfg()
749 static int psnet_alloc_irq_vector(struct pci_dev *pdev, struct psnet *psnet) in psnet_alloc_irq_vector() argument
755 for (i = 0; i < psnet->cfg.devices_num; i++) in psnet_alloc_irq_vector()
756 irq_num += psnet->cfg.devs[i]->vq_num + 1; in psnet_alloc_irq_vector()
821 snet->vqs[i]->kick_ptr = snet->bar + snet->psnet->cfg.kick_off + in snet_build_vqs()
829 static int psnet_get_next_irq_num(struct psnet *psnet) in psnet_get_next_irq_num() argument
833 spin_lock(&psnet->lock); in psnet_get_next_irq_num()
834 irq = psnet->next_irq++; in psnet_get_next_irq_num()
835 spin_unlock(&psnet->lock); in psnet_get_next_irq_num()
842 struct psnet *psnet = snet->psnet; in snet_reserve_irq_idx() local
846 snet->cfg_irq_idx = psnet_get_next_irq_num(psnet); in snet_reserve_irq_idx()
852 snet->vqs[i]->irq_idx = psnet_get_next_irq_num(psnet); in snet_reserve_irq_idx()
875 struct psnet *psnet; in snet_vdpa_probe_pf() local
886 psnet = kzalloc(sizeof(*psnet), GFP_KERNEL); in snet_vdpa_probe_pf()
887 if (!psnet) in snet_vdpa_probe_pf()
891 spin_lock_init(&psnet->lock); in snet_vdpa_probe_pf()
894 pci_set_drvdata(pdev, psnet); in snet_vdpa_probe_pf()
897 ret = psnet_open_pf_bar(pdev, psnet); in snet_vdpa_probe_pf()
902 ret = psnet_read_cfg(pdev, psnet); in snet_vdpa_probe_pf()
909 pf_irqs = PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_IRQ_PF); in snet_vdpa_probe_pf()
912 ret = psnet_alloc_irq_vector(pdev, psnet); in snet_vdpa_probe_pf()
917 SNET_DBG(pdev, "Enable %u virtual functions\n", psnet->cfg.vf_num); in snet_vdpa_probe_pf()
918 ret = pci_enable_sriov(pdev, psnet->cfg.vf_num); in snet_vdpa_probe_pf()
925 if (PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_HWMON)) { in snet_vdpa_probe_pf()
939 snet_free_cfg(&psnet->cfg); in snet_vdpa_probe_pf()
941 kfree(psnet); in snet_vdpa_probe_pf()
949 struct psnet *psnet = pci_get_drvdata(pdev_pf); in snet_vdpa_probe_vf() local
967 dev_cfg = snet_find_dev_cfg(&psnet->cfg, vfid); in snet_vdpa_probe_vf()
976 pf_irqs = PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_IRQ_PF); in snet_vdpa_probe_vf()
1002 snet->psnet = psnet; in snet_vdpa_probe_vf()
1014 snet->cfg->virtio_cfg = snet->bar + snet->psnet->cfg.virtio_cfg_off; in snet_vdpa_probe_vf()
1061 struct psnet *psnet = pci_get_drvdata(pdev); in snet_vdpa_remove_pf() local
1065 if (PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_IRQ_PF)) in snet_vdpa_remove_pf()
1068 snet_free_cfg(&psnet->cfg); in snet_vdpa_remove_pf()
1069 kfree(psnet); in snet_vdpa_remove_pf()
1075 struct psnet *psnet = snet->psnet; in snet_vdpa_remove_vf() local
1080 if (!PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_IRQ_PF)) in snet_vdpa_remove_vf()