From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bcmv-tmail01.ecl.ntt.co.jp (bcmv-tmail01.ecl.ntt.co.jp [124.146.185.148]) by dpdk.org (Postfix) with ESMTP id 4EB691B466 for ; Tue, 9 Oct 2018 12:52:21 +0200 (CEST) Received: from bcmv-ns01.ecl.ntt.co.jp (bcmv-ns01.ecl.ntt.co.jp [129.60.83.123]) by bcmv-tmail01.ecl.ntt.co.jp (8.14.4/8.14.4) with ESMTP id w99AqKii017829; Tue, 9 Oct 2018 19:52:20 +0900 Received: from bcmv-ns01.ecl.ntt.co.jp (localhost [127.0.0.1]) by bcmv-ns01.ecl.ntt.co.jp (Postfix) with ESMTP id 283D2125; Tue, 9 Oct 2018 19:52:20 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by bcmv-ns01.ecl.ntt.co.jp (Postfix) with ESMTP id 1211B119; Tue, 9 Oct 2018 19:52:20 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Tue, 9 Oct 2018 19:52:07 +0900 Message-Id: <20181009105207.42636-6-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20181009105207.42636-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20181009105207.42636-1-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 5/5] spp_vm: refactor add_ring_pmd 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: , X-List-Received-Date: Tue, 09 Oct 2018 10:52:21 -0000 From: Yasufumi Ogawa * Correct assigning of uint16_to for port ID which is assigned as int incorrectly. * Correct log messages. Signed-off-by: Yasufumi Ogawa --- src/vm/main.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/vm/main.c b/src/vm/main.c index 55592df..63d5684 100644 --- a/src/vm/main.c +++ b/src/vm/main.c @@ -315,32 +315,47 @@ get_memzone_by_addr(const void *addr) return mz; } +/* + * Create ring PMD with given ring_id. + */ static int add_ring_pmd(int ring_id) { const struct rte_memzone *memzone; struct rte_ring *ring; - int ring_port_id; + int res; + char rx_queue_name[32]; /* Prefix and number like as 'eth_ring_0' */ - /* look up ring, based on user's provided id*/ - ring = rte_ring_lookup(get_rx_queue_name(ring_id)); + memset(rx_queue_name, '\0', sizeof(rx_queue_name)); + sprintf(rx_queue_name, "%s", get_rx_queue_name(ring_id)); + + /* Look up ring with provided ring_id */ + ring = rte_ring_lookup(rx_queue_name); if (ring == NULL) { RTE_LOG(ERR, APP, - "Cannot get RX ring - is server process running?\n"); + "Failed to get RX ring %s - is primary running?\n", + rx_queue_name); return -1; } + RTE_LOG(INFO, APP, "Looked up ring '%s'\n", rx_queue_name); memzone = get_memzone_by_addr(ring); - if (memzone == NULL) + if (memzone == NULL) { + RTE_LOG(ERR, APP, "Cannot get memzone\n"); return -1; + } - /* create ring pmd*/ + /* Create ring pmd */ ring->memzone = memzone; - ring_port_id = rte_eth_from_ring(ring); - - RTE_LOG(DEBUG, APP, "ring port id %d\n", ring_port_id); + res = rte_eth_from_ring(ring); + if (res < 0) { + RTE_LOG(ERR, APP, + "Cannot create eth dev with rte_eth_from_ring()\n"); + return -1; + } + RTE_LOG(INFO, APP, "Created ring PMD: %d\n", res); - return ring_port_id; + return res; } /** -- 2.7.4