aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarini Katakam <harini.katakam@xilinx.com>2015-05-06 12:57:18 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-09 17:41:54 -0400
commita5898ea09aaded8a8236b12f3920f4e6f9b8fc13 (patch)
treea0b7d4354e6f642006bfdb4546943ba36a1be948
parent98b5a0f4a2282fb82907bee467636b8114677472 (diff)
net: macb: Add change_mtu callback with jumbo support
Add macb_change_mtu callback; if jumbo frame support is present allow mtu size changes upto (jumbo max length allowed - headers). Signed-off-by: Harini Katakam <harinik@xilinx.com> Reviewed-by: Punnaiah Choudary Kalluri <punnaia@xilinx.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/cadence/macb.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index cb84587d7555..97c664611e84 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -54,6 +54,8 @@
54#define MACB_MAX_TX_LEN ((unsigned int)((1 << MACB_TX_FRMLEN_SIZE) - 1)) 54#define MACB_MAX_TX_LEN ((unsigned int)((1 << MACB_TX_FRMLEN_SIZE) - 1))
55#define GEM_MAX_TX_LEN ((unsigned int)((1 << GEM_TX_FRMLEN_SIZE) - 1)) 55#define GEM_MAX_TX_LEN ((unsigned int)((1 << GEM_TX_FRMLEN_SIZE) - 1))
56 56
57#define GEM_MTU_MIN_SIZE 68
58
57/* 59/*
58 * Graceful stop timeouts in us. We should allow up to 60 * Graceful stop timeouts in us. We should allow up to
59 * 1 frame time (10 Mbits/s, full-duplex, ignoring collisions) 61 * 1 frame time (10 Mbits/s, full-duplex, ignoring collisions)
@@ -1855,6 +1857,26 @@ static int macb_close(struct net_device *dev)
1855 return 0; 1857 return 0;
1856} 1858}
1857 1859
1860static int macb_change_mtu(struct net_device *dev, int new_mtu)
1861{
1862 struct macb *bp = netdev_priv(dev);
1863 u32 max_mtu;
1864
1865 if (netif_running(dev))
1866 return -EBUSY;
1867
1868 max_mtu = ETH_DATA_LEN;
1869 if (bp->caps | MACB_CAPS_JUMBO)
1870 max_mtu = gem_readl(bp, JML) - ETH_HLEN - ETH_FCS_LEN;
1871
1872 if ((new_mtu > max_mtu) || (new_mtu < GEM_MTU_MIN_SIZE))
1873 return -EINVAL;
1874
1875 dev->mtu = new_mtu;
1876
1877 return 0;
1878}
1879
1858static void gem_update_stats(struct macb *bp) 1880static void gem_update_stats(struct macb *bp)
1859{ 1881{
1860 int i; 1882 int i;
@@ -2131,7 +2153,7 @@ static const struct net_device_ops macb_netdev_ops = {
2131 .ndo_get_stats = macb_get_stats, 2153 .ndo_get_stats = macb_get_stats,
2132 .ndo_do_ioctl = macb_ioctl, 2154 .ndo_do_ioctl = macb_ioctl,
2133 .ndo_validate_addr = eth_validate_addr, 2155 .ndo_validate_addr = eth_validate_addr,
2134 .ndo_change_mtu = eth_change_mtu, 2156 .ndo_change_mtu = macb_change_mtu,
2135 .ndo_set_mac_address = eth_mac_addr, 2157 .ndo_set_mac_address = eth_mac_addr,
2136#ifdef CONFIG_NET_POLL_CONTROLLER 2158#ifdef CONFIG_NET_POLL_CONTROLLER
2137 .ndo_poll_controller = macb_poll_controller, 2159 .ndo_poll_controller = macb_poll_controller,