Soft Patch Panel
 help / color / mirror / Atom feed
From: x-fn-spp@sl.ntt-tx.co.jp
To: ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Cc: spp@dpdk.org
Subject: [spp] [PATCH 1/4] shared: fix trying to create ring already exist
Date: Fri,  8 Feb 2019 17:47:50 +0900	[thread overview]
Message-ID: <201902080847.x188lrID021610@imss03.silk.ntt-tx.co.jp> (raw)
In-Reply-To: <20190208084753.8049-1-x-fn-spp@sl.ntt-tx.co.jp>

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

       reply	other threads:[~2019-02-08  8:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190208084753.8049-1-x-fn-spp@sl.ntt-tx.co.jp>
2019-02-08  8:47 ` x-fn-spp [this message]
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

Reply instructions:

You may reply publicly 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=201902080847.x188lrID021610@imss03.silk.ntt-tx.co.jp \
    --to=x-fn-spp@sl.ntt-tx.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=spp@dpdk.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).