From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) by dpdk.org (Postfix) with ESMTP id DA42A7FDB for ; Wed, 29 Oct 2014 09:41:28 +0100 (CET) Received: by mail-pd0-f169.google.com with SMTP id y10so2566829pdj.14 for ; Wed, 29 Oct 2014 01:50:19 -0700 (PDT) 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=/wvU6NbZ2hqYdD9ZObyaWahOIW904iMdTIvCbWmMLy8=; b=i1pWxWk7lGDwfflsy+9//WDDeRrSGePrcpT0Tg09NjJFBwJWMye02GTkqgv2aXOEdr yn4jLg019nSxkoT5N+7o4iyKNtrvFpGPeAa61AHsEr/ukJ0wE2VNeAAO72eF9ac4juQ2 f3VFSQmWiyJOYGxUWpMPp+7uXy+DUY727XMZgkXYtmOLl6l7Y1j8u8edD2x/Qw2WZkMV 6jKl/fREhdlzEyk6AHvDVz44lDE8GQVc4T3b2lyB2tHKnS7FkIdmXv7sLu01IIFKhTov PNGhazpQf5xHmwNqsSr/EOjF/34x8yhV3/89W+vTJzYD1cKCj98r5sV5bgsnndPMMowV r86A== X-Gm-Message-State: ALoCoQk4Cfw04ikwjv6RdTwNPGwkmEJZT/B7JnM/Dy7A8OUMbcc9/cGEdxiaFiMwNQF5pNdhThBi X-Received: by 10.70.88.139 with SMTP id bg11mr9092614pdb.145.1414572619232; Wed, 29 Oct 2014 01:50:19 -0700 (PDT) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id ky4sm3686872pbc.55.2014.10.29.01.50.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Oct 2014 01:50:18 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Wed, 29 Oct 2014 17:49:21 +0900 Message-Id: <1414572576-21371-11-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [RFC 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: , X-List-Received-Date: Wed, 29 Oct 2014 08:41:29 -0000 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 fb3094a..dea28c2 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -447,6 +447,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 1; + } + + /* 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 8a9d1d5..11853f5 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1665,6 +1665,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 -- 1.9.1