From: Troy Kisky <troy.kisky@boundarydevices.com> To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Cc: fabio.estevam@freescale.com, l.stach@pengutronix.de, andrew@lunn.ch, tremyfr@gmail.com, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org, laci@boundarydevices.com, shawnguo@kernel.org, Troy Kisky <troy.kisky@boundarydevices.com> Subject: [PATCH net-next 35/40] net: fec: rename dirty_tx to pending_tx Date: Thu, 28 Jan 2016 14:25:59 -0700 [thread overview] Message-ID: <1454016364-30985-36-git-send-email-troy.kisky@boundarydevices.com> (raw) In-Reply-To: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> 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 <troy.kisky@boundarydevices.com> --- 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 */ -- 2.5.0
WARNING: multiple messages have this Message-ID (diff)
From: troy.kisky@boundarydevices.com (Troy Kisky) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 35/40] net: fec: rename dirty_tx to pending_tx Date: Thu, 28 Jan 2016 14:25:59 -0700 [thread overview] Message-ID: <1454016364-30985-36-git-send-email-troy.kisky@boundarydevices.com> (raw) In-Reply-To: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> 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 <troy.kisky@boundarydevices.com> --- 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 */ -- 2.5.0
next prev parent reply other threads:[~2016-01-28 21:29 UTC|newest] Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-01-28 21:25 [PATCH net-next 00/40] net: fec: cleanup/fixes Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 01/40] net: fec: stop the "rcv is not +last, " error messages Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 02/40] net: fec: fix rx error counts Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 03/40] net: fec: fix fec_enet_get_free_txdesc_num Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 04/40] net: fec: add struct bufdesc_prop Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 05/40] net: fec: add variable reg_desc_active to speed things up Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 06/40] net: fec: don't disable FEC_ENET_TS_TIMER interrupt Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 07/40] net: fec: don't transfer ownership until descriptor write is complete Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 08/40] net: fec: move cbd_bufaddr assignment closer to the mapping function Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 22:02 ` Arnd Bergmann 2016-01-28 22:02 ` Arnd Bergmann 2016-01-28 22:14 ` Johannes Berg 2016-01-28 22:14 ` Johannes Berg 2016-01-29 17:49 ` Troy Kisky 2016-01-29 17:49 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 09/40] net: fec: only check queue 0 if RXF_0/TXF_0 interrupt is set Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 10/40] net: fec: pass rxq to fec_enet_rx_queue instead of queue_id Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 11/40] net: fec: pass txq to fec_enet_tx_queue " Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 12/40] net: fec: reduce interrupts Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 13/40] net: fec: split off napi routine with 3 queues Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 14/40] net: fec: don't clear all rx queue bits when just one is being checked Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 15/40] net: fec: set cbd_sc without relying on previous value Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 16/40] net: fec: eliminate calls to fec_enet_get_prevdesc Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 17/40] net: fec: move restart test for efficiency Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 18/40] net: fec: clear cbd_sc after transmission to help with debugging Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 19/40] net: fec: dump all tx queues in fec_dump Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 20/40] net: fec: detect tx int lost Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 21/40] net: fec: print more debug info in fec_timeout Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 22/40] net: fec: call dma_unmap_single on mapped tx buffers at restart Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 23/40] net: fec: don't set cbd_bufaddr unless no mapping error Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 24/40] net: fec: return NETDEV_TX_BUSY, when not enough space in ring Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 25/40] net: fec: don't free skb until it has been unmapped Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 26/40] net: fec: set cbd_esc only once Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 27/40] net: fec: enable interrupt on very last descriptor only Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 28/40] net: fec: unmap initial buffer on error Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 29/40] net: fec: don't free skb when returning busy Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 30/40] net: fec: move last_bdp assignment for symmetry Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 31/40] net: fec: don't transfer ownership until entire tso is queued Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 32/40] net: fec: fix err_release in fec_enet_txq_submit_tso Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 33/40] net: fec: shrink the window for 'tx int lost' Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` [PATCH net-next 34/40] net: fec: update dirty_tx even if no skb Troy Kisky 2016-01-28 21:25 ` Troy Kisky 2016-01-28 21:25 ` Troy Kisky [this message] 2016-01-28 21:25 ` [PATCH net-next 35/40] net: fec: rename dirty_tx to pending_tx Troy Kisky 2016-01-28 21:26 ` [PATCH net-next 36/40] net: fec: use mac set by bootloader before fuses Troy Kisky 2016-01-28 21:26 ` Troy Kisky 2016-01-28 21:26 ` [PATCH net-next 37/40] net: fec: add events device file Troy Kisky 2016-01-28 21:26 ` Troy Kisky 2016-01-28 21:26 ` [PATCH net-next 38/40] net: fec: recover from lost rxf_0 interrupt Troy Kisky 2016-01-28 21:26 ` Troy Kisky 2016-01-28 21:26 ` [PATCH net-next 39/40] ARM: dts: imx6qdl-nitrogen6x: add phy interrupt to eliminate polling Troy Kisky 2016-01-28 21:26 ` Troy Kisky 2016-02-01 14:03 ` Shawn Guo 2016-02-01 14:03 ` Shawn Guo 2016-01-28 21:26 ` [PATCH net-next 40/40] ARM: dts: imx6qdl-nitrogen6_max: " Troy Kisky 2016-01-28 21:26 ` Troy Kisky 2016-02-01 14:04 ` Shawn Guo 2016-02-01 14:04 ` Shawn Guo 2016-01-28 22:39 ` [PATCH net-next 00/40] net: fec: cleanup/fixes David Miller 2016-01-28 22:39 ` David Miller [not found] ` <CAGB=+3Sip-+2Qf-KTZfoCCBcO9=9tb=pVCaEs=+eNJ1sWSRgXw@mail.gmail.com> 2016-01-29 0:19 ` David Miller 2016-01-29 0:19 ` David Miller
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1454016364-30985-36-git-send-email-troy.kisky@boundarydevices.com \ --to=troy.kisky@boundarydevices.com \ --cc=B38611@freescale.com \ --cc=andrew@lunn.ch \ --cc=davem@davemloft.net \ --cc=fabio.estevam@freescale.com \ --cc=l.stach@pengutronix.de \ --cc=laci@boundarydevices.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux@arm.linux.org.uk \ --cc=netdev@vger.kernel.org \ --cc=shawnguo@kernel.org \ --cc=tremyfr@gmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.