ice: various virtualization cleanups
Subsystems (3)
Tony Nguyen
maintainerJacob Keller says:
This series contains a variety of refactors and cleanups in the VF code for the ice driver. Its primary focus is cleanup and simplification of the VF operations and addition of a few new operations that will be required by Scalable IOV, as well as some other refactors needed for the handling of VF subfunctions.
The following are changes since commit c21adf256f8dcfbc07436d45be4ba2edf7a6f463:
Merge branch 'tuntap-socket-uid'
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 100GbE
Brett Creeley (1):
ice: Add more usage of existing function ice_get_vf_vsi(vf)
Jacob Keller (12):
ice: fix function comment referring to ice_vsi_alloc
ice: drop unnecessary VF parameter from several VSI functions
ice: refactor VSI setup to use parameter structure
ice: move vsi_type assignment from ice_vsi_alloc to ice_vsi_cfg
ice: move ice_vf_vsi_release into ice_vf_lib.c
ice: Pull common tasks into ice_vf_post_vsi_rebuild
ice: add a function to initialize vf entry
ice: introduce ice_vf_init_host_cfg function
ice: convert vf_ops .vsi_rebuild to .create_vsi
ice: introduce clear_reset_state operation
ice: introduce .irq_close VF operation
ice: remove unnecessary virtchnl_ether_addr struct use
drivers/net/ethernet/intel/ice/ice_eswitch.c | 26 ++- drivers/net/ethernet/intel/ice/ice_lib.c | 138 +++++++------ drivers/net/ethernet/intel/ice/ice_lib.h | 52 ++++- drivers/net/ethernet/intel/ice/ice_main.c | 42 +++- drivers/net/ethernet/intel/ice/ice_sriov.c | 133 +++++-------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 181 +++++++++++++++++- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 12 +- .../ethernet/intel/ice/ice_vf_lib_private.h | 3 + drivers/net/ethernet/intel/ice/ice_virtchnl.c | 24 +-- .../ethernet/intel/ice/ice_virtchnl_fdir.c | 8 +- 10 files changed, 406 insertions(+), 213 deletions(-)
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 1/13 ice: Add more usage of existing function ice_get_vf_vsi(vf)
From: Brett Creeley <[email protected]>
Extend the usage of function ice_get_vf_vsi(vf) in multiple places instead of VF's VSI by using a long string of dereferences (i.e. vf->pf->vsi[vf->lan_vsi_idx]).
--- drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +4 -4
@@ -113,7 +113,7 @@ ice_vc_fdir_param_check(struct ice_vf *vf, u16 vsi_id)if (!ice_vc_isvalid_vsi_id (vf, vsi_id))return -EINVAL ; -if (!pf->vsi[vf->lan_vsi_idx]) +if (!ice_get_vf_vsi (vf))return -EINVAL ;return 0 ;
@@ -494,7 +494,7 @@ ice_vc_fdir_rem_prof(struct ice_vf *vf, enum ice_fltr_ptype flow, int tun) vf_prof = fdir->fdir_prof[flow]; - vf_vsi = pf->vsi[vf->lan_vsi_idx]; + vf_vsi =ice_get_vf_vsi (vf);if (!vf_vsi) {dev_dbg (dev,"NULL vf %d vsi pointer\n" , vf->vf_id);return ;
@@ -572,7 +572,7 @@ ice_vc_fdir_write_flow_prof(struct ice_vf *vf, enum ice_fltr_ptype flow, pf = vf->pf; dev =ice_pf_to_dev (pf); hw = &pf->hw; - vf_vsi = pf->vsi[vf->lan_vsi_idx]; + vf_vsi =ice_get_vf_vsi (vf);if (!vf_vsi)return -EINVAL ;
@@ -1205,7 +1205,7 @@ static int ice_vc_fdir_write_fltr(struct ice_vf *vf, pf = vf->pf; dev =ice_pf_to_dev (pf); hw = &pf->hw; - vsi = pf->vsi[vf->lan_vsi_idx]; + vsi =ice_get_vf_vsi (vf);if (!vsi) {dev_dbg (dev,"Invalid vsi for VF %d\n" , vf->vf_id);return -EINVAL ;
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 2/13 ice: fix function comment referring to ice_vsi_alloc
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
Since commit 1d2e32275de7 ("ice: split ice_vsi_setup into smaller functions") ice_vsi_alloc has not been responsible for all of the behavior implied by the comment for ice_vsi_setup_vector_base.
Fix the comment to refer to the new function ice_vsi_alloc_def().
--- drivers/net/ethernet/intel/ice/ice_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_lib.c +1 -1
@@ -1527,7 +1527,7 @@ static int ice_get_vf_ctrl_res(struct ice_pf *pf, struct ice_vsi *vsi)* ice_vsi_setup_vector_base - Set up the base vector for the given VSI * @vsi: ptr to the VSI * -* This should only be called after ice_vsi_alloc() which allocates the +* This should only be called after ice_vsi_alloc_def() which allocates the * corresponding SW VSI structure and initializes num_queue_pairs for the * newly allocated VSI. *
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 3/13 ice: drop unnecessary VF parameter from several VSI functions
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The vsi->vf pointer gets assigned early on during ice_vsi_alloc. Several functions currently take a VF pointer, but they can just use the existing vsi->vf pointer as needed. Modify these functions to drop the unnecessary VF parameter.
Note that ice_vsi_cfg is not changed as a following change will refactor so that the VF pointer is assigned during ice_vsi_cfg rather than ice_vsi_alloc.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +8 -13
@@ -166,14 +166,14 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi)/** * ice_vsi_set_num_qs - Set number of queues, descriptors and vectors for a VSI * @vsi: the VSI being configured -* @vf: the VF associated with this VSI, if any * * Return 0 on success and a negative value on error */ -static void ice_vsi_set_num_qs (struct ice_vsi *vsi,struct ice_vf *vf) +static void ice_vsi_set_num_qs (struct ice_vsi *vsi) {enum ice_vsi_type vsi_type = vsi->type;struct ice_pf *pf = vsi->back; +struct ice_vf *vf = vsi->vf;if (WARN_ON (vsi_type ==ICE_VSI_VF && !vf))return ;
@@ -594,15 +594,13 @@ static int ice_vsi_alloc_stat_arrays(struct ice_vsi *vsi)/** * ice_vsi_alloc_def - set default values for already allocated VSI * @vsi: ptr to VSI -* @vf: VF for ICE_VSI_VF and ICE_VSI_CTRL * @ch: ptr to channel */ static int -ice_vsi_alloc_def (struct ice_vsi *vsi,struct ice_vf *vf, -struct ice_channel *ch) +ice_vsi_alloc_def (struct ice_vsi *vsi,struct ice_channel *ch) {if (vsi->type !=ICE_VSI_CHNL ) { -ice_vsi_set_num_qs (vsi, vf); +ice_vsi_set_num_qs (vsi);if (ice_vsi_alloc_arrays (vsi))return -ENOMEM ; }
@@ -2702,14 +2700,11 @@ static int ice_vsi_cfg_tc_lan(struct ice_pf *pf, struct ice_vsi *vsi)/** * ice_vsi_cfg_def - configure default VSI based on the type * @vsi: pointer to VSI -* @vf: pointer to VF to which this VSI connects. This field is used primarily -* for the ICE_VSI_VF type. Other VSI types should pass NULL. * @ch: ptr to channel * @init_vsi: is this an initialization or a reconfigure of the VSI */ static int -ice_vsi_cfg_def (struct ice_vsi *vsi,struct ice_vf *vf,struct ice_channel *ch, -int init_vsi) +ice_vsi_cfg_def (struct ice_vsi *vsi,struct ice_channel *ch,int init_vsi) {struct device *dev =ice_pf_to_dev (vsi->back);struct ice_pf *pf = vsi->back;
@@ -2717,7 +2712,7 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vf *vf, struct ice_channel *ch, vsi->vsw = pf->first_sw; - ret =ice_vsi_alloc_def (vsi, vf, ch); + ret =ice_vsi_alloc_def (vsi, ch);if (ret)return ret;
@@ -2875,7 +2870,7 @@ int ice_vsi_cfg(struct ice_vsi *vsi, struct ice_vf *vf, struct ice_channel *ch, {int ret; - ret =ice_vsi_cfg_def (vsi, vf, ch, init_vsi); + ret =ice_vsi_cfg_def (vsi, ch, init_vsi);if (ret)return ret;
@@ -3506,7 +3501,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, int init_vsi) prev_rxq = vsi->num_rxq;ice_vsi_decfg (vsi); - ret =ice_vsi_cfg_def (vsi, vsi->vf, vsi->ch, init_vsi); + ret =ice_vsi_cfg_def (vsi, vsi->ch, init_vsi);if (ret) goto err_vsi_cfg;
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 4/13 ice: refactor VSI setup to use parameter structure
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The ice_vsi_setup function, ice_vsi_alloc, and ice_vsi_cfg functions have grown a large number of parameters. These parameters are used to initialize a new VSI, as well as re-configure an existing VSI
Any time we want to add a new parameter to this function chain, even if it will usually be unset, we have to change many call sites due to changing the function signature.
A future change is going to refactor ice_vsi_alloc and ice_vsi_cfg to move the VSI configuration and initialization all into ice_vsi_cfg.
Before this, refactor the VSI setup flow to use a new ice_vsi_cfg_params structure. This will contain the configuration (mainly pointers) used to initialize a VSI.
Pass this from ice_vsi_setup into the related functions such as ice_vsi_alloc, ice_vsi_cfg, and ice_vsi_cfg_def.
Introduce a helper, ice_vsi_to_params to convert an existing VSI to the parameters used to initialize it. This will aid in the flows where we rebuild an existing VSI.
Since we also pass the ICE_VSI_FLAG_INIT to more functions which do not need (or cannot yet have) the VSI parameters, lets make this clear by renaming the function parameter to vsi_flags and using a u32 instead of a signed integer. The name vsi_flags also makes it clear that we may extend the flags in the future.
This change will make it easier to refactor the setup flow in the future, and will reduce the complexity required to add a new parameter for configuration in the future.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 8 +- drivers/net/ethernet/intel/ice/ice_lib.c | 92 ++++++++++---------- drivers/net/ethernet/intel/ice/ice_lib.h | 52 +++++++++-- drivers/net/ethernet/intel/ice/ice_main.c | 40 +++++++-- drivers/net/ethernet/intel/ice/ice_sriov.c | 9 +- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 9 +- 6 files changed, 147 insertions(+), 63 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +7 -1
@@ -425,7 +425,13 @@ static void ice_eswitch_release_env(struct ice_pf *pf)static struct ice_vsi *ice_eswitch_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi) { -return ice_vsi_setup (pf, pi,ICE_VSI_SWITCHDEV_CTRL ,NULL ,NULL ); +struct ice_vsi_cfg_params params = {}; + + params.type =ICE_VSI_SWITCHDEV_CTRL ; + params.pi = pi; + params.flags =ICE_VSI_FLAG_INIT ; + +return ice_vsi_setup (pf, ¶ms); }/**
drivers/net/ethernet/intel/ice/ice_lib.c +47 -45
235 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.h +44 -8
70 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +35 -5
@@ -3447,14 +3447,27 @@ void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size)static struct ice_vsi *ice_pf_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi) { -return ice_vsi_setup (pf, pi,ICE_VSI_PF ,NULL ,NULL ); +struct ice_vsi_cfg_params params = {}; + + params.type =ICE_VSI_PF ; + params.pi = pi; + params.flags =ICE_VSI_FLAG_INIT ; + +return ice_vsi_setup (pf, ¶ms); }static struct ice_vsi *ice_chnl_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi,struct ice_channel *ch) { -return ice_vsi_setup (pf, pi,ICE_VSI_CHNL ,NULL , ch); +struct ice_vsi_cfg_params params = {}; + + params.type =ICE_VSI_CHNL ; + params.pi = pi; + params.ch = ch; + params.flags =ICE_VSI_FLAG_INIT ; + +return ice_vsi_setup (pf, ¶ms); }/**
@@ -3468,7 +3481,13 @@ ice_chnl_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,static struct ice_vsi *ice_ctrl_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi) { -return ice_vsi_setup (pf, pi,ICE_VSI_CTRL ,NULL ,NULL ); +struct ice_vsi_cfg_params params = {}; + + params.type =ICE_VSI_CTRL ; + params.pi = pi; + params.flags =ICE_VSI_FLAG_INIT ; + +return ice_vsi_setup (pf, ¶ms); }/**
@@ -3482,7 +3501,13 @@ ice_ctrl_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)struct ice_vsi *ice_lb_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi) { -return ice_vsi_setup (pf, pi,ICE_VSI_LB ,NULL ,NULL ); +struct ice_vsi_cfg_params params = {}; + + params.type =ICE_VSI_LB ; + params.pi = pi; + params.flags =ICE_VSI_FLAG_INIT ; + +return ice_vsi_setup (pf, ¶ms); }/**
@@ -5002,6 +5027,7 @@ static void ice_deinit(struct ice_pf *pf)*/ int ice_load (struct ice_pf *pf) { +struct ice_vsi_cfg_params params = {};struct ice_vsi *vsi;int err;
@@ -5014,7 +5040,11 @@ int ice_load(struct ice_pf *pf)return err; vsi =ice_get_main_vsi (pf); - err =ice_vsi_cfg (vsi,NULL ,NULL ,ICE_VSI_FLAG_INIT ); + + params =ice_vsi_to_params (vsi); + params.flags =ICE_VSI_FLAG_INIT ; + + err =ice_vsi_cfg (vsi, ¶ms);if (err) goto err_vsi_cfg;
drivers/net/ethernet/intel/ice/ice_sriov.c +7 -2
@@ -248,11 +248,16 @@ void ice_free_vfs(struct ice_pf *pf)*/ static struct ice_vsi *ice_vf_vsi_setup (struct ice_vf *vf) { -struct ice_port_info *pi =ice_vf_get_port_info (vf); +struct ice_vsi_cfg_params params = {};struct ice_pf *pf = vf->pf;struct ice_vsi *vsi; - vsi =ice_vsi_setup (pf, pi,ICE_VSI_VF , vf,NULL ); + params.type =ICE_VSI_VF ; + params.pi =ice_vf_get_port_info (vf); + params.vf = vf; + params.flags =ICE_VSI_FLAG_INIT ; + + vsi =ice_vsi_setup (pf, ¶ms);if (!vsi) {dev_err (ice_pf_to_dev (pf),"Failed to create VF VSI\n" );
drivers/net/ethernet/intel/ice/ice_vf_lib.c +7 -2
@@ -1115,11 +1115,16 @@ void ice_vf_ctrl_vsi_release(struct ice_vf *vf)*/ struct ice_vsi *ice_vf_ctrl_vsi_setup (struct ice_vf *vf) { -struct ice_port_info *pi =ice_vf_get_port_info (vf); +struct ice_vsi_cfg_params params = {};struct ice_pf *pf = vf->pf;struct ice_vsi *vsi; - vsi =ice_vsi_setup (pf, pi,ICE_VSI_CTRL , vf,NULL ); + params.type =ICE_VSI_CTRL ; + params.pi =ice_vf_get_port_info (vf); + params.vf = vf; + params.flags =ICE_VSI_FLAG_INIT ; + + vsi =ice_vsi_setup (pf, ¶ms);if (!vsi) {dev_err (ice_pf_to_dev (pf),"Failed to create VF control VSI\n" );ice_vf_ctrl_invalidate_vsi (vf);
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 5/13 ice: move vsi_type assignment from ice_vsi_alloc to ice_vsi_cfg
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The ice_vsi_alloc and ice_vsi_cfg functions are used together to allocate and configure a new VSI, called as part of the ice_vsi_setup function.
In the future with the addition of the subfunction code the ice driver will want to be able to allocate a VSI while delaying the configuration to a later point of the port activation.
Currently this requires that the port code know what type of VSI should be allocated. This is required because ice_vsi_alloc assigns the VSI type.
Refactor the ice_vsi_alloc and ice_vsi_cfg functions so that VSI type assignment isn't done until the configuration stage. This will allow the devlink port addition logic to reserve a VSI as early as possible before the type of the port is known. In this way, the port add can fail in the event that all hardware VSI resources are exhausted.
Since the ice_vsi_cfg function already takes the ice_vsi_cfg_params structure, this is relatively straight forward.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 51 ++++++++++++------------ 1 file changed, 26 insertions(+), 25 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +26 -25
@@ -639,23 +639,18 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch)/** * ice_vsi_alloc - Allocates the next available struct VSI in the PF * @pf: board private structure -* @params: parameters to use when allocating the new VSI * -* The VF pointer is used for ICE_VSI_VF and ICE_VSI_CTRL. For ICE_VSI_CTRL, -* it may be NULL in the case there is no association with a VF. For -* ICE_VSI_VF the VF pointer *must not* be NULL. +* Reserves a VSI index from the PF and allocates an empty VSI structure +* without a type. The VSI structure must later be initialized by calling +* ice_vsi_cfg(). * * returns a pointer to a VSI on success, NULL on failure. */ -static struct ice_vsi * -ice_vsi_alloc (struct ice_pf *pf,struct ice_vsi_cfg_params *params) +static struct ice_vsi *ice_vsi_alloc (struct ice_pf *pf) {struct device *dev =ice_pf_to_dev (pf);struct ice_vsi *vsi =NULL ; -if (WARN_ON (params->type ==ICE_VSI_VF && !params->vf)) -return NULL ; -/* Need to protect the allocation of the VSIs at the PF level */ mutex_lock (&pf->sw_mutex);
@@ -672,11 +667,7 @@ ice_vsi_alloc(struct ice_pf *pf, struct ice_vsi_cfg_params *params)if (!vsi) goto unlock_pf; - vsi->type = params->type; vsi->back = pf; - vsi->port_info = params->pi; -/* For VSIs which don't have a connected VF, this will be NULL */ - vsi->vf = params->vf;set_bit (ICE_VSI_DOWN , vsi->state);/* fill slot and make note of the index */
@@ -687,16 +678,6 @@ ice_vsi_alloc(struct ice_pf *pf, struct ice_vsi_cfg_params *params) pf->next_vsi =ice_get_free_slot (pf->vsi, pf->num_alloc_vsi, pf->next_vsi); -if (vsi->type ==ICE_VSI_CTRL ) { -if (vsi->vf) { -WARN_ON (vsi->vf->ctrl_vsi_idx !=ICE_NO_VSI ); - vsi->vf->ctrl_vsi_idx = vsi->idx; - }else { -WARN_ON (pf->ctrl_vsi_idx !=ICE_NO_VSI ); - pf->ctrl_vsi_idx = vsi->idx; - } - } - unlock_pf:mutex_unlock (&pf->sw_mutex);return vsi;
@@ -2856,14 +2837,24 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params) }/** -* ice_vsi_cfg - configure VSI and tc on it +* ice_vsi_cfg - configure a previously allocated VSI * @vsi: pointer to VSI * @params: parameters used to configure this VSI */ int ice_vsi_cfg (struct ice_vsi *vsi,struct ice_vsi_cfg_params *params) { +struct ice_pf *pf = vsi->back;int ret; +if (WARN_ON (params->type ==ICE_VSI_VF && !params->vf)) +return -EINVAL ; + + vsi->type = params->type; + vsi->port_info = params->pi; + +/* For VSIs which don't have a connected VF, this will be NULL */ + vsi->vf = params->vf; + ret =ice_vsi_cfg_def (vsi, params);if (ret)return ret;
@@ -2872,6 +2863,16 @@ int ice_vsi_cfg(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)if (ret)ice_vsi_decfg (vsi); +if (vsi->type ==ICE_VSI_CTRL ) { +if (vsi->vf) { +WARN_ON (vsi->vf->ctrl_vsi_idx !=ICE_NO_VSI ); + vsi->vf->ctrl_vsi_idx = vsi->idx; + }else { +WARN_ON (pf->ctrl_vsi_idx !=ICE_NO_VSI ); + pf->ctrl_vsi_idx = vsi->idx; + } + } +return ret; }
@@ -2956,7 +2957,7 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params) WARN_ON(!params->pi))return NULL ; - vsi =ice_vsi_alloc (pf, params); + vsi =ice_vsi_alloc (pf);if (!vsi) {dev_err (dev,"could not allocate VSI\n" );return NULL ;
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 6/13 ice: move ice_vf_vsi_release into ice_vf_lib.c
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The ice_vf_vsi_release function will be used in a future change to refactor the .vsi_rebuild function. Move this over to ice_vf_lib.c so that it can be used there.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 15 --------------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 18 ++++++++++++++++++ .../ethernet/intel/ice/ice_vf_lib_private.h | 1 + 3 files changed, 19 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -15
@@ -40,21 +40,6 @@ static void ice_free_vf_entries(struct ice_pf *pf) } } -/** -* ice_vf_vsi_release - invalidate the VF's VSI after freeing it -* @vf: invalidate this VF's VSI after freeing it -*/ -static void ice_vf_vsi_release (struct ice_vf *vf) -{ -struct ice_vsi *vsi =ice_get_vf_vsi (vf); - -if (WARN_ON (!vsi)) -return ; - -ice_vsi_release (vsi); -ice_vf_invalidate_vsi (vf); -} -/** * ice_free_vf_res - Free a VF's resources * @vf: pointer to the VF info
drivers/net/ethernet/intel/ice/ice_vf_lib.c +18 -0
@@ -1143,6 +1143,24 @@ void ice_vf_invalidate_vsi(struct ice_vf *vf) vf->lan_vsi_num =ICE_NO_VSI ; } +/** +* ice_vf_vsi_release - Release the VF VSI and invalidate indexes +* @vf: pointer to the VF structure +* +* Release the VF associated with this VSI and then invalidate the VSI +* indexes. +*/ +void ice_vf_vsi_release (struct ice_vf *vf) +{ +struct ice_vsi *vsi =ice_get_vf_vsi (vf); + +if (WARN_ON (!vsi)) +return ; + +ice_vsi_release (vsi); +ice_vf_invalidate_vsi (vf); +} +/** * ice_vf_set_initialized - VF is ready for VIRTCHNL communication * @vf: VF to set in initialized state
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h +1 -0
@@ -36,6 +36,7 @@ void ice_vf_ctrl_invalidate_vsi(struct ice_vf *vf);void ice_vf_ctrl_vsi_release (struct ice_vf *vf);struct ice_vsi *ice_vf_ctrl_vsi_setup (struct ice_vf *vf);void ice_vf_invalidate_vsi (struct ice_vf *vf); +void ice_vf_vsi_release (struct ice_vf *vf);void ice_vf_set_initialized (struct ice_vf *vf);#endif /* _ICE_VF_LIB_PRIVATE_H_ */
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 7/13 ice: Pull common tasks into ice_vf_post_vsi_rebuild
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The Single Root IOV implementation of .post_vsi_rebuild performs some tasks that will ultimately need to be shared with the Scalable IOV implementation such as rebuilding the host configuration.
Refactor by introducing a new wrapper function, ice_vf_post_vsi_rebuild which performs the tasks that will be shared between SR-IOV and Scalable IOV. Move the ice_vf_rebuild_host_cfg and ice_vf_set_initialized calls into this wrapper. Then call the implementation specific post_vsi_rebuild handler afterwards.
This ensures that we will properly re-initialize filters and expected settings for both SR-IOV and Scalable IOV.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 2 -- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -2
@@ -816,8 +816,6 @@ static int ice_sriov_vsi_rebuild(struct ice_vf *vf)*/ static void ice_sriov_post_vsi_rebuild (struct ice_vf *vf) { -ice_vf_rebuild_host_cfg (vf); -ice_vf_set_initialized (vf);ice_ena_vf_mappings (vf);wr32 (&vf->pf->hw,VFGEN_RSTAT (vf->vf_id),VIRTCHNL_VFR_VFACTIVE ); }
drivers/net/ethernet/intel/ice/ice_vf_lib.c +17 -2
@@ -270,6 +270,21 @@ static int ice_vf_rebuild_vsi(struct ice_vf *vf)return 0 ; } +/** +* ice_vf_post_vsi_rebuild - Reset tasks that occur after VSI rebuild +* @vf: the VF being reset +* +* Perform reset tasks which must occur after the VSI has been re-created or +* rebuilt during a VF reset. +*/ +static void ice_vf_post_vsi_rebuild (struct ice_vf *vf) +{ +ice_vf_rebuild_host_cfg (vf); +ice_vf_set_initialized (vf); + + vf->vf_ops->post_vsi_rebuild (vf); +} +/** * ice_is_any_vf_in_unicast_promisc - check if any VF(s) * are in unicast promiscuous mode
@@ -495,7 +510,7 @@ void ice_reset_all_vfs(struct ice_pf *pf)ice_vf_pre_vsi_rebuild (vf);ice_vf_rebuild_vsi (vf); - vf->vf_ops->post_vsi_rebuild (vf); +ice_vf_post_vsi_rebuild (vf);mutex_unlock (&vf->cfg_lock); }
@@ -646,7 +661,7 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags) goto out_unlock; } - vf->vf_ops->post_vsi_rebuild (vf); +ice_vf_post_vsi_rebuild (vf); vsi =ice_get_vf_vsi (vf);if (WARN_ON (!vsi)) { err = -EINVAL ;
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 8/13 ice: add a function to initialize vf entry
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
Some of the initialization code for Single Root IOV VFs will need to be reused when we introduce Scalable IOV. Pull this code out into a new ice_initialize_vf_entry helper function.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 16 ++---------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 26 +++++++++++++++++++ .../ethernet/intel/ice/ice_vf_lib_private.h | 1 + 3 files changed, 29 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -14
@@ -867,21 +867,9 @@ static int ice_create_vf_entries(struct ice_pf *pf, u16 num_vfs)/* set sriov vf ops for VFs created during SRIOV flow */ vf->vf_ops = &ice_sriov_vf_ops; - vf->vf_sw_id = pf->first_sw; -/* assign default capabilities */ - vf->spoofchk = true; - vf->num_vf_qs = pf->vfs.num_qps_per; -ice_vc_set_default_allowlist (vf); - -/* ctrl_vsi_idx will be set to a valid value only when VF -* creates its first fdir rule. -*/ -ice_vf_ctrl_invalidate_vsi (vf); -ice_vf_fdir_init (vf); +ice_initialize_vf_entry (vf); -ice_virtchnl_set_dflt_ops (vf); - -mutex_init (&vf->cfg_lock); + vf->vf_sw_id = pf->first_sw;hash_add_rcu (vfs->table, &vf->entry, vf_id); }
drivers/net/ethernet/intel/ice/ice_vf_lib.c +26 -0
@@ -698,6 +698,32 @@ void ice_set_vf_state_qs_dis(struct ice_vf *vf)/* Private functions only accessed from other virtualization files */ +/** +* ice_initialize_vf_entry - Initialize a VF entry +* @vf: pointer to the VF structure +*/ +void ice_initialize_vf_entry (struct ice_vf *vf) +{ +struct ice_pf *pf = vf->pf; +struct ice_vfs *vfs; + + vfs = &pf->vfs; + +/* assign default capabilities */ + vf->spoofchk = true; + vf->num_vf_qs = vfs->num_qps_per; +ice_vc_set_default_allowlist (vf); +ice_virtchnl_set_dflt_ops (vf); + +/* ctrl_vsi_idx will be set to a valid value only when iAVF +* creates its first fdir rule. +*/ +ice_vf_ctrl_invalidate_vsi (vf); +ice_vf_fdir_init (vf); + +mutex_init (&vf->cfg_lock); +} +/** * ice_dis_vf_qs - Disable the VF queues * @vf: pointer to the VF structure
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h +1 -0
@@ -23,6 +23,7 @@#warning "Only include ice_vf_lib_private.h in CONFIG_PCI_IOV virtualization files"#endif +void ice_initialize_vf_entry (struct ice_vf *vf);void ice_dis_vf_qs (struct ice_vf *vf);int ice_check_vf_init (struct ice_vf *vf);enum virtchnl_status_code ice_err_to_virt_err (int err);
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 9/13 ice: introduce ice_vf_init_host_cfg function
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
Introduce a new generic helper ice_vf_init_host_cfg which performs common host configuration initialization tasks that will need to be done for both Single Root IOV and the new Scalable IOV implementation.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 36 +------------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 54 +++++++++++++++++++ .../ethernet/intel/ice/ice_vf_lib_private.h | 1 + 3 files changed, 57 insertions(+), 34 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -34
@@ -573,51 +573,19 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)*/ static int ice_init_vf_vsi_res (struct ice_vf *vf) { -struct ice_vsi_vlan_ops *vlan_ops;struct ice_pf *pf = vf->pf; -u8 broadcast[ETH_ALEN ];struct ice_vsi *vsi; -struct device *dev;int err; vf->first_vector_idx =ice_calc_vf_first_vector_idx (pf, vf); - dev =ice_pf_to_dev (pf); vsi =ice_vf_vsi_setup (vf);if (!vsi)return -ENOMEM ; - err =ice_vsi_add_vlan_zero (vsi); -if (err) { -dev_warn (dev,"Failed to add VLAN 0 filter for VF %d\n" , - vf->vf_id); - goto release_vsi; - } - - vlan_ops =ice_get_compat_vsi_vlan_ops (vsi); - err = vlan_ops->ena_rx_filtering (vsi); -if (err) { -dev_warn (dev,"Failed to enable Rx VLAN filtering for VF %d\n" , - vf->vf_id); - goto release_vsi; - } - -eth_broadcast_addr (broadcast); - err =ice_fltr_add_mac (vsi, broadcast,ICE_FWD_TO_VSI ); -if (err) { -dev_err (dev,"Failed to add broadcast MAC filter for VF %d, error %d\n" , - vf->vf_id, err); - goto release_vsi; - } - - err =ice_vsi_apply_spoofchk (vsi, vf->spoofchk); -if (err) { -dev_warn (dev,"Failed to initialize spoofchk setting for VF %d\n" , - vf->vf_id); + err =ice_vf_init_host_cfg (vf, vsi); +if (err) goto release_vsi; - } - - vf->num_mac =1 ;return 0 ;
drivers/net/ethernet/intel/ice/ice_vf_lib.c +54 -0
60 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h +1 -0
@@ -36,6 +36,7 @@ void ice_vf_rebuild_host_cfg(struct ice_vf *vf);void ice_vf_ctrl_invalidate_vsi (struct ice_vf *vf);void ice_vf_ctrl_vsi_release (struct ice_vf *vf);struct ice_vsi *ice_vf_ctrl_vsi_setup (struct ice_vf *vf); +int ice_vf_init_host_cfg (struct ice_vf *vf,struct ice_vsi *vsi);void ice_vf_invalidate_vsi (struct ice_vf *vf);void ice_vf_vsi_release (struct ice_vf *vf);void ice_vf_set_initialized (struct ice_vf *vf);
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 10/13 ice: convert vf_ops .vsi_rebuild to .create_vsi
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
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.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 22 ++++++--------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 31 ++++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 2 +- 3 files changed, 40 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +9 -13
@@ -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, };
drivers/net/ethernet/intel/ice/ice_vf_lib.c +30 -1
@@ -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 ;
drivers/net/ethernet/intel/ice/ice_vf_lib.h +1 -1
@@ -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); };
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 11/13 ice: introduce clear_reset_state operation
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
When hardware is reset, the VF relies on the VFGEN_RSTAT register to detect when the VF is finished resetting. This is a tri-state register where 0 indicates a reset is in progress, 1 indicates the hardware is done resetting, and 2 indicates that the software is done resetting.
Currently the PF driver relies on the device hardware resetting VFGEN_RSTAT when a global reset occurs. This works ok, but it does mean that the VF might not immediately notice a reset when the driver first detects that the global reset is occurring.
This is also problematic for Scalable IOV, because there is no read/write equivalent VFGEN_RSTAT register for the Scalable VSI type. Instead, the Scalable IOV VFs will need to emulate this register.
To support this, introduce a new VF operation, clear_reset_state, which is called when the PF driver first detects a global reset. The Single Root IOV implementation can just write to VFGEN_RSTAT to ensure it's cleared immediately, without waiting for the actual hardware reset to begin. The Scalable IOV implementation will use this as part of its tracking of the reset status to allow properly reporting the emulated VFGEN_RSTAT to the VF driver.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 16 ++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 12 +++++++++++- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 5 +++-- 4 files changed, 31 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -537,7 +537,7 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)/* Disable VFs until reset is completed */ mutex_lock (&pf->vfs.table_lock);ice_for_each_vf (pf, bkt, vf) -ice_set_vf_state_qs_dis (vf); +ice_set_vf_state_dis (vf);mutex_unlock (&pf->vfs.table_lock);if (ice_is_eswitch_mode_switchdev (pf)) {
drivers/net/ethernet/intel/ice/ice_sriov.c +16 -0
@@ -654,6 +654,21 @@ static void ice_sriov_free_vf(struct ice_vf *vf)kfree_rcu (vf, rcu); } +/** +* ice_sriov_clear_reset_state - clears VF Reset status register +* @vf: the vf to configure +*/ +static void ice_sriov_clear_reset_state (struct ice_vf *vf) +{ +struct ice_hw *hw = &vf->pf->hw; + +/* Clear the reset status register so that VF immediately sees that +* the device is resetting, even if hardware hasn't yet gotten around +* to clearing VFGEN_RSTAT for us. +*/ +wr32 (hw,VFGEN_RSTAT (vf->vf_id),VIRTCHNL_VFR_INPROGRESS ); +} +/** * ice_sriov_clear_mbx_register - clears SRIOV VF's mailbox registers * @vf: the vf to configure
@@ -787,6 +802,7 @@ static void ice_sriov_post_vsi_rebuild(struct ice_vf *vf)static const struct ice_vf_ops ice_sriov_vf_ops = { .reset_type =ICE_VF_RESET , .free = ice_sriov_free_vf, + .clear_reset_state = ice_sriov_clear_reset_state, .clear_mbx_register = ice_sriov_clear_mbx_register, .trigger_reset_register = ice_sriov_trigger_reset_register, .poll_reset_status = ice_sriov_poll_reset_status,
drivers/net/ethernet/intel/ice/ice_vf_lib.c +11 -1
@@ -717,7 +717,7 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)* ice_set_vf_state_qs_dis - Set VF queues state to disabled * @vf: pointer to the VF structure */ -void ice_set_vf_state_qs_dis (struct ice_vf *vf) +static void ice_set_vf_state_qs_dis (struct ice_vf *vf) {/* Clear Rx/Tx enabled queues flag */ bitmap_zero (vf->txq_ena,ICE_MAX_RSS_QS_PER_VF );
@@ -725,6 +725,16 @@ void ice_set_vf_state_qs_dis(struct ice_vf *vf)clear_bit (ICE_VF_STATE_QS_ENA , vf->vf_states); } +/** +* ice_set_vf_state_dis - Set VF state to disabled +* @vf: pointer to the VF structure +*/ +void ice_set_vf_state_dis (struct ice_vf *vf) +{ +ice_set_vf_state_qs_dis (vf); + vf->vf_ops->clear_reset_state (vf); +} +/* Private functions only accessed from other virtualization files */ /**
drivers/net/ethernet/intel/ice/ice_vf_lib.h +3 -2
@@ -56,6 +56,7 @@ struct ice_mdd_vf_events {struct ice_vf_ops {enum ice_disq_rst_src reset_type;void (*free)(struct ice_vf *vf); +void (*clear_reset_state)(struct ice_vf *vf);void (*clear_mbx_register)(struct ice_vf *vf);void (*trigger_reset_register)(struct ice_vf *vf,bool is_vflr);bool (*poll_reset_status)(struct ice_vf *vf);
@@ -213,7 +214,7 @@ u16 ice_get_num_vfs(struct ice_pf *pf);struct ice_vsi *ice_get_vf_vsi (struct ice_vf *vf);bool ice_is_vf_disabled (struct ice_vf *vf);int ice_check_vf_ready_for_cfg (struct ice_vf *vf); -void ice_set_vf_state_qs_dis (struct ice_vf *vf); +void ice_set_vf_state_dis (struct ice_vf *vf);bool ice_is_any_vf_in_unicast_promisc (struct ice_pf *pf); void ice_vf_get_promisc_masks(struct ice_vf *vf, struct ice_vsi *vsi,
@@ -259,7 +260,7 @@ static inline int ice_check_vf_ready_for_cfg(struct ice_vf *vf)return -EOPNOTSUPP ; } -static inline void ice_set_vf_state_qs_dis (struct ice_vf *vf) +static inline void ice_set_vf_state_dis (struct ice_vf *vf) { }
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 12/13 ice: introduce .irq_close VF operation
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The Scalable IOV implementation will require notifying the VDCM driver when an IRQ must be closed. This allows the VDCM to handle releasing stale IRQ context values and properly reconfigure.
To handle this, introduce a new optional .irq_close callback to the VF operations structure. This will be implemented by Scalable IOV to handle the shutdown of the IRQ context.
Since the SR-IOV implementation does not need this, we must check that its non-NULL before calling it.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 ++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 1 + 3 files changed, 6 insertions(+)
drivers/net/ethernet/intel/ice/ice_sriov.c +1 -0
@@ -807,6 +807,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, + .irq_close = NULL, .create_vsi = ice_sriov_create_vsi, .post_vsi_rebuild = ice_sriov_post_vsi_rebuild, };
drivers/net/ethernet/intel/ice/ice_vf_lib.c +4 -0
@@ -237,6 +237,10 @@ static void ice_vf_clear_counters(struct ice_vf *vf)*/ static void ice_vf_pre_vsi_rebuild (struct ice_vf *vf) { +/* Close any IRQ mapping now */ +if (vf->vf_ops->irq_close) + vf->vf_ops->irq_close (vf); +ice_vf_clear_counters (vf); vf->vf_ops->clear_reset_trigger (vf); }
drivers/net/ethernet/intel/ice/ice_vf_lib.h +1 -0
@@ -61,6 +61,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); +void (*irq_close)(struct ice_vf *vf);int (*create_vsi)(struct ice_vf *vf);void (*post_vsi_rebuild)(struct ice_vf *vf); };
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH 13/13 ice: remove unnecessary virtchnl_ether_addr struct use
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
The dev_lan_addr and hw_lan_addr members of ice_vf are used only to store the MAC address for the VF. They are defined using virtchnl_ether_addr, but only the .addr sub-member is actually used. Drop the use of virtchnl_ether_addr and just use a u8 array of length [ETH_ALEN].
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 18 +++++++------- drivers/net/ethernet/intel/ice/ice_sriov.c | 16 ++++++------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 8 +++---- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 4 ++-- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 24 +++++++++---------- 5 files changed, 35 insertions(+), 35 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +9 -9
@@ -71,17 +71,17 @@ void ice_eswitch_replay_vf_mac_rule(struct ice_vf *vf)if (!ice_is_switchdev_running (vf->pf))return ; -if (is_valid_ether_addr (vf->hw_lan_addr.addr)) { +if (is_valid_ether_addr (vf->hw_lan_addr)) { err =ice_eswitch_add_vf_mac_rule (vf->pf, vf, - vf->hw_lan_addr.addr); + vf->hw_lan_addr);if (err) {dev_err (ice_pf_to_dev (vf->pf),"Failed to add MAC %pM for VF %d\n, error %d\n" , - vf->hw_lan_addr.addr, vf->vf_id, err); + vf->hw_lan_addr, vf->vf_id, err);return ; } vf->num_mac++; -ether_addr_copy (vf->dev_lan_addr.addr, vf->hw_lan_addr.addr); +ether_addr_copy (vf->dev_lan_addr, vf->hw_lan_addr); } }
@@ -237,7 +237,7 @@ ice_eswitch_release_reprs(struct ice_pf *pf, struct ice_vsi *ctrl_vsi)ice_vsi_update_security (vsi, ice_vsi_ctx_set_antispoof);metadata_dst_free (vf->repr->dst); vf->repr->dst =NULL ; -ice_fltr_add_mac_and_broadcast (vsi, vf->hw_lan_addr.addr, +ice_fltr_add_mac_and_broadcast (vsi, vf->hw_lan_addr,ICE_FWD_TO_VSI );netif_napi_del (&vf->repr->q_vector->napi);
@@ -265,14 +265,14 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf) GFP_KERNEL);if (!vf->repr->dst) {ice_fltr_add_mac_and_broadcast (vsi, - vf->hw_lan_addr.addr, + vf->hw_lan_addr,ICE_FWD_TO_VSI ); goto err; }if (ice_vsi_update_security (vsi, ice_vsi_ctx_clear_antispoof)) {ice_fltr_add_mac_and_broadcast (vsi, - vf->hw_lan_addr.addr, + vf->hw_lan_addr,ICE_FWD_TO_VSI );metadata_dst_free (vf->repr->dst); vf->repr->dst =NULL ;
@@ -281,7 +281,7 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf)if (ice_vsi_add_vlan_zero (vsi)) {ice_fltr_add_mac_and_broadcast (vsi, - vf->hw_lan_addr.addr, + vf->hw_lan_addr,ICE_FWD_TO_VSI );metadata_dst_free (vf->repr->dst); vf->repr->dst =NULL ;
@@ -338,7 +338,7 @@ void ice_eswitch_update_repr(struct ice_vsi *vsi) ret =ice_vsi_update_security (vsi, ice_vsi_ctx_clear_antispoof);if (ret) { -ice_fltr_add_mac_and_broadcast (vsi, vf->hw_lan_addr.addr,ICE_FWD_TO_VSI ); +ice_fltr_add_mac_and_broadcast (vsi, vf->hw_lan_addr,ICE_FWD_TO_VSI );dev_err (ice_pf_to_dev (pf),"Failed to update VF %d port representor" , vsi->vf->vf_id); }
drivers/net/ethernet/intel/ice/ice_sriov.c +8 -8
@@ -1242,7 +1242,7 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi) goto out_put_vf; ivi->vf = vf_id; -ether_addr_copy (ivi->mac, vf->hw_lan_addr.addr); +ether_addr_copy (ivi->mac, vf->hw_lan_addr);/* VF configuration for VLAN and applicable QoS */ ivi->vlan =ice_vf_get_port_vlan_id (vf);
@@ -1290,8 +1290,8 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)return -EINVAL ;/* nothing left to do, unicast MAC already set */ -if (ether_addr_equal (vf->dev_lan_addr.addr, mac) && -ether_addr_equal (vf->hw_lan_addr.addr, mac)) { +if (ether_addr_equal (vf->dev_lan_addr, mac) && +ether_addr_equal (vf->hw_lan_addr, mac)) { ret =0 ; goto out_put_vf; }
@@ -1305,8 +1305,8 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)/* VF is notified of its new MAC via the PF's response to the * VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset */ -ether_addr_copy (vf->dev_lan_addr.addr, mac); -ether_addr_copy (vf->hw_lan_addr.addr, mac); +ether_addr_copy (vf->dev_lan_addr, mac); +ether_addr_copy (vf->hw_lan_addr, mac);if (is_zero_ether_addr (mac)) {/* VF will send VIRTCHNL_OP_ADD_ETH_ADDR message with its MAC */ vf->pf_set_mac = false;
@@ -1707,7 +1707,7 @@ void ice_print_vf_rx_mdd_event(struct ice_vf *vf)dev_info (dev,"%d Rx Malicious Driver Detection events detected on PF %d VF %d MAC %pM. mdd-auto-reset-vfs=%s\n" , vf->mdd_rx_events.count, pf->hw.pf_id, vf->vf_id, - vf->dev_lan_addr.addr, + vf->dev_lan_addr,test_bit (ICE_FLAG_MDD_AUTO_RESET_VF , pf->flags) ?"on" :"off" ); }
@@ -1751,7 +1751,7 @@ void ice_print_vfs_mdd_events(struct ice_pf *pf)dev_info (dev,"%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM.\n" , vf->mdd_tx_events.count, hw->pf_id, vf->vf_id, - vf->dev_lan_addr.addr); + vf->dev_lan_addr); } }mutex_unlock (&pf->vfs.table_lock);
@@ -1841,7 +1841,7 @@ ice_is_malicious_vf(struct ice_pf *pf, struct ice_rq_event_info *event,if (pf_vsi)dev_warn (dev,"VF MAC %pM on PF MAC %pM is generating asynchronous messages and may be overflowing the PF message queue. Please see the Adapter User Guide for more information\n" , - &vf->dev_lan_addr.addr[0 ], + &vf->dev_lan_addr[0 ], pf_vsi->netdev->dev_addr); } }
drivers/net/ethernet/intel/ice/ice_vf_lib.c +4 -4
@@ -1008,18 +1008,18 @@ static int ice_vf_rebuild_host_mac_cfg(struct ice_vf *vf) vf->num_mac++; -if (is_valid_ether_addr (vf->hw_lan_addr.addr)) { - status =ice_fltr_add_mac (vsi, vf->hw_lan_addr.addr, +if (is_valid_ether_addr (vf->hw_lan_addr)) { + status =ice_fltr_add_mac (vsi, vf->hw_lan_addr,ICE_FWD_TO_VSI );if (status) {dev_err (dev,"failed to add default unicast MAC filter %pM for VF %u, error %d\n" , - &vf->hw_lan_addr.addr[0 ], vf->vf_id, + &vf->hw_lan_addr[0 ], vf->vf_id, status);return status; } vf->num_mac++; -ether_addr_copy (vf->dev_lan_addr.addr, vf->hw_lan_addr.addr); +ether_addr_copy (vf->dev_lan_addr, vf->hw_lan_addr); }return 0 ;
drivers/net/ethernet/intel/ice/ice_vf_lib.h +2 -2
@@ -98,8 +98,8 @@ struct ice_vf {struct ice_sw *vf_sw_id;/* switch ID the VF VSIs connect to */ struct virtchnl_version_info vf_ver;u32 driver_caps;/* reported by VF driver */ -struct virtchnl_ether_addr dev_lan_addr; -struct virtchnl_ether_addr hw_lan_addr; +u8 dev_lan_addr[ETH_ALEN ]; +u8 hw_lan_addr[ETH_ALEN ];struct ice_time_mac legacy_last_added_umac;DECLARE_BITMAP (txq_ena,ICE_MAX_RSS_QS_PER_VF );DECLARE_BITMAP (rxq_ena,ICE_MAX_RSS_QS_PER_VF );
drivers/net/ethernet/intel/ice/ice_virtchnl.c +12 -12
@@ -507,7 +507,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) vfres->vsi_res[0 ].vsi_type =VIRTCHNL_VSI_SRIOV ; vfres->vsi_res[0 ].num_queue_pairs = vsi->num_txq;ether_addr_copy (vfres->vsi_res[0 ].default_mac_addr, - vf->hw_lan_addr.addr); + vf->hw_lan_addr);/* match guest capabilities */ vf->driver_caps = vfres->vf_cap_flags;
@@ -1802,10 +1802,10 @@ ice_vfhw_mac_add(struct ice_vf *vf, struct virtchnl_ether_addr *vc_ether_addr)* was correctly specified over VIRTCHNL */ if ((ice_is_vc_addr_legacy (vc_ether_addr) && -is_zero_ether_addr (vf->hw_lan_addr.addr)) || +is_zero_ether_addr (vf->hw_lan_addr)) ||ice_is_vc_addr_primary (vc_ether_addr)) { -ether_addr_copy (vf->dev_lan_addr.addr, mac_addr); -ether_addr_copy (vf->hw_lan_addr.addr, mac_addr); +ether_addr_copy (vf->dev_lan_addr, mac_addr); +ether_addr_copy (vf->hw_lan_addr, mac_addr); }/* hardware and device MACs are already set, but its possible that the
@@ -1836,7 +1836,7 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi,int ret;/* device MAC already added */ -if (ether_addr_equal (mac_addr, vf->dev_lan_addr.addr)) +if (ether_addr_equal (mac_addr, vf->dev_lan_addr))return 0 ;if (is_unicast_ether_addr (mac_addr) && !ice_can_vf_change_mac (vf)) {
@@ -1891,8 +1891,8 @@ ice_update_legacy_cached_mac(struct ice_vf *vf, ice_is_legacy_umac_expired(&vf->legacy_last_added_umac)) return; -ether_addr_copy (vf->dev_lan_addr.addr, vf->legacy_last_added_umac.addr); -ether_addr_copy (vf->hw_lan_addr.addr, vf->legacy_last_added_umac.addr); +ether_addr_copy (vf->dev_lan_addr, vf->legacy_last_added_umac.addr); +ether_addr_copy (vf->hw_lan_addr, vf->legacy_last_added_umac.addr); }/**
@@ -1906,15 +1906,15 @@ ice_vfhw_mac_del(struct ice_vf *vf, struct virtchnl_ether_addr *vc_ether_addr)u8 *mac_addr = vc_ether_addr->addr;if (!is_valid_ether_addr (mac_addr) || - !ether_addr_equal (vf->dev_lan_addr.addr, mac_addr)) + !ether_addr_equal (vf->dev_lan_addr, mac_addr))return ;/* allow the device MAC to be repopulated in the add flow and don't -* clear the hardware MAC (i.e. hw_lan_addr.addr) here as that is meant +* clear the hardware MAC (i.e. hw_lan_addr) here as that is meant * to be persistent on VM reboot and across driver unload/load, which * won't work if we clear the hardware MAC here */ -eth_zero_addr (vf->dev_lan_addr.addr); +eth_zero_addr (vf->dev_lan_addr);ice_update_legacy_cached_mac (vf, vc_ether_addr); }
@@ -1934,7 +1934,7 @@ ice_vc_del_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi,int status;if (!ice_can_vf_change_mac (vf) && -ether_addr_equal (vf->dev_lan_addr.addr, mac_addr)) +ether_addr_equal (vf->dev_lan_addr, mac_addr))return 0 ; status =ice_fltr_remove_mac (vsi, mac_addr,ICE_FWD_TO_VSI );
@@ -3733,7 +3733,7 @@ static int ice_vc_repr_add_mac(struct ice_vf *vf, u8 *msg)int result;if (!is_unicast_ether_addr (mac_addr) || -ether_addr_equal (mac_addr, vf->hw_lan_addr.addr)) +ether_addr_equal (mac_addr, vf->hw_lan_addr))continue ;if (vf->pf_set_mac) {
Signature · 1 line
2.38.1
This series was applied to netdev/net-next.git (master) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Tony Nguyen <[email protected]>:
Quoted 9 lines · On Mon, 6 Feb 2023 13:48:00 -0800 you wrote:
Jacob Keller says:
This series contains a variety of refactors and cleanups in the VF code for the ice driver. Its primary focus is cleanup and simplification of the VF operations and addition of a few new operations that will be required by Scalable IOV, as well as some other refactors needed for the handling of VF subfunctions.
[...]
Here is the summary with links:
- [net-next,01/13] ice: Add more usage of existing function ice_get_vf_vsi(vf)
https://git.kernel.org/netdev/net-next/c/772dec645934 - [net-next,02/13] ice: fix function comment referring to ice_vsi_alloc https://git.kernel.org/netdev/net-next/c/a2ca73eae33f - [net-next,03/13] ice: drop unnecessary VF parameter from several VSI functions https://git.kernel.org/netdev/net-next/c/157acda5b1fa - [net-next,04/13] ice: refactor VSI setup to use parameter structure https://git.kernel.org/netdev/net-next/c/5e509ab237f1 - [net-next,05/13] ice: move vsi_type assignment from ice_vsi_alloc to ice_vsi_cfg https://git.kernel.org/netdev/net-next/c/e15881970692 - [net-next,06/13] ice: move ice_vf_vsi_release into ice_vf_lib.c https://git.kernel.org/netdev/net-next/c/1efee0734b98 - [net-next,07/13] ice: Pull common tasks into ice_vf_post_vsi_rebuild https://git.kernel.org/netdev/net-next/c/aeead3d04fa0 - [net-next,08/13] ice: add a function to initialize vf entry https://git.kernel.org/netdev/net-next/c/b5dcff1fd57a - [net-next,09/13] ice: introduce ice_vf_init_host_cfg function https://git.kernel.org/netdev/net-next/c/b1b5694235ef - [net-next,10/13] ice: convert vf_ops .vsi_rebuild to .create_vsi https://git.kernel.org/netdev/net-next/c/5531bb851fba - [net-next,11/13] ice: introduce clear_reset_state operation https://git.kernel.org/netdev/net-next/c/fa4a15c85c84 - [net-next,12/13] ice: introduce .irq_close VF operation https://git.kernel.org/netdev/net-next/c/537dfe06acca - [net-next,13/13] ice: remove unnecessary virtchnl_ether_addr struct use https://git.kernel.org/netdev/net-next/c/e0645311e1ab
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html