Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: ethtool: Add PSE port priority support feature

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>

authored by

Kory Maincent (Dent Project) and committed by
Jakub Kicinski
eeb0c8f7 ffef61d6

+57
+11
Documentation/netlink/specs/ethtool.yaml
··· 1436 1436 name: pse-pw-d-id 1437 1437 type: u32 1438 1438 name-prefix: ethtool-a- 1439 + - 1440 + name: pse-prio-max 1441 + type: u32 1442 + name-prefix: ethtool-a- 1443 + - 1444 + name: pse-prio 1445 + type: u32 1446 + name-prefix: ethtool-a- 1439 1447 - 1440 1448 name: rss 1441 1449 attr-cnt-name: __ethtool-a-rss-cnt ··· 2268 2260 - c33-pse-avail-pw-limit 2269 2261 - c33-pse-pw-limit-ranges 2270 2262 - pse-pw-d-id 2263 + - pse-prio-max 2264 + - pse-prio 2271 2265 dump: *pse-get-op 2272 2266 - 2273 2267 name: pse-set ··· 2284 2274 - podl-pse-admin-control 2285 2275 - c33-pse-admin-control 2286 2276 - c33-pse-avail-pw-limit 2277 + - pse-prio 2287 2278 - 2288 2279 name: rss-get 2289 2280 doc: Get RSS params.
+26
Documentation/networking/ethtool-netlink.rst
··· 1790 1790 ``ETHTOOL_A_C33_PSE_PW_LIMIT_RANGES`` nested Supported power limit 1791 1791 configuration ranges. 1792 1792 ``ETHTOOL_A_PSE_PW_D_ID`` u32 Index of the PSE power domain 1793 + ``ETHTOOL_A_PSE_PRIO_MAX`` u32 Priority maximum configurable 1794 + on the PoE PSE 1795 + ``ETHTOOL_A_PSE_PRIO`` u32 Priority of the PoE PSE 1796 + currently configured 1793 1797 ========================================== ====== ============================= 1794 1798 1795 1799 When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_STATE`` attribute identifies ··· 1870 1866 The ``ETHTOOL_A_PSE_PW_D_ID`` attribute identifies the index of PSE power 1871 1867 domain. 1872 1868 1869 + When set, the optional ``ETHTOOL_A_PSE_PRIO_MAX`` attribute identifies 1870 + the PSE maximum priority value. 1871 + When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to 1872 + identifies the currently configured PSE priority. 1873 + For a description of PSE priority attributes, see ``PSE_SET``. 1874 + 1873 1875 PSE_SET 1874 1876 ======= 1875 1877 ··· 1889 1879 ``ETHTOOL_A_C33_PSE_ADMIN_CONTROL`` u32 Control PSE Admin state 1890 1880 ``ETHTOOL_A_C33_PSE_AVAIL_PWR_LIMIT`` u32 Control PoE PSE available 1891 1881 power limit 1882 + ``ETHTOOL_A_PSE_PRIO`` u32 Control priority of the 1883 + PoE PSE 1892 1884 ====================================== ====== ============================= 1893 1885 1894 1886 When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_CONTROL`` attribute is used ··· 1912 1900 various existing products that document power consumption in watts rather than 1913 1901 classes. If power limit configuration based on classes is needed, the 1914 1902 conversion can be done in user space, for example by ethtool. 1903 + 1904 + When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to 1905 + control the PSE priority. Allowed priority value are between zero and 1906 + the value of ``ETHTOOL_A_PSE_PRIO_MAX`` attribute. 1907 + 1908 + A lower value indicates a higher priority, meaning that a priority value 1909 + of 0 corresponds to the highest port priority. 1910 + Port priority serves two functions: 1911 + 1912 + - Power-up Order: After a reset, ports are powered up in order of their 1913 + priority from highest to lowest. Ports with higher priority 1914 + (lower values) power up first. 1915 + - Shutdown Order: When the power budget is exceeded, ports with lower 1916 + priority (higher values) are turned off first. 1915 1917 1916 1918 PSE_NTF 1917 1919 =======
+18
net/ethtool/pse-pd.c
··· 111 111 len += st->c33_pw_limit_nb_ranges * 112 112 (nla_total_size(0) + 113 113 nla_total_size(sizeof(u32)) * 2); 114 + if (st->prio_max) 115 + /* _PSE_PRIO_MAX + _PSE_PRIO */ 116 + len += nla_total_size(sizeof(u32)) * 2; 114 117 115 118 return len; 116 119 } ··· 208 205 pse_put_pw_limit_ranges(skb, st)) 209 206 return -EMSGSIZE; 210 207 208 + if (st->prio_max && 209 + (nla_put_u32(skb, ETHTOOL_A_PSE_PRIO_MAX, st->prio_max) || 210 + nla_put_u32(skb, ETHTOOL_A_PSE_PRIO, st->prio))) 211 + return -EMSGSIZE; 212 + 211 213 return 0; 212 214 } 213 215 ··· 234 226 NLA_POLICY_RANGE(NLA_U32, ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED, 235 227 ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED), 236 228 [ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT] = { .type = NLA_U32 }, 229 + [ETHTOOL_A_PSE_PRIO] = { .type = NLA_U32 }, 237 230 }; 238 231 239 232 static int ··· 282 273 ret = ethnl_set_pse_validate(phydev, info); 283 274 if (ret) 284 275 return ret; 276 + 277 + if (tb[ETHTOOL_A_PSE_PRIO]) { 278 + unsigned int prio; 279 + 280 + prio = nla_get_u32(tb[ETHTOOL_A_PSE_PRIO]); 281 + ret = pse_ethtool_set_prio(phydev->psec, info->extack, prio); 282 + if (ret) 283 + return ret; 284 + } 285 285 286 286 if (tb[ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT]) { 287 287 unsigned int pw_limit;