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 C77217FE6 for ; Wed, 29 Oct 2014 09:41:26 +0100 (CET) Received: by mail-pd0-f169.google.com with SMTP id y10so2600921pdj.0 for ; Wed, 29 Oct 2014 01:50:17 -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=LqzzRHsnwQrkuEPisEm4u1p3hsRDss6Vg7VotB/n2gk=; b=h4Sscfen7iIE14qOEXp7bxHXB3PIi6KKURLUsYv4xnR2a9DWxj9pYCDAVjtfLktoTH nmodW/Txn5D0qTur5+7ykJH+l/YvNeiFSVPCB3BWSV54Ng9X7EeW2fNlP9oNcc5D+gkG ACjNATjXknnBufm1BSwF5U86no0zJ2z/80UwKIh2WQBIVuEGEV7+utAQY/3KWAwz+UKY yMkgSRzbTTu6P7anuq8wjJ36BhDKFkG42LWs1kUkURv4rWSRsx0XkRgpcwvhjo/WmnZ+ qxjiP9Vm7pbZ2YCEzMtoikg+RNINlGb14E2BYoLRpFFD39CPOZShAG/TBsgI6/w0nCU7 2jzg== X-Gm-Message-State: ALoCoQm4szgVcoODkOj/ewAk2x3NabgBD71Du5l79HXQf0q0OK6KL4Tek/DyEYzJx6uO+VFwT/GG X-Received: by 10.66.241.239 with SMTP id wl15mr9220439pac.15.1414572617096; Wed, 29 Oct 2014 01:50:17 -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.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Oct 2014 01:50:16 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Wed, 29 Oct 2014 17:49:20 +0900 Message-Id: <1414572576-21371-10-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 09/25] ethdev: Add rte_eth_dev_get_port_by_addr 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:27 -0000 The function returns a port identifier of a ethdev specified by pci address. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 13 +++++++++++++ lib/librte_ether/rte_ethdev.h | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index c04061d..fb3094a 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -434,6 +434,19 @@ rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr) return 0; } +int +rte_eth_dev_get_port_by_addr(struct rte_pci_addr *addr, uint8_t *port_id) +{ + struct rte_pci_addr *tmp; + + for (*port_id = 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++) { + tmp = &rte_eth_devices[*port_id].pci_dev->addr; + if (eal_compare_pci_addr(tmp, addr)) + return 0; + } + return -1; +} + 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 e87e7cc..8a9d1d5 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1652,6 +1652,19 @@ extern int rte_eth_dev_get_addr_by_port( uint8_t port_id, struct rte_pci_addr *addr); /** + * Function for internal use by port hotplug functions. + * Returns a port identifier of a ethdev specified by pci address. + * @param addr + * The pointer to the pci address of the Ethernet device. + * @param port_id + * The pointer to the port identifier + * @return + * - 0 on success, negative on error + */ +extern int rte_eth_dev_get_port_by_addr( + struct rte_pci_addr *addr, uint8_t *port_id); + +/** * 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