cns3xxx: fix mtu setting with kernel 4.14
Since kernel 4.10 commit 61e84623ace3 ("net: centralize net_device
min/max MTU checking"), the range of mtu is [min_mtu, max_mtu], which
is [68, 1500] by default.
It's necessary to set a max_mtu if a mtu > 1500 is supported.
Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: Mathias Kresin <dev@kresin.me>
			
			
This commit is contained in:
		| @@ -1124,22 +1124,12 @@ static int eth_set_mac(struct net_device *netdev, void *p) | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int cns3xxx_change_mtu(struct net_device *dev, int new_mtu) |  | ||||||
| { |  | ||||||
| 	if (new_mtu > MAX_MTU) |  | ||||||
| 		return -EINVAL; |  | ||||||
|  |  | ||||||
| 	dev->mtu = new_mtu; |  | ||||||
| 	return 0; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static const struct net_device_ops cns3xxx_netdev_ops = { | static const struct net_device_ops cns3xxx_netdev_ops = { | ||||||
| 	.ndo_open = eth_open, | 	.ndo_open = eth_open, | ||||||
| 	.ndo_stop = eth_close, | 	.ndo_stop = eth_close, | ||||||
| 	.ndo_start_xmit = eth_xmit, | 	.ndo_start_xmit = eth_xmit, | ||||||
| 	.ndo_set_rx_mode = eth_rx_mode, | 	.ndo_set_rx_mode = eth_rx_mode, | ||||||
| 	.ndo_do_ioctl = eth_ioctl, | 	.ndo_do_ioctl = eth_ioctl, | ||||||
| 	.ndo_change_mtu = cns3xxx_change_mtu, |  | ||||||
| 	.ndo_set_mac_address = eth_set_mac, | 	.ndo_set_mac_address = eth_set_mac, | ||||||
| 	.ndo_validate_addr = eth_validate_addr, | 	.ndo_validate_addr = eth_validate_addr, | ||||||
| }; | }; | ||||||
| @@ -1236,6 +1226,7 @@ static int eth_init_one(struct platform_device *pdev) | |||||||
| 		dev->netdev_ops = &cns3xxx_netdev_ops; | 		dev->netdev_ops = &cns3xxx_netdev_ops; | ||||||
| 		dev->ethtool_ops = &cns3xxx_ethtool_ops; | 		dev->ethtool_ops = &cns3xxx_ethtool_ops; | ||||||
| 		dev->tx_queue_len = 1000; | 		dev->tx_queue_len = 1000; | ||||||
|  | 		dev->max_mtu = MAX_MTU; | ||||||
| 		dev->features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST; | 		dev->features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST; | ||||||
|  |  | ||||||
| 		switch_port_tab[port->id] = port; | 		switch_port_tab[port->id] = port; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mathias Kresin
					Mathias Kresin