Skip to contentSkip to conversation

Extend uAPI with lanes parameter

PATCH In review Danielle Ratson 2 participants 7 messages Feb 10, 2021 – Feb 14, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover Extend uAPI with lanes parameter

Currently, there is no way of knowing how many lanes will be use to achieve a wanted speed.
For example, 100G speed can be achieved using: 2X50 or 4X25.

In order to solve that, extend ethtool uAPI with lanes as a new link mode setting so the command below, for example, will be supported:

$ ethtool -s swp5 lanes N

Patch #1: Update headers with the new parameter.
Patch #2: Support lanes in netlink.
Patch #3: Expose the number of lanes in use.
Patch #4: Add auto-completion for lanes.
Patch #5: Add lanes to man page.

v3:
* Add a seperated patch, patch #1, for uapi headers and squash
* the rest of it to patch #2.

Danielle Ratson (5):
update UAPI header copies
netlink: settings: Add netlink support for lanes parameter
netlink: settings: Expose the number of lanes in use
shell-completion: Add completion for lanes
man: Add man page for setting lanes parameter

 ethtool.8.in                  |  4 ++++
 ethtool.c                     |  1 +
 netlink/desc-ethtool.c        |  1 +
 netlink/settings.c            | 13 +++++++++++++
 shell-completion/bash/ethtool |  4 ++++
 uapi/linux/ethtool.h          |  2 +-
 uapi/linux/ethtool_netlink.h  |  1 +
 uapi/linux/if_link.h          | 10 ++++++++--
 uapi/linux/netlink.h          |  2 +-
 uapi/linux/rtnetlink.h        | 20 +++++++++++++++-----
 10 files changed, 49 insertions(+), 9 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH v3 1/5 update UAPI header copies

Update to kernel commit 012ce4dd3102.

---
 uapi/linux/ethtool.h         |  2 +-
 uapi/linux/ethtool_netlink.h |  1 +
 uapi/linux/if_link.h         | 10 ++++++++--
 uapi/linux/netlink.h         |  2 +-
 uapi/linux/rtnetlink.h       | 20 +++++++++++++++-----
 5 files changed, 26 insertions(+), 9 deletions(-)
uapi/linux/ethtool.h +1 -1
index 052689b..a951137 100644
@@ -14,7 +14,7 @@
 #ifndef _LINUX_ETHTOOL_H
 #define _LINUX_ETHTOOL_H
 
-#include <linux/kernel.h>
+#include <linux/const.h>
 #include <linux/types.h>
 #include <linux/if_ether.h>
 
uapi/linux/ethtool_netlink.h +1 -0
index c022883..0cd6906 100644
@@ -227,6 +227,7 @@ enum {
 	ETHTOOL_A_LINKMODES_DUPLEX,		/* u8 */
 	ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG,	/* u8 */
 	ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE,	/* u8 */
+	ETHTOOL_A_LINKMODES_LANES,		/* u32 */
 
 	/* add new constants above here */
 	__ETHTOOL_A_LINKMODES_CNT,
uapi/linux/if_link.h +8 -2
index 307e5c2..c96880c 100644
@@ -75,8 +75,9 @@ struct rtnl_link_stats {
  *
  * @rx_dropped: Number of packets received but not processed,
  *   e.g. due to lack of resources or unsupported protocol.
- *   For hardware interfaces this counter should not include packets
- *   dropped by the device which are counted separately in
+ *   For hardware interfaces this counter may include packets discarded
+ *   due to L2 address filtering but should not include packets dropped
+ *   by the device due to buffer exhaustion which are counted separately in
  *   @rx_missed_errors (since procfs folds those two counters together).
  *
  * @tx_dropped: Number of packets dropped on their way to transmission,
@@ -522,6 +523,8 @@ enum {
 	IFLA_BRPORT_BACKUP_PORT,
 	IFLA_BRPORT_MRP_RING_OPEN,
 	IFLA_BRPORT_MRP_IN_OPEN,
+	IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
+	IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
 	__IFLA_BRPORT_MAX
 };
 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
@@ -586,6 +589,8 @@ enum {
 	IFLA_MACVLAN_MACADDR,
 	IFLA_MACVLAN_MACADDR_DATA,
 	IFLA_MACVLAN_MACADDR_COUNT,
+	IFLA_MACVLAN_BC_QUEUE_LEN,
+	IFLA_MACVLAN_BC_QUEUE_LEN_USED,
 	__IFLA_MACVLAN_MAX,
 };
 
@@ -804,6 +809,7 @@ enum {
 	IFLA_GTP_FD1,
 	IFLA_GTP_PDP_HASHSIZE,
 	IFLA_GTP_ROLE,
+	IFLA_GTP_COLLECT_METADATA,
 	__IFLA_GTP_MAX,
 };
 #define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)
uapi/linux/netlink.h +1 -1
index dfef006..5024c54 100644
@@ -2,7 +2,7 @@
 #ifndef __LINUX_NETLINK_H
 #define __LINUX_NETLINK_H
 
-#include <linux/kernel.h>
+#include <linux/const.h>
 #include <linux/socket.h> /* for __kernel_sa_family_t */
 #include <linux/types.h>
 
uapi/linux/rtnetlink.h +15 -5
index 5ad84e6..c66fd24 100644
@@ -396,11 +396,13 @@ struct rtnexthop {
 #define RTNH_F_DEAD		1	/* Nexthop is dead (used by multipath)	*/
 #define RTNH_F_PERVASIVE	2	/* Do recursive gateway lookup	*/
 #define RTNH_F_ONLINK		4	/* Gateway is forced on link	*/
-#define RTNH_F_OFFLOAD		8	/* offloaded route */
+#define RTNH_F_OFFLOAD		8	/* Nexthop is offloaded */
 #define RTNH_F_LINKDOWN		16	/* carrier-down on nexthop */
 #define RTNH_F_UNRESOLVED	32	/* The entry is unresolved (ipmr) */
+#define RTNH_F_TRAP		64	/* Nexthop is trapping packets */
 
-#define RTNH_COMPARE_MASK	(RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD)
+#define RTNH_COMPARE_MASK	(RTNH_F_DEAD | RTNH_F_LINKDOWN | \
+				 RTNH_F_OFFLOAD | RTNH_F_TRAP)
 
 /* Macros to handle hexthops */
 
@@ -764,12 +766,18 @@ enum {
 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
 /* tcamsg flags stored in attribute TCA_ROOT_FLAGS
  *
- * TCA_FLAG_LARGE_DUMP_ON user->kernel to request for larger than TCA_ACT_MAX_PRIO
- * actions in a dump. All dump responses will contain the number of actions
- * being dumped stored in for user app's consumption in TCA_ROOT_COUNT
+ * TCA_ACT_FLAG_LARGE_DUMP_ON user->kernel to request for larger than
+ * TCA_ACT_MAX_PRIO actions in a dump. All dump responses will contain the
+ * number of actions being dumped stored in for user app's consumption in
+ * TCA_ROOT_COUNT
+ *
+ * TCA_ACT_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only
+ * includes essential action info (kind, index, etc.)
  *
  */
 #define TCA_FLAG_LARGE_DUMP_ON		(1 << 0)
+#define TCA_ACT_FLAG_LARGE_DUMP_ON	TCA_FLAG_LARGE_DUMP_ON
+#define TCA_ACT_FLAG_TERSE_DUMP		(1 << 1)
 
 /* New extended info filters for IFLA_EXT_MASK */
 #define RTEXT_FILTER_VF		(1 << 0)
@@ -777,6 +785,8 @@ enum {
 #define RTEXT_FILTER_BRVLAN_COMPRESSED	(1 << 2)
 #define	RTEXT_FILTER_SKIP_STATS	(1 << 3)
 #define RTEXT_FILTER_MRP	(1 << 4)
+#define RTEXT_FILTER_CFM_CONFIG	(1 << 5)
+#define RTEXT_FILTER_CFM_STATUS	(1 << 6)
 
 /* End of information exported to user level */
 
Signature · 1 line
2.26.2
#2 lore raw

PATCH v3 2/5 netlink: settings: Add netlink support for lanes parameter

In reply to Danielle Ratson

From: Danielle Ratson <[email protected]>

Add support for "ethtool -s <dev> lanes N ..." for setting a specific number of lanes.

---

Notes:
v3:
* Remove a leftover.
* After adding a seperated patch for uapi headers, squash rest of the first patch.

 ethtool.c              | 1 +
 netlink/desc-ethtool.c | 1 +
 netlink/settings.c     | 7 +++++++
 3 files changed, 9 insertions(+)
ethtool.c +1 -0
index fb90e9e..a8339c8 100644
@@ -5620,6 +5620,7 @@ static const struct option args[] = {
 		.nlfunc	= nl_sset,
 		.help	= "Change generic options",
 		.xhelp	= "		[ speed %d ]\n"
+			  "		[ lanes %d ]\n"
 			  "		[ duplex half|full ]\n"
 			  "		[ port tp|aui|bnc|mii|fibre|da ]\n"
 			  "		[ mdix auto|on|off ]\n"
netlink/desc-ethtool.c +1 -0
index 96291b9..fe5d7ba 100644
@@ -87,6 +87,7 @@ static const struct pretty_nla_desc __linkmodes_desc[] = {
 	NLATTR_DESC_U8(ETHTOOL_A_LINKMODES_DUPLEX),
 	NLATTR_DESC_U8(ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG),
 	NLATTR_DESC_U8(ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE),
+	NLATTR_DESC_U32(ETHTOOL_A_LINKMODES_LANES),
 };
 
 static const struct pretty_nla_desc __linkstate_desc[] = {
netlink/settings.c +7 -0
index 90c28b1..c54fe56 100644
@@ -1067,6 +1067,13 @@ static const struct param_parser sset_params[] = {
 		.handler	= nl_parse_direct_u32,
 		.min_argc	= 1,
 	},
+	{
+		.arg		= "lanes",
+		.group		= ETHTOOL_MSG_LINKMODES_SET,
+		.type		= ETHTOOL_A_LINKMODES_LANES,
+		.handler	= nl_parse_direct_u32,
+		.min_argc	= 1,
+	},
 	{
 		.arg		= "duplex",
 		.group		= ETHTOOL_MSG_LINKMODES_SET,
Signature · 1 line
2.26.2
#5 lore raw

PATCH v3 5/5 man: Add man page for setting lanes parameter

In reply to Danielle Ratson

Lanes parameter was added for setting using ethtool.

Update the man page to include the new parameter.

---
 ethtool.8.in | 4 ++++
 1 file changed, 4 insertions(+)
ethtool.8.in +4 -0
index ba4e245..fe49b66 100644
@@ -251,6 +251,7 @@ ethtool \- query or control network driver and hardware settings
 .B ethtool \-s
 .I devname
 .BN speed
+.BN lanes
 .B2 duplex half full
 .B4 port tp aui bnc mii fibre da
 .B3 mdix auto on off
@@ -685,6 +686,9 @@ Set speed in Mb/s.
 .B ethtool
 with just the device name as an argument will show you the supported device speeds.
 .TP
+.BI lanes \ N
+Set number of lanes.
+.TP
 .A2 duplex half full
 Sets full or half duplex mode.
 .TP
Signature · 1 line
2.26.2
#3 lore raw

PATCH v3 3/5 netlink: settings: Expose the number of lanes in use

In reply to Danielle Ratson

Currently, the user does not have the information regarding how many lanes are used when the link is up.

After adding a possibility to advertise or force a specific number of lanes this information becomes helpful.

Expose the number of lanes in use if the information is passed from kernel.

---

Notes:
v2:
* Remove possibility for printing unknown lanes, as now unknown lanes attribute doesn't pass to netlink.

 netlink/settings.c | 6 ++++++
 1 file changed, 6 insertions(+)
netlink/settings.c +6 -0
index c54fe56..e47a38f 100644
@@ -473,6 +473,12 @@ int linkmodes_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		else
 			printf("\tSpeed: %uMb/s\n", val);
 	}
+	if (tb[ETHTOOL_A_LINKMODES_LANES]) {
+		uint32_t val = mnl_attr_get_u32(tb[ETHTOOL_A_LINKMODES_LANES]);
+
+		print_banner(nlctx);
+		printf("\tLanes: %u\n", val);
+	}
 	if (tb[ETHTOOL_A_LINKMODES_DUPLEX]) {
 		uint8_t val = mnl_attr_get_u8(tb[ETHTOOL_A_LINKMODES_DUPLEX]);
 
Signature · 1 line
2.26.2
#4 lore raw

PATCH v3 4/5 shell-completion: Add completion for lanes

In reply to Danielle Ratson

From: Danielle Ratson <[email protected]>

Lanes was added as a new link mode setting in ethtool.

Support completion for lanes when setting parameters.

---
 shell-completion/bash/ethtool | 4 ++++
 1 file changed, 4 insertions(+)
shell-completion/bash/ethtool +4 -0
index 5305559..4557341 100644
@@ -97,6 +97,7 @@ _ethtool_change()
 		[speed]=notseen
 		[wol]=notseen
 		[xcvr]=notseen
+		[lanes]=notseen
 	)
 
 	local -A msgtypes=(
@@ -175,6 +176,9 @@ _ethtool_change()
 		xcvr)
 			COMPREPLY=( $( compgen -W 'internal external' -- "$cur" ) )
 			return ;;
+		lanes)
+			# Number
+			return ;;
 	esac
 
 	local -a comp_words=()
Signature · 1 line
2.26.2
#6 lore raw
In reply to Danielle Ratson
Quoted 14 lines · Danielle Ratson

Currently, there is no way of knowing how many lanes will be use to achieve a wanted speed.
For example, 100G speed can be achieved using: 2X50 or 4X25.

In order to solve that, extend ethtool uAPI with lanes as a new link mode setting so the command below, for example, will be supported:

$ ethtool -s swp5 lanes N

Patch #1: Update headers with the new parameter.
Patch #2: Support lanes in netlink.
Patch #3: Expose the number of lanes in use.
Patch #4: Add auto-completion for lanes.
Patch #5: Add lanes to man page.

Quoted 3 lines

v3:
* Add a seperated patch, patch #1, for uapi headers and squash
* the rest of it to patch #2.

Series applied, thank you.

Michal

Quoted 23 lines

Danielle Ratson (5):
update UAPI header copies
netlink: settings: Add netlink support for lanes parameter
netlink: settings: Expose the number of lanes in use
shell-completion: Add completion for lanes
man: Add man page for setting lanes parameter

 ethtool.8.in                  |  4 ++++
 ethtool.c                     |  1 +
 netlink/desc-ethtool.c        |  1 +
 netlink/settings.c            | 13 +++++++++++++
 shell-completion/bash/ethtool |  4 ++++
 uapi/linux/ethtool.h          |  2 +-
 uapi/linux/ethtool_netlink.h  |  1 +
 uapi/linux/if_link.h          | 10 ++++++++--
 uapi/linux/netlink.h          |  2 +-
 uapi/linux/rtnetlink.h        | 20 +++++++++++++++-----
 10 files changed, 49 insertions(+), 9 deletions(-)
Signature · 1 line
2.26.2