Commit 5531bb85 authored by Jacob Keller's avatar Jacob Keller Committed by Tony Nguyen
Browse files

ice: convert vf_ops .vsi_rebuild to .create_vsi



The .vsi_rebuild function exists for ice_reset_vf. It is used to release
and re-create the VSI during a single-VF reset.

This function is only called when we need to re-create the VSI, and not
when rebuilding an existing VSI. This makes the single-VF reset process
different from the process used to restore functionality after a
hardware reset such as the PF reset or EMP reset.

When we add support for Scalable IOV VFs, the implementation will be very
similar. The primary difference will be in the fact that each VF type uses
a different underlying VSI type in hardware.

Move the common functionality into a new ice_vf_recreate VSI function. This
will allow the two IOV paths to share this functionality. Rework the
.vsi_rebuild vf_op into .create_vsi, only performing the task of creating a
new VSI.

This creates a nice dichotomy between the ice_vf_rebuild_vsi and
ice_vf_recreate_vsi, and should make it more clear why the two flows atre
distinct.

Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarMarek Szlosek <marek.szlosek@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent b1b56942
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -757,23 +757,19 @@ static void ice_sriov_clear_reset_trigger(struct ice_vf *vf)
}

/**
 * ice_sriov_vsi_rebuild - release and rebuild VF's VSI
 * @vf: VF to release and setup the VSI for
 * ice_sriov_create_vsi - Create a new VSI for a VF
 * @vf: VF to create the VSI for
 *
 * This is only called when a single VF is being reset (i.e. VFR, VFLR, host VF
 * configuration change, etc.).
 * This is called by ice_vf_recreate_vsi to create the new VSI after the old
 * VSI has been released.
 */
static int ice_sriov_vsi_rebuild(struct ice_vf *vf)
static int ice_sriov_create_vsi(struct ice_vf *vf)
{
	struct ice_pf *pf = vf->pf;
	struct ice_vsi *vsi;

	ice_vf_vsi_release(vf);
	if (!ice_vf_vsi_setup(vf)) {
		dev_err(ice_pf_to_dev(pf),
			"Failed to release and setup the VF%u's VSI\n",
			vf->vf_id);
	vsi = ice_vf_vsi_setup(vf);
	if (!vsi)
		return -ENOMEM;
	}

	return 0;
}
@@ -795,7 +791,7 @@ static const struct ice_vf_ops ice_sriov_vf_ops = {
	.trigger_reset_register = ice_sriov_trigger_reset_register,
	.poll_reset_status = ice_sriov_poll_reset_status,
	.clear_reset_trigger = ice_sriov_clear_reset_trigger,
	.vsi_rebuild = ice_sriov_vsi_rebuild,
	.create_vsi = ice_sriov_create_vsi,
	.post_vsi_rebuild = ice_sriov_post_vsi_rebuild,
};

+30 −1
Original line number Diff line number Diff line
@@ -241,12 +241,41 @@ static void ice_vf_pre_vsi_rebuild(struct ice_vf *vf)
	vf->vf_ops->clear_reset_trigger(vf);
}

/**
 * ice_vf_recreate_vsi - Release and re-create the VF's VSI
 * @vf: VF to recreate the VSI for
 *
 * This is only called when a single VF is being reset (i.e. VVF, VFLR, host
 * VF configuration change, etc)
 *
 * It releases and then re-creates a new VSI.
 */
static int ice_vf_recreate_vsi(struct ice_vf *vf)
{
	struct ice_pf *pf = vf->pf;
	int err;

	ice_vf_vsi_release(vf);

	err = vf->vf_ops->create_vsi(vf);
	if (err) {
		dev_err(ice_pf_to_dev(pf),
			"Failed to recreate the VF%u's VSI, error %d\n",
			vf->vf_id, err);
		return err;
	}

	return 0;
}

/**
 * ice_vf_rebuild_vsi - rebuild the VF's VSI
 * @vf: VF to rebuild the VSI for
 *
 * This is only called when all VF(s) are being reset (i.e. PCIe Reset on the
 * host, PFR, CORER, etc.).
 *
 * It reprograms the VSI configuration back into hardware.
 */
static int ice_vf_rebuild_vsi(struct ice_vf *vf)
{
@@ -654,7 +683,7 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)

	ice_vf_pre_vsi_rebuild(vf);

	if (vf->vf_ops->vsi_rebuild(vf)) {
	if (ice_vf_recreate_vsi(vf)) {
		dev_err(dev, "Failed to release and setup the VF%u's VSI\n",
			vf->vf_id);
		err = -EFAULT;
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ struct ice_vf_ops {
	void (*trigger_reset_register)(struct ice_vf *vf, bool is_vflr);
	bool (*poll_reset_status)(struct ice_vf *vf);
	void (*clear_reset_trigger)(struct ice_vf *vf);
	int (*vsi_rebuild)(struct ice_vf *vf);
	int (*create_vsi)(struct ice_vf *vf);
	void (*post_vsi_rebuild)(struct ice_vf *vf);
};