aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet.h9
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c46
2 files changed, 27 insertions, 28 deletions
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index 4c9b4fa1d3c1..4e309440964a 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -11,16 +11,16 @@
11#include <linux/netdevice.h> 11#include <linux/netdevice.h>
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/if_vlan.h>
14 15
15/* Packet size info */ 16/* Packet size info */
16#define XAE_HDR_SIZE 14 /* Size of Ethernet header */ 17#define XAE_HDR_SIZE 14 /* Size of Ethernet header */
17#define XAE_HDR_VLAN_SIZE 18 /* Size of an Ethernet hdr + VLAN */
18#define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */ 18#define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */
19#define XAE_MTU 1500 /* Max MTU of an Ethernet frame */ 19#define XAE_MTU 1500 /* Max MTU of an Ethernet frame */
20#define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */ 20#define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */
21 21
22#define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE) 22#define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
23#define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + XAE_HDR_VLAN_SIZE + XAE_TRL_SIZE) 23#define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + VLAN_ETH_HLEN + XAE_TRL_SIZE)
24#define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE) 24#define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
25 25
26/* Configuration options */ 26/* Configuration options */
@@ -407,8 +407,7 @@ struct axidma_bd {
407 * Txed/Rxed in the existing hardware. If jumbo option is 407 * Txed/Rxed in the existing hardware. If jumbo option is
408 * supported, the maximum frame size would be 9k. Else it is 408 * supported, the maximum frame size would be 9k. Else it is
409 * 1522 bytes (assuming support for basic VLAN) 409 * 1522 bytes (assuming support for basic VLAN)
410 * @jumbo_support: Stores hardware configuration for jumbo support. If hardware 410 * @rxmem: Stores rx memory size for jumbo frame handling.
411 * can handle jumbo packets, this entry will be 1, else 0.
412 */ 411 */
413struct axienet_local { 412struct axienet_local {
414 struct net_device *ndev; 413 struct net_device *ndev;
@@ -446,7 +445,7 @@ struct axienet_local {
446 u32 rx_bd_ci; 445 u32 rx_bd_ci;
447 446
448 u32 max_frm_size; 447 u32 max_frm_size;
449 u32 jumbo_support; 448 u32 rxmem;
450 449
451 int csum_offload_on_tx_path; 450 int csum_offload_on_tx_path;
452 int csum_offload_on_rx_path; 451 int csum_offload_on_rx_path;
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);