From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 75EAE3B29D for ; Fri, 4 Mar 2022 07:43:12 -0500 (EST) Received: by mail-ej1-x62c.google.com with SMTP id bg10so17267222ejb.4 for ; Fri, 04 Mar 2022 04:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=p7EupcnfYrgUODzGV98FrtuLSQyfEwHnDWlTZnD3o7Q=; b=njV2+59C5f7+ZYhpRjVeEB2DHwCUo9d8C5XZuyZe78OftVwvbpxvSr/rHW+5d51YuH EmUepoI+waoMdYMBUvLzgLjAAtZ+QP9qjhT4fMQtGbECAGX2a+O5V/yYFmcli3JkfCp1 TtmTsO7a2Qau8GxCRbIATH+gkXCtULaNU0zVOfgDA5oCCwf5h+5T3U2o0QyGzzxDi3C4 cVRBJeWdYY/kuwuh7QbcyaeI0aBwxSY3o5zMn89n6S0o3tL/J24J8goeALImAzJm/Rxl 3P5h8186t5+6KGNVzaBwNDX+PM3LNYC4RwgXGQQbUcuF6ir5cjRL3Uo/XYaUjDWvQQPJ WkMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=p7EupcnfYrgUODzGV98FrtuLSQyfEwHnDWlTZnD3o7Q=; b=3deUQBen6TzTDZz9BUNOyEFzs12esc3VCJKHyNgcM0a/Lush2w0XoTbUEz2IybH5wW zn0j4LeTY2XC/f51dOJZf6hBvKMI7XsBy+nnjlg7GFnZCzV3jwxt1PgjtI+ufb6pNuXu fsKpyLjET1sKr8lAO5VikZwXpY1c/n3GRyzc3lYQRbdhFDvOV78LqxXZu/PK4wPG622R sXv/K0qMe7uwoLAqnFNhZQg83KcYVf9P4PjdFbDLDHqH2+dxjWtC2JmrxT6m+pI1NaKm IYCB5hQwEzbyTdQKANk98k7jFa1GVuu1WV6szGqYDGZfBI8/TBs3mZcwoHQvOZzJt81r hTiQ== X-Gm-Message-State: AOAM532hkZnm77DRMGZNxHVUMGhYETt5bJHgw+Iyu1cjrqrIdTXw8ZXo TFnqM5q/ettl5JgK14zsobAhsvYIX4vBURiPVht6r2Ia X-Google-Smtp-Source: ABdhPJxfPfIhF4L46LwMANw2BSKhBoRI8xvqs0r9StVkhiuFr8mZcrdKCr3ADy7K8WsDCkkTI1V0vmsFqulns8gm47g= X-Received: by 2002:a17:907:d93:b0:6da:bb7a:4da with SMTP id go19-20020a1709070d9300b006dabb7a04damr1877824ejc.183.1646397791123; Fri, 04 Mar 2022 04:43:11 -0800 (PST) MIME-Version: 1.0 References: <20220207144804.708118-1-miquel.raynal@bootlin.com> <20220207144804.708118-14-miquel.raynal@bootlin.com> In-Reply-To: <20220207144804.708118-14-miquel.raynal@bootlin.com> From: Dave Taht Date: Fri, 4 Mar 2022 07:42:57 -0500 Message-ID: To: Make-Wifi-fast Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [Make-wifi-fast] Fwd: [PATCH wpan-next v2 13/14] net: mac802154: Introduce a tx queue flushing mechanism X-BeenThere: make-wifi-fast@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Mar 2022 12:43:12 -0000 ---------- Forwarded message --------- From: Miquel Raynal Date: Wed, Feb 9, 2022 at 4:00 AM Subject: [PATCH wpan-next v2 13/14] net: mac802154: Introduce a tx queue flushing mechanism To: Alexander Aring , Stefan Schmidt , Cc: David S. Miller , Jakub Kicinski , , David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal 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 --- include/net/cfg802154.h | 1 + net/ieee802154/core.c | 1 + net/mac802154/cfg.c | 5 ++--- net/mac802154/ieee802154_i.h | 1 + net/mac802154/tx.c | 11 ++++++++++- net/mac802154/util.c | 3 ++- 6 files changed, 17 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 e8aabf215286..da94aaa32fcb 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; - atomic_inc(&wpan_phy->hold_txs); - ieee802154_stop_queue(&local->hw); + ieee802154_sync_and_stop_tx(local); synchronize_net(); /* stop hardware - this must stop RX */ @@ -73,7 +72,7 @@ static int ieee802154_resume(struct wpan_phy *wpan_phy) return ret; wake_up: - if (!atomic_dec_and_test(&wpan_phy->hold_txs)) + if (!atomic_read(&wpan_phy->hold_txs)) ieee802154_wake_queue(&local->hw); local->suspended =3D false; return 0; diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 56fcd7ef5b6f..295c9ce091e1 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -122,6 +122,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); +void ieee802154_sync_and_stop_tx(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 abd9a057521e..06ae2e6cea43 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -47,7 +47,8 @@ void ieee802154_xmit_sync_worker(struct work_struct *work= ) ieee802154_wake_queue(&local->hw); 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"); } @@ -117,6 +118,14 @@ ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb) return ieee802154_tx(local, skb); } +void ieee802154_sync_and_stop_tx(struct ieee802154_local *local) +{ + atomic_inc(&local->phy->hold_txs); + ieee802154_stop_queue(&local->hw); + wait_event(local->phy->sync_txq, !atomic_read(&local->phy->ongoing_txs)); + atomic_dec(&local->phy->hold_txs); +} + netdev_tx_t ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev) { diff --git a/net/mac802154/util.c b/net/mac802154/util.c index cc572c12a8f9..e666ac7a16bd 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -93,7 +93,8 @@ static void ieee802154_xmit_end(struct ieee802154_hw *hw, bool ifs_handling, if (!mac802154_queue_is_stopped(local)) ieee802154_wakeup_after_xmit_done(hw, ifs_handling, skb_len= ); - atomic_dec(&hw->phy->ongoing_txs); + if (!atomic_dec_and_test(&hw->phy->ongoing_txs)) + wake_up(&hw->phy->sync_txq); } void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *sk= b, -- 2.27.0 --=20 I tried to build a better future, a few times: https://wayforward.archive.org/?site=3Dhttps%3A%2F%2Fwww.icei.org Dave T=C3=A4ht CEO, TekLibre, LLC