netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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, johannes@sipsolutions.net,
	stillcompiling@gmail.com, sergei.shtylyov@cogentembedded.com,
	arnd@arndb.de, Troy Kisky <troy.kisky@boundarydevices.com>
Subject: [PATCH net-next V2 07/16] net: fec: set cbd_sc without relying on previous value
Date: Wed, 24 Feb 2016 17:36:50 -0700	[thread overview]
Message-ID: <1456360619-24390-8-git-send-email-troy.kisky@boundarydevices.com> (raw)
In-Reply-To: <1456360619-24390-1-git-send-email-troy.kisky@boundarydevices.com>

Relying on the wrap bit to stay valid once initialized
when the controller also writes to this byte seems
undesirable since we can easily know what the value
should be.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 38 +++++++++----------------------
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 791f385..6ceb5f9 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -340,9 +340,8 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
 		bdp = fec_enet_get_nextdesc(bdp, &txq->bd);
 		ebdp = (struct bufdesc_ex *)bdp;
 
-		status = fec16_to_cpu(bdp->cbd_sc);
-		status &= ~BD_ENET_TX_STATS;
-		status |= (BD_ENET_TX_TC | BD_ENET_TX_READY);
+		status = BD_ENET_TX_TC | BD_ENET_TX_READY |
+				((bdp == txq->bd.last) ? BD_SC_WRAP : 0);
 		frag_len = skb_shinfo(skb)->frags[frag].size;
 
 		/* Handle the last BD specially */
@@ -436,8 +435,6 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
 	/* Fill in a Tx ring entry */
 	bdp = txq->bd.cur;
 	last_bdp = bdp;
-	status = fec16_to_cpu(bdp->cbd_sc);
-	status &= ~BD_ENET_TX_STATS;
 
 	/* Set buffer length and buffer pointer */
 	bufaddr = skb->data;
@@ -462,6 +459,8 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
 		return NETDEV_TX_OK;
 	}
 
+	status = BD_ENET_TX_TC | BD_ENET_TX_READY |
+			((bdp == txq->bd.last) ? BD_SC_WRAP : 0);
 	if (nr_frags) {
 		last_bdp = fec_enet_txq_submit_frag_skb(txq, skb, ndev);
 		if (IS_ERR(last_bdp)) {
@@ -512,7 +511,6 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq,
 	/* Send it on its way.  Tell FEC it's ready, interrupt when done,
 	 * it's the last BD of the frame, and to put the CRC on the end.
 	 */
-	status |= (BD_ENET_TX_READY | BD_ENET_TX_TC);
 	bdp->cbd_sc = cpu_to_fec16(status);
 
 	/* If this was the last BD in the ring, start at the beginning again. */
@@ -544,11 +542,6 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
 	unsigned int estatus = 0;
 	dma_addr_t addr;
 
-	status = fec16_to_cpu(bdp->cbd_sc);
-	status &= ~BD_ENET_TX_STATS;
-
-	status |= (BD_ENET_TX_TC | BD_ENET_TX_READY);
-
 	if (((unsigned long) data) & fep->tx_align ||
 		fep->quirks & FEC_QUIRK_SWAP_FRAME) {
 		memcpy(txq->tx_bounce[index], data, size);
@@ -578,15 +571,16 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,
 		ebdp->cbd_esc = cpu_to_fec32(estatus);
 	}
 
+	status = BD_ENET_TX_TC | BD_ENET_TX_READY |
+			((bdp == txq->bd.last) ? BD_SC_WRAP : 0);
 	/* Handle the last BD specially */
 	if (last_tcp)
-		status |= (BD_ENET_TX_LAST | BD_ENET_TX_TC);
+		status |= BD_ENET_TX_LAST;
 	if (is_last) {
 		status |= BD_ENET_TX_INTR;
 		if (fep->bufdesc_ex)
 			ebdp->cbd_esc |= cpu_to_fec32(BD_ENET_TX_INT);
 	}
-
 	bdp->cbd_sc = cpu_to_fec16(status);
 
 	return 0;
@@ -602,13 +596,8 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
 	struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc);
 	void *bufaddr;
 	unsigned long dmabuf;
-	unsigned short status;
 	unsigned int estatus = 0;
 
-	status = fec16_to_cpu(bdp->cbd_sc);
-	status &= ~BD_ENET_TX_STATS;
-	status |= (BD_ENET_TX_TC | BD_ENET_TX_READY);
-
 	bufaddr = txq->tso_hdrs + index * TSO_HEADER_SIZE;
 	dmabuf = txq->tso_hdrs_dma + index * TSO_HEADER_SIZE;
 	if (((unsigned long)bufaddr) & fep->tx_align ||
@@ -641,8 +630,8 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,
 		ebdp->cbd_esc = cpu_to_fec32(estatus);
 	}
 
-	bdp->cbd_sc = cpu_to_fec16(status);
-
+	bdp->cbd_sc = cpu_to_fec16(BD_ENET_TX_TC | BD_ENET_TX_READY |
+			((bdp == txq->bd.last) ? BD_SC_WRAP : 0));
 	return 0;
 }
 
@@ -1453,12 +1442,6 @@ static int fec_rxq(struct net_device *ndev, struct fec_enet_private *fep,
 		}
 
 rx_processing_done:
-		/* Clear the status flags for this buffer */
-		status &= ~BD_ENET_RX_STATS;
-
-		/* Mark the buffer empty */
-		status |= BD_ENET_RX_EMPTY;
-
 		if (fep->bufdesc_ex) {
 			struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp;
 
@@ -1470,7 +1453,8 @@ rx_processing_done:
 		 * performed before transferring ownership.
 		 */
 		wmb();
-		bdp->cbd_sc = cpu_to_fec16(status);
+		bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY |
+				((bdp == rxq->bd.last) ? BD_SC_WRAP : 0));
 
 		/* Update BD pointer to next entry */
 		bdp = fec_enet_get_nextdesc(bdp, &rxq->bd);
-- 
2.5.0

  parent reply	other threads:[~2016-02-25  0:40 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25  0:36 [PATCH net-next V2 00/16] net: fec: cleanup and fixes Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 01/16] net: fec: only check queue 0 if RXF_0/TXF_0 interrupt is set Troy Kisky
2016-03-02 14:57   ` Fugang Duan
2016-02-25  0:36 ` [PATCH net-next V2 02/16] net: fec: pass rxq to fec_enet_rx_queue instead of queue_id Troy Kisky
2016-03-01 21:05   ` Zhi Li
2016-03-02 15:01   ` Fugang Duan
2016-02-25  0:36 ` [PATCH net-next V2 03/16] net: fec: pass txq to fec_enet_tx_queue " Troy Kisky
2016-03-01 21:06   ` Zhi Li
2016-03-01 21:51     ` Troy Kisky
2016-03-01 22:26       ` Zhi Li
2016-03-01 22:43         ` Troy Kisky
2016-03-02 15:16   ` Fugang Duan
2016-03-02 16:13     ` Troy Kisky
2016-03-04  7:41       ` Fugang Duan
2016-03-04 16:23         ` Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 04/16] net: fec: reduce interrupts Troy Kisky
2016-03-02 15:13   ` Fugang Duan
2016-03-02 16:12     ` Troy Kisky
2016-03-02 16:44       ` Zhi Li
2016-03-02 16:47       ` Zhi Li
2016-03-02 22:32         ` Troy Kisky
2016-03-02 22:52           ` Zhi Li
2016-03-04  8:58   ` Fugang Duan
2016-02-25  0:36 ` [PATCH net-next V2 05/16] net: fec: split off napi routine with 3 queues Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 06/16] net: fec: don't clear all rx queue bits when just one is being checked Troy Kisky
2016-03-04  9:11   ` Fugang Duan
2016-03-04 16:18     ` Troy Kisky
2016-03-04 16:38       ` Russell King - ARM Linux
2016-03-04 17:28         ` Troy Kisky
2016-02-25  0:36 ` Troy Kisky [this message]
2016-03-04  9:29   ` [PATCH net-next V2 07/16] net: fec: set cbd_sc without relying on previous value Fugang Duan
2016-03-04 16:08     ` Troy Kisky
2016-03-05 23:55       ` Fugang Duan
2016-02-25  0:36 ` [PATCH net-next V2 08/16] net: fec: eliminate calls to fec_enet_get_prevdesc Troy Kisky
2016-03-04  9:33   ` Fugang Duan
2016-03-04 16:05     ` Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 09/16] net: fec: move restart test for efficiency Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 10/16] net: fec: clear cbd_sc after transmission to help with debugging Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 11/16] net: fec: dump all tx queues in fec_dump Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 12/16] net: fec: detect tx int lost Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 13/16] net: fec: print more debug info in fec_timeout Troy Kisky
2016-03-04 10:06   ` Fugang Duan
2016-03-04 16:05     ` Troy Kisky
2016-03-04 17:35       ` Joe Perches
2016-03-04 19:06         ` Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 14/16] net: fec: create subroutine reset_tx_queue Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 15/16] net: fec: call dma_unmap_single on mapped tx buffers at restart Troy Kisky
2016-02-25  0:36 ` [PATCH net-next V2 16/16] net: fec: don't set cbd_bufaddr unless no mapping error Troy Kisky
2016-02-25  2:52 ` [PATCH net-next V2 00/16] net: fec: cleanup and fixes Joshua Clayton
2016-02-25 16:05   ` Troy Kisky
2016-02-25 16:49     ` Joshua Clayton
2016-02-25  8:39 ` Holger Schurig
2016-02-25 15:57   ` Troy Kisky

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=1456360619-24390-8-git-send-email-troy.kisky@boundarydevices.com \
    --to=troy.kisky@boundarydevices.com \
    --cc=B38611@freescale.com \
    --cc=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=fabio.estevam@freescale.com \
    --cc=johannes@sipsolutions.net \
    --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=sergei.shtylyov@cogentembedded.com \
    --cc=shawnguo@kernel.org \
    --cc=stillcompiling@gmail.com \
    --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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).