Skip to content

Commit 74e7fef

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: fix dynamic access to L2 Address Lookup table for SJA1110
The SJA1105P/Q/R/S and SJA1110 may have the same layout for the command to read/write/search for L2 Address Lookup entries, but as explained in the comments at the beginning of the sja1105_dynamic_config.c file, the command portion of the buffer is at the end, and we need to obtain a pointer to it by adding the length of the entry to the buffer. Alas, the length of an L2 Address Lookup entry is larger in SJA1110 than it is for SJA1105P/Q/R/S, so we need to create a common helper to access the command buffer, and this receives as argument the length of the entry buffer. Fixes: 3e77e59 ("net: dsa: sja1105: add support for the SJA1110 switch family") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f745893 commit 74e7fef

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

drivers/net/dsa/sja1105/sja1105_dynamic_config.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ sja1110_vl_policing_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
258258
}
259259

260260
static void
261-
sja1105pqrs_l2_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
262-
enum packing_op op)
261+
sja1105pqrs_common_l2_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
262+
enum packing_op op, int entry_size)
263263
{
264-
u8 *p = buf + SJA1105PQRS_SIZE_L2_LOOKUP_ENTRY;
265264
const int size = SJA1105_SIZE_DYN_CMD;
265+
u8 *p = buf + entry_size;
266266
u64 hostcmd;
267267

268268
sja1105_packing(p, &cmd->valid, 31, 31, size, op);
@@ -317,6 +317,24 @@ sja1105pqrs_l2_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
317317
SJA1105PQRS_SIZE_L2_LOOKUP_ENTRY, op);
318318
}
319319

320+
static void
321+
sja1105pqrs_l2_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
322+
enum packing_op op)
323+
{
324+
int size = SJA1105PQRS_SIZE_L2_LOOKUP_ENTRY;
325+
326+
return sja1105pqrs_common_l2_lookup_cmd_packing(buf, cmd, op, size);
327+
}
328+
329+
static void
330+
sja1110_l2_lookup_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
331+
enum packing_op op)
332+
{
333+
int size = SJA1110_SIZE_L2_LOOKUP_ENTRY;
334+
335+
return sja1105pqrs_common_l2_lookup_cmd_packing(buf, cmd, op, size);
336+
}
337+
320338
/* The switch is so retarded that it makes our command/entry abstraction
321339
* crumble apart.
322340
*
@@ -1055,7 +1073,7 @@ const struct sja1105_dynamic_table_ops sja1110_dyn_ops[BLK_IDX_MAX_DYN] = {
10551073
},
10561074
[BLK_IDX_L2_LOOKUP] = {
10571075
.entry_packing = sja1110_dyn_l2_lookup_entry_packing,
1058-
.cmd_packing = sja1105pqrs_l2_lookup_cmd_packing,
1076+
.cmd_packing = sja1110_l2_lookup_cmd_packing,
10591077
.access = (OP_READ | OP_WRITE | OP_DEL | OP_SEARCH),
10601078
.max_entry_count = SJA1105_MAX_L2_LOOKUP_COUNT,
10611079
.packed_size = SJA1110_SIZE_L2_LOOKUP_DYN_CMD,

0 commit comments

Comments
 (0)