57df4c126e493797ff1b0f14749ea4d8b684b1f9
[openwrt/staging/dangole.git] /
1 From 69fd055957a02309ffdc23d887a01988b6e5bab1 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Sat, 16 Apr 2022 01:30:12 +0200
4 Subject: [PATCH 1/6] net: dsa: qca8k: drop MTU tracking from qca8k_priv
5
6 DSA set the CPU port based on the largest MTU of all the slave ports.
7 Based on this we can drop the MTU array from qca8k_priv and set the
8 port_change_mtu logic on DSA changing MTU of the CPU port as the switch
9 have a global MTU settingfor each port.
10
11 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
12 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/dsa/qca8k.c | 26 +++++++++-----------------
16 drivers/net/dsa/qca8k.h | 1 -
17 2 files changed, 9 insertions(+), 18 deletions(-)
18
19 --- a/drivers/net/dsa/qca8k.c
20 +++ b/drivers/net/dsa/qca8k.c
21 @@ -1803,16 +1803,6 @@ qca8k_setup(struct dsa_switch *ds)
22 QCA8K_PORT_HOL_CTRL1_WRED_EN,
23 mask);
24 }
25 -
26 - /* Set initial MTU for every port.
27 - * We have only have a general MTU setting. So track
28 - * every port and set the max across all port.
29 - * Set per port MTU to 1500 as the MTU change function
30 - * will add the overhead and if its set to 1518 then it
31 - * will apply the overhead again and we will end up with
32 - * MTU of 1536 instead of 1518
33 - */
34 - priv->port_mtu[i] = ETH_DATA_LEN;
35 }
36
37 /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */
38 @@ -2525,13 +2515,16 @@ static int
39 qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
40 {
41 struct qca8k_priv *priv = ds->priv;
42 - int ret, i, mtu = 0;
43 -
44 - priv->port_mtu[port] = new_mtu;
45 + int ret;
46
47 - for (i = 0; i < QCA8K_NUM_PORTS; i++)
48 - if (priv->port_mtu[i] > mtu)
49 - mtu = priv->port_mtu[i];
50 + /* We have only have a general MTU setting.
51 + * DSA always set the CPU port's MTU to the largest MTU of the slave
52 + * ports.
53 + * Setting MTU just for the CPU port is sufficient to correctly set a
54 + * value for every port.
55 + */
56 + if (!dsa_is_cpu_port(ds, port))
57 + return 0;
58
59 /* To change the MAX_FRAME_SIZE the cpu ports must be off or
60 * the switch panics.
61 @@ -2545,7 +2538,7 @@ qca8k_port_change_mtu(struct dsa_switch
62 qca8k_port_set_status(priv, 6, 0);
63
64 /* Include L2 header / FCS length */
65 - ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_LEN);
66 + ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, new_mtu + ETH_HLEN + ETH_FCS_LEN);
67
68 if (priv->port_sts[0].enabled)
69 qca8k_port_set_status(priv, 0, 1);
70 --- a/drivers/net/dsa/qca8k.h
71 +++ b/drivers/net/dsa/qca8k.h
72 @@ -392,7 +392,6 @@ struct qca8k_priv {
73 struct device *dev;
74 struct dsa_switch_ops ops;
75 struct gpio_desc *reset_gpio;
76 - unsigned int port_mtu[QCA8K_NUM_PORTS];
77 struct net_device *mgmt_master; /* Track if mdio/mib Ethernet is available */
78 struct qca8k_mgmt_eth_data mgmt_eth_data;
79 struct qca8k_mib_eth_data mib_eth_data;