Skip to content

Commit ba61cf1

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: fix VL lookup command packing for P/Q/R/S
At the beginning of the sja1105_dynamic_config.c file there is a diagram of the dynamic config interface layout: packed_buf | V +-----------------------------------------+------------------+ | ENTRY BUFFER | COMMAND BUFFER | +-----------------------------------------+------------------+ <----------------------- packed_size ------------------------> So in order to pack/unpack the command bits into the buffer, sja1105_vl_lookup_cmd_packing must first advance the buffer pointer by the length of the entry. This is similar to what the other *cmd_packing functions do. This bug exists because the command packing function for P/Q/R/S was copied from the E/T generation, and on E/T, the command was actually embedded within the entry buffer itself. Fixes: 94f94d4 ("net: dsa: sja1105: add static tables for virtual links") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a6e9a9 commit ba61cf1

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/net/dsa/sja1105/sja1105_dynamic_config.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ enum sja1105_hostcmd {
167167
SJA1105_HOSTCMD_INVALIDATE = 4,
168168
};
169169

170+
/* Command and entry overlap */
170171
static void
171-
sja1105_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
172-
enum packing_op op)
172+
sja1105et_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
173+
enum packing_op op)
173174
{
174175
const int size = SJA1105_SIZE_DYN_CMD;
175176

@@ -179,6 +180,20 @@ sja1105_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
179180
sja1105_packing(buf, &cmd->index, 9, 0, size, op);
180181
}
181182

183+
/* Command and entry are separate */
184+
static void
185+
sja1105pqrs_vl_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
186+
enum packing_op op)
187+
{
188+
u8 *p = buf + SJA1105_SIZE_VL_LOOKUP_ENTRY;
189+
const int size = SJA1105_SIZE_DYN_CMD;
190+
191+
sja1105_packing(p, &cmd->valid, 31, 31, size, op);
192+
sja1105_packing(p, &cmd->errors, 30, 30, size, op);
193+
sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op);
194+
sja1105_packing(p, &cmd->index, 9, 0, size, op);
195+
}
196+
182197
static size_t sja1105et_vl_lookup_entry_packing(void *buf, void *entry_ptr,
183198
enum packing_op op)
184199
{
@@ -641,7 +656,7 @@ static size_t sja1105pqrs_cbs_entry_packing(void *buf, void *entry_ptr,
641656
const struct sja1105_dynamic_table_ops sja1105et_dyn_ops[BLK_IDX_MAX_DYN] = {
642657
[BLK_IDX_VL_LOOKUP] = {
643658
.entry_packing = sja1105et_vl_lookup_entry_packing,
644-
.cmd_packing = sja1105_vl_lookup_cmd_packing,
659+
.cmd_packing = sja1105et_vl_lookup_cmd_packing,
645660
.access = OP_WRITE,
646661
.max_entry_count = SJA1105_MAX_VL_LOOKUP_COUNT,
647662
.packed_size = SJA1105ET_SIZE_VL_LOOKUP_DYN_CMD,
@@ -725,7 +740,7 @@ const struct sja1105_dynamic_table_ops sja1105et_dyn_ops[BLK_IDX_MAX_DYN] = {
725740
const struct sja1105_dynamic_table_ops sja1105pqrs_dyn_ops[BLK_IDX_MAX_DYN] = {
726741
[BLK_IDX_VL_LOOKUP] = {
727742
.entry_packing = sja1105_vl_lookup_entry_packing,
728-
.cmd_packing = sja1105_vl_lookup_cmd_packing,
743+
.cmd_packing = sja1105pqrs_vl_lookup_cmd_packing,
729744
.access = (OP_READ | OP_WRITE),
730745
.max_entry_count = SJA1105_MAX_VL_LOOKUP_COUNT,
731746
.packed_size = SJA1105PQRS_SIZE_VL_LOOKUP_DYN_CMD,

0 commit comments

Comments
 (0)