* [PATCH] ethdev: add support to provide link type
@ 2025-06-05 11:31 skori
2025-06-05 15:26 ` Stephen Hemminger
2025-06-06 9:28 ` [PATCH v2 1/1] " skori
0 siblings, 2 replies; 5+ messages in thread
From: skori @ 2025-06-05 11:31 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko
Cc: dev, Sunil Kumar Kori, Nithin Dabilpuram
From: Sunil Kumar Kori <skori@marvell.com>
As a port can be configured at one of the supported speed
which can be part of specific link mode.
Port type helps to translate speed into the respective mode.
Hence add support to provide link type as part of link
status if available from ethdev driver.
Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
lib/ethdev/ethdev_trace.h | 7 +++++
lib/ethdev/ethdev_trace_points.c | 3 +++
lib/ethdev/rte_ethdev.c | 45 ++++++++++++++++++++++++++++++--
lib/ethdev/rte_ethdev.h | 28 ++++++++++++++++++++
4 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h
index c65b78590a..a060e2de03 100644
--- a/lib/ethdev/ethdev_trace.h
+++ b/lib/ethdev/ethdev_trace.h
@@ -2110,6 +2110,13 @@ RTE_TRACE_POINT_FP(
rte_trace_point_emit_string(ret);
)
+RTE_TRACE_POINT_FP(
+ rte_eth_trace_link_type_to_str,
+ RTE_TRACE_POINT_ARGS(uint8_t link_type, const char *ret),
+ rte_trace_point_emit_u8(link_type);
+ rte_trace_point_emit_string(ret);
+);
+
/* Called in loop in examples/bond and examples/ethtool */
RTE_TRACE_POINT_FP(
rte_eth_trace_macaddr_get,
diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c
index 071c508327..706acdf356 100644
--- a/lib/ethdev/ethdev_trace_points.c
+++ b/lib/ethdev/ethdev_trace_points.c
@@ -206,6 +206,9 @@ RTE_TRACE_POINT_REGISTER(rte_eth_trace_link_speed_to_str,
RTE_TRACE_POINT_REGISTER(rte_eth_trace_link_to_str,
lib.ethdev.link_to_str)
+RTE_TRACE_POINT_REGISTER(rte_eth_trace_link_type_to_str,
+ lib.ethdev.link_type_to_str)
+
RTE_TRACE_POINT_REGISTER(rte_eth_trace_stats_get,
lib.ethdev.stats_get)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d4197322a0..73a38ea2ca 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -3286,18 +3286,59 @@ rte_eth_link_to_str(char *str, size_t len, const struct rte_eth_link *eth_link)
if (eth_link->link_status == RTE_ETH_LINK_DOWN)
ret = snprintf(str, len, "Link down");
else
- ret = snprintf(str, len, "Link up at %s %s %s",
+ ret = snprintf(str, len, "Link up at %s %s %s %s",
rte_eth_link_speed_to_str(eth_link->link_speed),
(eth_link->link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ?
"FDX" : "HDX",
(eth_link->link_autoneg == RTE_ETH_LINK_AUTONEG) ?
- "Autoneg" : "Fixed");
+ "Autoneg" : "Fixed",
+ rte_eth_link_type_to_str(eth_link->link_type));
rte_eth_trace_link_to_str(len, eth_link, str, ret);
return ret;
}
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_link_type_to_str, 25.07)
+const char *
+rte_eth_link_type_to_str(uint8_t link_type)
+{
+ const char *ret;
+
+ switch (link_type) {
+ case RTE_ETH_LINK_TYPE_NONE:
+ ret = "None";
+ break;
+ case RTE_ETH_LINK_TYPE_TP:
+ ret = "Twisted Pair";
+ break;
+ case RTE_ETH_LINK_TYPE_AUI:
+ ret = "AUI";
+ break;
+ case RTE_ETH_LINK_TYPE_MII:
+ ret = "MII";
+ break;
+ case RTE_ETH_LINK_TYPE_FIBRE:
+ ret = "Fibre";
+ break;
+ case RTE_ETH_LINK_TYPE_BNC:
+ ret = "BNC";
+ break;
+ case RTE_ETH_LINK_TYPE_DA:
+ ret = "Direct Attach Copper";
+ break;
+ case RTE_ETH_LINK_TYPE_OTHER:
+ ret = "Other";
+ break;
+ default:
+ ret = "Invalid";
+ }
+
+ rte_eth_trace_link_type_to_str(link_type, ret);
+
+ return ret;
+}
+
RTE_EXPORT_SYMBOL(rte_eth_stats_get)
int
rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index ea7f8c4a1a..19417242ca 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -329,6 +329,19 @@ struct rte_eth_stats {
#define RTE_ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
/**@}*/
+/**@{@name PORT type
+ * Ethernet port type
+ */
+#define RTE_ETH_LINK_TYPE_NONE 0x00 /**< Not defined */
+#define RTE_ETH_LINK_TYPE_TP 0x01 /**< Twisted Pair */
+#define RTE_ETH_LINK_TYPE_AUI 0x02 /**< Attachment Unit Interface */
+#define RTE_ETH_LINK_TYPE_MII 0x03 /**< Media Independent Interface */
+#define RTE_ETH_LINK_TYPE_FIBRE 0x04 /**< Fibre */
+#define RTE_ETH_LINK_TYPE_BNC 0x05 /**< BNC */
+#define RTE_ETH_LINK_TYPE_DA 0x06 /**< Direct Attach copper */
+#define RTE_ETH_LINK_TYPE_OTHER 0x1F /**< Other type */
+/**@}*/
+
/**
* A structure used to retrieve link-level information of an Ethernet port.
*/
@@ -341,6 +354,7 @@ struct rte_eth_link {
uint16_t link_duplex : 1; /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */
uint16_t link_autoneg : 1; /**< RTE_ETH_LINK_[AUTONEG/FIXED] */
uint16_t link_status : 1; /**< RTE_ETH_LINK_[DOWN/UP] */
+ uint16_t link_type : 5; /**< RTE_ETH_LINK_TYPE_XXX */
};
};
};
@@ -3113,6 +3127,20 @@ int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link)
__rte_experimental
const char *rte_eth_link_speed_to_str(uint32_t link_speed);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * This function converts an Ethernet link type to a string.
+ *
+ * @param link_type
+ * The link type to convert.
+ * @return
+ * The string representation of the link type.
+ */
+__rte_experimental
+const char *rte_eth_link_type_to_str(uint8_t link_type);
+
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice.
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ethdev: add support to provide link type
2025-06-05 11:31 [PATCH] ethdev: add support to provide link type skori
@ 2025-06-05 15:26 ` Stephen Hemminger
2025-06-06 9:28 ` [PATCH v2 1/1] " skori
1 sibling, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-06-05 15:26 UTC (permalink / raw)
To: skori
Cc: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, dev, Nithin Dabilpuram
On Thu, 5 Jun 2025 17:01:51 +0530
<skori@marvell.com> wrote:
> From: Sunil Kumar Kori <skori@marvell.com>
>
> As a port can be configured at one of the supported speed
> which can be part of specific link mode.
>
> Port type helps to translate speed into the respective mode.
>
> Hence add support to provide link type as part of link
> status if available from ethdev driver.
>
This is hard to read English syntax.
Maybe try one of the AI grammar tools to make it more readable.
> Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/1] ethdev: add support to provide link type
2025-06-05 11:31 [PATCH] ethdev: add support to provide link type skori
2025-06-05 15:26 ` Stephen Hemminger
@ 2025-06-06 9:28 ` skori
2025-06-06 9:54 ` Morten Brørup
1 sibling, 1 reply; 5+ messages in thread
From: skori @ 2025-06-06 9:28 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko
Cc: dev, Sunil Kumar Kori, Nithin Dabilpuram
From: Sunil Kumar Kori <skori@marvell.com>
Adding link type parameter to provide the type
of port like twisted pair, fibre etc.
Also added an API to convert the RTE_ETH_LINK_TYPE_XXX
to a readable string.
Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v1..v2:
- Updated the commit message.
- change release version to 25.11
lib/ethdev/ethdev_trace.h | 7 +++++
lib/ethdev/ethdev_trace_points.c | 3 +++
lib/ethdev/rte_ethdev.c | 45 ++++++++++++++++++++++++++++++--
lib/ethdev/rte_ethdev.h | 28 ++++++++++++++++++++
4 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h
index c65b78590a..a060e2de03 100644
--- a/lib/ethdev/ethdev_trace.h
+++ b/lib/ethdev/ethdev_trace.h
@@ -2110,6 +2110,13 @@ RTE_TRACE_POINT_FP(
rte_trace_point_emit_string(ret);
)
+RTE_TRACE_POINT_FP(
+ rte_eth_trace_link_type_to_str,
+ RTE_TRACE_POINT_ARGS(uint8_t link_type, const char *ret),
+ rte_trace_point_emit_u8(link_type);
+ rte_trace_point_emit_string(ret);
+);
+
/* Called in loop in examples/bond and examples/ethtool */
RTE_TRACE_POINT_FP(
rte_eth_trace_macaddr_get,
diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c
index 071c508327..706acdf356 100644
--- a/lib/ethdev/ethdev_trace_points.c
+++ b/lib/ethdev/ethdev_trace_points.c
@@ -206,6 +206,9 @@ RTE_TRACE_POINT_REGISTER(rte_eth_trace_link_speed_to_str,
RTE_TRACE_POINT_REGISTER(rte_eth_trace_link_to_str,
lib.ethdev.link_to_str)
+RTE_TRACE_POINT_REGISTER(rte_eth_trace_link_type_to_str,
+ lib.ethdev.link_type_to_str)
+
RTE_TRACE_POINT_REGISTER(rte_eth_trace_stats_get,
lib.ethdev.stats_get)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d4197322a0..4464ec00e6 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -3286,18 +3286,59 @@ rte_eth_link_to_str(char *str, size_t len, const struct rte_eth_link *eth_link)
if (eth_link->link_status == RTE_ETH_LINK_DOWN)
ret = snprintf(str, len, "Link down");
else
- ret = snprintf(str, len, "Link up at %s %s %s",
+ ret = snprintf(str, len, "Link up at %s %s %s %s",
rte_eth_link_speed_to_str(eth_link->link_speed),
(eth_link->link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ?
"FDX" : "HDX",
(eth_link->link_autoneg == RTE_ETH_LINK_AUTONEG) ?
- "Autoneg" : "Fixed");
+ "Autoneg" : "Fixed",
+ rte_eth_link_type_to_str(eth_link->link_type));
rte_eth_trace_link_to_str(len, eth_link, str, ret);
return ret;
}
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_link_type_to_str, 25.11)
+const char *
+rte_eth_link_type_to_str(uint8_t link_type)
+{
+ const char *ret;
+
+ switch (link_type) {
+ case RTE_ETH_LINK_TYPE_NONE:
+ ret = "None";
+ break;
+ case RTE_ETH_LINK_TYPE_TP:
+ ret = "Twisted Pair";
+ break;
+ case RTE_ETH_LINK_TYPE_AUI:
+ ret = "AUI";
+ break;
+ case RTE_ETH_LINK_TYPE_MII:
+ ret = "MII";
+ break;
+ case RTE_ETH_LINK_TYPE_FIBRE:
+ ret = "Fibre";
+ break;
+ case RTE_ETH_LINK_TYPE_BNC:
+ ret = "BNC";
+ break;
+ case RTE_ETH_LINK_TYPE_DA:
+ ret = "Direct Attach Copper";
+ break;
+ case RTE_ETH_LINK_TYPE_OTHER:
+ ret = "Other";
+ break;
+ default:
+ ret = "Invalid";
+ }
+
+ rte_eth_trace_link_type_to_str(link_type, ret);
+
+ return ret;
+}
+
RTE_EXPORT_SYMBOL(rte_eth_stats_get)
int
rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index ea7f8c4a1a..19417242ca 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -329,6 +329,19 @@ struct rte_eth_stats {
#define RTE_ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
/**@}*/
+/**@{@name PORT type
+ * Ethernet port type
+ */
+#define RTE_ETH_LINK_TYPE_NONE 0x00 /**< Not defined */
+#define RTE_ETH_LINK_TYPE_TP 0x01 /**< Twisted Pair */
+#define RTE_ETH_LINK_TYPE_AUI 0x02 /**< Attachment Unit Interface */
+#define RTE_ETH_LINK_TYPE_MII 0x03 /**< Media Independent Interface */
+#define RTE_ETH_LINK_TYPE_FIBRE 0x04 /**< Fibre */
+#define RTE_ETH_LINK_TYPE_BNC 0x05 /**< BNC */
+#define RTE_ETH_LINK_TYPE_DA 0x06 /**< Direct Attach copper */
+#define RTE_ETH_LINK_TYPE_OTHER 0x1F /**< Other type */
+/**@}*/
+
/**
* A structure used to retrieve link-level information of an Ethernet port.
*/
@@ -341,6 +354,7 @@ struct rte_eth_link {
uint16_t link_duplex : 1; /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */
uint16_t link_autoneg : 1; /**< RTE_ETH_LINK_[AUTONEG/FIXED] */
uint16_t link_status : 1; /**< RTE_ETH_LINK_[DOWN/UP] */
+ uint16_t link_type : 5; /**< RTE_ETH_LINK_TYPE_XXX */
};
};
};
@@ -3113,6 +3127,20 @@ int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link)
__rte_experimental
const char *rte_eth_link_speed_to_str(uint32_t link_speed);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * This function converts an Ethernet link type to a string.
+ *
+ * @param link_type
+ * The link type to convert.
+ * @return
+ * The string representation of the link type.
+ */
+__rte_experimental
+const char *rte_eth_link_type_to_str(uint8_t link_type);
+
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice.
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2 1/1] ethdev: add support to provide link type
2025-06-06 9:28 ` [PATCH v2 1/1] " skori
@ 2025-06-06 9:54 ` Morten Brørup
2025-06-06 15:23 ` Stephen Hemminger
0 siblings, 1 reply; 5+ messages in thread
From: Morten Brørup @ 2025-06-06 9:54 UTC (permalink / raw)
To: skori, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko
Cc: dev, Nithin Dabilpuram, jerinj
> From: skori@marvell.com [mailto:skori@marvell.com]
> Sent: Friday, 6 June 2025 11.28
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> Adding link type parameter to provide the type
> of port like twisted pair, fibre etc.
>
> Also added an API to convert the RTE_ETH_LINK_TYPE_XXX
> to a readable string.
>
> Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> ---
> +/**@{@name PORT type
> + * Ethernet port type
> + */
> +#define RTE_ETH_LINK_TYPE_NONE 0x00 /**< Not defined */
> +#define RTE_ETH_LINK_TYPE_TP 0x01 /**< Twisted Pair */
> +#define RTE_ETH_LINK_TYPE_AUI 0x02 /**< Attachment Unit Interface */
> +#define RTE_ETH_LINK_TYPE_MII 0x03 /**< Media Independent Interface
> */
> +#define RTE_ETH_LINK_TYPE_FIBRE 0x04 /**< Fibre */
> +#define RTE_ETH_LINK_TYPE_BNC 0x05 /**< BNC */
> +#define RTE_ETH_LINK_TYPE_DA 0x06 /**< Direct Attach copper */
> +#define RTE_ETH_LINK_TYPE_OTHER 0x1F /**< Other type */
> +/**@}*/
I don't see the use case for this patch, when only ancient interface types are defined.
How about RMII, GMII, RGMII, XGMII, XAUI, XAUI4, CAUI4, SFP, SFP+, SFP28, etc.
Please don't blindly port stuff from Linux to DPDK.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] ethdev: add support to provide link type
2025-06-06 9:54 ` Morten Brørup
@ 2025-06-06 15:23 ` Stephen Hemminger
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-06-06 15:23 UTC (permalink / raw)
To: Morten Brørup
Cc: skori, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, dev,
Nithin Dabilpuram, jerinj
On Fri, 6 Jun 2025 11:54:52 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:
> > From: skori@marvell.com [mailto:skori@marvell.com]
> > Sent: Friday, 6 June 2025 11.28
> >
> > From: Sunil Kumar Kori <skori@marvell.com>
> >
> > Adding link type parameter to provide the type
> > of port like twisted pair, fibre etc.
> >
> > Also added an API to convert the RTE_ETH_LINK_TYPE_XXX
> > to a readable string.
> >
> > Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> > ---
> > +/**@{@name PORT type
> > + * Ethernet port type
> > + */
> > +#define RTE_ETH_LINK_TYPE_NONE 0x00 /**< Not defined */
> > +#define RTE_ETH_LINK_TYPE_TP 0x01 /**< Twisted Pair */
> > +#define RTE_ETH_LINK_TYPE_AUI 0x02 /**< Attachment Unit Interface */
> > +#define RTE_ETH_LINK_TYPE_MII 0x03 /**< Media Independent Interface
> > */
> > +#define RTE_ETH_LINK_TYPE_FIBRE 0x04 /**< Fibre */
> > +#define RTE_ETH_LINK_TYPE_BNC 0x05 /**< BNC */
> > +#define RTE_ETH_LINK_TYPE_DA 0x06 /**< Direct Attach copper */
> > +#define RTE_ETH_LINK_TYPE_OTHER 0x1F /**< Other type */
> > +/**@}*/
>
> I don't see the use case for this patch, when only ancient interface types are defined.
> How about RMII, GMII, RGMII, XGMII, XAUI, XAUI4, CAUI4, SFP, SFP+, SFP28, etc.
>
> Please don't blindly port stuff from Linux to DPDK.
>
>
Agree with Morten here.
Plus, it isn't really much use to user unless all drivers report it.
Also, it breaks ABI (see build failures).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-06 15:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-05 11:31 [PATCH] ethdev: add support to provide link type skori
2025-06-05 15:26 ` Stephen Hemminger
2025-06-06 9:28 ` [PATCH v2 1/1] " skori
2025-06-06 9:54 ` Morten Brørup
2025-06-06 15:23 ` Stephen Hemminger
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).