From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by dpdk.org (Postfix) with ESMTP id 24EA67F45 for ; Tue, 4 Nov 2014 04:37:18 +0100 (CET) Received: by mail-pa0-f43.google.com with SMTP id eu11so13571456pac.2 for ; Mon, 03 Nov 2014 19:46:34 -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=YkHeF2KE8B/upaYOsv8YU7TV5qguw2642R+hIQeY2JI=; b=jaxD0XU9RM/ifk2qC+3NSKkuqqzMNMg4l2a+Wk4Nd4kW1+vhnzOGhBo6NyRbqoJKZg D70monhu6iscYcS2gOWqBFhK7ocbE52eTIMgK9IPYJlhiTKsgqhrQqHW7UCd9X1Kfuwv bVILqTheSgS1Ugs+nMJqdcIaRQLCmPMGBd21u4tTDr8drj6L4t6yxUfu+AXTs9PTr091 o56y/r6Kgs+90JRRGNdvXwovchcPL6Bc462rSYOWcR1w88zw48L6+xThsotAUsuGTo5F 5XgAue7aWxL3fdXUVC/HXx+CxPSvs8EL59keQDyCEHuIkdn7YLyp0goN7yyM/t1z3zx9 kejw== X-Gm-Message-State: ALoCoQkvDEp5U6jWfW/uIBx8GHFAM1YdAwXAPnxzuUVYXXqBQ1djVyRsZL+jb0R3Cvt+gqBLAif9 X-Received: by 10.66.65.130 with SMTP id x2mr39302991pas.85.1415072794318; Mon, 03 Nov 2014 19:46:34 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id jc3sm18430580pbb.49.2014.11.03.19.46.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Nov 2014 19:46:33 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 4 Nov 2014 12:45:30 +0900 Message-Id: <1415072748-31937-11-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415072748-31937-1-git-send-email-mukawa@igel.co.jp> References: <1414572576-21371-1-git-send-email-mukawa@igel.co.jp> <1415072748-31937-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 v2 10/28] 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: Tue, 04 Nov 2014 03:37:20 -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 48833f7..e3f2713 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -434,6 +434,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 (port_id >= nb_ports) { + 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 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