From patchwork Sat Mar 22 06:23:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 26885 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f199.google.com (mail-yk0-f199.google.com [209.85.160.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77425203AB for ; Sat, 22 Mar 2014 06:24:19 +0000 (UTC) Received: by mail-yk0-f199.google.com with SMTP id 200sf17427665ykr.2 for ; Fri, 21 Mar 2014 23:24:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:thread-index:dlp-filter:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding:content-language; bh=LyJQtKgybKaPpDdWGRwMJMxg4oGKFgtCfitWL5INxto=; b=DsdU+AdN7RIfTNktrETt4SXor/CNOssiJGbWvj4p3LJvYZOWDVsbZJ0fAAwXV8whuE TZaxZwKTEm/8Sozm9JEtgNJJiwGM4v/BzTMtKEJOIUqGhZQezqYTuUtpAqAmUSg7S1Wu L0pJ9zZIpXjYMLbdosLB/EmALb11Ux3biN+3im9FGNhuTwCAv/lAk1gQywUWmhKYeJu8 JBT8UmBdUbqxjKCZcfBNM/2SiTuw1PK3jD3k+SD6iYC9fBdQKfcGjvFzzgXMpkT2DK/1 P7DIz6lhGI36p1fOvGt/4s4GCuTt3zi5LZ4g22BDUkUCFAHDKFWPglt+lqtvjMIouNgw 2JnA== X-Gm-Message-State: ALoCoQktBudF+bHWGr3Z7uGw338QuMxdQLWiUkzkGBSOchDkLalXfIWyXzWHBQ70q/sOdGPcislW X-Received: by 10.236.114.201 with SMTP id c49mr14493429yhh.7.1395469459185; Fri, 21 Mar 2014 23:24:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.38 with SMTP id 35ls813675qgw.77.gmail; Fri, 21 Mar 2014 23:24:19 -0700 (PDT) X-Received: by 10.58.34.101 with SMTP id y5mr40650043vei.8.1395469459074; Fri, 21 Mar 2014 23:24:19 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id vd8si1707029vdc.70.2014.03.21.23.24.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 23:24:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lh14so3624562vcb.34 for ; Fri, 21 Mar 2014 23:24:19 -0700 (PDT) X-Received: by 10.58.185.145 with SMTP id fc17mr41523189vec.14.1395469458948; Fri, 21 Mar 2014 23:24:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp80724vck; Fri, 21 Mar 2014 23:24:18 -0700 (PDT) X-Received: by 10.68.34.197 with SMTP id b5mr58218396pbj.16.1395469457226; Fri, 21 Mar 2014 23:24:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dj5si5045827pad.410.2014.03.21.23.24.16; Fri, 21 Mar 2014 23:24:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751199AbaCVGYL (ORCPT + 8 others); Sat, 22 Mar 2014 02:24:11 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:26723 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751294AbaCVGXx (ORCPT ); Sat, 22 Mar 2014 02:23:53 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2T00JXSR3SRC90@mailout3.samsung.com>; Sat, 22 Mar 2014 15:23:52 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.47]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id B3.13.12635.87C2D235; Sat, 22 Mar 2014 15:23:52 +0900 (KST) X-AuditID: cbfee68d-b7fcd6d00000315b-3e-532d2c780e8a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D1.60.29263.87C2D235; Sat, 22 Mar 2014 15:23:52 +0900 (KST) Received: from VISITOR1LAB ([105.128.34.229]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2T00LCIR3N9330@mmp1.samsung.com>; Sat, 22 Mar 2014 15:23:52 +0900 (KST) From: Byungho An To: netdev@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Cc: 'David Miller' , 'GIRISH K S' , 'SIVAREDDY KALLAM' , 'Vipul Chandrakant' , 'Ilho Lee' Subject: [PATCH V11 5/7] net: sxgbe: add Checksum offload support for Samsung sxgbe Date: Fri, 21 Mar 2014 23:23:48 -0700 Message-id: <007c01cf4597$4a3d8e00$deb8aa00$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac9FluUHIiXzCIswQUCNu5KAGOB+lQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsVy+t8zfd0KHd1gg40zjC3mnG9hsZh/5Byr xdF/Cxkt5h/dw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iasfLLoYuYDsv4wSC86uZgJJsAmoSTTPvAxWJCIQLbHj yEQ2kCJmgWuMEtt+P2YBSQgLhErsv98OVsQioCrx/v1FMJtXwFJiV/dBJghbUOLH5Htg9cwC WhLrdx5ngrDlJTavecsMcZGCxI6zrxkhlulJLOx8BFUvLjHpwUP2CYwCs5CMmoVk1Cwko2Yh aVnAyLKKUTS1ILmgOCk911CvODG3uDQvXS85P3cTIzjGn0ntYFzZYHGIUYCDUYmH94a8brAQ a2JZcWXuIUYJDmYlEd4TCkAh3pTEyqrUovz4otKc1OJDjMlAn05klhJNzgemn7ySeENjEzMj SyMzCyMTc3PShJXEeQ+0WgcKCaQnlqRmp6YWpBbBbGHi4JRqYOy512///VONQOcJSWu+Kyy8 v4/rLTdQ51JNvOfX+yXgtuZJVdOKn4dLZj3yvRoZufHerzOORre6WSUa1AzNbv/nmzR/yinW kLNuCROvuP1tfr8j7XZTWWLGGonWBebJn2fqmc4L6K998C+usi7iwJGoR847/34/+fc827W8 TE1noagvc77JBCqxFGckGmoxFxUnAgAsTXVKNQMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bh74.an@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Content-language: en-us From: Vipul Pandya This patch adds TX and RX checksum offload support. Signed-off-by: Vipul Pandya Neatening-by: Joe Perches Signed-off-by: Byungho An --- drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h | 5 +++ drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c | 20 +++++++++ drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h | 6 +-- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 46 ++++++++++++++++----- 4 files changed, 63 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h index 58e1ace..36a72a3 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h @@ -337,6 +337,10 @@ struct sxgbe_core_ops { void (*set_eee_timer)(void __iomem *ioaddr, const int ls, const int tw); void (*set_eee_pls)(void __iomem *ioaddr, const int link); + + /* Enable disable checksum offload operations */ + void (*enable_rx_csum)(void __iomem *ioaddr); + void (*disable_rx_csum)(void __iomem *ioaddr); }; const struct sxgbe_core_ops *sxgbe_get_core_ops(void); @@ -449,6 +453,7 @@ struct sxgbe_priv_data { struct sxgbe_ops *hw; /* sxgbe specific ops */ int no_csum_insertion; int irq; + int rxcsum_insertion; spinlock_t stats_lock; /* lock for tx/rx statatics */ struct phy_device *phydev; diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c index 0164790..66d4a74 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c @@ -218,6 +218,24 @@ static void sxgbe_set_eee_timer(void __iomem *ioaddr, writel(value, ioaddr + SXGBE_CORE_LPI_TIMER_CTRL); } +static void sxgbe_enable_rx_csum(void __iomem *ioaddr) +{ + u32 ctrl; + + ctrl = readl(ioaddr + SXGBE_CORE_RX_CONFIG_REG); + ctrl |= SXGBE_RX_CSUMOFFLOAD_ENABLE; + writel(ctrl, ioaddr + SXGBE_CORE_RX_CONFIG_REG); +} + +static void sxgbe_disable_rx_csum(void __iomem *ioaddr) +{ + u32 ctrl; + + ctrl = readl(ioaddr + SXGBE_CORE_RX_CONFIG_REG); + ctrl &= ~SXGBE_RX_CSUMOFFLOAD_ENABLE; + writel(ctrl, ioaddr + SXGBE_CORE_RX_CONFIG_REG); +} + const struct sxgbe_core_ops core_ops = { .core_init = sxgbe_core_init, .dump_regs = sxgbe_core_dump_regs, @@ -234,6 +252,8 @@ const struct sxgbe_core_ops core_ops = { .reset_eee_mode = sxgbe_reset_eee_mode, .set_eee_timer = sxgbe_set_eee_timer, .set_eee_pls = sxgbe_set_eee_pls, + .enable_rx_csum = sxgbe_enable_rx_csum, + .disable_rx_csum = sxgbe_disable_rx_csum, }; const struct sxgbe_core_ops *sxgbe_get_core_ops(void) diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h index e553687..838cb9f 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h @@ -113,7 +113,7 @@ struct sxgbe_rx_norm_desc { /* WB RDES3 */ u32 pkt_len:14; u32 rdes3_reserved:1; - u32 err_summary:15; + u32 err_summary:1; u32 err_l2_type:4; u32 layer34_pkt_type:4; u32 no_coagulation_pkt:1; @@ -273,8 +273,8 @@ struct sxgbe_desc_ops { int (*get_rx_ld_status)(struct sxgbe_rx_norm_desc *p); /* Return the reception status looking at the RDES1 */ - void (*rx_wbstatus)(struct sxgbe_rx_norm_desc *p, - struct sxgbe_extra_stats *x); + int (*rx_wbstatus)(struct sxgbe_rx_norm_desc *p, + struct sxgbe_extra_stats *x, int *checksum); /* Get own bit */ int (*get_rx_ctxt_owner)(struct sxgbe_rx_ctxt_desc *p); diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c index b4b7689..1a8cee4 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c @@ -1255,6 +1255,7 @@ void sxgbe_tso_prepare(struct sxgbe_priv_data *priv, static netdev_tx_t sxgbe_xmit(struct sk_buff *skb, struct net_device *dev) { unsigned int entry, frag_num; + int cksum_flag = 0; struct netdev_queue *dev_txq; unsigned txq_index = skb_get_queue_mapping(skb); struct sxgbe_priv_data *priv = netdev_priv(dev); @@ -1335,7 +1336,7 @@ static netdev_tx_t sxgbe_xmit(struct sk_buff *skb, struct net_device *dev) __func__); priv->hw->desc->prepare_tx_desc(tx_desc, 1, no_pagedlen, - no_pagedlen); + no_pagedlen, cksum_flag); } } @@ -1353,7 +1354,7 @@ static netdev_tx_t sxgbe_xmit(struct sk_buff *skb, struct net_device *dev) /* prepare the descriptor */ priv->hw->desc->prepare_tx_desc(tx_desc, 0, len, - len); + len, cksum_flag); /* memory barrier to flush descriptor */ wmb(); @@ -1474,6 +1475,8 @@ static int sxgbe_rx(struct sxgbe_priv_data *priv, int limit) unsigned int entry = priv->rxq[qnum]->cur_rx; unsigned int next_entry = 0; unsigned int count = 0; + int checksum; + int status; while (count < limit) { struct sxgbe_rx_norm_desc *p; @@ -1490,7 +1493,18 @@ static int sxgbe_rx(struct sxgbe_priv_data *priv, int limit) next_entry = (++priv->rxq[qnum]->cur_rx) % rxsize; prefetch(priv->rxq[qnum]->dma_rx + next_entry); - /*TO DO read the status of the incoming frame */ + /* Read the status of the incoming frame and also get checksum + * value based on whether it is enabled in SXGBE hardware or + * not. + */ + status = priv->hw->desc->rx_wbstatus(p, &priv->xstats, + &checksum); + if (unlikely(status < 0)) { + entry = next_entry; + continue; + } + if (unlikely(!priv->rxcsum_insertion)) + checksum = CHECKSUM_NONE; skb = priv->rxq[qnum]->rx_skbuff[entry]; @@ -1504,7 +1518,11 @@ static int sxgbe_rx(struct sxgbe_priv_data *priv, int limit) skb_put(skb, frame_len); - netif_receive_skb(skb); + skb->ip_summed = checksum; + if (checksum == CHECKSUM_NONE) + netif_receive_skb(skb); + else + napi_gro_receive(&priv->napi, skb); entry = next_entry; } @@ -1751,15 +1769,15 @@ static int sxgbe_set_features(struct net_device *dev, { struct sxgbe_priv_data *priv = netdev_priv(dev); netdev_features_t changed = dev->features ^ features; - u32 ctrl; if (changed & NETIF_F_RXCSUM) { - ctrl = readl(priv->ioaddr + SXGBE_CORE_RX_CONFIG_REG); - if (features & NETIF_F_RXCSUM) - ctrl |= SXGBE_RX_CSUMOFFLOAD_ENABLE; - else - ctrl &= ~SXGBE_RX_CSUMOFFLOAD_ENABLE; - writel(ctrl, priv->ioaddr + SXGBE_CORE_RX_CONFIG_REG); + if (features & NETIF_F_RXCSUM) { + priv->hw->mac->enable_rx_csum(priv->ioaddr); + priv->rxcsum_insertion = true; + } else { + priv->hw->mac->disable_rx_csum(priv->ioaddr); + priv->rxcsum_insertion = false; + } } return 0; @@ -2119,6 +2137,12 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device, } } + /* Enable Rx checksum offload */ + if (priv->hw_cap.rx_csum_offload) { + priv->hw->mac->enable_rx_csum(priv->ioaddr); + priv->rxcsum_insertion = true; + } + /* Rx Watchdog is available, enable depend on platform data */ if (!priv->plat->riwt_off) { priv->use_riwt = 1;