Commit f9305949 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'ethtool-generate-uapi-header-from-the-spec'

Stanislav Fomichev says:

====================
ethtool: generate uapi header from the spec

We keep expanding ethtool netlink api surface and this leads to
constantly playing catchup on the ynl spec side. There are a couple
of things that prevent us from fully converting to generating
the header from the spec (stats and cable tests), but we can
generate 95% of the header which is still better than maintaining
c header and spec separately. The series adds a couple of missing
features on the ynl-gen-c side and separates the parts
that we can generate into new ethtool_netlink_generated.h.
====================

Link: https://patch.msgid.link/20241204155549.641348-1-sdf@fomichev.me


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 302cc446 8d0580c6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -106,6 +106,9 @@ properties:
        name-prefix:
          description: For enum the prefix of the values, optional.
          type: string
        enum-cnt-name:
          description: Name of the render-max counter enum entry.
          type: string
        # End genetlink-c

  attribute-sets:
+3 −0
Original line number Diff line number Diff line
@@ -117,6 +117,9 @@ properties:
        name-prefix:
          description: For enum the prefix of the values, optional.
          type: string
        enum-cnt-name:
          description: Name of the render-max counter enum entry.
          type: string
        # End genetlink-c
        # Start genetlink-legacy
        members:
+346 −12
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ name: ethtool
protocol: genetlink-legacy

doc: Partial family for Ethtool Netlink.
uapi-header: linux/ethtool_netlink_generated.h

definitions:
  -
@@ -12,43 +13,99 @@ definitions:
    enum-name:
    type: enum
    entries: [ vxlan, geneve, vxlan-gpe ]
    enum-cnt-name: __ethtool-udp-tunnel-type-cnt
    render-max: true
  -
    name: stringset
    type: enum
    entries: []
    header: linux/ethtool.h # skip rendering, no actual definition
  -
    name: header-flags
    type: flags
    entries: [ compact-bitsets, omit-reply, stats ]
    name-prefix: ethtool-flag-
    doc: common ethtool header flags
    entries:
      -
        name: compact-bitsets
        doc: use compact bitsets in reply
      -
        name: omit-reply
        doc: provide optional reply for SET or ACT requests
      -
        name: stats
        doc: request statistics, if supported by the driver
  -
    name: module-fw-flash-status
    type: enum
    entries: [ started, in_progress, completed, error ]
    doc: plug-in module firmware flashing status
    header: linux/ethtool.h
    entries:
      -
        name: started
        doc: The firmware flashing process has started.
      -
        name: in_progress
        doc: The firmware flashing process is in progress.
      -
        name: completed
        doc: The firmware flashing process was completed successfully.
      -
        name: error
        doc: The firmware flashing process was stopped due to an error.
  -
    name: c33-pse-ext-state
    enum-name:
    doc: "groups of PSE extended states functions. IEEE 802.3-2022 33.2.4.4 Variables"
    type: enum
    name-prefix: ethtool-c33-pse-ext-state-
    header: linux/ethtool.h
    entries:
        - none
        - error-condition
        - mr-mps-valid
        - mr-pse-enable
        - option-detect-ted
        - option-vport-lim
        - ovld-detected
        - power-not-available
        - short-detected
        -
          name: none
          doc: none
        -
          name: error-condition
          doc: Group of error_condition states
        -
          name: mr-mps-valid
          doc: Group of mr_mps_valid states
        -
          name: mr-pse-enable
          doc: Group of mr_pse_enable states
        -
          name: option-detect-ted
          doc: Group of option_detect_ted states
        -
          name: option-vport-lim
          doc: Group of option_vport_lim states
        -
          name: ovld-detected
          doc: Group of ovld_detected states
        -
          name: power-not-available
          doc: Group of power_not_available states
        -
          name: short-detected
          doc: Group of short_detected states
  -
    name: phy-upstream-type
    enum-name:
    type: enum
    entries: [ mac, phy ]
  -
    name: tcp-data-split
    type: enum
    entries: [ unknown, disabled, enabled ]

attribute-sets:
  -
    name: header
    attr-cnt-name: __ethtool-a-header-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: dev-index
        type: u32
@@ -65,7 +122,12 @@ attribute-sets:

  -
    name: bitset-bit
    attr-cnt-name: __ethtool-a-bitset-bit-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: index
        type: u32
@@ -77,7 +139,12 @@ attribute-sets:
        type: flag
  -
    name: bitset-bits
    attr-cnt-name: __ethtool-a-bitset-bits-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: bit
        type: nest
@@ -85,7 +152,12 @@ attribute-sets:
        nested-attributes: bitset-bit
  -
    name: bitset
    attr-cnt-name: __ethtool-a-bitset-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: nomask
        type: flag
@@ -104,7 +176,12 @@ attribute-sets:
        type: binary
  -
    name: string
    attr-cnt-name: __ethtool-a-string-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: index
        type: u32
@@ -113,7 +190,16 @@ attribute-sets:
        type: string
  -
    name: strings
    attr-cnt-name: __ethtool-a-strings-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: unspec
        type: unused
        value: 0
      -
        name: string
        type: nest
@@ -121,7 +207,12 @@ attribute-sets:
        nested-attributes: string
  -
    name: stringset
    attr-cnt-name: __ethtool-a-stringset-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: id
        type: u32
@@ -135,7 +226,12 @@ attribute-sets:
        nested-attributes: strings
  -
    name: stringsets
    attr-cnt-name: __ethtool-a-stringsets-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: stringset
        type: nest
@@ -143,7 +239,12 @@ attribute-sets:
        nested-attributes: stringset
  -
    name: strset
    attr-cnt-name: __ethtool-a-strset-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -158,7 +259,12 @@ attribute-sets:

  -
    name: privflags
    attr-cnt-name: __ethtool-a-privflags-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -170,7 +276,12 @@ attribute-sets:

  -
    name: rings
    attr-cnt-name: __ethtool-a-rings-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -205,6 +316,7 @@ attribute-sets:
      -
        name: tcp-data-split
        type: u8
        enum: tcp-data-split
      -
        name: cqe-size
        type: u32
@@ -223,31 +335,48 @@ attribute-sets:

  -
    name: mm-stat
    attr-cnt-name: __ethtool-a-mm-stat-cnt
    doc: MAC Merge (802.3)
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: pad
        type: pad
      -
        name: reassembly-errors
        doc: aMACMergeFrameAssErrorCount
        type: u64
      -
        name: smd-errors
        doc: aMACMergeFrameSmdErrorCount
        type: u64
      -
        name: reassembly-ok
        doc: aMACMergeFrameAssOkCount
        type: u64
      -
        name: rx-frag-count
        doc: aMACMergeFragCountRx
        type: u64
      -
        name: tx-frag-count
        doc: aMACMergeFragCountTx
        type: u64
      -
        name: hold-count
        doc: aMACMergeHoldCount
        type: u64
  -
    name: mm
    attr-cnt-name: __ethtool-a-mm-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -285,7 +414,12 @@ attribute-sets:
        nested-attributes: mm-stat
  -
    name: linkinfo
    attr-cnt-name: __ethtool-a-linkinfo-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -307,7 +441,12 @@ attribute-sets:
        type: u8
  -
    name: linkmodes
    attr-cnt-name: __ethtool-a-linkmodes-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -343,7 +482,12 @@ attribute-sets:
        type: u8
  -
    name: linkstate
    attr-cnt-name: __ethtool-a-linkstate-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -368,7 +512,12 @@ attribute-sets:
        type: u32
  -
    name: debug
    attr-cnt-name: __ethtool-a-debug-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -379,7 +528,12 @@ attribute-sets:
        nested-attributes: bitset
  -
    name: wol
    attr-cnt-name: __ethtool-a-wol-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -393,7 +547,12 @@ attribute-sets:
        type: binary
  -
    name: features
    attr-cnt-name: __ethtool-a-features-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -416,7 +575,12 @@ attribute-sets:
        nested-attributes: bitset
  -
    name: channels
    attr-cnt-name: __ethtool-a-channels-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -448,7 +612,12 @@ attribute-sets:

  -
    name: irq-moderation
    attr-cnt-name: __ethtool-a-irq-moderation-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: usec
        type: u32
@@ -460,7 +629,12 @@ attribute-sets:
        type: u32
  -
    name: profile
    attr-cnt-name: __ethtool-a-profile-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: irq-moderation
        type: nest
@@ -468,7 +642,12 @@ attribute-sets:
        nested-attributes: irq-moderation
  -
    name: coalesce
    attr-cnt-name: __ethtool-a-coalesce-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -565,7 +744,12 @@ attribute-sets:

  -
    name: pause-stat
    attr-cnt-name: __ethtool-a-pause-stat-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: pad
        type: pad
@@ -577,7 +761,12 @@ attribute-sets:
        type: u64
  -
    name: pause
    attr-cnt-name: __ethtool-a-pause-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -600,7 +789,12 @@ attribute-sets:
        type: u32
  -
    name: eee
    attr-cnt-name: __ethtool-a-eee-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -627,7 +821,12 @@ attribute-sets:
        type: u32
  -
    name: ts-stat
    attr-cnt-name: __ethtool-a-ts-stat-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: tx-pkts
        type: uint
@@ -639,7 +838,12 @@ attribute-sets:
        type: uint
  -
    name: tsinfo
    attr-cnt-name: __ethtool-a-tsinfo-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -665,19 +869,32 @@ attribute-sets:
        nested-attributes: ts-stat
  -
    name: cable-result
    attr-cnt-name: __ethtool-a-cable-result-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: pair
        doc: ETHTOOL_A_CABLE_PAIR
        type: u8
      -
        name: code
        doc: ETHTOOL_A_CABLE_RESULT_CODE
        type: u8
      -
        name: src
        doc: ETHTOOL_A_CABLE_INF_SRC
        type: u32
  -
    name: cable-fault-length
    attr-cnt-name: __ethtool-a-cable-fault-length-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: pair
        type: u8
@@ -689,7 +906,12 @@ attribute-sets:
        type: u32
  -
    name: cable-nest
    attr-cnt-name: __ethtool-a-cable-nest-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: result
        type: nest
@@ -700,20 +922,31 @@ attribute-sets:
        nested-attributes: cable-fault-length
  -
    name: cable-test
    attr-cnt-name: __ethtool-a-cable-test-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
        nested-attributes: header
  -
    name: cable-test-ntf
    attr-cnt-name: __ethtool-a-cable-test-ntf-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
        nested-attributes: header
      -
        name: status
        doc: _STARTED/_COMPLETE
        type: u8
      -
        name: nest
@@ -721,7 +954,12 @@ attribute-sets:
        nested-attributes: cable-nest
  -
    name: cable-test-tdr-cfg
    attr-cnt-name: __ethtool-a-cable-test-tdr-cfg-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: first
        type: u32
@@ -736,7 +974,12 @@ attribute-sets:
        type: u8
  -
    name: cable-test-tdr-ntf
    attr-cnt-name: __ethtool-a-cable-test-tdr-ntf-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -750,7 +993,12 @@ attribute-sets:
        nested-attributes: cable-nest
  -
    name: cable-test-tdr
    attr-cnt-name: __ethtool-a-cable-test-tdr-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -761,7 +1009,12 @@ attribute-sets:
        nested-attributes: cable-test-tdr-cfg
  -
    name: tunnel-udp-entry
    attr-cnt-name: __ethtool-a-tunnel-udp-entry-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: port
        type: u16
@@ -772,7 +1025,12 @@ attribute-sets:
        enum: udp-tunnel-type
  -
    name: tunnel-udp-table
    attr-cnt-name: __ethtool-a-tunnel-udp-table-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: size
        type: u32
@@ -787,14 +1045,24 @@ attribute-sets:
        nested-attributes: tunnel-udp-entry
  -
    name: tunnel-udp
    attr-cnt-name: __ethtool-a-tunnel-udp-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: table
        type: nest
        nested-attributes: tunnel-udp-table
  -
    name: tunnel-info
    attr-cnt-name: __ethtool-a-tunnel-info-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -805,7 +1073,12 @@ attribute-sets:
        nested-attributes: tunnel-udp
  -
    name: fec-stat
    attr-cnt-name: __ethtool-a-fec-stat-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: pad
        type: pad
@@ -823,7 +1096,12 @@ attribute-sets:
        sub-type: u64
  -
    name: fec
    attr-cnt-name: __ethtool-a-fec-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -844,7 +1122,12 @@ attribute-sets:
        nested-attributes: fec-stat
  -
    name: module-eeprom
    attr-cnt-name: __ethtool-a-module-eeprom-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -869,7 +1152,12 @@ attribute-sets:
        type: binary
  -
    name: stats-grp
    attr-cnt-name: __ethtool-a-stats-grp-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: pad
        type: pad
@@ -912,7 +1200,12 @@ attribute-sets:
        name: hist-val
  -
    name: stats
    attr-cnt-name: __ethtool-a-stats-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: pad
        type: pad
@@ -933,7 +1226,12 @@ attribute-sets:
        type: u32
  -
    name: phc-vclocks
    attr-cnt-name: __ethtool-a-phc-vclocks-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -947,7 +1245,12 @@ attribute-sets:
        sub-type: s32
  -
    name: module
    attr-cnt-name: __ethtool-a-module-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -960,7 +1263,13 @@ attribute-sets:
        type: u8
  -
    name: c33-pse-pw-limit
    attr-cnt-name: __ethtool-a-c33-pse-pw-limit-cnt
    attr-max-name: __ethtool-a-c33-pse-pw-limit-max
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: min
        type: u32
@@ -969,7 +1278,12 @@ attribute-sets:
        type: u32
  -
    name: pse
    attr-cnt-name: __ethtool-a-pse-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -1027,7 +1341,12 @@ attribute-sets:
        nested-attributes: c33-pse-pw-limit
  -
    name: rss
    attr-cnt-name: __ethtool-a-rss-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -1053,7 +1372,12 @@ attribute-sets:
        type: u32
  -
    name: plca
    attr-cnt-name: __ethtool-a-plca-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -1084,7 +1408,12 @@ attribute-sets:
        type: u32
  -
    name: module-fw-flash
    attr-cnt-name: __ethtool-a-module-fw-flash-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
@@ -1110,7 +1439,12 @@ attribute-sets:
        type: uint
  -
    name: phy
    attr-cnt-name: __ethtool-a-phy-cnt
    attributes:
      -
        name: unspec
        type: unused
        value: 0
      -
        name: header
        type: nest
+3 −1
Original line number Diff line number Diff line
@@ -56,7 +56,9 @@ If ``name-prefix`` is specified it replaces the ``$family-$enum``
portion of the entry name.

Boolean ``render-max`` controls creation of the max values
(which are enabled by default for attribute enums).
(which are enabled by default for attribute enums). These max
values are named ``__$pfx-MAX`` and ``$pfx-MAX``. The name
of the first value can be overridden via ``enum-cnt-name`` property.

Attributes
==========
+1 −1
Original line number Diff line number Diff line
@@ -16280,7 +16280,7 @@ F: include/linux/inetdevice.h
F:	include/linux/netdev*
F:	include/linux/platform_data/wiznet.h
F:	include/uapi/linux/cn_proc.h
F:	include/uapi/linux/ethtool_netlink.h
F:	include/uapi/linux/ethtool_netlink*
F:	include/uapi/linux/if_*
F:	include/uapi/linux/net_shaper.h
F:	include/uapi/linux/netdev*
Loading