From patchwork Thu Nov 20 09:06:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1371 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 5E3767FD2; Thu, 20 Nov 2014 09:57:09 +0100 (CET) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by dpdk.org (Postfix) with ESMTP id B7CEB7FCF for ; Thu, 20 Nov 2014 09:57:06 +0100 (CET) Received: by mail-pa0-f47.google.com with SMTP id kq14so2179588pab.20 for ; Thu, 20 Nov 2014 01:07:35 -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=bmDu7j+SauSOa7xo8yyOODew+avmBFG9rLvRaD6TdRA=; b=kw38iOr9zz+95rbQtg7CAxLeOrZtJCJZscya3ojJjNtmWHMsZ1j+KaZ1vJnia0y5Hj CeZtRdP4Ohw63/oQX9KdOFfFbqdkVdfgO702d08Gx47pM45f+lfQMcRU/sW+cUw9d3bU rge0SVbmdxRdJ3U/eE+08Xf3q0RaJ6NFwxAF9weFeImI89aAyKcJKvN4Y6NB7ZnYO5q0 vN31aAO0dfoRuHIjzscdmq4U9/vxEPFEQ8lApAB/xYxq+jF2ntKMOLotLM/5IM3emnp8 7/rsKiJf5BqKQW8oEqCtuo5wNrMLrPujhzDbzVoyrxX/vxAmC4CgbfF4DqFN5Pp39c06 uPqQ== X-Gm-Message-State: ALoCoQlu8AARteeRhMoLp+qcZ2BUUIXJTczR/C1RHrA0wzNdQdRAE3RhhZcIYJFGddEocnv5Qbql X-Received: by 10.68.211.193 with SMTP id ne1mr54357090pbc.49.1416474455526; Thu, 20 Nov 2014 01:07:35 -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.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 01:07:34 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 20 Nov 2014 18:06:22 +0900 Message-Id: <1416474399-16851-9-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 08/25] ethdev: Add rte_eth_dev_get_addr_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 pci address of a ethdev specified by port identifier. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 12 ++++++++++++ lib/librte_ether/rte_ethdev.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 5e1b6b9..fa75ea9 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -420,6 +420,18 @@ rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *port_id) return 1; } +int +rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr) +{ + if (rte_eth_dev_validate_port(port_id)) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -EINVAL; + } + + *addr = rte_eth_devices[port_id].pci_dev->addr; + 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 683b79c..fd4aa5a 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1659,6 +1659,19 @@ extern int rte_eth_dev_get_changed_port( struct rte_eth_dev *devs, uint8_t *port_id); /** + * Function for internal use by port hotplug functions. + * Returns a pci address of a ethdev specified by port identifier. + * @param port_id + * The port identifier of the Ethernet device + * @param addr + * The pointer to the pci address + * @return + * - 0 on success, negative on error + */ +extern int rte_eth_dev_get_addr_by_port( + uint8_t port_id, struct rte_pci_addr *addr); + +/** * 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