From nobody Thu Sep 18 17:14:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAC5EC47089 for ; Sun, 4 Dec 2022 02:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbiLDCig (ORCPT ); Sat, 3 Dec 2022 21:38:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiLDCie (ORCPT ); Sat, 3 Dec 2022 21:38:34 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DD23193D1; Sat, 3 Dec 2022 18:38:32 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id m19so11299525edj.8; Sat, 03 Dec 2022 18:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=3Q/V2M1Y83UrJip400E0rrEKMewxiVB8B57hvdgogEI=; b=X/8kG5lI9NYV3DmrfDKxDFqioSPtUN5vvZj9ivjkNORJTuF2mQv5UdA12iLwtIjghD 9j3kkbtve7pHGcApsx/KBFTghlW0Ux0Xgy3Xgq/PEKg3O53/wxz9KbJ7xzjRjIYMdcMv 3WxbfkzsrcktgbeC/My+O0vt5ZDI5v4778bGC+OpuwmPDGfhUjCXf0qlOzsGuiLRgYKX fD9RX6BjMoSyIJ8TSbyhWSMRSdHNSp7Nq5blQq1PW94SO7Gw0S/oNajV8iTbG6CkSuin ZJWRnecTGU/8upfrTqxRAwuJ2r0qgIF3yk8Zol0WoVCeXXJGiC3hZ+Cdpdfyr0uGNMx3 G7pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3Q/V2M1Y83UrJip400E0rrEKMewxiVB8B57hvdgogEI=; b=0wmeE9hr0YX51ii4shfuBYFNFMp2aCrcyp8aJMUpO020b5G5mA2paSRf328UtN9ysU EejnuqEhP/MYxP68ZQHMfmNfH8lej6fcp01o4Y8LNYKxxjnXssOg4Ak01nxX8TE2O3mR 2+eR9P74jHPqRWTkPqqWr68Z/CjJO1h3FmZJgRvWYxrbIglmGN5vOHSShGER4ZMt2qD7 osiqEYxF7PGNwdi0CsCMANKMt8q+Pql9RCGb7Or2AUse/tzCuYIeE2AhQXqAdl16bcJc 05haxUxqR68uFP0G13+OQoNpoSPk5s/v+zeHgcsh+/bz93k3I1qws1jnaie2B1nqY93f 1lAQ== X-Gm-Message-State: ANoB5pk27LSW5NKkyWdRy3BHOxz1FjSi3h6Hf60mtZWRHk8HGTt/BGDO MnkdUGzvW5nA5kMSckUx5H0= X-Google-Smtp-Source: AA0mqf7qs+jqyckibrJDDXWahSzBrk2of7lGISyFHc2aQ5mg/FPK0pWFj4Dp3wA/ASXWZYPZvv33FQ== X-Received: by 2002:a05:6402:5305:b0:467:69e3:c25b with SMTP id eo5-20020a056402530500b0046769e3c25bmr68258865edb.3.1670121510371; Sat, 03 Dec 2022 18:38:30 -0800 (PST) Received: from gvm01 (net-2-45-26-236.cust.vodafonedsl.it. [2.45.26.236]) by smtp.gmail.com with ESMTPSA id kx4-20020a170907774400b0079e11b8e891sm4705115ejc.125.2022.12.03.18.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 18:38:30 -0800 (PST) Date: Sun, 4 Dec 2022 03:38:37 +0100 From: Piergiorgio Beruto To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: [PATCH net-next 1/2] ethtool: update UAPI files Message-ID: <0f7042bc6bcd59b37969d10a40e65d705940bee0.1670121214.git.piergiorgio.beruto@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Piergiorgio Beruto --- uapi/linux/ethtool.h | 104 +++++++++++++++++++++++++++++------ uapi/linux/ethtool_netlink.h | 49 ++++++++++++++++- uapi/linux/genetlink.h | 6 +- uapi/linux/if_link.h | 23 +++++++- uapi/linux/netlink.h | 41 ++++++++++---- uapi/linux/rtnetlink.h | 8 ++- 6 files changed, 192 insertions(+), 39 deletions(-) diff --git a/uapi/linux/ethtool.h b/uapi/linux/ethtool.h index 944711cfa6f6..5f414deacf23 100644 --- a/uapi/linux/ethtool.h +++ b/uapi/linux/ethtool.h @@ -11,14 +11,16 @@ * Portions Copyright (C) Sun Microsystems 2008 */ =20 -#ifndef _LINUX_ETHTOOL_H -#define _LINUX_ETHTOOL_H +#ifndef _UAPI_LINUX_ETHTOOL_H +#define _UAPI_LINUX_ETHTOOL_H =20 #include #include #include =20 +#ifndef __KERNEL__ #include /* for INT_MAX */ +#endif =20 /* All structures exposed to userland should be defined such that they * have the same layout for 32-bit and 64-bit userland. @@ -120,14 +122,14 @@ struct ethtool_cmd { __u32 reserved[2]; }; =20 -static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep, +static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, __u32 speed) { ep->speed =3D (__u16)(speed & 0xFFFF); ep->speed_hi =3D (__u16)(speed >> 16); } =20 -static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) +static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) { return (ep->speed_hi << 16) | ep->speed; } @@ -157,8 +159,10 @@ static __inline__ __u32 ethtool_cmd_speed(const struct= ethtool_cmd *ep) * in its bus driver structure (e.g. pci_driver::name). Must * not be an empty string. * @version: Driver version string; may be an empty string - * @fw_version: Firmware version string; may be an empty string - * @erom_version: Expansion ROM version string; may be an empty string + * @fw_version: Firmware version string; driver defined; may be an + * empty string + * @erom_version: Expansion ROM version string; driver defined; may be + * an empty string * @bus_info: Device bus address. This should match the dev_name() * string for the underlying bus device, if there is one. May be * an empty string. @@ -177,10 +181,6 @@ static __inline__ __u32 ethtool_cmd_speed(const struct= ethtool_cmd *ep) * * Users can use the %ETHTOOL_GSSET_INFO command to get the number of * strings in any string set (from Linux 2.6.34). - * - * Drivers should set at most @driver, @version, @fw_version and - * @bus_info in their get_drvinfo() implementation. The ethtool - * core fills in the other fields using other driver operations. */ struct ethtool_drvinfo { __u32 cmd; @@ -734,6 +734,51 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; =20 +/** + * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE + * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState + * @ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN: state of PoDL PSE functions are + * unknown + * @ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED: PoDL PSE functions are disabled + * @ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED: PoDL PSE functions are enabled + */ +enum ethtool_podl_pse_admin_state { + ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN =3D 1, + ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED, + ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED, +}; + +/** + * enum ethtool_podl_pse_pw_d_status - power detection status of the PoDL = PSE. + * IEEE 802.3-2018 30.15.1.1.3 aPoDLPSEPowerDetectionStatus: + * @ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN: PoDL PSE + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED: "The enumeration =E2=80=9Cdisab= led=E2=80=9D is + * asserted true when the PoDL PSE state diagram variable mr_pse_enable is + * false" + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING: "The enumeration =E2=80=9Csear= ching=E2=80=9D is + * asserted true when either of the PSE state diagram variables + * pi_detecting or pi_classifying is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING: "The enumeration =E2=80=9Cdel= iveringPower=E2=80=9D + * is asserted true when the PoDL PSE state diagram variable pi_powered is + * true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP: "The enumeration =E2=80=9Csleep=E2= =80=9D is asserted + * true when the PoDL PSE state diagram variable pi_sleeping is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE: "The enumeration =E2=80=9Cidle=E2= =80=9D is asserted true + * when the logical combination of the PoDL PSE state diagram variables + * pi_prebiased*!pi_sleeping is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR: "The enumeration =E2=80=9Cerror=E2= =80=9D is asserted + * true when the PoDL PSE state diagram variable overload_held is true." + */ +enum ethtool_podl_pse_pw_d_status { + ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN =3D 1, + ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED, + ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING, + ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING, + ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP, + ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE, + ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR, +}; + /** * struct ethtool_gstrings - string set for data tagging * @cmd: Command number =3D %ETHTOOL_GSTRINGS @@ -1057,12 +1102,12 @@ struct ethtool_rx_flow_spec { #define ETHTOOL_RX_FLOW_SPEC_RING 0x00000000FFFFFFFFLL #define ETHTOOL_RX_FLOW_SPEC_RING_VF 0x000000FF00000000LL #define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32 -static __inline__ __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie) +static inline __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie) { return ETHTOOL_RX_FLOW_SPEC_RING & ring_cookie; } =20 -static __inline__ __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie) +static inline __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie) { return (ETHTOOL_RX_FLOW_SPEC_RING_VF & ring_cookie) >> ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF; @@ -1690,6 +1735,16 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_100baseFX_Half_BIT =3D 90, ETHTOOL_LINK_MODE_100baseFX_Full_BIT =3D 91, ETHTOOL_LINK_MODE_10baseT1L_Full_BIT =3D 92, + ETHTOOL_LINK_MODE_800000baseCR8_Full_BIT =3D 93, + ETHTOOL_LINK_MODE_800000baseKR8_Full_BIT =3D 94, + ETHTOOL_LINK_MODE_800000baseDR8_Full_BIT =3D 95, + ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT =3D 96, + ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT =3D 97, + ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT =3D 98, + ETHTOOL_LINK_MODE_10baseT1S_Full_BIT =3D 99, + ETHTOOL_LINK_MODE_10baseT1S_Half_BIT =3D 100, + ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT =3D 101, + /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS }; @@ -1801,10 +1856,11 @@ enum ethtool_link_mode_bit_indices { #define SPEED_100000 100000 #define SPEED_200000 200000 #define SPEED_400000 400000 +#define SPEED_800000 800000 =20 #define SPEED_UNKNOWN -1 =20 -static __inline__ int ethtool_validate_speed(__u32 speed) +static inline int ethtool_validate_speed(__u32 speed) { return speed <=3D INT_MAX || speed =3D=3D (__u32)SPEED_UNKNOWN; } @@ -1814,7 +1870,7 @@ static __inline__ int ethtool_validate_speed(__u32 sp= eed) #define DUPLEX_FULL 0x01 #define DUPLEX_UNKNOWN 0xff =20 -static __inline__ int ethtool_validate_duplex(__u8 duplex) +static inline int ethtool_validate_duplex(__u8 duplex) { switch (duplex) { case DUPLEX_HALF: @@ -1838,6 +1894,20 @@ static __inline__ int ethtool_validate_duplex(__u8 d= uplex) #define MASTER_SLAVE_STATE_SLAVE 3 #define MASTER_SLAVE_STATE_ERR 4 =20 +/* These are used to throttle the rate of data on the phy interface when t= he + * native speed of the interface is higher than the link speed. These shou= ld + * not be used for phy interfaces which natively support multiple speeds (= e.g. + * MII or SGMII). + */ +/* No rate matching performed. */ +#define RATE_MATCH_NONE 0 +/* The phy sends pause frames to throttle the MAC. */ +#define RATE_MATCH_PAUSE 1 +/* The phy asserts CRS to prevent the MAC from transmitting. */ +#define RATE_MATCH_CRS 2 +/* The MAC is programmed with a sufficiently-large IPG. */ +#define RATE_MATCH_OPEN_LOOP 3 + /* Which connector port. */ #define PORT_TP 0x00 #define PORT_AUI 0x01 @@ -2031,8 +2101,8 @@ enum ethtool_reset_flags { * reported consistently by PHYLIB. Read-only. * @master_slave_cfg: Master/slave port mode. * @master_slave_state: Master/slave port state. + * @rate_matching: Rate adaptation performed by the PHY * @reserved: Reserved for future use; see the note on reserved space. - * @reserved1: Reserved for future use; see the note on reserved space. * @link_mode_masks: Variable length bitmaps. * * If autonegotiation is disabled, the speed and @duplex represent the @@ -2083,7 +2153,7 @@ struct ethtool_link_settings { __u8 transceiver; __u8 master_slave_cfg; __u8 master_slave_state; - __u8 reserved1[1]; + __u8 rate_matching; __u32 reserved[7]; __u32 link_mode_masks[]; /* layout of link_mode_masks fields: @@ -2092,4 +2162,4 @@ struct ethtool_link_settings { * __u32 map_lp_advertising[link_mode_masks_nwords]; */ }; -#endif /* _LINUX_ETHTOOL_H */ +#endif /* _UAPI_LINUX_ETHTOOL_H */ diff --git a/uapi/linux/ethtool_netlink.h b/uapi/linux/ethtool_netlink.h index 378ad7da74f4..81e3d7b42d0f 100644 --- a/uapi/linux/ethtool_netlink.h +++ b/uapi/linux/ethtool_netlink.h @@ -6,8 +6,8 @@ * doucumentation of the interface. */ =20 -#ifndef _LINUX_ETHTOOL_NETLINK_H_ -#define _LINUX_ETHTOOL_NETLINK_H_ +#ifndef _UAPI_LINUX_ETHTOOL_NETLINK_H_ +#define _UAPI_LINUX_ETHTOOL_NETLINK_H_ =20 #include =20 @@ -49,6 +49,11 @@ enum { ETHTOOL_MSG_PHC_VCLOCKS_GET, ETHTOOL_MSG_MODULE_GET, ETHTOOL_MSG_MODULE_SET, + ETHTOOL_MSG_PSE_GET, + ETHTOOL_MSG_PSE_SET, + ETHTOOL_MSG_PLCA_GET_CFG, + ETHTOOL_MSG_PLCA_SET_CFG, + ETHTOOL_MSG_PLCA_GET_STATUS, =20 /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -94,6 +99,10 @@ enum { ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY, ETHTOOL_MSG_MODULE_GET_REPLY, ETHTOOL_MSG_MODULE_NTF, + ETHTOOL_MSG_PSE_GET_REPLY, + ETHTOOL_MSG_PLCA_GET_CFG_REPLY, + ETHTOOL_MSG_PLCA_GET_STATUS_REPLY, + ETHTOOL_MSG_PLCA_NTF, =20 /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -242,6 +251,7 @@ enum { ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, /* u8 */ ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, /* u8 */ ETHTOOL_A_LINKMODES_LANES, /* u32 */ + ETHTOOL_A_LINKMODES_RATE_MATCHING, /* u8 */ =20 /* add new constants above here */ __ETHTOOL_A_LINKMODES_CNT, @@ -258,6 +268,7 @@ enum { ETHTOOL_A_LINKSTATE_SQI_MAX, /* u32 */ ETHTOOL_A_LINKSTATE_EXT_STATE, /* u8 */ ETHTOOL_A_LINKSTATE_EXT_SUBSTATE, /* u8 */ + ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT, /* u32 */ =20 /* add new constants above here */ __ETHTOOL_A_LINKSTATE_CNT, @@ -862,10 +873,42 @@ enum { ETHTOOL_A_MODULE_MAX =3D (__ETHTOOL_A_MODULE_CNT - 1) }; =20 +/* Power Sourcing Equipment */ +enum { + ETHTOOL_A_PSE_UNSPEC, + ETHTOOL_A_PSE_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_PODL_PSE_ADMIN_STATE, /* u32 */ + ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, /* u32 */ + ETHTOOL_A_PODL_PSE_PW_D_STATUS, /* u32 */ + + /* add new constants above here */ + __ETHTOOL_A_PSE_CNT, + ETHTOOL_A_PSE_MAX =3D (__ETHTOOL_A_PSE_CNT - 1) +}; + +/* PLCA */ + +enum { + ETHTOOL_A_PLCA_UNSPEC, + ETHTOOL_A_PLCA_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_PLCA_VERSION, /* u16 */ + ETHTOOL_A_PLCA_ENABLED, /* u8 */ + ETHTOOL_A_PLCA_STATUS, /* u8 */ + ETHTOOL_A_PLCA_NODE_CNT, /* u8 */ + ETHTOOL_A_PLCA_NODE_ID, /* u8 */ + ETHTOOL_A_PLCA_TO_TMR, /* u8 */ + ETHTOOL_A_PLCA_BURST_CNT, /* u8 */ + ETHTOOL_A_PLCA_BURST_TMR, /* u8 */ + + /* add new constants above here */ + __ETHTOOL_A_PLCA_CNT, + ETHTOOL_A_PLCA_MAX =3D (__ETHTOOL_A_PLCA_CNT - 1) +}; + /* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool" #define ETHTOOL_GENL_VERSION 1 =20 #define ETHTOOL_MCGRP_MONITOR_NAME "monitor" =20 -#endif /* _LINUX_ETHTOOL_NETLINK_H_ */ +#endif /* _UAPI_LINUX_ETHTOOL_NETLINK_H_ */ diff --git a/uapi/linux/genetlink.h b/uapi/linux/genetlink.h index e9b8117bdcf9..ddba3ca01e39 100644 --- a/uapi/linux/genetlink.h +++ b/uapi/linux/genetlink.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_GENERIC_NETLINK_H -#define __LINUX_GENERIC_NETLINK_H +#ifndef _UAPI__LINUX_GENERIC_NETLINK_H +#define _UAPI__LINUX_GENERIC_NETLINK_H =20 #include #include @@ -100,4 +100,4 @@ enum { =20 #define CTRL_ATTR_POLICY_MAX (__CTRL_ATTR_POLICY_DUMP_MAX - 1) =20 -#endif /* __LINUX_GENERIC_NETLINK_H */ +#endif /* _UAPI__LINUX_GENERIC_NETLINK_H */ diff --git a/uapi/linux/if_link.h b/uapi/linux/if_link.h index e0fbbfeeb3a1..1021a7e47a86 100644 --- a/uapi/linux/if_link.h +++ b/uapi/linux/if_link.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_IF_LINK_H -#define _LINUX_IF_LINK_H +#ifndef _UAPI_LINUX_IF_LINK_H +#define _UAPI_LINUX_IF_LINK_H =20 #include #include @@ -370,6 +370,9 @@ enum { IFLA_GRO_MAX_SIZE, IFLA_TSO_MAX_SIZE, IFLA_TSO_MAX_SEGS, + IFLA_ALLMULTI, /* Allmulti count: > 0 means acts ALLMULTI */ + + IFLA_DEVLINK_PORT, =20 __IFLA_MAX }; @@ -387,8 +390,10 @@ enum { }; =20 /* backwards compatibility for userspace */ +#ifndef __KERNEL__ #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(s= truct ifinfomsg)))) #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) +#endif =20 enum { IFLA_INET_UNSPEC, @@ -558,6 +563,7 @@ enum { IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT, IFLA_BRPORT_MCAST_EHT_HOSTS_CNT, IFLA_BRPORT_LOCKED, + IFLA_BRPORT_MAB, __IFLA_BRPORT_MAX }; #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) @@ -692,6 +698,7 @@ enum { IFLA_XFRM_UNSPEC, IFLA_XFRM_LINK, IFLA_XFRM_IF_ID, + IFLA_XFRM_COLLECT_METADATA, __IFLA_XFRM_MAX }; =20 @@ -1372,4 +1379,14 @@ enum { =20 #define IFLA_MCTP_MAX (__IFLA_MCTP_MAX - 1) =20 -#endif /* _LINUX_IF_LINK_H */ +/* DSA section */ + +enum { + IFLA_DSA_UNSPEC, + IFLA_DSA_MASTER, + __IFLA_DSA_MAX, +}; + +#define IFLA_DSA_MAX (__IFLA_DSA_MAX - 1) + +#endif /* _UAPI_LINUX_IF_LINK_H */ diff --git a/uapi/linux/netlink.h b/uapi/linux/netlink.h index 105b79f05744..e2ae82e3f9f7 100644 --- a/uapi/linux/netlink.h +++ b/uapi/linux/netlink.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_NETLINK_H -#define __LINUX_NETLINK_H +#ifndef _UAPI__LINUX_NETLINK_H +#define _UAPI__LINUX_NETLINK_H =20 #include #include /* for __kernel_sa_family_t */ @@ -20,7 +20,7 @@ #define NETLINK_CONNECTOR 11 #define NETLINK_NETFILTER 12 /* netfilter subsystem */ #define NETLINK_IP6_FW 13 -#define NETLINK_DNRTMSG 14 /* DECnet routing messages */ +#define NETLINK_DNRTMSG 14 /* DECnet routing messages (obsolete) */ #define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */ #define NETLINK_GENERIC 16 /* leave room for NETLINK_DM (DM Events) */ @@ -41,12 +41,20 @@ struct sockaddr_nl { __u32 nl_groups; /* multicast groups mask */ }; =20 +/** + * struct nlmsghdr - fixed format metadata header of Netlink messages + * @nlmsg_len: Length of message including header + * @nlmsg_type: Message content type + * @nlmsg_flags: Additional flags + * @nlmsg_seq: Sequence number + * @nlmsg_pid: Sending process port ID + */ struct nlmsghdr { - __u32 nlmsg_len; /* Length of message including header */ - __u16 nlmsg_type; /* Message content */ - __u16 nlmsg_flags; /* Additional flags */ - __u32 nlmsg_seq; /* Sequence number */ - __u32 nlmsg_pid; /* Sending process port ID */ + __u32 nlmsg_len; + __u16 nlmsg_type; + __u16 nlmsg_flags; + __u32 nlmsg_seq; + __u32 nlmsg_pid; }; =20 /* Flags values */ @@ -54,7 +62,7 @@ struct nlmsghdr { #define NLM_F_REQUEST 0x01 /* It is request message. */ #define NLM_F_MULTI 0x02 /* Multipart message, terminated by NLMSG_DONE */ #define NLM_F_ACK 0x04 /* Reply with ack, with zero or error code */ -#define NLM_F_ECHO 0x08 /* Echo this request */ +#define NLM_F_ECHO 0x08 /* Receive resulting notifications */ #define NLM_F_DUMP_INTR 0x10 /* Dump was inconsistent due to sequence cha= nge */ #define NLM_F_DUMP_FILTERED 0x20 /* Dump was filtered as requested */ =20 @@ -132,6 +140,10 @@ struct nlmsgerr { * be used - in the success case - to identify a created * object or operation or similar (binary) * @NLMSGERR_ATTR_POLICY: policy for a rejected attribute + * @NLMSGERR_ATTR_MISS_TYPE: type of a missing required attribute, + * %NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was + * missing at the message level + * @NLMSGERR_ATTR_MISS_NEST: offset of the nest where attribute was missing * @__NLMSGERR_ATTR_MAX: number of attributes * @NLMSGERR_ATTR_MAX: highest attribute number */ @@ -141,6 +153,8 @@ enum nlmsgerr_attrs { NLMSGERR_ATTR_OFFS, NLMSGERR_ATTR_COOKIE, NLMSGERR_ATTR_POLICY, + NLMSGERR_ATTR_MISS_TYPE, + NLMSGERR_ATTR_MISS_NEST, =20 __NLMSGERR_ATTR_MAX, NLMSGERR_ATTR_MAX =3D __NLMSGERR_ATTR_MAX - 1 @@ -151,8 +165,10 @@ enum nlmsgerr_attrs { #define NETLINK_PKTINFO 3 #define NETLINK_BROADCAST_ERROR 4 #define NETLINK_NO_ENOBUFS 5 +#ifndef __KERNEL__ #define NETLINK_RX_RING 6 #define NETLINK_TX_RING 7 +#endif #define NETLINK_LISTEN_ALL_NSID 8 #define NETLINK_LIST_MEMBERSHIPS 9 #define NETLINK_CAP_ACK 10 @@ -180,6 +196,7 @@ struct nl_mmap_hdr { __u32 nm_gid; }; =20 +#ifndef __KERNEL__ enum nl_mmap_status { NL_MMAP_STATUS_UNUSED, NL_MMAP_STATUS_RESERVED, @@ -191,6 +208,7 @@ enum nl_mmap_status { #define NL_MMAP_MSG_ALIGNMENT NLMSG_ALIGNTO #define NL_MMAP_MSG_ALIGN(sz) __ALIGN_KERNEL(sz, NL_MMAP_MSG_ALIGNMENT) #define NL_MMAP_HDRLEN NL_MMAP_MSG_ALIGN(sizeof(struct nl_mmap_hdr)) +#endif =20 #define NET_MAJOR 36 /* Major 36 is reserved for networking */ =20 @@ -333,6 +351,9 @@ enum netlink_attribute_type { * bitfield32 type (U32) * @NL_POLICY_TYPE_ATTR_MASK: mask of valid bits for unsigned integers (U6= 4) * @NL_POLICY_TYPE_ATTR_PAD: pad attribute for 64-bit alignment + * + * @__NL_POLICY_TYPE_ATTR_MAX: number of attributes + * @NL_POLICY_TYPE_ATTR_MAX: highest attribute number */ enum netlink_policy_type_attr { NL_POLICY_TYPE_ATTR_UNSPEC, @@ -354,4 +375,4 @@ enum netlink_policy_type_attr { NL_POLICY_TYPE_ATTR_MAX =3D __NL_POLICY_TYPE_ATTR_MAX - 1 }; =20 -#endif /* __LINUX_NETLINK_H */ +#endif /* _UAPI__LINUX_NETLINK_H */ diff --git a/uapi/linux/rtnetlink.h b/uapi/linux/rtnetlink.h index f4a540c01b15..eb2747d58a81 100644 --- a/uapi/linux/rtnetlink.h +++ b/uapi/linux/rtnetlink.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_RTNETLINK_H -#define __LINUX_RTNETLINK_H +#ifndef _UAPI__LINUX_RTNETLINK_H +#define _UAPI__LINUX_RTNETLINK_H =20 #include #include @@ -672,6 +672,7 @@ enum { =20 #define NDUSEROPT_MAX (__NDUSEROPT_MAX - 1) =20 +#ifndef __KERNEL__ /* RTnetlink multicast groups - backwards compatibility for userspace */ #define RTMGRP_LINK 1 #define RTMGRP_NOTIFY 2 @@ -692,6 +693,7 @@ enum { #define RTMGRP_DECnet_ROUTE 0x4000 =20 #define RTMGRP_IPV6_PREFIX 0x20000 +#endif =20 /* RTnetlink multicast groups */ enum rtnetlink_groups { @@ -821,4 +823,4 @@ enum { =20 =20 =20 -#endif /* __LINUX_RTNETLINK_H */ +#endif /* _UAPI__LINUX_RTNETLINK_H */ --=20 2.35.1 From nobody Thu Sep 18 17:14:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5D61C47089 for ; Sun, 4 Dec 2022 02:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbiLDCkH (ORCPT ); Sat, 3 Dec 2022 21:40:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiLDCkE (ORCPT ); Sat, 3 Dec 2022 21:40:04 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CBA71180A; Sat, 3 Dec 2022 18:40:02 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id qk9so2330187ejc.3; Sat, 03 Dec 2022 18:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=KGd5LpCKZo9NoOS5phY6+jbNL3TjfFQ5CGWt9wHy6Tk=; b=o5/I6R1mkotGC/7492XSDrYAHLFkD8v17/1A1EwSMytIjR423IV7bDM+gOpcxDM/rn zUOtYXXAO01u621hc2/ew19d1nz6Hxh/Q/jMuVgG0PDU5QvHyp9wQiYnxzECvCmcC//y mLl9fIKCwEqpSGVnx43QmnW325wpRRv9YFEEwy9FfZOPS4bvhsYFwM35qnfCyCbPnlMY OqPpjMjnr9/wvpYgXnBMY5DmtrwvW242pT0JQuRxzE1d9BhVqc8PpNv8tQDuiFaPFy9H 2x+AdsdJDzoz+kOnOOKdyWz7ayEv1PuUkKwSoOG9eGlO0Bs9dT5iJgLTmzm1I5y4LkhW 4JYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KGd5LpCKZo9NoOS5phY6+jbNL3TjfFQ5CGWt9wHy6Tk=; b=p8N5oES3NJfM2GpyCmxSWZ1BZSCC8vVoGiyJwS9UhlXMfcsY/bsfrLycBHdnW5ZQqK wXJxeXsVj6h82Pe+h2xP0FIjTTjLMlSJ7bCLZuhI+GHB7gviqHYAdxmQ/ZKHVmksfEZ1 P8eXzpp7lzUy+bLWIt2dlQTOb4muY2TK2GzV7qFH+0M9lemZ33ufc85z1FMj/fYSyTd7 7GQxGoKCKUsv8OqJG75LNYALAMDvwqf6jfvdGVBhRNbeyY+JT5ucWTosHz9AceoKbdNR mzL/2nnzUYToyV3cxKwzIVDYApsp2eQXoPthxmkZsSAbD3Iq+Trm6BFOsIpLzM2IL9Ah b1ew== X-Gm-Message-State: ANoB5pmydQ6tlE3pUoOUv8L/dbUbPJp924TppJs47Z7LgNTay2HYHk8e S1kMFZUJ54t+K/SzWF9vb8c= X-Google-Smtp-Source: AA0mqf7VeJ4H9JkHGYfDcgGcwiUC80PUweq09/AnMMrga2U1TZfMCXrH4qYioOw7CWV6szN85BXT8g== X-Received: by 2002:a17:907:a489:b0:7c0:c14f:73d7 with SMTP id vp9-20020a170907a48900b007c0c14f73d7mr7634062ejc.52.1670121600855; Sat, 03 Dec 2022 18:40:00 -0800 (PST) Received: from gvm01 (net-2-45-26-236.cust.vodafonedsl.it. [2.45.26.236]) by smtp.gmail.com with ESMTPSA id v21-20020a170906859500b007aea1dc1840sm4762625ejx.111.2022.12.03.18.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 18:40:00 -0800 (PST) Date: Sun, 4 Dec 2022 03:40:08 +0100 From: Piergiorgio Beruto To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: [PATCH net-next 2/2] ethtool: Add support for IEEE 802.3cg-2019 Clause 148 - PLCA RS Message-ID: <8929b2dbbca7d29573d604ffcd6e7c1cd5760894.1670121214.git.piergiorgio.beruto@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds support for the Physical Layer Collision Avoidance Reconciliation Sublayer which was introduced in the IEEE 802.3 standard by the 802.3cg working group in 2019. The ethtool interface has been extended as follows: - show if the device supports PLCA when ethtool is invoked without FLAGS - additionally show what PLCA version is supported - show the current PLCA status - add FLAGS for getting and setting the PLCA configuration Signed-off-by: Piergiorgio Beruto --- Makefile.am | 1 + ethtool.c | 21 +++ netlink/extapi.h | 6 + netlink/plca.c | 311 +++++++++++++++++++++++++++++++++++++++++++++ netlink/settings.c | 86 ++++++++++++- 5 files changed, 424 insertions(+), 1 deletion(-) create mode 100644 netlink/plca.c diff --git a/Makefile.am b/Makefile.am index fcc912edd7e4..b184b8ceb28a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,6 +41,7 @@ ethtool_SOURCES +=3D \ netlink/desc-ethtool.c netlink/desc-genlctrl.c \ netlink/module-eeprom.c netlink/module.c \ netlink/desc-rtnl.c netlink/cable_test.c netlink/tunnels.c \ + netlink/plca.c \ uapi/linux/ethtool_netlink.h \ uapi/linux/netlink.h uapi/linux/genetlink.h \ uapi/linux/rtnetlink.h uapi/linux/if_link.h diff --git a/ethtool.c b/ethtool.c index 3207e49137c4..d23406f54a37 100644 --- a/ethtool.c +++ b/ethtool.c @@ -6075,6 +6075,27 @@ static const struct option args[] =3D { .help =3D "Set transceiver module settings", .xhelp =3D " [ power-mode-policy high|auto ]\n" }, + { + .opts =3D "--get-plca-cfg", + .nlfunc =3D nl_plca_get_cfg, + .help =3D "Get PLCA configuration", + }, + { + .opts =3D "--set-plca-cfg", + .nlfunc =3D nl_plca_set_cfg, + .help =3D "Set PLCA configuration", + .xhelp =3D " [ enable on|off ]\n" + " [ node-id N ]\n" + " [ node-cnt N ]\n" + " [ to-tmr N ]\n" + " [ burst-cnt N ]\n" + " [ burst-tmr N ]\n" + }, + { + .opts =3D "--get-plca-status", + .nlfunc =3D nl_plca_get_status, + .help =3D "Get PLCA status information", + }, { .opts =3D "-h|--help", .no_dev =3D true, diff --git a/netlink/extapi.h b/netlink/extapi.h index 1bb580a889a8..0add156e644a 100644 --- a/netlink/extapi.h +++ b/netlink/extapi.h @@ -47,6 +47,9 @@ int nl_gmodule(struct cmd_context *ctx); int nl_smodule(struct cmd_context *ctx); int nl_monitor(struct cmd_context *ctx); int nl_getmodule(struct cmd_context *ctx); +int nl_plca_get_cfg(struct cmd_context *ctx); +int nl_plca_set_cfg(struct cmd_context *ctx); +int nl_plca_get_status(struct cmd_context *ctx); =20 void nl_monitor_usage(void); =20 @@ -114,6 +117,9 @@ nl_get_eeprom_page(struct cmd_context *ctx __maybe_unus= ed, #define nl_getmodule NULL #define nl_gmodule NULL #define nl_smodule NULL +#define nl_get_plca_cfg NULL +#define nl_set_plca_cfg NULL +#define nl_get_plca_status NULL =20 #endif /* ETHTOOL_ENABLE_NETLINK */ =20 diff --git a/netlink/plca.c b/netlink/plca.c new file mode 100644 index 000000000000..19818598ec55 --- /dev/null +++ b/netlink/plca.c @@ -0,0 +1,311 @@ +/* + * plca.c - netlink implementation of plca command + * + * Implementation of "ethtool --show-plca " and + * "ethtool --set-plca ..." + */ + +#include +#include +#include + +#include "../internal.h" +#include "../common.h" +#include "netlink.h" +#include "bitset.h" +#include "parser.h" + +/* PLCA_GET_CFG */ + +int plca_get_cfg_reply_cb(const struct nlmsghdr *nlhdr, void *data) +{ + const struct nlattr *tb[ETHTOOL_A_PLCA_MAX + 1] =3D {}; + DECLARE_ATTR_TB_INFO(tb); + struct nl_context *nlctx =3D data; + bool silent; + int err_ret; + u8 id =3D 255; + int ret; + u8 val; + + silent =3D nlctx->is_dump || nlctx->is_monitor; + err_ret =3D silent ? MNL_CB_OK : MNL_CB_ERROR; + ret =3D mnl_attr_parse(nlhdr, GENL_HDRLEN, attr_cb, &tb_info); + if (ret < 0) + return err_ret; + + nlctx->devname =3D get_dev_name(tb[ETHTOOL_A_PLCA_HEADER]); + if (!dev_ok(nlctx)) + return err_ret; + + if (silent) + putchar('\n'); + + printf("PLCA settings for %s:\n", nlctx->devname); + + // check if PLCA is enabled + printf("\tEnabled: "); + + if (!tb[ETHTOOL_A_PLCA_ENABLED]) { + printf("not supported"); + } + else { + val =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_ENABLED]); + printf(val ? "Yes" : "No"); + } + putchar('\n'); + + // get node ID + printf("\tlocal node ID: "); + + if (!tb[ETHTOOL_A_PLCA_NODE_ID]) { + printf("not supported"); + } + else { + id =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_NODE_ID]); + printf("%u (%s)", (unsigned int)id, + id =3D=3D 0 ? "coordinator" : + id =3D=3D 255 ? "unconfigured" : "follower"); + } + putchar('\n'); + + // get node count + printf("\tNode count: "); + if (!tb[ETHTOOL_A_PLCA_NODE_CNT]) { + printf("not supported"); + } + else { + val =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_NODE_CNT]); + printf("%u", (unsigned int)val); + + // The node count is ignored by follower nodes. However, it can + // be pre-set to enable fast coordinator role switchover. + // Therefore, on a follower node we still wanto to show it, + // indicating it is not currently used. + if (tb[ETHTOOL_A_PLCA_NODE_ID] && id !=3D 0) + printf(" (ignored)"); + } + putchar('\n'); + + // get TO timer (transmit opportunity timer) + printf("\tTO timer: "); + if (!tb[ETHTOOL_A_PLCA_TO_TMR]) { + printf("not supported"); + } + else { + val =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_TO_TMR]); + printf("%u BT", (unsigned int) val); + } + putchar('\n'); + + // get burst count + printf("\tBurst count: "); + if (!tb[ETHTOOL_A_PLCA_BURST_CNT]) { + printf("not supported"); + } + else { + val =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_BURST_CNT]); + printf("%u (%s)", (unsigned int) val, + val > 0 ? "enabled" : "disabled"); + } + putchar('\n'); + + // get burst timer + printf("\tBurst timer: "); + if (!tb[ETHTOOL_A_PLCA_BURST_TMR]) { + printf("not supported"); + } + else { + val =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_BURST_TMR]); + printf("%u BT", (unsigned int) val); + } + putchar('\n'); + + return MNL_CB_OK; +} + + +int nl_plca_get_cfg(struct cmd_context *ctx) +{ + struct nl_context *nlctx =3D ctx->nlctx; + struct nl_socket *nlsk =3D nlctx->ethnl_socket; + int ret; + + if (netlink_cmd_check(ctx, ETHTOOL_MSG_PLCA_GET_CFG, true)) + return -EOPNOTSUPP; + + if (ctx->argc > 0) { + fprintf(stderr, "ethtool: unexpected parameter '%s'\n", + *ctx->argp); + return 1; + } + + ret =3D nlsock_prep_get_request( + nlsk, + ETHTOOL_MSG_PLCA_GET_CFG, + ETHTOOL_A_PLCA_HEADER, + 0 + ); + + if (ret < 0) + return ret; + + return nlsock_send_get_request(nlsk, plca_get_cfg_reply_cb); +} + +/* PLCA_SET_CFG */ + +static const struct param_parser set_plca_params[] =3D { + { + .arg =3D "enable", + .type =3D ETHTOOL_A_PLCA_ENABLED, + .handler =3D nl_parse_u8bool, + .min_argc =3D 1, + }, + { + .arg =3D "node-id", + .type =3D ETHTOOL_A_PLCA_NODE_ID, + .handler =3D nl_parse_direct_u8, + .min_argc =3D 1, + }, + { + .arg =3D "node-cnt", + .type =3D ETHTOOL_A_PLCA_NODE_CNT, + .handler =3D nl_parse_direct_u8, + .min_argc =3D 1, + }, + { + .arg =3D "to-tmr", + .type =3D ETHTOOL_A_PLCA_TO_TMR, + .handler =3D nl_parse_direct_u8, + .min_argc =3D 1, + }, + { + .arg =3D "burst-cnt", + .type =3D ETHTOOL_A_PLCA_BURST_CNT, + .handler =3D nl_parse_direct_u8, + .min_argc =3D 1, + }, + { + .arg =3D "burst-tmr", + .type =3D ETHTOOL_A_PLCA_BURST_TMR, + .handler =3D nl_parse_direct_u8, + .min_argc =3D 1, + }, + {} +}; + +int nl_plca_set_cfg(struct cmd_context *ctx) +{ + struct nl_context *nlctx =3D ctx->nlctx; + struct nl_msg_buff *msgbuff; + struct nl_socket *nlsk; + int ret; + + if (netlink_cmd_check(ctx, ETHTOOL_MSG_PLCA_SET_CFG, false)) + return -EOPNOTSUPP; + if (!ctx->argc) { + fprintf(stderr, + "ethtool (--set-plca-cfg): parameters missing\n"); + return 1; + } + + nlctx->cmd =3D "--set-plca-cfg"; + nlctx->argp =3D ctx->argp; + nlctx->argc =3D ctx->argc; + nlctx->devname =3D ctx->devname; + nlsk =3D nlctx->ethnl_socket; + msgbuff =3D &nlsk->msgbuff; + + ret =3D msg_init(nlctx, msgbuff, ETHTOOL_MSG_PLCA_SET_CFG, + NLM_F_REQUEST | NLM_F_ACK); + if (ret < 0) + return 2; + if (ethnla_fill_header(msgbuff, ETHTOOL_A_PLCA_HEADER, + ctx->devname, 0)) + return -EMSGSIZE; + + ret =3D nl_parser(nlctx, set_plca_params, NULL, PARSER_GROUP_NONE, NULL); + if (ret < 0) + return 1; + + ret =3D nlsock_sendmsg(nlsk, NULL); + if (ret < 0) + return 76; + ret =3D nlsock_process_reply(nlsk, nomsg_reply_cb, nlctx); + if (ret =3D=3D 0) + return 0; + else + return nlctx->exit_code ?: 76; +} + +/* PLCA_GET_STATUS */ + +int plca_get_status_reply_cb(const struct nlmsghdr *nlhdr, void *data) +{ + const struct nlattr *tb[ETHTOOL_A_PLCA_MAX + 1] =3D {}; + DECLARE_ATTR_TB_INFO(tb); + struct nl_context *nlctx =3D data; + bool silent; + int err_ret; + int ret; + u8 val; + + silent =3D nlctx->is_dump || nlctx->is_monitor; + err_ret =3D silent ? MNL_CB_OK : MNL_CB_ERROR; + ret =3D mnl_attr_parse(nlhdr, GENL_HDRLEN, attr_cb, &tb_info); + if (ret < 0) + return err_ret; + + nlctx->devname =3D get_dev_name(tb[ETHTOOL_A_PLCA_HEADER]); + if (!dev_ok(nlctx)) + return err_ret; + + if (silent) + putchar('\n'); + + printf("PLCA status of %s:\n", nlctx->devname); + + // check whether the Open Alliance TC14 standard memory map is supported + printf("\tStatus: "); + + if (!tb[ETHTOOL_A_PLCA_STATUS]) { + printf("not supported"); + } + else { + val =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_STATUS]); + printf(val ? "on" : "off"); + } + putchar('\n'); + + return MNL_CB_OK; +} + + +int nl_plca_get_status(struct cmd_context *ctx) +{ + struct nl_context *nlctx =3D ctx->nlctx; + struct nl_socket *nlsk =3D nlctx->ethnl_socket; + int ret; + + if (netlink_cmd_check(ctx, ETHTOOL_MSG_PLCA_GET_STATUS, true)) + return -EOPNOTSUPP; + + if (ctx->argc > 0) { + fprintf(stderr, "ethtool: unexpected parameter '%s'\n", + *ctx->argp); + return 1; + } + + ret =3D nlsock_prep_get_request( + nlsk, + ETHTOOL_MSG_PLCA_GET_STATUS, + ETHTOOL_A_PLCA_HEADER, + 0 + ); + + if (ret < 0) + return ret; + + return nlsock_send_get_request(nlsk, plca_get_status_reply_cb); +} diff --git a/netlink/settings.c b/netlink/settings.c index ea86e365383b..25c5e7848fb7 100644 --- a/netlink/settings.c +++ b/netlink/settings.c @@ -165,6 +165,9 @@ static const struct link_mode_info link_modes[] =3D { [ETHTOOL_LINK_MODE_100baseFX_Half_BIT] =3D __HALF_DUPLEX(100), [ETHTOOL_LINK_MODE_100baseFX_Full_BIT] =3D __REAL(100), [ETHTOOL_LINK_MODE_10baseT1L_Full_BIT] =3D __REAL(10), + [ETHTOOL_LINK_MODE_10baseT1S_Full_BIT] =3D __REAL(10), + [ETHTOOL_LINK_MODE_10baseT1S_Half_BIT] =3D __REAL(10), + [ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT] =3D __REAL(10), }; const unsigned int link_modes_count =3D ARRAY_SIZE(link_modes); =20 @@ -882,6 +885,75 @@ int debug_reply_cb(const struct nlmsghdr *nlhdr, void = *data) return MNL_CB_OK; } =20 +int plca_cfg_reply_cb(const struct nlmsghdr *nlhdr, void *data) +{ + const struct nlattr *tb[ETHTOOL_A_PLCA_MAX + 1] =3D {}; + DECLARE_ATTR_TB_INFO(tb); + struct nl_context *nlctx =3D data; + int ret; + + if (nlctx->is_dump || nlctx->is_monitor) + nlctx->no_banner =3D false; + ret =3D mnl_attr_parse(nlhdr, GENL_HDRLEN, attr_cb, &tb_info); + if (ret < 0) + return ret; + nlctx->devname =3D get_dev_name(tb[ETHTOOL_A_PLCA_HEADER]); + if (!dev_ok(nlctx)) + return MNL_CB_OK; + + print_banner(nlctx); + printf("\tPLCA support: "); + + if (tb[ETHTOOL_A_PLCA_VERSION]) { + uint16_t val =3D mnl_attr_get_u16(tb[ETHTOOL_A_PLCA_VERSION]); + if ((val >> 8) =3D=3D 0x0A) { + printf("OPEN Alliance v%u.%u", + (unsigned int)((val >> 4) & 0xF), + (unsigned int)(val & 0xF) + ); + } + else + printf("unknown standard"); + } + else + printf("non-standard"); + + printf("\n"); + + return MNL_CB_OK; +} + +int plca_status_reply_cb(const struct nlmsghdr *nlhdr, void *data) +{ + const struct nlattr *tb[ETHTOOL_A_PLCA_MAX + 1] =3D {}; + DECLARE_ATTR_TB_INFO(tb); + struct nl_context *nlctx =3D data; + int ret; + + if (nlctx->is_dump || nlctx->is_monitor) + nlctx->no_banner =3D false; + ret =3D mnl_attr_parse(nlhdr, GENL_HDRLEN, attr_cb, &tb_info); + if (ret < 0) + return ret; + nlctx->devname =3D get_dev_name(tb[ETHTOOL_A_PLCA_HEADER]); + if (!dev_ok(nlctx)) + return MNL_CB_OK; + + print_banner(nlctx); + printf("\tPLCA status: "); + + if (tb[ETHTOOL_A_PLCA_STATUS]) { + uint8_t val =3D mnl_attr_get_u8(tb[ETHTOOL_A_PLCA_STATUS]); + printf(val ? "up" : "down"); + } + else + printf("unknown"); + + printf("\n"); + + return MNL_CB_OK; +} + static int gset_request(struct nl_socket *nlsk, uint8_t msg_type, uint16_t hdr_attr, mnl_cb_t cb) { @@ -903,7 +975,9 @@ int nl_gset(struct cmd_context *ctx) netlink_cmd_check(ctx, ETHTOOL_MSG_LINKINFO_GET, true) || netlink_cmd_check(ctx, ETHTOOL_MSG_WOL_GET, true) || netlink_cmd_check(ctx, ETHTOOL_MSG_DEBUG_GET, true) || - netlink_cmd_check(ctx, ETHTOOL_MSG_LINKSTATE_GET, true)) + netlink_cmd_check(ctx, ETHTOOL_MSG_LINKSTATE_GET, true) || + netlink_cmd_check(ctx, ETHTOOL_MSG_PLCA_GET_CFG, true) || + netlink_cmd_check(ctx, ETHTOOL_MSG_PLCA_GET_STATUS, true)) return -EOPNOTSUPP; =20 nlctx->suppress_nlerr =3D 1; @@ -923,6 +997,11 @@ int nl_gset(struct cmd_context *ctx) if (ret =3D=3D -ENODEV) return ret; =20 + ret =3D gset_request(nlsk, ETHTOOL_MSG_PLCA_GET_CFG, + ETHTOOL_A_PLCA_HEADER, plca_cfg_reply_cb); + if (ret =3D=3D -ENODEV) + return ret; + ret =3D gset_request(nlsk, ETHTOOL_MSG_DEBUG_GET, ETHTOOL_A_DEBUG_HEADER, debug_reply_cb); if (ret =3D=3D -ENODEV) @@ -933,6 +1012,11 @@ int nl_gset(struct cmd_context *ctx) if (ret =3D=3D -ENODEV) return ret; =20 + ret =3D gset_request(nlsk, ETHTOOL_MSG_PLCA_GET_STATUS, + ETHTOOL_A_PLCA_HEADER, plca_status_reply_cb); + if (ret =3D=3D -ENODEV) + return ret; + if (!nlctx->no_banner) { printf("No data available\n"); return 75; --=20 2.35.1