net: dsa: felix: keep reference on entire tc-taprio config

[ Upstream commit 1c9017e44a ]

In a future change we will need to remember the entire tc-taprio config
on all ports rather than just the base time, so use the
taprio_offload_get() helper function to replace ocelot_port->base_time
with ocelot_port->taprio.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Vladimir Oltean 2022-06-28 17:52:35 +03:00 committed by Greg Kroah-Hartman
parent dd31b754e0
commit 6c2cd05556
2 changed files with 15 additions and 13 deletions

View File

@ -1207,6 +1207,9 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,
QSYS_TAG_CONFIG_INIT_GATE_STATE_M,
QSYS_TAG_CONFIG, port);
taprio_offload_free(ocelot_port->taprio);
ocelot_port->taprio = NULL;
mutex_unlock(&ocelot->tas_lock);
return 0;
}
@ -1255,8 +1258,6 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,
QSYS_TAG_CONFIG_SCH_TRAFFIC_QUEUES_M,
QSYS_TAG_CONFIG, port);
ocelot_port->base_time = taprio->base_time;
vsc9959_new_base_time(ocelot, taprio->base_time,
taprio->cycle_time, &base_ts);
ocelot_write(ocelot, base_ts.tv_nsec, QSYS_PARAM_CFG_REG_1);
@ -1279,6 +1280,10 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,
ret = readx_poll_timeout(vsc9959_tas_read_cfg_status, ocelot, val,
!(val & QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE),
10, 100000);
if (ret)
goto err;
ocelot_port->taprio = taprio_offload_get(taprio);
err:
mutex_unlock(&ocelot->tas_lock);
@ -1288,17 +1293,18 @@ err:
static void vsc9959_tas_clock_adjust(struct ocelot *ocelot)
{
struct tc_taprio_qopt_offload *taprio;
struct ocelot_port *ocelot_port;
struct timespec64 base_ts;
u64 cycletime;
int port;
u32 val;
mutex_lock(&ocelot->tas_lock);
for (port = 0; port < ocelot->num_phys_ports; port++) {
val = ocelot_read_rix(ocelot, QSYS_TAG_CONFIG, port);
if (!(val & QSYS_TAG_CONFIG_ENABLE))
ocelot_port = ocelot->ports[port];
taprio = ocelot_port->taprio;
if (!taprio)
continue;
ocelot_rmw(ocelot,
@ -1312,11 +1318,8 @@ static void vsc9959_tas_clock_adjust(struct ocelot *ocelot)
QSYS_TAG_CONFIG_INIT_GATE_STATE_M,
QSYS_TAG_CONFIG, port);
cycletime = ocelot_read(ocelot, QSYS_PARAM_CFG_REG_4);
ocelot_port = ocelot->ports[port];
vsc9959_new_base_time(ocelot, ocelot_port->base_time,
cycletime, &base_ts);
vsc9959_new_base_time(ocelot, taprio->base_time,
taprio->cycle_time, &base_ts);
ocelot_write(ocelot, base_ts.tv_nsec, QSYS_PARAM_CFG_REG_1);
ocelot_write(ocelot, lower_32_bits(base_ts.tv_sec),

View File

@ -659,6 +659,8 @@ struct ocelot_port {
/* VLAN that untagged frames are classified to, on ingress */
const struct ocelot_bridge_vlan *pvid_vlan;
struct tc_taprio_qopt_offload *taprio;
phy_interface_t phy_mode;
unsigned int ptp_skbs_in_flight;
@ -679,9 +681,6 @@ struct ocelot_port {
int bridge_num;
int speed;
/* Store the AdminBaseTime of EST fetched from userspace. */
s64 base_time;
};
struct ocelot {