From patchwork Thu Mar 20 22:23:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 26776 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5DE17202E0 for ; Thu, 20 Mar 2014 22:25:49 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id to1sf5296550ieb.5 for ; Thu, 20 Mar 2014 15:25:48 -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=gBEm8+8lNvnp3SK934NsG0QDdf9Ok77eDOtlm1FBXMw=; b=CrkynP7t0bfAjmQEw/9tKqYVU7mYLnNPU4c0uCxhSzpG6TM3epV2lC/CuJ2jftlUE5 r5A2cBE88LaESldqZCzaSGr9cJ28pnohlSY1Gf72OL5e9RY+IaMEApSAfOqmdXrQbHpO miP5yT0dUyd/foJTB95wv6PZedExEw5j/A7/D9cgbhPo3qOvK3Flsa2BXqM+OJkfkNyq 2VOXNVSZuhaebGWahNYbQwo7CdEe8ioRp63N88JGSFow47j2e21LXzlJTpjFRmpn/NV+ YIk4luYR9XT1O0hAQAJX43LFFhOIS9R6DZSJnYlhyDtF82emwQqejOlwIZWR6lnn2DSJ +FVg== X-Gm-Message-State: ALoCoQlfErOURJAaNCyMhv0WLrkl+fxGY/vxSTABoBRqwq4LDU50TUhHXw5dB6M4EEEFU3AHx9FD X-Received: by 10.50.73.198 with SMTP id n6mr10276423igv.0.1395354348855; Thu, 20 Mar 2014 15:25:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.14 with SMTP id 14ls417526qgs.58.gmail; Thu, 20 Mar 2014 15:25:48 -0700 (PDT) X-Received: by 10.52.126.107 with SMTP id mx11mr4410844vdb.41.1395354348731; Thu, 20 Mar 2014 15:25:48 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id ys8si720001veb.160.2014.03.20.15.25.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 15:25:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 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.174; Received: by mail-ve0-f174.google.com with SMTP id oz11so1679098veb.5 for ; Thu, 20 Mar 2014 15:25:48 -0700 (PDT) X-Received: by 10.52.65.165 with SMTP id y5mr1721421vds.51.1395354348621; Thu, 20 Mar 2014 15:25:48 -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 i9csp423135vck; Thu, 20 Mar 2014 15:25:48 -0700 (PDT) X-Received: by 10.68.143.231 with SMTP id sh7mr50254146pbb.7.1395354347706; Thu, 20 Mar 2014 15:25:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si2299595pbn.304.2014.03.20.15.25.47; Thu, 20 Mar 2014 15:25:47 -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 S1760090AbaCTWY6 (ORCPT + 4 others); Thu, 20 Mar 2014 18:24:58 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:19118 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759898AbaCTWX4 (ORCPT ); Thu, 20 Mar 2014 18:23:56 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2R007YHA7UN650@mailout2.samsung.com>; Fri, 21 Mar 2014 07:23:54 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.50]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id BA.95.12635.A7A6B235; Fri, 21 Mar 2014 07:23:54 +0900 (KST) X-AuditID: cbfee68d-b7fcd6d00000315b-c7-532b6a7a5bf9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 65.D8.29263.A7A6B235; Fri, 21 Mar 2014 07:23:54 +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 <0N2R0047WA7H8B90@mmp1.samsung.com>; Fri, 21 Mar 2014 07:23:54 +0900 (KST) From: Byungho An To: netdev@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Cc: 'David Miller' , ks.giri@samsung.com, siva.kallam@samsung.com, vipul.pandya@samsung.com, ilho215.lee@samsung.com Subject: [PATCH V9 5/7] net: sxgbe: add Checksum offload support for Samsung sxgbe Date: Thu, 20 Mar 2014 15:23:51 -0700 Message-id: <000601cf448b$13191eb0$394b5c10$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac9EiqHQWtIWS6xAS5CT7ODo0upusg== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsVy+t8zI92qLO1gg+8XlCzmnG9hsZh/5Byr xdF/Cxkt5h/dwWQx4/w+JotjC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B2X8ZJe73PWYESbAJqEk0z7wMViQiEC2x 48hENpAiZoFuRolPK/aDJYQFQiR2P+4Bs1kEVCX6b21n72Lk4OAVsJRoPK8DEuYVEJT4Mfke C4jNLKAlsX7ncSYIW15i85q3zBAHKUjsOPuaEWKXnsShJZsZIWrEJSY9eMg+gVFgFpJRs5CM moVk1CwkLQsYWVYxiqYWJBcUJ6XnGuoVJ+YWl+al6yXn525iBEf4M6kdjCsbLA4xCnAwKvHw VnBqBwuxJpYVV+YeYpTgYFYS4T0fCxTiTUmsrEotyo8vKs1JLT7EmAz06ERmKdHkfGDyySuJ NzQ2MTOyNDKzMDIxNydNWEmc90CrdaCQQHpiSWp2ampBahHMFiYOTqkGxrQVOVkB09bMtFo9 x2Rtn/GTbVvFPV56CC7aZiZXqKumubd325WIXwlb1mZYMD/Mc5Z7GrTgosKu1I2KLFmTDjVs n3BBJkYg+2rBxbf7Vtyeu0sr2vHgvVt8Cwvmbu4+xuAtu+7QosPP3JS3dhovfzxL7o6bcxvj Fo21tU5vue4e0U16VKe/S0yJpTgj0VCLuag4EQADcP2oNAMAAA== 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.128.174 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 d105b2c..b845322 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; } @@ -1750,15 +1768,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; @@ -2121,6 +2139,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;