[dpdk-dev] [PATCH v2] app/testpmd: fix pmd_test_exit function for vdevs

Yao, Lei A lei.a.yao at intel.com
Fri May 18 06:52:07 CEST 2018



> -----Original Message-----
> From: Yang, Zhiyong
> Sent: Friday, May 18, 2018 6:00 PM
> To: dev at dpdk.org
> Cc: maxime.coquelin at redhat.com; Yigit, Ferruh <ferruh.yigit at intel.com>;
> Bie, Tiwei <tiwei.bie at intel.com>; Yao, Lei A <lei.a.yao at intel.com>;
> Iremonger, Bernard <bernard.iremonger at intel.com>; stable at dpdk.org;
> Yang, Zhiyong <zhiyong.yang at intel.com>
> Subject: [PATCH v2] app/testpmd: fix pmd_test_exit function for vdevs
> 
> For vdev, just calling rte_eth_dev_close() isn't enough to free all
> the resources allocated during device probe, e.g. for virtio-user,
> virtio_user_pmd_remove(), i.e. the remove() method of a vdev driver,
> needs to be called to unlink the socket file created during device
> probe. So this patch calls the rte_eth_dev_detach() for vdev when
> quitting testpmd.
> 
> Cc: maxime.coquelin at redhat.com
> Cc: ferruh.yigit at intel.com
> Cc: tiwei.bie at intel.com
> Cc: lei.a.yao at intel.com
> Cc: bernard.iremonger at intel.com
> Cc: stable at dpdk.org
> 
> Fixes: af75078fece3 ("first public release")
> Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> 
> Signed-off-by: Zhiyong Yang <zhiyong.yang at intel.com>
Tested-by: Lei Yao<lei.a.yao at intel.com>
This patch pass the test for virtio-user server mode. The socket file can 
be deleted after quit testpmd.
> ---
> 
> changes in V2:
> 1. change the pache title and add a fixes line.
> 
>  app/test-pmd/testpmd.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 134401603..1d308f056 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2011,6 +2011,8 @@ detach_port(portid_t port_id)
>  void
>  pmd_test_exit(void)
>  {
> +	const struct rte_bus *bus;
> +	struct rte_device *device;
>  	portid_t pt_id;
>  	int ret;
> 
> @@ -2020,10 +2022,14 @@ pmd_test_exit(void)
>  	if (ports != NULL) {
>  		no_link_check = 1;
>  		RTE_ETH_FOREACH_DEV(pt_id) {
> +			device = rte_eth_devices[pt_id].device;
> +			bus = rte_bus_find_by_device(device);
>  			printf("\nShutting down port %d...\n", pt_id);
>  			fflush(stdout);
>  			stop_port(pt_id);
>  			close_port(pt_id);
> +			if (bus && !strcmp(bus->name, "vdev"))
> +				detach_port(pt_id);
>  		}
>  	}
> 
> --
> 2.14.3



More information about the dev mailing list