Skip to contentSkip to conversation

net: ethernet: am65-cpsw: Add mqprio, frame pre-emption & coalescing

PATCH Superseded Roger Quadros 3 participants 30 messages Dec 1, 2023 – Dec 11, 2023

Subsystems (4)

v7 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v7 cover net: ethernet: am65-cpsw: Add mqprio, frame pre-emption & coalescing

Hi,

This series adds mqprio qdisc offload in channel mode, Frame Pre-emption MAC merge support and RX/TX coalesing for AM65 CPSW driver.

In v7 all kselftest issues with ethtool_mm have been resolved.

Changelog information in each patch file.

cheers,
-roger

Grygorii Strashko (2):
net: ethernet: ti: am65-cpsw: add mqprio qdisc offload in channel mode
net: ethernet: ti: am65-cpsw: add sw tx/rx irq coalescing based on
hrtimers

Roger Quadros (5):
net: ethernet: am65-cpsw: Build am65-cpsw-qos only if required
net: ethernet: am65-cpsw: cleanup TAPRIO handling
net: ethernet: ti: am65-cpsw: Move code to avoid forward declaration
net: ethernet: am65-cpsw: Move register definitions to header file
net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge
support

Vladimir Oltean (1):
selftests: forwarding: ethtool_mm: support devices with higher
rx-min-frag-size

 drivers/net/ethernet/ti/Makefile              |   3 +-
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c   | 236 ++++++
 drivers/net/ethernet/ti/am65-cpsw-nuss.c      |  64 +-
 drivers/net/ethernet/ti/am65-cpsw-nuss.h      |   9 +
 drivers/net/ethernet/ti/am65-cpsw-qos.c       | 705 +++++++++++++-----
 drivers/net/ethernet/ti/am65-cpsw-qos.h       | 183 +++++
 .../selftests/net/forwarding/ethtool_mm.sh    |  37 +-
 7 files changed, 1057 insertions(+), 180 deletions(-)

base-commit: 15bc81212f593fbd7bda787598418b931842dc14

Signature · 1 line
2.34.1
#1 lore raw

PATCH v7 1/8 net: ethernet: am65-cpsw: Build am65-cpsw-qos only if required

Build am65-cpsw-qos only if CONFIG_TI_AM65_CPSW_TAS is enabled.

---
 drivers/net/ethernet/ti/Makefile        |  3 ++-
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 12 ------------
 drivers/net/ethernet/ti/am65-cpsw-qos.h | 26 +++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 13 deletions(-)

Changelog:

v7: no change
v6: initial commit

drivers/net/ethernet/ti/Makefile +2 -1
index 27de1d697134..9d7cd84d1e2d 100644
@@ -26,7 +26,8 @@ keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.
 obj-$(CONFIG_TI_K3_CPPI_DESC_POOL) += k3-cppi-desc-pool.o
 
 obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
-ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o am65-cpsw-qos.o
+ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o
+ti-am65-cpsw-nuss-$(CONFIG_TI_AM65_CPSW_TAS) += am65-cpsw-qos.o
 ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o
 obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o
 
drivers/net/ethernet/ti/am65-cpsw-qos.c +0 -12
index 9ac2ff05d501..4bc611cc4aad 100644
@@ -571,9 +571,6 @@ static int am65_cpsw_setup_taprio(struct net_device *ndev, void *type_data)
 	    taprio->cmd != TAPRIO_CMD_DESTROY)
 		return -EOPNOTSUPP;
 
-	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-		return -ENODEV;
-
 	if (!netif_running(ndev)) {
 		dev_err(&ndev->dev, "interface is down, link speed unknown\n");
 		return -ENETDOWN;
@@ -599,9 +596,6 @@ static int am65_cpsw_tc_query_caps(struct net_device *ndev, void *type_data)
 	case TC_SETUP_QDISC_TAPRIO: {
 		struct tc_taprio_caps *caps = base->caps;
 
-		if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-			return -EOPNOTSUPP;
-
 		caps->gate_mask_per_txq = true;
 
 		return 0;
@@ -806,9 +800,6 @@ void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed)
 {
 	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 
-	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-		return;
-
 	am65_cpsw_est_link_up(ndev, link_speed);
 	port->qos.link_down_time = 0;
 }
@@ -817,9 +808,6 @@ void am65_cpsw_qos_link_down(struct net_device *ndev)
 {
 	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 
-	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-		return;
-
 	if (!port->qos.link_down_time)
 		port->qos.link_down_time = ktime_get();
 
drivers/net/ethernet/ti/am65-cpsw-qos.h +26 -0
index 0cc2a3b3d7f9..898f13a4a112 100644
@@ -31,11 +31,37 @@ struct am65_cpsw_qos {
 	struct am65_cpsw_ale_ratelimit ale_mc_ratelimit;
 };
 
+#if IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS)
 int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
 			       void *type_data);
 void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed);
 void am65_cpsw_qos_link_down(struct net_device *ndev);
 int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev, int queue, u32 rate_mbps);
 void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common);
+#else
+static inline int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev,
+					     enum tc_setup_type type,
+					     void *type_data)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline void am65_cpsw_qos_link_up(struct net_device *ndev,
+					 int link_speed)
+{ }
+
+static inline void am65_cpsw_qos_link_down(struct net_device *ndev)
+{ }
+
+static inline int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev,
+						      int queue,
+						      u32 rate_mbps)
+{
+	return 0;
+}
+
+static inline void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
+{ }
+#endif
 
 #endif /* AM65_CPSW_QOS_H_ */
Signature · 1 line
2.34.1
#2 lore raw

PATCH v7 2/8 net: ethernet: am65-cpsw: cleanup TAPRIO handling

In reply to Roger Quadros

Handle offloading commands using switch-case in
am65_cpsw_setup_taprio().

Move checks to am65_cpsw_taprio_replace().

Use NL_SET_ERR_MSG_MOD for error messages.
Change error message from "Failed to set cycle time extension" to "cycle time extension not supported"

---
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 149 +++++++++++-------------
 1 file changed, 70 insertions(+), 79 deletions(-)

Changelog

v7: don't use "\n" in NL_SET_ERR_MSG_MOD()
v6: initial commit

drivers/net/ethernet/ti/am65-cpsw-qos.c +70 -79
index 4bc611cc4aad..3d4773af783a 100644
@@ -428,7 +428,7 @@ static void am65_cpsw_stop_est(struct net_device *ndev)
 	am65_cpsw_timer_stop(ndev);
 }
 
-static void am65_cpsw_purge_est(struct net_device *ndev)
+static void am65_cpsw_taprio_destroy(struct net_device *ndev)
 {
 	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 
@@ -441,29 +441,66 @@ static void am65_cpsw_purge_est(struct net_device *ndev)
 	port->qos.est_admin = NULL;
 }
 
-static int am65_cpsw_configure_taprio(struct net_device *ndev,
-				      struct am65_cpsw_est *est_new)
+static void am65_cpsw_cp_taprio(struct tc_taprio_qopt_offload *from,
+				struct tc_taprio_qopt_offload *to)
+{
+	int i;
+
+	*to = *from;
+	for (i = 0; i < from->num_entries; i++)
+		to->entries[i] = from->entries[i];
+}
+
+static int am65_cpsw_taprio_replace(struct net_device *ndev,
+				    struct tc_taprio_qopt_offload *taprio)
 {
 	struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
+	struct netlink_ext_ack *extack = taprio->mqprio.extack;
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 	struct am65_cpts *cpts = common->cpts;
 	int ret = 0, tact = TACT_PROG;
+	struct am65_cpsw_est *est_new;
 
-	am65_cpsw_est_update_state(ndev);
+	if (!netif_running(ndev)) {
+		NL_SET_ERR_MSG_MOD(extack, "interface is down, link speed unknown");
+		return -ENETDOWN;
+	}
 
-	if (est_new->taprio.cmd == TAPRIO_CMD_DESTROY) {
-		am65_cpsw_stop_est(ndev);
-		return ret;
+	if (common->pf_p0_rx_ptype_rrobin) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "p0-rx-ptype-rrobin flag conflicts with taprio qdisc");
+		return -EINVAL;
+	}
+
+	if (port->qos.link_speed == SPEED_UNKNOWN)
+		return -ENOLINK;
+
+	if (taprio->cycle_time_extension) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "cycle time extension not supported");
+		return -EOPNOTSUPP;
 	}
 
+	est_new = devm_kzalloc(&ndev->dev,
+			       struct_size(est_new, taprio.entries, taprio->num_entries),
+			       GFP_KERNEL);
+	if (!est_new)
+		return -ENOMEM;
+
+	am65_cpsw_cp_taprio(taprio, &est_new->taprio);
+
+	am65_cpsw_est_update_state(ndev);
+
 	ret = am65_cpsw_est_check_scheds(ndev, est_new);
 	if (ret < 0)
-		return ret;
+		goto fail;
 
 	tact = am65_cpsw_timer_act(ndev, est_new);
 	if (tact == TACT_NEED_STOP) {
-		dev_err(&ndev->dev,
-			"Can't toggle estf timer, stop taprio first");
-		return -EINVAL;
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Can't toggle estf timer, stop taprio first");
+		ret = -EINVAL;
+		goto fail;
 	}
 
 	if (tact == TACT_PROG)
@@ -476,62 +513,24 @@ static int am65_cpsw_configure_taprio(struct net_device *ndev,
 	am65_cpsw_est_set_sched_list(ndev, est_new);
 	am65_cpsw_port_est_assign_buf_num(ndev, est_new->buf);
 
-	am65_cpsw_est_set(ndev, est_new->taprio.cmd == TAPRIO_CMD_REPLACE);
+	am65_cpsw_est_set(ndev, 1);
 
 	if (tact == TACT_PROG) {
 		ret = am65_cpsw_timer_set(ndev, est_new);
 		if (ret) {
-			dev_err(&ndev->dev, "Failed to set cycle time");
-			return ret;
+			NL_SET_ERR_MSG_MOD(extack,
+					   "Failed to set cycle time");
+			goto fail;
 		}
 	}
 
-	return ret;
-}
-
-static void am65_cpsw_cp_taprio(struct tc_taprio_qopt_offload *from,
-				struct tc_taprio_qopt_offload *to)
-{
-	int i;
-
-	*to = *from;
-	for (i = 0; i < from->num_entries; i++)
-		to->entries[i] = from->entries[i];
-}
-
-static int am65_cpsw_set_taprio(struct net_device *ndev, void *type_data)
-{
-	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
-	struct tc_taprio_qopt_offload *taprio = type_data;
-	struct am65_cpsw_est *est_new;
-	int ret = 0;
-
-	if (taprio->cycle_time_extension) {
-		dev_err(&ndev->dev, "Failed to set cycle time extension");
-		return -EOPNOTSUPP;
-	}
-
-	est_new = devm_kzalloc(&ndev->dev,
-			       struct_size(est_new, taprio.entries, taprio->num_entries),
-			       GFP_KERNEL);
-	if (!est_new)
-		return -ENOMEM;
-
-	am65_cpsw_cp_taprio(taprio, &est_new->taprio);
-	ret = am65_cpsw_configure_taprio(ndev, est_new);
-	if (!ret) {
-		if (taprio->cmd == TAPRIO_CMD_REPLACE) {
-			devm_kfree(&ndev->dev, port->qos.est_admin);
+	devm_kfree(&ndev->dev, port->qos.est_admin);
+	port->qos.est_admin = est_new;
 
-			port->qos.est_admin = est_new;
-		} else {
-			devm_kfree(&ndev->dev, est_new);
-			am65_cpsw_purge_est(ndev);
-		}
-	} else {
-		devm_kfree(&ndev->dev, est_new);
-	}
+	return 0;
 
+fail:
+	devm_kfree(&ndev->dev, est_new);
 	return ret;
 }
 
@@ -558,34 +557,26 @@ static void am65_cpsw_est_link_up(struct net_device *ndev, int link_speed)
 	return;
 
 purge_est:
-	am65_cpsw_purge_est(ndev);
+	am65_cpsw_taprio_destroy(ndev);
 }
 
 static int am65_cpsw_setup_taprio(struct net_device *ndev, void *type_data)
 {
-	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 	struct tc_taprio_qopt_offload *taprio = type_data;
-	struct am65_cpsw_common *common = port->common;
-
-	if (taprio->cmd != TAPRIO_CMD_REPLACE &&
-	    taprio->cmd != TAPRIO_CMD_DESTROY)
-		return -EOPNOTSUPP;
-
-	if (!netif_running(ndev)) {
-		dev_err(&ndev->dev, "interface is down, link speed unknown\n");
-		return -ENETDOWN;
-	}
-
-	if (common->pf_p0_rx_ptype_rrobin) {
-		dev_err(&ndev->dev,
-			"p0-rx-ptype-rrobin flag conflicts with taprio qdisc\n");
-		return -EINVAL;
+	int err = 0;
+
+	switch (taprio->cmd) {
+	case TAPRIO_CMD_REPLACE:
+		err = am65_cpsw_taprio_replace(ndev, taprio);
+		break;
+	case TAPRIO_CMD_DESTROY:
+		am65_cpsw_taprio_destroy(ndev);
+		break;
+	default:
+		err = -EOPNOTSUPP;
 	}
 
-	if (port->qos.link_speed == SPEED_UNKNOWN)
-		return -ENOLINK;
-
-	return am65_cpsw_set_taprio(ndev, type_data);
+	return err;
 }
 
 static int am65_cpsw_tc_query_caps(struct net_device *ndev, void *type_data)
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v7 net-next 2/8] net: ethernet: am65-cpsw: cleanup TAPRIO handling

Quoted 11 lines · Roger Quadros

Handle offloading commands using switch-case in
am65_cpsw_setup_taprio().

Move checks to am65_cpsw_taprio_replace().

Use NL_SET_ERR_MSG_MOD for error messages.
Change error message from "Failed to set cycle time extension" to "cycle time extension not supported"

---

After this change (I guess), it's pointless to initialize

	int ret = 0, tact = TACT_PROG;

when both will be overwritten later in am65_cpsw_taprio_replace(), and nothing depends upon their initial values.

#4 lore raw

PATCH v7 3/8 net: ethernet: ti: am65-cpsw: Move code to avoid forward declaration

In reply to Roger Quadros

Move this code to the end to avoid forward declaration. No functional change.

---
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 86 ++++++++++++-------------
 1 file changed, 43 insertions(+), 43 deletions(-)

Changelog

v7: move am65_cpsw_qos_tx_rate_calc()
v6: no change
v5: no change
v4: initial commit

drivers/net/ethernet/ti/am65-cpsw-qos.c +43 -43
index 3d4773af783a..d468a6856a85 100644
@@ -56,6 +56,16 @@ enum timer_act {
 	TACT_SKIP_PROG,		/* just buffer can be updated */
 };
 
+static u32
+am65_cpsw_qos_tx_rate_calc(u32 rate_mbps, unsigned long bus_freq)
+{
+	u32 ir;
+
+	bus_freq /= 1000000;
+	ir = DIV_ROUND_UP(((u64)rate_mbps * 32768),  bus_freq);
+	return ir;
+}
+
 static int am65_cpsw_port_est_enabled(struct am65_cpsw_port *port)
 {
 	return port->qos.est_oper || port->qos.est_admin;
@@ -772,49 +782,6 @@ static int am65_cpsw_qos_setup_tc_block(struct net_device *ndev, struct flow_blo
 					  port, port, true);
 }
 
-int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
-			       void *type_data)
-{
-	switch (type) {
-	case TC_QUERY_CAPS:
-		return am65_cpsw_tc_query_caps(ndev, type_data);
-	case TC_SETUP_QDISC_TAPRIO:
-		return am65_cpsw_setup_taprio(ndev, type_data);
-	case TC_SETUP_BLOCK:
-		return am65_cpsw_qos_setup_tc_block(ndev, type_data);
-	default:
-		return -EOPNOTSUPP;
-	}
-}
-
-void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed)
-{
-	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
-
-	am65_cpsw_est_link_up(ndev, link_speed);
-	port->qos.link_down_time = 0;
-}
-
-void am65_cpsw_qos_link_down(struct net_device *ndev)
-{
-	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
-
-	if (!port->qos.link_down_time)
-		port->qos.link_down_time = ktime_get();
-
-	port->qos.link_speed = SPEED_UNKNOWN;
-}
-
-static u32
-am65_cpsw_qos_tx_rate_calc(u32 rate_mbps, unsigned long bus_freq)
-{
-	u32 ir;
-
-	bus_freq /= 1000000;
-	ir = DIV_ROUND_UP(((u64)rate_mbps * 32768),  bus_freq);
-	return ir;
-}
-
 static void
 am65_cpsw_qos_tx_p0_rate_apply(struct am65_cpsw_common *common,
 			       int tx_ch, u32 rate_mbps)
@@ -916,3 +883,36 @@ void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
 		       host->port_base + AM65_CPSW_PN_REG_PRI_CIR(tx_ch));
 	}
 }
+
+int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
+			       void *type_data)
+{
+	switch (type) {
+	case TC_QUERY_CAPS:
+		return am65_cpsw_tc_query_caps(ndev, type_data);
+	case TC_SETUP_QDISC_TAPRIO:
+		return am65_cpsw_setup_taprio(ndev, type_data);
+	case TC_SETUP_BLOCK:
+		return am65_cpsw_qos_setup_tc_block(ndev, type_data);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed)
+{
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+
+	am65_cpsw_est_link_up(ndev, link_speed);
+	port->qos.link_down_time = 0;
+}
+
+void am65_cpsw_qos_link_down(struct net_device *ndev)
+{
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+
+	if (!port->qos.link_down_time)
+		port->qos.link_down_time = ktime_get();
+
+	port->qos.link_speed = SPEED_UNKNOWN;
+}
Signature · 1 line
2.34.1
#5 lore raw

PATCH v7 4/8 net: ethernet: am65-cpsw: Move register definitions to header file

In reply to Roger Quadros

Move register definitions to header file. No functional change.

---
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 35 -------------------------
 drivers/net/ethernet/ti/am65-cpsw-qos.h | 35 +++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 35 deletions(-)

Changelog:

v7: no change
v6: initial commit

drivers/net/ethernet/ti/am65-cpsw-qos.c +0 -35
index d468a6856a85..49ae9d1cd948 100644
@@ -15,41 +15,6 @@
 #include "am65-cpts.h"
 #include "cpsw_ale.h"
 
-#define AM65_CPSW_REG_CTL			0x004
-#define AM65_CPSW_PN_REG_CTL			0x004
-#define AM65_CPSW_PN_REG_FIFO_STATUS		0x050
-#define AM65_CPSW_PN_REG_EST_CTL		0x060
-#define AM65_CPSW_PN_REG_PRI_CIR(pri)		(0x140 + 4 * (pri))
-
-/* AM65_CPSW_REG_CTL register fields */
-#define AM65_CPSW_CTL_EST_EN			BIT(18)
-
-/* AM65_CPSW_PN_REG_CTL register fields */
-#define AM65_CPSW_PN_CTL_EST_PORT_EN		BIT(17)
-
-/* AM65_CPSW_PN_REG_EST_CTL register fields */
-#define AM65_CPSW_PN_EST_ONEBUF			BIT(0)
-#define AM65_CPSW_PN_EST_BUFSEL			BIT(1)
-#define AM65_CPSW_PN_EST_TS_EN			BIT(2)
-#define AM65_CPSW_PN_EST_TS_FIRST		BIT(3)
-#define AM65_CPSW_PN_EST_ONEPRI			BIT(4)
-#define AM65_CPSW_PN_EST_TS_PRI_MSK		GENMASK(7, 5)
-
-/* AM65_CPSW_PN_REG_FIFO_STATUS register fields */
-#define AM65_CPSW_PN_FST_TX_PRI_ACTIVE_MSK	GENMASK(7, 0)
-#define AM65_CPSW_PN_FST_TX_E_MAC_ALLOW_MSK	GENMASK(15, 8)
-#define AM65_CPSW_PN_FST_EST_CNT_ERR		BIT(16)
-#define AM65_CPSW_PN_FST_EST_ADD_ERR		BIT(17)
-#define AM65_CPSW_PN_FST_EST_BUFACT		BIT(18)
-
-/* EST FETCH COMMAND RAM */
-#define AM65_CPSW_FETCH_RAM_CMD_NUM		0x80
-#define AM65_CPSW_FETCH_CNT_MSK			GENMASK(21, 8)
-#define AM65_CPSW_FETCH_CNT_MAX			(AM65_CPSW_FETCH_CNT_MSK >> 8)
-#define AM65_CPSW_FETCH_CNT_OFFSET		8
-#define AM65_CPSW_FETCH_ALLOW_MSK		GENMASK(7, 0)
-#define AM65_CPSW_FETCH_ALLOW_MAX		AM65_CPSW_FETCH_ALLOW_MSK
-
 enum timer_act {
 	TACT_PROG,		/* need program timer */
 	TACT_NEED_STOP,		/* need stop first */
drivers/net/ethernet/ti/am65-cpsw-qos.h +35 -0
index 898f13a4a112..d8bccfd48532 100644
@@ -31,6 +31,41 @@ struct am65_cpsw_qos {
 	struct am65_cpsw_ale_ratelimit ale_mc_ratelimit;
 };
 
+#define AM65_CPSW_REG_CTL			0x004
+#define AM65_CPSW_PN_REG_CTL			0x004
+#define AM65_CPSW_PN_REG_FIFO_STATUS		0x050
+#define AM65_CPSW_PN_REG_EST_CTL		0x060
+#define AM65_CPSW_PN_REG_PRI_CIR(pri)		(0x140 + 4 * (pri))
+
+/* AM65_CPSW_REG_CTL register fields */
+#define AM65_CPSW_CTL_EST_EN			BIT(18)
+
+/* AM65_CPSW_PN_REG_CTL register fields */
+#define AM65_CPSW_PN_CTL_EST_PORT_EN		BIT(17)
+
+/* AM65_CPSW_PN_REG_EST_CTL register fields */
+#define AM65_CPSW_PN_EST_ONEBUF			BIT(0)
+#define AM65_CPSW_PN_EST_BUFSEL			BIT(1)
+#define AM65_CPSW_PN_EST_TS_EN			BIT(2)
+#define AM65_CPSW_PN_EST_TS_FIRST		BIT(3)
+#define AM65_CPSW_PN_EST_ONEPRI			BIT(4)
+#define AM65_CPSW_PN_EST_TS_PRI_MSK		GENMASK(7, 5)
+
+/* AM65_CPSW_PN_REG_FIFO_STATUS register fields */
+#define AM65_CPSW_PN_FST_TX_PRI_ACTIVE_MSK	GENMASK(7, 0)
+#define AM65_CPSW_PN_FST_TX_E_MAC_ALLOW_MSK	GENMASK(15, 8)
+#define AM65_CPSW_PN_FST_EST_CNT_ERR		BIT(16)
+#define AM65_CPSW_PN_FST_EST_ADD_ERR		BIT(17)
+#define AM65_CPSW_PN_FST_EST_BUFACT		BIT(18)
+
+/* EST FETCH COMMAND RAM */
+#define AM65_CPSW_FETCH_RAM_CMD_NUM		0x80
+#define AM65_CPSW_FETCH_CNT_MSK			GENMASK(21, 8)
+#define AM65_CPSW_FETCH_CNT_MAX			(AM65_CPSW_FETCH_CNT_MSK >> 8)
+#define AM65_CPSW_FETCH_CNT_OFFSET		8
+#define AM65_CPSW_FETCH_ALLOW_MSK		GENMASK(7, 0)
+#define AM65_CPSW_FETCH_ALLOW_MAX		AM65_CPSW_FETCH_ALLOW_MSK
+
 #if IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS)
 int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
 			       void *type_data);
Signature · 1 line
2.34.1
#6 lore raw

PATCH v7 5/8 net: ethernet: ti: am65-cpsw: add mqprio qdisc offload in channel mode

In reply to Roger Quadros

From: Grygorii Strashko <[email protected]>

This patch adds MQPRIO Qdisc offload in full 'channel' mode which allows not only setting up pri:tc mapping, but also configuring TX shapers (rate-limiting) on external port FIFOs.

The MQPRIO Qdisc offload is expected to work with or without VLAN/priority tagged packets.

The CPSW external Port FIFO has 8 Priority queues. The rate-limit can be set for each of these priority queues. Which Priority queue a packet is assigned to depends on PN_REG_TX_PRI_MAP register which maps header priority to switch priority.

The header priority of a packet is assigned via the RX_PRI_MAP_REG which maps packet priority to header priority.

The packet priority is either the VLAN priority (for VLAN tagged packets) or the thread/channel offset.

For simplicity, we assign the same priority queue to all queues of a Traffic Class so it can be rate-limited correctly.

Configuration example:
ethtool -L eth1 tx 5
ethtool --set-priv-flags eth1 p0-rx-ptype-rrobin off

tc qdisc add dev eth1 parent root handle 100: mqprio num_tc 3 \
map 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 \
queues 1@0 1@1 1@2 hw 1 mode channel \
shaper bw_rlimit min_rate 0 100mbit 200mbit max_rate 0 101mbit 202mbit

tc qdisc replace dev eth2 handle 100: parent root mqprio num_tc 1 \
map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues 1@0 hw 1

ip link add link eth1 name eth1.100 type vlan id 100
ip link set eth1.100 type vlan egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7

In the above example two ports share the same TX CPPI queue 0 for low priority traffic. 3 traffic classes are defined for eth1 and mapped to:
TC0 - low priority, TX CPPI queue 0 -> ext Port 1 fifo0, no rate limit TC1 - prio 2, TX CPPI queue 1 -> ext Port 1 fifo1, CIR=100Mbit/s, EIR=1Mbit/s TC2 - prio 3, TX CPPI queue 2 -> ext Port 1 fifo2, CIR=200Mbit/s, EIR=2Mbit/s

---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c |   3 +
 drivers/net/ethernet/ti/am65-cpsw-qos.c  | 254 ++++++++++++++++++++++-
 drivers/net/ethernet/ti/am65-cpsw-qos.h  |  20 ++
 3 files changed, 274 insertions(+), 3 deletions(-)

Changelog

v7:
- don't return -EINVAL if num_tc is 0 in setup

v6:
- fixed typo in comment "packet_priorit"->"packet_priority"
- don't call netif_set_real_num_tx_queues() from am65_cpsw_reset_tc_mqprio()
- reset TX queue priorities to zero at init. AM65_CPSW_PN_REG_TX_PRI_MAP = 0
- don't ignore return value in am65_cpsw_setup_mqprio()

v5:
- fix warning at NL_SET_ERR_MSG_FMT_MOD()

v4:
- use macro TO_MBPS()
- use bool for 'shaper_en'
- split code movement into separate patch
- drop rate vs link speed check as mqprio can be set at link down
- call am65_cpsw_reset_tc_mqprio() after pm_runtime_get_sync()

v2:
- clean up commit message
- avoid forward declarations
- use tc_mqprio_qopt_offload :: extack for error message reporting
- avoid unnecessary mqprio->qopt.hw == 0 checks
- set struct tc_mqprio_caps :: validate_queue_counts = true and get rid of am65_cpsw_mqprio_verify()
- do not modify AM65_CPSW_P0_REG_RX_PRI_MAP register.

drivers/net/ethernet/ti/am65-cpsw-nuss.c +3 -0
index 7651f90f51f2..2e374745f239 100644
@@ -2127,6 +2127,9 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
 				dev_err(dev, "Use random MAC address\n");
 			}
 		}
+
+		/* Reset all Queue priorities to 0 */
+		writel(0, port->port_base + AM65_CPSW_PN_REG_TX_PRI_MAP);
 	}
 	of_node_put(node);
 
drivers/net/ethernet/ti/am65-cpsw-qos.c +251 -3

314 lines not on this page · raw message

drivers/net/ethernet/ti/am65-cpsw-qos.h +20 -0
index d8bccfd48532..a0f9fa2eb2aa 100644
@@ -9,6 +9,7 @@
 #include <net/pkt_sched.h>
 
 struct am65_cpsw_common;
+struct am65_cpsw_port;
 
 struct am65_cpsw_est {
 	int buf;
@@ -16,6 +17,12 @@ struct am65_cpsw_est {
 	struct tc_taprio_qopt_offload taprio;
 };
 
+struct am65_cpsw_mqprio {
+	struct tc_mqprio_qopt_offload mqprio_hw;
+	u64 max_rate_total;
+	bool shaper_en;
+};
+
 struct am65_cpsw_ale_ratelimit {
 	unsigned long cookie;
 	u64 rate_packet_ps;
@@ -26,6 +33,7 @@ struct am65_cpsw_qos {
 	struct am65_cpsw_est *est_oper;
 	ktime_t link_down_time;
 	int link_speed;
+	struct am65_cpsw_mqprio mqprio;
 
 	struct am65_cpsw_ale_ratelimit ale_bc_ratelimit;
 	struct am65_cpsw_ale_ratelimit ale_mc_ratelimit;
@@ -36,6 +44,15 @@ struct am65_cpsw_qos {
 #define AM65_CPSW_PN_REG_FIFO_STATUS		0x050
 #define AM65_CPSW_PN_REG_EST_CTL		0x060
 #define AM65_CPSW_PN_REG_PRI_CIR(pri)		(0x140 + 4 * (pri))
+#define AM65_CPSW_P0_REG_PRI_EIR(pri)		(0x160 + 4 * (pri))
+
+#define AM65_CPSW_PN_REG_CTL			0x004
+#define AM65_CPSW_PN_REG_TX_PRI_MAP		0x018
+#define AM65_CPSW_PN_REG_RX_PRI_MAP		0x020
+#define AM65_CPSW_PN_REG_FIFO_STATUS		0x050
+#define AM65_CPSW_PN_REG_EST_CTL		0x060
+#define AM65_CPSW_PN_REG_PRI_CIR(pri)		(0x140 + 4 * (pri))
+#define AM65_CPSW_PN_REG_PRI_EIR(pri)		(0x160 + 4 * (pri))
 
 /* AM65_CPSW_REG_CTL register fields */
 #define AM65_CPSW_CTL_EST_EN			BIT(18)
@@ -66,6 +83,9 @@ struct am65_cpsw_qos {
 #define AM65_CPSW_FETCH_ALLOW_MSK		GENMASK(7, 0)
 #define AM65_CPSW_FETCH_ALLOW_MAX		AM65_CPSW_FETCH_ALLOW_MSK
 
+/* number of priority queues per port FIFO */
+#define AM65_CPSW_PN_FIFO_PRIO_NUM		8
+
 #if IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS)
 int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
 			       void *type_data);
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v7 net-next 5/8] net: ethernet: ti: am65-cpsw: add mqprio qdisc offload in channel mode

drivers/net/ethernet/ti/am65-cpsw-qos.c line 18

Quoted 9 lines · Roger Quadros
drivers/net/ethernet/ti/am65-cpsw-qos.c +1 -0
index 49ae9d1cd948..2733bac55bfa 100644
@@ -15,6 +15,8 @@
 #include "am65-cpts.h"
 #include "cpsw_ale.h"
 
+#define TO_MBPS(x)	((x) * 8 / 1000000)

Can be rewritten as ((x) * BITS_PER_BYTE / MEGA)

and further as ((x) / BYTES_PER_MBIT).

Also, I wonder if it wouldn't be better to do a DIV_ROUND_UP(x, BYTES_PER_MBIT) instead. When user space requests a certain bandwidth, it expects to get it. If the hardware is not fine grained enough, it should prefer giving it slightly more rather than slightly less.

#8 lore raw

PATCH v7 6/8 net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

In reply to Roger Quadros

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 157 ++++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-nuss.c    |   2 +
 drivers/net/ethernet/ti/am65-cpsw-nuss.h    |   5 +
 drivers/net/ethernet/ti/am65-cpsw-qos.c     | 175 ++++++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-qos.h     | 102 ++++++++++++
 5 files changed, 441 insertions(+)

Changelog:

v7:
- use else if
- drop FIXME comment
- fix lldp kselftest failure by limiting max_verify_time to spec limit of 128ms.
- now passes all ethtool_mm.sh kselftests (patch 8 required)

v6:
- get mutex around am65_cpsw_iet_commit_preemptible_tcs() in am65_cpsw_iet_change_preemptible_tcs()
- use "preemption" instead of "pre-emption"
- call am65_cpsw_setup_mqprio() from within am65_cpsw_setup_taprio()
- Now works with kselftest except the last test which fails

v5:
- No change

v4:
- Rebase and include in the same series as mqprio support.

v3:
- Rebase on top of v6.6-rc1 and mqprio support [1]
- Support ethtool_ops :: get_mm_stats()
- drop unused variables cmn_ctrl and verify_cnt
- make am65_cpsw_iet_link_state_update() and am65_cpsw_iet_change_preemptible_tcs() static

[1] https://lore.kernel.org/all/[email protected]/

v2:
- Use proper control bits for PMAC enable (AM65_CPSW_PN_CTL_IET_PORT_EN) and TX enable (AM65_CPSW_PN_IET_MAC_PENABLE)
- Common IET Enable (AM65_CPSW_CTL_IET_EN) is set if any port has AM65_CPSW_PN_CTL_IET_PORT_EN set.
- Fix workaround for erratum i2208. i.e. Limit rx_min_frag_size to 124
- Fix am65_cpsw_iet_get_verify_timeout_ms() to default to timeout for 1G link if link is inactive.
- resize the RX FIFO based on pmac_enabled, not tx_enabled.

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +157 -0
index b9e1d568604b..5571385b4baf 100644
@@ -11,6 +11,7 @@
 #include <linux/pm_runtime.h>
 
 #include "am65-cpsw-nuss.h"
+#include "am65-cpsw-qos.h"
 #include "cpsw_ale.h"
 #include "am65-cpts.h"
 
@@ -740,6 +741,159 @@ static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags)
 	return 0;
 }
 
+static void am65_cpsw_port_iet_rx_enable(struct am65_cpsw_port *port, bool enable)
+{
+	u32 val;
+
+	val = readl(port->port_base + AM65_CPSW_PN_REG_CTL);
+	if (enable)
+		val |= AM65_CPSW_PN_CTL_IET_PORT_EN;
+	else
+		val &= ~AM65_CPSW_PN_CTL_IET_PORT_EN;
+
+	writel(val, port->port_base + AM65_CPSW_PN_REG_CTL);
+	am65_cpsw_iet_common_enable(port->common);
+}
+
+static void am65_cpsw_port_iet_tx_enable(struct am65_cpsw_port *port, bool enable)
+{
+	u32 val;
+
+	val = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	if (enable)
+		val |= AM65_CPSW_PN_IET_MAC_PENABLE;
+	else
+		val &= ~AM65_CPSW_PN_IET_MAC_PENABLE;
+
+	writel(val, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+}
+
+static int am65_cpsw_get_mm(struct net_device *ndev, struct ethtool_mm_state *state)
+{
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+	struct am65_cpsw_ndev_priv *priv = netdev_priv(ndev);
+	u32 port_ctrl, iet_ctrl, iet_status;
+	u32 add_frag_size;
+
+	mutex_lock(&priv->mm_lock);
+
+	iet_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	port_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_CTL);
+
+	state->tx_enabled = !!(iet_ctrl & AM65_CPSW_PN_IET_MAC_PENABLE);
+	state->pmac_enabled = !!(port_ctrl & AM65_CPSW_PN_CTL_IET_PORT_EN);
+
+	iet_status = readl(port->port_base + AM65_CPSW_PN_REG_IET_STATUS);
+
+	if (iet_ctrl & AM65_CPSW_PN_IET_MAC_DISABLEVERIFY)
+		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_DISABLED;
+	else if (iet_status & AM65_CPSW_PN_MAC_VERIFIED)
+		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;
+	else if (iet_status & AM65_CPSW_PN_MAC_VERIFY_FAIL)
+		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_FAILED;
+	else
+		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_UNKNOWN;
+
+	add_frag_size = AM65_CPSW_PN_IET_MAC_GET_ADDFRAGSIZE(iet_ctrl);
+	state->tx_min_frag_size = ethtool_mm_frag_size_add_to_min(add_frag_size);
+
+	/* Errata i2208: RX min fragment size cannot be less than 124 */
+	state->rx_min_frag_size = 124;
+
+	/* FPE active if common tx_enabled and verification success or disabled (forced) */
+	state->tx_active = state->tx_enabled &&
+			   (state->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED ||
+			    state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED);
+	state->verify_enabled = !(iet_ctrl & AM65_CPSW_PN_IET_MAC_DISABLEVERIFY);
+
+	state->verify_time = port->qos.iet.verify_time_ms;
+
+	/* 802.3-2018 clause 30.14.1.6, says that the aMACMergeVerifyTime
+	 * variable has a range between 1 and 128 ms inclusive. Limit to that.
+	 */
+	state->max_verify_time = 128;
+
+	mutex_unlock(&priv->mm_lock);
+
+	return 0;
+}
+
+static int am65_cpsw_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
+			    struct netlink_ext_ack *extack)
+{
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+	struct am65_cpsw_ndev_priv *priv = netdev_priv(ndev);
+	struct am65_cpsw_iet *iet = &port->qos.iet;
+	u32 val, add_frag_size;
+	int err;
+
+	err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, &add_frag_size, extack);
+	if (err)
+		return err;
+
+	mutex_lock(&priv->mm_lock);
+
+	if (cfg->pmac_enabled) {
+		/* change TX & RX FIFO MAX_BLKS as per TRM recommendation */
+		if (!iet->original_max_blks)
+			iet->original_max_blks = readl(port->port_base + AM65_CPSW_PN_REG_MAX_BLKS);
+
+		writel(AM65_CPSW_PN_TX_RX_MAX_BLKS_IET,
+		       port->port_base + AM65_CPSW_PN_REG_MAX_BLKS);
+	} else if (iet->original_max_blks) {
+		/* restore RX & TX FIFO MAX_BLKS */
+		writel(iet->original_max_blks,
+		       port->port_base + AM65_CPSW_PN_REG_MAX_BLKS);
+	}
+
+	am65_cpsw_port_iet_rx_enable(port, cfg->pmac_enabled);
+	am65_cpsw_port_iet_tx_enable(port, cfg->tx_enabled);
+
+	val = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	if (cfg->verify_enabled) {
+		val &= ~AM65_CPSW_PN_IET_MAC_DISABLEVERIFY;
+		/* Reset Verify state machine. Verification won't start here.
+		 * Verification will be done once link-up.
+		 */
+		val |= AM65_CPSW_PN_IET_MAC_LINKFAIL;
+	} else {
+		val |= AM65_CPSW_PN_IET_MAC_DISABLEVERIFY;
+		/* Clear LINKFAIL to allow verify/response packets */
+		val &= ~AM65_CPSW_PN_IET_MAC_LINKFAIL;
+	}
+
+	val &= ~AM65_CPSW_PN_IET_MAC_MAC_ADDFRAGSIZE_MASK;
+	val |= AM65_CPSW_PN_IET_MAC_SET_ADDFRAGSIZE(add_frag_size);
+	writel(val, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+
+	/* verify_timeout_count can only be set at valid link */
+	if (cfg->verify_time > 0)
+		port->qos.iet.verify_time_ms = cfg->verify_time;
+	else
+		port->qos.iet.verify_time_ms = 10;
+
+	/* enable/disable preemption based on link status */
+	am65_cpsw_iet_commit_preemptible_tcs(port);
+
+	mutex_unlock(&priv->mm_lock);
+
+	return 0;
+}
+
+static void am65_cpsw_get_mm_stats(struct net_device *ndev,
+				   struct ethtool_mm_stats *s)
+{
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+	void __iomem *base = port->stat_base;
+
+	s->MACMergeFrameAssOkCount = readl(base + AM65_CPSW_STATN_IET_RX_ASSEMBLY_OK);
+	s->MACMergeFrameAssErrorCount = readl(base + AM65_CPSW_STATN_IET_RX_ASSEMBLY_ERROR);
+	s->MACMergeFrameSmdErrorCount = readl(base + AM65_CPSW_STATN_IET_RX_SMD_ERROR);
+	s->MACMergeFragCountRx = readl(base + AM65_CPSW_STATN_IET_RX_FRAG);
+	s->MACMergeFragCountTx = readl(base + AM65_CPSW_STATN_IET_TX_FRAG);
+	s->MACMergeHoldCount = readl(base + AM65_CPSW_STATN_IET_TX_HOLD);
+}
+
 const struct ethtool_ops am65_cpsw_ethtool_ops_slave = {
 	.begin			= am65_cpsw_ethtool_op_begin,
 	.complete		= am65_cpsw_ethtool_op_complete,
@@ -769,4 +923,7 @@ const struct ethtool_ops am65_cpsw_ethtool_ops_slave = {
 	.get_eee		= am65_cpsw_get_eee,
 	.set_eee		= am65_cpsw_set_eee,
 	.nway_reset		= am65_cpsw_nway_reset,
+	.get_mm			= am65_cpsw_get_mm,
+	.set_mm			= am65_cpsw_set_mm,
+	.get_mm_stats		= am65_cpsw_get_mm_stats,
 };
drivers/net/ethernet/ti/am65-cpsw-nuss.c +2 -0
index 2e374745f239..41e0046a52d5 100644
@@ -2194,6 +2194,8 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
 	ndev_priv = netdev_priv(port->ndev);
 	ndev_priv->port = port;
 	ndev_priv->msg_enable = AM65_CPSW_DEBUG;
+	mutex_init(&ndev_priv->mm_lock);
+	port->qos.link_speed = SPEED_UNKNOWN;
 	SET_NETDEV_DEV(port->ndev, dev);
 
 	eth_hw_addr_set(port->ndev, port->slave.mac_addr);
drivers/net/ethernet/ti/am65-cpsw-nuss.h +5 -0
index f3dad2ab9828..1e4a045057fc 100644
@@ -145,6 +145,7 @@ struct am65_cpsw_common {
 	bool			pf_p0_rx_ptype_rrobin;
 	struct am65_cpts	*cpts;
 	int			est_enabled;
+	bool			iet_enabled;
 
 	bool		is_emac_mode;
 	u16			br_members;
@@ -170,6 +171,10 @@ struct am65_cpsw_ndev_priv {
 	struct am65_cpsw_port	*port;
 	struct am65_cpsw_ndev_stats __percpu *stats;
 	bool offload_fwd_mark;
+	/* Serialize access to MAC Merge state between ethtool requests
+	 * and link state updates
+	 */
+	struct mutex		mm_lock;
 };
 
 #define am65_ndev_to_priv(ndev) \
drivers/net/ethernet/ti/am65-cpsw-qos.c +175 -0

227 lines not on this page · raw message

drivers/net/ethernet/ti/am65-cpsw-qos.h +102 -0

118 lines not on this page · raw message

Signature · 1 line
2.34.1
#9 lore raw

RE: [EXTERNAL] [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 13 lines

-----Original Message-----
From: Roger Quadros <[email protected]>

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

Quoted 5 lines

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

Should be 128 not 124

Quoted 43 lines

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 157 ++++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-nuss.c    |   2 +
 drivers/net/ethernet/ti/am65-cpsw-nuss.h    |   5 +
 drivers/net/ethernet/ti/am65-cpsw-qos.c     | 175 ++++++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-qos.h     | 102 ++++++++++++
 5 files changed, 441 insertions(+)

Changelog:

v7:
- use else if
- drop FIXME comment
- fix lldp kselftest failure by limiting max_verify_time to spec limit of 128ms.
- now passes all ethtool_mm.sh kselftests (patch 8 required)

v6:
- get mutex around am65_cpsw_iet_commit_preemptible_tcs() in am65_cpsw_iet_change_preemptible_tcs()
- use "preemption" instead of "pre-emption"
- call am65_cpsw_setup_mqprio() from within am65_cpsw_setup_taprio()
- Now works with kselftest except the last test which fails

v5:
- No change

v4:
- Rebase and include in the same series as mqprio support.

v3:
- Rebase on top of v6.6-rc1 and mqprio support [1]
- Support ethtool_ops :: get_mm_stats()
- drop unused variables cmn_ctrl and verify_cnt
- make am65_cpsw_iet_link_state_update() and am65_cpsw_iet_change_preemptible_tcs() static

[1] https://lore.kernel.org/all/[email protected]/

Quoted 7 lines

v2:
- Use proper control bits for PMAC enable (AM65_CPSW_PN_CTL_IET_PORT_EN)
and TX enable (AM65_CPSW_PN_IET_MAC_PENABLE)
- Common IET Enable (AM65_CPSW_CTL_IET_EN) is set if any port has AM65_CPSW_PN_CTL_IET_PORT_EN set.
- Fix workaround for erratum i2208. i.e. Limit rx_min_frag_size to 124

Should be 128 not 124

Quoted 84 lines

- Fix am65_cpsw_iet_get_verify_timeout_ms() to default to timeout for 1G link if link is inactive.
- resize the RX FIFO based on pmac_enabled, not tx_enabled.

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +43 -0
index b9e1d568604b..5571385b4baf 100644
@@ -11,6 +11,7 @@
 #include <linux/pm_runtime.h>
 
 #include "am65-cpsw-nuss.h"
+#include "am65-cpsw-qos.h"
 #include "cpsw_ale.h"
 #include "am65-cpts.h"
 
@@ -740,6 +741,159 @@ static int am65_cpsw_set_ethtool_priv_flags(struct
 net_device *ndev, u32 flags)
 	return 0;
 }
 
+static void am65_cpsw_port_iet_rx_enable(struct am65_cpsw_port *port,
+bool enable) {
+	u32 val;
+
+	val = readl(port->port_base + AM65_CPSW_PN_REG_CTL);
+	if (enable)
+		val |= AM65_CPSW_PN_CTL_IET_PORT_EN;
+	else
+		val &= ~AM65_CPSW_PN_CTL_IET_PORT_EN;
+
+	writel(val, port->port_base + AM65_CPSW_PN_REG_CTL);
+	am65_cpsw_iet_common_enable(port->common);
+}
+
+static void am65_cpsw_port_iet_tx_enable(struct am65_cpsw_port *port,
+bool enable) {
+	u32 val;
+
+	val = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	if (enable)
+		val |= AM65_CPSW_PN_IET_MAC_PENABLE;
+	else
+		val &= ~AM65_CPSW_PN_IET_MAC_PENABLE;
+
+	writel(val, port->port_base + AM65_CPSW_PN_REG_IET_CTRL); }
+
+static int am65_cpsw_get_mm(struct net_device *ndev, struct
+ethtool_mm_state *state) {
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+	struct am65_cpsw_ndev_priv *priv = netdev_priv(ndev);
+	u32 port_ctrl, iet_ctrl, iet_status;
+	u32 add_frag_size;
+
+	mutex_lock(&priv->mm_lock);
+
+	iet_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	port_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_CTL);
+
+	state->tx_enabled = !!(iet_ctrl &
 AM65_CPSW_PN_IET_MAC_PENABLE);
+	state->pmac_enabled = !!(port_ctrl &
 AM65_CPSW_PN_CTL_IET_PORT_EN);
+
+	iet_status = readl(port->port_base +

AM65_CPSW_PN_REG_IET_STATUS);

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +3 -0
+
+	if (iet_ctrl & AM65_CPSW_PN_IET_MAC_DISABLEVERIFY)
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_DISABLED;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+	else if (iet_status & AM65_CPSW_PN_MAC_VERIFIED)
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+	else if (iet_status & AM65_CPSW_PN_MAC_VERIFY_FAIL)
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_FAILED;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+	else
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_UNKNOWN;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+
+	add_frag_size =

AM65_CPSW_PN_IET_MAC_GET_ADDFRAGSIZE(iet_ctrl);

drivers/net/ethernet/ti/am65-cpsw-ethtool.c static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags) · line 801

Quoted 5 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +5 -0
+	state->tx_min_frag_size =
+ethtool_mm_frag_size_add_to_min(add_frag_size);
+
+	/* Errata i2208: RX min fragment size cannot be less than 124 */
+	state->rx_min_frag_size = 124;

/* Errata i2208: RX min fragment size cannot be less than 128 */ state->rx_min_frag_size = 128;

Pekka

#10 lore raw

Re: [EXTERNAL] [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Hi Pekka,

Quoted 13 lines · Pekka
Quoted 13 lines

-----Original Message-----
From: Roger Quadros <[email protected]>

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

Quoted 7 lines
Quoted 5 lines

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

Should be 128 not 124

User space setting is without FCS.

Quoted 138 lines
Quoted 44 lines

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 157 ++++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-nuss.c    |   2 +
 drivers/net/ethernet/ti/am65-cpsw-nuss.h    |   5 +
 drivers/net/ethernet/ti/am65-cpsw-qos.c     | 175 ++++++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-qos.h     | 102 ++++++++++++
 5 files changed, 441 insertions(+)

Changelog:

v7:
- use else if
- drop FIXME comment
- fix lldp kselftest failure by limiting max_verify_time to spec limit of 128ms.
- now passes all ethtool_mm.sh kselftests (patch 8 required)

v6:
- get mutex around am65_cpsw_iet_commit_preemptible_tcs() in am65_cpsw_iet_change_preemptible_tcs()
- use "preemption" instead of "pre-emption"
- call am65_cpsw_setup_mqprio() from within am65_cpsw_setup_taprio()
- Now works with kselftest except the last test which fails

v5:
- No change

v4:
- Rebase and include in the same series as mqprio support.

v3:
- Rebase on top of v6.6-rc1 and mqprio support [1]
- Support ethtool_ops :: get_mm_stats()
- drop unused variables cmn_ctrl and verify_cnt
- make am65_cpsw_iet_link_state_update() and am65_cpsw_iet_change_preemptible_tcs() static

[1] https://lore.kernel.org/all/[email protected]/

Quoted 7 lines

v2:
- Use proper control bits for PMAC enable (AM65_CPSW_PN_CTL_IET_PORT_EN)
and TX enable (AM65_CPSW_PN_IET_MAC_PENABLE)
- Common IET Enable (AM65_CPSW_CTL_IET_EN) is set if any port has AM65_CPSW_PN_CTL_IET_PORT_EN set.
- Fix workaround for erratum i2208. i.e. Limit rx_min_frag_size to 124

Should be 128 not 124

Quoted 84 lines

- Fix am65_cpsw_iet_get_verify_timeout_ms() to default to timeout for 1G link if link is inactive.
- resize the RX FIFO based on pmac_enabled, not tx_enabled.

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +43 -0
index b9e1d568604b..5571385b4baf 100644
@@ -11,6 +11,7 @@
 #include <linux/pm_runtime.h>
 
 #include "am65-cpsw-nuss.h"
+#include "am65-cpsw-qos.h"
 #include "cpsw_ale.h"
 #include "am65-cpts.h"
 
@@ -740,6 +741,159 @@ static int am65_cpsw_set_ethtool_priv_flags(struct
 net_device *ndev, u32 flags)
 	return 0;
 }
 
+static void am65_cpsw_port_iet_rx_enable(struct am65_cpsw_port *port,
+bool enable) {
+	u32 val;
+
+	val = readl(port->port_base + AM65_CPSW_PN_REG_CTL);
+	if (enable)
+		val |= AM65_CPSW_PN_CTL_IET_PORT_EN;
+	else
+		val &= ~AM65_CPSW_PN_CTL_IET_PORT_EN;
+
+	writel(val, port->port_base + AM65_CPSW_PN_REG_CTL);
+	am65_cpsw_iet_common_enable(port->common);
+}
+
+static void am65_cpsw_port_iet_tx_enable(struct am65_cpsw_port *port,
+bool enable) {
+	u32 val;
+
+	val = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	if (enable)
+		val |= AM65_CPSW_PN_IET_MAC_PENABLE;
+	else
+		val &= ~AM65_CPSW_PN_IET_MAC_PENABLE;
+
+	writel(val, port->port_base + AM65_CPSW_PN_REG_IET_CTRL); }
+
+static int am65_cpsw_get_mm(struct net_device *ndev, struct
+ethtool_mm_state *state) {
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+	struct am65_cpsw_ndev_priv *priv = netdev_priv(ndev);
+	u32 port_ctrl, iet_ctrl, iet_status;
+	u32 add_frag_size;
+
+	mutex_lock(&priv->mm_lock);
+
+	iet_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	port_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_CTL);
+
+	state->tx_enabled = !!(iet_ctrl &
 AM65_CPSW_PN_IET_MAC_PENABLE);
+	state->pmac_enabled = !!(port_ctrl &
 AM65_CPSW_PN_CTL_IET_PORT_EN);
+
+	iet_status = readl(port->port_base +

AM65_CPSW_PN_REG_IET_STATUS);

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +3 -0
+
+	if (iet_ctrl & AM65_CPSW_PN_IET_MAC_DISABLEVERIFY)
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_DISABLED;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+	else if (iet_status & AM65_CPSW_PN_MAC_VERIFIED)
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+	else if (iet_status & AM65_CPSW_PN_MAC_VERIFY_FAIL)
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_FAILED;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+	else
+		state->verify_status =

ETHTOOL_MM_VERIFY_STATUS_UNKNOWN;

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+
+	add_frag_size =

AM65_CPSW_PN_IET_MAC_GET_ADDFRAGSIZE(iet_ctrl);

Quoted 8 lines

drivers/net/ethernet/ti/am65-cpsw-ethtool.c static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags) · line 801

Quoted 5 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +5 -0
+	state->tx_min_frag_size =
+ethtool_mm_frag_size_add_to_min(add_frag_size);
+
+	/* Errata i2208: RX min fragment size cannot be less than 124 */
+	state->rx_min_frag_size = 124;

/* Errata i2208: RX min fragment size cannot be less than 128 */ state->rx_min_frag_size = 128;

ethtool man page says
" tx-min-frag-size
Shows the minimum size (in octets) of transmitted non- final fragments which can be received by the link partner. Corresponds to the standard addFragSize variable using the formula:

tx-min-frag-size = 64 * (1 + addFragSize) - 4"

Which means user needs to put a -4 offset i.e. drop FCS size.

Drivers show rx-min-frag-size also without the FCS.

e.g.
https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/mscc/ocelot_mm.c#L260

Signature · 2 lines
cheers,
-roger
#11 lore raw

Re: [EXTERNAL] [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 5 lines · Roger Quadros
Quoted 3 lines
Quoted 1 line

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

Should be 128 not 124

User space setting is without FCS.

Technically it's called mCRC for preemptible frames, but yes.

Quoted 13 lines
Quoted 5 lines

drivers/net/ethernet/ti/am65-cpsw-ethtool.c static int am65_cpsw_set_ethtool_priv_flags(struct net_device *ndev, u32 flags) · line 801

Quoted 2 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +2 -0
+	/* Errata i2208: RX min fragment size cannot be less than 124 */
+	state->rx_min_frag_size = 124;

/* Errata i2208: RX min fragment size cannot be less than 128 */ state->rx_min_frag_size = 128;

ethtool man page says
" tx-min-frag-size
Shows the minimum size (in octets) of transmitted non- final fragments which can be received by the link partner. Corresponds to the standard addFragSize variable using the formula:

Quoted 8 lines

tx-min-frag-size = 64 * (1 + addFragSize) - 4"

Which means user needs to put a -4 offset i.e. drop FCS size.

Drivers show rx-min-frag-size also without the FCS.

e.g.
https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/mscc/ocelot_mm.c#L260

Ack.

Reviewed-by on v7 6/8
#12 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

In reply to Roger Quadros
Quoted 12 lines · Roger Quadros

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Quoted 7 lines

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---

pw-bot: under-review

#13 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

In reply to Roger Quadros
Quoted 12 lines · Roger Quadros

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Quoted 7 lines

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---

Actually...

ld.lld: error: undefined symbol: am65_cpsw_iet_common_enable

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

ld.lld: error: undefined symbol: am65_cpsw_iet_commit_preemptible_tcs

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m

am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c, built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.

#14 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 38 lines · Vladimir Oltean
Quoted 12 lines · Roger Quadros

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Quoted 7 lines

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---

Actually...

ld.lld: error: undefined symbol: am65_cpsw_iet_common_enable

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

ld.lld: error: undefined symbol: am65_cpsw_iet_commit_preemptible_tcs

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m

Quoted 2 lines

am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c, built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.

Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?

Signature · 2 lines
cheers,
-roger
#15 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 41 lines · Roger Quadros
Quoted 38 lines · Vladimir Oltean
Quoted 12 lines · Roger Quadros

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Quoted 7 lines

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---

Actually...

ld.lld: error: undefined symbol: am65_cpsw_iet_common_enable

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

ld.lld: error: undefined symbol: am65_cpsw_iet_commit_preemptible_tcs

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m

Quoted 5 lines
Quoted 2 lines

am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c, built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.

Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?

How about this fix?

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +6 -0
index 1ac4b9b53c93..688291d6038f 100644
@@ -775,6 +775,9 @@ static int am65_cpsw_get_mm(struct net_device *ndev, struct ethtool_mm_state *st
 	u32 port_ctrl, iet_ctrl, iet_status;
 	u32 add_frag_size;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	mutex_lock(&priv->mm_lock);
 
 	iet_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
@@ -827,6 +830,9 @@ static int am65_cpsw_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
 	u32 val, add_frag_size;
 	int err;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, &add_frag_size, extack);
 	if (err)
 		return err;
drivers/net/ethernet/ti/am65-cpsw-qos.h +6 -2
index 6df3c2c5a04b..946e89fbb314 100644
@@ -100,6 +100,8 @@ void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed);
 void am65_cpsw_qos_link_down(struct net_device *ndev);
 int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev, int queue, u32 rate_mbps);
 void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common);
+void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
+void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 #else
 static inline int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev,
 					     enum tc_setup_type type,
@@ -124,10 +126,12 @@ static inline int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev,
 
 static inline void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
 { }
+static inline void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port)
+{ }
+static inline void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common)
+{ }
 #endif
 
-void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
-void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 
 #define AM65_CPSW_REG_CTL			0x004
 #define AM65_CPSW_PN_REG_CTL			0x004
Signature · 2 lines
cheers,
-roger
#16 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 96 lines · Roger Quadros
Quoted 41 lines · Roger Quadros
Quoted 38 lines · Vladimir Oltean
Quoted 12 lines · Roger Quadros

Add driver support for viewing / changing the MAC Merge sublayer parameters and seeing the verification state machine's current state via ethtool.

As hardware does not support interrupt notification for verification events we resort to polling on link up. On link up we try a couple of times for verification success and if unsuccessful then give up.

The Frame Preemption feature is described in the Technical Reference Manual [1] in section:

	12.3.1.4.6.7 Intersperced Express Traffic (IET – P802.3br/D2.0)
Quoted 7 lines

Due to Silicon Errata i2208 [2] we set limit min IET fragment size to 124.

[1] AM62x TRM - https://www.ti.com/lit/ug/spruiv7a/spruiv7a.pdf
[2] AM62x Silicon Errata - https://www.ti.com/lit/er/sprz487c/sprz487c.pdf

---

Actually...

ld.lld: error: undefined symbol: am65_cpsw_iet_common_enable

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:755 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:755)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

ld.lld: error: undefined symbol: am65_cpsw_iet_commit_preemptible_tcs

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by am65-cpsw-ethtool.c:876 (drivers/net/ethernet/ti/am65-cpsw-ethtool.c:876)
drivers/net/ethernet/ti/am65-cpsw-ethtool.o:(am65_cpsw_set_mm) in archive vmlinux.a

cat $KBUILD_OUTPUT/.config | grep AM65
CONFIG_TI_K3_AM65_CPSW_NUSS=y
# CONFIG_TI_K3_AM65_CPSW_SWITCHDEV is not set
# CONFIG_TI_K3_AM65_CPTS is not set
CONFIG_MMC_SDHCI_AM654=y
CONFIG_PHY_AM654_SERDES=m

Quoted 5 lines
Quoted 2 lines

am65-cpsw-qos.c is built only if CONFIG_TI_AM65_CPSW_TAS is enabled, yet am65-cpsw-ethtool.c, built by CONFIG_TI_K3_AM65_CPSW_NUSS, depends on it.

Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?

How about this fix?

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +6 -0
index 1ac4b9b53c93..688291d6038f 100644
@@ -775,6 +775,9 @@ static int am65_cpsw_get_mm(struct net_device *ndev, struct ethtool_mm_state *st
 	u32 port_ctrl, iet_ctrl, iet_status;
 	u32 add_frag_size;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	mutex_lock(&priv->mm_lock);
 
 	iet_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
@@ -827,6 +830,9 @@ static int am65_cpsw_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
 	u32 val, add_frag_size;
 	int err;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, &add_frag_size, extack);
 	if (err)
 		return err;
drivers/net/ethernet/ti/am65-cpsw-qos.h +3 -0
index 6df3c2c5a04b..946e89fbb314 100644
@@ -100,6 +100,8 @@ void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed);
 void am65_cpsw_qos_link_down(struct net_device *ndev);
 int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev, int queue, u32 rate_mbps);
 void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common);
+void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
+void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 #else
 static inline int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev,
 					     enum tc_setup_type type,
@@ -124,10 +126,12 @@ static inline int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev,
 
 static inline void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
 { }
+static inline void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port)

drivers/net/ethernet/ti/am65-cpsw-qos.h static inline int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev, · line 137

Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-qos.h +3 -2
+{ }
+static inline void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common)
+{ }
 #endif
 
-void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
-void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 
 #define AM65_CPSW_REG_CTL			0x004
 #define AM65_CPSW_PN_REG_CTL			0x004

But,

bool __ethtool_dev_mm_supported(struct net_device *dev)

{
	const struct ethtool_ops *ops = dev->ethtool_ops;
	struct ethtool_mm_state state = {};
	int ret = -EOPNOTSUPP;

	if (ops && ops->get_mm)
		ret = ops->get_mm(dev, &state);

	return !ret;
}

So looks like it is better to not define get_mm/set_mm if CONFIG_TI_AM65_CPSW_TAS is disabled.

Signature · 2 lines
cheers,
-roger
#17 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 14 lines · Roger Quadros

But,

bool __ethtool_dev_mm_supported(struct net_device *dev)

{
	const struct ethtool_ops *ops = dev->ethtool_ops;
	struct ethtool_mm_state state = {};
	int ret = -EOPNOTSUPP;

	if (ops && ops->get_mm)
		ret = ops->get_mm(dev, &state);

	return !ret;
}
Quoted 1 line

So looks like it is better to not define get_mm/set_mm if CONFIG_TI_AM65_CPSW_TAS is disabled.

Why not? __ethtool_dev_mm_supported() returns true if os->get_mm() is implemented and returns 0. You return -EOPNOTSUPP, and that's different from 0.

#18 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 12 lines · Vladimir Oltean
Quoted 11 lines · Roger Quadros

But,

bool __ethtool_dev_mm_supported(struct net_device *dev)

{
	const struct ethtool_ops *ops = dev->ethtool_ops;
	struct ethtool_mm_state state = {};
	int ret = -EOPNOTSUPP;

	if (ops && ops->get_mm)
		ret = ops->get_mm(dev, &state);
Quoted 8 lines
Quoted 4 lines
	return !ret;
}

So looks like it is better to not define get_mm/set_mm if CONFIG_TI_AM65_CPSW_TAS is disabled.

Why not? __ethtool_dev_mm_supported() returns true if os->get_mm() is implemented and returns 0. You return -EOPNOTSUPP, and that's different from 0.

Yes, I realized it eventually. Better to define it and return -EOPNOTSUPP if CONFIG_TI_AM65_CPSW_TAS is not enabled.

Signature · 2 lines
cheers,
-roger
#19 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

In reply to Roger Quadros
Quoted 63 lines · Roger Quadros
Quoted 2 lines · Roger Quadros

Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?

How about this fix?

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +6 -0
index 1ac4b9b53c93..688291d6038f 100644
@@ -775,6 +775,9 @@ static int am65_cpsw_get_mm(struct net_device *ndev, struct ethtool_mm_state *st
 	u32 port_ctrl, iet_ctrl, iet_status;
 	u32 add_frag_size;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	mutex_lock(&priv->mm_lock);
 
 	iet_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
@@ -827,6 +830,9 @@ static int am65_cpsw_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
 	u32 val, add_frag_size;
 	int err;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, &add_frag_size, extack);
 	if (err)
 		return err;
drivers/net/ethernet/ti/am65-cpsw-qos.h +6 -2
index 6df3c2c5a04b..946e89fbb314 100644
@@ -100,6 +100,8 @@ void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed);
 void am65_cpsw_qos_link_down(struct net_device *ndev);
 int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev, int queue, u32 rate_mbps);
 void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common);
+void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
+void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 #else
 static inline int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev,
 					     enum tc_setup_type type,
@@ -124,10 +126,12 @@ static inline int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev,
 
 static inline void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
 { }
+static inline void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port)
+{ }
+static inline void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common)
+{ }
 #endif
 
-void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
-void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 
 #define AM65_CPSW_REG_CTL			0x004
 #define AM65_CPSW_PN_REG_CTL			0x004
Signature · 3 lines
-- 
cheers,
-roger

I don't know, does it sound like it is related?

config TI_AM65_CPSW_TAS
bool "Enable TAS offload in AM65 CPSW"
depends on TI_K3_AM65_CPSW_NUSS && NET_SCH_TAPRIO && TI_K3_AM65_CPTS help
Say y here to support Time Aware Shaper(TAS) offload in AM65 CPSW. AM65 CPSW hardware supports Enhanced Scheduled Traffic (EST) defined in IEEE 802.1Q 2018. The EST scheduler runs on CPTS and the TAS/EST schedule is updated in the Fetch RAM memory of the CPSW.

#20 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 67 lines · Vladimir Oltean
Quoted 63 lines · Roger Quadros
Quoted 2 lines · Roger Quadros

Wondering how to fix this the right way. Should set/get_mm fail if CONFIG_TI_AM65_CPSW_TAS is not enabled?

How about this fix?

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +6 -0
index 1ac4b9b53c93..688291d6038f 100644
@@ -775,6 +775,9 @@ static int am65_cpsw_get_mm(struct net_device *ndev, struct ethtool_mm_state *st
 	u32 port_ctrl, iet_ctrl, iet_status;
 	u32 add_frag_size;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	mutex_lock(&priv->mm_lock);
 
 	iet_ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
@@ -827,6 +830,9 @@ static int am65_cpsw_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
 	u32 val, add_frag_size;
 	int err;
 
+	if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
+		return -EOPNOTSUPP;
+
 	err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, &add_frag_size, extack);
 	if (err)
 		return err;
drivers/net/ethernet/ti/am65-cpsw-qos.h +6 -2
index 6df3c2c5a04b..946e89fbb314 100644
@@ -100,6 +100,8 @@ void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed);
 void am65_cpsw_qos_link_down(struct net_device *ndev);
 int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev, int queue, u32 rate_mbps);
 void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common);
+void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
+void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 #else
 static inline int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev,
 					     enum tc_setup_type type,
@@ -124,10 +126,12 @@ static inline int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev,
 
 static inline void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
 { }
+static inline void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port)
+{ }
+static inline void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common)
+{ }
 #endif
 
-void am65_cpsw_iet_commit_preemptible_tcs(struct am65_cpsw_port *port);
-void am65_cpsw_iet_common_enable(struct am65_cpsw_common *common);
 
 #define AM65_CPSW_REG_CTL			0x004
 #define AM65_CPSW_PN_REG_CTL			0x004
Signature · 3 lines
-- 
cheers,
-roger

I don't know, does it sound like it is related?

Quoted 8 lines

config TI_AM65_CPSW_TAS
bool "Enable TAS offload in AM65 CPSW"
depends on TI_K3_AM65_CPSW_NUSS && NET_SCH_TAPRIO && TI_K3_AM65_CPTS help
Say y here to support Time Aware Shaper(TAS) offload in AM65 CPSW. AM65 CPSW hardware supports Enhanced Scheduled Traffic (EST) defined in IEEE 802.1Q 2018. The EST scheduler runs on CPTS and the TAS/EST schedule is updated in the Fetch RAM memory of the CPSW.

The config option mentions only about TAS/EST 802.1Qbv.
Maybe it needs to be extended to include IET/Frame-preeption 802.1Qbu as well?

This is the simplest way as the file am65-cpsw-qos.c can be completely omitted if TI_AM65_CPSW_TSN is not set.

Signature · 2 lines
cheers,
-roger
#21 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 5 lines · Roger Quadros

The config option mentions only about TAS/EST 802.1Qbv.
Maybe it needs to be extended to include IET/Frame-preeption 802.1Qbu as well?

This is the simplest way as the file am65-cpsw-qos.c can be completely omitted if TI_AM65_CPSW_TSN is not set.

As long as you need to look no further than in "make menuconfig" to figure out what you're enabling, it should be fine.

Furthermore, some consistency between the file name (-qos.c) and the Kconfig option (_TAS/_TSN) would be nice.

#22 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

In reply to Roger Quadros
Quoted 1 line · Roger Quadros

- now passes all ethtool_mm.sh kselftests (patch 8 required)

There's another problem with your patch set, leading to the traffic_test() selftest passing with the "emac" and "pmac" argument when it shouldn't.

Drivers which implement frame preemption are supposed to be prepared to distinguish, in their ethtool get_eth_mac_stats() method, between ETHTOOL_MAC_STATS_SRC_EMAC, ETHTOOL_MAC_STATS_SRC_PMAC and ETHTOOL_MAC_STATS_SRC_AGGREGATE. You don't, so you report the same thing everywhere, which is incorrect, and it also fools the selftest.

I would like you to figure out which source are your stats coming from, reject everything else, and edit the selftest to do something sensible for your hardware. If it's as I suspect and the reported counters are eMAC+pMAC aggregates, then I guess the most sensible thing to do would be to probe the device with an ethtool -S --src pmac at the beginning of the test, see what it reports, and if we don't get pMAC counters from it, fall back to aggregate ones during calls to traffic_test().

#23 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 13 lines · Vladimir Oltean
Quoted 1 line · Roger Quadros

- now passes all ethtool_mm.sh kselftests (patch 8 required)

There's another problem with your patch set, leading to the traffic_test() selftest passing with the "emac" and "pmac" argument when it shouldn't.

Drivers which implement frame preemption are supposed to be prepared to distinguish, in their ethtool get_eth_mac_stats() method, between ETHTOOL_MAC_STATS_SRC_EMAC, ETHTOOL_MAC_STATS_SRC_PMAC and ETHTOOL_MAC_STATS_SRC_AGGREGATE. You don't, so you report the same thing everywhere, which is incorrect, and it also fools the selftest.

Quoted 7 lines

I would like you to figure out which source are your stats coming from, reject everything else, and edit the selftest to do something sensible for your hardware. If it's as I suspect and the reported counters are eMAC+pMAC aggregates, then I guess the most sensible thing to do would be to probe the device with an ethtool -S --src pmac at the beginning of the test, see what it reports, and if we don't get pMAC counters from it, fall back to aggregate ones during calls to traffic_test().

Thanks for the catch.

How do the below 2 patches look to resolve this?

From af2a8503dc04c54d6eaf50954628009aba54e2c8 Mon Sep 17 00:00:00 2001
From: Roger Quadros <[email protected]>
Date: Fri, 8 Dec 2023 15:11:06 +0200
Subject: [PATCH] net: ethernet: ti: am65-cpsw: Fix get_eth_mac_stats

We do not support individual stats for PMAC and EMAC so report only aggregate stats.

Fixes 67372d7a85fcd ("net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool")
---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 37 ++++++++++++---------
 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +21 -15
index 44e01d68db39..934b03382508 100644
@@ -671,21 +671,28 @@ static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev,
 
 	stats = port->stat_base;
 
-	s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
-	s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
-	s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
-	s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
-	s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
-	s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
-	s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
-	s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
-	s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
-	s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
-	s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
-	s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
-	s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
-	s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
-	s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
+        switch (s->src) {
+	case ETHTOOL_MAC_STATS_SRC_AGGREGATE:
+		s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
+		s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
+		s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
+		s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
+		s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
+		s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
+		s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
+		s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
+		s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
+		s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
+		s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
+		s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
+		s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
+		s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
+		s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
+		break;
+	default:
+		break;
+	}
 };
 
 static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,

base-commit: a78e0a2c4353d6c100e45c5ef738113bf2d0fda5

Signature · 18 lines
2.34.1




From 0b20d8b8ef110d886396ee2486f3a9e20170cc85 Mon Sep 17 00:00:00 2001
From: Roger Quadros <[email protected]>
Date: Fri, 8 Dec 2023 15:38:57 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: support devices that don't
 support pmac stats

Some devices do not support individual 'pmac' and 'emac' stats.
For such devices, resort to 'aggregate' stats.

Signed-off-by: Roger Quadros <[email protected]>
---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +7 -0
index 6212913f4ad1..e3f2e62029ca 100755
@@ -26,6 +26,13 @@ traffic_test()
 	local delta=
 
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
+	# some devices don't support individual pmac/emac stats,
+	# use aggregate stats for them.
+        if [ "$before" == null ]; then
+                src="aggregate"
+                before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOO
+K" $src)
+        fi
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
 

base-commit: af2a8503dc04c54d6eaf50954628009aba54e2c8

Signature · 5 lines
2.34.1

-- 
cheers,
-roger
#24 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 51 lines · Roger Quadros

How do the below 2 patches look to resolve this?

From af2a8503dc04c54d6eaf50954628009aba54e2c8 Mon Sep 17 00:00:00 2001
From: Roger Quadros <[email protected]>
Date: Fri, 8 Dec 2023 15:11:06 +0200
Subject: [PATCH] net: ethernet: ti: am65-cpsw: Fix get_eth_mac_stats

We do not support individual stats for PMAC and EMAC so report only aggregate stats.

Fixes 67372d7a85fcd ("net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool")
---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 37 ++++++++++++---------
 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +12 -15
index 44e01d68db39..934b03382508 100644
@@ -671,21 +671,28 @@ static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev,
 
 	stats = port->stat_base;
 
-	s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
-	s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
-	s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
-	s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
-	s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
-	s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
-	s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
-	s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
-	s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
-	s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
-	s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
-	s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
-	s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
-	s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
-	s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
+        switch (s->src) {
+	case ETHTOOL_MAC_STATS_SRC_AGGREGATE:
+		s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
+		s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
+		s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
+		s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
+		s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
+		s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
+		s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
+		s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
+		s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
+		s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);

drivers/net/ethernet/ti/am65-cpsw-ethtool.c static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev, · line 695

Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +9 -0
+		s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
+		s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
+		s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
+		s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
+		s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
+		break;
+	default:
+		break;
+	}
 };
	if (s->src != ETHTOOL_MAC_STATS_SRC_AGGREGATE)
		return;

Also, again, tabs mixed with spaces. What editor are you using, notepad?

Quoted 43 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +0 -0
 static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
 

base-commit: a78e0a2c4353d6c100e45c5ef738113bf2d0fda5

Signature · 18 lines
2.34.1




From 0b20d8b8ef110d886396ee2486f3a9e20170cc85 Mon Sep 17 00:00:00 2001
From: Roger Quadros <[email protected]>
Date: Fri, 8 Dec 2023 15:38:57 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: support devices that don't
 support pmac stats

Some devices do not support individual 'pmac' and 'emac' stats.
For such devices, resort to 'aggregate' stats.

Signed-off-by: Roger Quadros <[email protected]>
---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +7 -0
index 6212913f4ad1..e3f2e62029ca 100755
@@ -26,6 +26,13 @@ traffic_test()
 	local delta=
 
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
+	# some devices don't support individual pmac/emac stats,
+	# use aggregate stats for them.
+        if [ "$before" == null ]; then
+                src="aggregate"
+                before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOO
+K" $src)
+        fi
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
 
Quoted 7 lines

base-commit: af2a8503dc04c54d6eaf50954628009aba54e2c8

Signature · 5 lines
2.34.1

-- 
cheers,
-roger

I commented on the second patch when you submitted it.

#25 lore raw

Re: [PATCH v7 net-next 6/8] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

Quoted 57 lines · Vladimir Oltean
Quoted 56 lines · Roger Quadros

How do the below 2 patches look to resolve this?

From af2a8503dc04c54d6eaf50954628009aba54e2c8 Mon Sep 17 00:00:00 2001
From: Roger Quadros <[email protected]>
Date: Fri, 8 Dec 2023 15:11:06 +0200
Subject: [PATCH] net: ethernet: ti: am65-cpsw: Fix get_eth_mac_stats

We do not support individual stats for PMAC and EMAC so report only aggregate stats.

Fixes 67372d7a85fcd ("net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool")
---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 37 ++++++++++++---------
 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +17 -15
index 44e01d68db39..934b03382508 100644
@@ -671,21 +671,28 @@ static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev,
 
 	stats = port->stat_base;
 
-	s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
-	s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
-	s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
-	s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
-	s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
-	s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
-	s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
-	s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
-	s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
-	s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
-	s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
-	s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
-	s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
-	s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
-	s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
+        switch (s->src) {
+	case ETHTOOL_MAC_STATS_SRC_AGGREGATE:
+		s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
+		s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
+		s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
+		s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
+		s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
+		s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
+		s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
+		s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
+		s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
+		s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
+		s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
+		s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
+		s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
+		s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
+		s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
Quoted 8 lines

drivers/net/ethernet/ti/am65-cpsw-ethtool.c static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev, · line 695

Quoted 5 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +4 -0
+		break;
+	default:
+		break;
+	}
 };
	if (s->src != ETHTOOL_MAC_STATS_SRC_AGGREGATE)
		return;

Is better.

Quoted 2 lines

Also, again, tabs mixed with spaces. What editor are you using, notepad?

I'm using vim but I didn't run checkpatch on it before pasting it here for quick feedback.

Quoted 53 lines
Quoted 44 lines
drivers/net/ethernet/ti/am65-cpsw-ethtool.c +0 -0
 static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
 

base-commit: a78e0a2c4353d6c100e45c5ef738113bf2d0fda5

Signature · 18 lines
2.34.1




From 0b20d8b8ef110d886396ee2486f3a9e20170cc85 Mon Sep 17 00:00:00 2001
From: Roger Quadros <[email protected]>
Date: Fri, 8 Dec 2023 15:38:57 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: support devices that don't
 support pmac stats

Some devices do not support individual 'pmac' and 'emac' stats.
For such devices, resort to 'aggregate' stats.

Signed-off-by: Roger Quadros <[email protected]>
---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +7 -0
index 6212913f4ad1..e3f2e62029ca 100755
@@ -26,6 +26,13 @@ traffic_test()
 	local delta=
 
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
+	# some devices don't support individual pmac/emac stats,
+	# use aggregate stats for them.
+        if [ "$before" == null ]; then
+                src="aggregate"
+                before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOO
+K" $src)
+        fi
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
 
Quoted 7 lines

base-commit: af2a8503dc04c54d6eaf50954628009aba54e2c8

Signature · 5 lines
2.34.1

-- 
cheers,
-roger

I commented on the second patch when you submitted it.

Signature · 2 lines
cheers,
-roger
#26 lore raw

PATCH v7 7/8 net: ethernet: ti: am65-cpsw: add sw tx/rx irq coalescing based on hrtimers

In reply to Roger Quadros

From: Grygorii Strashko <[email protected]>

Add SW IRQ coalescing based on hrtimers for TX and RX data path which can be enabled by ethtool commands:

- RX coalescing
ethtool -C eth1 rx-usecs 50

- TX coalescing can be enabled per TX queue

- by default enables coalesing for TX0
ethtool -C eth1 tx-usecs 50
- configure TX0
ethtool -Q eth0 queue_mask 1 --coalesce tx-usecs 100
- configure TX1
ethtool -Q eth0 queue_mask 2 --coalesce tx-usecs 100
- configure TX0 and TX1
ethtool -Q eth0 queue_mask 3 --coalesce tx-usecs 100 --coalesce tx-usecs 100

show configuration for TX0 and TX1:
ethtool -Q eth0 queue_mask 3 --show-coalesce

Comparing to gro_flush_timeout and napi_defer_hard_irqs, this patch allows to enable IRQ coalesing for RX path separately.

---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 79 +++++++++++++++++++++
 drivers/net/ethernet/ti/am65-cpsw-nuss.c    | 59 ++++++++++++---
 drivers/net/ethernet/ti/am65-cpsw-nuss.h    |  4 ++
 3 files changed, 134 insertions(+), 8 deletions(-)

Changelog

v7: no change

drivers/net/ethernet/ti/am65-cpsw-ethtool.c +79 -0
index 5571385b4baf..1ac4b9b53c93 100644
@@ -894,6 +894,80 @@ static void am65_cpsw_get_mm_stats(struct net_device *ndev,
 	s->MACMergeHoldCount = readl(base + AM65_CPSW_STATN_IET_TX_HOLD);
 }
 
+static int am65_cpsw_get_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal,
+				  struct kernel_ethtool_coalesce *kernel_coal,
+				  struct netlink_ext_ack *extack)
+{
+	struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
+	struct am65_cpsw_tx_chn *tx_chn;
+
+	tx_chn = &common->tx_chns[0];
+
+	coal->rx_coalesce_usecs = common->rx_pace_timeout / 1000;
+	coal->tx_coalesce_usecs = tx_chn->tx_pace_timeout / 1000;
+
+	return 0;
+}
+
+static int am65_cpsw_get_per_queue_coalesce(struct net_device *ndev, u32 queue,
+					    struct ethtool_coalesce *coal)
+{
+	struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
+	struct am65_cpsw_tx_chn *tx_chn;
+
+	if (queue >= AM65_CPSW_MAX_TX_QUEUES)
+		return -EINVAL;
+
+	tx_chn = &common->tx_chns[queue];
+
+	coal->tx_coalesce_usecs = tx_chn->tx_pace_timeout / 1000;
+
+	return 0;
+}
+
+static int am65_cpsw_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *coal,
+				  struct kernel_ethtool_coalesce *kernel_coal,
+				  struct netlink_ext_ack *extack)
+{
+	struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
+	struct am65_cpsw_tx_chn *tx_chn;
+
+	tx_chn = &common->tx_chns[0];
+
+	if (coal->rx_coalesce_usecs && coal->rx_coalesce_usecs < 20)
+		return -EINVAL;
+
+	if (coal->tx_coalesce_usecs && coal->tx_coalesce_usecs < 20)
+		return -EINVAL;
+
+	common->rx_pace_timeout = coal->rx_coalesce_usecs * 1000;
+	tx_chn->tx_pace_timeout = coal->tx_coalesce_usecs * 1000;
+
+	return 0;
+}
+
+static int am65_cpsw_set_per_queue_coalesce(struct net_device *ndev, u32 queue,
+					    struct ethtool_coalesce *coal)
+{
+	struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
+	struct am65_cpsw_tx_chn *tx_chn;
+
+	if (queue >= AM65_CPSW_MAX_TX_QUEUES)
+		return -EINVAL;
+
+	tx_chn = &common->tx_chns[queue];
+
+	if (coal->tx_coalesce_usecs && coal->tx_coalesce_usecs < 20) {
+		dev_info(common->dev, "defaulting to min value of 20us for tx-usecs for tx-%u\n",
+			 queue);
+		coal->tx_coalesce_usecs = 20;
+	}
+
+	tx_chn->tx_pace_timeout = coal->tx_coalesce_usecs * 1000;
+
+	return 0;
+}
+
 const struct ethtool_ops am65_cpsw_ethtool_ops_slave = {
 	.begin			= am65_cpsw_ethtool_op_begin,
 	.complete		= am65_cpsw_ethtool_op_complete,
@@ -912,6 +986,11 @@ const struct ethtool_ops am65_cpsw_ethtool_ops_slave = {
 	.get_ts_info		= am65_cpsw_get_ethtool_ts_info,
 	.get_priv_flags		= am65_cpsw_get_ethtool_priv_flags,
 	.set_priv_flags		= am65_cpsw_set_ethtool_priv_flags,
+	.supported_coalesce_params = ETHTOOL_COALESCE_USECS,
+	.get_coalesce           = am65_cpsw_get_coalesce,
+	.set_coalesce           = am65_cpsw_set_coalesce,
+	.get_per_queue_coalesce = am65_cpsw_get_per_queue_coalesce,
+	.set_per_queue_coalesce = am65_cpsw_set_per_queue_coalesce,
 
 	.get_link		= ethtool_op_get_link,
 	.get_link_ksettings	= am65_cpsw_get_link_ksettings,
drivers/net/ethernet/ti/am65-cpsw-nuss.c +51 -8

137 lines not on this page · raw message

drivers/net/ethernet/ti/am65-cpsw-nuss.h +4 -0
index 1e4a045057fc..7da0492dc091 100644
@@ -75,6 +75,8 @@ struct am65_cpsw_tx_chn {
 	struct k3_cppi_desc_pool *desc_pool;
 	struct k3_udma_glue_tx_channel *tx_chn;
 	spinlock_t lock; /* protect TX rings in multi-port mode */
+	struct hrtimer tx_hrtimer;
+	unsigned long tx_pace_timeout;
 	int irq;
 	u32 id;
 	u32 descs_num;
@@ -138,6 +140,8 @@ struct am65_cpsw_common {
 	struct napi_struct	napi_rx;
 
 	bool			rx_irq_disabled;
+	struct hrtimer		rx_hrtimer;
+	unsigned long		rx_pace_timeout;
 
 	u32			nuss_ver;
 	u32			cpsw_ver;
Signature · 1 line
2.34.1
#27 lore raw

PATCH v7 8/8 selftests: forwarding: ethtool_mm: support devices with higher rx-min-frag-size

In reply to Roger Quadros

From: Vladimir Oltean <[email protected]>

Some devices have errata due to which they cannot report ETH_ZLEN (60) in the rx-min-frag-size. This was foreseen of course, and lldpad has logic that when we request it to advertise addFragSize 0, it will round it up to the lowest value that is _actually_ supported by the hardware.

The problem is that the selftest expects lldpad to report back to us the same value as we requested.

Make the selftest smarter by figuring out on its own what is a reasonable value to expect.

---
 .../selftests/net/forwarding/ethtool_mm.sh    | 37 ++++++++++++++++++-
 1 file changed, 35 insertions(+), 2 deletions(-)

Changelog:

v7: initial commit

tools/testing/selftests/net/forwarding/ethtool_mm.sh +35 -2
index 39e736f30322..6212913f4ad1 100755
@@ -155,15 +155,48 @@ manual_failed_verification_h2_to_h1()
 	manual_failed_verification $h2 $h1
 }
 
+smallest_supported_add_frag_size()
+{
+	local iface=$1
+	local rx_min_frag_size=
+
+	rx_min_frag_size=$(ethtool --json --show-mm $iface | \
+		jq '.[]."rx-min-frag-size"')
+
+	if [ $rx_min_frag_size -le 60 ]; then
+		echo 0
+	elif [ $rx_min_frag_size -le 124 ]; then
+		echo 1
+	elif [ $rx_min_frag_size -le 188 ]; then
+		echo 2
+	elif [ $rx_min_frag_size -le 252 ]; then
+		echo 3
+	else
+		echo "$iface: RX min frag size $rx_min_frag_size cannot be advertised over LLDP"
+		exit 1
+	fi
+}
+
+expected_add_frag_size()
+{
+	local iface=$1
+	local requested=$2
+	local min=$(smallest_supported_add_frag_size $iface)
+
+	[ $requested -le $min ] && echo $min || echo $requested
+}
+
 lldp_change_add_frag_size()
 {
 	local add_frag_size=$1
+	local pattern=
 
 	lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null
 	# Wait for TLVs to be received
 	sleep 2
-	lldptool -i $h2 -t -n -V addEthCaps | \
-		grep -q "Additional fragment size: $add_frag_size"
+	pattern=$(printf "Additional fragment size: %d" \
+			 $(expected_add_frag_size $h1 $add_frag_size))
+	lldptool -i $h2 -t -n -V addEthCaps | grep -q "$pattern"
 }
 
 lldp()
Signature · 1 line
2.34.1
#28 lore raw

Re: [PATCH v7 net-next 8/8] selftests: forwarding: ethtool_mm: support devices with higher rx-min-frag-size

Quoted 10 lines · Roger Quadros

From: Vladimir Oltean <[email protected]>

Some devices have errata due to which they cannot report ETH_ZLEN (60) in the rx-min-frag-size. This was foreseen of course, and lldpad has logic that when we request it to advertise addFragSize 0, it will round it up to the lowest value that is _actually_ supported by the hardware.

The problem is that the selftest expects lldpad to report back to us the same value as we requested.

Quoted 6 lines

Make the selftest smarter by figuring out on its own what is a reasonable value to expect.

---

This needs your sign off as well after mine, otherwise in the git log it will imply that I sent the patch myself. I think you can reply with the tag to this email and either the patchwork bot or one of the maintainers will pick it up automatically, it's not a reason in itself to resend.

#29 lore raw

Re: [PATCH v7 net-next 8/8] selftests: forwarding: ethtool_mm: support devices with higher rx-min-frag-size

In reply to Roger Quadros
Quoted 10 lines · Roger Quadros

From: Vladimir Oltean <[email protected]>

Some devices have errata due to which they cannot report ETH_ZLEN (60) in the rx-min-frag-size. This was foreseen of course, and lldpad has logic that when we request it to advertise addFragSize 0, it will round it up to the lowest value that is _actually_ supported by the hardware.

The problem is that the selftest expects lldpad to report back to us the same value as we requested.

Quoted 6 lines

Make the selftest smarter by figuring out on its own what is a reasonable value to expect.

---

When you do resend, please make sure that this change is present before your driver support, such that bisections show that the selftest passes since the very introduction of this feature.