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

net: ocelot: add support for ndo_change_mtu

This commit adds support for changing MTU for the ocelot register based
interface. For ocelot, JUMBO frame size can be set up to 25000 bytes
but has been set to 9000 which is a saner value and allows for maximum
gain of performance with FDMA.

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Clément Léger and committed by
Jakub Kicinski
de5841e1 b471a71e

+16
+2
drivers/net/ethernet/mscc/ocelot.h
··· 32 32 33 33 #define OCELOT_PTP_QUEUE_SZ 128 34 34 35 + #define OCELOT_JUMBO_MTU 9000 36 + 35 37 struct ocelot_port_tc { 36 38 bool block_shared; 37 39 unsigned long offload_cnt;
+14
drivers/net/ethernet/mscc/ocelot_net.c
··· 764 764 return phy_mii_ioctl(dev->phydev, ifr, cmd); 765 765 } 766 766 767 + static int ocelot_change_mtu(struct net_device *dev, int new_mtu) 768 + { 769 + struct ocelot_port_private *priv = netdev_priv(dev); 770 + struct ocelot_port *ocelot_port = &priv->port; 771 + struct ocelot *ocelot = ocelot_port->ocelot; 772 + 773 + ocelot_port_set_maxlen(ocelot, priv->chip_port, new_mtu); 774 + WRITE_ONCE(dev->mtu, new_mtu); 775 + 776 + return 0; 777 + } 778 + 767 779 static const struct net_device_ops ocelot_port_netdev_ops = { 768 780 .ndo_open = ocelot_port_open, 769 781 .ndo_stop = ocelot_port_stop, 770 782 .ndo_start_xmit = ocelot_port_xmit, 783 + .ndo_change_mtu = ocelot_change_mtu, 771 784 .ndo_set_rx_mode = ocelot_set_rx_mode, 772 785 .ndo_set_mac_address = ocelot_port_set_mac_address, 773 786 .ndo_get_stats64 = ocelot_get_stats64, ··· 1683 1670 1684 1671 dev->netdev_ops = &ocelot_port_netdev_ops; 1685 1672 dev->ethtool_ops = &ocelot_ethtool_ops; 1673 + dev->max_mtu = OCELOT_JUMBO_MTU; 1686 1674 1687 1675 dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXFCS | 1688 1676 NETIF_F_HW_TC;