From: Alexander Aring <aahringo@redhat.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Alexander Aring <alex.aring@gmail.com>,
Stefan Schmidt <stefan@datenfreihafen.org>,
linux-wpan - ML <linux-wpan@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Network Development <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>
Subject: Re: [PATCH wpan-next v2 08/11] net: mac802154: Introduce a tx queue flushing mechanism
Date: Sun, 15 May 2022 18:23:04 -0400 [thread overview]
Message-ID: <CAK-6q+iazXHZmf2vteXGEEpSXLLp9279g5JD2whBn-_FPL0piw@mail.gmail.com> (raw)
In-Reply-To: <20220512143314.235604-9-miquel.raynal@bootlin.com>
Hi,
On Thu, May 12, 2022 at 10:34 AM Miquel Raynal
<miquel.raynal@bootlin.com> wrote:
>
> Right now we are able to stop a queue but we have no indication if a
> transmission is ongoing or not.
>
> Thanks to recent additions, we can track the number of ongoing
> transmissions so we know if the last transmission is over. Adding on top
> of it an internal wait queue also allows to be woken up asynchronously
> when this happens. If, beforehands, we marked the queue to be held and
> stopped it, we end up flushing and stopping the tx queue.
>
> Thanks to this feature, we will soon be able to introduce a synchronous
> transmit API.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> include/net/cfg802154.h | 1 +
> net/ieee802154/core.c | 1 +
> net/mac802154/cfg.c | 2 +-
> net/mac802154/ieee802154_i.h | 1 +
> net/mac802154/tx.c | 26 ++++++++++++++++++++++++--
> net/mac802154/util.c | 6 ++++--
> 6 files changed, 32 insertions(+), 5 deletions(-)
>
> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> index ad3f438e4583..8b6326aa2d42 100644
> --- a/include/net/cfg802154.h
> +++ b/include/net/cfg802154.h
> @@ -218,6 +218,7 @@ struct wpan_phy {
> struct mutex queue_lock;
> atomic_t ongoing_txs;
> atomic_t hold_txs;
> + wait_queue_head_t sync_txq;
>
> char priv[] __aligned(NETDEV_ALIGN);
> };
> diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
> index d81b7301e013..f13e3082d988 100644
> --- a/net/ieee802154/core.c
> +++ b/net/ieee802154/core.c
> @@ -129,6 +129,7 @@ wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size)
> wpan_phy_net_set(&rdev->wpan_phy, &init_net);
>
> init_waitqueue_head(&rdev->dev_wait);
> + init_waitqueue_head(&rdev->wpan_phy.sync_txq);
>
> mutex_init(&rdev->wpan_phy.queue_lock);
>
> diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
> index b51100fd9e3f..93df24f75572 100644
> --- a/net/mac802154/cfg.c
> +++ b/net/mac802154/cfg.c
> @@ -46,7 +46,7 @@ static int ieee802154_suspend(struct wpan_phy *wpan_phy)
> if (!local->open_count)
> goto suspend;
>
> - ieee802154_hold_queue(local);
> + ieee802154_sync_and_hold_queue(local);
> synchronize_net();
>
> /* stop hardware - this must stop RX */
> diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
> index e34db1d49ef4..a057827fc48a 100644
> --- a/net/mac802154/ieee802154_i.h
> +++ b/net/mac802154/ieee802154_i.h
> @@ -124,6 +124,7 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
>
> void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb);
> void ieee802154_xmit_sync_worker(struct work_struct *work);
> +int ieee802154_sync_and_hold_queue(struct ieee802154_local *local);
> netdev_tx_t
> ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
> netdev_tx_t
> diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
> index 607019b8f8ab..38f74b8b6740 100644
> --- a/net/mac802154/tx.c
> +++ b/net/mac802154/tx.c
> @@ -44,7 +44,8 @@ void ieee802154_xmit_sync_worker(struct work_struct *work)
> err_tx:
> /* Restart the netif queue on each sub_if_data object. */
> ieee802154_release_queue(local);
> - atomic_dec(&local->phy->ongoing_txs);
> + if (!atomic_dec_and_test(&local->phy->ongoing_txs))
> + wake_up(&local->phy->sync_txq);
> kfree_skb(skb);
> netdev_dbg(dev, "transmission failed\n");
> }
> @@ -100,12 +101,33 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
>
> err_wake_netif_queue:
> ieee802154_release_queue(local);
> - atomic_dec(&local->phy->ongoing_txs);
> + if (!atomic_dec_and_test(&local->phy->ongoing_txs))
> + wake_up(&local->phy->sync_txq);
> err_free_skb:
> kfree_skb(skb);
> return NETDEV_TX_OK;
> }
>
> +static int ieee802154_sync_queue(struct ieee802154_local *local)
> +{
> + int ret;
> +
> + ieee802154_hold_queue(local);
> + ieee802154_disable_queue(local);
> + wait_event(local->phy->sync_txq, !atomic_read(&local->phy->ongoing_txs));
> + ret = local->tx_result;
> + ieee802154_release_queue(local);
I am curious, why this extra hold, release here?
- Alex
next prev parent reply other threads:[~2022-05-15 22:23 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-12 14:33 [PATCH wpan-next v2 00/11] ieee802154: Synchronous Tx support Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 01/11] net: mac802154: Rename the synchronous xmit worker Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 02/11] net: mac802154: Rename the main tx_work struct Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 03/11] net: mac802154: Enhance the error path in the main tx helper Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 04/11] net: mac802154: Follow the count of ongoing transmissions Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 05/11] net: mac802154: Bring the hability to hold the transmit queue Miquel Raynal
2022-05-15 22:19 ` Alexander Aring
2022-05-17 9:27 ` Miquel Raynal
2022-05-17 13:19 ` Alexander Aring
2022-05-17 13:28 ` Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 06/11] net: mac802154: Create a hot tx path Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 07/11] net: mac802154: Introduce a helper to disable the queue Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 08/11] net: mac802154: Introduce a tx queue flushing mechanism Miquel Raynal
2022-05-15 22:23 ` Alexander Aring [this message]
2022-05-17 13:20 ` Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 09/11] net: mac802154: Introduce a synchronous API for MLME commands Miquel Raynal
2022-05-15 22:28 ` Alexander Aring
2022-05-15 22:56 ` Alexander Aring
2022-05-15 23:03 ` Alexander Aring
2022-05-17 13:30 ` Miquel Raynal
2022-05-18 1:14 ` Alexander Aring
2022-05-18 10:12 ` Miquel Raynal
2022-05-18 12:05 ` Alexander Aring
2022-05-18 12:37 ` Miquel Raynal
2022-05-18 13:08 ` Alexander Aring
2022-05-18 16:12 ` Miquel Raynal
2022-05-19 1:51 ` Alexander Aring
2022-05-19 14:20 ` Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 10/11] net: mac802154: Add a warning in the hot path Miquel Raynal
2022-05-15 22:30 ` Alexander Aring
2022-05-17 13:36 ` Miquel Raynal
2022-05-17 14:52 ` Miquel Raynal
2022-05-18 0:59 ` Alexander Aring
2022-05-18 9:13 ` Miquel Raynal
2022-05-12 14:33 ` [PATCH wpan-next v2 11/11] net: mac802154: Add a warning in the slow path Miquel Raynal
2022-05-15 22:30 ` Alexander Aring
2022-05-17 13:45 ` 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=CAK-6q+iazXHZmf2vteXGEEpSXLLp9279g5JD2whBn-_FPL0piw@mail.gmail.com \
--to=aahringo@redhat.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=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=nico@ni.fr.eu.org \
--cc=pabeni@redhat.com \
--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 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).