Commit 60cbd38b authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'xstats-for-tc-taprio'

Vladimir Oltean says:

====================
xstats for tc-taprio

As a result of this discussion:
https://lore.kernel.org/intel-wired-lan/20230411055543.24177-1-muhammad.husaini.zulkifli@intel.com/

it became apparent that tc-taprio should make an effort to standardize
statistics counters related to the 802.1Qbv scheduling as implemented
by the NIC. I'm presenting here one counter suggested by the standard,
and one counter defined by the NXP ENETC controller from LS1028A. Both
counters are reported globally and per traffic class - drivers get
different callbacks for reporting both of these, and get to choose what
to report in both cases.

The iproute2 counterpart is available here for testing:
https://github.com/vladimiroltean/iproute2/commits/taprio-xstats


====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 5dedf5c4 4802fca8
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -1885,13 +1885,17 @@ static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port,
	case TC_SETUP_QDISC_TAPRIO: {
		struct tc_taprio_qopt_offload *taprio = type_data;

		switch (taprio->cmd) {
		case TAPRIO_CMD_REPLACE:
			if (!hellcreek_validate_schedule(hellcreek, taprio))
				return -EOPNOTSUPP;

		if (taprio->enable)
			return hellcreek_port_set_schedule(ds, port, taprio);

		case TAPRIO_CMD_DESTROY:
			return hellcreek_port_del_schedule(ds, port);
		default:
			return -EOPNOTSUPP;
		}
	}
	default:
		return -EOPNOTSUPP;
+3 −1
Original line number Diff line number Diff line
@@ -1411,7 +1411,7 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,

	mutex_lock(&ocelot->tas_lock);

	if (!taprio->enable) {
	if (taprio->cmd == TAPRIO_CMD_DESTROY) {
		ocelot_port_mqprio(ocelot, port, &taprio->mqprio);
		ocelot_rmw_rix(ocelot, 0, QSYS_TAG_CONFIG_ENABLE,
			       QSYS_TAG_CONFIG, port);
@@ -1423,6 +1423,8 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,

		mutex_unlock(&ocelot->tas_lock);
		return 0;
	} else if (taprio->cmd != TAPRIO_CMD_REPLACE) {
		return -EOPNOTSUPP;
	}

	ret = ocelot_port_mqprio(ocelot, port, &taprio->mqprio);
+5 −2
Original line number Diff line number Diff line
@@ -516,10 +516,11 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
	/* Can't change an already configured port (must delete qdisc first).
	 * Can't delete the qdisc from an unconfigured port.
	 */
	if (!!tas_data->offload[port] == admin->enable)
	if ((!!tas_data->offload[port] && admin->cmd == TAPRIO_CMD_REPLACE) ||
	    (!tas_data->offload[port] && admin->cmd == TAPRIO_CMD_DESTROY))
		return -EINVAL;

	if (!admin->enable) {
	if (admin->cmd == TAPRIO_CMD_DESTROY) {
		taprio_offload_free(tas_data->offload[port]);
		tas_data->offload[port] = NULL;

@@ -528,6 +529,8 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
			return rc;

		return sja1105_static_config_reload(priv, SJA1105_SCHEDULING);
	} else if (admin->cmd != TAPRIO_CMD_REPLACE) {
		return -EOPNOTSUPP;
	}

	/* The cycle time extension is the amount of time the last cycle from
+6 −6
Original line number Diff line number Diff line
@@ -329,7 +329,7 @@ static bool disable_taprio(struct tsnep_adapter *adapter)
	int retval;

	memset(&qopt, 0, sizeof(qopt));
	qopt.enable = 0;
	qopt.cmd = TAPRIO_CMD_DESTROY;
	retval = tsnep_tc_setup(adapter->netdev, TC_SETUP_QDISC_TAPRIO, &qopt);
	if (retval)
		return false;
@@ -360,7 +360,7 @@ static bool tsnep_test_taprio(struct tsnep_adapter *adapter)
	for (i = 0; i < 255; i++)
		qopt->entries[i].command = TC_TAPRIO_CMD_SET_GATES;

	qopt->enable = 1;
	qopt->cmd = TAPRIO_CMD_REPLACE;
	qopt->base_time = ktime_set(0, 0);
	qopt->cycle_time = 1500000;
	qopt->cycle_time_extension = 0;
@@ -382,7 +382,7 @@ static bool tsnep_test_taprio(struct tsnep_adapter *adapter)
	if (!run_taprio(adapter, qopt, 100))
		goto failed;

	qopt->enable = 1;
	qopt->cmd = TAPRIO_CMD_REPLACE;
	qopt->base_time = ktime_set(0, 0);
	qopt->cycle_time = 411854;
	qopt->cycle_time_extension = 0;
@@ -406,7 +406,7 @@ static bool tsnep_test_taprio(struct tsnep_adapter *adapter)
	if (!run_taprio(adapter, qopt, 100))
		goto failed;

	qopt->enable = 1;
	qopt->cmd = TAPRIO_CMD_REPLACE;
	qopt->base_time = ktime_set(0, 0);
	delay_base_time(adapter, qopt, 12);
	qopt->cycle_time = 125000;
@@ -457,7 +457,7 @@ static bool tsnep_test_taprio_change(struct tsnep_adapter *adapter)
	for (i = 0; i < 255; i++)
		qopt->entries[i].command = TC_TAPRIO_CMD_SET_GATES;

	qopt->enable = 1;
	qopt->cmd = TAPRIO_CMD_REPLACE;
	qopt->base_time = ktime_set(0, 0);
	qopt->cycle_time = 100000;
	qopt->cycle_time_extension = 0;
@@ -610,7 +610,7 @@ static bool tsnep_test_taprio_extension(struct tsnep_adapter *adapter)
	for (i = 0; i < 255; i++)
		qopt->entries[i].command = TC_TAPRIO_CMD_SET_GATES;

	qopt->enable = 1;
	qopt->cmd = TAPRIO_CMD_REPLACE;
	qopt->base_time = ktime_set(0, 0);
	qopt->cycle_time = 100000;
	qopt->cycle_time_extension = 50000;
+3 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ static int tsnep_taprio(struct tsnep_adapter *adapter,
	if (!adapter->gate_control)
		return -EOPNOTSUPP;

	if (!qopt->enable) {
	if (qopt->cmd == TAPRIO_CMD_DESTROY) {
		/* disable gate control if active */
		mutex_lock(&adapter->gate_control_lock);

@@ -337,6 +337,8 @@ static int tsnep_taprio(struct tsnep_adapter *adapter,
		mutex_unlock(&adapter->gate_control_lock);

		return 0;
	} else if (qopt->cmd != TAPRIO_CMD_REPLACE) {
		return -EOPNOTSUPP;
	}

	retval = tsnep_validate_gcl(qopt);
Loading