From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CF8BAA04A2; Mon, 31 Jan 2022 15:32:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C2FA411A4; Mon, 31 Jan 2022 15:32:44 +0100 (CET) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id 7E81141183; Mon, 31 Jan 2022 15:32:42 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id x11so12497687plg.6; Mon, 31 Jan 2022 06:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dQVX+F+9L5PzygSK/Z9zRKMWHZrTXyFdwXFIWJYDi4E=; b=Xw5F0P0A6i6hzYENUKM1AFgT2onQy+EMSxnaBI7UO7bJPhCPVHBzJpXjIubD/skwz7 65K2iRFQj5X2kea5SpwQI8Gp3D2CUMDKzMAYdcZlrVnH997rA4UbR2LYgJfrSj3RrpjB mAUoKJDhTsvCmyMXxxAkQePj6hwNk8ph5CB/3bKBI5KSbh6Dn2eLTBh04LeRAl/3Vpif hrrLQdkkqNvqtTfgU1BmrzFFUz4oE3fVuLpoq+eDW9dgvC7JAPatir0L+SuOW76VJ3W/ ggUf8OWnIg6tEDiWr0fRytcbRVlY/6XatzHtwXVAcC4ukCUIBkx+uVVWjYK/7Ee+It/D l3YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dQVX+F+9L5PzygSK/Z9zRKMWHZrTXyFdwXFIWJYDi4E=; b=GQj3ByhQZy/I4uSJgO4ZkW0NEfMAOzP59ckcwmUrw9XL6x/64k7B0NLQ3kRQdYASuT B2kl/Pf+MrYR+CG8/UYSK687J83M/G3T1vvMjZEfvdhkyg1zaobfgJcDCHheJi9F1zqw SXMqW48lShtRCwl1g9YQL5GyoS2rnKPTy72LvfVfObtlgX2G633WZlTtOGcABeJvuUB+ aFZviIQrLh5OIdPIW0/Xd8HEUFwrozO1hy/J25j/n5Wn85nNnnWe7wUJIauiqQmy6FzK sebSym/Uy5rOcTH5PqWzevx9VKok9gJLbhzoK/KP6R2021H7ByZ/feR2NTb6U0+agFfp lPkw== X-Gm-Message-State: AOAM530sCqybjHO1NeiYrqYUWcl7wKB5GbgPV6PikGwKd8Hi85g8omtq n6RMNJVTPwrXC/FyEkFCn2BJ3AG8/QRCTg== X-Google-Smtp-Source: ABdhPJz7io9h7OYnqEZHMAXRY1pSKtdggpVeRQJMM6UbrQzlUcxNJxOHAy9umMAGd2DrDMTcXKOlkA== X-Received: by 2002:a17:902:bc82:: with SMTP id bb2mr7129098plb.145.1643639561314; Mon, 31 Jan 2022 06:32:41 -0800 (PST) Received: from kparameshwa-a01.vmware.com.com ([49.206.11.18]) by smtp.gmail.com with ESMTPSA id n22sm18602571pfu.77.2022.01.31.06.32.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jan 2022 06:32:40 -0800 (PST) From: Kumara Parameshwaran To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kumara Parameshwaran , stable@dpdk.org Subject: [PATCH v3 1/2] ethdev: define a function to get eth dev structure Date: Mon, 31 Jan 2022 20:02:33 +0530 Message-Id: <20220131143234.17945-1-kumaraparamesh92@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220121042944.23929-1-kumaraparamesh92@gmail.com> References: <20220121042944.23929-1-kumaraparamesh92@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Kumara Parameshwaran The PMDs would need a function to access the rte_eth_devices global array Cc: stable@dpdk.org Signed-off-by: Kumara Parameshwaran --- lib/ethdev/ethdev_driver.h | 18 ++++++++++++++++++ lib/ethdev/rte_ethdev.c | 11 +++++++++++ lib/ethdev/version.map | 1 + 3 files changed, 30 insertions(+) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index d95605a355..7d27781f7d 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1629,6 +1629,24 @@ rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue, struct rte_hairpin_peer_info *peer_info, uint32_t direction); +/** + * @internal + * Get rte_eth_dev from device name. The device name should be specified + * as below: + * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0 + * - SoC device name, for example- fsl-gmac0 + * - vdev dpdk name, for example- net_[pcap0|null0|tap0] + * + * @param name + * pci address or name of the device + * @return + * - rte_eth_dev if successful + * - NULL on failure + */ +__rte_internal +struct rte_eth_dev* +rte_eth_dev_get_by_name(const char *name); + /** * @internal * Reset the current queue state and configuration to disconnect (unbind) it diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index a1d475a292..968475d107 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -894,6 +894,17 @@ rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id) return -ENODEV; } +struct rte_eth_dev * +rte_eth_dev_get_by_name(const char *name) +{ + uint16_t pid; + + if (rte_eth_dev_get_port_by_name(name, &pid)) + return NULL; + + return &rte_eth_devices[pid]; +} + static int eth_err(uint16_t port_id, int ret) { diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index c2fb0669a4..1f7359c846 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -267,6 +267,7 @@ INTERNAL { rte_eth_dev_callback_process; rte_eth_dev_create; rte_eth_dev_destroy; + rte_eth_dev_get_by_name; rte_eth_dev_is_rx_hairpin_queue; rte_eth_dev_is_tx_hairpin_queue; rte_eth_dev_probing_finish; -- 2.17.1