Commit 2eea1fa8 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

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: default avatarVladimir Oltean <olteanv@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d438945a
...@@ -115,7 +115,15 @@ typedef enum { ...@@ -115,7 +115,15 @@ typedef enum {
} sja1105_spi_rw_mode_t; } sja1105_spi_rw_mode_t;
/* From sja1105_main.c */ /* From sja1105_main.c */
int sja1105_static_config_reload(struct sja1105_private *priv); enum sja1105_reset_reason {
SJA1105_VLAN_FILTERING = 0,
SJA1105_RX_HWTSTAMPING,
SJA1105_AGEING_TIME,
SJA1105_SCHEDULING,
};
int sja1105_static_config_reload(struct sja1105_private *priv,
enum sja1105_reset_reason reason);
/* From sja1105_spi.c */ /* From sja1105_spi.c */
int sja1105_xfer_buf(const struct sja1105_private *priv, int sja1105_xfer_buf(const struct sja1105_private *priv,
......
...@@ -1341,13 +1341,21 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port, ...@@ -1341,13 +1341,21 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port,
sja1105_bridge_member(ds, port, br, false); sja1105_bridge_member(ds, port, br, false);
} }
static const char * const sja1105_reset_reasons[] = {
[SJA1105_VLAN_FILTERING] = "VLAN filtering",
[SJA1105_RX_HWTSTAMPING] = "RX timestamping",
[SJA1105_AGEING_TIME] = "Ageing time",
[SJA1105_SCHEDULING] = "Time-aware scheduling",
};
/* For situations where we need to change a setting at runtime that is only /* For situations where we need to change a setting at runtime that is only
* available through the static configuration, resetting the switch in order * available through the static configuration, resetting the switch in order
* to upload the new static config is unavoidable. Back up the settings we * to upload the new static config is unavoidable. Back up the settings we
* modify at runtime (currently only MAC) and restore them after uploading, * modify at runtime (currently only MAC) and restore them after uploading,
* such that this operation is relatively seamless. * such that this operation is relatively seamless.
*/ */
int sja1105_static_config_reload(struct sja1105_private *priv) int sja1105_static_config_reload(struct sja1105_private *priv,
enum sja1105_reset_reason reason)
{ {
struct ptp_system_timestamp ptp_sts_before; struct ptp_system_timestamp ptp_sts_before;
struct ptp_system_timestamp ptp_sts_after; struct ptp_system_timestamp ptp_sts_after;
...@@ -1405,6 +1413,10 @@ int sja1105_static_config_reload(struct sja1105_private *priv) ...@@ -1405,6 +1413,10 @@ int sja1105_static_config_reload(struct sja1105_private *priv)
out_unlock_ptp: out_unlock_ptp:
mutex_unlock(&priv->ptp_data.lock); mutex_unlock(&priv->ptp_data.lock);
dev_info(priv->ds->dev,
"Reset switch and programmed static config. Reason: %s\n",
sja1105_reset_reasons[reason]);
/* Configure the CGU (PLLs) for MII and RMII PHYs. /* Configure the CGU (PLLs) for MII and RMII PHYs.
* For these interfaces there is no dynamic configuration * For these interfaces there is no dynamic configuration
* needed, since PLLs have same settings at all speeds. * 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) ...@@ -1599,7 +1611,7 @@ static int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled)
l2_lookup_params = table->entries; l2_lookup_params = table->entries;
l2_lookup_params->shared_learn = !enabled; l2_lookup_params->shared_learn = !enabled;
rc = sja1105_static_config_reload(priv); rc = sja1105_static_config_reload(priv, SJA1105_VLAN_FILTERING);
if (rc) if (rc)
dev_err(ds->dev, "Failed to change VLAN Ethertype\n"); dev_err(ds->dev, "Failed to change VLAN Ethertype\n");
...@@ -1871,7 +1883,7 @@ static int sja1105_set_ageing_time(struct dsa_switch *ds, ...@@ -1871,7 +1883,7 @@ static int sja1105_set_ageing_time(struct dsa_switch *ds,
l2_lookup_params->maxage = maxage; l2_lookup_params->maxage = maxage;
return sja1105_static_config_reload(priv); return sja1105_static_config_reload(priv, SJA1105_AGEING_TIME);
} }
static int sja1105_port_setup_tc(struct dsa_switch *ds, int port, static int sja1105_port_setup_tc(struct dsa_switch *ds, int port,
......
...@@ -102,7 +102,7 @@ static int sja1105_change_rxtstamping(struct sja1105_private *priv, ...@@ -102,7 +102,7 @@ static int sja1105_change_rxtstamping(struct sja1105_private *priv,
priv->tagger_data.stampable_skb = NULL; priv->tagger_data.stampable_skb = NULL;
} }
return sja1105_static_config_reload(priv); return sja1105_static_config_reload(priv, SJA1105_RX_HWTSTAMPING);
} }
int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr) int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr)
......
...@@ -352,7 +352,7 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port, ...@@ -352,7 +352,7 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
if (rc < 0) if (rc < 0)
return rc; return rc;
return sja1105_static_config_reload(priv); return sja1105_static_config_reload(priv, SJA1105_SCHEDULING);
} }
/* The cycle time extension is the amount of time the last cycle from /* 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, ...@@ -400,7 +400,7 @@ int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
if (rc < 0) if (rc < 0)
return rc; return rc;
return sja1105_static_config_reload(priv); return sja1105_static_config_reload(priv, SJA1105_SCHEDULING);
} }
void sja1105_tas_setup(struct dsa_switch *ds) void sja1105_tas_setup(struct dsa_switch *ds)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment