Skip to content

Commit 2a2cb4c

Browse files
jacob-kelleranguy11
authored andcommitted
ice: replace ice_vf_recreate_vsi() with ice_vf_reconfig_vsi()
The ice_vf_create_vsi() function and its VF ops helper introduced by commit a4c785e8162e ("ice: convert vf_ops .vsi_rebuild to .create_vsi") are used during an individual VF reset to re-create the VSI. This was done in order to ensure that the VSI gets properly reconfigured within the hardware. This is somewhat heavy handed as we completely release the VSI memory and structure, and then create a new VSI. This can also potentially force a change of the VSI index as we will re-use the first open slot in the VSI array which may not be the same. As part of implementing devlink reload, commit 6624e78 ("ice: split ice_vsi_setup into smaller functions") split VSI setup into smaller functions, introducing both ice_vsi_cfg() and ice_vsi_decfg() which can be used to configure or deconfigure an existing software VSI structure. Rather than completely removing the VSI and adding a new one using the .create_vsi() VF operation, simply use ice_vsi_decfg() to remove the current configuration. Save the VSI type and then call ice_vsi_cfg() to reconfigure the VSI as the same type that it was before. The existing reset logic assumes that all hardware filters will be removed, so also call ice_fltr_remove_all() before re-configuring the VSI. This new operation does not re-create the VSI, so rename it to ice_vf_reconfig_vsi(). The new approach can safely share the exact same flow for both SR-IOV VFs as well as the Scalable IOV VFs being worked on. This uses less code and is a better abstraction over fully deleting the VSI and adding a new one. Signed-off-by: Jacob Keller <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Petr Oros <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent aa4967d commit 2a2cb4c

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

drivers/net/ethernet/intel/ice/ice_sriov.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -761,24 +761,6 @@ static void ice_sriov_clear_reset_trigger(struct ice_vf *vf)
761761
ice_flush(hw);
762762
}
763763

764-
/**
765-
* ice_sriov_create_vsi - Create a new VSI for a VF
766-
* @vf: VF to create the VSI for
767-
*
768-
* This is called by ice_vf_recreate_vsi to create the new VSI after the old
769-
* VSI has been released.
770-
*/
771-
static int ice_sriov_create_vsi(struct ice_vf *vf)
772-
{
773-
struct ice_vsi *vsi;
774-
775-
vsi = ice_vf_vsi_setup(vf);
776-
if (!vsi)
777-
return -ENOMEM;
778-
779-
return 0;
780-
}
781-
782764
/**
783765
* ice_sriov_post_vsi_rebuild - tasks to do after the VF's VSI have been rebuilt
784766
* @vf: VF to perform tasks on
@@ -798,7 +780,6 @@ static const struct ice_vf_ops ice_sriov_vf_ops = {
798780
.poll_reset_status = ice_sriov_poll_reset_status,
799781
.clear_reset_trigger = ice_sriov_clear_reset_trigger,
800782
.irq_close = NULL,
801-
.create_vsi = ice_sriov_create_vsi,
802783
.post_vsi_rebuild = ice_sriov_post_vsi_rebuild,
803784
};
804785

@@ -1141,8 +1122,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
11411122
if (vf->first_vector_idx < 0)
11421123
goto unroll;
11431124

1144-
ice_vf_vsi_release(vf);
1145-
if (vf->vf_ops->create_vsi(vf)) {
1125+
if (ice_vf_reconfig_vsi(vf)) {
11461126
/* Try to rebuild with previous values */
11471127
needs_rebuild = true;
11481128
goto unroll;
@@ -1169,7 +1149,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
11691149
return -EINVAL;
11701150

11711151
if (needs_rebuild)
1172-
vf->vf_ops->create_vsi(vf);
1152+
ice_vf_reconfig_vsi(vf);
11731153

11741154
ice_ena_vf_mappings(vf);
11751155
ice_put_vf(vf);

drivers/net/ethernet/intel/ice/ice_vf_lib.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,29 +248,44 @@ static void ice_vf_pre_vsi_rebuild(struct ice_vf *vf)
248248
}
249249

250250
/**
251-
* ice_vf_recreate_vsi - Release and re-create the VF's VSI
252-
* @vf: VF to recreate the VSI for
251+
* ice_vf_reconfig_vsi - Reconfigure a VF VSI with the device
252+
* @vf: VF to reconfigure the VSI for
253253
*
254-
* This is only called when a single VF is being reset (i.e. VVF, VFLR, host
255-
* VF configuration change, etc)
254+
* This is called when a single VF is being reset (i.e. VVF, VFLR, host VF
255+
* configuration change, etc).
256256
*
257-
* It releases and then re-creates a new VSI.
257+
* It brings the VSI down and then reconfigures it with the hardware.
258258
*/
259-
static int ice_vf_recreate_vsi(struct ice_vf *vf)
259+
int ice_vf_reconfig_vsi(struct ice_vf *vf)
260260
{
261+
struct ice_vsi *vsi = ice_get_vf_vsi(vf);
262+
struct ice_vsi_cfg_params params = {};
261263
struct ice_pf *pf = vf->pf;
262264
int err;
263265

264-
ice_vf_vsi_release(vf);
266+
if (WARN_ON(!vsi))
267+
return -EINVAL;
268+
269+
params = ice_vsi_to_params(vsi);
270+
params.flags = ICE_VSI_FLAG_NO_INIT;
265271

266-
err = vf->vf_ops->create_vsi(vf);
272+
ice_vsi_decfg(vsi);
273+
ice_fltr_remove_all(vsi);
274+
275+
err = ice_vsi_cfg(vsi, &params);
267276
if (err) {
268277
dev_err(ice_pf_to_dev(pf),
269-
"Failed to recreate the VF%u's VSI, error %d\n",
278+
"Failed to reconfigure the VF%u's VSI, error %d\n",
270279
vf->vf_id, err);
271280
return err;
272281
}
273282

283+
/* Update the lan_vsi_num field since it might have been changed. The
284+
* PF lan_vsi_idx number remains the same so we don't need to change
285+
* that.
286+
*/
287+
vf->lan_vsi_num = vsi->vsi_num;
288+
274289
return 0;
275290
}
276291

@@ -928,7 +943,7 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
928943

929944
ice_vf_pre_vsi_rebuild(vf);
930945

931-
if (ice_vf_recreate_vsi(vf)) {
946+
if (ice_vf_reconfig_vsi(vf)) {
932947
dev_err(dev, "Failed to release and setup the VF%u's VSI\n",
933948
vf->vf_id);
934949
err = -EFAULT;

drivers/net/ethernet/intel/ice/ice_vf_lib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct ice_vf_ops {
6262
bool (*poll_reset_status)(struct ice_vf *vf);
6363
void (*clear_reset_trigger)(struct ice_vf *vf);
6464
void (*irq_close)(struct ice_vf *vf);
65-
int (*create_vsi)(struct ice_vf *vf);
6665
void (*post_vsi_rebuild)(struct ice_vf *vf);
6766
};
6867

drivers/net/ethernet/intel/ice/ice_vf_lib_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#warning "Only include ice_vf_lib_private.h in CONFIG_PCI_IOV virtualization files"
2424
#endif
2525

26+
int ice_vf_reconfig_vsi(struct ice_vf *vf);
2627
void ice_initialize_vf_entry(struct ice_vf *vf);
2728
void ice_dis_vf_qs(struct ice_vf *vf);
2829
int ice_check_vf_init(struct ice_vf *vf);

0 commit comments

Comments
 (0)