Skip to content

Commit f58f081

Browse files
jarodwilsondavem330
authored andcommitted
ethernet/tile: use core min/max MTU checking
tilegx: min_mtu 68, max_mtu 1500 or 9000, depending on modparam - remove tile_net_change_mtu now that it is fully redundant tilepro: min_mtu 68, max_mtu 1500 - hardware supports jumbo packets up to 10226, but it's not implemented or tested yet, according to code comments CC: [email protected] CC: Chris Metcalf <[email protected]> Signed-off-by: Jarod Wilson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3d5d96a commit f58f081

File tree

2 files changed

+13
-35
lines changed

2 files changed

+13
-35
lines changed

drivers/net/ethernet/tile/tilegx.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
/* Maximum number of packets to handle per "poll". */
6060
#define TILE_NET_WEIGHT 64
6161

62+
/* Maximum Jumbo Packet MTU */
63+
#define TILE_JUMBO_MAX_MTU 9000
64+
6265
/* Number of entries in each iqueue. */
6366
#define IQUEUE_ENTRIES 512
6467

@@ -2101,17 +2104,6 @@ static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
21012104
return -EOPNOTSUPP;
21022105
}
21032106

2104-
/* Change the MTU. */
2105-
static int tile_net_change_mtu(struct net_device *dev, int new_mtu)
2106-
{
2107-
if (new_mtu < 68)
2108-
return -EINVAL;
2109-
if (new_mtu > ((jumbo_num != 0) ? 9000 : 1500))
2110-
return -EINVAL;
2111-
dev->mtu = new_mtu;
2112-
return 0;
2113-
}
2114-
21152107
/* Change the Ethernet address of the NIC.
21162108
*
21172109
* The hypervisor driver does not support changing MAC address. However,
@@ -2154,7 +2146,6 @@ static const struct net_device_ops tile_net_ops = {
21542146
.ndo_start_xmit = tile_net_tx,
21552147
.ndo_select_queue = tile_net_select_queue,
21562148
.ndo_do_ioctl = tile_net_ioctl,
2157-
.ndo_change_mtu = tile_net_change_mtu,
21582149
.ndo_tx_timeout = tile_net_tx_timeout,
21592150
.ndo_set_mac_address = tile_net_set_mac_address,
21602151
#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2174,7 +2165,11 @@ static void tile_net_setup(struct net_device *dev)
21742165
ether_setup(dev);
21752166
dev->netdev_ops = &tile_net_ops;
21762167
dev->watchdog_timeo = TILE_NET_TIMEOUT;
2177-
dev->mtu = 1500;
2168+
2169+
/* MTU range: 68 - 1500 or 9000 */
2170+
dev->mtu = ETH_DATA_LEN;
2171+
dev->min_mtu = ETH_MIN_MTU;
2172+
dev->max_mtu = jumbo_num ? TILE_JUMBO_MAX_MTU : ETH_DATA_LEN;
21782173

21792174
features |= NETIF_F_HW_CSUM;
21802175
features |= NETIF_F_SG;

drivers/net/ethernet/tile/tilepro.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
/* This should be 1500 if "jumbo" is not set in LIPP. */
8888
/* This should be at most 10226 (10240 - 14) if "jumbo" is set in LIPP. */
8989
/* ISSUE: This has not been thoroughly tested (except at 1500). */
90-
#define TILE_NET_MTU 1500
90+
#define TILE_NET_MTU ETH_DATA_LEN
9191

9292
/* HACK: Define this to verify incoming packets. */
9393
/* #define TILE_NET_VERIFY_INGRESS */
@@ -2095,26 +2095,6 @@ static struct rtnl_link_stats64 *tile_net_get_stats64(struct net_device *dev,
20952095
}
20962096

20972097

2098-
/*
2099-
* Change the "mtu".
2100-
*
2101-
* The "change_mtu" method is usually not needed.
2102-
* If you need it, it must be like this.
2103-
*/
2104-
static int tile_net_change_mtu(struct net_device *dev, int new_mtu)
2105-
{
2106-
PDEBUG("tile_net_change_mtu()\n");
2107-
2108-
/* Check ranges. */
2109-
if ((new_mtu < 68) || (new_mtu > 1500))
2110-
return -EINVAL;
2111-
2112-
/* Accept the value. */
2113-
dev->mtu = new_mtu;
2114-
2115-
return 0;
2116-
}
2117-
21182098

21192099
/*
21202100
* Change the Ethernet Address of the NIC.
@@ -2229,7 +2209,6 @@ static const struct net_device_ops tile_net_ops = {
22292209
.ndo_start_xmit = tile_net_tx,
22302210
.ndo_do_ioctl = tile_net_ioctl,
22312211
.ndo_get_stats64 = tile_net_get_stats64,
2232-
.ndo_change_mtu = tile_net_change_mtu,
22332212
.ndo_tx_timeout = tile_net_tx_timeout,
22342213
.ndo_set_mac_address = tile_net_set_mac_address,
22352214
#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2252,7 +2231,11 @@ static void tile_net_setup(struct net_device *dev)
22522231
dev->netdev_ops = &tile_net_ops;
22532232
dev->watchdog_timeo = TILE_NET_TIMEOUT;
22542233
dev->tx_queue_len = TILE_NET_TX_QUEUE_LEN;
2234+
2235+
/* MTU range: 68 - 1500 */
22552236
dev->mtu = TILE_NET_MTU;
2237+
dev->min_mtu = ETH_MIN_MTU;
2238+
dev->max_mtu = TILE_NET_MTU;
22562239

22572240
features |= NETIF_F_HW_CSUM;
22582241
features |= NETIF_F_SG;

0 commit comments

Comments
 (0)