Commit 180a7419 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: sja1105: complete tc-cbs offload support on SJA1110

The blamed commit left this delta behind:

  struct sja1105_cbs_entry {
 -	u64 port;
 -	u64 prio;
 +	u64 port; /* Not used for SJA1110 */
 +	u64 prio; /* Not used for SJA1110 */
  	u64 credit_hi;
  	u64 credit_lo;
  	u64 send_slope;
  	u64 idle_slope;
  };

but did not actually implement tc-cbs offload fully for the new switch.
The offload is accepted, but it doesn't work.

The difference compared to earlier switch generations is that now, the
table of CBS shapers is sparse, because there are many more shapers, so
the mapping between a {port, prio} and a table index is static, rather
than requiring us to store the port and prio into the sja1105_cbs_entry.

So, the problem is that the code programs the CBS shaper parameters at a
dynamic table index which is incorrect.

All that needs to be done for SJA1110 CBS shapers to work is to bypass
the logic which allocates shapers in a dense manner, as for SJA1105, and
use the fixed mapping instead.

Fixes: 3e77e59b ("net: dsa: sja1105: add support for the SJA1110 switch family")
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 894cafc5
...@@ -132,6 +132,8 @@ struct sja1105_info { ...@@ -132,6 +132,8 @@ struct sja1105_info {
int max_frame_mem; int max_frame_mem;
int num_ports; int num_ports;
bool multiple_cascade_ports; bool multiple_cascade_ports;
/* Every {port, TXQ} has its own CBS shaper */
bool fixed_cbs_mapping;
enum dsa_tag_protocol tag_proto; enum dsa_tag_protocol tag_proto;
const struct sja1105_dynamic_table_ops *dyn_ops; const struct sja1105_dynamic_table_ops *dyn_ops;
const struct sja1105_table_ops *static_ops; const struct sja1105_table_ops *static_ops;
......
...@@ -2115,12 +2115,22 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port, ...@@ -2115,12 +2115,22 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port,
} }
#define BYTES_PER_KBIT (1000LL / 8) #define BYTES_PER_KBIT (1000LL / 8)
/* Port 0 (the uC port) does not have CBS shapers */
#define SJA1110_FIXED_CBS(port, prio) ((((port) - 1) * SJA1105_NUM_TC) + (prio))
static int sja1105_find_cbs_shaper(struct sja1105_private *priv, static int sja1105_find_cbs_shaper(struct sja1105_private *priv,
int port, int prio) int port, int prio)
{ {
int i; int i;
if (priv->info->fixed_cbs_mapping) {
i = SJA1110_FIXED_CBS(port, prio);
if (i >= 0 && i < priv->info->num_cbs_shapers)
return i;
return -1;
}
for (i = 0; i < priv->info->num_cbs_shapers; i++) for (i = 0; i < priv->info->num_cbs_shapers; i++)
if (priv->cbs[i].port == port && priv->cbs[i].prio == prio) if (priv->cbs[i].port == port && priv->cbs[i].prio == prio)
return i; return i;
...@@ -2132,6 +2142,9 @@ static int sja1105_find_unused_cbs_shaper(struct sja1105_private *priv) ...@@ -2132,6 +2142,9 @@ static int sja1105_find_unused_cbs_shaper(struct sja1105_private *priv)
{ {
int i; int i;
if (priv->info->fixed_cbs_mapping)
return -1;
for (i = 0; i < priv->info->num_cbs_shapers; i++) for (i = 0; i < priv->info->num_cbs_shapers; i++)
if (!priv->cbs[i].idle_slope && !priv->cbs[i].send_slope) if (!priv->cbs[i].idle_slope && !priv->cbs[i].send_slope)
return i; return i;
......
...@@ -781,6 +781,7 @@ const struct sja1105_info sja1110a_info = { ...@@ -781,6 +781,7 @@ const struct sja1105_info sja1110a_info = {
.tag_proto = DSA_TAG_PROTO_SJA1110, .tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true, .multiple_cascade_ports = true,
.fixed_cbs_mapping = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
...@@ -831,6 +832,7 @@ const struct sja1105_info sja1110b_info = { ...@@ -831,6 +832,7 @@ const struct sja1105_info sja1110b_info = {
.tag_proto = DSA_TAG_PROTO_SJA1110, .tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true, .multiple_cascade_ports = true,
.fixed_cbs_mapping = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
...@@ -881,6 +883,7 @@ const struct sja1105_info sja1110c_info = { ...@@ -881,6 +883,7 @@ const struct sja1105_info sja1110c_info = {
.tag_proto = DSA_TAG_PROTO_SJA1110, .tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true, .multiple_cascade_ports = true,
.fixed_cbs_mapping = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
...@@ -931,6 +934,7 @@ const struct sja1105_info sja1110d_info = { ...@@ -931,6 +934,7 @@ const struct sja1105_info sja1110d_info = {
.tag_proto = DSA_TAG_PROTO_SJA1110, .tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true, .multiple_cascade_ports = true,
.fixed_cbs_mapping = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
......
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