Skip to contentSkip to conversation

add support for PLCA RS

PATCH Superseded Piergiorgio Beruto 2 participants 5 messages Dec 17, 2022 – Feb 2, 2023

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover add support for PLCA RS

This patch adds support for the IEEE802.3cg-2019 Clause 148 PLCA Reconciliation Sublayer. It adds get/set configuration and get status functions. Additionally, shows PLCA capabilities and status when invoked without arguments.

Piergiorgio Beruto (2):
update UAPI header copies
add support for IEEE 802.3cg-2019 Clause 148 - PLCA RS

 Makefile.am                  |   1 +
 ethtool.c                    |  21 +++
 netlink/extapi.h             |   6 +
 netlink/plca.c               | 295 +++++++++++++++++++++++++++++++++++
 netlink/settings.c           |  86 +++++++++-
 uapi/linux/ethtool.h         |   3 +
 uapi/linux/ethtool_netlink.h |  39 +++++
 uapi/linux/net_tstamp.h      |   3 +-
 8 files changed, 451 insertions(+), 3 deletions(-)
 create mode 100644 netlink/plca.c
Signature · 1 line
2.37.4
#1 lore raw

PATCH v4 1/2 update UAPI header copies

Update to kernel commit 5518b1e55dcd.

---
 uapi/linux/ethtool.h         |  3 +++
 uapi/linux/ethtool_netlink.h | 39 ++++++++++++++++++++++++++++++++++++
 uapi/linux/net_tstamp.h      |  3 ++-
 3 files changed, 44 insertions(+), 1 deletion(-)
uapi/linux/ethtool.h +3 -0
index d1748702bddc..78bf6fad9e02 100644
@@ -1739,6 +1739,9 @@ enum ethtool_link_mode_bit_indices {
 	ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT	 = 96,
 	ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT	 = 97,
 	ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT	 = 98,
+	ETHTOOL_LINK_MODE_10baseT1S_Full_BIT		 = 99,
+	ETHTOOL_LINK_MODE_10baseT1S_Half_BIT		 = 100,
+	ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT	 = 101,
 
 	/* must be last entry */
 	__ETHTOOL_LINK_MODE_MASK_NBITS
uapi/linux/ethtool_netlink.h +39 -0
index d581c43d592d..a6d899cd7f3a 100644
@@ -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,
 
 	/* 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,
 
 	/* add new constants above here */
 	__ETHTOOL_MSG_KERNEL_CNT,
@@ -880,6 +888,37 @@ enum {
 	ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
 };
 
+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 = (__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,			/* u8  */
+	ETHTOOL_A_PLCA_STATUS,			/* u8  */
+	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 = (__ETHTOOL_A_PLCA_CNT - 1)
+};
+
 /* generic netlink info */
 #define ETHTOOL_GENL_NAME "ethtool"
 #define ETHTOOL_GENL_VERSION 1
uapi/linux/net_tstamp.h +2 -1
index 55501e5e7ac8..a2c66b3d7f0f 100644
@@ -31,8 +31,9 @@ enum {
 	SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),
 	SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14),
 	SOF_TIMESTAMPING_BIND_PHC = (1 << 15),
+	SOF_TIMESTAMPING_OPT_ID_TCP = (1 << 16),
 
-	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_BIND_PHC,
+	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_ID_TCP,
 	SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
 				 SOF_TIMESTAMPING_LAST
 };
Signature · 1 line
2.37.4
#2 lore raw

PATCH v4 2/2 add support for IEEE 802.3cg-2019 Clause 148 - PLCA RS

In reply to Piergiorgio Beruto

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

---
 Makefile.am        |   1 +
 ethtool.c          |  21 ++++
 netlink/extapi.h   |   6 +
 netlink/plca.c     | 295 +++++++++++++++++++++++++++++++++++++++++++++
 netlink/settings.c |  86 ++++++++++++-
 5 files changed, 407 insertions(+), 2 deletions(-)
 create mode 100644 netlink/plca.c
Makefile.am +1 -0
index fcc912edd7e4..b184b8ceb28a 100644
@@ -41,6 +41,7 @@ ethtool_SOURCES += \
 		  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
ethtool.c +21 -0
index 3207e49137c4..d23406f54a37 100644
@@ -6075,6 +6075,27 @@ static const struct option args[] = {
 		.help	= "Set transceiver module settings",
 		.xhelp	= "		[ power-mode-policy high|auto ]\n"
 	},
+	{
+		.opts	= "--get-plca-cfg",
+		.nlfunc	= nl_plca_get_cfg,
+		.help	= "Get PLCA configuration",
+	},
+	{
+		.opts	= "--set-plca-cfg",
+		.nlfunc	= nl_plca_set_cfg,
+		.help	= "Set PLCA configuration",
+		.xhelp  = "             [ 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	= "--get-plca-status",
+		.nlfunc	= nl_plca_get_status,
+		.help	= "Get PLCA status information",
+	},
 	{
 		.opts	= "-h|--help",
 		.no_dev	= true,
netlink/extapi.h +6 -0
index 1bb580a889a8..0add156e644a 100644
@@ -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);
 
 void nl_monitor_usage(void);
 
@@ -114,6 +117,9 @@ nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused,
 #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
 
 #endif /* ETHTOOL_ENABLE_NETLINK */
 
netlink/plca.c new file +295 -0

295 lines not on this page · raw message

netlink/settings.c +84 -2

122 lines not on this page · raw message

Signature · 1 line
2.37.4
#3 lore raw

Re: [PATCH v4 ethtool-next 2/2] add support for IEEE 802.3cg-2019 Clause 148 - PLCA RS

Quoted 10 lines · Piergiorgio Beruto

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

Quoted 7 lines
---
 Makefile.am        |   1 +
 ethtool.c          |  21 ++++
 netlink/extapi.h   |   6 +
 netlink/plca.c     | 295 +++++++++++++++++++++++++++++++++++++++++++++
 netlink/settings.c |  86 ++++++++++++-

Please update also the manual page (ethtool.8.in), this should be done whenever adding a new feature so that documented and implemented features don't diverge.

[...]

Quoted 4 lines
netlink/extapi.h +0 -0
index 1bb580a889a8..0add156e644a 100644

[...]

netlink/extapi.h nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused, · line 125

Quoted 10 lines
netlink/extapi.h +3 -0
@@ -114,6 +117,9 @@ nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused,
 #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
 
 #endif /* ETHTOOL_ENABLE_NETLINK */
 

The function names are misspelled here so that a build with --disable-netlink fails.

[...]

Quoted 24 lines
netlink/plca.c new file +18 -0
new file mode 100644
index 000000000000..f7d7bdbc5c84
@@ -0,0 +1,295 @@
+/*
+ * plca.c - netlink implementation of plca command
+ *
+ * Implementation of "ethtool --show-plca <dev>" and
+ * "ethtool --set-plca <dev> ..."
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "../internal.h"
+#include "../common.h"
+#include "netlink.h"
+#include "bitset.h"
+#include "parser.h"
+
+/* PLCA_GET_CFG */

[...]

Quoted 9 lines
netlink/plca.c new file +9 -0
+int plca_get_cfg_reply_cb(const struct nlmsghdr *nlhdr, void *data)
+{
+	const struct nlattr *tb[ETHTOOL_A_PLCA_MAX + 1] = {};
+	DECLARE_ATTR_TB_INFO(tb);
+	struct nl_context *nlctx = data;
+	bool silent;
+	int idv, val;
+	int err_ret;
+	int ret;

[...]

netlink/plca.c line 82

Quoted 6 lines
netlink/plca.c new file +6 -0
+		// 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 != 0)
+			printf(" (ignored)");

The compiler warns that idv may be uninitialized here. While it's in wrong, AFAICS, not even gcc13 is smart enough to recognize that it's not actually possible so let's initialize the variable to make it happy. Also, both idv and val are used to store unsigned values so they should be unsigned int.

Other than these, the patch looks good to me. The next branch already has the UAPI updates needed for it so patch 1 won't be needed any more if you rebase on top of current next.

Michal

#4 lore raw

Re: [PATCH v4 ethtool-next 2/2] add support for IEEE 802.3cg-2019 Clause 148 - PLCA RS

Quoted 19 lines · Michal Kubecek
Quoted 10 lines · Piergiorgio Beruto

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

Quoted 7 lines
---
 Makefile.am        |   1 +
 ethtool.c          |  21 ++++
 netlink/extapi.h   |   6 +
 netlink/plca.c     | 295 +++++++++++++++++++++++++++++++++++++++++++++
 netlink/settings.c |  86 ++++++++++++-
Quoted 3 lines

Please update also the manual page (ethtool.8.in), this should be done whenever adding a new feature so that documented and implemented features don't diverge.

I wrote the required text, please have a look and see it's ok!

Quoted 15 lines

[...]

Quoted 4 lines
netlink/extapi.h +0 -0
index 1bb580a889a8..0add156e644a 100644

[...]

Quoted 8 lines
netlink/extapi.h +3 -0
@@ -114,6 +117,9 @@ nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused,
 #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
 
Quoted 5 lines

netlink/extapi.h nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused, · line 125

Quoted 2 lines
netlink/extapi.h +0 -0
 #endif /* ETHTOOL_ENABLE_NETLINK */
 

The function names are misspelled here so that a build with --disable-netlink fails.

Ok, sorry about that. I've fixed the problem and tested with --disable-netlink. Should be OK now.

Quoted 50 lines

[...]

Quoted 24 lines
netlink/plca.c new file +18 -0
new file mode 100644
index 000000000000..f7d7bdbc5c84
@@ -0,0 +1,295 @@
+/*
+ * plca.c - netlink implementation of plca command
+ *
+ * Implementation of "ethtool --show-plca <dev>" and
+ * "ethtool --set-plca <dev> ..."
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "../internal.h"
+#include "../common.h"
+#include "netlink.h"
+#include "bitset.h"
+#include "parser.h"
+
+/* PLCA_GET_CFG */

[...]

Quoted 9 lines
netlink/plca.c new file +9 -0
+int plca_get_cfg_reply_cb(const struct nlmsghdr *nlhdr, void *data)
+{
+	const struct nlattr *tb[ETHTOOL_A_PLCA_MAX + 1] = {};
+	DECLARE_ATTR_TB_INFO(tb);
+	struct nl_context *nlctx = data;
+	bool silent;
+	int idv, val;
+	int err_ret;
+	int ret;

[...]

netlink/plca.c line 82

Quoted 6 lines
netlink/plca.c new file +6 -0
+		// 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 != 0)
+			printf(" (ignored)");

The compiler warns that idv may be uninitialized here. While it's in wrong, AFAICS, not even gcc13 is smart enough to recognize that it's not actually possible so let's initialize the variable to make it happy. Also, both idv and val are used to store unsigned values so they should be unsigned int.

Quoted 5 lines

Other than these, the patch looks good to me. The next branch already has the UAPI updates needed for it so patch 1 won't be needed any more if you rebase on top of current next.

Michal

Thanks,
Piergiorgio