Skip to content

Commit

Permalink
ice: remove PF pointer from ice_check_vf_init
Browse files Browse the repository at this point in the history
The ice_check_vf_init function takes both a PF and a VF pointer. Every
caller looks up the PF pointer from the VF structure. Some callers only
use of the PF pointer is call this function. Move the lookup inside
ice_check_vf_init and drop the unnecessary argument.

Cleanup the callers to drop the now unnecessary local variables. In
particular, replace the local PF pointer with a HW structure pointer in
ice_vc_get_vf_res_msg which simplifies a few accesses to the HW
structure in that function.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
  • Loading branch information
Jacob Keller authored and Tony Nguyen committed Mar 15, 2022
1 parent bf93bf7 commit 5a57ee8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
16 changes: 7 additions & 9 deletions drivers/net/ethernet/intel/ice/ice_vf_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,12 @@ static void ice_wait_on_vf_reset(struct ice_vf *vf)
*/
int ice_check_vf_ready_for_cfg(struct ice_vf *vf)
{
struct ice_pf *pf;

ice_wait_on_vf_reset(vf);

if (ice_is_vf_disabled(vf))
return -EINVAL;

pf = vf->pf;
if (ice_check_vf_init(pf, vf))
if (ice_check_vf_init(vf))
return -EBUSY;

return 0;
Expand Down Expand Up @@ -620,11 +617,12 @@ void ice_dis_vf_qs(struct ice_vf *vf)

/**
* ice_check_vf_init - helper to check if VF init complete
* @pf: pointer to the PF structure
* @vf: the pointer to the VF to check
*/
int ice_check_vf_init(struct ice_pf *pf, struct ice_vf *vf)
int ice_check_vf_init(struct ice_vf *vf)
{
struct ice_pf *pf = vf->pf;

if (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) {
dev_err(ice_pf_to_dev(pf), "VF ID: %u in reset. Try again.\n",
vf->vf_id);
Expand Down Expand Up @@ -752,17 +750,17 @@ bool ice_vf_has_no_qs_ena(struct ice_vf *vf)
*/
bool ice_is_vf_link_up(struct ice_vf *vf)
{
struct ice_pf *pf = vf->pf;
struct ice_port_info *pi = ice_vf_get_port_info(vf);

if (ice_check_vf_init(pf, vf))
if (ice_check_vf_init(vf))
return false;

if (ice_vf_has_no_qs_ena(vf))
return false;
else if (vf->link_forced)
return vf->link_up;
else
return pf->hw.port_info->phy.link_info.link_info &
return pi->phy.link_info.link_info &
ICE_AQ_LINK_UP;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/intel/ice/ice_vf_lib_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#endif

void ice_dis_vf_qs(struct ice_vf *vf);
int ice_check_vf_init(struct ice_pf *pf, struct ice_vf *vf);
int ice_check_vf_init(struct ice_vf *vf);
struct ice_port_info *ice_vf_get_port_info(struct ice_vf *vf);
int ice_vsi_apply_spoofchk(struct ice_vsi *vsi, bool enable);
bool ice_is_vf_trusted(struct ice_vf *vf);
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/ethernet/intel/ice/ice_virtchnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,12 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
{
enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
struct virtchnl_vf_resource *vfres = NULL;
struct ice_pf *pf = vf->pf;
struct ice_hw *hw = &vf->pf->hw;
struct ice_vsi *vsi;
int len = 0;
int ret;

if (ice_check_vf_init(pf, vf)) {
if (ice_check_vf_init(vf)) {
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
goto err;
}
Expand Down Expand Up @@ -412,17 +412,17 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
* inner/single VLAN respectively and don't allow VF to
* negotiate VIRTCHNL_VF_OFFLOAD in any other cases
*/
if (ice_is_dvm_ena(&pf->hw) && ice_vf_is_port_vlan_ena(vf)) {
if (ice_is_dvm_ena(hw) && ice_vf_is_port_vlan_ena(vf)) {
vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_VLAN;
} else if (!ice_is_dvm_ena(&pf->hw) &&
} else if (!ice_is_dvm_ena(hw) &&
!ice_vf_is_port_vlan_ena(vf)) {
vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_VLAN;
/* configure backward compatible support for VFs that
* only support VIRTCHNL_VF_OFFLOAD_VLAN, the PF is
* configured in SVM, and no port VLAN is configured
*/
ice_vf_vsi_cfg_svm_legacy_vlan_mode(vsi);
} else if (ice_is_dvm_ena(&pf->hw)) {
} else if (ice_is_dvm_ena(hw)) {
/* configure software offloaded VLAN support when DVM
* is enabled, but no port VLAN is enabled
*/
Expand Down Expand Up @@ -472,7 +472,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
vfres->num_vsis = 1;
/* Tx and Rx queue are equal for VF */
vfres->num_queue_pairs = vsi->num_txq;
vfres->max_vectors = pf->vfs.num_msix_per;
vfres->max_vectors = vf->pf->vfs.num_msix_per;
vfres->rss_key_size = ICE_VSIQF_HKEY_ARRAY_SIZE;
vfres->rss_lut_size = ICE_VSIQF_HLUT_ARRAY_SIZE;
vfres->max_mtu = ice_vc_get_max_frame_size(vf);
Expand Down

0 comments on commit 5a57ee8

Please sign in to comment.