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 3/4] spp_vf: fix trying to create ring already exist
Date: Fri,  8 Feb 2019 17:47:52 +0900	[thread overview]
Message-ID: <201902080847.x188lrfi021618@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>

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

  parent 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 ` [spp] [PATCH 1/4] shared: " 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 [this message]
2019-02-08  8:47 ` [spp] [PATCH 4/4] spp_pcap: fix trying to create ring already exist 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.x188lrfi021618@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).