From patchwork Thu Nov 20 09:06:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1373 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 692397FEE; Thu, 20 Nov 2014 09:57:16 +0100 (CET) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by dpdk.org (Postfix) with ESMTP id 49E1D7F11 for ; Thu, 20 Nov 2014 09:57:12 +0100 (CET) Received: by mail-pd0-f182.google.com with SMTP id r10so2720330pdi.13 for ; Thu, 20 Nov 2014 01:07:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mQoNeQX+BnHptVOiYm/5rcBdyVb7bB71f+SxMLJsh6c=; b=ckS+XwLw1QB3vNde05d7dDHDXyQiGOG2glcuTBj/LS5iX+pmh8mG3KEuZwXHcsoJvS 44Y44EzRNKbm6dvfEjVC871PAWdwll+4mvWnmCI38s+fUIlINmVkv73fdnuKsGY6tNmH Ycqlof4qB7LSPem10RQzsGpUtXG2SUuLJqb3YbUXwsU6Pj77lH7hUaNb8IhZxx9NDCkA SHQ+Yn7Hc7glHqBYDNz4p7jkcbDGmEh5pN/L6rFUGOnStNuUv9XsZNOxLV9+yOg39ZgX 7l5doLGT0DvyWezztENpZeltLw0y8yFnhfKvVyuXJ/IH12kVqnaTbmCvibJGPNoKzNH/ dypQ== X-Gm-Message-State: ALoCoQl1AH7k0KkwxirF+gm0J4mI8ja81bkn+2Eoq9YMGVbG4cnvEcBqhdySL3qHU8mAzt3sRFZJ X-Received: by 10.68.111.37 with SMTP id if5mr27758535pbb.140.1416474460909; Thu, 20 Nov 2014 01:07:40 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id a6sm1432407pbu.64.2014.11.20.01.07.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 01:07:40 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 20 Nov 2014 18:06:24 +0900 Message-Id: <1416474399-16851-11-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [PATCH 10/25] ethdev: Add rte_eth_dev_get_name_by_port 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The function returns a unique identifier name of a ethdev specified by port identifier. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index fa5b928..372ab7d 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -449,6 +449,23 @@ rte_eth_dev_get_port_by_addr(struct rte_pci_addr *addr, uint8_t *port_id) return -1; } +int +rte_eth_dev_get_name_by_port(uint8_t port_id, char *name) +{ + char *tmp; + + if (rte_eth_dev_validate_port(port_id)) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -EINVAL; + } + + /* shouldn't check 'rte_eth_devices[i].data', + * because it might be overwritten by VDEV PMD */ + tmp = rte_eth_dev_data[port_id].name; + strncpy(name, tmp, strlen(tmp) + 1); + return 0; +} + static int rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 8bdc8ae..2087daf 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1685,6 +1685,18 @@ extern int rte_eth_dev_get_port_by_addr( struct rte_pci_addr *addr, uint8_t *port_id); /** + * Function for internal use by port hotplug functions. + * Returns a unique identifier name of a ethdev specified by port identifier. + * @param port_id + * The port identifier. + * @param name + * The pointer to the Unique identifier name for each Ethernet device + * @return + * - 0 on success, negative on error + */ +extern int rte_eth_dev_get_name_by_port(uint8_t port_id, char *name); + +/** * Function for internal use by dummy drivers primarily, e.g. ring-based * driver. * Allocates a new ethdev slot for an ethernet device and returns the pointer