From patchwork Tue Dec 9 06:30:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1864 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 47D3D808A; Tue, 9 Dec 2014 07:31:05 +0100 (CET) Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com [209.85.192.174]) by dpdk.org (Postfix) with ESMTP id 76EE68088 for ; Tue, 9 Dec 2014 07:31:03 +0100 (CET) Received: by mail-pd0-f174.google.com with SMTP id fp1so6390159pdb.33 for ; Mon, 08 Dec 2014 22:31:02 -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=ArjZ2+Ukb9//yQk16IRpLVwBfnCmHg6woBF6mHZZZCs=; b=UunQ3Kn9M7VDM8legwDQAprnONW1WnTBrA6guFaCKCjH2BLryx9NwNYiAHr6BhstLO tOsuMSY5b8NggNH3hPeo+NINkXEJU0uypphhdeE3vdJJPO3hx/LEgEFVW+qPCYaGrWZ7 Zn3Fr7kTRX7WKBGi/xilxKEqQOSDCjcDSKYx00qv5q1U4YM0jqdAnwkQ3GHOvEYISAIO Hmbv0QM+B5HfjXlwvPUccISH+ujHapZKFVXK8ORNfwWIrWrJD2YW+w0/DSkxYgY7lJ8X G5l7qMI2WNfdYnsm3IKV7yH3dNpfJjPmmul/ux2owfTqioxikHDLkUdRZWou2iZDJh4I IeUg== X-Gm-Message-State: ALoCoQkRSg/t/0aF55fVNZaTG3gb8U6kNTT1W8XBMSriAkHDBbh0uRJaXjYUjtiEJ4d5b/5kLM7g X-Received: by 10.68.135.197 with SMTP id pu5mr2196527pbb.105.1418106662849; Mon, 08 Dec 2014 22:31:02 -0800 (PST) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id f12sm403088pat.43.2014.12.08.22.31.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 22:31:02 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 9 Dec 2014 15:30:09 +0900 Message-Id: <1418106629-22227-9-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-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 v3 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 | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 6a3700e..ddaf14a 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -437,6 +437,23 @@ 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) == DEV_INVALID) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -EINVAL; + } + + if (addr == NULL) { + PMD_DEBUG_TRACE("Null pointer is specified\n"); + 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 03c8850..30277a2 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1663,6 +1663,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