667be87db0d1082529888653183c3d5f3c315598
[openwrt/openwrt.git] /
1 From b2f7c18c351737c2a053c39c09ef50870fd78c06 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Thu, 14 Nov 2019 17:03:25 +0200
4 Subject: [PATCH] net: mscc: ocelot: adjust MTU on the CPU port in NPI mode
5
6 When using the NPI port, the DSA tag is passed through Ethernet, so the
7 switch's MAC needs to accept it as it comes from the DSA master. Increase
8 the MTU on the external CPU port to account for the length of the
9 injection header.
10
11 Without this patch, MTU-sized frames are dropped by the switch's CPU
12 port on xmit, which is especially obvious in TCP sessions.
13
14 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
15 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
16 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
17 Signed-off-by: David S. Miller <davem@davemloft.net>
18 ---
19 drivers/net/ethernet/mscc/ocelot.c | 9 +++++++++
20 drivers/net/ethernet/mscc/ocelot.h | 2 ++
21 2 files changed, 11 insertions(+)
22
23 --- a/drivers/net/ethernet/mscc/ocelot.c
24 +++ b/drivers/net/ethernet/mscc/ocelot.c
25 @@ -2229,9 +2229,18 @@ void ocelot_set_cpu_port(struct ocelot *
26 * Only one port can be an NPI at the same time.
27 */
28 if (cpu < ocelot->num_phys_ports) {
29 + int mtu = VLAN_ETH_FRAME_LEN + OCELOT_TAG_LEN;
30 +
31 ocelot_write(ocelot, QSYS_EXT_CPU_CFG_EXT_CPUQ_MSK_M |
32 QSYS_EXT_CPU_CFG_EXT_CPU_PORT(cpu),
33 QSYS_EXT_CPU_CFG);
34 +
35 + if (injection == OCELOT_TAG_PREFIX_SHORT)
36 + mtu += OCELOT_SHORT_PREFIX_LEN;
37 + else if (injection == OCELOT_TAG_PREFIX_LONG)
38 + mtu += OCELOT_LONG_PREFIX_LEN;
39 +
40 + ocelot_port_set_mtu(ocelot, cpu, mtu);
41 }
42
43 /* CPU port Injection/Extraction configuration */
44 --- a/drivers/net/ethernet/mscc/ocelot.h
45 +++ b/drivers/net/ethernet/mscc/ocelot.h
46 @@ -65,6 +65,8 @@ struct frame_info {
47 #define IFH_REW_OP_ORIGIN_PTP 0x5
48
49 #define OCELOT_TAG_LEN 16
50 +#define OCELOT_SHORT_PREFIX_LEN 4
51 +#define OCELOT_LONG_PREFIX_LEN 16
52
53 #define OCELOT_SPEED_2500 0
54 #define OCELOT_SPEED_1000 1