From patchwork Wed Mar 5 11:28:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 25752 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2DE1203C3 for ; Wed, 5 Mar 2014 11:28:43 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id le5sf1969803vcb.7 for ; Wed, 05 Mar 2014 03:28:43 -0800 (PST) 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=qenPZRc+z+DlPwPE7i8guvVhGMG75KhgF/MtSnTI9oo=; b=iPr4xO24tCQVwmmApsWgxFGXDMhPYwsZbclI83Pp7wOricfzh8ExFUqqn/7hRbDefK QrV+UJLh0T18hlOcWmimMdiJde3hRmXdRASgT/jKu+Kui5mSkG6H8MrWb+tiNT/epZWE LFyJ50WLcUP11Kdu5Wjt5MEWFFJ4OoBxURsO9grH5afobernZK8Sqp108Ut12+FfR1K2 vssyNMqZfIaKeJPsTJPbIPHPvjZj5U/xCKr6wIG+DRoyO1z4N+tgx63JtPsgRy2YGUM7 DKgoNWMaiq3Koq9CD+lCEQMJjM6Or+mT2I0LUn1CIiyPAUx+kP6DwLuE5gEIVjS9LpQs A8GA== X-Gm-Message-State: ALoCoQliwqNwN2XTTI73PdPpELQne/d13OnuL0WnyUYzXCqbZbBR/yUfdbnXj2Xzpc6H/tZLqtiH X-Received: by 10.236.118.38 with SMTP id k26mr2184145yhh.35.1394018923517; Wed, 05 Mar 2014 03:28:43 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.137 with SMTP id l9ls225713qgf.40.gmail; Wed, 05 Mar 2014 03:28:43 -0800 (PST) X-Received: by 10.52.89.230 with SMTP id br6mr3589303vdb.20.1394018923323; Wed, 05 Mar 2014 03:28:43 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id ry8si582544vdc.149.2014.03.05.03.28.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Mar 2014 03:28:43 -0800 (PST) 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 ks9so881693vcb.11 for ; Wed, 05 Mar 2014 03:28:43 -0800 (PST) X-Received: by 10.58.12.169 with SMTP id z9mr57578veb.61.1394018923212; Wed, 05 Mar 2014 03:28:43 -0800 (PST) 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 i9csp11200vck; Wed, 5 Mar 2014 03:28:42 -0800 (PST) X-Received: by 10.68.189.5 with SMTP id ge5mr6335254pbc.42.1394018922205; Wed, 05 Mar 2014 03:28:42 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tk9si2184367pac.64.2014.03.05.03.28.41; Wed, 05 Mar 2014 03:28:41 -0800 (PST) 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 S1755516AbaCEL2d (ORCPT + 4 others); Wed, 5 Mar 2014 06:28:33 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:58294 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751459AbaCEL21 (ORCPT ); Wed, 5 Mar 2014 06:28:27 -0500 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N1Y009ZNNV7UCA0@mailout2.samsung.com>; Wed, 05 Mar 2014 20:28:19 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.50]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id F8.A9.14803.35A07135; Wed, 05 Mar 2014 20:28:19 +0900 (KST) X-AuditID: cbfee691-b7efc6d0000039d3-6d-53170a53ebe0 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 2F.20.28157.35A07135; Wed, 05 Mar 2014 20:28:19 +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 <0N1Y00731NV4KZ00@mmp1.samsung.com>; Wed, 05 Mar 2014 20:28:19 +0900 (KST) From: Byungho An To: netdev@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: davem@davemloft.net, vipul.pandya@samsung.com, ilho215.lee@samsung.com Subject: [PATCH 2/7] net: xgmac: add TSO support for Samsung xgmac Date: Wed, 05 Mar 2014 20:28:19 +0900 Message-id: <007c01cf3866$02291460$067b3d20$%an@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac84ZgIWlyP3o5BCTHC5V0BEWhpNvg== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRmVeSWpSXmKPExsVy+t8zI91gLvFgg8kLxCyunjvGaDHnfAuL xdF/CxktZpzfx2RxDCi+bcEFZgc2jy0rbzJ59G1ZxejxeZNcAHMUl01Kak5mWWqRvl0CV8b0 d++ZCzZnVsw/9IOtgXFDRBcjB4eEgInEt2sOXYycQKaYxIV769m6GLk4hASWMUrMPbicFSJh ItG57gMzRGIRo8S0cz/ZQBJCAr8ZJT5c4Aax2QTUJJpnXgaLiwjYSiw58pkdxGYW8JJoO7MH bJCwgJPE789nweIsAqoSBxqvsYDYvAI2EnfP/4CyBSV+TL7HAtGrJbF5WxMrhC0vsXnNW2aI o9UlHv3VBTFFBPQkbt4tgagQkdj34h0jyJkSArvYJY78m8wGsUpA4tvkQywQrbISmw4wQ7wl KXFwxQ2WCYxis5AsnoVk8Swki2chWbGAkWUVo2hqQXJBcVJ6kalecWJucWleul5yfu4mRkik TdzBeP+A9SHGZKD1E5mlRJPzgZGaVxJvaGxmZGFqYmpsZG5pRpqwkjhv+qOkICGB9MSS1OzU 1ILUovii0pzU4kOMTBycUg2MsZviGI+VBG8Ul41dx1lSpfdn876N+VO53v86EaohWxi6Xa3J SW6hV97R/yqtEr6b96aGRr5r2uLHez042m9t3mam6+us09aKuRWtC/4W7SM6n9sn8WVhlkpE Ff+kuToBSre8Q1bMd4jpcX8tuFGbKdzL+0rAM967rvk1FzlC83sfvGP/4anEUpyRaKjFXFSc CAAJaZWwygIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKKsWRmVeSWpSXmKPExsVy+t9jAd1gLvFgg7mzBSyunjvGaDHnfAuL xdF/CxktZpzfx2RxbIGYxbYFF5gd2Dy2rLzJ5NG3ZRWjx+dNcgHMUQ2MNhmpiSmpRQqpecn5 KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlAe5UUyhJzSoFCAYnFxUr6dpgm hIa46VrANEbo+oYEwfUYGaCBhHWMGdPfvWcu2JxZMf/QD7YGxg0RXYycHBICJhKd6z4wQ9hi EhfurWfrYuTiEBJYxCgx7dxPNpCEkMBvRokPF7hBbDYBNYnmmZfB4iICthJLjnxmB7GZBbwk 2s7sYQWxhQWcJH5/PgsWZxFQlTjQeI0FxOYVsJG4e/4HlC0o8WPyPRaIXi2JzduaWCFseYnN a94CHcQBdJC6xKO/uiCmiICexM27JRAVIhL7XrxjnMAoMAvJoFlIBs1CMmgWkpYFjCyrGEVT C5ILipPSc430ihNzi0vz0vWS83M3MYIj+Zn0DsZVDRaHGAU4GJV4eF9wiAULsSaWFVfmHmKU 4GBWEuE9xiIeLMSbklhZlVqUH19UmpNafIgxGejPicxSosn5wCSTVxJvaGxiZmRpZGZhZGJu TpqwkjjvwVbrQCGB9MSS1OzU1ILUIpgtTBycUg2MfunHZktyXqm8Zb/mVXeohu4H+2ybkgg9 FgXPH41HxG9vrHJ5uWeJmdgGbV1/4Wql/nDmvUVH5hnbnG5YfPjrzE6jXWs0xTZqN07WKI6U nPNOoN/bK9VX93zWXrmLzo1Tfxl+UJRlXSX7Y36Sza6PXp56v6vmLj6v27PDtS5MsJ5/9QV9 p5NKLMUZiYZazEXFiQDwDAMKKAMAAA== 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: ko From: Vipul Pandya Enable TSO during initialization for each DMA channels Signed-off-by: Vipul Pandya Signed-off-by: Byungho An --- drivers/net/ethernet/samsung/xgmac_desc.c | 47 +++++++++++++++--- drivers/net/ethernet/samsung/xgmac_desc.h | 17 +++++-- drivers/net/ethernet/samsung/xgmac_dma.c | 10 ++++ drivers/net/ethernet/samsung/xgmac_dma.h | 2 + drivers/net/ethernet/samsung/xgmac_main.c | 76 ++++++++++++++++++++++++++--- 5 files changed, 131 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/samsung/xgmac_desc.c b/drivers/net/ethernet/samsung/xgmac_desc.c index 791b5ec..51b7e71 100644 --- a/drivers/net/ethernet/samsung/xgmac_desc.c +++ b/drivers/net/ethernet/samsung/xgmac_desc.c @@ -25,6 +25,16 @@ static void xgmac_init_tx_desc(struct xgmac_tx_norm_desc *p) p->tdes23.tx_rd_des23.own_bit = 0; } +static void xgmac_tx_desc_enable_tse(struct xgmac_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 xgmac_prepare_tx_desc(struct xgmac_tx_norm_desc *p, u8 is_fd, int buf1_len, int pkt_len) @@ -99,36 +109,47 @@ static int xgmac_get_tx_timestamp_status(struct xgmac_tx_norm_desc *p) } /* TX Context Descripto Specific */ -static void xgmac_init_tx_ctxtdesc(struct xgmac_tx_ctxt_desc *p) +static void xgmac_tx_ctxt_desc_set_ctxt(struct xgmac_tx_ctxt_desc *p) { p->ctxt_bit = 1; - p->own_bit = 0; } /* Set the owner of TX context descriptor */ -static void xgmac_set_tx_ctxt_owner(struct xgmac_tx_ctxt_desc *p) +static void xgmac_tx_ctxt_desc_set_owner(struct xgmac_tx_ctxt_desc *p) { p->own_bit = 1; } /* Get the owner of TX context descriptor */ -static int xgmac_get_tx_ctxt_owner(struct xgmac_tx_ctxt_desc *p) +static int xgmac_tx_ctxt_desc_get_owner(struct xgmac_tx_ctxt_desc *p) { return p->own_bit; } /* Set TX mss in TX context Descriptor */ -static void xgmac_tx_ctxt_desc_setmss(struct xgmac_tx_ctxt_desc *p, int mss) +static void xgmac_tx_ctxt_desc_set_mss(struct xgmac_tx_ctxt_desc *p, u16 mss) { p->maxseg_size = mss; } /* Get TX mss from TX context Descriptor */ -static int xgmac_tx_ctxt_desc_getmss(struct xgmac_tx_ctxt_desc *p) +static int xgmac_tx_ctxt_desc_get_mss(struct xgmac_tx_ctxt_desc *p) { return p->maxseg_size; } +/* Set TX tcmssv in TX context Descriptor */ +static void xgmac_tx_ctxt_desc_set_tcmssv(struct xgmac_tx_ctxt_desc *p) +{ + p->tcmssv = 1; +} + +/* Reset TX ostc in TX context Descriptor */ +static void xgmac_tx_ctxt_desc_reset_ostc(struct xgmac_tx_ctxt_desc *p) +{ + p->ostc = 0; +} + /* Set IVLAN information */ static void xgmac_tx_ctxt_desc_set_ivlantag(struct xgmac_tx_ctxt_desc *p, int is_ivlanvalid, int ivlan_tag, @@ -175,13 +196,13 @@ static void xgmac_tx_ctxt_desc_set_tstamp(struct xgmac_tx_ctxt_desc *p, } /* Close TX context descriptor */ -static void xgmac_close_tx_ctxt_desc(struct xgmac_tx_ctxt_desc *p) +static void xgmac_tx_ctxt_desc_close(struct xgmac_tx_ctxt_desc *p) { p->own_bit = 1; } /* WB status of context descriptor */ -static int xgmac_get_tx_ctxt_cde(struct xgmac_tx_ctxt_desc *p) +static int xgmac_tx_ctxt_desc_get_cde(struct xgmac_tx_ctxt_desc *p) { return p->ctxt_desc_err; } @@ -433,6 +454,7 @@ static u64 xgmac_get_rx_timestamp(struct xgmac_rx_ctxt_desc *p) static const struct xgmac_desc_ops desc_ops = { .init_tx_desc = xgmac_init_tx_desc, + .tx_desc_enable_tse = xgmac_tx_desc_enable_tse, .prepare_tx_desc = xgmac_prepare_tx_desc, .tx_vlanctl_desc = xgmac_tx_vlanctl_desc, .set_tx_owner = xgmac_set_tx_owner, @@ -444,11 +466,20 @@ static const struct xgmac_desc_ops desc_ops = { .get_tx_len = xgmac_get_tx_len, .tx_enable_tstamp = xgmac_tx_enable_tstamp, .get_tx_timestamp_status = xgmac_get_tx_timestamp_status, + .tx_ctxt_desc_set_ctxt = xgmac_tx_ctxt_desc_set_ctxt, + .tx_ctxt_desc_set_owner = xgmac_tx_ctxt_desc_set_owner, + .get_tx_ctxt_owner = xgmac_tx_ctxt_desc_get_owner, + .tx_ctxt_desc_set_mss = xgmac_tx_ctxt_desc_set_mss, + .tx_ctxt_desc_get_mss = xgmac_tx_ctxt_desc_get_mss, + .tx_ctxt_desc_set_tcmssv = xgmac_tx_ctxt_desc_set_tcmssv, + .tx_ctxt_desc_reset_ostc = xgmac_tx_ctxt_desc_reset_ostc, .tx_ctxt_desc_set_ivlantag = xgmac_tx_ctxt_desc_set_ivlantag, .tx_ctxt_desc_get_ivlantag = xgmac_tx_ctxt_desc_get_ivlantag, .tx_ctxt_desc_set_vlantag = xgmac_tx_ctxt_desc_set_vlantag, .tx_ctxt_desc_get_vlantag = xgmac_tx_ctxt_desc_get_vlantag, .tx_ctxt_set_tstamp = xgmac_tx_ctxt_desc_set_tstamp, + .close_tx_ctxt_desc = xgmac_tx_ctxt_desc_close, + .get_tx_ctxt_cde = xgmac_tx_ctxt_desc_get_cde, .init_rx_desc = xgmac_init_rx_desc, .get_rx_owner = xgmac_get_rx_owner, .set_rx_owner = xgmac_set_rx_owner, diff --git a/drivers/net/ethernet/samsung/xgmac_desc.h b/drivers/net/ethernet/samsung/xgmac_desc.h index 4f20283..d9b80fc 100644 --- a/drivers/net/ethernet/samsung/xgmac_desc.h +++ b/drivers/net/ethernet/samsung/xgmac_desc.h @@ -167,8 +167,9 @@ struct xgmac_desc_ops { void (*init_tx_desc)(struct xgmac_tx_norm_desc *p); /* Invoked by the xmit function to prepare the tx descriptor */ - void (*tx_enable_tse)(struct xgmac_tx_norm_desc *p, u8 is_tse, - u32 hdr_len, u32 payload_len); + void (*tx_desc_enable_tse)(struct xgmac_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 xgmac_tx_norm_desc *p, u8 is_fd, @@ -207,20 +208,26 @@ struct xgmac_desc_ops { int (*get_tx_timestamp_status)(struct xgmac_tx_norm_desc *p); /* TX Context Descripto Specific */ - void (*init_tx_ctxt_desc)(struct xgmac_tx_ctxt_desc *p); + void (*tx_ctxt_desc_set_ctxt)(struct xgmac_tx_ctxt_desc *p); /* Set the owner of the TX context descriptor */ - void (*set_tx_ctxt_owner)(struct xgmac_tx_ctxt_desc *p); + void (*tx_ctxt_desc_set_owner)(struct xgmac_tx_ctxt_desc *p); /* Get the owner of the TX context descriptor */ int (*get_tx_ctxt_owner)(struct xgmac_tx_ctxt_desc *p); /* Set TX mss */ - void (*tx_ctxt_desc_setmss)(struct xgmac_tx_ctxt_desc *p, int mss); + void (*tx_ctxt_desc_set_mss)(struct xgmac_tx_ctxt_desc *p, u16 mss); /* Set TX mss */ int (*tx_ctxt_desc_get_mss)(struct xgmac_tx_ctxt_desc *p); + /* Set TX tcmssv */ + void (*tx_ctxt_desc_set_tcmssv)(struct xgmac_tx_ctxt_desc *p); + + /* Reset TX ostc */ + void (*tx_ctxt_desc_reset_ostc)(struct xgmac_tx_ctxt_desc *p); + /* Set IVLAN information */ void (*tx_ctxt_desc_set_ivlantag)(struct xgmac_tx_ctxt_desc *p, int is_ivlanvalid, int ivlan_tag, diff --git a/drivers/net/ethernet/samsung/xgmac_dma.c b/drivers/net/ethernet/samsung/xgmac_dma.c index c28d90c..47945a3 100644 --- a/drivers/net/ethernet/samsung/xgmac_dma.c +++ b/drivers/net/ethernet/samsung/xgmac_dma.c @@ -348,6 +348,15 @@ static void xgmac_dma_rx_watchdog(void __iomem *ioaddr, u32 riwt) } } +static void xgmac_enable_tso(void __iomem *ioaddr, u8 chan_num) +{ + u32 ctrl; + + ctrl = readl(ioaddr + XGMAC_DMA_CHA_TXCTL_REG(chan_num)); + ctrl |= XGMAC_DMA_CHA_TXCTL_TSE_ENABLE; + writel(ctrl, ioaddr + XGMAC_DMA_CHA_TXCTL_REG(chan_num)); +} + static const struct xgmac_dma_ops xgmac_dma_ops = { .init = xgmac_dma_init, .cha_init = xgmac_dma_channel_init, @@ -363,6 +372,7 @@ static const struct xgmac_dma_ops xgmac_dma_ops = { .tx_dma_int_status = xgmac_tx_dma_int_status, .rx_dma_int_status = xgmac_rx_dma_int_status, .rx_watchdog = xgmac_dma_rx_watchdog, + .enable_tso = xgmac_enable_tso, }; const struct xgmac_dma_ops *xgmac_get_dma_ops(void) diff --git a/drivers/net/ethernet/samsung/xgmac_dma.h b/drivers/net/ethernet/samsung/xgmac_dma.h index 002fd18..2e76ae0 100644 --- a/drivers/net/ethernet/samsung/xgmac_dma.h +++ b/drivers/net/ethernet/samsung/xgmac_dma.h @@ -42,6 +42,8 @@ struct xgmac_dma_ops { struct xgmac_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 xgmac_dma_ops *xgmac_get_dma_ops(void); diff --git a/drivers/net/ethernet/samsung/xgmac_main.c b/drivers/net/ethernet/samsung/xgmac_main.c index f72a4c1..ef7f55b 100644 --- a/drivers/net/ethernet/samsung/xgmac_main.c +++ b/drivers/net/ethernet/samsung/xgmac_main.c @@ -1185,6 +1185,29 @@ static int xgmac_release(struct net_device *dev) } +/* Prepare first Tx descriptor for doing TSO operation */ +void xgmac_tso_prepare(struct xgmac_priv_data *priv, + struct xgmac_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); + +} + /** * xgmac_xmit: Tx entry point of the driver * @skb : the socket buffer @@ -1202,13 +1225,22 @@ static netdev_tx_t xgmac_xmit(struct sk_buff *skb, struct net_device *dev) unsigned int tx_rsize = priv->dma_tx_size; struct xgmac_tx_queue *tqueue = priv->txq[txq_index]; struct xgmac_tx_norm_desc *tx_desc, *first_desc; + struct xgmac_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); @@ -1227,18 +1259,36 @@ static netdev_tx_t xgmac_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 xgmac_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; + + xgmac_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)) + pr_err("%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++) { @@ -1927,6 +1977,7 @@ struct xgmac_priv_data *xgmac_dvr_probe(struct device *device, int ret = 0; struct net_device *ndev = NULL; struct xgmac_priv_data *priv; + u8 queue_num; ndev = alloc_etherdev_mqs(sizeof(struct xgmac_priv_data), XGMAC_TX_QUEUES, XGMAC_RX_QUEUES); @@ -1971,7 +2022,9 @@ struct xgmac_priv_data *xgmac_dvr_probe(struct device *device, ndev->netdev_ops = &xgmac_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); @@ -1983,6 +2036,13 @@ struct xgmac_priv_data *xgmac_dvr_probe(struct device *device, if (flow_ctrl) priv->flow_ctrl = XGMAC_FLOW_AUTO; /* RX/TX pause on */ + /* Enable TCP segmentation offload for all DMA channels */ + if (priv->hw_cap.tcpseg_offload) { + XGMAC_FOR_EACH_QUEUE(XGMAC_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;