提交 a476d72a 编写于 作者: A Anirudh Venkataramanan 提交者: Tony Nguyen

ice: Add new VSI states to track netdev alloc/registration

Add two new VSI states, one to track if a netdev for the VSI has been
allocated and the other to track if the netdev has been registered.
Call unregister_netdev/free_netdev only when the corresponding state
bits are set.
Signed-off-by: NAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: NTony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
上级 7e408e07
...@@ -241,6 +241,8 @@ enum ice_pf_state { ...@@ -241,6 +241,8 @@ enum ice_pf_state {
enum ice_vsi_state { enum ice_vsi_state {
ICE_VSI_DOWN, ICE_VSI_DOWN,
ICE_VSI_NEEDS_RESTART, ICE_VSI_NEEDS_RESTART,
ICE_VSI_NETDEV_ALLOCD,
ICE_VSI_NETDEV_REGISTERED,
ICE_VSI_UMAC_FLTR_CHANGED, ICE_VSI_UMAC_FLTR_CHANGED,
ICE_VSI_MMAC_FLTR_CHANGED, ICE_VSI_MMAC_FLTR_CHANGED,
ICE_VSI_VLAN_FLTR_CHANGED, ICE_VSI_VLAN_FLTR_CHANGED,
......
...@@ -2752,11 +2752,14 @@ int ice_vsi_release(struct ice_vsi *vsi) ...@@ -2752,11 +2752,14 @@ int ice_vsi_release(struct ice_vsi *vsi)
* PF that is running the work queue items currently. This is done to * PF that is running the work queue items currently. This is done to
* avoid check_flush_dependency() warning on this wq * avoid check_flush_dependency() warning on this wq
*/ */
if (vsi->netdev && !ice_is_reset_in_progress(pf->state)) { if (vsi->netdev && !ice_is_reset_in_progress(pf->state) &&
(test_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state))) {
unregister_netdev(vsi->netdev); unregister_netdev(vsi->netdev);
ice_devlink_destroy_port(vsi); clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
} }
ice_devlink_destroy_port(vsi);
if (test_bit(ICE_FLAG_RSS_ENA, pf->flags)) if (test_bit(ICE_FLAG_RSS_ENA, pf->flags))
ice_rss_clean(vsi); ice_rss_clean(vsi);
...@@ -2811,10 +2814,16 @@ int ice_vsi_release(struct ice_vsi *vsi) ...@@ -2811,10 +2814,16 @@ int ice_vsi_release(struct ice_vsi *vsi)
ice_vsi_delete(vsi); ice_vsi_delete(vsi);
ice_vsi_free_q_vectors(vsi); ice_vsi_free_q_vectors(vsi);
/* make sure unregister_netdev() was called by checking ICE_DOWN */ if (vsi->netdev) {
if (vsi->netdev && test_bit(ICE_VSI_DOWN, vsi->state)) { if (test_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state)) {
free_netdev(vsi->netdev); unregister_netdev(vsi->netdev);
vsi->netdev = NULL; clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
}
if (test_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state)) {
free_netdev(vsi->netdev);
vsi->netdev = NULL;
clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
}
} }
if (vsi->type == ICE_VSI_VF && if (vsi->type == ICE_VSI_VF &&
......
...@@ -2977,6 +2977,7 @@ static int ice_cfg_netdev(struct ice_vsi *vsi) ...@@ -2977,6 +2977,7 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)
if (!netdev) if (!netdev)
return -ENOMEM; return -ENOMEM;
set_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
vsi->netdev = netdev; vsi->netdev = netdev;
np = netdev_priv(netdev); np = netdev_priv(netdev);
np->vsi = vsi; np->vsi = vsi;
...@@ -3189,6 +3190,7 @@ static int ice_setup_pf_sw(struct ice_pf *pf) ...@@ -3189,6 +3190,7 @@ static int ice_setup_pf_sw(struct ice_pf *pf)
if (vsi) { if (vsi) {
ice_napi_del(vsi); ice_napi_del(vsi);
if (vsi->netdev) { if (vsi->netdev) {
clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
free_netdev(vsi->netdev); free_netdev(vsi->netdev);
vsi->netdev = NULL; vsi->netdev = NULL;
} }
...@@ -3958,6 +3960,7 @@ static int ice_register_netdev(struct ice_pf *pf) ...@@ -3958,6 +3960,7 @@ static int ice_register_netdev(struct ice_pf *pf)
if (err) if (err)
goto err_register_netdev; goto err_register_netdev;
set_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
netif_carrier_off(vsi->netdev); netif_carrier_off(vsi->netdev);
netif_tx_stop_all_queues(vsi->netdev); netif_tx_stop_all_queues(vsi->netdev);
err = ice_devlink_create_port(vsi); err = ice_devlink_create_port(vsi);
...@@ -3969,9 +3972,11 @@ static int ice_register_netdev(struct ice_pf *pf) ...@@ -3969,9 +3972,11 @@ static int ice_register_netdev(struct ice_pf *pf)
return 0; return 0;
err_devlink_create: err_devlink_create:
unregister_netdev(vsi->netdev); unregister_netdev(vsi->netdev);
clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
err_register_netdev: err_register_netdev:
free_netdev(vsi->netdev); free_netdev(vsi->netdev);
vsi->netdev = NULL; vsi->netdev = NULL;
clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册