static int ifcvf_hw_enable()

in ifcvf/ifcvf_base.c [352:393]


static int ifcvf_hw_enable(struct ifcvf_hw *hw)
{
	struct virtio_pci_common_cfg __iomem *cfg;
	struct ifcvf_adapter *ifcvf;
	u32 i;

	ifcvf = vf_to_adapter(hw);
	cfg = hw->common_cfg;
	ifc_iowrite16(IFCVF_MSI_CONFIG_OFF, &cfg->msix_config);

	if (ifc_ioread16(&cfg->msix_config) == VIRTIO_MSI_NO_VECTOR) {
		IFCVF_ERR(ifcvf->pdev, "No msix vector for device config\n");
		return -EINVAL;
	}

	for (i = 0; i < hw->nr_vring; i++) {
		if (!hw->vring[i].ready)
			break;

		ifc_iowrite16(i, &cfg->queue_select);
		ifc_iowrite64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,
				     &cfg->queue_desc_hi);
		ifc_iowrite64_twopart(hw->vring[i].avail, &cfg->queue_avail_lo,
				      &cfg->queue_avail_hi);
		ifc_iowrite64_twopart(hw->vring[i].used, &cfg->queue_used_lo,
				     &cfg->queue_used_hi);
		ifc_iowrite16(hw->vring[i].size, &cfg->queue_size);
		ifc_iowrite16(i + IFCVF_MSI_QUEUE_OFF, &cfg->queue_msix_vector);

		if (ifc_ioread16(&cfg->queue_msix_vector) ==
		    VIRTIO_MSI_NO_VECTOR) {
			IFCVF_ERR(ifcvf->pdev,
				  "No msix vector for queue %u\n", i);
			return -EINVAL;
		}

		ifcvf_set_vq_state(hw, i, hw->vring[i].last_avail_idx);
		ifc_iowrite16(1, &cfg->queue_enable);
	}

	return 0;
}