aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
diff options
context:
space:
mode:
authorSrikanth Thokala <srikanth.thokala@xilinx.com>2015-05-05 05:25:57 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-05 19:33:58 -0400
commitf080a8c35d8932d72c08df1260bbea14b7db481e (patch)
tree498f620cdf988689587a202d24f6f65e7dc846e5 /drivers/net/ethernet/xilinx/xilinx_axienet_main.c
parent80c775accdf834567a8e163eee9a3531eeafea7d (diff)
net: axienet: Handle jumbo frames for lesser frame sizes
In the current implementation, jumbo frames are supported only for the frame sizes > 16K. This patch corrects this logic to handle jumbo frames for lesser frame sizes (< 16K) ensuring jumbo frame MTU is within the limit of max frame size configured in the h/w design. Signed-off-by: Srikanth Thokala <sthokal@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/xilinx/xilinx_axienet_main.c')
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index b83425393a24..b1081e1893b0 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -471,14 +471,16 @@ static void axienet_device_reset(struct net_device *ndev)
471 __axienet_device_reset(lp, &ndev->dev, XAXIDMA_RX_CR_OFFSET); 471 __axienet_device_reset(lp, &ndev->dev, XAXIDMA_RX_CR_OFFSET);
472 472
473 lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE; 473 lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE;
474 lp->options |= XAE_OPTION_VLAN;
474 lp->options &= (~XAE_OPTION_JUMBO); 475 lp->options &= (~XAE_OPTION_JUMBO);
475 476
476 if ((ndev->mtu > XAE_MTU) && 477 if ((ndev->mtu > XAE_MTU) &&
477 (ndev->mtu <= XAE_JUMBO_MTU) && 478 (ndev->mtu <= XAE_JUMBO_MTU)) {
478 (lp->jumbo_support)) { 479 lp->max_frm_size = ndev->mtu + VLAN_ETH_HLEN +
479 lp->max_frm_size = ndev->mtu + XAE_HDR_VLAN_SIZE + 480 XAE_TRL_SIZE;
480 XAE_TRL_SIZE; 481
481 lp->options |= XAE_OPTION_JUMBO; 482 if (lp->max_frm_size <= lp->rxmem)
483 lp->options |= XAE_OPTION_JUMBO;
482 } 484 }
483 485
484 if (axienet_dma_bd_init(ndev)) { 486 if (axienet_dma_bd_init(ndev)) {
@@ -1027,15 +1029,15 @@ static int axienet_change_mtu(struct net_device *ndev, int new_mtu)
1027 1029
1028 if (netif_running(ndev)) 1030 if (netif_running(ndev))
1029 return -EBUSY; 1031 return -EBUSY;
1030 if (lp->jumbo_support) { 1032
1031 if ((new_mtu > XAE_JUMBO_MTU) || (new_mtu < 64)) 1033 if ((new_mtu + VLAN_ETH_HLEN +
1032 return -EINVAL; 1034 XAE_TRL_SIZE) > lp->rxmem)
1033 ndev->mtu = new_mtu; 1035 return -EINVAL;
1034 } else { 1036
1035 if ((new_mtu > XAE_MTU) || (new_mtu < 64)) 1037 if ((new_mtu > XAE_JUMBO_MTU) || (new_mtu < 64))
1036 return -EINVAL; 1038 return -EINVAL;
1037 ndev->mtu = new_mtu; 1039
1038 } 1040 ndev->mtu = new_mtu;
1039 1041
1040 return 0; 1042 return 0;
1041} 1043}
@@ -1556,16 +1558,14 @@ static int axienet_of_probe(struct platform_device *op)
1556 } 1558 }
1557 } 1559 }
1558 /* For supporting jumbo frames, the Axi Ethernet hardware must have 1560 /* For supporting jumbo frames, the Axi Ethernet hardware must have
1559 * a larger Rx/Tx Memory. Typically, the size must be more than or 1561 * a larger Rx/Tx Memory. Typically, the size must be large so that
1560 * equal to 16384 bytes, so that we can enable jumbo option and start 1562 * we can enable jumbo option and start supporting jumbo frames.
1561 * supporting jumbo frames. Here we check for memory allocated for 1563 * Here we check for memory allocated for Rx/Tx in the hardware from
1562 * Rx/Tx in the hardware from the device-tree and accordingly set 1564 * the device-tree and accordingly set flags.
1563 * flags. */ 1565 */
1564 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,rxmem", NULL); 1566 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,rxmem", NULL);
1565 if (p) { 1567 if (p)
1566 if ((be32_to_cpup(p)) >= 0x4000) 1568 lp->rxmem = be32_to_cpup(p);
1567 lp->jumbo_support = 1;
1568 }
1569 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL); 1569 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL);
1570 if (p) 1570 if (p)
1571 lp->phy_type = be32_to_cpup(p); 1571 lp->phy_type = be32_to_cpup(p);