All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, Alexander Aring <alex.aring@gmail.com>
Subject: [PATCH bluetooth-next 15/15] at86rf230: asynchronous xmit handling
Date: Sun, 26 Oct 2014 09:15:52 +0100	[thread overview]
Message-ID: <1414311352-908-16-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1414311352-908-1-git-send-email-alex.aring@gmail.com>

This patch converts the sync xmit handling into an async xmit handling. The
driver was already prepared for this step, all other drivers need more
work to implement a xmit_async function.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 42 +++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 06a3e90..0669783 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -91,7 +91,6 @@ struct at86rf230_local {
 	bool is_tx;
 	/* spinlock for is_tx protection */
 	spinlock_t lock;
-	struct completion tx_complete;
 	struct sk_buff *tx_skb;
 	struct at86rf230_state_change tx;
 };
@@ -452,6 +451,7 @@ at86rf230_async_error_recover(void *context)
 	struct at86rf230_local *lp = ctx->lp;
 
 	at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON, NULL, false);
+	ieee802154_wake_queue(lp->hw);
 }
 
 static void
@@ -715,9 +715,23 @@ at86rf230_tx_complete(void *context)
 {
 	struct at86rf230_state_change *ctx = context;
 	struct at86rf230_local *lp = ctx->lp;
+	struct sk_buff *skb = lp->tx_skb;
 
 	enable_irq(lp->spi->irq);
-	complete(&lp->tx_complete);
+
+	if (lp->max_frame_retries <= 0) {
+		/* Interfame spacing time, which is phy depend.
+		 * TODO
+		 * Move this handling in MAC 802.15.4 layer.
+		 * This is currently a workaround to avoid fragmenation issues.
+		 */
+		if (skb->len > 18)
+			udelay(lp->data->t_lifs);
+		else
+			udelay(lp->data->t_sifs);
+	}
+
+	ieee802154_xmit_complete(lp->hw, skb);
 }
 
 static void
@@ -975,7 +989,6 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
 	struct at86rf230_state_change *ctx = &lp->tx;
 
 	void (*tx_complete)(void *context) = at86rf230_write_frame;
-	int rc;
 
 	lp->tx_skb = skb;
 
@@ -988,26 +1001,6 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
 
 	at86rf230_async_state_change(lp, ctx, STATE_TX_ON, tx_complete, false);
 
-	rc = wait_for_completion_interruptible_timeout(&lp->tx_complete,
-						       msecs_to_jiffies(lp->data->t_tx_timeout));
-	if (!rc) {
-		at86rf230_async_error(lp, ctx, -ETIMEDOUT);
-		return -ETIMEDOUT;
-	}
-
-	if (lp->max_frame_retries > 0)
-		return 0;
-
-	/* Interfame spacing time, which is phy depend.
-	 * TODO
-	 * Move this handling in MAC 802.15.4 layer.
-	 * This is currently a workaround to avoid fragmenation issues.
-	 */
-	if (skb->len > 18)
-		usleep_range(lp->data->t_lifs, lp->data->t_lifs + 10);
-	else
-		usleep_range(lp->data->t_sifs, lp->data->t_sifs + 10);
-
 	return 0;
 }
 
@@ -1237,7 +1230,7 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
 
 static struct ieee802154_ops at86rf230_ops = {
 	.owner = THIS_MODULE,
-	.xmit_sync = at86rf230_xmit,
+	.xmit_async = at86rf230_xmit,
 	.ed = at86rf230_ed,
 	.set_channel = at86rf230_channel,
 	.start = at86rf230_start,
@@ -1541,7 +1534,6 @@ static int at86rf230_probe(struct spi_device *spi)
 		goto free_dev;
 
 	spin_lock_init(&lp->lock);
-	init_completion(&lp->tx_complete);
 	init_completion(&lp->state_complete);
 
 	spi_set_drvdata(spi, lp);
-- 
2.1.2


      parent reply	other threads:[~2014-10-26  8:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-26  8:15 [PATCH bluetooth-next 00/15] ieee802154: rework transmit handling Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 01/15] mac802154: tx: move xmit callback to tx file Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 02/15] mac802154: tx: remove kmalloc in xmit hotpath Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 03/15] mac802154: tx: squash multiple dereferencing Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 04/15] mac802154: tx: remove xmit channel context switch Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 05/15] mac802154: add netdev qeue helpers Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 06/15] mac802154: tx: use queue helpers in xmit worker Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 07/15] mac802154: tx: fix error handling while xmit Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 08/15] mac802154: tx: add support for xmit_async callback Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 09/15] mac802154: tx: don't allow if down while sync tx Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 10/15] mac802154: tx: use netdev print helpers Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 11/15] mac802154: tx: cleanup crc calculation Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 12/15] mac802154: tx: move stats tx increment Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 13/15] mac802154: tx: change naming convention Alexander Aring
2014-10-26  8:15 ` [PATCH bluetooth-next 14/15] mac802154: tx: add comment at sync xmit callback Alexander Aring
2014-10-26  8:25   ` Alexander Aring
2014-10-26  8:15 ` Alexander Aring [this message]

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=1414311352-908-16-git-send-email-alex.aring@gmail.com \
    --to=alex.aring@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-wpan@vger.kernel.org \
    /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.