Skip to content

Commit 99b981f

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: fix port mirroring for P/Q/R/S
The dynamic configuration interface for the General Params and the L2 Lookup Params tables was copy-pasted between E/T devices and P/Q/R/S devices. Nonetheless, these interfaces are bitwise different. The driver is using dynamic reconfiguration of the General Parameters table for the port mirroring feature, which was therefore broken on P/Q/R/S. Note that this patch can't be backported easily very far to stable trees (since it conflicts with some other development done since the introduction of the driver). So the Fixes: tag is purely informational. Fixes: 8aa9ebc ("net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 53bd63a commit 99b981f

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

drivers/net/dsa/sja1105/sja1105_dynamic_config.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,15 @@
127127
#define SJA1105ET_SIZE_L2_LOOKUP_PARAMS_DYN_CMD \
128128
SJA1105_SIZE_DYN_CMD
129129

130+
#define SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_DYN_CMD \
131+
(SJA1105_SIZE_DYN_CMD + SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_ENTRY)
132+
130133
#define SJA1105ET_SIZE_GENERAL_PARAMS_DYN_CMD \
131134
SJA1105_SIZE_DYN_CMD
132135

136+
#define SJA1105PQRS_SIZE_GENERAL_PARAMS_DYN_CMD \
137+
(SJA1105_SIZE_DYN_CMD + SJA1105PQRS_SIZE_GENERAL_PARAMS_ENTRY)
138+
133139
#define SJA1105PQRS_SIZE_AVB_PARAMS_DYN_CMD \
134140
(SJA1105_SIZE_DYN_CMD + SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY)
135141

@@ -143,7 +149,7 @@
143149
(SJA1105_SIZE_DYN_CMD + SJA1105PQRS_SIZE_CBS_ENTRY)
144150

145151
#define SJA1105_MAX_DYN_CMD_SIZE \
146-
SJA1105PQRS_SIZE_MAC_CONFIG_DYN_CMD
152+
SJA1105PQRS_SIZE_GENERAL_PARAMS_DYN_CMD
147153

148154
struct sja1105_dyn_cmd {
149155
bool search;
@@ -500,6 +506,18 @@ sja1105et_l2_lookup_params_entry_packing(void *buf, void *entry_ptr,
500506
return 0;
501507
}
502508

509+
static void
510+
sja1105pqrs_l2_lookup_params_cmd_packing(void *buf,
511+
struct sja1105_dyn_cmd *cmd,
512+
enum packing_op op)
513+
{
514+
u8 *p = buf + SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_ENTRY;
515+
const int size = SJA1105_SIZE_DYN_CMD;
516+
517+
sja1105_packing(p, &cmd->valid, 31, 31, size, op);
518+
sja1105_packing(p, &cmd->rdwrset, 30, 30, size, op);
519+
}
520+
503521
static void
504522
sja1105et_general_params_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
505523
enum packing_op op)
@@ -522,6 +540,18 @@ sja1105et_general_params_entry_packing(void *buf, void *entry_ptr,
522540
return 0;
523541
}
524542

543+
static void
544+
sja1105pqrs_general_params_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
545+
enum packing_op op)
546+
{
547+
u8 *p = buf + SJA1105PQRS_SIZE_GENERAL_PARAMS_ENTRY;
548+
const int size = SJA1105_SIZE_DYN_CMD;
549+
550+
sja1105_packing(p, &cmd->valid, 31, 31, size, op);
551+
sja1105_packing(p, &cmd->errors, 30, 30, size, op);
552+
sja1105_packing(p, &cmd->rdwrset, 28, 28, size, op);
553+
}
554+
525555
static void
526556
sja1105pqrs_avb_params_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd,
527557
enum packing_op op)
@@ -761,12 +791,12 @@ struct sja1105_dynamic_table_ops sja1105pqrs_dyn_ops[BLK_IDX_MAX_DYN] = {
761791
[BLK_IDX_SCHEDULE_ENTRY_POINTS_PARAMS] = {0},
762792
[BLK_IDX_VL_FORWARDING_PARAMS] = {0},
763793
[BLK_IDX_L2_LOOKUP_PARAMS] = {
764-
.entry_packing = sja1105et_l2_lookup_params_entry_packing,
765-
.cmd_packing = sja1105et_l2_lookup_params_cmd_packing,
794+
.entry_packing = sja1105pqrs_l2_lookup_params_entry_packing,
795+
.cmd_packing = sja1105pqrs_l2_lookup_params_cmd_packing,
766796
.max_entry_count = SJA1105_MAX_L2_LOOKUP_PARAMS_COUNT,
767797
.access = (OP_READ | OP_WRITE),
768-
.packed_size = SJA1105ET_SIZE_L2_LOOKUP_PARAMS_DYN_CMD,
769-
.addr = 0x38,
798+
.packed_size = SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_DYN_CMD,
799+
.addr = 0x54,
770800
},
771801
[BLK_IDX_L2_FORWARDING_PARAMS] = {0},
772802
[BLK_IDX_AVB_PARAMS] = {
@@ -778,12 +808,12 @@ struct sja1105_dynamic_table_ops sja1105pqrs_dyn_ops[BLK_IDX_MAX_DYN] = {
778808
.addr = 0x8003,
779809
},
780810
[BLK_IDX_GENERAL_PARAMS] = {
781-
.entry_packing = sja1105et_general_params_entry_packing,
782-
.cmd_packing = sja1105et_general_params_cmd_packing,
811+
.entry_packing = sja1105pqrs_general_params_entry_packing,
812+
.cmd_packing = sja1105pqrs_general_params_cmd_packing,
783813
.max_entry_count = SJA1105_MAX_GENERAL_PARAMS_COUNT,
784-
.access = OP_WRITE,
785-
.packed_size = SJA1105ET_SIZE_GENERAL_PARAMS_DYN_CMD,
786-
.addr = 0x34,
814+
.access = (OP_READ | OP_WRITE),
815+
.packed_size = SJA1105PQRS_SIZE_GENERAL_PARAMS_DYN_CMD,
816+
.addr = 0x3B,
787817
},
788818
[BLK_IDX_RETAGGING] = {
789819
.entry_packing = sja1105_retagging_entry_packing,

drivers/net/dsa/sja1105/sja1105_static_config.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ static size_t sja1105et_general_params_entry_packing(void *buf, void *entry_ptr,
146146
/* TPID and TPID2 are intentionally reversed so that semantic
147147
* compatibility with E/T is kept.
148148
*/
149-
static size_t
150-
sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr,
151-
enum packing_op op)
149+
size_t sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr,
150+
enum packing_op op)
152151
{
153152
const size_t size = SJA1105PQRS_SIZE_GENERAL_PARAMS_ENTRY;
154153
struct sja1105_general_params_entry *entry = entry_ptr;
@@ -228,9 +227,8 @@ sja1105et_l2_lookup_params_entry_packing(void *buf, void *entry_ptr,
228227
return size;
229228
}
230229

231-
static size_t
232-
sja1105pqrs_l2_lookup_params_entry_packing(void *buf, void *entry_ptr,
233-
enum packing_op op)
230+
size_t sja1105pqrs_l2_lookup_params_entry_packing(void *buf, void *entry_ptr,
231+
enum packing_op op)
234232
{
235233
const size_t size = SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_ENTRY;
236234
struct sja1105_l2_lookup_params_entry *entry = entry_ptr;

drivers/net/dsa/sja1105/sja1105_static_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ void sja1105_packing(void *buf, u64 *val, int start, int end,
431431
size_t len, enum packing_op op);
432432

433433
/* Common implementations for the static and dynamic configs */
434+
size_t sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr,
435+
enum packing_op op);
436+
size_t sja1105pqrs_l2_lookup_params_entry_packing(void *buf, void *entry_ptr,
437+
enum packing_op op);
434438
size_t sja1105_l2_forwarding_entry_packing(void *buf, void *entry_ptr,
435439
enum packing_op op);
436440
size_t sja1105pqrs_l2_lookup_entry_packing(void *buf, void *entry_ptr,

0 commit comments

Comments
 (0)