Skip to content

Commit ce84c7c

Browse files
committed
Merge branch 'mv88e6390-batch-three'
Andrew Lunn says: ==================== mv88e6390 batch 3 More patches to support the MV88e6390. This is mostly refactoring existing code and adding implementations for the mv88e6390. This patchset set which reserved frames are sent to the cpu, the size of jumbo frames that will be accepted, turn off egress rate limiting, and configuration of pause frames. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 7a6c5cb + 3ce0e65 commit ce84c7c

File tree

8 files changed

+225
-42
lines changed

8 files changed

+225
-42
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 102 additions & 23 deletions
Large diffs are not rendered by default.

drivers/net/dsa/mv88e6xxx/global1.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,33 @@ int mv88e6390_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port)
102102
port);
103103
}
104104

105+
int mv88e6390_g1_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip)
106+
{
107+
int err;
108+
109+
/* 01:c2:80:00:00:00:00-01:c2:80:00:00:00:07 are Management */
110+
err = mv88e6390_g1_monitor_write(
111+
chip, GLOBAL_MONITOR_CONTROL_0180C280000000XLO, 0xff);
112+
if (err)
113+
return err;
114+
115+
/* 01:c2:80:00:00:00:08-01:c2:80:00:00:00:0f are Management */
116+
err = mv88e6390_g1_monitor_write(
117+
chip, GLOBAL_MONITOR_CONTROL_0180C280000000XHI, 0xff);
118+
if (err)
119+
return err;
120+
121+
/* 01:c2:80:00:00:00:20-01:c2:80:00:00:00:27 are Management */
122+
err = mv88e6390_g1_monitor_write(
123+
chip, GLOBAL_MONITOR_CONTROL_0180C280000002XLO, 0xff);
124+
if (err)
125+
return err;
126+
127+
/* 01:c2:80:00:00:00:28-01:c2:80:00:00:00:2f are Management */
128+
return mv88e6390_g1_monitor_write(
129+
chip, GLOBAL_MONITOR_CONTROL_0180C280000002XHI, 0xff);
130+
}
131+
105132
/* Offset 0x1c: Global Control 2 */
106133

107134
int mv88e6390_g1_stats_set_histogram(struct mv88e6xxx_chip *chip)

drivers/net/dsa/mv88e6xxx/global1.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ int mv88e6095_g1_set_egress_port(struct mv88e6xxx_chip *chip, int port);
2929
int mv88e6390_g1_set_egress_port(struct mv88e6xxx_chip *chip, int port);
3030
int mv88e6095_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
3131
int mv88e6390_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
32+
int mv88e6390_g1_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
3233

3334
#endif /* _MV88E6XXX_GLOBAL1_H */

drivers/net/dsa/mv88e6xxx/global2.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,31 @@ static int mv88e6xxx_g2_wait(struct mv88e6xxx_chip *chip, int reg, u16 mask)
3838
return mv88e6xxx_wait(chip, ADDR_GLOBAL2, reg, mask);
3939
}
4040

41+
/* Offset 0x02: Management Enable 2x */
42+
/* Offset 0x03: Management Enable 0x */
43+
44+
int mv88e6095_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip)
45+
{
46+
int err;
47+
48+
/* Consider the frames with reserved multicast destination
49+
* addresses matching 01:80:c2:00:00:2x as MGMT.
50+
*/
51+
if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_G2_MGMT_EN_2X)) {
52+
err = mv88e6xxx_g2_write(chip, GLOBAL2_MGMT_EN_2X, 0xffff);
53+
if (err)
54+
return err;
55+
}
56+
57+
/* Consider the frames with reserved multicast destination
58+
* addresses matching 01:80:c2:00:00:0x as MGMT.
59+
*/
60+
if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_G2_MGMT_EN_0X))
61+
return mv88e6xxx_g2_write(chip, GLOBAL2_MGMT_EN_0X, 0xffff);
62+
63+
return 0;
64+
}
65+
4166
/* Offset 0x06: Device Mapping Table register */
4267

4368
static int mv88e6xxx_g2_device_mapping_write(struct mv88e6xxx_chip *chip,
@@ -567,24 +592,6 @@ int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip)
567592
u16 reg;
568593
int err;
569594

570-
if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_G2_MGMT_EN_2X)) {
571-
/* Consider the frames with reserved multicast destination
572-
* addresses matching 01:80:c2:00:00:2x as MGMT.
573-
*/
574-
err = mv88e6xxx_g2_write(chip, GLOBAL2_MGMT_EN_2X, 0xffff);
575-
if (err)
576-
return err;
577-
}
578-
579-
if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_G2_MGMT_EN_0X)) {
580-
/* Consider the frames with reserved multicast destination
581-
* addresses matching 01:80:c2:00:00:0x as MGMT.
582-
*/
583-
err = mv88e6xxx_g2_write(chip, GLOBAL2_MGMT_EN_0X, 0xffff);
584-
if (err)
585-
return err;
586-
}
587-
588595
/* Ignore removed tag data on doubly tagged packets, disable
589596
* flow control messages, force flow control priority to the
590597
* highest, and send all special multicast frames to the CPU

drivers/net/dsa/mv88e6xxx/global2.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int mv88e6xxx_g2_set_eeprom16(struct mv88e6xxx_chip *chip,
3535
int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip);
3636
int mv88e6xxx_g2_irq_setup(struct mv88e6xxx_chip *chip);
3737
void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip);
38+
int mv88e6095_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
3839

3940
#else /* !CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 */
4041

@@ -94,6 +95,11 @@ static inline void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip)
9495
{
9596
}
9697

98+
static inline int mv88e6095_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip)
99+
{
100+
return -EOPNOTSUPP;
101+
}
102+
97103
#endif /* CONFIG_NET_DSA_MV88E6XXX_GLOBAL2 */
98104

99105
#endif /* _MV88E6XXX_GLOBAL2_H */

drivers/net/dsa/mv88e6xxx/mv88e6xxx.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
#define PORT_PCS_CTRL_SPEED_10000 (0x03) /* 6390X */
7979
#define PORT_PCS_CTRL_SPEED_UNFORCED (0x03)
8080
#define PORT_PAUSE_CTRL 0x02
81+
#define PORT_FLOW_CTRL_LIMIT_IN ((0x00 << 8) | BIT(15))
82+
#define PORT_FLOW_CTRL_LIMIT_OUT ((0x01 << 8) | BIT(15))
8183
#define PORT_SWITCH_ID 0x03
8284
#define PORT_SWITCH_ID_PROD_NUM_6085 0x04a
8385
#define PORT_SWITCH_ID_PROD_NUM_6095 0x095
@@ -833,6 +835,10 @@ struct mv88e6xxx_ops {
833835
bool on);
834836
int (*port_set_ether_type)(struct mv88e6xxx_chip *chip, int port,
835837
u16 etype);
838+
int (*port_jumbo_config)(struct mv88e6xxx_chip *chip, int port);
839+
840+
int (*port_egress_rate_limiting)(struct mv88e6xxx_chip *chip, int port);
841+
int (*port_pause_config)(struct mv88e6xxx_chip *chip, int port);
836842

837843
/* Snapshot the statistics for a port. The statistics can then
838844
* be read back a leisure but still with a consistent view.
@@ -851,6 +857,9 @@ struct mv88e6xxx_ops {
851857
uint64_t *data);
852858
int (*g1_set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
853859
int (*g1_set_egress_port)(struct mv88e6xxx_chip *chip, int port);
860+
861+
/* Can be either in g1 or g2, so don't use a prefix */
862+
int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip);
854863
};
855864

856865
#define STATS_TYPE_PORT BIT(0)

drivers/net/dsa/mv88e6xxx/port.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,30 @@ int mv88e6390x_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
304304
return mv88e6xxx_port_set_speed(chip, port, speed, true, true);
305305
}
306306

307+
/* Offset 0x02: Pause Control
308+
*
309+
* Do not limit the period of time that this port can be paused for by
310+
* the remote end or the period of time that this port can pause the
311+
* remote end.
312+
*/
313+
int mv88e6097_port_pause_config(struct mv88e6xxx_chip *chip, int port)
314+
{
315+
return mv88e6xxx_port_write(chip, port, PORT_PAUSE_CTRL, 0x0000);
316+
}
317+
318+
int mv88e6390_port_pause_config(struct mv88e6xxx_chip *chip, int port)
319+
{
320+
int err;
321+
322+
err = mv88e6xxx_port_write(chip, port, PORT_PAUSE_CTRL,
323+
PORT_FLOW_CTRL_LIMIT_IN | 0);
324+
if (err)
325+
return err;
326+
327+
return mv88e6xxx_port_write(chip, port, PORT_PAUSE_CTRL,
328+
PORT_FLOW_CTRL_LIMIT_OUT | 0);
329+
}
330+
307331
/* Offset 0x04: Port Control Register */
308332

309333
static const char * const mv88e6xxx_port_state_names[] = {
@@ -607,6 +631,32 @@ int mv88e6xxx_port_set_8021q_mode(struct mv88e6xxx_chip *chip, int port,
607631
return 0;
608632
}
609633

634+
int mv88e6165_port_jumbo_config(struct mv88e6xxx_chip *chip, int port)
635+
{
636+
u16 reg;
637+
int err;
638+
639+
err = mv88e6xxx_port_read(chip, port, PORT_CONTROL_2, &reg);
640+
if (err)
641+
return err;
642+
643+
reg |= PORT_CONTROL_2_JUMBO_10240;
644+
645+
return mv88e6xxx_port_write(chip, port, PORT_CONTROL_2, reg);
646+
}
647+
648+
/* Offset 0x09: Port Rate Control */
649+
650+
int mv88e6095_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port)
651+
{
652+
return mv88e6xxx_port_write(chip, port, PORT_RATE_CONTROL, 0x0000);
653+
}
654+
655+
int mv88e6097_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port)
656+
{
657+
return mv88e6xxx_port_write(chip, port, PORT_RATE_CONTROL, 0x0001);
658+
}
659+
610660
/* Offset 0x0f: Port Ether type */
611661

612662
int mv88e6351_port_set_ether_type(struct mv88e6xxx_chip *chip, int port,

drivers/net/dsa/mv88e6xxx/port.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ int mv88e6351_port_set_egress_unknowns(struct mv88e6xxx_chip *chip, int port,
6262
bool on);
6363
int mv88e6351_port_set_ether_type(struct mv88e6xxx_chip *chip, int port,
6464
u16 etype);
65-
65+
int mv88e6165_port_jumbo_config(struct mv88e6xxx_chip *chip, int port);
66+
int mv88e6095_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port);
67+
int mv88e6097_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port);
68+
int mv88e6097_port_pause_config(struct mv88e6xxx_chip *chip, int port);
69+
int mv88e6390_port_pause_config(struct mv88e6xxx_chip *chip, int port);
6670

6771
#endif /* _MV88E6XXX_PORT_H */

0 commit comments

Comments
 (0)