From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 28FBDA0352 for ; Mon, 23 Dec 2019 06:00:41 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3931F1BE80; Mon, 23 Dec 2019 06:00:40 +0100 (CET) Received: from valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by dpdk.org (Postfix) with ESMTP id 408812BE3 for ; Mon, 23 Dec 2019 06:00:38 +0100 (CET) Received: by valinux.co.jp (Postfix, from userid 1000) id 69627240CD9; Mon, 23 Dec 2019 14:00:37 +0900 (JST) From: Itsuro Oda To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 23 Dec 2019 14:00:36 +0900 Message-Id: <20191223050036.30765-4-oda@valinux.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191223050036.30765-1-oda@valinux.co.jp> References: <20191223050036.30765-1-oda@valinux.co.jp> Subject: [spp] [PATCH 3/3] make robust against process start and termination X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" 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 --- 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