[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK-6q+gkMbf7HGFWtaB2QX9z10dvbk2ac28to3TMUDS9MdWuvA@mail.gmail.com>
Date: Tue, 3 May 2022 20:40:20 -0400
From: Alexander Aring <aahringo@...hat.com>
To: Miquel Raynal <miquel.raynal@...tlin.com>
Cc: Alexander Aring <alex.aring@...il.com>,
Stefan Schmidt <stefan@...enfreihafen.org>,
linux-wpan@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Network Development <netdev@...r.kernel.org>,
David Girault <david.girault@...vo.com>,
Romuald Despres <romuald.despres@...vo.com>,
Frederic Blain <frederic.blain@...vo.com>,
Nicolas Schodet <nico@...fr.eu.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH wpan-next 10/11] net: mac802154: Introduce a tx queue
flushing mechanism
Hi,
On Wed, Apr 27, 2022 at 12:55 PM Miquel Raynal
<miquel.raynal@...tlin.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@...tlin.com>
> ---
> include/net/cfg802154.h | 1 +
> net/ieee802154/core.c | 1 +
> net/mac802154/cfg.c | 3 +--
> net/mac802154/ieee802154_i.h | 1 +
> net/mac802154/tx.c | 24 +++++++++++++++++++++++-
> net/mac802154/util.c | 7 +++++--
> 6 files changed, 32 insertions(+), 5 deletions(-)
>
> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> index 043d8e4359e7..0d385a214da3 100644
> --- a/include/net/cfg802154.h
> +++ b/include/net/cfg802154.h
> @@ -217,6 +217,7 @@ struct wpan_phy {
> /* Transmission monitoring and control */
> 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 de259b5170ab..0953cacafbff 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);
>
> return &rdev->wpan_phy;
> }
> diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
> index 0540a2b014d2..c17e38bef425 100644
> --- a/net/mac802154/cfg.c
> +++ b/net/mac802154/cfg.c
> @@ -46,8 +46,7 @@ static int ieee802154_suspend(struct wpan_phy *wpan_phy)
> if (!local->open_count)
> goto suspend;
>
> - ieee802154_hold_queue(local);
> - ieee802154_stop_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 c686a027555a..c87c7fa04435 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 021dddfea542..5f94973b57e4 100644
> --- a/net/mac802154/tx.c
> +++ b/net/mac802154/tx.c
> @@ -45,7 +45,8 @@ void ieee802154_xmit_sync_worker(struct work_struct *work)
> /* Restart the netif queue on each sub_if_data object. */
> ieee802154_wake_queue(local);
> kfree_skb(skb);
> - atomic_dec(&local->phy->ongoing_txs);
> + if (!atomic_dec_and_test(&local->phy->ongoing_txs))
> + wake_up(&local->phy->sync_txq);
> netdev_dbg(dev, "transmission failed\n");
> }
There is a missing handling of dec() wake_up() in ieee802154_tx()
"err_tx" label.
- Alex
Powered by blists - more mailing lists