Thread (33 messages) 33 messages, 4 authors, 2021-10-21

Re: [dpdk-dev] [RFC V2] ethdev: fix issue that dev close in PMD calls twice

From: Thomas Monjalon <hidden>
Date: 2021-08-13 06:13:18

13/08/2021 04:11, Huisong Li:
Hi, all

This patch can enhance the security of device uninstallation to 
eliminate dependency on user usage methods.

Can you check this patch?


在 2021/8/3 10:30, Huisong Li 写道:
quoted
Ethernet devices in DPDK can be released by rte_eth_dev_close() and
rte_dev_remove(). These APIs both call xxx_dev_close() in PMD layer
to uninstall hardware. However, the two APIs do not have explicit
invocation restrictions. In other words, at the ethdev layer, it is
possible to call rte_eth_dev_close() before calling rte_dev_remove()
or rte_eal_hotplug_remove(). In such a bad scenario,
It is not a bad scenario.
If there is no more port for the device after calling close,
the device should be removed automatically.
Keep in mind "close" is for one port, "remove" is for the entire device
which can have more than one port.
quoted
the primary
process may be fine, but it may cause that xxx_dev_close() in the PMD
layer will be called twice in the secondary process. So this patch
fixes it.
If a port is closed in primary, it should be the same in secondary.

quoted
+	/*
+	 * The eth_dev->data->name doesn't be cleared by the secondary process,
+	 * so above "eth_dev" isn't NULL after rte_eth_dev_close() called.
This assumption is not clear. All should be closed together.
quoted
+	 * Namely, whether "eth_dev" is NULL cannot be used to determine whether
+	 * an ethdev port has been released.
+	 * For both primary process and secondary process, eth_dev->state is
+	 * RTE_ETH_DEV_UNUSED, which means the ethdev port has been released.
+	 */
+	if (eth_dev->state == RTE_ETH_DEV_UNUSED) {
+		RTE_ETHDEV_LOG(INFO, "The ethdev port has been released.");
+		return 0;
+	}

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help