DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] net/txgbe: fix driver exit
@ 2020-10-28  2:29 Jiawen Wu
  2020-10-29 19:33 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Jiawen Wu @ 2020-10-28  2:29 UTC (permalink / raw)
  To: dev; +Cc: Jiawen Wu

Replace the 'rte_panic()' with an error return.
Also change the type of the calling function.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/txgbe_ethdev.c | 11 +++++++++--
 drivers/net/txgbe/txgbe_ethdev.h |  2 +-
 drivers/net/txgbe/txgbe_pf.c     | 23 ++++++++++++++++++-----
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index aeefb1ed1..189caf2e9 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -475,7 +475,7 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 	const struct rte_memzone *mz;
 	uint32_t ctrl_ext;
 	uint16_t csum;
-	int err, i;
+	int err, i, ret;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -639,7 +639,14 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 	memset(hwstrip, 0, sizeof(*hwstrip));
 
 	/* initialize PF if max_vfs not zero */
-	txgbe_pf_host_init(eth_dev);
+	ret = txgbe_pf_host_init(eth_dev);
+	if (ret) {
+		rte_free(eth_dev->data->mac_addrs);
+		eth_dev->data->mac_addrs = NULL;
+		rte_free(eth_dev->data->hash_mac_addrs);
+		eth_dev->data->hash_mac_addrs = NULL;
+		return ret;
+	}
 
 	ctrl_ext = rd32(hw, TXGBE_PORTCTL);
 	/* let hardware know driver is loaded */
diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h
index 331be9244..2c3680218 100644
--- a/drivers/net/txgbe/txgbe_ethdev.h
+++ b/drivers/net/txgbe/txgbe_ethdev.h
@@ -288,7 +288,7 @@ void txgbe_configure_dcb(struct rte_eth_dev *dev);
 int
 txgbe_dev_link_update_share(struct rte_eth_dev *dev,
 		int wait_to_complete);
-void txgbe_pf_host_init(struct rte_eth_dev *eth_dev);
+int txgbe_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void txgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/txgbe/txgbe_pf.c b/drivers/net/txgbe/txgbe_pf.c
index 67045fb01..151f2c7a4 100644
--- a/drivers/net/txgbe/txgbe_pf.c
+++ b/drivers/net/txgbe/txgbe_pf.c
@@ -64,7 +64,7 @@ txgbe_mb_intr_setup(struct rte_eth_dev *dev)
 	return 0;
 }
 
-void txgbe_pf_host_init(struct rte_eth_dev *eth_dev)
+int txgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct txgbe_vf_info **vfinfo = TXGBE_DEV_VFDATA(eth_dev);
 	struct txgbe_mirror_info *mirror_info = TXGBE_DEV_MR_INFO(eth_dev);
@@ -72,20 +72,31 @@ void txgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 	struct txgbe_hw *hw = TXGBE_DEV_HW(eth_dev);
 	uint16_t vf_num;
 	uint8_t nb_queue;
+	int ret = 0;
 
 	PMD_INIT_FUNC_TRACE();
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return;
+		return ret;
 
 	*vfinfo = rte_zmalloc("vf_info",
 			sizeof(struct txgbe_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_INIT_LOG(ERR,
+			"Cannot allocate memory for private VF data\n");
+		return -ENOMEM;
+	}
 
-	rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
+	ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
+	if (ret) {
+		PMD_INIT_LOG(ERR,
+			"failed to allocate switch domain for device %d", ret);
+		rte_free(*vfinfo);
+		*vfinfo = NULL;
+		return ret;
+	}
 
 	memset(mirror_info, 0, sizeof(struct txgbe_mirror_info));
 	memset(uta_info, 0, sizeof(struct txgbe_uta_info));
@@ -114,6 +125,8 @@ void txgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	/* set mb interrupt mask */
 	txgbe_mb_intr_setup(eth_dev);
+
+	return ret;
 }
 
 void txgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
-- 
2.21.0.windows.1




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/txgbe: fix driver exit
  2020-10-28  2:29 [dpdk-dev] [PATCH v2] net/txgbe: fix driver exit Jiawen Wu
@ 2020-10-29 19:33 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2020-10-29 19:33 UTC (permalink / raw)
  To: Jiawen Wu, dev

On 10/28/2020 2:29 AM, Jiawen Wu wrote:
> Replace the 'rte_panic()' with an error return.
> Also change the type of the calling function.
> 
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>

Applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-29 19:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28  2:29 [dpdk-dev] [PATCH v2] net/txgbe: fix driver exit Jiawen Wu
2020-10-29 19:33 ` Ferruh Yigit

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git