Commit 6624e780 authored by Michal Swiatkowski's avatar Michal Swiatkowski Committed by Tony Nguyen

ice: split ice_vsi_setup into smaller functions

Main goal is to reuse the same functions in VSI config and rebuild
paths.
To do this split ice_vsi_setup into smaller pieces and reuse it during
rebuild.

ice_vsi_alloc() should only alloc memory, not set the default values
for VSI.
Move setting defaults to separate function. This will allow config of
already allocated VSI, for example in reload path.

The path is mostly moving code around without introducing new
functionality. Functions ice_vsi_cfg() and ice_vsi_decfg() were
added, but they are using code that already exist.

Use flag to pass information about VSI initialization during rebuild
instead of using boolean value.
Co-developed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 0db66d20
This diff is collapsed.
...@@ -61,8 +61,11 @@ int ice_vsi_release(struct ice_vsi *vsi); ...@@ -61,8 +61,11 @@ int ice_vsi_release(struct ice_vsi *vsi);
void ice_vsi_close(struct ice_vsi *vsi); void ice_vsi_close(struct ice_vsi *vsi);
int ice_vsi_cfg(struct ice_vsi *vsi, struct ice_vf *vf,
struct ice_channel *ch);
int ice_ena_vsi(struct ice_vsi *vsi, bool locked); int ice_ena_vsi(struct ice_vsi *vsi, bool locked);
void ice_vsi_decfg(struct ice_vsi *vsi);
void ice_dis_vsi(struct ice_vsi *vsi, bool locked); void ice_dis_vsi(struct ice_vsi *vsi, bool locked);
int ice_free_res(struct ice_res_tracker *res, u16 index, u16 id); int ice_free_res(struct ice_res_tracker *res, u16 index, u16 id);
...@@ -70,7 +73,9 @@ int ice_free_res(struct ice_res_tracker *res, u16 index, u16 id); ...@@ -70,7 +73,9 @@ int ice_free_res(struct ice_res_tracker *res, u16 index, u16 id);
int int
ice_get_res(struct ice_pf *pf, struct ice_res_tracker *res, u16 needed, u16 id); ice_get_res(struct ice_pf *pf, struct ice_res_tracker *res, u16 needed, u16 id);
int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi); #define ICE_VSI_FLAG_INIT BIT(0)
#define ICE_VSI_FLAG_NO_INIT 0
int ice_vsi_rebuild(struct ice_vsi *vsi, int init_vsi);
bool ice_is_reset_in_progress(unsigned long *state); bool ice_is_reset_in_progress(unsigned long *state);
int ice_wait_for_reset(struct ice_pf *pf, unsigned long timeout); int ice_wait_for_reset(struct ice_pf *pf, unsigned long timeout);
......
...@@ -4220,13 +4220,13 @@ int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx, bool locked) ...@@ -4220,13 +4220,13 @@ int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx, bool locked)
/* set for the next time the netdev is started */ /* set for the next time the netdev is started */
if (!netif_running(vsi->netdev)) { if (!netif_running(vsi->netdev)) {
ice_vsi_rebuild(vsi, false); ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT);
dev_dbg(ice_pf_to_dev(pf), "Link is down, queue count change happens when link is brought up\n"); dev_dbg(ice_pf_to_dev(pf), "Link is down, queue count change happens when link is brought up\n");
goto done; goto done;
} }
ice_vsi_close(vsi); ice_vsi_close(vsi);
ice_vsi_rebuild(vsi, false); ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT);
ice_pf_dcb_recfg(pf, locked); ice_pf_dcb_recfg(pf, locked);
ice_vsi_open(vsi); ice_vsi_open(vsi);
done: done:
...@@ -7056,7 +7056,7 @@ static int ice_vsi_rebuild_by_type(struct ice_pf *pf, enum ice_vsi_type type) ...@@ -7056,7 +7056,7 @@ static int ice_vsi_rebuild_by_type(struct ice_pf *pf, enum ice_vsi_type type)
continue; continue;
/* rebuild the VSI */ /* rebuild the VSI */
err = ice_vsi_rebuild(vsi, true); err = ice_vsi_rebuild(vsi, ICE_VSI_FLAG_INIT);
if (err) { if (err) {
dev_err(dev, "rebuild VSI failed, err %d, VSI index %d, type %s\n", dev_err(dev, "rebuild VSI failed, err %d, VSI index %d, type %s\n",
err, vsi->idx, ice_vsi_type_str(type)); err, vsi->idx, ice_vsi_type_str(type));
...@@ -8465,7 +8465,7 @@ static int ice_rebuild_channels(struct ice_pf *pf) ...@@ -8465,7 +8465,7 @@ static int ice_rebuild_channels(struct ice_pf *pf)
type = vsi->type; type = vsi->type;
/* rebuild ADQ VSI */ /* rebuild ADQ VSI */
err = ice_vsi_rebuild(vsi, true); err = ice_vsi_rebuild(vsi, ICE_VSI_FLAG_INIT);
if (err) { if (err) {
dev_err(dev, "VSI (type:%s) at index %d rebuild failed, err %d\n", dev_err(dev, "VSI (type:%s) at index %d rebuild failed, err %d\n",
ice_vsi_type_str(type), vsi->idx, err); ice_vsi_type_str(type), vsi->idx, err);
...@@ -8697,14 +8697,14 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data) ...@@ -8697,14 +8697,14 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data)
cur_rxq = vsi->num_rxq; cur_rxq = vsi->num_rxq;
/* proceed with rebuild main VSI using correct number of queues */ /* proceed with rebuild main VSI using correct number of queues */
ret = ice_vsi_rebuild(vsi, false); ret = ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT);
if (ret) { if (ret) {
/* fallback to current number of queues */ /* fallback to current number of queues */
dev_info(dev, "Rebuild failed with new queues, try with current number of queues\n"); dev_info(dev, "Rebuild failed with new queues, try with current number of queues\n");
vsi->req_txq = cur_txq; vsi->req_txq = cur_txq;
vsi->req_rxq = cur_rxq; vsi->req_rxq = cur_rxq;
clear_bit(ICE_RESET_FAILED, pf->state); clear_bit(ICE_RESET_FAILED, pf->state);
if (ice_vsi_rebuild(vsi, false)) { if (ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT)) {
dev_err(dev, "Rebuild of main VSI failed again\n"); dev_err(dev, "Rebuild of main VSI failed again\n");
return ret; return ret;
} }
......
...@@ -256,7 +256,7 @@ static int ice_vf_rebuild_vsi(struct ice_vf *vf) ...@@ -256,7 +256,7 @@ static int ice_vf_rebuild_vsi(struct ice_vf *vf)
if (WARN_ON(!vsi)) if (WARN_ON(!vsi))
return -EINVAL; return -EINVAL;
if (ice_vsi_rebuild(vsi, true)) { if (ice_vsi_rebuild(vsi, ICE_VSI_FLAG_INIT)) {
dev_err(ice_pf_to_dev(pf), "failed to rebuild VF %d VSI\n", dev_err(ice_pf_to_dev(pf), "failed to rebuild VF %d VSI\n",
vf->vf_id); vf->vf_id);
return -EIO; return -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment