DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] ethdev: sync ethtool link modes with Linux 6.15
@ 2025-06-25 13:42 Thomas Monjalon
  2025-06-26 14:26 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Monjalon @ 2025-06-25 13:42 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit, Andrew Rybchenko

Update ethtool link modes with new ones added in Linux 6.15.
These values won't change as they are part of the Linux uAPI.
Note: extracting them avoids to depend on a kernel version.

The parsing command is updated to generate padding
accordingly to the alignments in the DPDK source file.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/ethdev/ethdev_linux_ethtool.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/ethdev/ethdev_linux_ethtool.c b/lib/ethdev/ethdev_linux_ethtool.c
index ec42d3054a..f508cdba6c 100644
--- a/lib/ethdev/ethdev_linux_ethtool.c
+++ b/lib/ethdev/ethdev_linux_ethtool.c
@@ -17,8 +17,9 @@
  *
  * The array below is built from bit definitions with this shell command:
  *   sed -rn 's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;'\
- *           '[\4] = \2, /\* \1\2\3 *\/;p' /usr/include/linux/ethtool.h |
- *   awk '/_Half_/{$3=$3+1","}1'
+ *           '[\4] \2 \1\2\3;p' /usr/include/linux/ethtool.h |
+ *   awk '/_Half_/{$2=$2+1}1' |
+ *   awk '{printf "\t%5s = %7s, /\* %s *\/\n", $1, $2, $3}'
  */
 static const uint32_t link_modes[] = {
 	  [0] =      11, /* ETHTOOL_LINK_MODE_10baseT_Half_BIT */
@@ -110,6 +111,25 @@ static const uint32_t link_modes[] = {
 	 [99] =      10, /* ETHTOOL_LINK_MODE_10baseT1S_Full_BIT */
 	[100] =      11, /* ETHTOOL_LINK_MODE_10baseT1S_Half_BIT */
 	[101] =      11, /* ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT */
+	[102] =      10, /* ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT */
+	[103] =  200000, /* ETHTOOL_LINK_MODE_200000baseCR_Full_BIT */
+	[104] =  200000, /* ETHTOOL_LINK_MODE_200000baseKR_Full_BIT */
+	[105] =  200000, /* ETHTOOL_LINK_MODE_200000baseDR_Full_BIT */
+	[106] =  200000, /* ETHTOOL_LINK_MODE_200000baseDR_2_Full_BIT */
+	[107] =  200000, /* ETHTOOL_LINK_MODE_200000baseSR_Full_BIT */
+	[108] =  200000, /* ETHTOOL_LINK_MODE_200000baseVR_Full_BIT */
+	[109] =  400000, /* ETHTOOL_LINK_MODE_400000baseCR2_Full_BIT */
+	[110] =  400000, /* ETHTOOL_LINK_MODE_400000baseKR2_Full_BIT */
+	[111] =  400000, /* ETHTOOL_LINK_MODE_400000baseDR2_Full_BIT */
+	[112] =  400000, /* ETHTOOL_LINK_MODE_400000baseDR2_2_Full_BIT */
+	[113] =  400000, /* ETHTOOL_LINK_MODE_400000baseSR2_Full_BIT */
+	[114] =  400000, /* ETHTOOL_LINK_MODE_400000baseVR2_Full_BIT */
+	[115] =  800000, /* ETHTOOL_LINK_MODE_800000baseCR4_Full_BIT */
+	[116] =  800000, /* ETHTOOL_LINK_MODE_800000baseKR4_Full_BIT */
+	[117] =  800000, /* ETHTOOL_LINK_MODE_800000baseDR4_Full_BIT */
+	[118] =  800000, /* ETHTOOL_LINK_MODE_800000baseDR4_2_Full_BIT */
+	[119] =  800000, /* ETHTOOL_LINK_MODE_800000baseSR4_Full_BIT */
+	[120] =  800000, /* ETHTOOL_LINK_MODE_800000baseVR4_Full_BIT */
 };
 
 RTE_EXPORT_INTERNAL_SYMBOL(rte_eth_link_speed_ethtool)
-- 
2.47.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ethdev: sync ethtool link modes with Linux 6.15
  2025-06-25 13:42 [PATCH] ethdev: sync ethtool link modes with Linux 6.15 Thomas Monjalon
@ 2025-06-26 14:26 ` Stephen Hemminger
  2025-06-26 15:13   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2025-06-26 14:26 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Ferruh Yigit, Andrew Rybchenko

On Wed, 25 Jun 2025 15:42:02 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> diff --git a/lib/ethdev/ethdev_linux_ethtool.c b/lib/ethdev/ethdev_linux_ethtool.c
> index ec42d3054a..f508cdba6c 100644
> --- a/lib/ethdev/ethdev_linux_ethtool.c
> +++ b/lib/ethdev/ethdev_linux_ethtool.c
> @@ -17,8 +17,9 @@
>   *
>   * The array below is built from bit definitions with this shell command:
>   *   sed -rn 's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;'\
> - *           '[\4] = \2, /\* \1\2\3 *\/;p' /usr/include/linux/ethtool.h |
> - *   awk '/_Half_/{$3=$3+1","}1'
> + *           '[\4] \2 \1\2\3;p' /usr/include/linux/ethtool.h |
> + *   awk '/_Half_/{$2=$2+1}1' |
> + *   awk '{printf "\t%5s = %7s, /\* %s *\/\n", $1, $2, $3}'
>   */

The commands in the comment never worked verbatim.

$  sed -rn 's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;'\
           '[\4] \2 \1\2\3;p' /usr/include/linux/ethtool.h |
   awk '/_Half_/{$2=$2+1}1' |
   awk '{printf "\t%5s = %7s, /\* %s *\/\n", $1, $2, $3}'

> > > sed: -e expression #1, char 63: unterminated `s' command
awk: cmd. line:1: warning: escape sequence `\*' treated as plain `*'
awk: cmd. line:1: warning: escape sequence `\/' treated as plain `/'

Fixing the comment would be:
$ git diff
diff --git a/lib/ethdev/ethdev_linux_ethtool.c b/lib/ethdev/ethdev_linux_ethtool.c
index f508cdba6c..8a148ae0cd 100644
--- a/lib/ethdev/ethdev_linux_ethtool.c
+++ b/lib/ethdev/ethdev_linux_ethtool.c
@@ -16,10 +16,11 @@
  * and allows to compile with new bits included even on an old kernel.
  *
  * The array below is built from bit definitions with this shell command:
- *   sed -rn 's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;'\
- *           '[\4] \2 \1\2\3;p' /usr/include/linux/ethtool.h |
- *   awk '/_Half_/{$2=$2+1}1' |
- *   awk '{printf "\t%5s = %7s, /\* %s *\/\n", $1, $2, $3}'
+ * sed -rn \
+ *   's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;[\4] \2 \1\2\3;p' \
+ *   /usr/include/linux/ethtool.h | \
+ * awk '/_Half_/{$2=$2+1}1' | \
+ * awk '{printf "\t%5s = %7s, /* %s */\n", $1, $2, $3}'
  */
 static const uint32_t link_modes[] = {
          [0] =      11, /* ETHTOOL_LINK_MODE_10baseT_Half_BIT */



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ethdev: sync ethtool link modes with Linux 6.15
  2025-06-26 14:26 ` Stephen Hemminger
@ 2025-06-26 15:13   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2025-06-26 15:13 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Ferruh Yigit, Andrew Rybchenko

26/06/2025 16:26, Stephen Hemminger:
> On Wed, 25 Jun 2025 15:42:02 +0200
> Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > diff --git a/lib/ethdev/ethdev_linux_ethtool.c b/lib/ethdev/ethdev_linux_ethtool.c
> > index ec42d3054a..f508cdba6c 100644
> > --- a/lib/ethdev/ethdev_linux_ethtool.c
> > +++ b/lib/ethdev/ethdev_linux_ethtool.c
> > @@ -17,8 +17,9 @@
> >   *
> >   * The array below is built from bit definitions with this shell command:
> >   *   sed -rn 's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;'\
> > - *           '[\4] = \2, /\* \1\2\3 *\/;p' /usr/include/linux/ethtool.h |
> > - *   awk '/_Half_/{$3=$3+1","}1'
> > + *           '[\4] \2 \1\2\3;p' /usr/include/linux/ethtool.h |
> > + *   awk '/_Half_/{$2=$2+1}1' |
> > + *   awk '{printf "\t%5s = %7s, /\* %s *\/\n", $1, $2, $3}'
> >   */
> 
> The commands in the comment never worked verbatim.

It works on my machine.

> $  sed -rn 's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;'\
>            '[\4] \2 \1\2\3;p' /usr/include/linux/ethtool.h |
>    awk '/_Half_/{$2=$2+1}1' |
>    awk '{printf "\t%5s = %7s, /\* %s *\/\n", $1, $2, $3}'
> 
> > > > sed: -e expression #1, char 63: unterminated `s' command
> awk: cmd. line:1: warning: escape sequence `\*' treated as plain `*'
> awk: cmd. line:1: warning: escape sequence `\/' treated as plain `/'

The backslashes were added to help the syntax highlighting.
But I can remove them.


> Fixing the comment would be:
> $ git diff
> diff --git a/lib/ethdev/ethdev_linux_ethtool.c b/lib/ethdev/ethdev_linux_ethtool.c
> index f508cdba6c..8a148ae0cd 100644
> --- a/lib/ethdev/ethdev_linux_ethtool.c
> +++ b/lib/ethdev/ethdev_linux_ethtool.c
> @@ -16,10 +16,11 @@
>   * and allows to compile with new bits included even on an old kernel.
>   *
>   * The array below is built from bit definitions with this shell command:
> - *   sed -rn 's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;'\
> - *           '[\4] \2 \1\2\3;p' /usr/include/linux/ethtool.h |
> - *   awk '/_Half_/{$2=$2+1}1' |
> - *   awk '{printf "\t%5s = %7s, /\* %s *\/\n", $1, $2, $3}'
> + * sed -rn \
> + *   's;.*(ETHTOOL_LINK_MODE_)([0-9]+)([0-9a-zA-Z_]*).*= *([0-9]*).*;[\4] \2 \1\2\3;p' \
> + *   /usr/include/linux/ethtool.h | \
> + * awk '/_Half_/{$2=$2+1}1' | \
> + * awk '{printf "\t%5s = %7s, /* %s */\n", $1, $2, $3}'




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-26 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-25 13:42 [PATCH] ethdev: sync ethtool link modes with Linux 6.15 Thomas Monjalon
2025-06-26 14:26 ` Stephen Hemminger
2025-06-26 15:13   ` Thomas Monjalon

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).