From patchwork Wed Aug 26 18:48:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyappan Subramanian X-Patchwork-Id: 7079491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CB4DB9F41A for ; Wed, 26 Aug 2015 18:50:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DFEB820961 for ; Wed, 26 Aug 2015 18:50:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05C2C20962 for ; Wed, 26 Aug 2015 18:50:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUfkK-0007p4-Pv; Wed, 26 Aug 2015 18:48:28 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUfkG-0007nG-Tv for linux-arm-kernel@bombadil.infradead.org; Wed, 26 Aug 2015 18:48:25 +0000 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUfkE-0007YU-8z for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2015 18:48:23 +0000 Received: by pabzx8 with SMTP id zx8so78386325pab.1 for ; Wed, 26 Aug 2015 11:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=34tyD9J/rjOGGb65gKcmn/iyFYybKlywhzh9XAsjQBo=; b=ID/xLb6jTsf0/9RGVibBmSCgbgR/c2zsGofqgYJl1SrxjPn3iGeXFrvLTcV5x+n0i0 pKWUAaMncqESmkRpZBgFQqrR/BsNtPpXQees6y8Vo5WDK0hBFwDMiUQqqvLiIpOR9Qad 9uwcrcltwmYMk82aNJDTf9znkkHQ+tb2oXVls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=34tyD9J/rjOGGb65gKcmn/iyFYybKlywhzh9XAsjQBo=; b=k+bgbvzWXL/YHQ1cKjYpO7dBURwRee4jlViAjl+jzq0Pl/69fPtmp3ZscKXMVx5IPF 5tjgrGom3xx4SE/ZfMxnnkQkKH6xrHzzeNmYL9aO62znKkPSysPgID57yIqAeW4GAdXl vqJB+S8AmEdg/hNmKyPvr2CCqqDAe3c6fm1T6w4hA1ux7hbbY9g7X2xHf02knpWVGOwu hG6rMEQQVVZqAziWaCSKDzBkQNoq8Wox+J0gSS9Xtk47UodS1RCzcpU0eJS6W3PmnkAq RHNNtr6D+rpHSJJ390lGsokdPjHzciX//8XWAZISSfkDdWIYlYpBTB0f+NMclinO96jF 45tw== X-Gm-Message-State: ALoCoQljYS29ID3f+TYlwXeeO/S0ifK6bpypIfsOeaB11iUK4HS9rp3p1wwlAZALAVfIA3ZPgyan X-Received: by 10.66.253.170 with SMTP id ab10mr72334619pad.135.1440614879227; Wed, 26 Aug 2015 11:47:59 -0700 (PDT) Received: from isubrama-dev.amcc.com (70-35-53-82.static.wiline.com. [70.35.53.82]) by smtp.gmail.com with ESMTPSA id ll8sm21223486pab.39.2015.08.26.11.47.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 11:47:58 -0700 (PDT) From: Iyappan Subramanian To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH v2 1/2] drivers: net: xgene: Preparatory patch for TSO support Date: Wed, 26 Aug 2015 11:48:05 -0700 Message-Id: <1440614886-23566-2-git-send-email-isubramanian@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440614886-23566-1-git-send-email-isubramanian@apm.com> References: <1440614886-23566-1-git-send-email-isubramanian@apm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_194822_505309_19B7E7FD X-CRM114-Status: GOOD ( 15.53 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@apm.com, linux-arm-kernel@lists.infradead.org, Iyappan Subramanian MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Rearranged descriptor writes - Moved increment command write to xgene_enet_setup_tx_desc Signed-off-by: Iyappan Subramanian --- drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 29 ++++++++++++++++++------ drivers/net/ethernet/apm/xgene/xgene_enet_main.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c index 4f68d19..652b4c3 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c @@ -219,6 +219,11 @@ out: return hopinfo; } +static u16 xgene_enet_encode_len(u16 len) +{ + return (len == BUFLEN_16K) ? 0 : len; +} + static int xgene_enet_setup_tx_desc(struct xgene_enet_desc_ring *tx_ring, struct sk_buff *skb) { @@ -227,27 +232,36 @@ static int xgene_enet_setup_tx_desc(struct xgene_enet_desc_ring *tx_ring, dma_addr_t dma_addr; u16 tail = tx_ring->tail; u64 hopinfo; + u32 len, hw_len; + u8 count = 1; raw_desc = &tx_ring->raw_desc[tail]; memset(raw_desc, 0, sizeof(struct xgene_enet_raw_desc)); - dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE); + len = skb_headlen(skb); + hw_len = xgene_enet_encode_len(len); + + dma_addr = dma_map_single(dev, skb->data, len, DMA_TO_DEVICE); if (dma_mapping_error(dev, dma_addr)) { netdev_err(tx_ring->ndev, "DMA mapping error\n"); return -EINVAL; } /* Hardware expects descriptor in little endian format */ - raw_desc->m0 = cpu_to_le64(tail); raw_desc->m1 = cpu_to_le64(SET_VAL(DATAADDR, dma_addr) | - SET_VAL(BUFDATALEN, skb->len) | + SET_VAL(BUFDATALEN, hw_len) | SET_BIT(COHERENT)); + + raw_desc->m0 = cpu_to_le64(SET_VAL(USERINFO, tail)); hopinfo = xgene_enet_work_msg(skb); raw_desc->m3 = cpu_to_le64(SET_VAL(HENQNUM, tx_ring->dst_ring_num) | hopinfo); tx_ring->cp_ring->cp_skb[tail] = skb; - return 0; + tail = (tail + 1) & (tx_ring->slots - 1); + tx_ring->tail = tail; + + return count; } static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb, @@ -257,6 +271,7 @@ static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb, struct xgene_enet_desc_ring *tx_ring = pdata->tx_ring; struct xgene_enet_desc_ring *cp_ring = tx_ring->cp_ring; u32 tx_level, cq_level; + int count; tx_level = pdata->ring_ops->len(tx_ring); cq_level = pdata->ring_ops->len(cp_ring); @@ -266,14 +281,14 @@ static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb, return NETDEV_TX_BUSY; } - if (xgene_enet_setup_tx_desc(tx_ring, skb)) { + count = xgene_enet_setup_tx_desc(tx_ring, skb); + if (count <= 0) { dev_kfree_skb_any(skb); return NETDEV_TX_OK; } - pdata->ring_ops->wr_cmd(tx_ring, 1); + pdata->ring_ops->wr_cmd(tx_ring, count); skb_tx_timestamp(skb); - tx_ring->tail = (tx_ring->tail + 1) & (tx_ring->slots - 1); pdata->stats.tx_packets++; pdata->stats.tx_bytes += skb->len; diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h index 1c85fc8..2ac547e 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h @@ -40,6 +40,7 @@ #define XGENE_DRV_VERSION "v1.0" #define XGENE_ENET_MAX_MTU 1536 #define SKB_BUFFER_SIZE (XGENE_ENET_MAX_MTU - NET_IP_ALIGN) +#define BUFLEN_16K (16 * 1024) #define NUM_PKT_BUF 64 #define NUM_BUFPOOL 32