ethernet/marvell: use core min/max MTU checking
mvneta: min_mtu 68, max_mtu 9676 - mtu validation routine mostly did range check, merge back into mvneta_change_mtu for simplicity mvpp2: min_mtu 68, max_mtu 9676 - mtu validation routine mostly did range check, merge back into mvpp2_change_mtu for simplicity pxa168_eth: min_mtu 68, max_mtu 9500 skge: min_mtu 60, max_mtu 9000 sky2: min_mtu 68, max_mtu 1500 or 9000, depending on hw CC: netdev@vger.kernel.org CC: Mirko Lindner <mlindner@marvell.com> CC: Stephen Hemminger <stephen@networkplumber.org> CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
91c527a556
commit
5777987e0f
@@ -3024,29 +3024,6 @@ static void mvneta_stop_dev(struct mvneta_port *pp)
|
||||
mvneta_rx_reset(pp);
|
||||
}
|
||||
|
||||
/* Return positive if MTU is valid */
|
||||
static int mvneta_check_mtu_valid(struct net_device *dev, int mtu)
|
||||
{
|
||||
if (mtu < 68) {
|
||||
netdev_err(dev, "cannot change mtu to less than 68\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* 9676 == 9700 - 20 and rounding to 8 */
|
||||
if (mtu > 9676) {
|
||||
netdev_info(dev, "Illegal MTU value %d, round to 9676\n", mtu);
|
||||
mtu = 9676;
|
||||
}
|
||||
|
||||
if (!IS_ALIGNED(MVNETA_RX_PKT_SIZE(mtu), 8)) {
|
||||
netdev_info(dev, "Illegal MTU value %d, rounding to %d\n",
|
||||
mtu, ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8));
|
||||
mtu = ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8);
|
||||
}
|
||||
|
||||
return mtu;
|
||||
}
|
||||
|
||||
static void mvneta_percpu_enable(void *arg)
|
||||
{
|
||||
struct mvneta_port *pp = arg;
|
||||
@@ -3067,9 +3044,11 @@ static int mvneta_change_mtu(struct net_device *dev, int mtu)
|
||||
struct mvneta_port *pp = netdev_priv(dev);
|
||||
int ret;
|
||||
|
||||
mtu = mvneta_check_mtu_valid(dev, mtu);
|
||||
if (mtu < 0)
|
||||
return -EINVAL;
|
||||
if (!IS_ALIGNED(MVNETA_RX_PKT_SIZE(mtu), 8)) {
|
||||
netdev_info(dev, "Illegal MTU value %d, rounding to %d\n",
|
||||
mtu, ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8));
|
||||
mtu = ALIGN(MVNETA_RX_PKT_SIZE(mtu), 8);
|
||||
}
|
||||
|
||||
dev->mtu = mtu;
|
||||
|
||||
@@ -4154,6 +4133,11 @@ static int mvneta_probe(struct platform_device *pdev)
|
||||
dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE;
|
||||
dev->gso_max_segs = MVNETA_MAX_TSO_SEGS;
|
||||
|
||||
/* MTU range: 68 - 9676 */
|
||||
dev->min_mtu = ETH_MIN_MTU;
|
||||
/* 9676 == 9700 - 20 and rounding to 8 */
|
||||
dev->max_mtu = 9676;
|
||||
|
||||
err = register_netdev(dev);
|
||||
if (err < 0) {
|
||||
dev_err(&pdev->dev, "failed to register\n");
|
||||
|
Reference in New Issue
Block a user