Skip to content

Commit 2eea1fa

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: Print the reset reason
Sometimes it can be quite opaque even for me why the driver decided to reset the switch. So instead of adding dump_stack() calls each time for debugging, just add a reset reason to sja1105_static_config_reload calls which gets printed to the console. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d438945 commit 2eea1fa

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

drivers/net/dsa/sja1105/sja1105.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,15 @@ typedef enum {
115115
} sja1105_spi_rw_mode_t;
116116

117117
/* From sja1105_main.c */
118-
int sja1105_static_config_reload(struct sja1105_private *priv);
118+
enum sja1105_reset_reason {
119+
SJA1105_VLAN_FILTERING = 0,
120+
SJA1105_RX_HWTSTAMPING,
121+
SJA1105_AGEING_TIME,
122+
SJA1105_SCHEDULING,
123+
};
124+
125+
int sja1105_static_config_reload(struct sja1105_private *priv,
126+
enum sja1105_reset_reason reason);
119127

120128
/* From sja1105_spi.c */
121129
int sja1105_xfer_buf(const struct sja1105_private *priv,

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,13 +1341,21 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port,
13411341
sja1105_bridge_member(ds, port, br, false);
13421342
}
13431343

1344+
static const char * const sja1105_reset_reasons[] = {
1345+
[SJA1105_VLAN_FILTERING] = "VLAN filtering",
1346+
[SJA1105_RX_HWTSTAMPING] = "RX timestamping",
1347+
[SJA1105_AGEING_TIME] = "Ageing time",
1348+
[SJA1105_SCHEDULING] = "Time-aware scheduling",
1349+
};
1350+
13441351
/* For situations where we need to change a setting at runtime that is only
13451352
* available through the static configuration, resetting the switch in order
13461353
* to upload the new static config is unavoidable. Back up the settings we
13471354
* modify at runtime (currently only MAC) and restore them after uploading,
13481355
* such that this operation is relatively seamless.
13491356
*/
1350-
int sja1105_static_config_reload(struct sja1105_private *priv)
1357+
int sja1105_static_config_reload(struct sja1105_private *priv,
1358+
enum sja1105_reset_reason reason)
13511359
{
13521360
struct ptp_system_timestamp ptp_sts_before;
13531361
struct ptp_system_timestamp ptp_sts_after;
@@ -1405,6 +1413,10 @@ int sja1105_static_config_reload(struct sja1105_private *priv)
14051413
out_unlock_ptp:
14061414
mutex_unlock(&priv->ptp_data.lock);
14071415

1416+
dev_info(priv->ds->dev,
1417+
"Reset switch and programmed static config. Reason: %s\n",
1418+
sja1105_reset_reasons[reason]);
1419+
14081420
/* Configure the CGU (PLLs) for MII and RMII PHYs.
14091421
* For these interfaces there is no dynamic configuration
14101422
* needed, since PLLs have same settings at all speeds.
@@ -1599,7 +1611,7 @@ static int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled)
15991611
l2_lookup_params = table->entries;
16001612
l2_lookup_params->shared_learn = !enabled;
16011613

1602-
rc = sja1105_static_config_reload(priv);
1614+
rc = sja1105_static_config_reload(priv, SJA1105_VLAN_FILTERING);
16031615
if (rc)
16041616
dev_err(ds->dev, "Failed to change VLAN Ethertype\n");
16051617

@@ -1871,7 +1883,7 @@ static int sja1105_set_ageing_time(struct dsa_switch *ds,
18711883

18721884
l2_lookup_params->maxage = maxage;
18731885

1874-
return sja1105_static_config_reload(priv);
1886+
return sja1105_static_config_reload(priv, SJA1105_AGEING_TIME);
18751887
}
18761888

18771889
static int sja1105_port_setup_tc(struct dsa_switch *ds, int port,

drivers/net/dsa/sja1105/sja1105_ptp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int sja1105_change_rxtstamping(struct sja1105_private *priv,
102102
priv->tagger_data.stampable_skb = NULL;
103103
}
104104

105-
return sja1105_static_config_reload(priv);
105+
return sja1105_static_config_reload(priv, SJA1105_RX_HWTSTAMPING);
106106
}
107107

108108
int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr)

drivers/net/dsa/sja1105/sja1105_tas.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
352352
if (rc < 0)
353353
return rc;
354354

355-
return sja1105_static_config_reload(priv);
355+
return sja1105_static_config_reload(priv, SJA1105_SCHEDULING);
356356
}
357357

358358
/* The cycle time extension is the amount of time the last cycle from
@@ -400,7 +400,7 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
400400
if (rc < 0)
401401
return rc;
402402

403-
return sja1105_static_config_reload(priv);
403+
return sja1105_static_config_reload(priv, SJA1105_SCHEDULING);
404404
}
405405

406406
void sja1105_tas_setup(struct dsa_switch *ds)

0 commit comments

Comments
 (0)