Skip to content

Commit 180a741

Browse files
vladimirolteandavem330
authored andcommitted
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: 3e77e59 ("net: dsa: sja1105: add support for the SJA1110 switch family") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 894cafc commit 180a741

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

drivers/net/dsa/sja1105/sja1105.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ struct sja1105_info {
132132
int max_frame_mem;
133133
int num_ports;
134134
bool multiple_cascade_ports;
135+
/* Every {port, TXQ} has its own CBS shaper */
136+
bool fixed_cbs_mapping;
135137
enum dsa_tag_protocol tag_proto;
136138
const struct sja1105_dynamic_table_ops *dyn_ops;
137139
const struct sja1105_table_ops *static_ops;

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,12 +2115,22 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port,
21152115
}
21162116

21172117
#define BYTES_PER_KBIT (1000LL / 8)
2118+
/* Port 0 (the uC port) does not have CBS shapers */
2119+
#define SJA1110_FIXED_CBS(port, prio) ((((port) - 1) * SJA1105_NUM_TC) + (prio))
21182120

21192121
static int sja1105_find_cbs_shaper(struct sja1105_private *priv,
21202122
int port, int prio)
21212123
{
21222124
int i;
21232125

2126+
if (priv->info->fixed_cbs_mapping) {
2127+
i = SJA1110_FIXED_CBS(port, prio);
2128+
if (i >= 0 && i < priv->info->num_cbs_shapers)
2129+
return i;
2130+
2131+
return -1;
2132+
}
2133+
21242134
for (i = 0; i < priv->info->num_cbs_shapers; i++)
21252135
if (priv->cbs[i].port == port && priv->cbs[i].prio == prio)
21262136
return i;
@@ -2132,6 +2142,9 @@ static int sja1105_find_unused_cbs_shaper(struct sja1105_private *priv)
21322142
{
21332143
int i;
21342144

2145+
if (priv->info->fixed_cbs_mapping)
2146+
return -1;
2147+
21352148
for (i = 0; i < priv->info->num_cbs_shapers; i++)
21362149
if (!priv->cbs[i].idle_slope && !priv->cbs[i].send_slope)
21372150
return i;

drivers/net/dsa/sja1105/sja1105_spi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ const struct sja1105_info sja1110a_info = {
781781
.tag_proto = DSA_TAG_PROTO_SJA1110,
782782
.can_limit_mcast_flood = true,
783783
.multiple_cascade_ports = true,
784+
.fixed_cbs_mapping = true,
784785
.ptp_ts_bits = 32,
785786
.ptpegr_ts_bytes = 8,
786787
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
@@ -831,6 +832,7 @@ const struct sja1105_info sja1110b_info = {
831832
.tag_proto = DSA_TAG_PROTO_SJA1110,
832833
.can_limit_mcast_flood = true,
833834
.multiple_cascade_ports = true,
835+
.fixed_cbs_mapping = true,
834836
.ptp_ts_bits = 32,
835837
.ptpegr_ts_bytes = 8,
836838
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
@@ -881,6 +883,7 @@ const struct sja1105_info sja1110c_info = {
881883
.tag_proto = DSA_TAG_PROTO_SJA1110,
882884
.can_limit_mcast_flood = true,
883885
.multiple_cascade_ports = true,
886+
.fixed_cbs_mapping = true,
884887
.ptp_ts_bits = 32,
885888
.ptpegr_ts_bytes = 8,
886889
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
@@ -931,6 +934,7 @@ const struct sja1105_info sja1110d_info = {
931934
.tag_proto = DSA_TAG_PROTO_SJA1110,
932935
.can_limit_mcast_flood = true,
933936
.multiple_cascade_ports = true,
937+
.fixed_cbs_mapping = true,
934938
.ptp_ts_bits = 32,
935939
.ptpegr_ts_bytes = 8,
936940
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY,

0 commit comments

Comments
 (0)