From: Di ChenxuX <chenxux.di@intel.com>
To: dev@dpdk.org
Cc: qiming.yang@intel.com, Di ChenxuX <chenxux.di@intel.com>
Subject: [dpdk-dev] [PATCH v3 3/5] net/i40e: release port upon close
Date: Thu, 5 Sep 2019 11:03:57 +0000 [thread overview]
Message-ID: <20190905110359.62406-4-chenxux.di@intel.com> (raw)
In-Reply-To: <20190905110359.62406-1-chenxux.di@intel.com>
Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the private resources
for the port can be freed by rte_eth_dev_close().
Signed-off-by: Di ChenxuX <chenxux.di@intel.com>
---
drivers/net/i40e/i40e_ethdev.c | 128 ++++++++++++++----------------
drivers/net/i40e/i40e_ethdev_vf.c | 25 +++---
2 files changed, 77 insertions(+), 76 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4e40b7ab5..f8180c850 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1520,6 +1520,11 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)
rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.perm_addr,
&dev->data->mac_addrs[0]);
+ /* Pass the information to the rte_eth_dev_close() that it should also
+ * release the private port resources.
+ */
+ dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
/* Init dcb to sw mode by default */
ret = i40e_dcb_init_configure(dev, TRUE);
if (ret != I40E_SUCCESS) {
@@ -1689,85 +1694,18 @@ void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)
static int
eth_i40e_dev_uninit(struct rte_eth_dev *dev)
{
- struct i40e_pf *pf;
- struct rte_pci_device *pci_dev;
- struct rte_intr_handle *intr_handle;
struct i40e_hw *hw;
- struct i40e_filter_control_settings settings;
- struct rte_flow *p_flow;
- int ret;
- uint8_t aq_fail = 0;
- int retries = 0;
PMD_INIT_FUNC_TRACE();
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- pci_dev = RTE_ETH_DEV_TO_PCI(dev);
- intr_handle = &pci_dev->intr_handle;
-
- ret = rte_eth_switch_domain_free(pf->switch_domain_id);
- if (ret)
- PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
if (hw->adapter_closed == 0)
i40e_dev_close(dev);
- dev->dev_ops = NULL;
- dev->rx_pkt_burst = NULL;
- dev->tx_pkt_burst = NULL;
-
- /* Clear PXE mode */
- i40e_clear_pxe_mode(hw);
-
- /* Unconfigure filter control */
- memset(&settings, 0, sizeof(settings));
- ret = i40e_set_filter_control(hw, &settings);
- if (ret)
- PMD_INIT_LOG(WARNING, "setup_pf_filter_control failed: %d",
- ret);
-
- /* Disable flow control */
- hw->fc.requested_mode = I40E_FC_NONE;
- i40e_set_fc(hw, &aq_fail, TRUE);
-
- /* uninitialize pf host driver */
- i40e_pf_host_uninit(dev);
-
- /* disable uio intr before callback unregister */
- rte_intr_disable(intr_handle);
-
- /* unregister callback func to eal lib */
- do {
- ret = rte_intr_callback_unregister(intr_handle,
- i40e_dev_interrupt_handler, dev);
- if (ret >= 0) {
- break;
- } else if (ret != -EAGAIN) {
- PMD_INIT_LOG(ERR,
- "intr callback unregister failed: %d",
- ret);
- return ret;
- }
- i40e_msec_delay(500);
- } while (retries++ < 5);
-
- i40e_rm_ethtype_filter_list(pf);
- i40e_rm_tunnel_filter_list(pf);
- i40e_rm_fdir_filter_list(pf);
-
- /* Remove all flows */
- while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
- TAILQ_REMOVE(&pf->flow_list, p_flow, node);
- rte_free(p_flow);
- }
-
- /* Remove all Traffic Manager configuration */
- i40e_tm_conf_uninit(dev);
-
return 0;
}
@@ -2465,12 +2403,21 @@ i40e_dev_close(struct rte_eth_dev *dev)
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct i40e_mirror_rule *p_mirror;
+ struct i40e_filter_control_settings settings;
+ struct rte_flow *p_flow;
uint32_t reg;
int i;
int ret;
+ uint8_t aq_fail = 0;
+ int retries = 0;
PMD_INIT_FUNC_TRACE();
+ ret = rte_eth_switch_domain_free(pf->switch_domain_id);
+ if (ret)
+ PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
+
+
i40e_dev_stop(dev);
/* Remove all mirror rules */
@@ -2535,6 +2482,53 @@ i40e_dev_close(struct rte_eth_dev *dev)
(reg | I40E_PFGEN_CTRL_PFSWR_MASK));
I40E_WRITE_FLUSH(hw);
+ dev->dev_ops = NULL;
+ dev->rx_pkt_burst = NULL;
+ dev->tx_pkt_burst = NULL;
+
+ /* Clear PXE mode */
+ i40e_clear_pxe_mode(hw);
+
+ /* Unconfigure filter control */
+ memset(&settings, 0, sizeof(settings));
+ ret = i40e_set_filter_control(hw, &settings);
+ if (ret)
+ PMD_INIT_LOG(WARNING, "setup_pf_filter_control failed: %d",
+ ret);
+
+ /* Disable flow control */
+ hw->fc.requested_mode = I40E_FC_NONE;
+ i40e_set_fc(hw, &aq_fail, TRUE);
+
+ /* uninitialize pf host driver */
+ i40e_pf_host_uninit(dev);
+
+ do {
+ ret = rte_intr_callback_unregister(intr_handle,
+ i40e_dev_interrupt_handler, dev);
+ if (ret >= 0) {
+ break;
+ } else if (ret != -EAGAIN) {
+ PMD_INIT_LOG(ERR,
+ "intr callback unregister failed: %d",
+ ret);
+ }
+ i40e_msec_delay(500);
+ } while (retries++ < 5);
+
+ i40e_rm_ethtype_filter_list(pf);
+ i40e_rm_tunnel_filter_list(pf);
+ i40e_rm_fdir_filter_list(pf);
+
+ /* Remove all flows */
+ while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
+ TAILQ_REMOVE(&pf->flow_list, p_flow, node);
+ rte_free(p_flow);
+ }
+
+ /* Remove all Traffic Manager configuration */
+ i40e_tm_conf_uninit(dev);
+
hw->adapter_closed = 1;
}
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 308fb9835..0916e01a6 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1310,17 +1310,12 @@ i40evf_init_vf(struct rte_eth_dev *dev)
static int
i40evf_uninit_vf(struct rte_eth_dev *dev)
{
- struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
PMD_INIT_FUNC_TRACE();
if (hw->adapter_closed == 0)
i40evf_dev_close(dev);
- rte_free(vf->vf_res);
- vf->vf_res = NULL;
- rte_free(vf->aq_resp);
- vf->aq_resp = NULL;
return 0;
}
@@ -1498,6 +1493,11 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
hw->adapter_stopped = 0;
hw->adapter_closed = 0;
+ /* Pass the information to the rte_eth_dev_close() that it should also
+ * release the private port resources.
+ */
+ eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
if(i40evf_init_vf(eth_dev) != 0) {
PMD_INIT_LOG(ERR, "Init vf failed");
return -1;
@@ -1534,10 +1534,6 @@ i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return -EPERM;
- eth_dev->dev_ops = NULL;
- eth_dev->rx_pkt_burst = NULL;
- eth_dev->tx_pkt_burst = NULL;
-
if (i40evf_uninit_vf(eth_dev) != 0) {
PMD_INIT_LOG(ERR, "i40evf_uninit_vf failed");
return -1;
@@ -2324,6 +2320,7 @@ static void
i40evf_dev_close(struct rte_eth_dev *dev)
{
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
i40evf_dev_stop(dev);
i40e_dev_free_queues(dev);
@@ -2339,6 +2336,16 @@ i40evf_dev_close(struct rte_eth_dev *dev)
i40evf_reset_vf(dev);
i40e_shutdown_adminq(hw);
i40evf_disable_irq0(hw);
+
+ dev->dev_ops = NULL;
+ dev->rx_pkt_burst = NULL;
+ dev->tx_pkt_burst = NULL;
+
+ rte_free(vf->vf_res);
+ vf->vf_res = NULL;
+ rte_free(vf->aq_resp);
+ vf->aq_resp = NULL;
+
hw->adapter_closed = 1;
}
--
2.17.1
next prev parent reply other threads:[~2019-09-05 11:48 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 5:01 [dpdk-dev] [PATCH] drivers/net: " chenxux.di
2019-08-27 6:23 ` Ye Xiaolong
2019-09-05 11:03 ` [dpdk-dev] [PATCH v3 0/5] " Di ChenxuX
2019-09-05 11:03 ` [dpdk-dev] [PATCH v3 1/5] net/e1000: " Di ChenxuX
2019-09-05 11:03 ` [dpdk-dev] [PATCH v3 2/5] net/fm10k: " Di ChenxuX
2019-09-05 11:03 ` Di ChenxuX [this message]
2019-09-05 11:03 ` [dpdk-dev] [PATCH v3 4/5] net/ice: " Di ChenxuX
2019-09-05 11:03 ` [dpdk-dev] [PATCH v3 5/5] net/ixgbe: " Di ChenxuX
2019-09-19 2:47 ` [dpdk-dev] [PATCH v4 0/5] drivers/net: " Di ChenxuX
2019-09-19 2:47 ` [dpdk-dev] [PATCH v4 1/5] net/e1000: " Di ChenxuX
2019-09-25 15:41 ` Ye Xiaolong
2019-09-26 3:21 ` Di, ChenxuX
2019-09-19 2:47 ` [dpdk-dev] [PATCH v4 2/5] net/fm10k: " Di ChenxuX
2019-09-19 2:47 ` [dpdk-dev] [PATCH v4 3/5] net/i40e: " Di ChenxuX
2019-09-19 2:47 ` [dpdk-dev] [PATCH v4 4/5] net/ice: " Di ChenxuX
2019-09-19 2:47 ` [dpdk-dev] [PATCH v4 5/5] net/ixgbe: " Di ChenxuX
2019-09-23 2:27 ` [dpdk-dev] [PATCH v4 0/5] drivers/net: " Yang, Qiming
2019-09-26 7:30 ` [dpdk-dev] [PATCH v5 " Di ChenxuX
2019-09-26 7:30 ` [dpdk-dev] [PATCH v5 1/5] net/e1000: " Di ChenxuX
2019-09-26 7:30 ` [dpdk-dev] [PATCH v5 2/5] net/fm10k: " Di ChenxuX
2019-09-26 7:30 ` [dpdk-dev] [PATCH v5 3/5] net/i40e: " Di ChenxuX
2019-09-26 7:30 ` [dpdk-dev] [PATCH v5 4/5] net/ice: " Di ChenxuX
2019-09-26 7:30 ` [dpdk-dev] [PATCH v5 5/5] net/ixgbe: " Di ChenxuX
2019-09-26 10:42 ` [dpdk-dev] [PATCH v5 0/5] drivers/net: " Ye Xiaolong
2019-09-26 10:00 ` [dpdk-dev] [PATCH v6 " Di ChenxuX
2019-09-26 10:00 ` [dpdk-dev] [PATCH v6 1/5] net/e1000: " Di ChenxuX
2019-09-26 10:00 ` [dpdk-dev] [PATCH v6 2/5] net/fm10k: " Di ChenxuX
2019-09-26 10:00 ` [dpdk-dev] [PATCH v6 3/5] net/i40e: " Di ChenxuX
2019-09-26 10:00 ` [dpdk-dev] [PATCH v6 4/5] net/ice: " Di ChenxuX
2019-09-26 10:00 ` [dpdk-dev] [PATCH v6 5/5] net/ixgbe: " Di ChenxuX
2019-09-27 2:46 ` [dpdk-dev] [PATCH v6 0/5] drivers/net: " Yang, Qiming
2019-09-27 9:09 ` [dpdk-dev] [PATCH v7 " Di ChenxuX
2019-09-27 9:09 ` [dpdk-dev] [PATCH v7 1/5] net/e1000: " Di ChenxuX
2019-09-27 9:09 ` [dpdk-dev] [PATCH v7 2/5] net/fm10k: " Di ChenxuX
2019-09-27 9:09 ` [dpdk-dev] [PATCH v7 3/5] net/i40e: " Di ChenxuX
2019-09-27 9:09 ` [dpdk-dev] [PATCH v7 4/5] net/ice: " Di ChenxuX
2019-09-27 9:09 ` [dpdk-dev] [PATCH v7 5/5] net/ixgbe: " Di ChenxuX
2019-09-27 10:50 ` [dpdk-dev] [PATCH v7 0/5] drivers/net: " Ye Xiaolong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190905110359.62406-4-chenxux.di@intel.com \
--to=chenxux.di@intel.com \
--cc=dev@dpdk.org \
--cc=qiming.yang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).