提交 94ab2488 编写于 作者: J Jacob Keller 提交者: Tony Nguyen

ice: cleanup error logging for ice_ena_vfs

The ice_ena_vfs function and some of its sub-functions like
ice_set_per_vf_res use a "if (<function>) { <print error> ; <exit> }"
flow. This flow discards specialized errors reported by the called
function.

This style is generally not preferred as it makes tracing error sources
more difficult. It also means we cannot log the actual error received
properly.

Refactor several calls in the ice_ena_vfs function that do this to catch
the error in the 'ret' variable. Report this in the messages, and then
return the more precise error value.

Doing this reveals that ice_set_per_vf_res returns -EINVAL or -EIO in
places where -ENOSPC makes more sense. Fix these calls up to return the
more appropriate value.
Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
上级 346f7aa3
...@@ -1275,12 +1275,16 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs) ...@@ -1275,12 +1275,16 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)
u16 num_msix_per_vf, num_txq, num_rxq, avail_qs; u16 num_msix_per_vf, num_txq, num_rxq, avail_qs;
int msix_avail_per_vf, msix_avail_for_sriov; int msix_avail_per_vf, msix_avail_for_sriov;
struct device *dev = ice_pf_to_dev(pf); struct device *dev = ice_pf_to_dev(pf);
int err;
lockdep_assert_held(&pf->vfs.table_lock); lockdep_assert_held(&pf->vfs.table_lock);
if (!num_vfs || max_valid_res_idx < 0) if (!num_vfs)
return -EINVAL; return -EINVAL;
if (max_valid_res_idx < 0)
return -ENOSPC;
/* determine MSI-X resources per VF */ /* determine MSI-X resources per VF */
msix_avail_for_sriov = pf->hw.func_caps.common_cap.num_msix_vectors - msix_avail_for_sriov = pf->hw.func_caps.common_cap.num_msix_vectors -
pf->irq_tracker->num_entries; pf->irq_tracker->num_entries;
...@@ -1297,7 +1301,7 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs) ...@@ -1297,7 +1301,7 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)
dev_err(dev, "Only %d MSI-X interrupts available for SR-IOV. Not enough to support minimum of %d MSI-X interrupts per VF for %d VFs\n", dev_err(dev, "Only %d MSI-X interrupts available for SR-IOV. Not enough to support minimum of %d MSI-X interrupts per VF for %d VFs\n",
msix_avail_for_sriov, ICE_MIN_INTR_PER_VF, msix_avail_for_sriov, ICE_MIN_INTR_PER_VF,
num_vfs); num_vfs);
return -EIO; return -ENOSPC;
} }
num_txq = min_t(u16, num_msix_per_vf - ICE_NONQ_VECS_VF, num_txq = min_t(u16, num_msix_per_vf - ICE_NONQ_VECS_VF,
...@@ -1319,13 +1323,14 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs) ...@@ -1319,13 +1323,14 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)
if (num_txq < ICE_MIN_QS_PER_VF || num_rxq < ICE_MIN_QS_PER_VF) { if (num_txq < ICE_MIN_QS_PER_VF || num_rxq < ICE_MIN_QS_PER_VF) {
dev_err(dev, "Not enough queues to support minimum of %d queue pairs per VF for %d VFs\n", dev_err(dev, "Not enough queues to support minimum of %d queue pairs per VF for %d VFs\n",
ICE_MIN_QS_PER_VF, num_vfs); ICE_MIN_QS_PER_VF, num_vfs);
return -EIO; return -ENOSPC;
} }
if (ice_sriov_set_msix_res(pf, num_msix_per_vf * num_vfs)) { err = ice_sriov_set_msix_res(pf, num_msix_per_vf * num_vfs);
dev_err(dev, "Unable to set MSI-X resources for %d VFs\n", if (err) {
num_vfs); dev_err(dev, "Unable to set MSI-X resources for %d VFs, err %d\n",
return -EINVAL; num_vfs, err);
return err;
} }
/* only allow equal Tx/Rx queue count (i.e. queue pairs) */ /* only allow equal Tx/Rx queue count (i.e. queue pairs) */
...@@ -2058,10 +2063,10 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs) ...@@ -2058,10 +2063,10 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
mutex_lock(&pf->vfs.table_lock); mutex_lock(&pf->vfs.table_lock);
if (ice_set_per_vf_res(pf, num_vfs)) { ret = ice_set_per_vf_res(pf, num_vfs);
dev_err(dev, "Not enough resources for %d VFs, try with fewer number of VFs\n", if (ret) {
num_vfs); dev_err(dev, "Not enough resources for %d VFs, err %d. Try with fewer number of VFs\n",
ret = -ENOSPC; num_vfs, ret);
goto err_unroll_sriov; goto err_unroll_sriov;
} }
...@@ -2072,8 +2077,9 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs) ...@@ -2072,8 +2077,9 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
goto err_unroll_sriov; goto err_unroll_sriov;
} }
if (ice_start_vfs(pf)) { ret = ice_start_vfs(pf);
dev_err(dev, "Failed to start VF(s)\n"); if (ret) {
dev_err(dev, "Failed to start %d VFs, err %d\n", num_vfs, ret);
ret = -EAGAIN; ret = -EAGAIN;
goto err_unroll_vf_entries; goto err_unroll_vf_entries;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册