Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 540bfe30 authored by Jarod Wilson's avatar Jarod Wilson Committed by David S. Miller
Browse files

ethernet/sun: use core min/max MTU checking



cassini: min_mtu 60, max_mtu 9000

niu: min_mtu 68, max_mtu 9216

sungem: min_mtu 68, max_mtu 1500 (comments say jumbo mode is broken)

sunvnet: min_mtu 68, max_mtu 65535
- removed sunvnet_change_mut_common as it does nothing now

CC: netdev@vger.kernel.org
Signed-off-by: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c7315a95
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3863,9 +3863,6 @@ static int cas_change_mtu(struct net_device *dev, int new_mtu)
{
	struct cas *cp = netdev_priv(dev);

	if (new_mtu < CAS_MIN_MTU || new_mtu > CAS_MAX_MTU)
		return -EINVAL;

	dev->mtu = new_mtu;
	if (!netif_running(dev) || !netif_device_present(dev))
		return 0;
@@ -5115,6 +5112,10 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
	if (pci_using_dac)
		dev->features |= NETIF_F_HIGHDMA;

	/* MTU range: 60 - varies or 9000 */
	dev->min_mtu = CAS_MIN_MTU;
	dev->max_mtu = CAS_MAX_MTU;

	if (register_netdev(dev)) {
		dev_err(&pdev->dev, "Cannot register net device, aborting\n");
		goto err_out_free_consistent;
+4 −1
Original line number Diff line number Diff line
@@ -139,7 +139,6 @@ static const struct net_device_ops vsw_ops = {
	.ndo_set_mac_address	= sunvnet_set_mac_addr_common,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_tx_timeout		= sunvnet_tx_timeout_common,
	.ndo_change_mtu		= sunvnet_change_mtu_common,
	.ndo_start_xmit		= vsw_start_xmit,
	.ndo_select_queue	= vsw_select_queue,
#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -239,6 +238,10 @@ static struct net_device *vsw_alloc_netdev(u8 hwaddr[],
			   NETIF_F_HW_CSUM | NETIF_F_SG;
	dev->features = dev->hw_features;

	/* MTU range: 68 - 65535 */
	dev->min_mtu = ETH_MIN_MTU;
	dev->max_mtu = VNET_MAX_MTU;

	SET_NETDEV_DEV(dev, &vdev->dev);

	return dev;
+4 −3
Original line number Diff line number Diff line
@@ -6754,9 +6754,6 @@ static int niu_change_mtu(struct net_device *dev, int new_mtu)
	struct niu *np = netdev_priv(dev);
	int err, orig_jumbo, new_jumbo;

	if (new_mtu < 68 || new_mtu > NIU_MAX_MTU)
		return -EINVAL;

	orig_jumbo = (dev->mtu > ETH_DATA_LEN);
	new_jumbo = (new_mtu > ETH_DATA_LEN);

@@ -9823,6 +9820,10 @@ static int niu_pci_init_one(struct pci_dev *pdev,

	dev->irq = pdev->irq;

	/* MTU range: 68 - 9216 */
	dev->min_mtu = ETH_MIN_MTU;
	dev->max_mtu = NIU_MAX_MTU;

	niu_assign_netdev_ops(dev);

	err = niu_get_invariants(np);
+6 −5
Original line number Diff line number Diff line
@@ -2476,9 +2476,9 @@ static void gem_set_multicast(struct net_device *dev)
}

/* Jumbo-grams don't seem to work :-( */
#define GEM_MIN_MTU	68
#define GEM_MIN_MTU	ETH_MIN_MTU
#if 1
#define GEM_MAX_MTU	1500
#define GEM_MAX_MTU	ETH_DATA_LEN
#else
#define GEM_MAX_MTU	9000
#endif
@@ -2487,9 +2487,6 @@ static int gem_change_mtu(struct net_device *dev, int new_mtu)
{
	struct gem *gp = netdev_priv(dev);

	if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU)
		return -EINVAL;

	dev->mtu = new_mtu;

	/* We'll just catch it later when the device is up'd or resumed */
@@ -2977,6 +2974,10 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
	if (pci_using_dac)
		dev->features |= NETIF_F_HIGHDMA;

	/* MTU range: 68 - 1500 (Jumbo mode is broken) */
	dev->min_mtu = GEM_MIN_MTU;
	dev->max_mtu = GEM_MAX_MTU;

	/* Register with kernel */
	if (register_netdev(dev)) {
		pr_err("Cannot register net device, aborting\n");
+4 −1
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@ static const struct net_device_ops vnet_ops = {
	.ndo_set_mac_address	= sunvnet_set_mac_addr_common,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_tx_timeout		= sunvnet_tx_timeout_common,
	.ndo_change_mtu		= sunvnet_change_mtu_common,
	.ndo_start_xmit		= vnet_start_xmit,
	.ndo_select_queue	= vnet_select_queue,
#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -202,6 +201,10 @@ static struct vnet *vnet_new(const u64 *local_mac,
			   NETIF_F_HW_CSUM | NETIF_F_SG;
	dev->features = dev->hw_features;

	/* MTU range: 68 - 65535 */
	dev->min_mtu = ETH_MIN_MTU;
	dev->max_mtu = VNET_MAX_MTU;

	SET_NETDEV_DEV(dev, &vdev->dev);

	err = register_netdev(dev);
Loading