Skip to contentSkip to conversation

ethtool: Add support for frame preemption

PATCH In review Vinicius Costa Gomes 4 participants 27 messages Dec 2, 2020 – Dec 8, 2020

Subsystems (6)
lore
Share & tools
lore

Vinicius Costa Gomes

author maintainer
#0 lore raw

cover ethtool: Add support for frame preemption

Hi,

Changes from RFC v2:
- Reorganised the offload enabling/disabling on the driver size;
- Added a few igc fixes;

Changes from RFC v1:
- The per-queue preemptible/express setting is moved to applicable qdiscs (Jakub Kicinski and others);
- "min-frag-size" now follows the 802.3br specification more closely, it's expressed as X in '64(1 + X) + 4' (Joergen Andreasen);

Another point that should be noted is the addition of the TC_SETUP_PREEMPT offload type, the idea behind this is to allow other qdiscs (was thinking of mqprio) to also configure which queues should be marked as express/preemptible.

Original cover letter:

This is still an RFC because two main reasons, I want to confirm that this approach (per-queue settings via qdiscs, device settings via ethtool) looks good, even though there aren't much more options left ;-) The other reason is that while testing this I found some weirdness in the driver that I would need a bit more time to investigate.

(In case these patches are not enough to give an idea of how things work, I can send the userspace patches, of course.)

The idea of this "hybrid" approach is that applications/users would do the following steps to configure frame preemption:

$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
      num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
      queues 1 at 0 1 at 1 2 at 2 \
      base-time $BASE_TIME \
      sched-entry S 0f 10000000 \
      preempt 1110 \
      flags 0x2 

The "preempt" parameter is the only difference, it configures which queues are marked as preemptible, in this example, queue 0 is marked as "not preemptible", so it is express, the rest of the four queues are preemptible.

The next step, of this example, would be to enable frame preemption in the device, via ethtool, and set the minimum fragment size to 2:

$ sudo ./ethtool --set-frame-preemption $IFACE fp on min-frag-size 2

Cheers,

Vinicius Costa Gomes (9):
ethtool: Add support for configuring frame preemption
taprio: Add support for frame preemption offload
igc: Set the RX packet buffer size for TSN mode
igc: Only dump registers if configured to dump HW information
igc: Avoid TX Hangs because long cycles
igc: Add support for tuning frame preemption via ethtool
igc: Add support for Frame Preemption offload
igc: Add support for exposing frame preemption stats registers
igc: Separate TSN configurations that can be updated

 drivers/net/ethernet/intel/igc/igc.h         |  10 ++
 drivers/net/ethernet/intel/igc/igc_defines.h |   6 +
 drivers/net/ethernet/intel/igc/igc_dump.c    |   3 +
 drivers/net/ethernet/intel/igc/igc_ethtool.c |  63 ++++++++
 drivers/net/ethernet/intel/igc/igc_main.c    |  31 +++-
 drivers/net/ethernet/intel/igc/igc_regs.h    |  10 ++
 drivers/net/ethernet/intel/igc/igc_tsn.c     | 158 ++++++++++++++-----
 drivers/net/ethernet/intel/igc/igc_tsn.h     |   1 +
 include/linux/ethtool.h                      |  19 +++
 include/linux/netdevice.h                    |   1 +
 include/net/pkt_sched.h                      |   4 +
 include/uapi/linux/ethtool_netlink.h         |  17 ++
 include/uapi/linux/pkt_sched.h               |   1 +
 net/ethtool/Makefile                         |   2 +-
 net/ethtool/netlink.c                        |  19 +++
 net/ethtool/netlink.h                        |   4 +
 net/ethtool/preempt.c                        | 151 ++++++++++++++++++
 net/sched/sch_taprio.c                       |  41 ++++-
 18 files changed, 491 insertions(+), 50 deletions(-)
 create mode 100644 net/ethtool/preempt.c
Signature · 1 line
2.29.2
author maintainer
#1 lore raw

PATCH 1/9 ethtool: Add support for configuring frame preemption

Frame preemption (described in IEEE 802.3br-2016) defines the concept of preemptible and express queues. It allows traffic from express queues to "interrupt" traffic from preemptible queues, which are "resumed" after the express traffic has finished transmitting.

Frame preemption can only be used when both the local device and the link partner support it.

Only parameters for enabling/disabling frame preemption and configuring the minimum fragment size are included here. Expressing which queues are marked as preemptible is left to mqprio/taprio, as having that information there should be easier on the user.

---
 include/linux/ethtool.h              |  19 ++++
 include/uapi/linux/ethtool_netlink.h |  17 +++
 net/ethtool/Makefile                 |   2 +-
 net/ethtool/netlink.c                |  19 ++++
 net/ethtool/netlink.h                |   4 +
 net/ethtool/preempt.c                | 151 +++++++++++++++++++++++++++
 6 files changed, 211 insertions(+), 1 deletion(-)
 create mode 100644 net/ethtool/preempt.c
include/linux/ethtool.h +19 -0
index e3da25b51ae4..16d6ee29a6ac 100644
@@ -263,6 +263,19 @@ struct ethtool_pause_stats {
 	u64 rx_pause_frames;
 };
 
+/**
+ * struct ethtool_fp - Frame Preemption information
+ *
+ * @enabled: Enable frame preemption.
+ *
+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'
+ */
+struct ethtool_fp {
+	u8 enabled;
+	u8 min_frag_size_mult;
+};
+
 /**
  * struct ethtool_ops - optional netdev operations
  * @supported_coalesce_params: supported types of interrupt coalescing.
@@ -406,6 +419,8 @@ struct ethtool_pause_stats {
  * @get_ethtool_phy_stats: Return extended statistics about the PHY device.
  *	This is only useful if the device maintains PHY statistics and
  *	cannot use the standard PHY library helpers.
+ * @get_preempt: Get the network device Frame Preemption parameters.
+ * @set_preempt: Set the network device Frame Preemption parameters.
  *
  * All operations are optional (i.e. the function pointer may be set
  * to %NULL) and callers must take this into account.  Callers must
@@ -504,6 +519,10 @@ struct ethtool_ops {
 				      struct ethtool_fecparam *);
 	int	(*set_fecparam)(struct net_device *,
 				      struct ethtool_fecparam *);
+	int	(*get_preempt)(struct net_device *,
+			       struct ethtool_fp *);
+	int	(*set_preempt)(struct net_device *,
+			       struct ethtool_fp *);
 	void	(*get_ethtool_phy_stats)(struct net_device *,
 					 struct ethtool_stats *, u64 *);
 	int	(*get_phy_tunable)(struct net_device *,
include/uapi/linux/ethtool_netlink.h +17 -0
index e2bf36e6964b..0b3dc0c263a9 100644
@@ -42,6 +42,8 @@ enum {
 	ETHTOOL_MSG_CABLE_TEST_ACT,
 	ETHTOOL_MSG_CABLE_TEST_TDR_ACT,
 	ETHTOOL_MSG_TUNNEL_INFO_GET,
+	ETHTOOL_MSG_PREEMPT_GET,
+	ETHTOOL_MSG_PREEMPT_SET,
 
 	/* add new constants above here */
 	__ETHTOOL_MSG_USER_CNT,
@@ -80,6 +82,8 @@ enum {
 	ETHTOOL_MSG_CABLE_TEST_NTF,
 	ETHTOOL_MSG_CABLE_TEST_TDR_NTF,
 	ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY,
+	ETHTOOL_MSG_PREEMPT_GET_REPLY,
+	ETHTOOL_MSG_PREEMPT_NTF,
 
 	/* add new constants above here */
 	__ETHTOOL_MSG_KERNEL_CNT,
@@ -628,6 +632,19 @@ enum {
 	ETHTOOL_A_TUNNEL_INFO_MAX = (__ETHTOOL_A_TUNNEL_INFO_CNT - 1)
 };
 
+/* FRAME PREEMPTION */
+
+enum {
+	ETHTOOL_A_PREEMPT_UNSPEC,
+	ETHTOOL_A_PREEMPT_HEADER,			/* nest - _A_HEADER_* */
+	ETHTOOL_A_PREEMPT_ENABLED,			/* u8 */
+	ETHTOOL_A_PREEMPT_MIN_FRAG_SIZE_MULT,		/* u8 */
+
+	/* add new constants above here */
+	__ETHTOOL_A_PREEMPT_CNT,
+	ETHTOOL_A_PREEMPT_MAX = (__ETHTOOL_A_PREEMPT_CNT - 1)
+};
+
 /* generic netlink info */
 #define ETHTOOL_GENL_NAME "ethtool"
 #define ETHTOOL_GENL_VERSION 1
net/ethtool/Makefile +1 -1
index 7a849ff22dad..4e584903e3ef 100644
@@ -7,4 +7,4 @@ obj-$(CONFIG_ETHTOOL_NETLINK)	+= ethtool_nl.o
 ethtool_nl-y	:= netlink.o bitset.o strset.o linkinfo.o linkmodes.o \
 		   linkstate.o debug.o wol.o features.o privflags.o rings.o \
 		   channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \
-		   tunnels.o
+		   tunnels.o preempt.o
net/ethtool/netlink.c +19 -0
index 50d3c8896f91..bc7d66e3ba38 100644
@@ -245,6 +245,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = {
 	[ETHTOOL_MSG_PAUSE_GET]		= &ethnl_pause_request_ops,
 	[ETHTOOL_MSG_EEE_GET]		= &ethnl_eee_request_ops,
 	[ETHTOOL_MSG_TSINFO_GET]	= &ethnl_tsinfo_request_ops,
+	[ETHTOOL_MSG_PREEMPT_GET]	= &ethnl_preempt_request_ops,
 };
 
 static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb)
@@ -551,6 +552,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
 	[ETHTOOL_MSG_COALESCE_NTF]	= &ethnl_coalesce_request_ops,
 	[ETHTOOL_MSG_PAUSE_NTF]		= &ethnl_pause_request_ops,
 	[ETHTOOL_MSG_EEE_NTF]		= &ethnl_eee_request_ops,
+	[ETHTOOL_MSG_PREEMPT_NTF]	= &ethnl_preempt_request_ops,
 };
 
 /* default notification handler */
@@ -643,6 +645,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
 	[ETHTOOL_MSG_COALESCE_NTF]	= ethnl_default_notify,
 	[ETHTOOL_MSG_PAUSE_NTF]		= ethnl_default_notify,
 	[ETHTOOL_MSG_EEE_NTF]		= ethnl_default_notify,
+	[ETHTOOL_MSG_PREEMPT_NTF]	= ethnl_default_notify,
 };
 
 void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
@@ -912,6 +915,22 @@ static const struct genl_ops ethtool_genl_ops[] = {
 		.policy = ethnl_tunnel_info_get_policy,
 		.maxattr = ARRAY_SIZE(ethnl_tunnel_info_get_policy) - 1,
 	},
+	{
+		.cmd	= ETHTOOL_MSG_PREEMPT_GET,
+		.doit	= ethnl_default_doit,
+		.start	= ethnl_default_start,
+		.dumpit	= ethnl_default_dumpit,
+		.done	= ethnl_default_done,
+		.policy = ethnl_preempt_get_policy,
+		.maxattr = ARRAY_SIZE(ethnl_preempt_get_policy) - 1,
+	},
+	{
+		.cmd	= ETHTOOL_MSG_PREEMPT_SET,
+		.flags	= GENL_UNS_ADMIN_PERM,
+		.doit	= ethnl_set_preempt,
+		.policy = ethnl_preempt_set_policy,
+		.maxattr = ARRAY_SIZE(ethnl_preempt_set_policy) - 1,
+	},
 };
 
 static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
net/ethtool/netlink.h +4 -0
index d8efec516d86..8f65e53ccd59 100644
@@ -344,6 +344,7 @@ extern const struct ethnl_request_ops ethnl_coalesce_request_ops;
 extern const struct ethnl_request_ops ethnl_pause_request_ops;
 extern const struct ethnl_request_ops ethnl_eee_request_ops;
 extern const struct ethnl_request_ops ethnl_tsinfo_request_ops;
+extern const struct ethnl_request_ops ethnl_preempt_request_ops;
 
 extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1];
 extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1];
@@ -375,6 +376,8 @@ extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER +
 extern const struct nla_policy ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_HEADER + 1];
 extern const struct nla_policy ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG + 1];
 extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_HEADER + 1];
+extern const struct nla_policy ethnl_preempt_get_policy[ETHTOOL_A_PREEMPT_MAX + 1];
+extern const struct nla_policy ethnl_preempt_set_policy[ETHTOOL_A_PREEMPT_MAX + 1];
 
 int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info);
 int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info);
@@ -392,5 +395,6 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info);
 int ethnl_tunnel_info_doit(struct sk_buff *skb, struct genl_info *info);
 int ethnl_tunnel_info_start(struct netlink_callback *cb);
 int ethnl_tunnel_info_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
+int ethnl_set_preempt(struct sk_buff *skb, struct genl_info *info);
 
 #endif /* _NET_ETHTOOL_NETLINK_H */
net/ethtool/preempt.c new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
2.29.2
maintainer
#2 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

Quoted 8 lines · On Tue, 1 Dec 2020 20:53:17 -0800 Vinicius Costa Gomes wrote:

Frame preemption (described in IEEE 802.3br-2016) defines the concept of preemptible and express queues. It allows traffic from express queues to "interrupt" traffic from preemptible queues, which are "resumed" after the express traffic has finished transmitting.

Frame preemption can only be used when both the local device and the link partner support it.

Quoted 6 lines

Only parameters for enabling/disabling frame preemption and configuring the minimum fragment size are included here. Expressing which queues are marked as preemptible is left to mqprio/taprio, as having that information there should be easier on the user.

CC Michal
maintainer
#3 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

In reply to Vinicius Costa Gomes
Quoted 29 lines · On Tue, 1 Dec 2020 20:53:17 -0800 Vinicius Costa Gomes wrote:

Frame preemption (described in IEEE 802.3br-2016) defines the concept of preemptible and express queues. It allows traffic from express queues to "interrupt" traffic from preemptible queues, which are "resumed" after the express traffic has finished transmitting.

Frame preemption can only be used when both the local device and the link partner support it.

Only parameters for enabling/disabling frame preemption and configuring the minimum fragment size are included here. Expressing which queues are marked as preemptible is left to mqprio/taprio, as having that information there should be easier on the user.

---
 include/linux/ethtool.h              |  19 ++++
 include/uapi/linux/ethtool_netlink.h |  17 +++
 net/ethtool/Makefile                 |   2 +-
 net/ethtool/netlink.c                |  19 ++++
 net/ethtool/netlink.h                |   4 +
 net/ethtool/preempt.c                | 151 +++++++++++++++++++++++++++
 6 files changed, 211 insertions(+), 1 deletion(-)
 create mode 100644 net/ethtool/preempt.c
include/linux/ethtool.h +0 -0
index e3da25b51ae4..16d6ee29a6ac 100644

include/linux/ethtool.h struct ethtool_pause_stats { · line 270

Quoted 8 lines
include/linux/ethtool.h +5 -0
@@ -263,6 +263,19 @@ struct ethtool_pause_stats {
 	u64 rx_pause_frames;
 };
 
+/**
+ * struct ethtool_fp - Frame Preemption information
+ *
+ * @enabled: Enable frame preemption.
+ *

The empty line between members seems unnecessary.

include/linux/ethtool.h struct ethtool_pause_stats { · line 272

Quoted 2 lines
include/linux/ethtool.h +2 -0
+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'

Is this way of expressing the min frag size from the standard?

include/linux/ethtool.h struct ethtool_pause_stats {

Quoted 10 lines
include/linux/ethtool.h +9 -0
+ */
+struct ethtool_fp {
+	u8 enabled;
+	u8 min_frag_size_mult;
+};
 
+	int	(*get_preempt)(struct net_device *,
+			       struct ethtool_fp *);
+	int	(*set_preempt)(struct net_device *,
+			       struct ethtool_fp *);

Since this is a new op we should probably pass extack to the drivers?

include/linux/ethtool.h extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER + · line 380

Quoted 8 lines

extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1];

include/linux/ethtool.h +2 -0
@@ -375,6 +376,8 @@ extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER +
 extern const struct nla_policy ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_HEADER + 1];
 extern const struct nla_policy ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG + 1];
 extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_HEADER + 1];
+extern const struct nla_policy ethnl_preempt_get_policy[ETHTOOL_A_PREEMPT_MAX + 1];
+extern const struct nla_policy ethnl_preempt_set_policy[ETHTOOL_A_PREEMPT_MAX + 1];

Let's make the size

ETHTOOL_A_PREEMPT_MIN_FRAG_SIZE_MULT + 1

for set, and

ETHTOOL_A_PREEMPT_HEADER + 1

for get, like the other tables

include/linux/ethtool.h extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER + · line 383

Quoted 3 lines
include/linux/ethtool.h +3 -0
+const struct nla_policy
+ethnl_preempt_get_policy[ETHTOOL_A_PREEMPT_MAX + 1] = {
+	[ETHTOOL_A_PREEMPT_UNSPEC]		= { .type = NLA_REJECT },

Unnecessary, NLA_REJECT is 0.

include/linux/ethtool.h extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER +

Quoted 1 line
include/linux/ethtool.h +1 -0
+	[ETHTOOL_A_PREEMPT_HEADER]		= { .type = NLA_NESTED },

Please specify nested policy

include/linux/ethtool.h

Quoted 2 lines
include/linux/ethtool.h +2 -0
+	[ETHTOOL_A_PREEMPT_ENABLED]		= { .type = NLA_REJECT },
+	[ETHTOOL_A_PREEMPT_MIN_FRAG_SIZE_MULT]	= { .type = NLA_REJECT },

Unnecessary

include/linux/ethtool.h

Quoted 5 lines
include/linux/ethtool.h +5 -0
+const struct nla_policy
+ethnl_preempt_set_policy[ETHTOOL_A_PREEMPT_MAX + 1] = {
+	[ETHTOOL_A_PREEMPT_UNSPEC]			= { .type = NLA_REJECT },
+	[ETHTOOL_A_PREEMPT_HEADER]			= { .type = NLA_NESTED },
+	[ETHTOOL_A_PREEMPT_ENABLED]			= { .type = NLA_U8 },

Set the right netlink policy to check the value is <= 1.

Quoted 2 lines
include/linux/ethtool.h +2 -0
+	[ETHTOOL_A_PREEMPT_MIN_FRAG_SIZE_MULT]		= { .type = NLA_U8 },
+};
author maintainer
#4 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

Quoted 8 lines · Jakub Kicinski
Quoted 8 lines
include/linux/ethtool.h +0 -0
index e3da25b51ae4..16d6ee29a6ac 100644
@@ -263,6 +263,19 @@ struct ethtool_pause_stats {
 	u64 rx_pause_frames;
 };
 
Quoted 7 lines

include/linux/ethtool.h struct ethtool_pause_stats { · line 270

Quoted 5 lines
include/linux/ethtool.h +5 -0
+/**
+ * struct ethtool_fp - Frame Preemption information
+ *
+ * @enabled: Enable frame preemption.
+ *

The empty line between members seems unnecessary.

Will fix.

Quoted 6 lines

include/linux/ethtool.h struct ethtool_pause_stats { · line 272

Quoted 3 lines
include/linux/ethtool.h +2 -0
+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'

Is this way of expressing the min frag size from the standard?

The standard has this: "A 2-bit integer value indicating, in units of 64 octets, the minimum number of octets over 64 octets required in non-final fragments by the receiver" from IEEE 802.3br-2016, Table 79-7a.

Quoted 6 lines
Quoted 5 lines
include/linux/ethtool.h +5 -0
+ */
+struct ethtool_fp {
+	u8 enabled;
+	u8 min_frag_size_mult;
+};
Quoted 6 lines

include/linux/ethtool.h struct ethtool_ops { · line 525

Quoted 4 lines
include/linux/ethtool.h +4 -0
+	int	(*get_preempt)(struct net_device *,
+			       struct ethtool_fp *);
+	int	(*set_preempt)(struct net_device *,
+			       struct ethtool_fp *);

Since this is a new op we should probably pass extack to the drivers?

Yes. Will fix.

Quoted 43 lines

include/linux/ethtool.h extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER + · line 380

Quoted 9 lines
include/linux/ethtool.h +2 -0
 extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1];
 extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1];
@@ -375,6 +376,8 @@ extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER +
 extern const struct nla_policy ethnl_cable_test_act_policy[ETHTOOL_A_CABLE_TEST_HEADER + 1];
 extern const struct nla_policy ethnl_cable_test_tdr_act_policy[ETHTOOL_A_CABLE_TEST_TDR_CFG + 1];
 extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INFO_HEADER + 1];
+extern const struct nla_policy ethnl_preempt_get_policy[ETHTOOL_A_PREEMPT_MAX + 1];
+extern const struct nla_policy ethnl_preempt_set_policy[ETHTOOL_A_PREEMPT_MAX + 1];

Let's make the size

ETHTOOL_A_PREEMPT_MIN_FRAG_SIZE_MULT + 1

for set, and

ETHTOOL_A_PREEMPT_HEADER + 1

for get, like the other tables

include/linux/ethtool.h extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER + · line 383

Quoted 3 lines
include/linux/ethtool.h +3 -0
+const struct nla_policy
+ethnl_preempt_get_policy[ETHTOOL_A_PREEMPT_MAX + 1] = {
+	[ETHTOOL_A_PREEMPT_UNSPEC]		= { .type = NLA_REJECT },

Unnecessary, NLA_REJECT is 0.

include/linux/ethtool.h extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_HEADER +

Quoted 1 line
include/linux/ethtool.h +1 -0
+	[ETHTOOL_A_PREEMPT_HEADER]		= { .type = NLA_NESTED },

Please specify nested policy

include/linux/ethtool.h

Quoted 2 lines
include/linux/ethtool.h +2 -0
+	[ETHTOOL_A_PREEMPT_ENABLED]		= { .type = NLA_REJECT },
+	[ETHTOOL_A_PREEMPT_MIN_FRAG_SIZE_MULT]	= { .type = NLA_REJECT },

Unnecessary

include/linux/ethtool.h

Quoted 5 lines
include/linux/ethtool.h +5 -0
+const struct nla_policy
+ethnl_preempt_set_policy[ETHTOOL_A_PREEMPT_MAX + 1] = {
+	[ETHTOOL_A_PREEMPT_UNSPEC]			= { .type = NLA_REJECT },
+	[ETHTOOL_A_PREEMPT_HEADER]			= { .type = NLA_NESTED },
+	[ETHTOOL_A_PREEMPT_ENABLED]			= { .type = NLA_U8 },

Set the right netlink policy to check the value is <= 1.

Quoted 2 lines

include/linux/ethtool.h

Quoted 2 lines
include/linux/ethtool.h +2 -0
+	[ETHTOOL_A_PREEMPT_MIN_FRAG_SIZE_MULT]		= { .type = NLA_U8 },
+};

Will fix these netlink validation issues.

Cheers,

Signature · 1 line
Vinicius
maintainer
#5 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

Quoted 11 lines · On Mon, 07 Dec 2020 14:11:48 -0800 Vinicius Costa Gomes wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines

+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'

Is this way of expressing the min frag size from the standard?

The standard has this: "A 2-bit integer value indicating, in units of 64 octets, the minimum number of octets over 64 octets required in non-final fragments by the receiver" from IEEE 802.3br-2016, Table 79-7a.

Thanks! Let's drop the _mult suffix and add a mention of this controlling the addFragSize variable from the standard. Perhaps it should in fact be called add_frag_size (with an explanation that the "additional" means "above the 64B" which are required in Ethernet, and which are accounted for by the "1" in the 1 + X formula)?

author maintainer
#6 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

Quoted 13 lines · Jakub Kicinski
Quoted 11 lines · On Mon, 07 Dec 2020 14:11:48 -0800 Vinicius Costa Gomes wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines

+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'

Is this way of expressing the min frag size from the standard?

The standard has this: "A 2-bit integer value indicating, in units of 64 octets, the minimum number of octets over 64 octets required in non-final fragments by the receiver" from IEEE 802.3br-2016, Table 79-7a.

Quoted 6 lines

Thanks! Let's drop the _mult suffix and add a mention of this controlling the addFragSize variable from the standard. Perhaps it should in fact be called add_frag_size (with an explanation that the "additional" means "above the 64B" which are required in Ethernet, and which are accounted for by the "1" in the 1 + X formula)?

Sounds good :-) Will add a comment with the standard reference and change the name to 'add_frag_size'.

Cheers,

Signature · 1 line
Vinicius
#7 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

Quoted 22 lines · Vinicius Costa Gomes
Quoted 13 lines · Jakub Kicinski
Quoted 11 lines · On Mon, 07 Dec 2020 14:11:48 -0800 Vinicius Costa Gomes wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines

+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'

Is this way of expressing the min frag size from the standard?

The standard has this: "A 2-bit integer value indicating, in units of 64 octets, the minimum number of octets over 64 octets required in non-final fragments by the receiver" from IEEE 802.3br-2016, Table 79-7a.

Quoted 6 lines

Thanks! Let's drop the _mult suffix and add a mention of this controlling the addFragSize variable from the standard. Perhaps it should in fact be called add_frag_size (with an explanation that the "additional" means "above the 64B" which are required in Ethernet, and which are accounted for by the "1" in the 1 + X formula)?

Quoted 2 lines

Sounds good :-) Will add a comment with the standard reference and change the name to 'add_frag_size'.

I think you should be making references to the IEEE 802.3-2018, that will age better, and a lot more people have that handy.
I believe the go-to definition for the additional fragment size can be found in clause 30.12.2.1.37 aLldpXdot3LocAddFragSize.

maintainer
#8 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

Quoted 23 lines · On Tue, 8 Dec 2020 00:27:31 +0000 Vladimir Oltean wrote:
Quoted 22 lines · Vinicius Costa Gomes
Quoted 19 lines · Jakub Kicinski
Quoted 11 lines · On Mon, 07 Dec 2020 14:11:48 -0800 Vinicius Costa Gomes wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines

+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'

Is this way of expressing the min frag size from the standard?

The standard has this: "A 2-bit integer value indicating, in units of 64 octets, the minimum number of octets over 64 octets required in non-final fragments by the receiver" from IEEE 802.3br-2016, Table 79-7a.

Thanks! Let's drop the _mult suffix and add a mention of this controlling the addFragSize variable from the standard. Perhaps it should in fact be called add_frag_size (with an explanation that the "additional" means "above the 64B" which are required in Ethernet, and which are accounted for by the "1" in the 1 + X formula)?

Quoted 7 lines
Quoted 2 lines

Sounds good :-) Will add a comment with the standard reference and change the name to 'add_frag_size'.

I think you should be making references to the IEEE 802.3-2018, that will age better, and a lot more people have that handy.
I believe the go-to definition for the additional fragment size can be found in clause 30.12.2.1.37 aLldpXdot3LocAddFragSize.

That's the LLDP incarnation of it. The variable is defined in:

99.4.7.3 Variables

Probably better mention 30.14.1.7 aMACMergeAddFragSize if we want a MIB reference.

#9 lore raw

Re: [PATCH net-next v1 1/9] ethtool: Add support for configuring frame preemption

In reply to Vinicius Costa Gomes
Quoted 11 lines · Vinicius Costa Gomes
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines

+ * @min_frag_size_mult: Minimum size for all non-final fragment size,
+ * expressed in terms of X in '(1 + X)*64 + 4'

Is this way of expressing the min frag size from the standard?

The standard has this: "A 2-bit integer value indicating, in units of 64 octets, the minimum number of octets over 64 octets required in non-final fragments by the receiver" from IEEE 802.3br-2016, Table 79-7a.

Can we be sure that newer version of the standard cannot change this, e.g. come with a finer granularity? Perhaps it would be safer to express the size in bytes in the userspace API and translate to this internal representation in common ethtool code.

Also, please don't forget to update Documentation/networking/ethtool-netlink.rst

Michal

author maintainer
#10 lore raw

PATCH 2/9 taprio: Add support for frame preemption offload

In reply to Vinicius Costa Gomes

This adds a way to configure which queues are marked as preemptible and which are marked as express.

Even if this is not a "real" offload, because it can't be executed purely in software, having this information near where the mapping of queues is specified, makes it, hopefully, easier to understand.

---
 include/linux/netdevice.h      |  1 +
 include/net/pkt_sched.h        |  4 ++++
 include/uapi/linux/pkt_sched.h |  1 +
 net/sched/sch_taprio.c         | 41 ++++++++++++++++++++++++++++++----
 4 files changed, 43 insertions(+), 4 deletions(-)
include/linux/netdevice.h +1 -0
index 8eeb73ac58bd..d7a99e769e79 100644
@@ -852,6 +852,7 @@ enum tc_setup_type {
 	TC_SETUP_QDISC_ETS,
 	TC_SETUP_QDISC_TBF,
 	TC_SETUP_QDISC_FIFO,
+	TC_SETUP_PREEMPT,
 };
 
 /* These structures hold the attributes of bpf state that are being passed
include/net/pkt_sched.h +4 -0
index 15b1b30f454e..be5ff1535332 100644
@@ -183,6 +183,10 @@ struct tc_taprio_qopt_offload {
 	struct tc_taprio_sched_entry entries[];
 };
 
+struct tc_preempt_qopt_offload {
+	u32 preemptible_queues;
+};
+
 /* Reference counting */
 struct tc_taprio_qopt_offload *taprio_offload_get(struct tc_taprio_qopt_offload
 						  *offload);
include/uapi/linux/pkt_sched.h +1 -0
index 9e7c2c607845..f0240ddaeee3 100644
@@ -1240,6 +1240,7 @@ enum {
 	TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION, /* s64 */
 	TCA_TAPRIO_ATTR_FLAGS, /* u32 */
 	TCA_TAPRIO_ATTR_TXTIME_DELAY, /* u32 */
+	TCA_TAPRIO_ATTR_PREEMPT_QUEUES, /* u32 */
 	__TCA_TAPRIO_ATTR_MAX,
 };
 
net/sched/sch_taprio.c +37 -4

86 lines not on this page · raw message

Signature · 1 line
2.29.2
author maintainer
#11 lore raw

PATCH 3/9 igc: Set the RX packet buffer size for TSN mode

In reply to Vinicius Costa Gomes

In preparation for supporting frame preemption, when entering TSN mode set the receive packet buffer to 16KB for the Express MAC, 16KB for the Preemptible MAC and 2KB for the BMC, according to the datasheet section 7.1.3.2.

---
 drivers/net/ethernet/intel/igc/igc_defines.h |  2 ++
 drivers/net/ethernet/intel/igc/igc_tsn.c     | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_defines.h +2 -0
index 32f5fd684139..0e78abfd99ee 100644
@@ -351,6 +351,8 @@
 #define IGC_RXPBS_CFG_TS_EN	0x80000000 /* Timestamp in Rx buffer */
 
 #define IGC_TXPBSIZE_TSN	0x04145145 /* 5k bytes buffer for each queue */
+#define IGC_RXPBSIZE_TSN	0x00010090 /* 16KB for EXP + 16KB for BE + 2KB for BMC */
+#define IGC_RXPBSIZE_SIZE_MASK	0x0001FFFF
 
 #define IGC_DTXMXPKTSZ_TSN	0x19 /* 1600 bytes of max TX DMA packet size */
 #define IGC_DTXMXPKTSZ_DEFAULT	0x98 /* 9728-byte Jumbo frames */
drivers/net/ethernet/intel/igc/igc_tsn.c +12 -2
index 174103c4bea6..38451cf05ac6 100644
@@ -24,7 +24,7 @@ static bool is_any_launchtime(struct igc_adapter *adapter)
 static int igc_tsn_disable_offload(struct igc_adapter *adapter)
 {
 	struct igc_hw *hw = &adapter->hw;
-	u32 tqavctrl;
+	u32 tqavctrl, rxpbs;
 	int i;
 
 	if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED))
@@ -35,6 +35,11 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter)
 	wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT);
 	wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT);
 
+	rxpbs = rd32(IGC_RXPBS) & ~IGC_RXPBSIZE_SIZE_MASK;
+	rxpbs |= I225_RXPBSIZE_DEFAULT;
+
+	wr32(IGC_RXPBS, rxpbs);
+
 	tqavctrl = rd32(IGC_TQAVCTRL);
 	tqavctrl &= ~(IGC_TQAVCTRL_TRANSMIT_MODE_TSN |
 		      IGC_TQAVCTRL_ENHANCED_QAV);
@@ -64,7 +69,7 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 {
 	struct igc_hw *hw = &adapter->hw;
 	u32 tqavctrl, baset_l, baset_h;
-	u32 sec, nsec, cycle;
+	u32 sec, nsec, cycle, rxpbs;
 	ktime_t base_time, systim;
 	int i;
 
@@ -79,6 +84,11 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 	wr32(IGC_TXPBS, IGC_TXPBSIZE_TSN);
 
 	tqavctrl = rd32(IGC_TQAVCTRL);
+	rxpbs = rd32(IGC_RXPBS) & ~IGC_RXPBSIZE_SIZE_MASK;
+	rxpbs |= IGC_RXPBSIZE_TSN;
+
+	wr32(IGC_RXPBS, rxpbs);
+
 	tqavctrl |= IGC_TQAVCTRL_TRANSMIT_MODE_TSN | IGC_TQAVCTRL_ENHANCED_QAV;
 	wr32(IGC_TQAVCTRL, tqavctrl);
 
Signature · 1 line
2.29.2
author maintainer
#12 lore raw

PATCH 4/9 igc: Only dump registers if configured to dump HW information

In reply to Vinicius Costa Gomes

To avoid polluting the users logs with register dumps, only dump the adapter's registers if configured to do so.

If users want to enable HW status messages they can do:

$ ethtool -s IFACE msglvl hw on
---
 drivers/net/ethernet/intel/igc/igc_dump.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/igc/igc_dump.c +3 -0
index 4b9ec7d0b727..90b754b429ff 100644
@@ -308,6 +308,9 @@ void igc_regs_dump(struct igc_adapter *adapter)
 	struct igc_hw *hw = &adapter->hw;
 	struct igc_reg_info *reginfo;
 
+	if (!netif_msg_hw(adapter))
+		return;
+
 	/* Print Registers */
 	netdev_info(adapter->netdev, "Register Dump\n");
 	netdev_info(adapter->netdev, "Register Name   Value\n");
Signature · 1 line
2.29.2
author maintainer
#13 lore raw

PATCH 5/9 igc: Avoid TX Hangs because long cycles

In reply to Vinicius Costa Gomes

Avoid possible TX Hangs caused by using long Qbv cycles. In some cases, using long cycles (more than 1 second) can cause transmissions to be blocked for that time. As the TX Hang timeout is close to 1 second, we may need to reduce the cycle time to something more
reasonable: the value chosen is 1ms.

---
 drivers/net/ethernet/intel/igc/igc_main.c | 4 ++--
 drivers/net/ethernet/intel/igc/igc_tsn.c  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/igc/igc_main.c +2 -2
index b673ac1199bb..3af54fd9cc0d 100644
@@ -4692,12 +4692,12 @@ static int igc_save_launchtime_params(struct igc_adapter *adapter, int queue,
 	if (adapter->base_time)
 		return 0;
 
-	adapter->cycle_time = NSEC_PER_SEC;
+	adapter->cycle_time = NSEC_PER_MSEC;
 
 	for (i = 0; i < adapter->num_tx_queues; i++) {
 		ring = adapter->tx_ring[i];
 		ring->start_time = 0;
-		ring->end_time = NSEC_PER_SEC;
+		ring->end_time = NSEC_PER_MSEC;
 	}
 
 	return 0;
drivers/net/ethernet/intel/igc/igc_tsn.c +3 -3
index 38451cf05ac6..f5a5527adb21 100644
@@ -54,11 +54,11 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter)
 
 		wr32(IGC_TXQCTL(i), 0);
 		wr32(IGC_STQT(i), 0);
-		wr32(IGC_ENDQT(i), NSEC_PER_SEC);
+		wr32(IGC_ENDQT(i), NSEC_PER_MSEC);
 	}
 
-	wr32(IGC_QBVCYCLET_S, NSEC_PER_SEC);
-	wr32(IGC_QBVCYCLET, NSEC_PER_SEC);
+	wr32(IGC_QBVCYCLET_S, NSEC_PER_MSEC);
+	wr32(IGC_QBVCYCLET, NSEC_PER_MSEC);
 
 	adapter->flags &= ~IGC_FLAG_TSN_QBV_ENABLED;
 
Signature · 1 line
2.29.2
author maintainer
#14 lore raw

PATCH 6/9 igc: Add support for tuning frame preemption via ethtool

In reply to Vinicius Costa Gomes

The tc subsystem sets which queues are marked as preemptible, it's the role of ethtool to control more hardware specific parameters. These parameters include:

- enabling the frame preemption hardware: As enabling frame preemption may have other requirements before it can be enabled, it's exposed via the ethtool API;

- mininum fragment size multiplier: expressed in usually in the form of (1 + N)*64, this number indicates what's the size of the minimum fragment that can be preempted.

---
 drivers/net/ethernet/intel/igc/igc.h         | 10 ++++
 drivers/net/ethernet/intel/igc/igc_defines.h |  4 ++
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 55 ++++++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_tsn.c     | 20 +++++--
 4 files changed, 86 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +10 -0
index 35baae900c1f..35c2dc4ad810 100644
@@ -87,6 +87,7 @@ struct igc_ring {
 	u8 queue_index;                 /* logical index of the ring*/
 	u8 reg_idx;                     /* physical index of the ring */
 	bool launchtime_enable;         /* true if LaunchTime is enabled */
+	bool preemptible;		/* true if not express */
 
 	u32 start_time;
 	u32 end_time;
@@ -165,6 +166,11 @@ struct igc_adapter {
 
 	ktime_t base_time;
 	ktime_t cycle_time;
+	bool frame_preemption_active;
+	/* Frame preemption minimum fragment size, this the X in
+	 * (1 + X)*64 + 4
+	 */
+	u8 min_frag_size_mult;
 
 	/* OS defined structs */
 	struct pci_dev *pdev;
@@ -262,6 +268,10 @@ extern char igc_driver_name[];
 #define IGC_FLAG_VLAN_PROMISC		BIT(15)
 #define IGC_FLAG_RX_LEGACY		BIT(16)
 #define IGC_FLAG_TSN_QBV_ENABLED	BIT(17)
+#define IGC_FLAG_TSN_PREEMPT_ENABLED	BIT(18)
+
+#define IGC_FLAG_TSN_ANY_ENABLED \
+	(IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_PREEMPT_ENABLED)
 
 #define IGC_FLAG_RSS_FIELD_IPV4_UDP	BIT(6)
 #define IGC_FLAG_RSS_FIELD_IPV6_UDP	BIT(7)
drivers/net/ethernet/intel/igc/igc_defines.h +4 -0
index 0e78abfd99ee..c2155d109bd6 100644
@@ -410,10 +410,14 @@
 /* Transmit Scheduling */
 #define IGC_TQAVCTRL_TRANSMIT_MODE_TSN	0x00000001
 #define IGC_TQAVCTRL_ENHANCED_QAV	0x00000008
+#define IGC_TQAVCTRL_PREEMPT_ENA	0x00000002
+#define IGC_TQAVCTRL_MIN_FRAG_MASK	0x0000C000
+#define IGC_TQAVCTRL_MIN_FRAG_SHIFT	14
 
 #define IGC_TXQCTL_QUEUE_MODE_LAUNCHT	0x00000001
 #define IGC_TXQCTL_STRICT_CYCLE		0x00000002
 #define IGC_TXQCTL_STRICT_END		0x00000004
+#define IGC_TXQCTL_PREEMPTABLE		0x00000008
 
 /* Receive Checksum Control */
 #define IGC_RXCSUM_CRCOFL	0x00000800   /* CRC32 offload enable */
drivers/net/ethernet/intel/igc/igc_ethtool.c +55 -0

73 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_tsn.c +17 -3
index f5a5527adb21..76272f62bb69 100644
@@ -31,6 +31,7 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter)
 		return 0;
 
 	adapter->cycle_time = 0;
+	adapter->frame_preemption_active = false;
 
 	wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT);
 	wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT);
@@ -42,7 +43,8 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter)
 
 	tqavctrl = rd32(IGC_TQAVCTRL);
 	tqavctrl &= ~(IGC_TQAVCTRL_TRANSMIT_MODE_TSN |
-		      IGC_TQAVCTRL_ENHANCED_QAV);
+		      IGC_TQAVCTRL_ENHANCED_QAV | IGC_TQAVCTRL_PREEMPT_ENA |
+		      IGC_TQAVCTRL_MIN_FRAG_MASK);
 	wr32(IGC_TQAVCTRL, tqavctrl);
 
 	for (i = 0; i < adapter->num_tx_queues; i++) {
@@ -51,6 +53,7 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter)
 		ring->start_time = 0;
 		ring->end_time = 0;
 		ring->launchtime_enable = false;
+		ring->preemptible = false;
 
 		wr32(IGC_TXQCTL(i), 0);
 		wr32(IGC_STQT(i), 0);
@@ -83,13 +86,20 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 	wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_TSN);
 	wr32(IGC_TXPBS, IGC_TXPBSIZE_TSN);
 
-	tqavctrl = rd32(IGC_TQAVCTRL);
 	rxpbs = rd32(IGC_RXPBS) & ~IGC_RXPBSIZE_SIZE_MASK;
 	rxpbs |= IGC_RXPBSIZE_TSN;
 
 	wr32(IGC_RXPBS, rxpbs);
 
+	tqavctrl = rd32(IGC_TQAVCTRL) &
+		~(IGC_TQAVCTRL_MIN_FRAG_MASK | IGC_TQAVCTRL_PREEMPT_ENA);
 	tqavctrl |= IGC_TQAVCTRL_TRANSMIT_MODE_TSN | IGC_TQAVCTRL_ENHANCED_QAV;
+
+	if (adapter->frame_preemption_active)
+		tqavctrl |= IGC_TQAVCTRL_PREEMPT_ENA;
+
+	tqavctrl |= adapter->min_frag_size_mult << IGC_TQAVCTRL_MIN_FRAG_SHIFT;
+
 	wr32(IGC_TQAVCTRL, tqavctrl);
 
 	wr32(IGC_QBVCYCLET_S, cycle);
@@ -115,6 +125,9 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 		if (ring->launchtime_enable)
 			txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT;
 
+		if (ring->preemptible)
+			txqctl |= IGC_TXQCTL_PREEMPTABLE;
+
 		wr32(IGC_TXQCTL(i), txqctl);
 	}
 
@@ -142,7 +155,8 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 
 int igc_tsn_offload_apply(struct igc_adapter *adapter)
 {
-	bool is_any_enabled = adapter->base_time || is_any_launchtime(adapter);
+	bool is_any_enabled = adapter->base_time ||
+		is_any_launchtime(adapter) || adapter->frame_preemption_active;
 
 	if (!(adapter->flags & IGC_FLAG_TSN_QBV_ENABLED) && !is_any_enabled)
 		return 0;
Signature · 1 line
2.29.2
maintainer
#15 lore raw

Re: [PATCH net-next v1 6/9] igc: Add support for tuning frame preemption via ethtool

Quoted 8 lines · On Tue, 1 Dec 2020 20:53:22 -0800 Vinicius Costa Gomes wrote:

The tc subsystem sets which queues are marked as preemptible, it's the role of ethtool to control more hardware specific parameters. These parameters include:

- enabling the frame preemption hardware: As enabling frame preemption may have other requirements before it can be enabled, it's exposed via the ethtool API;

Quoted 5 lines

- mininum fragment size multiplier: expressed in usually in the form of (1 + N)*64, this number indicates what's the size of the minimum fragment that can be preempted.

WARNING: 'PREEMPTABLE' may be misspelled - perhaps 'PREEMPTIBLE'?

author maintainer
#16 lore raw

Re: [PATCH net-next v1 6/9] igc: Add support for tuning frame preemption via ethtool

Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Tue, 1 Dec 2020 20:53:22 -0800 Vinicius Costa Gomes wrote:

The tc subsystem sets which queues are marked as preemptible, it's the role of ethtool to control more hardware specific parameters. These parameters include:

- enabling the frame preemption hardware: As enabling frame preemption may have other requirements before it can be enabled, it's exposed via the ethtool API;

Quoted 7 lines
Quoted 5 lines

- mininum fragment size multiplier: expressed in usually in the form of (1 + N)*64, this number indicates what's the size of the minimum fragment that can be preempted.

WARNING: 'PREEMPTABLE' may be misspelled - perhaps 'PREEMPTIBLE'?

In the datasheet the term PREEMPTABLE is used, and when refering to register values I chose to be consistent with the datasheet. But as the margin for confusion is small, I can change to use "preemptible" everywhere, no problem.

Cheers,

Signature · 1 line
Vinicius
maintainer
#17 lore raw

Re: [PATCH net-next v1 6/9] igc: Add support for tuning frame preemption via ethtool

Quoted 6 lines · On Mon, 07 Dec 2020 14:15:25 -0800 Vinicius Costa Gomes wrote:
Quoted 1 line

WARNING: 'PREEMPTABLE' may be misspelled - perhaps 'PREEMPTIBLE'?

In the datasheet the term PREEMPTABLE is used, and when refering to register values I chose to be consistent with the datasheet. But as the margin for confusion is small, I can change to use "preemptible" everywhere, no problem.

If there is a reason to it feel free to keep as is.

author maintainer
#18 lore raw

PATCH 7/9 igc: Add support for Frame Preemption offload

In reply to Vinicius Costa Gomes

After the set of queues that are marked as preemptible are exposed to the driver we can configure the hardware to enable the frame preemption functionality.

---
 drivers/net/ethernet/intel/igc/igc_main.c | 32 +++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/net/ethernet/intel/igc/igc_main.c +32 -0
index 3af54fd9cc0d..763f39082f91 100644
@@ -4817,6 +4817,23 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,
 	return 0;
 }
 
+static int igc_save_frame_preemption(struct igc_adapter *adapter,
+				     struct tc_preempt_qopt_offload *qopt)
+{
+	u32 preempt;
+	int i;
+
+	preempt = qopt->preemptible_queues;
+
+	for (i = 0; i < adapter->num_tx_queues; i++) {
+		struct igc_ring *ring = adapter->tx_ring[i];
+
+		ring->preemptible = preempt & BIT(i);
+	}
+
+	return 0;
+}
+
 static int igc_tsn_enable_qbv_scheduling(struct igc_adapter *adapter,
 					 struct tc_taprio_qopt_offload *qopt)
 {
@@ -4833,6 +4850,18 @@ static int igc_tsn_enable_qbv_scheduling(struct igc_adapter *adapter,
 	return igc_tsn_offload_apply(adapter);
 }
 
+static int igc_tsn_enable_frame_preemption(struct igc_adapter *adapter,
+					   struct tc_preempt_qopt_offload *qopt)
+{
+	int err;
+
+	err = igc_save_frame_preemption(adapter, qopt);
+	if (err)
+		return err;
+
+	return igc_tsn_offload_apply(adapter);
+}
+
 static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
 			void *type_data)
 {
@@ -4845,6 +4874,9 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
 	case TC_SETUP_QDISC_ETF:
 		return igc_tsn_enable_launchtime(adapter, type_data);
 
+	case TC_SETUP_PREEMPT:
+		return igc_tsn_enable_frame_preemption(adapter, type_data);
+
 	default:
 		return -EOPNOTSUPP;
 	}
Signature · 1 line
2.29.2
author maintainer
#19 lore raw

PATCH 8/9 igc: Add support for exposing frame preemption stats registers

In reply to Vinicius Costa Gomes

Expose the Frame Preemption counters, so the number of express/preemptible packets can be monitored by userspace.

These registers are cleared when read, so the value shown is the number of events that happened since the last read.

---
 drivers/net/ethernet/intel/igc/igc_ethtool.c |  8 ++++++++
 drivers/net/ethernet/intel/igc/igc_regs.h    | 10 ++++++++++
 2 files changed, 18 insertions(+)
drivers/net/ethernet/intel/igc/igc_ethtool.c +8 -0
index 492c6592c150..14a14a61de45 100644
@@ -325,6 +325,14 @@ static void igc_ethtool_get_regs(struct net_device *netdev,
 
 	regs_buff[213] = adapter->stats.tlpic;
 	regs_buff[214] = adapter->stats.rlpic;
+	regs_buff[215] = rd32(IGC_PRMPTDTCNT);
+	regs_buff[216] = rd32(IGC_PRMEVNTTCNT);
+	regs_buff[217] = rd32(IGC_PRMPTDRCNT);
+	regs_buff[218] = rd32(IGC_PRMEVNTRCNT);
+	regs_buff[219] = rd32(IGC_PRMPBLTCNT);
+	regs_buff[220] = rd32(IGC_PRMPBLRCNT);
+	regs_buff[221] = rd32(IGC_PRMEXPTCNT);
+	regs_buff[222] = rd32(IGC_PRMEXPRCNT);
 }
 
 static void igc_ethtool_get_wol(struct net_device *netdev,
drivers/net/ethernet/intel/igc/igc_regs.h +10 -0
index b52dd9d737e8..69e295d69d84 100644
@@ -197,6 +197,16 @@
 
 #define IGC_FTQF(_n)	(0x059E0 + (4 * (_n)))  /* 5-tuple Queue Fltr */
 
+/* Time sync registers - preemption statistics */
+#define IGC_PRMPTDTCNT	0x04280  /* Good TX Preempted Packets */
+#define IGC_PRMEVNTTCNT	0x04298  /* TX Preemption event counter */
+#define IGC_PRMPTDRCNT	0x04284  /* Good RX Preempted Packets */
+#define IGC_PRMEVNTRCNT	0x0429C  /* RX Preemption event counter */
+#define IGC_PRMPBLTCNT	0x04288  /* Good TX Preemptable Packets */
+#define IGC_PRMPBLRCNT	0x0428C  /* Good RX Preemptable Packets */
+#define IGC_PRMEXPTCNT	0x04290  /* Good TX Express Packets */
+#define IGC_PRMEXPRCNT	0x042A0  /* Preemption Exception Counter */
+
 /* Transmit Scheduling Registers */
 #define IGC_TQAVCTRL		0x3570
 #define IGC_TXQCTL(_n)		(0x3344 + 0x4 * (_n))
Signature · 1 line
2.29.2
maintainer
#20 lore raw

Re: [PATCH net-next v1 8/9] igc: Add support for exposing frame preemption stats registers

Quoted 7 lines · On Tue, 1 Dec 2020 20:53:24 -0800 Vinicius Costa Gomes wrote:

Expose the Frame Preemption counters, so the number of express/preemptible packets can be monitored by userspace.

These registers are cleared when read, so the value shown is the number of events that happened since the last read.

You mean expose in a register dump? That's not great user experience..

Are there any stats that the standards mandate?

It'd be great if we could come up with some common set and expose them via ethtool like the pause frame statistics.

author maintainer
#21 lore raw

Re: [PATCH net-next v1 8/9] igc: Add support for exposing frame preemption stats registers

Quoted 10 lines · Jakub Kicinski
Quoted 7 lines · On Tue, 1 Dec 2020 20:53:24 -0800 Vinicius Costa Gomes wrote:

Expose the Frame Preemption counters, so the number of express/preemptible packets can be monitored by userspace.

These registers are cleared when read, so the value shown is the number of events that happened since the last read.

You mean expose in a register dump? That's not great user experience..

I can agree with that, even after some formatting on the ethtool side:

Preemption statistics:
TX Preemption event counter: 14070
Good TX Preemptable Packets: 201957
Good TX Express Packets: 32031
TX Preempted Packets: 13259
RX Preemption event counter: 0
Good RX Preemptable Packets: 0
Good RX Preempted Packets: 0
Preemption Exception Counter:
OOO_SMDC 0
OOO_FRAME 0
OOO_FRAG 0
MISS_FRAME_FRAG 0

It's less than ideal, but useful for development/debugging.

Quoted 2 lines

Are there any stats that the standards mandate?

I just took abother look at the standard, mainly at the MIBs, there are no statistics related to frame preemption that I could find, only configuration stuff.

Quoted 3 lines

It'd be great if we could come up with some common set and expose them via ethtool like the pause frame statistics.

Agreed, will drop this patch, until this common set is agreed upon.

Cheers,

Signature · 1 line
Vinicius
author maintainer
#22 lore raw

PATCH 9/9 igc: Separate TSN configurations that can be updated

In reply to Vinicius Costa Gomes

Some TSN features can be enabled during runtime, but most of the features need an adapter reset to be disabled.

To better keep track of this, separate the process into an "_apply" and a "reset" functions, "_apply" will run with the adapter in potencially "dirty" state, and if necessary will request an adapter reset, so "_reset" always run with a "clean" adapter.

The idea is to make the process easier to follow.

---
 drivers/net/ethernet/intel/igc/igc_main.c |  21 ++--
 drivers/net/ethernet/intel/igc/igc_tsn.c  | 140 +++++++++++++++-------
 drivers/net/ethernet/intel/igc/igc_tsn.h  |   1 +
 3 files changed, 103 insertions(+), 59 deletions(-)
drivers/net/ethernet/intel/igc/igc_main.c +7 -14
index 763f39082f91..76999fe05926 100644
@@ -107,7 +107,7 @@ void igc_reset(struct igc_adapter *adapter)
 	igc_ptp_reset(adapter);
 
 	/* Re-enable TSN offloading, where applicable. */
-	igc_tsn_offload_apply(adapter);
+	igc_tsn_reset(adapter);
 
 	igc_get_phy_info(hw);
 }
@@ -4823,6 +4823,11 @@ static int igc_save_frame_preemption(struct igc_adapter *adapter,
 	u32 preempt;
 	int i;
 
+	/* What we want here is just to save the configuration, so
+	 * when frame preemption is enabled via ethtool, which queues
+	 * are marked as preemptible is saved.
+	 */
+
 	preempt = qopt->preemptible_queues;
 
 	for (i = 0; i < adapter->num_tx_queues; i++) {
@@ -4850,18 +4855,6 @@ static int igc_tsn_enable_qbv_scheduling(struct igc_adapter *adapter,
 	return igc_tsn_offload_apply(adapter);
 }
 
-static int igc_tsn_enable_frame_preemption(struct igc_adapter *adapter,
-					   struct tc_preempt_qopt_offload *qopt)
-{
-	int err;
-
-	err = igc_save_frame_preemption(adapter, qopt);
-	if (err)
-		return err;
-
-	return igc_tsn_offload_apply(adapter);
-}
-
 static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
 			void *type_data)
 {
@@ -4875,7 +4868,7 @@ static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type,
 		return igc_tsn_enable_launchtime(adapter, type_data);
 
 	case TC_SETUP_PREEMPT:
-		return igc_tsn_enable_frame_preemption(adapter, type_data);
+		return igc_save_frame_preemption(adapter, type_data);
 
 	default:
 		return -EOPNOTSUPP;
drivers/net/ethernet/intel/igc/igc_tsn.c +95 -45

206 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_tsn.h +1 -0
index f76bc86ddccd..1512307f5a52 100644
@@ -5,5 +5,6 @@
 #define _IGC_TSN_H_
 
 int igc_tsn_offload_apply(struct igc_adapter *adapter);
+int igc_tsn_reset(struct igc_adapter *adapter);
 
 #endif /* _IGC_BASE_H */
Signature · 1 line
2.29.2
maintainer
#23 lore raw
In reply to Vinicius Costa Gomes
Quoted 9 lines · On Tue, 1 Dec 2020 20:53:16 -0800 Vinicius Costa Gomes wrote:
$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
      num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
      queues 1 at 0 1 at 1 2 at 2 \
      base-time $BASE_TIME \
      sched-entry S 0f 10000000 \
      preempt 1110 \
      flags 0x2 
Quoted 4 lines

The "preempt" parameter is the only difference, it configures which queues are marked as preemptible, in this example, queue 0 is marked as "not preemptible", so it is express, the rest of the four queues are preemptible.

Does it make more sense for the individual queues to be preemptible or not, or is it better controlled at traffic class level? I was looking at patch 2, and 32 queues isn't that many these days.. We either need a larger type there or configure this based on classes.

author maintainer
#24 lore raw
Quoted 15 lines · Jakub Kicinski
Quoted 9 lines · On Tue, 1 Dec 2020 20:53:16 -0800 Vinicius Costa Gomes wrote:
$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
      num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
      queues 1 at 0 1 at 1 2 at 2 \
      base-time $BASE_TIME \
      sched-entry S 0f 10000000 \
      preempt 1110 \
      flags 0x2 
Quoted 4 lines

The "preempt" parameter is the only difference, it configures which queues are marked as preemptible, in this example, queue 0 is marked as "not preemptible", so it is express, the rest of the four queues are preemptible.

Quoted 4 lines

Does it make more sense for the individual queues to be preemptible or not, or is it better controlled at traffic class level? I was looking at patch 2, and 32 queues isn't that many these days.. We either need a larger type there or configure this based on classes.

I can set more future proof sizes for expressing the queues, sure, but the issue, I think, is that frame preemption has dimishing returns with link speed: at 2.5G the latency improvements are on the order of single digit microseconds. At greater speeds the improvements are even less noticeable.

The only adapters that I see that support frame preemtion have 8 queues or less.

The idea of configuring frame preemption based on classes is interesting. I will play with it, and see how it looks.

Cheers,

Signature · 1 line
Vinicius
#25 lore raw
Quoted 22 lines · Vinicius Costa Gomes
Quoted 15 lines · Jakub Kicinski
Quoted 9 lines · On Tue, 1 Dec 2020 20:53:16 -0800 Vinicius Costa Gomes wrote:
$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
      num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
      queues 1 at 0 1 at 1 2 at 2 \
      base-time $BASE_TIME \
      sched-entry S 0f 10000000 \
      preempt 1110 \
      flags 0x2
Quoted 4 lines

The "preempt" parameter is the only difference, it configures which queues are marked as preemptible, in this example, queue 0 is marked as "not preemptible", so it is express, the rest of the four queues are preemptible.

Quoted 4 lines

Does it make more sense for the individual queues to be preemptible or not, or is it better controlled at traffic class level? I was looking at patch 2, and 32 queues isn't that many these days.. We either need a larger type there or configure this based on classes.

Quoted 5 lines

I can set more future proof sizes for expressing the queues, sure, but the issue, I think, is that frame preemption has dimishing returns with link speed: at 2.5G the latency improvements are on the order of single digit microseconds. At greater speeds the improvements are even less noticeable.

You could look at it another way.
You can enable jumbo frames in your network, and your latency-sensitive traffic would not suffer as long as the jumbo frames are preemptible.

Quoted 5 lines

The only adapters that I see that support frame preemtion have 8 queues or less.

The idea of configuring frame preemption based on classes is interesting. I will play with it, and see how it looks.

I admit I never understood why you insist on configuring TSN offloads per hardware queue and not per traffic class.

author maintainer
#26 lore raw
Quoted 29 lines · Vladimir Oltean
Quoted 22 lines · Vinicius Costa Gomes
Quoted 15 lines · Jakub Kicinski
Quoted 9 lines · On Tue, 1 Dec 2020 20:53:16 -0800 Vinicius Costa Gomes wrote:
$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
      num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \
      queues 1 at 0 1 at 1 2 at 2 \
      base-time $BASE_TIME \
      sched-entry S 0f 10000000 \
      preempt 1110 \
      flags 0x2
Quoted 4 lines

The "preempt" parameter is the only difference, it configures which queues are marked as preemptible, in this example, queue 0 is marked as "not preemptible", so it is express, the rest of the four queues are preemptible.

Quoted 4 lines

Does it make more sense for the individual queues to be preemptible or not, or is it better controlled at traffic class level? I was looking at patch 2, and 32 queues isn't that many these days.. We either need a larger type there or configure this based on classes.

Quoted 5 lines

I can set more future proof sizes for expressing the queues, sure, but the issue, I think, is that frame preemption has dimishing returns with link speed: at 2.5G the latency improvements are on the order of single digit microseconds. At greater speeds the improvements are even less noticeable.

Quoted 4 lines

You could look at it another way.
You can enable jumbo frames in your network, and your latency-sensitive traffic would not suffer as long as the jumbo frames are preemptible.

Speaking of jumbo frame, that's something that the standards are missing, TSN features + jumbo frames will leave a lot of stuff up to the implementation.

Quoted 8 lines
Quoted 5 lines

The only adapters that I see that support frame preemtion have 8 queues or less.

The idea of configuring frame preemption based on classes is interesting. I will play with it, and see how it looks.

I admit I never understood why you insist on configuring TSN offloads per hardware queue and not per traffic class.

So, I am sorry that I wasn't able to fully understand what you were saying, then.

I always thought that you were thinking more that the driver was responsible of making the 'traffic class to queue' translation than the configuration interface for frame preemption to the user (taprio, mqprio, etc) should be in terms of traffic classes, instead of queues.

My bad.

Cheers,

Signature · 1 line
Vinicius