Commit 2d800bc5 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller
Browse files

net/sched: taprio: replace tc_taprio_qopt_offload :: enable with a "cmd" enum



Inspired from struct flow_cls_offload :: cmd, in order for taprio to be
able to report statistics (which is future work), it seems that we need
to drill one step further with the ndo_setup_tc(TC_SETUP_QDISC_TAPRIO)
multiplexing, and pass the command as part of the common portion of the
muxed structure.

Since we already have an "enable" variable in tc_taprio_qopt_offload,
refactor all drivers to check for "cmd" instead of "enable", and reject
every other command except "replace" and "destroy" - to be future proof.

Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com> # for lan966x
Acked-by: Kurt Kanzenbach <kurt@linutronix.de> # hellcreek
Reviewed-by: default avatarMuhammad Husaini Zulkifli <muhammad.husaini.zulkifli@intel.com>
Reviewed-by: default avatarGerhard Engleder <gerhard@engleder-embedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dced11ef
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