From nobody Thu Sep 18 03:58:50 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 72275C10F1B for ; Sat, 10 Dec 2022 22:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbiLJWw3 (ORCPT ); Sat, 10 Dec 2022 17:52:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiLJWwX (ORCPT ); Sat, 10 Dec 2022 17:52:23 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72C34B1C0; Sat, 10 Dec 2022 14:52:21 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id qk9so19537579ejc.3; Sat, 10 Dec 2022 14:52:21 -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=HFJkwTEFSgPR36Zpv79C+3GhM7O6dp/lBALvB3RNw6g=; b=dcjstzkhaMUZDHLIpruwbwTWaKavRwsLhkaX/57LSB7oSIFlwGnGHg2nBjkE+Macsj M/28iJH8Im7tQnBQ+g45t8SwNlMJ9bAF3rGzfggAhoMseLIcFfsW6lUT1l2FJ02CTkyo HguSlEoL2/EA6kGUCnb2r0LPbgQ2fZPsgA58oFKpZDhCel/JUewl+Tc7N3nPUdz9y+kB WZ469a0orU8qmxWgKKMrEevRq5MZzv4x6Zm5dJPpbj/ZPa29PvzVZ2+rY6m00ZtG+wzT THza5rWQuC3/w4NK7VKhcv5k0eI7tVHnSEdxJylDVbXcfeitueiMv9ShNlJcbz+IoIXE W24Q== 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=HFJkwTEFSgPR36Zpv79C+3GhM7O6dp/lBALvB3RNw6g=; b=kyVy/Y0EWB698Fivf9jGTlImmWLlWHiLvayLI4q/BEqISRhkysjUb9aZjV5ClzK0l1 zGjHn9uH5EKB+vL9PqHlHjInI0ReL70GfRQyY97OPasS25Yn4cS0i6+FfHE94bev2CPA na3pZwEjxZwQuQXnOe7btl0V/SHF17EU+UXskRn4XuOmGa0sS2+hEkNVEyKc0ed7WOmc 2ePz9x1Jyj4jZkmtkhUNjoQVmwjoyCfrwk0to0QbitwXyT220dTMSaO7QWtgxZd5QjyC +A3UzWuZdih1diTSqMUYKpDn8r6v3HAua4yy5dBE44nQm+WF7srvZZJw3vXs9uhkAKBM bPXQ== X-Gm-Message-State: ANoB5pno24wkSa1E4nJDUytEKDulJ4riw/3NoNbPSlgWhN/zf6LLY+Gk MP65y2482n71oonuPINKHgo= X-Google-Smtp-Source: AA0mqf7nTjic9wu7N79/zXCxxHg72UQWXzmamHYC/NjhnbTTPkZ4HNIW90qmwxPusgw4b0I/IItWrQ== X-Received: by 2002:a17:906:f50:b0:7b2:c227:126d with SMTP id h16-20020a1709060f5000b007b2c227126dmr8456323ejj.20.1670712739999; Sat, 10 Dec 2022 14:52:19 -0800 (PST) Received: from gvm01 (net-2-45-26-236.cust.vodafonedsl.it. [2.45.26.236]) by smtp.gmail.com with ESMTPSA id tp25-20020a170907c49900b007bed316a6d9sm1486479ejc.18.2022.12.10.14.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Dec 2022 14:52:19 -0800 (PST) Date: Sat, 10 Dec 2022 23:52:18 +0100 From: Piergiorgio Beruto To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: [PATCH v3 ethtool-next 1/2] update UAPI header copies Message-ID: <10579fca736e88a98183f3bce06f8ba089dc9543.1670712544.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" Update to kernel commit 9f6c9504c56e. Signed-off-by: Piergiorgio Beruto --- uapi/linux/ethtool.h | 3 +++ uapi/linux/ethtool_netlink.h | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/uapi/linux/ethtool.h b/uapi/linux/ethtool.h index d1748702bddc..78bf6fad9e02 100644 --- a/uapi/linux/ethtool.h +++ b/uapi/linux/ethtool.h @@ -1739,6 +1739,9 @@ enum ethtool_link_mode_bit_indices { 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, =20 /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS diff --git a/uapi/linux/ethtool_netlink.h b/uapi/linux/ethtool_netlink.h index d581c43d592d..7e116fbe911f 100644 --- a/uapi/linux/ethtool_netlink.h +++ b/uapi/linux/ethtool_netlink.h @@ -51,6 +51,10 @@ enum { ETHTOOL_MSG_MODULE_SET, ETHTOOL_MSG_PSE_GET, ETHTOOL_MSG_PSE_SET, + ETHTOOL_MSG_RSS_GET, + 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, @@ -97,6 +101,10 @@ enum { ETHTOOL_MSG_MODULE_GET_REPLY, ETHTOOL_MSG_MODULE_NTF, ETHTOOL_MSG_PSE_GET_REPLY, + ETHTOOL_MSG_RSS_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, @@ -880,6 +888,37 @@ enum { ETHTOOL_A_PSE_MAX =3D (__ETHTOOL_A_PSE_CNT - 1) }; =20 +enum { + ETHTOOL_A_RSS_UNSPEC, + ETHTOOL_A_RSS_HEADER, + ETHTOOL_A_RSS_CONTEXT, /* u32 */ + ETHTOOL_A_RSS_HFUNC, /* u32 */ + ETHTOOL_A_RSS_INDIR, /* binary */ + ETHTOOL_A_RSS_HKEY, /* binary */ + + __ETHTOOL_A_RSS_CNT, + ETHTOOL_A_RSS_MAX =3D (__ETHTOOL_A_RSS_CNT - 1), +}; + +/* PLCA */ + +enum { + ETHTOOL_A_PLCA_UNSPEC, + ETHTOOL_A_PLCA_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_PLCA_VERSION, /* u16 */ + ETHTOOL_A_PLCA_ENABLED, /* u32 */ + ETHTOOL_A_PLCA_STATUS, /* u32 */ + ETHTOOL_A_PLCA_NODE_CNT, /* u32 */ + ETHTOOL_A_PLCA_NODE_ID, /* u32 */ + ETHTOOL_A_PLCA_TO_TMR, /* u32 */ + ETHTOOL_A_PLCA_BURST_CNT, /* u32 */ + ETHTOOL_A_PLCA_BURST_TMR, /* u32 */ + + /* 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 2.37.4 From nobody Thu Sep 18 03:58:50 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 770AFC10F1B for ; Sat, 10 Dec 2022 22:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbiLJWwn (ORCPT ); Sat, 10 Dec 2022 17:52:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbiLJWwg (ORCPT ); Sat, 10 Dec 2022 17:52:36 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC48A2AED; Sat, 10 Dec 2022 14:52:34 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id u19so1007367ejm.8; Sat, 10 Dec 2022 14:52:34 -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=IPS5NwxgitxgJ/4k1MZW4hHfzPpAnbVkwhMV0WPCQcQ=; b=jkSp3AePuYOz4x/v0T+uesotwXBxPvnIjeE23nrrSIOr1NA+Flvu7x5avKeeTZId6u oORcxa8LeL2bG/iJ5HeWXgDUgeseCGg35mwS07ncEVSjP8lDYdxUxq81J5tgGntPdqit kd7ADTT1PSCL7yXeZs5YoU+3wLt/FbjScwiaSavxbZ5C4EtbK2koytjThBPlL2Fxoufo ODYcGSHaVzeSLP5tbu/p8hzbv3zToT8jo6RpY1vzMe/UUziOqPsZmkbNW3iJTe5GTCfN mPn5zOeUl1n1EJW4y/06o2A3RHIyJArEKrCgWmwS7mDTlwAY1fdcbspJQbUw/18X10CU tqbw== 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=IPS5NwxgitxgJ/4k1MZW4hHfzPpAnbVkwhMV0WPCQcQ=; b=Dyz5LpIACmJr7p39d+S804wYQN4xziMHrbr/NEAkMztjIC6vLa6EZtgIl3zCnhqdHL dX7RgI7BfbSZ2Nl4ouFU4JD5UtQSMFTUxnvC4SFjqACsfvOprSXTkykxlrY3nUig9tqe HssE+Mp2hXhZf4zkDMlBv9BT7QUiFNAjqHV1Sumy0Q1CkiGbpa9S8iqgNHIx4oiL/vB6 8UJviYV3s+13kenU6w50A5OF8SoO2eReHfO/Kv6HKMEngalDhAAbZNGJlr6MQ+JN4OhS XMa9DvetT7XlOfcJwljaqL4exAv4X4iaQy0mkUcN9JqB2kAvu0POwBop0G9LS/0/pZoH saRw== X-Gm-Message-State: ANoB5plyxx7CYp2WuXZgEH0k3pkrNaKislnMoQBGXYHGCpFO4MebkzbS +kSxQbCX6vJxHAXEpxjgRpQ= X-Google-Smtp-Source: AA0mqf4WmGCz+vaTQ1y5jh4Cnglo7oo5X9ItVn3mkQWCwesY4y1PRgn/guDUBhzXfqByO9fxMtaN5A== X-Received: by 2002:a17:906:3fd1:b0:7ad:d7a4:4346 with SMTP id k17-20020a1709063fd100b007add7a44346mr13369359ejj.66.1670712753321; Sat, 10 Dec 2022 14:52:33 -0800 (PST) Received: from gvm01 (net-2-45-26-236.cust.vodafonedsl.it. [2.45.26.236]) by smtp.gmail.com with ESMTPSA id f3-20020a17090631c300b007b9269a0423sm1455436ejf.172.2022.12.10.14.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Dec 2022 14:52:32 -0800 (PST) Date: Sat, 10 Dec 2022 23:52:32 +0100 From: Piergiorgio Beruto To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: [PATCH v3 ethtool-next 2/2] add support for IEEE 802.3cg-2019 Clause 148 - PLCA RS Message-ID: <81162a080bc9c920625b6b29eeb530e3890ea39c.1670712544.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 | 295 +++++++++++++++++++++++++++++++++++++++++++++ netlink/settings.c | 89 +++++++++++++- 5 files changed, 410 insertions(+), 2 deletions(-) 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..f7d7bdbc5c84 --- /dev/null +++ b/netlink/plca.c @@ -0,0 +1,295 @@ +/* + * 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 idv, val; + int err_ret; + int ret; + + 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 { + idv =3D mnl_attr_get_u32(tb[ETHTOOL_A_PLCA_NODE_ID]); + printf("%u (%s)", idv, + idv =3D=3D 0 ? "coordinator" : + idv =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_u32(tb[ETHTOOL_A_PLCA_NODE_CNT]); + printf("%u", 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] && idv !=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_u32(tb[ETHTOOL_A_PLCA_TO_TMR]); + printf("%u BT", 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_u32(tb[ETHTOOL_A_PLCA_BURST_CNT]); + printf("%u (%s)", 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_u32(tb[ETHTOOL_A_PLCA_BURST_TMR]); + printf("%u BT", 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_u32, + .min_argc =3D 1, + }, + { + .arg =3D "node-cnt", + .type =3D ETHTOOL_A_PLCA_NODE_CNT, + .handler =3D nl_parse_direct_u32, + .min_argc =3D 1, + }, + { + .arg =3D "to-tmr", + .type =3D ETHTOOL_A_PLCA_TO_TMR, + .handler =3D nl_parse_direct_u32, + .min_argc =3D 1, + }, + { + .arg =3D "burst-cnt", + .type =3D ETHTOOL_A_PLCA_BURST_CNT, + .handler =3D nl_parse_direct_u32, + .min_argc =3D 1, + }, + { + .arg =3D "burst-tmr", + .type =3D ETHTOOL_A_PLCA_BURST_TMR, + .handler =3D nl_parse_direct_u32, + .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 14ad0b46e102..e0ed827547a0 100644 --- a/netlink/settings.c +++ b/netlink/settings.c @@ -166,6 +166,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 @@ -890,6 +893,73 @@ 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_context *nlctx, uint8_t msg_type, uint16_t hdr_attr, mnl_cb_t cb) { @@ -914,7 +984,10 @@ 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_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; @@ -934,6 +1007,12 @@ int nl_gset(struct cmd_context *ctx) if (ret =3D=3D -ENODEV) return ret; =20 + ret =3D gset_request(nlctx, ETHTOOL_MSG_PLCA_GET_CFG, + ETHTOOL_A_PLCA_HEADER, plca_cfg_reply_cb); + + if (ret =3D=3D -ENODEV) + return ret; + ret =3D gset_request(nlctx, ETHTOOL_MSG_DEBUG_GET, ETHTOOL_A_DEBUG_HEADER, debug_reply_cb); if (ret =3D=3D -ENODEV) @@ -941,6 +1020,13 @@ int nl_gset(struct cmd_context *ctx) =20 ret =3D gset_request(nlctx, ETHTOOL_MSG_LINKSTATE_GET, ETHTOOL_A_LINKSTATE_HEADER, linkstate_reply_cb); + + if (ret =3D=3D -ENODEV) + return ret; + + + ret =3D gset_request(nlctx, ETHTOOL_MSG_PLCA_GET_STATUS, + ETHTOOL_A_PLCA_HEADER, plca_status_reply_cb); if (ret =3D=3D -ENODEV) return ret; =20 @@ -949,7 +1035,6 @@ int nl_gset(struct cmd_context *ctx) return 75; } =20 - return 0; } =20 --=20 2.37.4