From patchwork Sun Mar 23 20:46:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 26912 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2715220490 for ; Sun, 23 Mar 2014 20:47:08 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id hw13sf10659221qab.5 for ; Sun, 23 Mar 2014 13:47:07 -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=4auVRq+SlIw3pqcYdJKavq1XMO5mN/eclCSAHDgdBy8=; b=M6m65ZYDBVYJEtqmFLWNVU7aSZU/5M+yeh/MHY84MmB7tCsEf2B1h5rm/fxFOLyNQR rtDb8kxA2xGcJcFWxL2/eNQfpI8MpJ5RBhMq78ElkVH8NjAzLs+dpAvEuqMwWfRy2hJ2 UQSZX1S0A19bMBbqz3a+tgTpy8jxKURotm7HtUWSG58BCveMJ0InPXmppXwyjKh49cRs FDRSxb7+PwKvsRYAh9/Smdi7nwT/Rt9BRYXdyQd83KjrooQj0TNW9zPPe/ubw77kDB0U 1gLFwaVs3b0v4i18IYJAdn9W3ng4/aZllEsubtnuRMoseSzG+TNClmv7asq78X/QBtT1 2OXw== X-Gm-Message-State: ALoCoQnVp7UjpvHDAsGTB5FLJNE5etf8cAFMR7azOFB+TAHhwNUk7tbZ811KK290WFFzp6uw+Fq3 X-Received: by 10.58.198.3 with SMTP id iy3mr15554713vec.39.1395607627929; Sun, 23 Mar 2014 13:47:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.72 with SMTP id l66ls902694qge.16.gmail; Sun, 23 Mar 2014 13:47:07 -0700 (PDT) X-Received: by 10.52.18.70 with SMTP id u6mr40913693vdd.11.1395607627783; Sun, 23 Mar 2014 13:47:07 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id tm8si2663401vdc.44.2014.03.23.13.47.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 23 Mar 2014 13:47:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 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.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so4900125vcb.11 for ; Sun, 23 Mar 2014 13:47:07 -0700 (PDT) X-Received: by 10.58.207.74 with SMTP id lu10mr46733204vec.15.1395607627676; Sun, 23 Mar 2014 13:47:07 -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 i9csp175564vck; Sun, 23 Mar 2014 13:47:07 -0700 (PDT) X-Received: by 10.68.71.131 with SMTP id v3mr67703451pbu.68.1395607626692; Sun, 23 Mar 2014 13:47:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iu9si7827873pac.289.2014.03.23.13.47.06; Sun, 23 Mar 2014 13:47:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 S1751534AbaCWUrB (ORCPT + 4 others); Sun, 23 Mar 2014 16:47:01 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:39493 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbaCWUq5 (ORCPT ); Sun, 23 Mar 2014 16:46:57 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2W00GWJPQ8KC00@mailout2.samsung.com>; Mon, 24 Mar 2014 05:46:56 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.49]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id B3.20.09028.0484F235; Mon, 24 Mar 2014 05:46:56 +0900 (KST) X-AuditID: cbfee68e-b7f566d000002344-c5-532f4840bfa9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 63.D6.29263.0484F235; Mon, 24 Mar 2014 05:46:56 +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 <0N2W009EYPOUPX50@mmp1.samsung.com>; Mon, 24 Mar 2014 05:46:56 +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 V13 5/7] net: sxgbe: add Checksum offload support for Samsung sxgbe Date: Sun, 23 Mar 2014 13:46:38 -0700 Message-id: <00a401cf46d9$05f518b0$11df4a10$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac9G2Mo9avuJfoo+TBKgoBa2eV80gw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsVy+t8zQ10HD/1gg/XvRS3mnG9hsZh/5Byr xdF/Cxkt5h/dwWQx4/w+J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SKTUBNonnmZTYQW0QgWmLH kYlgRcwC1xgltv1+zAKSEBYIlWi5dBysiEVAVWLyl03sIDavgKXEyo4GRghbUOLH5Htg9cwC WhLrdx5ngrDlJTaveQt1koLEjrOvGSGW6UlsfTefGaJGXGLSg4fsExgFZiEZNQvJqFlIRs1C 0rKAkWUVo2hqQXJBcVJ6rqFecWJucWleul5yfu4mRnCMP5PawbiyweIQowAHoxIP74lPusFC rIllxZW5hxglOJiVRHgjXfWDhXhTEiurUovy44tKc1KLDzEmA306kVlKNDkfmH7ySuINjU3M jCyNzCyMTMzNSRNWEuc90GodKCSQnliSmp2aWpBaBLOFiYNTqoGRyUaP68DZqu9uqea2ydUJ C+2L7h4xK7rE0v3tbqtuz5M3zDMTlwo+aeT3CnUWad/+wP3S5Y9vj18JadzJ9mPiCvZnexOC GLR9vF3CDQVa2b9w3WwQqrxx4Yj5rMXs+iJvPuZE2Bl1a7xe5B22w0T4aeLLZZVvFq+5O9tr x59UyT1pvlOf5/krsRRnJBpqMRcVJwIAOgDBMzUDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@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.180 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 | 2 +- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 46 ++++++++++++++++----- 4 files changed, 61 insertions(+), 12 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 6d44b9f..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; diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c index c44464d..e433969 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, 0); + 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, 0); + 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; } @@ -1748,15 +1766,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; @@ -2113,6 +2131,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;