From patchwork Thu Jan 28 21:25:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8154341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 22473BEEE5 for ; Thu, 28 Jan 2016 21:49:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B9AF20218 for ; Thu, 28 Jan 2016 21:49:07 +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 160A520211 for ; Thu, 28 Jan 2016 21:49:06 +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 1aOuPw-0000x0-Mu; Thu, 28 Jan 2016 21:47:52 +0000 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOu86-00069b-A3 for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2016 21:29:28 +0000 Received: by mail-pf0-x235.google.com with SMTP id x125so29980757pfb.0 for ; Thu, 28 Jan 2016 13:29:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e8fAu5Ls3vEL3GeBRA71IlpSWfiT20E4tYUEchEedHo=; b=eCPd7Km0BeVvB/vtKIExJTXED4SHarmY2dt+z58G6UhKOYmlZ/RfF80dYJ/xFYZVuG ZJO2RacDP4aTT0d2IzkCffRwbfRc7IZTpqEjrkzWYR92wvLT8pK7Db/bkHRVuBWrgO7R ygSa7OWLEHZnxrw94ysoDE0+VbXHrs9YnOTmribKmmuagUJJ9DJ09ZTcKY3umfdroM0M hEyPMLYNC7jDeF2+RhxYRrHRKhVEzjh1xu29VckWm6wfTKSCbmS/u2B85kJzLe9rDocr jeapuXWBVpRgSQOUj3JSupGjrKUS5ktvGMAlI9Vxv63uwvRMGK0ZiN42018JE8vUmEm5 J0ow== 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=e8fAu5Ls3vEL3GeBRA71IlpSWfiT20E4tYUEchEedHo=; b=dDb0PqlN+eL9d9aFWZ8rtdpKl7lI8xotNLQfDanwt1ArMYYlLHBEbkJe3FrlBV4iia 8cg/P08ptUC+gvS974jWPm6ugF85HxtqI4tqmeTAQg2wvAp2W0FbJKjpGSQr+pSOlUKK AE1Heg96IF6xlXNFDLJhbVK7FV2p4MhojpCAowgSNrTa4el1zVBSc+LcfAnjaJyUKYVR tjCzZiczrQcnwJSPRCw9u0hsCSSqfeDklx+h6psYAq4QaYv8WNHNwDRfCcRg5EPGjvB7 oU+eOU3HLYEVgedYEDeOptpcB0u7iAY2+0qBSweYN+AuAtLarMIU9nWQAKt/WwGz7alH JxuA== X-Gm-Message-State: AG10YOQFj2+/EIE0ohiYz1l4F0emtdyKewSbmy900mEw7WtHqW2owEPL9CRF4ee0KL1hbA== X-Received: by 10.98.89.215 with SMTP id k84mr8085222pfj.66.1454016547260; Thu, 28 Jan 2016 13:29:07 -0800 (PST) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id c90sm18583190pfd.31.2016.01.28.13.29.05 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jan 2016 13:29:06 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next 35/40] net: fec: rename dirty_tx to pending_tx Date: Thu, 28 Jan 2016 14:25:59 -0700 Message-Id: <1454016364-30985-36-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> References: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160128_132926_600799_CBCC63E7 X-CRM114-Status: GOOD ( 18.50 ) X-Spam-Score: -2.6 (--) 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: fabio.estevam@freescale.com, andrew@lunn.ch, linux@arm.linux.org.uk, Troy Kisky , laci@boundarydevices.com, l.stach@pengutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, tremyfr@gmail.com 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=-4.1 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 dirty_tx always pointed to the last entry that was trasmitted. pending_tx always points to the next entry to be transmitted. This should be a little more efficient. This will allow 1 more entry in the queue to be used. That is, ring_size -1 entries instead of ring_size -2. This also allows the removal of fec_enet_get_prevdesc. Signed-off-by: Troy Kisky --- drivers/net/ethernet/freescale/fec.h | 14 +++++------- drivers/net/ethernet/freescale/fec_main.c | 38 ++++++++++--------------------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index d2ca2e2..a16e47e 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -440,6 +440,10 @@ struct bufdesc_prop { unsigned char dsize_log2; }; +/* bd.cur points to the currently available buffer. + * pending_tx tracks the current buffer that is being sent by the + * controller. When bd.cur and pending_tx are equal, nothing is pending. + */ struct fec_enet_priv_tx_q { struct bufdesc_prop bd; unsigned char *tx_bounce[TX_RING_SIZE]; @@ -448,7 +452,7 @@ struct fec_enet_priv_tx_q { unsigned short tx_stop_threshold; unsigned short tx_wake_threshold; - struct bufdesc *dirty_tx; + struct bufdesc *pending_tx; char *tso_hdrs; dma_addr_t tso_hdrs_dma; }; @@ -458,13 +462,7 @@ struct fec_enet_priv_rx_q { struct sk_buff *rx_skbuff[RX_RING_SIZE]; }; -/* The FEC buffer descriptors track the ring buffers. The rx_bd_base and - * tx_bd_base always point to the base of the buffer descriptors. The - * cur_rx and cur_tx point to the currently available buffer. - * The dirty_tx tracks the current buffer that is being sent by the - * controller. The cur_tx and dirty_tx are equal under both completely - * empty and completely full conditions. The empty/ready indicator in - * the buffer descriptor determines the actual condition. +/* The FEC buffer descriptors track the ring buffers. */ struct fec_enet_private { /* Hardware registers of the FEC device */ diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 8dea600..9db645d 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -226,13 +226,6 @@ static struct bufdesc *fec_enet_get_nextdesc(struct bufdesc *bdp, : (struct bufdesc *)(((unsigned)bdp) + bd->dsize); } -static struct bufdesc *fec_enet_get_prevdesc(struct bufdesc *bdp, - struct bufdesc_prop *bd) -{ - return (bdp <= bd->base) ? bd->last - : (struct bufdesc *)(((unsigned)bdp) - bd->dsize); -} - static int fec_enet_get_bd_index(struct bufdesc *bdp, struct bufdesc_prop *bd) { @@ -243,7 +236,7 @@ static int fec_enet_get_free_txdesc_num(struct fec_enet_priv_tx_q *txq) { int entries; - entries = (((const char *)txq->dirty_tx - + entries = (((const char *)txq->pending_tx - (const char *)txq->bd.cur) >> txq->bd.dsize_log2) - 1; return entries >= 0 ? entries : entries + txq->bd.ring_size; @@ -288,7 +281,7 @@ static void fec_dump(struct net_device *ndev) pr_info("%3u %c%c 0x%04x 0x%08lx %4u %p\n", index, bdp == txq->bd.cur ? 'S' : ' ', - bdp == txq->dirty_tx ? 'H' : ' ', + bdp == txq->pending_tx ? 'H' : ' ', bdp->cbd_sc, bdp->cbd_bufaddr, bdp->cbd_datlen, txq->tx_skbuff[index]); bdp = fec_enet_get_nextdesc(bdp, &txq->bd); @@ -802,6 +795,7 @@ static void fec_enet_bd_init(struct net_device *dev) txq = fep->tx_queue[q]; bdp = txq->bd.base; txq->bd.cur = bdp; + txq->pending_tx = bdp; for (i = 0; i < txq->bd.ring_size; i++) { /* Initialize the BD for every fragment in the page. */ @@ -820,8 +814,6 @@ static void fec_enet_bd_init(struct net_device *dev) bdp->cbd_sc = (bdp == txq->bd.last) ? BD_SC_WRAP : 0; bdp = fec_enet_get_nextdesc(bdp, &txq->bd); } - bdp = fec_enet_get_prevdesc(bdp, &txq->bd); - txq->dirty_tx = bdp; } } @@ -1134,11 +1126,8 @@ fec_timeout(struct net_device *ndev) int index; struct sk_buff *skb = NULL; - bdp = txq->dirty_tx; - while (1) { - bdp = fec_enet_get_nextdesc(bdp, &txq->bd); - if (bdp == txq->bd.cur) - break; + bdp = txq->pending_tx; + while (bdp != txq->bd.cur) { index = fec_enet_get_bd_index(bdp, &txq->bd); skb = txq->tx_skbuff[index]; if (skb) { @@ -1147,6 +1136,7 @@ fec_timeout(struct net_device *ndev) events |= txint_flags[i]; break; } + bdp = fec_enet_get_nextdesc(bdp, &txq->bd); } } if (events) { @@ -1208,12 +1198,8 @@ static void fec_txq(struct net_device *ndev, struct fec_enet_private *fep, int index = 0; int entries_free; - /* get next bdp of dirty_tx */ nq = netdev_get_tx_queue(ndev, txq->bd.qid); - bdp = txq->dirty_tx; - - /* get next bdp of dirty_tx */ - bdp = fec_enet_get_nextdesc(bdp, &txq->bd); + bdp = txq->pending_tx; while (bdp != READ_ONCE(txq->bd.cur)) { /* Order the load of bd.cur and cbd_sc */ @@ -1277,14 +1263,14 @@ static void fec_txq(struct net_device *ndev, struct fec_enet_private *fep, /* Free the sk buffer associated with this last transmit */ dev_kfree_skb_any(skb); skb_done: + /* Update pointer to next buffer descriptor to be transmitted */ + bdp = fec_enet_get_nextdesc(bdp, &txq->bd); + /* Make sure the update to bdp and tx_skbuff are performed - * before dirty_tx + * before pending_tx */ wmb(); - txq->dirty_tx = bdp; - - /* Update pointer to next buffer descriptor to be transmitted */ - bdp = fec_enet_get_nextdesc(bdp, &txq->bd); + txq->pending_tx = bdp; /* Since we have freed up a buffer, the ring is no longer full */