net/iavf: ensure no polling during VF initiated reset
PATCH 1/1 net/iavf: ensure no polling during VF initiated reset
Ensure that the datapath functions will not poll during a vf initiated reset. Otherwise the datapath could access freed resources and cause a core dump. Achieve this by ensuring that the no-poll-on-link-down devarg is set when trying to reinit a started device. If it's not set, suggest stopping the port before the reinit.
--- drivers/net/intel/iavf/iavf_ethdev.c | 40 +++++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-)
drivers/net/intel/iavf/iavf_ethdev.c +30 -10
@@ -3102,13 +3102,18 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev, bool vf_initiated_reset)struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (dev->data->dev_private);struct iavf_adapter *adapter = dev->data->dev_private;int ret; +bool restart_device = false; -if (!dev->data->dev_started) -return ; +if (vf_initiated_reset) { + restart_device = dev->data->dev_started; + }else { +if (!dev->data->dev_started) +return ; -if (!vf_initiated_reset && !iavf_is_reset_detected (adapter)) { -PMD_DRV_LOG (DEBUG ,"reset not start" ); -return ; +if (!iavf_is_reset_detected (adapter)) { +PMD_DRV_LOG (DEBUG ,"reset not start" ); +return ; + } } vf->in_reset_recovery = true;
@@ -3125,12 +3130,14 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev, bool vf_initiated_reset)iavf_dev_xstats_reset (dev); -/* start the device */ - ret =iavf_dev_start (dev); -if (ret) - goto error; +if (!vf_initiated_reset || restart_device) { +/* start the device */ + ret =iavf_dev_start (dev); +if (ret) + goto error; - dev->data->dev_started =1 ; + dev->data->dev_started =1 ; + } goto exit; error:
@@ -3147,6 +3154,7 @@ int rte_pmd_iavf_reinit(uint16_t port) {struct rte_eth_dev *dev; +struct iavf_adapter *adapter;RTE_ETH_VALID_PORTID_OR_ERR_RET (port, -ENODEV );
@@ -3157,6 +3165,18 @@ rte_pmd_iavf_reinit(uint16_t port)return -ENOTSUP ; } +if (!dev->data->dev_configured) { +PMD_DRV_LOG (ERR ,"Cannot reinit unconfigured port %u." , port); +return -EINVAL ; + } + + adapter = dev->data->dev_private; +if (dev->data->dev_started && !adapter->devargs.no_poll_on_link_down) { +PMD_DRV_LOG (ERR ,"Cannot reinit started port %u. Either stop the port or enable " +"no-poll-on-link-down in devargs." , port); +return -EINVAL ; + } +iavf_handle_hw_reset (dev, true);return 0 ;
Signature · 1 line
2.34.1
Quoted 11 lines · Ciara Loftus
Ensure that the datapath functions will not poll during a vf initiated reset. Otherwise the datapath could access freed resources and cause a core dump. Achieve this by ensuring that the no-poll-on-link-down devarg is set when trying to reinit a started device. If it's not set, suggest stopping the port before the reinit.
Signed-off-by Ciara Loftus <[email protected]>--- drivers/net/intel/iavf/iavf_ethdev.c | 40 +++++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-)
After discussing offline with Ciara, this patch is mostly a fix to the previous iavf reset patch, which is not yet pulled to main. Therefore patch squashed to original commit on next-net-intel tree.
Thanks,
/Bruce