All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Alexander Aring <alex.aring@gmail.com>,
	Stefan Schmidt <stefan@datenfreihafen.org>,
	linux-wpan@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, David Girault <david.girault@qorvo.com>,
	Romuald Despres <romuald.despres@qorvo.com>,
	Frederic Blain <frederic.blain@qorvo.com>,
	Nicolas Schodet <nico@ni.fr.eu.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: [PATCH wpan-next v3 06/11] net: ieee802154: at86rf230: Return early in case of error
Date: Thu,  3 Mar 2022 19:25:03 +0100	[thread overview]
Message-ID: <20220303182508.288136-7-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20220303182508.288136-1-miquel.raynal@bootlin.com>

The TRAC register is only parsed in the Tx path if the debugfs entry is
enabled. This does not look like a good idea because this register gives
us the actual status of the transmitted packet.

Let's always check the content of this register and error out when
appropriate.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/net/ieee802154/at86rf230.c | 49 ++++++++++++++++--------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 616acfa8cd28..12ee071057d2 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -673,33 +673,36 @@ at86rf230_tx_trac_check(void *context)
 	struct at86rf230_state_change *ctx = context;
 	struct at86rf230_local *lp = ctx->lp;
 
-	if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
-		u8 trac = TRAC_MASK(ctx->buf[1]);
+	u8 trac = TRAC_MASK(ctx->buf[1]);
 
-		switch (trac) {
-		case TRAC_SUCCESS:
-			lp->trac.success++;
-			break;
-		case TRAC_SUCCESS_DATA_PENDING:
-			lp->trac.success_data_pending++;
-			break;
-		case TRAC_CHANNEL_ACCESS_FAILURE:
-			lp->trac.channel_access_failure++;
-			break;
-		case TRAC_NO_ACK:
-			lp->trac.no_ack++;
-			break;
-		case TRAC_INVALID:
-			lp->trac.invalid++;
-			break;
-		default:
-			WARN_ONCE(1, "received tx trac status %d\n", trac);
-			lp->trac.invalid++;
-			break;
-		}
+	switch (trac) {
+	case TRAC_SUCCESS:
+		lp->trac.success++;
+		break;
+	case TRAC_SUCCESS_DATA_PENDING:
+		lp->trac.success_data_pending++;
+		break;
+	case TRAC_CHANNEL_ACCESS_FAILURE:
+		lp->trac.channel_access_failure++;
+		goto failure;
+	case TRAC_NO_ACK:
+		lp->trac.no_ack++;
+		goto failure;
+	case TRAC_INVALID:
+		lp->trac.invalid++;
+		goto failure;
+	default:
+		WARN_ONCE(1, "received tx trac status %d\n", trac);
+		lp->trac.invalid++;
+		goto failure;
 	}
 
 	at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_tx_on);
+
+	return;
+
+failure:
+	at86rf230_async_error(lp, ctx, -EIO);
 }
 
 static void
-- 
2.27.0


  parent reply	other threads:[~2022-03-03 18:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 18:24 [PATCH wpan-next v3 00/11] ieee802154: Better Tx error handling Miquel Raynal
2022-03-03 18:24 ` [PATCH wpan-next v3 01/11] net: ieee802154: Enhance/fix the names of the MLME return codes Miquel Raynal
2022-03-03 18:24 ` [PATCH wpan-next v3 02/11] net: ieee802154: Fill the list of " Miquel Raynal
2022-03-03 18:25 ` [PATCH wpan-next v3 03/11] net: mac802154: Create a transmit error helper Miquel Raynal
2022-03-04  4:30   ` Jakub Kicinski
2022-03-04  8:04     ` Miquel Raynal
2022-03-03 18:25 ` [PATCH wpan-next v3 04/11] net: mac802154: Save a global error code on transmissions Miquel Raynal
2022-03-03 18:25 ` [PATCH wpan-next v3 05/11] net: ieee802154: at86rf230: Assume invalid TRAC if not recognized Miquel Raynal
2022-03-13 20:06   ` Alexander Aring
2022-03-03 18:25 ` Miquel Raynal [this message]
2022-03-03 18:25 ` [PATCH wpan-next v3 07/11] net: ieee802154: at86rf230: Provide meaningful error codes when possible Miquel Raynal
2022-03-13 20:16   ` Alexander Aring
2022-03-18  7:56     ` Miquel Raynal
2022-03-03 18:25 ` [PATCH wpan-next v3 08/11] net: ieee802154: at86rf230: Call _xmit_error() when a transmission fails Miquel Raynal
2022-03-03 18:25 ` [PATCH wpan-next v3 09/11] net: ieee802154: atusb: " Miquel Raynal
2022-03-13 20:20   ` Alexander Aring
2022-03-18  7:57     ` Miquel Raynal
2022-03-03 18:25 ` [PATCH wpan-next v3 10/11] net: ieee802154: ca8210: Use core return codes instead of hardcoding them Miquel Raynal
2022-03-03 18:25 ` [PATCH wpan-next v3 11/11] net: ieee802154: ca8210: Call _xmit_error() when a transmission fails Miquel Raynal

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=20220303182508.288136-7-miquel.raynal@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=alex.aring@gmail.com \
    --cc=davem@davemloft.net \
    --cc=david.girault@qorvo.com \
    --cc=frederic.blain@qorvo.com \
    --cc=kuba@kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nico@ni.fr.eu.org \
    --cc=romuald.despres@qorvo.com \
    --cc=stefan@datenfreihafen.org \
    --cc=thomas.petazzoni@bootlin.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 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.