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 A28D4A04A2; Mon, 31 Jan 2022 15:21:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E5C541180; Mon, 31 Jan 2022 15:21:46 +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 D50164069D for ; Mon, 31 Jan 2022 15:21:44 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id k17so12541835plk.0 for ; Mon, 31 Jan 2022 06:21:44 -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=+nngSYAQM7EdBZqdoo3pV31H5yuLGI+qVsl1Pwf55QQ=; b=mX9uqoeOi0ANbl9MD47MjYoDX8hgqHHFt2vMAtp/EMN6NwSSQaW85nO1msqHAtqrtE 2Z6CQGei79izQJA4wBhAHkjvxiUYtbhtc6jW+Hw8u1CWnAxExrAyGFIMB3HvW2S1xF7V tb8LbEioi+RlRzPhLJQr1FOS+EC6jC0SD2GBlLoRxnZUj00Tcw7YNX45MwuAryb27jkM 1HPy0xjiUiXjd4shRwjJGVK/rQ+6HFU7jSYnT5G/YZNeC7fZ8vPkakCQE2OSNGcXvQb1 80GBhKkZQobukTZ8QMpO0NTJHw0i7hDUb2WGCS/fompl3NrD8ZlrerwBv5UalVyHPmHm ajhw== 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=+nngSYAQM7EdBZqdoo3pV31H5yuLGI+qVsl1Pwf55QQ=; b=ov8dDBWcQtsGrM47lCXrknLsXaJWMeBhJZ3rC/Cm2lIDWBVzOZvRnTc2UixcZX18bq JmE5NJkK2/mp4JGDLSR6mZ5/XEeMLBHVg0xgExpHCtB7xHATISoSvMx8InLw5cpoNrKP hdzwIzARFIf7CvsJH7pF3ijuGoBhEZvcxIb6Uf8KNJc4bp1Nq0GFVYwhBUrPZSfv2eaT JOQp5LRIxH1duhf6QPiBHYntwXm5AYWgufZpHG/8BxBNv9XdwvWXOBGePPqBwsjGBQfr 9L/HzXA4l54EHiqymCEvuuizlvhQ700eFTPojFKjoinSbX7DB2zRB0FS72tULXxu85jZ bwtQ== X-Gm-Message-State: AOAM530lkRBtSmRdVGIwfZ75WJOQQUUFNGYqqLS9nhmGkW/eoo5ZakHK Shs94H9Un4hePp1puxjFyuK7qtIorVlLDQ== X-Google-Smtp-Source: ABdhPJwBxuzwb7UR6q9Ks/+HXNPikNhHqbHHfFC56+YqUbwQ09C9hzcbPDNLPJRyJTxAfxcrVxscnA== X-Received: by 2002:a17:902:d509:: with SMTP id b9mr20940343plg.3.1643638903749; Mon, 31 Jan 2022 06:21:43 -0800 (PST) Received: from kparameshwa-a01.vmware.com.com ([49.206.11.18]) by smtp.gmail.com with ESMTPSA id mq3sm12951347pjb.4.2022.01.31.06.21.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jan 2022 06:21:43 -0800 (PST) From: Kumara Parameshwaran To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kumara Parameshwaran Subject: [PATCH v3 1/2] ethdev: define a function to get eth dev structure Date: Mon, 31 Jan 2022 19:51:36 +0530 Message-Id: <20220131142137.14260-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