From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id EF408C6A2 for ; Thu, 18 Jun 2015 15:28:44 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 18 Jun 2015 06:28:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,638,1427785200"; d="scan'208";a="748993954" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 18 Jun 2015 06:28:43 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t5IDSgWv012810; Thu, 18 Jun 2015 14:28:42 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t5IDSfFi024075; Thu, 18 Jun 2015 14:28:41 +0100 Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id t5IDSfol024071; Thu, 18 Jun 2015 14:28:41 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Thu, 18 Jun 2015 14:28:41 +0100 Message-Id: <1434634121-24036-1-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] pmd_ring: return new port id on ethdev creation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jun 2015 13:28:45 -0000 The rte_eth_from_rings API allowed the creation of an ethdev port at runtime using rte_rings as the underlying storage. However, the return value from this function was either 0 or -1, and these values were never actually documented in the API documentation. Unfortunately, the programmers guide doc examples for this API implied that the return value from this function was the port id of the newly created ethdev. Since this latter behaviour is more useful - and already implied by the documentation, this patch changes the return 0 to "return data->port_id". It also adds in doxygen comments for the function so it can be correctly documented in the API reference. Signed-off-by: Bruce Richardson --- drivers/net/ring/rte_eth_ring.c | 9 +++++---- drivers/net/ring/rte_eth_ring.h | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 6832f01..ada025f 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -346,7 +346,7 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], eth_dev->rx_pkt_burst = eth_ring_rx; eth_dev->tx_pkt_burst = eth_ring_tx; - return 0; + return data->port_id; error: rte_free(data); @@ -384,7 +384,7 @@ eth_dev_ring_create(const char *name, const unsigned numa_node, return -1; } - if (rte_eth_from_rings(name, rxtx, num_rings, rxtx, num_rings, numa_node)) + if (rte_eth_from_rings(name, rxtx, num_rings, rxtx, num_rings, numa_node) < 0) return -1; return 0; @@ -424,8 +424,9 @@ eth_dev_ring_pair_create(const char *name, const unsigned numa_node, } if (rte_eth_from_rings(rx_rng_name, rx, num_rings, tx, num_rings, - numa_node) || rte_eth_from_rings(tx_rng_name, tx, num_rings, rx, - num_rings, numa_node)) + numa_node) < 0 || + rte_eth_from_rings(tx_rng_name, tx, num_rings, rx, + num_rings, numa_node) < 0) return -1; return 0; diff --git a/drivers/net/ring/rte_eth_ring.h b/drivers/net/ring/rte_eth_ring.h index d36489a..2262249 100644 --- a/drivers/net/ring/rte_eth_ring.h +++ b/drivers/net/ring/rte_eth_ring.h @@ -40,6 +40,24 @@ extern "C" { #include +/** + * Create a new ethdev port from a set of rings + * + * @param name + * name to be given to the new ethdev port + * @param rx_queues + * pointer to array of rte_rings to be used as RX queues + * @param nb_rx_queues + * number of elements in the rx_queues array + * @param tx_queues + * pointer to array of rte_rings to be used as TX queues + * @param nb_tx_queues + * number of elements in the tx_queues array + * @param numa_node + * the numa node on which the memory for this port is to be allocated + * @return + * the port number of the newly created the ethdev or -1 on error. + */ int rte_eth_from_rings(const char *name, struct rte_ring * const rx_queues[], const unsigned nb_rx_queues, -- 2.4.3