From patchwork Thu Mar 13 06:55:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 26176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0379C203AC for ; Thu, 13 Mar 2014 06:56:14 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id oy12sf1457825veb.3 for ; Wed, 12 Mar 2014 23:56:14 -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=gwELkiezU9R14qlX8Dmq5XHxEGeKd9TcFkx73/TV9OE=; b=FJcg4rtwqouSFaZ2pD3GBbz/g5s58mShGp4iFZLFgGiP6zdtV8AuOAeVoH4Uqup6Y7 LBfPaCNKI8eWPNJoP1BoTMZS9m6pOjAQpRUHSvu/ZYMglt0MFxoFixP9tKNqU956Wy/m 35qFMluyM3nVhYEjsMFzGhpbN+/GCJCVsaOy72d1KfVYcqzNuZp+twTLE5m74NC9eVDl jFnlpJi+BXYIJlFSqtzxCLD2yr2eahDxkXYo99zv+Gc4DNayTNexo2fIxw+ieUDPPzjk fzSG8oamAmutEzmJzHW2Mtt9rxVRvZtlT5El/Ta+wX8s1NhpE9hf/om9SKonDBAOfRBN L3Og== X-Gm-Message-State: ALoCoQnrssmWsqXDvLHKh5OFlEX7D5D+30XVjuqtVOzBvwJzyCcxzBcGyvxXgLwLZJxSmMWtYYmv X-Received: by 10.58.178.137 with SMTP id cy9mr107556vec.34.1394693774707; Wed, 12 Mar 2014 23:56:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.165 with SMTP id 34ls11752qgb.30.gmail; Wed, 12 Mar 2014 23:56:14 -0700 (PDT) X-Received: by 10.52.241.106 with SMTP id wh10mr86756vdc.16.1394693774511; Wed, 12 Mar 2014 23:56:14 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id l16si464230vcl.51.2014.03.12.23.56.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Mar 2014 23:56:14 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 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.179; Received: by mail-ve0-f179.google.com with SMTP id db12so636379veb.10 for ; Wed, 12 Mar 2014 23:56:14 -0700 (PDT) X-Received: by 10.52.107.35 with SMTP id gz3mr87011vdb.8.1394693774331; Wed, 12 Mar 2014 23:56:14 -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 i9csp345588vck; Wed, 12 Mar 2014 23:56:13 -0700 (PDT) X-Received: by 10.67.14.231 with SMTP id fj7mr166013pad.115.1394693768982; Wed, 12 Mar 2014 23:56:08 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wm7si685807pab.110.2014.03.12.23.56.07; Wed, 12 Mar 2014 23:56:08 -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 S1753083AbaCMG4C (ORCPT + 4 others); Thu, 13 Mar 2014 02:56:02 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:48922 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158AbaCMGz6 (ORCPT ); Thu, 13 Mar 2014 02:55:58 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2D0055Q4KZ5660@mailout1.samsung.com>; Thu, 13 Mar 2014 15:55:47 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.47]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 39.5B.09028.37651235; Thu, 13 Mar 2014 15:55:47 +0900 (KST) X-AuditID: cbfee68e-b7f566d000002344-0e-53215673c80b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 65.65.29263.37651235; Thu, 13 Mar 2014 15:55:47 +0900 (KST) Received: from DObh74an01 ([12.36.166.149]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2D003QA4KYB2A0@mmp1.samsung.com>; Thu, 13 Mar 2014 15:55:46 +0900 (KST) From: Byungho An To: netdev@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: davem@davemloft.net, ilho215.lee@samsung.com, vipul.pandya@samsung.com, 'Joe Perches' Subject: [PATCH V2 RE-SEND 2/7] net: sxgbe: add TSO support for Samsung sxgbe Date: Thu, 13 Mar 2014 15:55:46 +0900 Message-id: <007b01cf3e89$4289ea10$c79dbe30$%an@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac8+iUJoH+P1kqAdQPWk+sba0V0o0g== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsVy+t8zfd3iMMVgg0Mv5CyunjvGaDHnfAuL xdF/CxktZt9/zGLRu+Aqm8WM8/uYLI4tELPYtuACswOHx5aVN5k8vqy6xuzRt2UVo8fnTXIB LFFcNimpOZllqUX6dglcGVMf7WYp+JdZseX4IcYGxk8RXYycHBICJhKHX7eyQdhiEhfurQey uTiEBJYxStxYtIcZpmjx0b9MEIlFjBLPN91kgXB+M0rMn/2eCaSKTUBNonnmZbBRIgK2EkuO fGYHsZkFciX+LNsMNklYwFfizpTJYHEWAVWJu0uWgtm8AjYSvxo3skLYghI/Jt9jgejVkli/ 8zgThC0vsXnNW6A5HEAXqUs8+qsLsUpPYsf+DcwQJSIS+168YwS5TULgHLvE7JMr2SB2CUh8 m3yIBaJXVmLTAajHJCUOrrjBMoFRbBaSzbOQbJ6FZPMsJCsWMLKsYhRNLUguKE5KLzLSK07M LS7NS9dLzs/dxAiJxr4djDcPWB9iTAZaP5FZSjQ5HxjNeSXxhsZmRhamJqbGRuaWZqQJK4nz LnqYFCQkkJ5YkpqdmlqQWhRfVJqTWnyIkYmDU6qBMS7d67Wf3R6ma5vPvY9PbWRYkfpgrcri HcsXnLoV7ZE+XW3vwm8al6c49ilI8r6zk7mTzrikMCC29qzBxJpjv86ssn+av/hB6e0Lrr1R 4r8/d56+Kyb3eVbYXi6+255fp2SJ/O3e8bWh8Egu49YLyw7u2BpUu9A3f2XD1XcPahYsrPve KbQpjVuJpTgj0VCLuag4EQAX4Yee3AIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsVy+t9jAd3iMMVgg7a/ohZXzx1jtJhzvoXF 4ui/hYwWs+8/ZrHoXXCVzWLG+X1MFscWiFlsW3CB2YHDY8vKm0weX1ZdY/bo27KK0ePzJrkA lqgGRpuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wcoDOU FMoSc0qBQgGJxcVK+naYJoSGuOlawDRG6PqGBMH1GBmggYR1jBlTH+1mKfiXWbHl+CHGBsZP EV2MnBwSAiYSi4/+ZYKwxSQu3FvP1sXIxSEksIhR4vmmmywQzm9Gifmz34NVsQmoSTTPvMwG YosI2EosOfKZHcRmFsiV+LNsMzOILSzgK3FnymSwOIuAqsTdJUvBbF4BG4lfjRtZIWxBiR+T 77FA9GpJrN95nAnClpfYvOYt0BwOoIvUJR791YVYpSexY/8GZogSEYl9L94xTmAUmIVk0iwk k2YhmTQLScsCRpZVjKKpBckFxUnpuYZ6xYm5xaV56XrJ+bmbGMGx/kxqB+PKBotDjAIcjEo8 vCuWKwQLsSaWFVfmHmKU4GBWEuH19FEMFuJNSaysSi3Kjy8qzUktPsSYDPToRGYp0eR8YBrK K4k3NDYxM7I0MrMwMjE3J01YSZz3QKt1oJBAemJJanZqakFqEcwWJg5OqQbG8uWHvQ09dTum bYzJyt2sZ8g/b9GEhPjZLJZz/kiEPsndc23OCSPv6kezV5Z/EL1ku32/X4iQzodvVjzSJst2 9d93ZNjyuH5r3oWpvw/ts1jFk3jO+TtLSbz9Gm/e+6I3XjCyVXo9qORji9wmIpxw7MOEvTeu MfB4THPhPZ+6VOzG24nyPiVNSizFGYmGWsxFxYkAdHBbkjkDAAA= 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.179 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: ko From: Vipul Pandya Enable TSO during initialization for each DMA channels Signed-off-by: Vipul Pandya Neatening-by: Joe Perches Signed-off-by: Byungho An --- drivers/net/ethernet/samsung/sxgbe_desc.c | 47 +++++++++++++++--- drivers/net/ethernet/samsung/sxgbe_desc.h | 17 +++++-- drivers/net/ethernet/samsung/sxgbe_dma.c | 10 ++++ drivers/net/ethernet/samsung/sxgbe_dma.h | 2 + drivers/net/ethernet/samsung/sxgbe_main.c | 75 ++++++++++++++++++++++++++--- 5 files changed, 130 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/samsung/sxgbe_desc.c b/drivers/net/ethernet/samsung/sxgbe_desc.c index 9a93553..fa21236 100644 --- a/drivers/net/ethernet/samsung/sxgbe_desc.c +++ b/drivers/net/ethernet/samsung/sxgbe_desc.c @@ -28,6 +28,16 @@ static void sxgbe_init_tx_desc(struct sxgbe_tx_norm_desc *p) p->tdes23.tx_rd_des23.own_bit = 0; } +static void sxgbe_tx_desc_enable_tse(struct sxgbe_tx_norm_desc *p, u8 is_tse, + u32 total_hdr_len, u32 tcp_hdr_len, + u32 tcp_payload_len) +{ + p->tdes23.tx_rd_des23.tse_bit = is_tse; + p->tdes23.tx_rd_des23.buf1_size = total_hdr_len; + p->tdes23.tx_rd_des23.tcp_hdr_len = tcp_hdr_len / 4; + p->tdes23.tx_rd_des23.tx_pkt_len.tcp_payload_len = tcp_payload_len; +} + /* Assign buffer lengths for descriptor */ static void sxgbe_prepare_tx_desc(struct sxgbe_tx_norm_desc *p, u8 is_fd, int buf1_len, int pkt_len, int cksum) @@ -102,36 +112,47 @@ static int sxgbe_get_tx_timestamp_status(struct sxgbe_tx_norm_desc *p) } /* TX Context Descripto Specific */ -static void sxgbe_init_tx_ctxtdesc(struct sxgbe_tx_ctxt_desc *p) +static void sxgbe_tx_ctxt_desc_set_ctxt(struct sxgbe_tx_ctxt_desc *p) { p->ctxt_bit = 1; - p->own_bit = 0; } /* Set the owner of TX context descriptor */ -static void sxgbe_set_tx_ctxt_owner(struct sxgbe_tx_ctxt_desc *p) +static void sxgbe_tx_ctxt_desc_set_owner(struct sxgbe_tx_ctxt_desc *p) { p->own_bit = 1; } /* Get the owner of TX context descriptor */ -static int sxgbe_get_tx_ctxt_owner(struct sxgbe_tx_ctxt_desc *p) +static int sxgbe_tx_ctxt_desc_get_owner(struct sxgbe_tx_ctxt_desc *p) { return p->own_bit; } /* Set TX mss in TX context Descriptor */ -static void sxgbe_tx_ctxt_desc_setmss(struct sxgbe_tx_ctxt_desc *p, int mss) +static void sxgbe_tx_ctxt_desc_set_mss(struct sxgbe_tx_ctxt_desc *p, u16 mss) { p->maxseg_size = mss; } /* Get TX mss from TX context Descriptor */ -static int sxgbe_tx_ctxt_desc_getmss(struct sxgbe_tx_ctxt_desc *p) +static int sxgbe_tx_ctxt_desc_get_mss(struct sxgbe_tx_ctxt_desc *p) { return p->maxseg_size; } +/* Set TX tcmssv in TX context Descriptor */ +static void sxgbe_tx_ctxt_desc_set_tcmssv(struct sxgbe_tx_ctxt_desc *p) +{ + p->tcmssv = 1; +} + +/* Reset TX ostc in TX context Descriptor */ +static void sxgbe_tx_ctxt_desc_reset_ostc(struct sxgbe_tx_ctxt_desc *p) +{ + p->ostc = 0; +} + /* Set IVLAN information */ static void sxgbe_tx_ctxt_desc_set_ivlantag(struct sxgbe_tx_ctxt_desc *p, int is_ivlanvalid, int ivlan_tag, @@ -177,13 +198,13 @@ static void sxgbe_tx_ctxt_desc_set_tstamp(struct sxgbe_tx_ctxt_desc *p, } } /* Close TX context descriptor */ -static void sxgbe_close_tx_ctxt_desc(struct sxgbe_tx_ctxt_desc *p) +static void sxgbe_tx_ctxt_desc_close(struct sxgbe_tx_ctxt_desc *p) { p->own_bit = 1; } /* WB status of context descriptor */ -static int sxgbe_get_tx_ctxt_cde(struct sxgbe_tx_ctxt_desc *p) +static int sxgbe_tx_ctxt_desc_get_cde(struct sxgbe_tx_ctxt_desc *p) { return p->ctxt_desc_err; } @@ -432,6 +453,7 @@ static u64 sxgbe_get_rx_timestamp(struct sxgbe_rx_ctxt_desc *p) static const struct sxgbe_desc_ops desc_ops = { .init_tx_desc = sxgbe_init_tx_desc, + .tx_desc_enable_tse = sxgbe_tx_desc_enable_tse, .prepare_tx_desc = sxgbe_prepare_tx_desc, .tx_vlanctl_desc = sxgbe_tx_vlanctl_desc, .set_tx_owner = sxgbe_set_tx_owner, @@ -443,11 +465,20 @@ static const struct sxgbe_desc_ops desc_ops = { .get_tx_len = sxgbe_get_tx_len, .tx_enable_tstamp = sxgbe_tx_enable_tstamp, .get_tx_timestamp_status = sxgbe_get_tx_timestamp_status, + .tx_ctxt_desc_set_ctxt = sxgbe_tx_ctxt_desc_set_ctxt, + .tx_ctxt_desc_set_owner = sxgbe_tx_ctxt_desc_set_owner, + .get_tx_ctxt_owner = sxgbe_tx_ctxt_desc_get_owner, + .tx_ctxt_desc_set_mss = sxgbe_tx_ctxt_desc_set_mss, + .tx_ctxt_desc_get_mss = sxgbe_tx_ctxt_desc_get_mss, + .tx_ctxt_desc_set_tcmssv = sxgbe_tx_ctxt_desc_set_tcmssv, + .tx_ctxt_desc_reset_ostc = sxgbe_tx_ctxt_desc_reset_ostc, .tx_ctxt_desc_set_ivlantag = sxgbe_tx_ctxt_desc_set_ivlantag, .tx_ctxt_desc_get_ivlantag = sxgbe_tx_ctxt_desc_get_ivlantag, .tx_ctxt_desc_set_vlantag = sxgbe_tx_ctxt_desc_set_vlantag, .tx_ctxt_desc_get_vlantag = sxgbe_tx_ctxt_desc_get_vlantag, .tx_ctxt_set_tstamp = sxgbe_tx_ctxt_desc_set_tstamp, + .close_tx_ctxt_desc = sxgbe_tx_ctxt_desc_close, + .get_tx_ctxt_cde = sxgbe_tx_ctxt_desc_get_cde, .init_rx_desc = sxgbe_init_rx_desc, .get_rx_owner = sxgbe_get_rx_owner, .set_rx_owner = sxgbe_set_rx_owner, diff --git a/drivers/net/ethernet/samsung/sxgbe_desc.h b/drivers/net/ethernet/samsung/sxgbe_desc.h index 761b521..976d5ac 100644 --- a/drivers/net/ethernet/samsung/sxgbe_desc.h +++ b/drivers/net/ethernet/samsung/sxgbe_desc.h @@ -167,8 +167,9 @@ struct sxgbe_desc_ops { void (*init_tx_desc)(struct sxgbe_tx_norm_desc *p); /* Invoked by the xmit function to prepare the tx descriptor */ - void (*tx_enable_tse)(struct sxgbe_tx_norm_desc *p, u8 is_tse, - u32 hdr_len, u32 payload_len); + void (*tx_desc_enable_tse)(struct sxgbe_tx_norm_desc *p, u8 is_tse, + u32 total_hdr_len, u32 tcp_hdr_len, + u32 tcp_payload_len); /* Assign buffer lengths for descriptor */ void (*prepare_tx_desc)(struct sxgbe_tx_norm_desc *p, u8 is_fd, @@ -207,20 +208,26 @@ struct sxgbe_desc_ops { int (*get_tx_timestamp_status)(struct sxgbe_tx_norm_desc *p); /* TX Context Descripto Specific */ - void (*init_tx_ctxt_desc)(struct sxgbe_tx_ctxt_desc *p); + void (*tx_ctxt_desc_set_ctxt)(struct sxgbe_tx_ctxt_desc *p); /* Set the owner of the TX context descriptor */ - void (*set_tx_ctxt_owner)(struct sxgbe_tx_ctxt_desc *p); + void (*tx_ctxt_desc_set_owner)(struct sxgbe_tx_ctxt_desc *p); /* Get the owner of the TX context descriptor */ int (*get_tx_ctxt_owner)(struct sxgbe_tx_ctxt_desc *p); /* Set TX mss */ - void (*tx_ctxt_desc_setmss)(struct sxgbe_tx_ctxt_desc *p, int mss); + void (*tx_ctxt_desc_set_mss)(struct sxgbe_tx_ctxt_desc *p, u16 mss); /* Set TX mss */ int (*tx_ctxt_desc_get_mss)(struct sxgbe_tx_ctxt_desc *p); + /* Set TX tcmssv */ + void (*tx_ctxt_desc_set_tcmssv)(struct sxgbe_tx_ctxt_desc *p); + + /* Reset TX ostc */ + void (*tx_ctxt_desc_reset_ostc)(struct sxgbe_tx_ctxt_desc *p); + /* Set IVLAN information */ void (*tx_ctxt_desc_set_ivlantag)(struct sxgbe_tx_ctxt_desc *p, int is_ivlanvalid, int ivlan_tag, diff --git a/drivers/net/ethernet/samsung/sxgbe_dma.c b/drivers/net/ethernet/samsung/sxgbe_dma.c index 9ee4a3c..61fa64e 100644 --- a/drivers/net/ethernet/samsung/sxgbe_dma.c +++ b/drivers/net/ethernet/samsung/sxgbe_dma.c @@ -353,6 +353,15 @@ static void sxgbe_dma_rx_watchdog(void __iomem *ioaddr, u32 riwt) } } +static void sxgbe_enable_tso(void __iomem *ioaddr, u8 chan_num) +{ + u32 ctrl; + + ctrl = readl(ioaddr + SXGBE_DMA_CHA_TXCTL_REG(chan_num)); + ctrl |= SXGBE_DMA_CHA_TXCTL_TSE_ENABLE; + writel(ctrl, ioaddr + SXGBE_DMA_CHA_TXCTL_REG(chan_num)); +} + static const struct sxgbe_dma_ops sxgbe_dma_ops = { .init = sxgbe_dma_init, .cha_init = sxgbe_dma_channel_init, @@ -368,6 +377,7 @@ static const struct sxgbe_dma_ops sxgbe_dma_ops = { .tx_dma_int_status = sxgbe_tx_dma_int_status, .rx_dma_int_status = sxgbe_rx_dma_int_status, .rx_watchdog = sxgbe_dma_rx_watchdog, + .enable_tso = sxgbe_enable_tso, }; const struct sxgbe_dma_ops *sxgbe_get_dma_ops(void) diff --git a/drivers/net/ethernet/samsung/sxgbe_dma.h b/drivers/net/ethernet/samsung/sxgbe_dma.h index 50c8054..6c070ac 100644 --- a/drivers/net/ethernet/samsung/sxgbe_dma.h +++ b/drivers/net/ethernet/samsung/sxgbe_dma.h @@ -42,6 +42,8 @@ struct sxgbe_dma_ops { struct sxgbe_extra_stats *x); /* Program the HW RX Watchdog */ void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt); + /* Enable TSO for each DMA channel */ + void (*enable_tso)(void __iomem *ioaddr, u8 chan_num); }; const struct sxgbe_dma_ops *sxgbe_get_dma_ops(void); diff --git a/drivers/net/ethernet/samsung/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe_main.c index 7b5a6bd..857048e 100644 --- a/drivers/net/ethernet/samsung/sxgbe_main.c +++ b/drivers/net/ethernet/samsung/sxgbe_main.c @@ -1168,6 +1168,28 @@ static int sxgbe_release(struct net_device *dev) return 0; } +/* Prepare first Tx descriptor for doing TSO operation */ +void sxgbe_tso_prepare(struct sxgbe_priv_data *priv, + struct sxgbe_tx_norm_desc *first_desc, + struct sk_buff *skb) +{ + unsigned int total_hdr_len, tcp_hdr_len; + + /* Write first Tx descriptor with appropriate value */ + tcp_hdr_len = tcp_hdrlen(skb); + total_hdr_len = skb_transport_offset(skb) + tcp_hdr_len; + + first_desc->tdes01 = dma_map_single(priv->device, skb->data, + total_hdr_len, DMA_TO_DEVICE); + if (dma_mapping_error(priv->device, first_desc->tdes01)) + pr_err("%s: TX dma mapping failed!!\n", __func__); + + first_desc->tdes23.tx_rd_des23.first_desc = 1; + priv->hw->desc->tx_desc_enable_tse(first_desc, 1, total_hdr_len, + tcp_hdr_len, + skb->len - total_hdr_len); +} + /** * sxgbe_xmit: Tx entry point of the driver * @skb : the socket buffer @@ -1185,13 +1207,22 @@ static netdev_tx_t sxgbe_xmit(struct sk_buff *skb, struct net_device *dev) unsigned int tx_rsize = priv->dma_tx_size; struct sxgbe_tx_queue *tqueue = priv->txq[txq_index]; struct sxgbe_tx_norm_desc *tx_desc, *first_desc; + struct sxgbe_tx_ctxt_desc *ctxt_desc = NULL; int nr_frags = skb_shinfo(skb)->nr_frags; int no_pagedlen = skb_headlen(skb); int is_jumbo = 0; + u16 mss; + u32 ctxt_desc_req = 0; /* get the TX queue handle */ dev_txq = netdev_get_tx_queue(dev, txq_index); + if (likely(skb_is_gso(skb) || + vlan_tx_tag_present(skb) || + ((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && + tqueue->hwts_tx_en))) + ctxt_desc_req = 1; + /* get the spinlock */ spin_lock(&tqueue->tx_lock); @@ -1210,18 +1241,36 @@ static netdev_tx_t sxgbe_xmit(struct sk_buff *skb, struct net_device *dev) tx_desc = tqueue->dma_tx + entry; first_desc = tx_desc; + if (ctxt_desc_req) + ctxt_desc = (struct sxgbe_tx_ctxt_desc *)first_desc; /* save the skb address */ tqueue->tx_skbuff[entry] = skb; if (!is_jumbo) { - tx_desc->tdes01 = dma_map_single(priv->device, skb->data, - no_pagedlen, DMA_TO_DEVICE); - if (dma_mapping_error(priv->device, tx_desc->tdes01)) - pr_err("%s: TX dma mapping failed!!\n", __func__); - - priv->hw->desc->prepare_tx_desc(tx_desc, 1, no_pagedlen, - no_pagedlen); + if (likely(skb_is_gso(skb))) { + /* TSO support */ + mss = skb_shinfo(skb)->gso_size; + priv->hw->desc->tx_ctxt_desc_set_mss(ctxt_desc, mss); + priv->hw->desc->tx_ctxt_desc_set_tcmssv(ctxt_desc); + priv->hw->desc->tx_ctxt_desc_reset_ostc(ctxt_desc); + priv->hw->desc->tx_ctxt_desc_set_ctxt(ctxt_desc); + priv->hw->desc->tx_ctxt_desc_set_owner(ctxt_desc); + + entry = (++tqueue->cur_tx) % tx_rsize; + first_desc = tqueue->dma_tx + entry; + + sxgbe_tso_prepare(priv, first_desc, skb); + } else { + tx_desc->tdes01 = dma_map_single(priv->device, + skb->data, no_pagedlen, DMA_TO_DEVICE); + if (dma_mapping_error(priv->device, tx_desc->tdes01)) + netdev_err(dev, "%s: TX dma mapping failed!!\n", + __func__); + + priv->hw->desc->prepare_tx_desc(tx_desc, 1, no_pagedlen, + no_pagedlen); + } } for (frag_num = 0; frag_num < nr_frags; frag_num++) { @@ -1913,6 +1962,7 @@ struct sxgbe_priv_data *sxgbe_dvr_probe(struct device *device, int ret = 0; struct net_device *ndev = NULL; struct sxgbe_priv_data *priv; + u8 queue_num; ndev = alloc_etherdev_mqs(sizeof(struct sxgbe_priv_data), SXGBE_TX_QUEUES, SXGBE_RX_QUEUES); @@ -1957,7 +2007,9 @@ struct sxgbe_priv_data *sxgbe_dvr_probe(struct device *device, ndev->netdev_ops = &sxgbe_netdev_ops; - ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM; + ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | + NETIF_F_RXCSUM | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_GRO; ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA; ndev->watchdog_timeo = msecs_to_jiffies(watchdog); @@ -1969,6 +2021,13 @@ struct sxgbe_priv_data *sxgbe_dvr_probe(struct device *device, if (flow_ctrl) priv->flow_ctrl = SXGBE_FLOW_AUTO; /* RX/TX pause on */ + /* Enable TCP segmentation offload for all DMA channels */ + if (priv->hw_cap.tcpseg_offload) { + SXGBE_FOR_EACH_QUEUE(SXGBE_TX_QUEUES, queue_num) { + priv->hw->dma->enable_tso(priv->ioaddr, queue_num); + } + } + /* Rx Watchdog is available, enable depend on platform data */ if (!priv->plat->riwt_off) { priv->use_riwt = 1;