From patchwork Wed Mar 12 13:28:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungho An X-Patchwork-Id: 26098 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F01EA236AC for ; Wed, 12 Mar 2014 13:28:18 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id bj1sf2455690pad.7 for ; Wed, 12 Mar 2014 06:28:18 -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=O0xCjPhTgoskEprxBXaQYvDIs28PXe7/duQyOyDvEjc=; b=hFrNUDYgg7ozLOVeFd+m0b5Q6m0zyJh4aPTrxj23fbHNpHMHLLK79AczDbFdvzbM22 G+CG6kgkOjgpZn6yz4IAyt7a/Im+ZSzJdJb+WBsDzBfbSRl1OuOS6z5ODWTY7UmqOCoe y3PfP801euAFELZgnuEgr7PYqdAWxQ9+ijq+jpAFN5xjmMSLFDZyRCbp58Qks9Vsr+0t p6rul+ySYpjpQQCgmkBt/n50pW4GhplHpUNqLrqK67msthCwJaDDx/uy2qU6nOSo+nLP 8lWrHdwss5thbgrmST8SUViqnlSBgCdbQqDs9GQY53anUzI5Nr4x0w9qgbckoggMQAFJ vvUQ== X-Gm-Message-State: ALoCoQnz+3Wc3hY/bZKrE0WG40Ayc3AS4e+wrt6F8rAvUPv47Q80FW3K4m/0lD3pCKbnqQACbySQ X-Received: by 10.66.145.105 with SMTP id st9mr1822892pab.23.1394630898032; Wed, 12 Mar 2014 06:28:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.195 with SMTP id 61ls2905329qgv.19.gmail; Wed, 12 Mar 2014 06:28:17 -0700 (PDT) X-Received: by 10.59.9.38 with SMTP id dp6mr1744424ved.24.1394630897882; Wed, 12 Mar 2014 06:28:17 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id j20si6773379vcx.94.2014.03.12.06.28.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Mar 2014 06:28:17 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id cz12so10342029veb.30 for ; Wed, 12 Mar 2014 06:28:17 -0700 (PDT) X-Received: by 10.220.69.133 with SMTP id z5mr62634vci.49.1394630897791; Wed, 12 Mar 2014 06:28:17 -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 i9csp288360vck; Wed, 12 Mar 2014 06:28:15 -0700 (PDT) X-Received: by 10.68.113.68 with SMTP id iw4mr5004931pbb.119.1394630895510; Wed, 12 Mar 2014 06:28:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m9si2370356pab.264.2014.03.12.06.28.14; Wed, 12 Mar 2014 06:28:14 -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 S1754064AbaCLN2L (ORCPT + 8 others); Wed, 12 Mar 2014 09:28:11 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:36028 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753294AbaCLN2D (ORCPT ); Wed, 12 Mar 2014 09:28:03 -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 <0N2B00EMGS2QYE50@mailout2.samsung.com>; Wed, 12 Mar 2014 22:28:02 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.49]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id B9.1C.12635.2E060235; Wed, 12 Mar 2014 22:28:02 +0900 (KST) X-AuditID: cbfee68d-b7fcd6d00000315b-2b-532060e2aeb9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 94.6D.28157.2E060235; Wed, 12 Mar 2014 22:28:02 +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 <0N2B007LBS2MGD00@mmp1.samsung.com>; Wed, 12 Mar 2014 22:28:02 +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 V2 2/7] net: sxgbe: add TSO support for Samsung sxgbe Date: Wed, 12 Mar 2014 22:28:01 +0900 Message-id: <005201cf3df6$e4677bb0$ad367310$%an@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac899uRSH5+hwzJNSA+RHVyKNVAyUw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRmVeSWpSXmKPExsVy+t8zQ91HCQrBBl3fpS3mnG9hsTj6byGj xYzz+5gsji0Qs9i24AKzA6vHlpU3mTz6tqxi9Pi8SS6AOYrLJiU1J7MstUjfLoEro3djD2vB zKyK2zOWMjUwforoYuTkkBAwkbg34worhC0mceHeerYuRi4OIYFljBLXe16xwRT1LeuASixi lFg+/SoThPObUeLj8YdMIFVsAmoSzTMvg3WICNhKLDnymR3EZhbwkmg7swdshbCAq8StSXOY QWwWAVWJiUvbwGp4BWwkbn/7wAZhC0r8mHyPBaJXS2L9zuNMELa8xOY1b4F6OYAuUpd49FcX YpWexOS1f6HKRST2vXjHCHKbhMAmdomFs9+xQ+wSkPg2+RALRK+sxKYDzBCPSUocXHGDZQKj 2Cwkm2ch2TwLyeZZSFYsYGRZxSiaWpBcUJyUXmSoV5yYW1yal66XnJ+7iRESZb07GG8fsD7E mAy0fiKzlGhyPjBK80riDY3NjCxMTUyNjcwtzUgTVhLnTXqYFCQkkJ5YkpqdmlqQWhRfVJqT WnyIkYmDU6qB0eb79iW/M+VWmR37m7YkVH9N+UKbPVdbs1TWsSQ//OFjsprlzp9pFxc1Bd58 blpmdnuCSEXhi8SkmbKVmYE2iTozFhmynnNe0+S/4JMl79UNa6dP11MW3r5DL9T2KJOuwtE2 u6wiSwvbwife9b9n7Z36yO3l0Z7IX89+3/S+1RXVdH+epco8diWW4oxEQy3mouJEAIbMGaLI AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEKsWRmVeSWpSXmKPExsVy+t9jAd1HCQrBBq9/i1rMOd/CYnH030JG ixnn9zFZHFsgZrFtwQVmB1aPLStvMnn0bVnF6PF5k1wAc1QDo01GamJKapFCal5yfkpmXrqt kndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO0EolhbLEnFKgUEBicbGSvh2mCaEhbroW MI0Rur4hQXA9RgZoIGEdY0bvxh7WgplZFbdnLGVqYPwU0cXIySEhYCLRt6yDDcIWk7hwbz2Q zcUhJLCIUWL59KtMEM5vRomPxx8ygVSxCahJNM+8DNYhImArseTIZ3YQm1nAS6LtzB5WEFtY wFXi1qQ5zCA2i4CqxMSlbWA1vAI2Ere/fWCDsAUlfky+xwLRqyWxfudxJghbXmLzmrdAvRxA F6lLPPqrC7FKT2Ly2r9Q5SIS+168Y5zAKDALyaRZSCbNQjJpFpKWBYwsqxhFUwuSC4qT0nON 9IoTc4tL89L1kvNzNzGCY/iZ9A7GVQ0WhxgFOBiVeHgXasoHC7EmlhVX5h5ilOBgVhLhXRal ECzEm5JYWZValB9fVJqTWnyIMRno0YnMUqLJ+cD0klcSb2hsYmZkaWRmYWRibk6asJI478FW 60AhgfTEktTs1NSC1CKYLUwcnFINjGzlt/3PMsg3lxyK13b4creSf/fy7ovn1kfs3VDwI4qp Ipc9sX3Sgr9bJc44PrhYOrHw+A5B45Bwe9mPWvxqv3q1n5eX8HyqE+RaZjLhafBFyaXLD0vn /m5VcP3kdXLWnBeLWWu5mmVXsC54HLVMI/vC7K8l3s+uKJhvfKux8tDmPvNj8RcKHymxFGck GmoxFxUnAgApf2geJQMAAA== 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.171 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(-) @@ -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; diff --git a/drivers/net/ethernet/samsung/sxgbe_desc.c b/drivers/net/ethernet/samsung/sxgbe_desc.c index 7577375..f223eb5 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 0d75f56..26ed30f 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 f761867..e606ea7 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 0d84f89..64ccd91 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 b99afab..83b6e27 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);