[spp] [PATCH 3/3] make robust against process start and termination
Itsuro Oda
oda at valinux.co.jp
Mon Dec 23 06:00:36 CET 2019
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 at 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
More information about the spp
mailing list