Skip to content

Commit 109cc16

Browse files
jarodwilsondavem330
authored andcommitted
ethernet/cavium: use core min/max MTU checking
liquidio: min_mtu 68, max_mtu 16000 thunder: min_mtu 64, max_mtu 9200 CC: [email protected] CC: Sunil Goutham <[email protected]> CC: Robert Richter <[email protected]> CC: Derek Chickles <[email protected]> CC: Satanand Burla <[email protected]> CC: Felix Manlunas <[email protected]> CC: Raghu Vatsavayi <[email protected]> Signed-off-by: Jarod Wilson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 18c310f commit 109cc16

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,17 +2868,6 @@ static int liquidio_change_mtu(struct net_device *netdev, int new_mtu)
28682868
struct octnic_ctrl_pkt nctrl;
28692869
int ret = 0;
28702870

2871-
/* Limit the MTU to make sure the ethernet packets are between 68 bytes
2872-
* and 16000 bytes
2873-
*/
2874-
if ((new_mtu < LIO_MIN_MTU_SIZE) ||
2875-
(new_mtu > LIO_MAX_MTU_SIZE)) {
2876-
dev_err(&oct->pci_dev->dev, "Invalid MTU: %d\n", new_mtu);
2877-
dev_err(&oct->pci_dev->dev, "Valid range %d and %d\n",
2878-
LIO_MIN_MTU_SIZE, LIO_MAX_MTU_SIZE);
2879-
return -EINVAL;
2880-
}
2881-
28822871
memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt));
28832872

28842873
nctrl.ncmd.u64 = 0;
@@ -3891,6 +3880,10 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
38913880
netdev->hw_features = netdev->hw_features &
38923881
~NETIF_F_HW_VLAN_CTAG_RX;
38933882

3883+
/* MTU range: 68 - 16000 */
3884+
netdev->min_mtu = LIO_MIN_MTU_SIZE;
3885+
netdev->max_mtu = LIO_MAX_MTU_SIZE;
3886+
38943887
/* Point to the properties for octeon device to which this
38953888
* interface belongs.
38963889
*/

drivers/net/ethernet/cavium/liquidio/octeon_network.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <linux/ptp_clock_kernel.h>
3030

3131
#define LIO_MAX_MTU_SIZE (OCTNET_MAX_FRM_SIZE - OCTNET_FRM_HEADER_SIZE)
32-
#define LIO_MIN_MTU_SIZE 68
32+
#define LIO_MIN_MTU_SIZE ETH_MIN_MTU
3333

3434
struct oct_nic_stats_resp {
3535
u64 rh;

drivers/net/ethernet/cavium/octeon/octeon_mgmt.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,6 @@ static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
645645
struct octeon_mgmt *p = netdev_priv(netdev);
646646
int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
647647

648-
/* Limit the MTU to make sure the ethernet packets are between
649-
* 64 bytes and 16383 bytes.
650-
*/
651-
if (size_without_fcs < 64 || size_without_fcs > 16383) {
652-
dev_warn(p->dev, "MTU must be between %d and %d.\n",
653-
64 - OCTEON_MGMT_RX_HEADROOM,
654-
16383 - OCTEON_MGMT_RX_HEADROOM);
655-
return -EINVAL;
656-
}
657-
658648
netdev->mtu = new_mtu;
659649

660650
cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
@@ -1491,6 +1481,9 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
14911481
netdev->netdev_ops = &octeon_mgmt_ops;
14921482
netdev->ethtool_ops = &octeon_mgmt_ethtool_ops;
14931483

1484+
netdev->min_mtu = 64 - OCTEON_MGMT_RX_HEADROOM;
1485+
netdev->max_mtu = 16383 - OCTEON_MGMT_RX_HEADROOM;
1486+
14941487
mac = of_get_mac_address(pdev->dev.of_node);
14951488

14961489
if (mac)

drivers/net/ethernet/cavium/thunder/nicvf_main.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,12 +1312,6 @@ static int nicvf_change_mtu(struct net_device *netdev, int new_mtu)
13121312
{
13131313
struct nicvf *nic = netdev_priv(netdev);
13141314

1315-
if (new_mtu > NIC_HW_MAX_FRS)
1316-
return -EINVAL;
1317-
1318-
if (new_mtu < NIC_HW_MIN_FRS)
1319-
return -EINVAL;
1320-
13211315
if (nicvf_update_hw_max_frs(nic, new_mtu))
13221316
return -EINVAL;
13231317
netdev->mtu = new_mtu;
@@ -1630,6 +1624,10 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
16301624
netdev->netdev_ops = &nicvf_netdev_ops;
16311625
netdev->watchdog_timeo = NICVF_TX_TIMEOUT;
16321626

1627+
/* MTU range: 64 - 9200 */
1628+
netdev->min_mtu = NIC_HW_MIN_FRS;
1629+
netdev->max_mtu = NIC_HW_MAX_FRS;
1630+
16331631
INIT_WORK(&nic->reset_task, nicvf_reset_task);
16341632

16351633
err = register_netdev(netdev);

0 commit comments

Comments
 (0)