Soft Patch Panel
 help / color / Atom feed
From: Itsuro Oda <oda@valinux.co.jp>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 3/3] make robust against process start and termination
Date: Mon, 23 Dec 2019 14:00:36 +0900
Message-ID: <20191223050036.30765-4-oda@valinux.co.jp> (raw)
In-Reply-To: <20191223050036.30765-1-oda@valinux.co.jp>

A vhost device is shared among the primary process and secondary
processes. When a secodary process starts it recognizes vhost
devices if they are used by processes already started. It is not
appropriate to include to port information as PHY devices.
There are some fixes to ensure eth_dev_stop too.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/nfv/commands.h                             | 1 +
 src/nfv/main.c                                 | 7 ++++++-
 src/primary/main.c                             | 1 +
 src/shared/secondary/add_port.c                | 8 ++++++++
 src/shared/secondary/spp_worker_th/cmd_utils.c | 8 ++++++--
 5 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/nfv/commands.h b/src/nfv/commands.h
index f6c2305..7e50c8c 100644
--- a/src/nfv/commands.h
+++ b/src/nfv/commands.h
@@ -25,6 +25,7 @@ do_del(char *p_type, int p_id)
 		port_id = find_port_id(p_id, VHOST);
 		if (port_id == PORT_RESET)
 			return -1;
+		rte_eth_dev_stop(port_id);
 		dev_detach_by_port_id(port_id);
 
 	} else if (!strcmp(p_type, "ring")) {
diff --git a/src/nfv/main.c b/src/nfv/main.c
index 513a98d..f2c6bfc 100644
--- a/src/nfv/main.c
+++ b/src/nfv/main.c
@@ -211,7 +211,12 @@ main(int argc, char *argv[])
 		if (port_type == PHY) {
 			port_id = nof_phy_port;
 			nof_phy_port++;
-		}
+		} else if (port_type == VHOST)
+			continue;
+		/* NOTE: vhost may be used another process. even if no
+		 * process uses, it is necessary to "add vhost" explicitly.
+		 * not display to avoid confusion.
+		 */
 
 		/* Update ports_fwd_array with phy port. */
 		ports_fwd_array[i].in_port_id = i;
diff --git a/src/primary/main.c b/src/primary/main.c
index 26e9c42..a1ca791 100644
--- a/src/primary/main.c
+++ b/src/primary/main.c
@@ -874,6 +874,7 @@ del_port(char *p_type, int p_id)
 		dev_id = find_ethdev_id(p_id, VHOST);
 		if (dev_id == PORT_RESET)
 			return -1;
+		rte_eth_dev_stop(dev_id);
 		dev_detach_by_port_id(dev_id);
 
 	} else if (!strcmp(p_type, "ring")) {
diff --git a/src/shared/secondary/add_port.c b/src/shared/secondary/add_port.c
index b072140..d845250 100644
--- a/src/shared/secondary/add_port.c
+++ b/src/shared/secondary/add_port.c
@@ -170,6 +170,14 @@ add_vhost_pmd(int index)
 		return ret;
 	}
 
+	/* NOTE: make sure the eth_dev is stopped.
+	 * it is for the case a secondary process which used the vhost
+	 * was down without stopping the device.
+	 * note that it is still user responsibility to prevent multipul
+	 * processes use a vhost at the same time.
+	 */
+	rte_eth_dev_stop(vhost_port_id);
+
 	ret = rte_eth_dev_configure(vhost_port_id, nr_queues, nr_queues,
 		&port_conf);
 	if (ret < 0) {
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 010a4b6..69d7222 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -437,8 +437,12 @@ init_host_port_info(void)
 			p_iface_info->phy[port_id].ethdev_port_id = port_id;
 			break;
 		case VHOST:
-			p_iface_info->vhost[port_id].iface_type = port_type;
-			p_iface_info->vhost[port_id].ethdev_port_id = port_id;
+			/* NOTE: a vhost can be used by one process.
+			 * even if it exists, it is necessary to do
+			 * add_vhost_pmd to setup the device.
+			 * note that it is user responsibility to prevent
+			 * multipul processes use a vhost at the same time.
+			 */
 			break;
 		case RING:
 			p_iface_info->ring[port_id].iface_type = port_type;
-- 
2.17.1


  parent reply index

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-23  5:00 [spp] [PATCH 0/3] revive vhost Itsuro Oda
2019-12-23  5:00 ` [spp] [PATCH 1/3] multi process supported vhost PMD for SPP Itsuro Oda
2019-12-23  5:00 ` [spp] [PATCH 2/3] make use of " Itsuro Oda
2019-12-23  5:00 ` Itsuro Oda [this message]
2019-12-24  5:57 ` [spp] [PATCH 0/3] revive vhost Yasufumi Ogawa
2019-12-24  6:09   ` Itsuro ODA
2019-12-24  6:30     ` Yasufumi Ogawa
2019-12-25  4:49 ` [spp] [PATCH v2 00/12] " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 01/12] drivers/vhost: add multi process supported vhost PMD for SPP Itsuro Oda
2020-01-07 10:41     ` Yasufumi Ogawa
2020-01-08  1:17       ` Itsuro ODA
2020-01-08  1:23         ` Itsuro ODA
2019-12-25  4:49   ` [spp] [PATCH v2 02/12] drivers: add to build " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 03/12] shared: switch to use " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 04/12] spp_primary: add link to " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 05/12] spp_nfv: " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 06/12] spp_vf: " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 07/12] spp_mirror: " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 08/12] spp_primary: stop vhost before detach Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 09/12] spp_nfv: " Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 10/12] shared: make sure vhost is stopped before (re)using the vhost Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 11/12] spp_nfv: exclude vhosts at process initialization Itsuro Oda
2019-12-25  4:49   ` [spp] [PATCH v2 12/12] spp_vf, spp_mirror: " Itsuro Oda
2020-01-09 23:10 ` [spp] [PATCH v3 00/12] revive vhost Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 01/12] drivers/vhost: add multi process supported vhost PMD for SPP Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 02/12] drivers: add to build " Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 03/12] shared: switch to use " Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 04/12] spp_primary: add link to " Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 05/12] spp_nfv: " Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 06/12] spp_vf: " Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 07/12] spp_mirror: " Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 08/12] spp_primary: stop vhost before detach Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 09/12] spp_nfv: " Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 10/12] shared: make sure vhost is stopped before (re)using the vhost Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 11/12] spp_nfv: exclude vhosts at process initialization Itsuro Oda
2020-01-09 23:10   ` [spp] [PATCH v3 12/12] spp_vf, spp_mirror: " Itsuro Oda
2020-01-17  2:27   ` [spp] [PATCH v3 00/12] revive vhost Yasufumi Ogawa

Reply instructions:

You may reply publically 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=20191223050036.30765-4-oda@valinux.co.jp \
    --to=oda@valinux.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    --cc=yasufum.o@gmail.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

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/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 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


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