From patchwork Fri Mar 21 18:06:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 26863 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A1147203AB for ; Fri, 21 Mar 2014 18:07:43 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf6335047vcb.10 for ; Fri, 21 Mar 2014 11:07:43 -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=HA5DcpPwujWDFM1qTH8FoIe9ZfIHub2eRCp/6yQz/ps=; b=MKOhnIXrJDveTVvlCFl392EpFqGu6T8lE9VJqyO0kNOmmCwvR+EAaSXfiv+7SuvZaj LN6rkYE0Aj4WJpJPcLd6Qek2D13c/t+pzEGYqDoDc6LZ8Jz2176BKaCnEM8eus6jY4Uc cSN0aQuE4z92Th7HlqIJkhJ0RwGW95Gjk/OuZRaX+asYCv1+EABsviZSWO21fDumsv/+ E7VKAYFhl/SvTUcId0W914LLl0xuvCgJFor+Fij122aH/2lhW0NpQfJXySfmp1il1OUM tBnacZhcvEBge5rqw0hCpg2JGD8sTtcCk9Lk3XikTbedje5AUVbrGHnfYLC0YxQnPUnU r0XA== X-Gm-Message-State: ALoCoQlKDeKhguf4BvjzRZ2UJ6fezdLFuGvmeTtLg7u7Qk8ghKH1iRvgFw47MeeIow5cMV1/1iIL X-Received: by 10.236.4.101 with SMTP id 65mr589266yhi.57.1395425263385; Fri, 21 Mar 2014 11:07:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.101 with SMTP id a92ls689750qga.66.gmail; Fri, 21 Mar 2014 11:07:43 -0700 (PDT) X-Received: by 10.52.18.70 with SMTP id u6mr32808592vdd.11.1395425263309; Fri, 21 Mar 2014 11:07:43 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id vv9si1269576vcb.199.2014.03.21.11.07.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 11:07:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so2885977veb.22 for ; Fri, 21 Mar 2014 11:07:43 -0700 (PDT) X-Received: by 10.52.30.230 with SMTP id v6mr1935977vdh.6.1395425263202; Fri, 21 Mar 2014 11:07:43 -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 i9csp49480vck; Fri, 21 Mar 2014 11:07:39 -0700 (PDT) X-Received: by 10.68.215.68 with SMTP id og4mr55237980pbc.112.1395425257584; Fri, 21 Mar 2014 11:07:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si4137486pba.173.2014.03.21.11.07.37; Fri, 21 Mar 2014 11:07:37 -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 S1751062AbaCUSH3 (ORCPT + 8 others); Fri, 21 Mar 2014 14:07:29 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:58592 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbaCUSHL (ORCPT ); Fri, 21 Mar 2014 14:07:11 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2S003YFSZQ9490@mailout1.samsung.com>; Sat, 22 Mar 2014 03:07:02 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.47]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 16.1C.10092.6CF7C235; Sat, 22 Mar 2014 03:07:02 +0900 (KST) X-AuditID: cbfee68f-b7f156d00000276c-5f-532c7fc6bfd8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 72.98.29263.6CF7C235; Sat, 22 Mar 2014 03:07:02 +0900 (KST) Received: from VISITOR1LAB ([105.128.34.229]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2S0004OSZCIZA0@mmp2.samsung.com>; Sat, 22 Mar 2014 03:07:02 +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 V10 5/7] net: sxgbe: add Checksum offload support for Samsung sxgbe Date: Fri, 21 Mar 2014 11:06:55 -0700 Message-id: <005f01cf4530$5b34afc0$119e0f40$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac9FL9k+gBJcuwk7TgWtpMV0muwu8A== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsVy+t8zfd1j9TrBBq23jS3mnG9hsZh/5Byr xdF/Cxkt5h/dwWQx4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zPyNIFZuAmkTzzMtsILaI QLTEjiMTwTqYBa4xSmz7/ZgFJCEsECpxa1MnM4jNIqAq0fRzCTuIzStgKTHlym8WCFtQ4sfk e2A2s4CWxPqdx5kgbHmJzWveMkOcpCCx4+xrRohlehJ7vz+AqhGXmPTgIfsERoFZSEbNQjJq FpJRs5C0LGBkWcUomlqQXFCclJ5rqFecmFtcmpeul5yfu4kRHOPPpHYwrmywOMQowMGoxMNb wakdLMSaWFZcmXuIUYKDWUmEtzlWJ1iINyWxsiq1KD++qDQntfgQYzLQpxOZpUST84HpJ68k 3tDYxMzI0sjMwsjE3Jw0YSVx3gOt1oFCAumJJanZqakFqUUwW5g4OKUaGGXk64xNO64FJk2L vcSZqad7bkbsx3ADzUMns9sm93sES7v9+Mox5ftDfoYH332f3uBO4jj++8iVjTeKL+b8X2zP /7mzp+dsxnqx3wue1Fn8MJrdGZyTzXSDc2PPMsOp/6/0lLfGcoTXuHMqiD6Snmxf/mH2yaT6 sxJ98tmvD+bOUT2wifNdhBJLcUaioRZzUXEiAPEfDe41AwAA 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.128.177 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 5f1d02c..f06d439 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 bf93b16..5885fd6 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c @@ -217,6 +217,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, @@ -233,6 +251,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 547edf3..3c0b5a8 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 fb22c7e..e3f16c3 100644 --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c @@ -1252,6 +1252,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); @@ -1332,7 +1333,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); } } @@ -1350,7 +1351,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(); @@ -1471,6 +1472,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; @@ -1487,7 +1490,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]; @@ -1501,7 +1515,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; } @@ -1747,15 +1765,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; @@ -2118,6 +2136,12 @@ struct sxgbe_priv_data *sxgbe_dvr_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;