From patchwork Tue Nov 4 03:45:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1094 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 E2E6A7F65; Tue, 4 Nov 2014 04:37:21 +0100 (CET) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by dpdk.org (Postfix) with ESMTP id D84B658EE for ; Tue, 4 Nov 2014 04:37:13 +0100 (CET) Received: by mail-pa0-f52.google.com with SMTP id fa1so13556901pad.11 for ; Mon, 03 Nov 2014 19:46:30 -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=410d6X8lhkoWh8J0DjAuitFjHio7oG4pDgsQVaijvI4=; b=XIrzUFm5iUWnjTvTmO9i/eNE076J0jdveFVMqPyN4X24cExScaPXZa9p8eNctWyOui Vh31rVMJyKlZrUgN4GdbaXXXa7l7zdo/5wmaYw79uOOEcS81ASDc7e6Qp7AaJawfPOD3 mP2EhhnnetQ0+/eZ9JsolfCNKKOAkbYQybh2XBGHN5TZr0GNtJ2VU3BMKNUm8fzoBkyv fVgD4SHGiwNqeCLfD01nmI2Pl9IJehCJ6TBrvTn9ISB0wlYq6xc8HNIlZbaAaV22+oRm 86IFODeVEG+EVw3QzZVDXrYFeHpdnHyTg51/F2hLsP+q629Ml2oEpyKEbs8ca1of+vj9 Txcw== X-Gm-Message-State: ALoCoQnQWILxPpmz4uH6SEl0Z3BX/tWT8/Q9Gpqfc75gBvowi+j/duSEDRKdLbOZQsmUnTgCXe+3 X-Received: by 10.66.90.129 with SMTP id bw1mr46760849pab.61.1415072790095; Mon, 03 Nov 2014 19:46:30 -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.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Nov 2014 19:46:29 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 4 Nov 2014 12:45:28 +0900 Message-Id: <1415072748-31937-9-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 08/28] 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 939bf3b..f59658a 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -409,6 +409,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 (port_id >= nb_ports) { + 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 106ba5c..e87e7cc 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1639,6 +1639,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