From patchwork Wed Feb 12 15:55:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 319667 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5A6FE2C00A5 for ; Thu, 13 Feb 2014 03:06:54 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753039AbaBLP44 (ORCPT ); Wed, 12 Feb 2014 10:56:56 -0500 Received: from mail-ea0-f170.google.com ([209.85.215.170]:50784 "EHLO mail-ea0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753024AbaBLP4y (ORCPT ); Wed, 12 Feb 2014 10:56:54 -0500 Received: by mail-ea0-f170.google.com with SMTP id g15so2760736eak.29 for ; Wed, 12 Feb 2014 07:56:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:content-type; bh=+DSSl+qZ02/XdFsaX5RZPvSsWHHhruooO0rJ/ouTBwA=; b=QMpEuuCCV4yHswxbKse3Zbm8oU4N7fA1/A6WRwsu/wNvDEC4CJ1IXukw64/cbOFQKF pPsvbRC3yK14FqC3VTh4YWMD7aqlzCzHfgUooF/lU24I+td1yUqtYLRvvn2U7n9Cg1Pb 29ZLcPGPj4hYRwf8cnj89QQNTTBjmJC1GE6iauDLOK5NIkXL7J7MJDWfs9oDgIc20vYR sj6OYC9J5l0urUMHFlRqeAJbZZw7mNDKfj50VFUpvOm/IKBPlVuEYDY2xifDpwnn3T72 f5WO/2uN9plgZNJLRkHFwPpQdluapQ7tvKw9UMXM6Kd1bf/HjjcB1RhKlv8eJZEtc1Lo FJvQ== X-Gm-Message-State: ALoCoQmebSVvbBAJcMsrMJXlJGV4nA/Rq1r11yDCjIY50NCOemLEK/alSMrVQPKH50YLOiaVDhXz X-Received: by 10.14.104.6 with SMTP id h6mr4842645eeg.29.1392220612612; Wed, 12 Feb 2014 07:56:52 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id 46sm82089734ees.4.2014.02.12.07.56.49 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 12 Feb 2014 07:56:51 -0800 (PST) From: Michal Simek To: netdev@vger.kernel.org Cc: Srikanth Thokala , Srikanth Thokala , Michal Simek , Anirudha Sarangi , John Linn , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/14] net: axienet: Handle jumbo frames for lesser frame sizes Date: Wed, 12 Feb 2014 16:55:40 +0100 Message-Id: <7732b1e09951dca7b6786fa7ba3579c378f4f4c1.1392220536.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Srikanth Thokala 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 Signed-off-by: Michal Simek --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 9 ++--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 46 +++++++++++------------ 2 files changed, 27 insertions(+), 28 deletions(-) -- 1.8.2.3 diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index 44b8d2b..b3c50bd 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -11,16 +11,16 @@ #include #include #include +#include /* Packet size info */ #define XAE_HDR_SIZE 14 /* Size of Ethernet header */ -#define XAE_HDR_VLAN_SIZE 18 /* Size of an Ethernet hdr + VLAN */ #define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */ #define XAE_MTU 1500 /* Max MTU of an Ethernet frame */ #define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */ #define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE) -#define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + XAE_HDR_VLAN_SIZE + XAE_TRL_SIZE) +#define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + VLAN_ETH_HLEN + XAE_TRL_SIZE) #define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE) /* Configuration options */ @@ -408,8 +408,7 @@ struct axidma_bd { * Txed/Rxed in the existing hardware. If jumbo option is * supported, the maximum frame size would be 9k. Else it is * 1522 bytes (assuming support for basic VLAN) - * @jumbo_support: Stores hardware configuration for jumbo support. If hardware - * can handle jumbo packets, this entry will be 1, else 0. + * @rxmem: Stores rx memory size for jumbo frame handling. */ struct axienet_local { struct net_device *ndev; @@ -448,7 +447,7 @@ struct axienet_local { u32 rx_bd_ci; u32 max_frm_size; - u32 jumbo_support; + u32 rxmem; int csum_offload_on_tx_path; 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 3c24f97..9595403 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) __axienet_device_reset(lp, &ndev->dev, XAXIDMA_RX_CR_OFFSET); lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE; + lp->options |= XAE_OPTION_VLAN; lp->options &= (~XAE_OPTION_JUMBO); if ((ndev->mtu > XAE_MTU) && - (ndev->mtu <= XAE_JUMBO_MTU) && - (lp->jumbo_support)) { - lp->max_frm_size = ndev->mtu + XAE_HDR_VLAN_SIZE + - XAE_TRL_SIZE; - lp->options |= XAE_OPTION_JUMBO; + (ndev->mtu <= XAE_JUMBO_MTU)) { + lp->max_frm_size = ndev->mtu + VLAN_ETH_HLEN + + XAE_TRL_SIZE; + + if (lp->max_frm_size <= lp->rxmem) + lp->options |= XAE_OPTION_JUMBO; } if (axienet_dma_bd_init(ndev)) { @@ -1027,15 +1029,15 @@ static int axienet_change_mtu(struct net_device *ndev, int new_mtu) if (netif_running(ndev)) return -EBUSY; - if (lp->jumbo_support) { - if ((new_mtu > XAE_JUMBO_MTU) || (new_mtu < 64)) - return -EINVAL; - ndev->mtu = new_mtu; - } else { - if ((new_mtu > XAE_MTU) || (new_mtu < 64)) - return -EINVAL; - ndev->mtu = new_mtu; - } + + if ((new_mtu + VLAN_ETH_HLEN + + XAE_TRL_SIZE) > lp->rxmem) + return -EINVAL; + + if ((new_mtu > XAE_JUMBO_MTU) || (new_mtu < 64)) + return -EINVAL; + + ndev->mtu = new_mtu; return 0; } @@ -1556,16 +1558,14 @@ static int axienet_of_probe(struct platform_device *op) } } /* For supporting jumbo frames, the Axi Ethernet hardware must have - * a larger Rx/Tx Memory. Typically, the size must be more than or - * equal to 16384 bytes, so that we can enable jumbo option and start - * supporting jumbo frames. Here we check for memory allocated for - * Rx/Tx in the hardware from the device-tree and accordingly set - * flags. */ + * a larger Rx/Tx Memory. Typically, the size must be large so that + * we can enable jumbo option and start supporting jumbo frames. + * Here we check for memory allocated for Rx/Tx in the hardware from + * the device-tree and accordingly set flags. + */ p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,rxmem", NULL); - if (p) { - if ((be32_to_cpup(p)) >= 0x4000) - lp->jumbo_support = 1; - } + if (p) + lp->rxmem = be32_to_cpup(p); p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,temac-type", NULL); if (p)