Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: qca8k: implement the port MTU callbacks

This switch has a single max frame size configuration register, so we
track the requested MTU for each port and apply the largest.

v2:
- Address review feedback from Vladimir Oltean

Signed-off-by: Jonathan McDowell <noodles@earth.li>
Acked-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jonathan McDowell and committed by
David S. Miller
f58d2598 2b96692b

+34
+31
drivers/net/dsa/qca8k.c
··· 670 670 } 671 671 } 672 672 673 + /* Setup our port MTUs to match power on defaults */ 674 + for (i = 0; i < QCA8K_NUM_PORTS; i++) 675 + priv->port_mtu[i] = ETH_FRAME_LEN + ETH_FCS_LEN; 676 + qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, ETH_FRAME_LEN + ETH_FCS_LEN); 677 + 673 678 /* Flush the FDB table */ 674 679 qca8k_fdb_flush(priv); 675 680 ··· 1104 1099 } 1105 1100 1106 1101 static int 1102 + qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu) 1103 + { 1104 + struct qca8k_priv *priv = ds->priv; 1105 + int i, mtu = 0; 1106 + 1107 + priv->port_mtu[port] = new_mtu; 1108 + 1109 + for (i = 0; i < QCA8K_NUM_PORTS; i++) 1110 + if (priv->port_mtu[port] > mtu) 1111 + mtu = priv->port_mtu[port]; 1112 + 1113 + /* Include L2 header / FCS length */ 1114 + qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_LEN); 1115 + 1116 + return 0; 1117 + } 1118 + 1119 + static int 1120 + qca8k_port_max_mtu(struct dsa_switch *ds, int port) 1121 + { 1122 + return QCA8K_MAX_MTU; 1123 + } 1124 + 1125 + static int 1107 1126 qca8k_port_fdb_insert(struct qca8k_priv *priv, const u8 *addr, 1108 1127 u16 port_mask, u16 vid) 1109 1128 { ··· 1203 1174 .set_mac_eee = qca8k_set_mac_eee, 1204 1175 .port_enable = qca8k_port_enable, 1205 1176 .port_disable = qca8k_port_disable, 1177 + .port_change_mtu = qca8k_port_change_mtu, 1178 + .port_max_mtu = qca8k_port_max_mtu, 1206 1179 .port_stp_state_set = qca8k_port_stp_state_set, 1207 1180 .port_bridge_join = qca8k_port_bridge_join, 1208 1181 .port_bridge_leave = qca8k_port_bridge_leave,
+3
drivers/net/dsa/qca8k.h
··· 13 13 #include <linux/gpio.h> 14 14 15 15 #define QCA8K_NUM_PORTS 7 16 + #define QCA8K_MAX_MTU 9000 16 17 17 18 #define PHY_ID_QCA8337 0x004dd036 18 19 #define QCA8K_ID_QCA8337 0x13 ··· 59 58 #define QCA8K_MDIO_MASTER_MAX_REG 32 60 59 #define QCA8K_GOL_MAC_ADDR0 0x60 61 60 #define QCA8K_GOL_MAC_ADDR1 0x64 61 + #define QCA8K_MAX_FRAME_SIZE 0x78 62 62 #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4) 63 63 #define QCA8K_PORT_STATUS_SPEED GENMASK(1, 0) 64 64 #define QCA8K_PORT_STATUS_SPEED_10 0 ··· 191 189 struct device *dev; 192 190 struct dsa_switch_ops ops; 193 191 struct gpio_desc *reset_gpio; 192 + unsigned int port_mtu[QCA8K_NUM_PORTS]; 194 193 }; 195 194 196 195 struct qca8k_mib_desc {