]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ethtool: Add PSE port priority support feature
authorKory Maincent (Dent Project) <kory.maincent@bootlin.com>
Tue, 17 Jun 2025 12:12:07 +0000 (14:12 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 19 Jun 2025 02:00:17 +0000 (19:00 -0700)
This patch expands the status information provided by ethtool for PSE c33
with current port priority and max port priority. It also adds a call to
pse_ethtool_set_prio() to configure the PSE port priority.

Signed-off-by: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-8-78a1a645e2ee@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/netlink/specs/ethtool.yaml
Documentation/networking/ethtool-netlink.rst
include/uapi/linux/ethtool_netlink_generated.h
net/ethtool/pse-pd.c

index 7a9a857370e2c61db4f8c4810a67439153f02525..e6a77e8053a043b18b908c3f041a74184daffb1c 100644 (file)
@@ -1436,6 +1436,14 @@ attribute-sets:
         name: pse-pw-d-id
         type: u32
         name-prefix: ethtool-a-
+      -
+        name: pse-prio-max
+        type: u32
+        name-prefix: ethtool-a-
+      -
+        name: pse-prio
+        type: u32
+        name-prefix: ethtool-a-
   -
     name: rss
     attr-cnt-name: __ethtool-a-rss-cnt
@@ -2260,6 +2268,8 @@ operations:
             - c33-pse-avail-pw-limit
             - c33-pse-pw-limit-ranges
             - pse-pw-d-id
+            - pse-prio-max
+            - pse-prio
       dump: *pse-get-op
     -
       name: pse-set
@@ -2274,6 +2284,7 @@ operations:
             - podl-pse-admin-control
             - c33-pse-admin-control
             - c33-pse-avail-pw-limit
+            - pse-prio
     -
       name: rss-get
       doc: Get RSS params.
index e9af8e58564cfab17182a95f13b3898c368ab28d..e45bb555e909002f157ae3060669435db7df97d5 100644 (file)
@@ -1790,6 +1790,10 @@ Kernel response contents:
   ``ETHTOOL_A_C33_PSE_PW_LIMIT_RANGES``       nested  Supported power limit
                                                       configuration ranges.
   ``ETHTOOL_A_PSE_PW_D_ID``                      u32  Index of the PSE power domain
+  ``ETHTOOL_A_PSE_PRIO_MAX``                     u32  Priority maximum configurable
+                                                      on the PoE PSE
+  ``ETHTOOL_A_PSE_PRIO``                         u32  Priority of the PoE PSE
+                                                      currently configured
   ==========================================  ======  =============================
 
 When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_STATE`` attribute identifies
@@ -1866,6 +1870,12 @@ equal.
 The ``ETHTOOL_A_PSE_PW_D_ID`` attribute identifies the index of PSE power
 domain.
 
+When set, the optional ``ETHTOOL_A_PSE_PRIO_MAX`` attribute identifies
+the PSE maximum priority value.
+When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to
+identifies the currently configured PSE priority.
+For a description of PSE priority attributes, see ``PSE_SET``.
+
 PSE_SET
 =======
 
@@ -1879,6 +1889,8 @@ Request contents:
   ``ETHTOOL_A_C33_PSE_ADMIN_CONTROL``        u32  Control PSE Admin state
   ``ETHTOOL_A_C33_PSE_AVAIL_PWR_LIMIT``      u32  Control PoE PSE available
                                                   power limit
+  ``ETHTOOL_A_PSE_PRIO``                     u32  Control priority of the
+                                                  PoE PSE
   ======================================  ======  =============================
 
 When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_CONTROL`` attribute is used
@@ -1901,6 +1913,20 @@ various existing products that document power consumption in watts rather than
 classes. If power limit configuration based on classes is needed, the
 conversion can be done in user space, for example by ethtool.
 
+When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to
+control the PSE priority. Allowed priority value are between zero and
+the value of ``ETHTOOL_A_PSE_PRIO_MAX`` attribute.
+
+A lower value indicates a higher priority, meaning that a priority value
+of 0 corresponds to the highest port priority.
+Port priority serves two functions:
+
+ - Power-up Order: After a reset, ports are powered up in order of their
+   priority from highest to lowest. Ports with higher priority
+   (lower values) power up first.
+ - Shutdown Order: When the power budget is exceeded, ports with lower
+   priority (higher values) are turned off first.
+
 PSE_NTF
 =======
 
index c6a95224be25def075ec54e93deb1eee04f3875a..8e5d067e7ddf005b4055ff5b8fe443ba38a6c662 100644 (file)
@@ -671,6 +671,8 @@ enum {
        ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT,
        ETHTOOL_A_C33_PSE_PW_LIMIT_RANGES,
        ETHTOOL_A_PSE_PW_D_ID,
+       ETHTOOL_A_PSE_PRIO_MAX,
+       ETHTOOL_A_PSE_PRIO,
 
        __ETHTOOL_A_PSE_CNT,
        ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
index 6a978a55959ef2a9a8ffdcfedd637c925c132fe0..6c536dfe52dacc0717195d9058e1982ae49244ae 100644 (file)
@@ -111,6 +111,9 @@ static int pse_reply_size(const struct ethnl_req_info *req_base,
                len += st->c33_pw_limit_nb_ranges *
                       (nla_total_size(0) +
                        nla_total_size(sizeof(u32)) * 2);
+       if (st->prio_max)
+               /* _PSE_PRIO_MAX + _PSE_PRIO */
+               len += nla_total_size(sizeof(u32)) * 2;
 
        return len;
 }
@@ -205,6 +208,11 @@ static int pse_fill_reply(struct sk_buff *skb,
            pse_put_pw_limit_ranges(skb, st))
                return -EMSGSIZE;
 
+       if (st->prio_max &&
+           (nla_put_u32(skb, ETHTOOL_A_PSE_PRIO_MAX, st->prio_max) ||
+            nla_put_u32(skb, ETHTOOL_A_PSE_PRIO, st->prio)))
+               return -EMSGSIZE;
+
        return 0;
 }
 
@@ -226,6 +234,7 @@ const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1] = {
                NLA_POLICY_RANGE(NLA_U32, ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED,
                                 ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED),
        [ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT] = { .type = NLA_U32 },
+       [ETHTOOL_A_PSE_PRIO] = { .type = NLA_U32 },
 };
 
 static int
@@ -274,6 +283,15 @@ ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info)
        if (ret)
                return ret;
 
+       if (tb[ETHTOOL_A_PSE_PRIO]) {
+               unsigned int prio;
+
+               prio = nla_get_u32(tb[ETHTOOL_A_PSE_PRIO]);
+               ret = pse_ethtool_set_prio(phydev->psec, info->extack, prio);
+               if (ret)
+                       return ret;
+       }
+
        if (tb[ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT]) {
                unsigned int pw_limit;