DPDK patches and discussions
 help / color / mirror / Atom feed
From: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
To: dev@dpdk.org
Subject: [PATCH v2 3/4] lib/ethdev: add support for displaying lanes capability
Date: Sat,  1 Jun 2024 19:45:03 -0700	[thread overview]
Message-ID: <20240602024504.179506-4-damodharam.ammepalli@broadcom.com> (raw)
In-Reply-To: <20240602024504.179506-1-damodharam.ammepalli@broadcom.com>

Add new rte_lib callback to display ethernet controller's
supporting speeds and bitmap of supported lanes per speed.

The new command display looks like this.

testpmd> show port 0 speed_lanes capabilities

 Supported speeds         Valid lanes
-----------------------------------
 10 Gbps                  1
 25 Gbps                  1
 40 Gbps                  4
 50 Gbps                  1 2
 100 Gbps                 1 2 4
 200 Gbps                 2 4
 400 Gbps                 4 8
testpmd>

Signed-off-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
---
 lib/ethdev/ethdev_driver.h | 21 +++++++++++++++++++++
 lib/ethdev/rte_ethdev.c    | 13 +++++++++++++
 lib/ethdev/rte_ethdev.h    | 32 ++++++++++++++++++++++++++++++++
 lib/ethdev/version.map     |  1 +
 4 files changed, 67 insertions(+)

diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index b1f473e4de..5951986cec 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1224,6 +1224,26 @@ typedef int (*eth_speed_lanes_get_t)(struct rte_eth_dev *dev,
  */
 typedef int (*eth_speed_lanes_set_t)(struct rte_eth_dev *dev, uint32_t speed_lanes_capa);
 
+/**
+ * @internal
+ * Get speed vs number of lanes supported bitmap that controller supports
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param speed_lanes_capa
+ *   int array of size max speeds bitmap ie 17
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, driver updates the speed_lanes_capa bitmap.
+ * @retval -ENOTSUP
+ *   Operation is not supported.
+ * @retval -EIO
+ *   Device is removed.
+ */
+typedef int (*eth_speed_lanes_get_capa_t)(struct rte_eth_dev *dev, uint32_t *speed_lanes_bmap);
+
 /**
  * @internal
  * Dump Tx descriptor info to a file.
@@ -1523,6 +1543,7 @@ struct eth_dev_ops {
 	eth_speed_lanes_get_t speed_lanes_get;
 	/** Set number of speed lanes */
 	eth_speed_lanes_set_t speed_lanes_set;
+	eth_speed_lanes_get_capa_t speed_lanes_get_capa;
 };
 
 /**
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 45e2f7645b..1ac5174d62 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7021,6 +7021,19 @@ rte_eth_speed_lanes_get(uint16_t port_id, struct rte_eth_speed_lanes_capa *capa)
 	return eth_err(port_id, (*dev->dev_ops->speed_lanes_get)(dev, capa));
 }
 
+int
+rte_eth_speed_lanes_get_capa(uint16_t port_id, uint32_t *speed_lanes_bmap)
+{
+        struct rte_eth_dev *dev;
+
+        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+        dev = &rte_eth_devices[port_id];
+
+        if (*dev->dev_ops->speed_lanes_get == NULL)
+                return -ENOTSUP;
+        return eth_err(port_id, (*dev->dev_ops->speed_lanes_get_capa)(dev, speed_lanes_bmap));
+}
+
 int
 rte_eth_speed_lanes_set(uint16_t port_id, uint32_t speed_lanes_capa)
 {
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index caae1f27c6..b8a29416b6 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -308,6 +308,16 @@ struct rte_eth_stats {
 #define RTE_ETH_LINK_SPEED_400G    RTE_BIT32(16) /**< 400 Gbps */
 /**@}*/
 
+/**@{@name Link speed lane capabilities
+ * Device supported speeds lane bitmap flags
+ */
+#define RTE_ETH_LINK_SPEED_MAX_BIT	17 /**< RTE_ETH_LINK_SPEED_400G bit position + 1 */
+#define LANE_1	RTE_BIT32(1)
+#define LANE_2 	RTE_BIT32(2)
+#define LANE_4 	RTE_BIT32(4)
+#define LANE_8 	RTE_BIT32(8)
+/**@}*/
+
 /**@{@name Link speed
  * Ethernet numeric link speeds in Mbps
  */
@@ -6969,6 +6979,28 @@ int rte_eth_speed_lanes_get(uint16_t port_id, struct rte_eth_speed_lanes_capa *c
 __rte_experimental
 int rte_eth_speed_lanes_set(uint16_t port_id, uint32_t speed_lanes_capa);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Set speed lanes supported by the NIC.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param speed_lanes_bmap
+ *   speed_lanes_bmap int array updated by driver by valid lanes bmap.
+ *
+ * @return
+ *  - (>=0) valid input and supported by driver or hardware.
+ *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
+ *     that operation.
+ *   - (-EIO) if device is removed.
+ *   - (-ENODEV)  if *port_id* invalid.
+ *   - (-EINVAL)  if *speed_lanes* invalid
+ */
+__rte_experimental
+int rte_eth_speed_lanes_get_capa(uint16_t port_id, uint32_t *speed_lanes_bmap);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 9c27980f3a..c453494b8d 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -327,6 +327,7 @@ EXPERIMENTAL {
 	rte_flow_template_table_resize_complete;
 	rte_eth_speed_lanes_get;
 	rte_eth_speed_lanes_set;
+	rte_eth_speed_lanes_get_capa;
 };
 
 INTERNAL {
-- 
2.39.3


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

  parent reply	other threads:[~2024-06-02  2:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 22:25 [RFC 0/2] Add support for link speed lanes Damodharam Ammepalli
2024-03-22 22:25 ` [RFC 1/2] lib/ethdev: Add link_speed lanes support into rte lib Damodharam Ammepalli
2024-03-22 22:25 ` [RFC 2/2] testpmd: Add speed lanes to testpmd config and show command Damodharam Ammepalli
2024-05-22 20:59 ` [RFC 0/2] Add support for link speed lanes Ferruh Yigit
2024-05-28 21:19   ` Damodharam Ammepalli
2024-06-02  2:45     ` [PATCH v2 0/4] " Damodharam Ammepalli
2024-06-02  2:45       ` [PATCH v2 1/4] lib/ethdev: Add link_speed lanes support into rte lib Damodharam Ammepalli
2024-06-11 23:39         ` Ferruh Yigit
2024-06-14 18:27           ` Damodharam Ammepalli
2024-06-17 20:34             ` [PATCH v3] ethdev: Add link_speed lanes support Damodharam Ammepalli
2024-06-02  2:45       ` [PATCH v2 2/4] testpmd: Add speed lanes to testpmd config and show command Damodharam Ammepalli
2024-06-11 23:39         ` Ferruh Yigit
2024-06-02  2:45       ` Damodharam Ammepalli [this message]
2024-06-11 23:39         ` [PATCH v2 3/4] lib/ethdev: add support for displaying lanes capability Ferruh Yigit
2024-06-02  2:45       ` [PATCH v2 4/4] testpmd: " Damodharam Ammepalli
2024-06-11 23:39         ` Ferruh Yigit
2024-06-12 17:53           ` Damodharam Ammepalli
2024-06-12 20:57             ` Ferruh Yigit
2024-06-11 23:38       ` [PATCH v2 0/4] Add support for link speed lanes Ferruh Yigit
2024-06-12 17:46         ` Damodharam Ammepalli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240602024504.179506-4-damodharam.ammepalli@broadcom.com \
    --to=damodharam.ammepalli@broadcom.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).