Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH 1/4] shared: fix trying to create ring already exist
       [not found] <20190208084753.8049-1-x-fn-spp@sl.ntt-tx.co.jp>
@ 2019-02-08  8:47 ` x-fn-spp
  2019-02-08  8:47 ` [spp] [PATCH 2/4] spp_nfv: fix incorrect deleting for ring port x-fn-spp
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: x-fn-spp @ 2019-02-08  8:47 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

In add_ring_pmd(), it tries to create a ring port without checking if
already exists. To fix the issue, check requested port is created
before. If so, it calls rte_eth_dev_start() instead.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/shared/secondary/add_port.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/shared/secondary/add_port.c b/src/shared/secondary/add_port.c
index 2841f94..6924583 100644
--- a/src/shared/secondary/add_port.c
+++ b/src/shared/secondary/add_port.c
@@ -103,6 +103,8 @@ add_ring_pmd(int ring_id)
 	struct rte_ring *ring;
 	int res;
 	char rx_queue_name[32];  /* Prefix and number like as 'eth_ring_0' */
+	uint16_t port_id = PORT_RESET;
+	char dev_name[RTE_ETH_NAME_MAX_LEN];
 
 	memset(rx_queue_name, '\0', sizeof(rx_queue_name));
 	sprintf(rx_queue_name, "%s", get_rx_queue_name(ring_id));
@@ -118,12 +120,21 @@ add_ring_pmd(int ring_id)
 	RTE_LOG(INFO, SHARED, "Looked up ring '%s'\n", rx_queue_name);
 
 	/* create ring pmd*/
-	res = rte_eth_from_ring(ring);
-	if (res < 0) {
-		RTE_LOG(ERR, SHARED,
-			"Cannot create eth dev with rte_eth_from_ring()\n");
-		return -1;
+	snprintf(dev_name, RTE_ETH_NAME_MAX_LEN - 1, "net_ring_%s", ring->name);
+	/* check whether a port already exists. */
+	res = rte_eth_dev_get_port_by_name(dev_name, &port_id);
+	if (port_id == PORT_RESET) {
+		res = rte_eth_from_ring(ring);
+		if (res < 0) {
+			RTE_LOG(ERR, SHARED, "Cannot create eth dev with "
+						"rte_eth_from_ring()\n");
+			return -1;
+		}
+	} else {
+		res = port_id;
+		rte_eth_dev_start(res);
 	}
+
 	RTE_LOG(INFO, SHARED, "Created ring PMD: %d\n", res);
 
 	return res;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 2/4] spp_nfv: fix incorrect deleting for ring port
       [not found] <20190208084753.8049-1-x-fn-spp@sl.ntt-tx.co.jp>
  2019-02-08  8:47 ` [spp] [PATCH 1/4] shared: fix trying to create ring already exist x-fn-spp
@ 2019-02-08  8:47 ` x-fn-spp
  2019-02-08  8:47 ` [spp] [PATCH 3/4] spp_vf: fix trying to create ring already exist x-fn-spp
  2019-02-08  8:47 ` [spp] [PATCH 4/4] spp_pcap: " x-fn-spp
  3 siblings, 0 replies; 4+ messages in thread
From: x-fn-spp @ 2019-02-08  8:47 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Spp_nfv uses `rte_eal_hotplug_remove()` in `dev_detach_by_port_id()` to
delete a ring. However, it is wrong because it causes an error when
adding the same ring again. This update is to use `rte_eth_dev_stop()`
and `rte_eth_dev_close()` as correct manner.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/nfv/commands.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/nfv/commands.h b/src/nfv/commands.h
index 36ad86d..c8f726f 100644
--- a/src/nfv/commands.h
+++ b/src/nfv/commands.h
@@ -38,7 +38,8 @@ do_del(char *res_uid)
 		if (port_id == PORT_RESET)
 			return -1;
 
-		dev_detach_by_port_id(port_id);
+		rte_eth_dev_stop(port_id);
+		rte_eth_dev_close(port_id);
 
 	} else if (!strcmp(p_type, "pcap")) {
 		port_id = find_port_id(p_id, PCAP);
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 3/4] spp_vf: fix trying to create ring already exist
       [not found] <20190208084753.8049-1-x-fn-spp@sl.ntt-tx.co.jp>
  2019-02-08  8:47 ` [spp] [PATCH 1/4] shared: fix trying to create ring already exist x-fn-spp
  2019-02-08  8:47 ` [spp] [PATCH 2/4] spp_nfv: fix incorrect deleting for ring port x-fn-spp
@ 2019-02-08  8:47 ` x-fn-spp
  2019-02-08  8:47 ` [spp] [PATCH 4/4] spp_pcap: " x-fn-spp
  3 siblings, 0 replies; 4+ messages in thread
From: x-fn-spp @ 2019-02-08  8:47 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Same with "shared: fix trying to create ring already exist".

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/vf/common/spp_proc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index 803e498..b7c3ec5 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -80,6 +80,8 @@ spp_vf_add_ring_pmd(int ring_id)
 {
 	struct rte_ring *ring;
 	int ring_port_id;
+	uint16_t port_id = PORT_RESET;
+	char dev_name[RTE_ETH_NAME_MAX_LEN];
 
 	/* Lookup ring of given id */
 	ring = rte_ring_lookup(get_rx_queue_name(ring_id));
@@ -90,7 +92,20 @@ spp_vf_add_ring_pmd(int ring_id)
 	}
 
 	/* Create ring pmd */
-	ring_port_id = rte_eth_from_ring(ring);
+	snprintf(dev_name, RTE_ETH_NAME_MAX_LEN - 1, "net_ring_%s", ring->name);
+	/* check whether a port already exists. */
+	ring_port_id = rte_eth_dev_get_port_by_name(dev_name, &port_id);
+	if (port_id == PORT_RESET) {
+		ring_port_id = rte_eth_from_ring(ring);
+		if (ring_port_id < 0) {
+			RTE_LOG(ERR, APP, "Cannot create eth dev with "
+						"rte_eth_from_ring()\n");
+			return SPP_RET_NG;
+		}
+	} else {
+		ring_port_id = port_id;
+		rte_eth_dev_start(ring_port_id);
+	}
 	RTE_LOG(INFO, APP, "ring port add. (no = %d / port = %d)\n",
 			ring_id, ring_port_id);
 	return ring_port_id;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 4/4] spp_pcap: fix trying to create ring already exist
       [not found] <20190208084753.8049-1-x-fn-spp@sl.ntt-tx.co.jp>
                   ` (2 preceding siblings ...)
  2019-02-08  8:47 ` [spp] [PATCH 3/4] spp_vf: fix trying to create ring already exist x-fn-spp
@ 2019-02-08  8:47 ` x-fn-spp
  3 siblings, 0 replies; 4+ messages in thread
From: x-fn-spp @ 2019-02-08  8:47 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

Same with "shared: fix trying to create ring already exist".

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 src/pcap/spp_proc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/pcap/spp_proc.c b/src/pcap/spp_proc.c
index ab08337..4e3b2c9 100644
--- a/src/pcap/spp_proc.c
+++ b/src/pcap/spp_proc.c
@@ -32,6 +32,8 @@ add_ring_pmd(int ring_id)
 {
 	struct rte_ring *ring;
 	int ring_port_id;
+	uint16_t port_id = PORT_RESET;
+	char dev_name[RTE_ETH_NAME_MAX_LEN];
 
 	/* Lookup ring of given id */
 	ring = rte_ring_lookup(get_rx_queue_name(ring_id));
@@ -42,7 +44,20 @@ add_ring_pmd(int ring_id)
 	}
 
 	/* Create ring pmd */
-	ring_port_id = rte_eth_from_ring(ring);
+	snprintf(dev_name, RTE_ETH_NAME_MAX_LEN - 1, "net_ring_%s", ring->name);
+	/* check whether a port already exists. */
+	ring_port_id = rte_eth_dev_get_port_by_name(dev_name, &port_id);
+	if (port_id == PORT_RESET) {
+		ring_port_id = rte_eth_from_ring(ring);
+		if (ring_port_id < 0) {
+			RTE_LOG(ERR, SPP_PROC, "Cannot create eth dev with "
+						"rte_eth_from_ring()\n");
+			return SPP_RET_NG;
+		}
+	} else {
+		ring_port_id = port_id;
+		rte_eth_dev_start(ring_port_id);
+	}
 	RTE_LOG(INFO, SPP_PROC, "ring port add. (no = %d / port = %d)\n",
 			ring_id, ring_port_id);
 	return ring_port_id;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-08  8:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190208084753.8049-1-x-fn-spp@sl.ntt-tx.co.jp>
2019-02-08  8:47 ` [spp] [PATCH 1/4] shared: fix trying to create ring already exist x-fn-spp
2019-02-08  8:47 ` [spp] [PATCH 2/4] spp_nfv: fix incorrect deleting for ring port x-fn-spp
2019-02-08  8:47 ` [spp] [PATCH 3/4] spp_vf: fix trying to create ring already exist x-fn-spp
2019-02-08  8:47 ` [spp] [PATCH 4/4] spp_pcap: " x-fn-spp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).