From patchwork Wed Apr 27 16:46:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 836CBC433FE for ; Wed, 27 Apr 2022 16:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243438AbiD0QuT (ORCPT ); Wed, 27 Apr 2022 12:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243385AbiD0QuR (ORCPT ); Wed, 27 Apr 2022 12:50:17 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B8812D28A9; Wed, 27 Apr 2022 09:47:05 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 17C2A10000C; Wed, 27 Apr 2022 16:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I/cuTyMCze0n5qYU5HkcXz/EVFulTr5jEuFTHRjxkZI=; b=ESN9hD81MjrhU1lR9GGrSNJhGzsbnQgb7huAwPzGPrUUlgWniUwZmSE0q42aSmCet7slC8 2ox2bblDTLGQD9oUUzm9jTXrH0Zl71DBCB9W0jEo4zh2bQDCFJadLn2UDsRQQ+Dj7p8iu3 sNmgB4tJydj3USVeaVdYFl4aKETPLN9E7Af79Y1kKyJhQ7vAn52TGICNqf8ETBoJIY4orf cooFqbYslgVTNmcVME0YzM973T0kcUQxFw4JLEowZfOy/XJ6wnA9NYG0hL4SPZ1NoRetn2 HwIs3G02+BAKo3gSF/jzXdniCf9iZuCGcBc3KPBSrReAhafSEYILGZ0nV3dLYw== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 01/11] net: mac802154: Stop exporting ieee802154_wake/stop_queue() Date: Wed, 27 Apr 2022 18:46:49 +0200 Message-Id: <20220427164659.106447-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org Individual drivers do not necessarily need to call these helpers manually. There are other functions, more suited for this purpose, that will do that for them. The advantage is that, as no more drivers call these, it eases the tracking of the ongoing transfers that we are about to introduce while keeping the possibility to bypass thse counters from core code. Signed-off-by: Miquel Raynal --- include/net/mac802154.h | 27 --------------------------- net/mac802154/ieee802154_i.h | 24 ++++++++++++++++++++++++ net/mac802154/util.c | 2 -- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/include/net/mac802154.h b/include/net/mac802154.h index bdac0ddbdcdb..357d25ef627a 100644 --- a/include/net/mac802154.h +++ b/include/net/mac802154.h @@ -460,33 +460,6 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw); */ void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi); -/** - * ieee802154_wake_queue - wake ieee802154 queue - * @hw: pointer as obtained from ieee802154_alloc_hw(). - * - * Tranceivers usually have either one transmit framebuffer or one framebuffer - * for both transmitting and receiving. Hence, the core currently only handles - * one frame at a time for each phy, which means we had to stop the queue to - * avoid new skb to come during the transmission. The queue then needs to be - * woken up after the operation. - * - * Drivers should use this function instead of netif_wake_queue. - */ -void ieee802154_wake_queue(struct ieee802154_hw *hw); - -/** - * ieee802154_stop_queue - stop ieee802154 queue - * @hw: pointer as obtained from ieee802154_alloc_hw(). - * - * Tranceivers usually have either one transmit framebuffer or one framebuffer - * for both transmitting and receiving. Hence, the core currently only handles - * one frame at a time for each phy, which means we need to tell upper layers to - * stop giving us new skbs while we are busy with the transmitted one. The queue - * must then be stopped before transmitting. - * - * Drivers should use this function instead of netif_stop_queue. - */ -void ieee802154_stop_queue(struct ieee802154_hw *hw); /** * ieee802154_xmit_complete - frame transmission complete diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 1381e6a5e180..83f5ccd1ca0f 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -130,6 +130,30 @@ netdev_tx_t ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer); +/** + * ieee802154_wake_queue - wake ieee802154 queue + * @hw: pointer as obtained from ieee802154_alloc_hw(). + * + * Tranceivers usually have either one transmit framebuffer or one framebuffer + * for both transmitting and receiving. Hence, the core currently only handles + * one frame at a time for each phy, which means we had to stop the queue to + * avoid new skb to come during the transmission. The queue then needs to be + * woken up after the operation. + */ +void ieee802154_wake_queue(struct ieee802154_hw *hw); + +/** + * ieee802154_stop_queue - stop ieee802154 queue + * @hw: pointer as obtained from ieee802154_alloc_hw(). + * + * Tranceivers usually have either one transmit framebuffer or one framebuffer + * for both transmitting and receiving. Hence, the core currently only handles + * one frame at a time for each phy, which means we need to tell upper layers to + * stop giving us new skbs while we are busy with the transmitted one. The queue + * must then be stopped before transmitting. + */ +void ieee802154_stop_queue(struct ieee802154_hw *hw); + /* MIB callbacks */ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan); diff --git a/net/mac802154/util.c b/net/mac802154/util.c index 9f024d85563b..15a46b56d85a 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -27,7 +27,6 @@ void ieee802154_wake_queue(struct ieee802154_hw *hw) } rcu_read_unlock(); } -EXPORT_SYMBOL(ieee802154_wake_queue); void ieee802154_stop_queue(struct ieee802154_hw *hw) { @@ -43,7 +42,6 @@ void ieee802154_stop_queue(struct ieee802154_hw *hw) } rcu_read_unlock(); } -EXPORT_SYMBOL(ieee802154_stop_queue); enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer) { From patchwork Wed Apr 27 16:46:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D22DC433EF for ; Wed, 27 Apr 2022 16:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243385AbiD0QuU (ORCPT ); Wed, 27 Apr 2022 12:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243451AbiD0QuT (ORCPT ); Wed, 27 Apr 2022 12:50:19 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56C4E2E0277; Wed, 27 Apr 2022 09:47:07 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 7974B100007; Wed, 27 Apr 2022 16:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/0DYVMXV9G/YRNcorwQ5Bnz33u0sYDIwpfJKTDtj7B8=; b=ZXD3j2+hnUPtImpfZYr8vTxsLYc638wmAzHMoZhS+dq63hj6CiH/iAzm+AaXncAa6qCoLO sz/3ejfTMxeGVwSgMMGyznWW1vXGIvc7WVzUOzLayQWR2AjsDzcSBsgEGfePEw02vnBH1h JC2c+bBvYr7Ka9xcvYEPtw2zlJL3+7HITfjZOMs1SXEzIrEW5X4HPxs7HvLGHKPFgqhP6V 8GvKw5/a692UQEyG5+LjAlxW+4IR2Mg0BzomkkmCvB7mEZABPJ1w0wd7CZ6NmDvYLVqrxc WhseO2ntD/tyxrp0y4ZMThaqm7KLZVOA+gJnqHZRQqx+6Bbbbj8wEfCwBiXzmA== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 02/11] net: mac802154: Change the wake/stop queue prototypes Date: Wed, 27 Apr 2022 18:46:50 +0200 Message-Id: <20220427164659.106447-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org Currently the pointer returned by *_alloc_hw() is used for these helpers, while actually all the callers have a *local pointer available and anyway this local pointer is going to be derived inside both helpers. We will soon add more helpers like these so let's change the prototype right now to improve the harmony in this file. There is no functional change. Signed-off-by: Miquel Raynal --- net/mac802154/cfg.c | 4 ++-- net/mac802154/ieee802154_i.h | 8 ++++---- net/mac802154/tx.c | 6 +++--- net/mac802154/util.c | 12 +++++------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index 1e4a9f74ed43..dafe02548161 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_stop_queue(&local->hw); + ieee802154_stop_queue(local); synchronize_net(); /* stop hardware - this must stop RX */ @@ -72,7 +72,7 @@ static int ieee802154_resume(struct wpan_phy *wpan_phy) return ret; wake_up: - ieee802154_wake_queue(&local->hw); + ieee802154_wake_queue(local); local->suspended = false; return 0; } diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 83f5ccd1ca0f..6652445a1147 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -132,7 +132,7 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer); /** * ieee802154_wake_queue - wake ieee802154 queue - * @hw: pointer as obtained from ieee802154_alloc_hw(). + * @local: main mac object * * Tranceivers usually have either one transmit framebuffer or one framebuffer * for both transmitting and receiving. Hence, the core currently only handles @@ -140,11 +140,11 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer); * avoid new skb to come during the transmission. The queue then needs to be * woken up after the operation. */ -void ieee802154_wake_queue(struct ieee802154_hw *hw); +void ieee802154_wake_queue(struct ieee802154_local *local); /** * ieee802154_stop_queue - stop ieee802154 queue - * @hw: pointer as obtained from ieee802154_alloc_hw(). + * @local: main mac object * * Tranceivers usually have either one transmit framebuffer or one framebuffer * for both transmitting and receiving. Hence, the core currently only handles @@ -152,7 +152,7 @@ void ieee802154_wake_queue(struct ieee802154_hw *hw); * stop giving us new skbs while we are busy with the transmitted one. The queue * must then be stopped before transmitting. */ -void ieee802154_stop_queue(struct ieee802154_hw *hw); +void ieee802154_stop_queue(struct ieee802154_local *local); /* MIB callbacks */ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan); diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index c829e4a75325..c5befaca5366 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -43,7 +43,7 @@ void ieee802154_xmit_worker(struct work_struct *work) err_tx: /* Restart the netif queue on each sub_if_data object. */ - ieee802154_wake_queue(&local->hw); + ieee802154_wake_queue(local); kfree_skb(skb); netdev_dbg(dev, "transmission failed\n"); } @@ -74,7 +74,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) } /* Stop the netif queue on each sub_if_data object. */ - ieee802154_stop_queue(&local->hw); + ieee802154_stop_queue(local); /* async is priority, otherwise sync is fallback */ if (local->ops->xmit_async) { @@ -82,7 +82,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) ret = drv_xmit_async(local, skb); if (ret) { - ieee802154_wake_queue(&local->hw); + ieee802154_wake_queue(local); goto err_tx; } diff --git a/net/mac802154/util.c b/net/mac802154/util.c index 15a46b56d85a..6ded390f0132 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -13,9 +13,8 @@ /* privid for wpan_phys to determine whether they belong to us or not */ const void *const mac802154_wpan_phy_privid = &mac802154_wpan_phy_privid; -void ieee802154_wake_queue(struct ieee802154_hw *hw) +void ieee802154_wake_queue(struct ieee802154_local *local) { - struct ieee802154_local *local = hw_to_local(hw); struct ieee802154_sub_if_data *sdata; rcu_read_lock(); @@ -28,9 +27,8 @@ void ieee802154_wake_queue(struct ieee802154_hw *hw) rcu_read_unlock(); } -void ieee802154_stop_queue(struct ieee802154_hw *hw) +void ieee802154_stop_queue(struct ieee802154_local *local) { - struct ieee802154_local *local = hw_to_local(hw); struct ieee802154_sub_if_data *sdata; rcu_read_lock(); @@ -48,7 +46,7 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer) struct ieee802154_local *local = container_of(timer, struct ieee802154_local, ifs_timer); - ieee802154_wake_queue(&local->hw); + ieee802154_wake_queue(local); return HRTIMER_NORESTART; } @@ -82,7 +80,7 @@ void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, hw->phy->sifs_period * NSEC_PER_USEC, HRTIMER_MODE_REL); } else { - ieee802154_wake_queue(hw); + ieee802154_wake_queue(local); } dev_consume_skb_any(skb); @@ -95,7 +93,7 @@ void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb, struct ieee802154_local *local = hw_to_local(hw); local->tx_result = reason; - ieee802154_wake_queue(hw); + ieee802154_wake_queue(local); dev_kfree_skb_any(skb); } EXPORT_SYMBOL(ieee802154_xmit_error); From patchwork Wed Apr 27 16:46:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D249C433F5 for ; Wed, 27 Apr 2022 16:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243464AbiD0QuY (ORCPT ); Wed, 27 Apr 2022 12:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243383AbiD0QuU (ORCPT ); Wed, 27 Apr 2022 12:50:20 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB1331FABA; Wed, 27 Apr 2022 09:47:08 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 145F0100009; Wed, 27 Apr 2022 16:47:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FqllBuCqgaIf9HUIzN59jKwQs6BNFOqCkdFJ8C6y3XU=; b=X3hACt2PyPA/jiGi8cbdyKm6VsApmldO6vSwDxKArrdlTorKr920Uaztfn+j9ox0+2Y1bY otQPfyL4HaUJPnVe4Isf3ebyeDr7ffKneWvXUJiLk7CJ0O2ynXEyFH/VIet5o9xSZXFSfh NO4/2T3FzIJ+Lv4zJ24HCTy4yURnHzVNVCTyCYiDlwZhTMosM9SGpryhAhumMdrx/WiY0M hxp//8AugQJn+DgrwXou+92pno+NsMDByJcDOCLnmzpOYlRiERCEx0g8F1tELGwRA2cWiA 7wiWr5wgSSBF1DXjm1sNPpzX9g15n5IroA48//bA9ALjsur45n415VvMy3Y7ng== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 03/11] net: mac802154: Rename the synchronous xmit worker Date: Wed, 27 Apr 2022 18:46:51 +0200 Message-Id: <20220427164659.106447-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org There are currently two driver hooks: one is synchronous, the other is not. We cannot rely on driver implementations to provide a synchronous API (which is related to the bus medium more than a wish to have a synchronized implementation) so we are going to introduce a sync API above any kind of driver transmit function. In order to clarify what this worker is for (synchronous driver implementation), let's rename it so that people don't get bothered by the fact that their driver does not make use of the "xmit worker" which is a too generic name. Signed-off-by: Miquel Raynal --- net/mac802154/ieee802154_i.h | 2 +- net/mac802154/main.c | 2 +- net/mac802154/tx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 6652445a1147..d27e9fe363b6 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -123,7 +123,7 @@ ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata) extern struct ieee802154_mlme_ops mac802154_mlme_wpan; void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb); -void ieee802154_xmit_worker(struct work_struct *work); +void ieee802154_xmit_sync_worker(struct work_struct *work); netdev_tx_t ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); netdev_tx_t diff --git a/net/mac802154/main.c b/net/mac802154/main.c index 5546ef86e231..13c6b3cd0429 100644 --- a/net/mac802154/main.c +++ b/net/mac802154/main.c @@ -95,7 +95,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops) skb_queue_head_init(&local->skb_queue); - INIT_WORK(&local->tx_work, ieee802154_xmit_worker); + INIT_WORK(&local->tx_work, ieee802154_xmit_sync_worker); /* init supported flags with 802.15.4 default ranges */ phy->supported.max_minbe = 8; diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index c5befaca5366..0ebe39169309 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -22,7 +22,7 @@ #include "ieee802154_i.h" #include "driver-ops.h" -void ieee802154_xmit_worker(struct work_struct *work) +void ieee802154_xmit_sync_worker(struct work_struct *work) { struct ieee802154_local *local = container_of(work, struct ieee802154_local, tx_work); From patchwork Wed Apr 27 16:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 085B8C4332F for ; Wed, 27 Apr 2022 16:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243497AbiD0QuZ (ORCPT ); Wed, 27 Apr 2022 12:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243451AbiD0QuX (ORCPT ); Wed, 27 Apr 2022 12:50:23 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4814914A515; Wed, 27 Apr 2022 09:47:10 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 8B061100008; Wed, 27 Apr 2022 16:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+u74cISYZQ6y5kyeBoVnGGpW+IMXgn01hz9uorp+y0w=; b=Pz7pZN21WgHa3/gvseqoQN2aM0cHyYV9iheRom/pS8V/cYFOoj7Tgzd25WbEL3BAnggaMC J4CfgD/4UxTzgahxbIiYTw00XnW+bkF0t2SjYbCUt+sLCWs4MDr8L8E5eGo6HdaLqr1ROq c6IkfHl30CGvRlo5qbq/u4jpvB5VR3iZ1bPrg9MZYPP9QwyY65BqLakVtPukTlCddrmCsw tudk0yZy5lnX7o615OW6lJtL8XzPKsiEzQVbQfDQC+mQQzzJGJ+xbJ2T4oxuIbVPm0Z2mO Ga3gX5dBc3WEflVoHNdiJ04eQKNB8U+mKx4yydSfCRohaPJdf61trgWOKrBMzw== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 04/11] net: mac802154: Rename the main tx_work struct Date: Wed, 27 Apr 2022 18:46:52 +0200 Message-Id: <20220427164659.106447-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org This entry is dedicated to synchronous transmissions done by drivers without async hook. Make this clearer that this is not a work that any driver can use by at least prefixing it with "sync_". While at it, let's enhance the comment explaining why we choose one or the other. Signed-off-by: Miquel Raynal --- net/mac802154/ieee802154_i.h | 2 +- net/mac802154/main.c | 2 +- net/mac802154/tx.c | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index d27e9fe363b6..3f59a291b481 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -55,7 +55,7 @@ struct ieee802154_local { struct sk_buff_head skb_queue; struct sk_buff *tx_skb; - struct work_struct tx_work; + struct work_struct sync_tx_work; /* A negative Linux error code or a null/positive MLME error status */ int tx_result; }; diff --git a/net/mac802154/main.c b/net/mac802154/main.c index 13c6b3cd0429..46258c6d430f 100644 --- a/net/mac802154/main.c +++ b/net/mac802154/main.c @@ -95,7 +95,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops) skb_queue_head_init(&local->skb_queue); - INIT_WORK(&local->tx_work, ieee802154_xmit_sync_worker); + INIT_WORK(&local->sync_tx_work, ieee802154_xmit_sync_worker); /* init supported flags with 802.15.4 default ranges */ phy->supported.max_minbe = 8; diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index 0ebe39169309..6d559f96664d 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -25,7 +25,7 @@ void ieee802154_xmit_sync_worker(struct work_struct *work) { struct ieee802154_local *local = - container_of(work, struct ieee802154_local, tx_work); + container_of(work, struct ieee802154_local, sync_tx_work); struct sk_buff *skb = local->tx_skb; struct net_device *dev = skb->dev; int res; @@ -76,7 +76,10 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) /* Stop the netif queue on each sub_if_data object. */ ieee802154_stop_queue(local); - /* async is priority, otherwise sync is fallback */ + /* Drivers should preferably implement the async callback. In some rare + * cases they only provide a sync callback which we will use as a + * fallback. + */ if (local->ops->xmit_async) { unsigned int len = skb->len; @@ -90,7 +93,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) dev->stats.tx_bytes += len; } else { local->tx_skb = skb; - queue_work(local->workqueue, &local->tx_work); + queue_work(local->workqueue, &local->sync_tx_work); } return NETDEV_TX_OK; From patchwork Wed Apr 27 16:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 464F3C433FE for ; Wed, 27 Apr 2022 16:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243495AbiD0Qu0 (ORCPT ); Wed, 27 Apr 2022 12:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243456AbiD0QuX (ORCPT ); Wed, 27 Apr 2022 12:50:23 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE7F3681D5; Wed, 27 Apr 2022 09:47:11 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 12F4310000E; Wed, 27 Apr 2022 16:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lcIaN5D9rzzs6ODl/fOVj+Kiy8zn//WpgkmzEbJrQLM=; b=gJzdMXBPYFKVnZb9nUp+5uS0WzhUJj/apePAZW5vuZfUnB/ibIFv5SBQLO3JwhYgvfmQ+r e6rZafIVrWJzg0RmrPQ8VwRHdqarazJdVc4N0UtzC20rhr9z53z8FxU9lhSrYFiD9+uFFs AwtBsfS+FZ7zSX5fPwwy7r1DQgY1cylDsFX2K5hQl1KcofR1eJJ1xkA8H9M6l1nPvQ3Udk OH/B9udP8VJMQmZBlU1Yk+RpjFjHJv7Q0Ln/uAa1ZYMBoWqwQP69iWfKmETa3/zFj9t3e1 I5oYvrnlC98FZJxCCJIB/X0mShXwj5mZe4U6piDnQd/ocvYZQi9QH2FiURrOVA== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 05/11] net: mac802154: Follow the count of ongoing transmissions Date: Wed, 27 Apr 2022 18:46:53 +0200 Message-Id: <20220427164659.106447-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org In order to create a synchronous API for MLME command purposes, we need to be able to track the end of the ongoing transmissions. Let's introduce an atomic variable which is incremented when a transmission starts and decremented when relevant so that we know at any moment whether there is an ongoing transmission. The counter gets decremented in the following situations: - The operation is asynchronous and there was a failure during the offloading process. - The operation is synchronous and the synchronous operation failed. - The operation finished, either successfully or not. Signed-off-by: Miquel Raynal --- include/net/cfg802154.h | 3 +++ net/mac802154/tx.c | 3 +++ net/mac802154/util.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index 85f9e8417688..473ebcb9b155 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h @@ -214,6 +214,9 @@ struct wpan_phy { /* the network namespace this phy lives in currently */ possible_net_t _net; + /* Transmission monitoring */ + atomic_t ongoing_txs; + char priv[] __aligned(NETDEV_ALIGN); }; diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index 6d559f96664d..8c0bad7796ba 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -45,6 +45,7 @@ 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); netdev_dbg(dev, "transmission failed\n"); } @@ -75,6 +76,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) /* Stop the netif queue on each sub_if_data object. */ ieee802154_stop_queue(local); + atomic_inc(&local->phy->ongoing_txs); /* Drivers should preferably implement the async callback. In some rare * cases they only provide a sync callback which we will use as a @@ -99,6 +101,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) return NETDEV_TX_OK; err_tx: + atomic_dec(&local->phy->ongoing_txs); kfree_skb(skb); return NETDEV_TX_OK; } diff --git a/net/mac802154/util.c b/net/mac802154/util.c index 6ded390f0132..4bcc9cd2eb9d 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -84,6 +84,7 @@ void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, } dev_consume_skb_any(skb); + atomic_dec(&hw->phy->ongoing_txs); } EXPORT_SYMBOL(ieee802154_xmit_complete); @@ -95,6 +96,7 @@ void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb, local->tx_result = reason; ieee802154_wake_queue(local); dev_kfree_skb_any(skb); + atomic_dec(&hw->phy->ongoing_txs); } EXPORT_SYMBOL(ieee802154_xmit_error); From patchwork Wed Apr 27 16:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11B5EC433F5 for ; Wed, 27 Apr 2022 16:47:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243579AbiD0Quk (ORCPT ); Wed, 27 Apr 2022 12:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243518AbiD0Qu0 (ORCPT ); Wed, 27 Apr 2022 12:50:26 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D85A43A6AD3; Wed, 27 Apr 2022 09:47:13 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id CFDCF10000F; Wed, 27 Apr 2022 16:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=px6AHkCHCkCygBsaH5J3RUD7FCF1uQeWDYconq5IqwA=; b=b071SoX+ibijv9ZM3IMsk8uDNOrVnM2jjXuqOXaya8R9WS0yOGou8MY4NqSTzQtbFpwifA CzUelAneAwkq17v/ZtP706JhMKohkXkeRglpnezbvhddvTWa5qeZKCqvFkroV9npEPcWKj Fxb1dw36alKNfyyI2l/g26a98Cr3yaHm0o+da7zTqia7ul5JBuChdLLgjKGYLKGJ9QDSxs 3axpWchRpKzfUxbn+rU7wYMZUzqRujgYg6eAxJ+UGc3MlMopWLG74QdoIIZIaFsBiUkz/w FaQoNhmBpT9QVI9C5osMfVoTRXWK41RHsBLfKYARh8PUthQe6Kix7DOs2W7k6w== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 06/11] net: mac802154: Hold the transmit queue when relevant Date: Wed, 27 Apr 2022 18:46:54 +0200 Message-Id: <20220427164659.106447-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org Let's create a hold_txs atomic variable and increment/decrement it when relevant. Currently we can use it during a suspend. Very soon we will also use this feature during scans. When the variable is incremented, any further wake up call will be skipped until the variable gets decremented back. Signed-off-by: Miquel Raynal --- include/net/cfg802154.h | 3 ++- net/mac802154/cfg.c | 2 ++ net/mac802154/ieee802154_i.h | 24 ++++++++++++++++++++++++ net/mac802154/tx.c | 15 +++++++++++++++ net/mac802154/util.c | 3 +++ 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index 473ebcb9b155..043d8e4359e7 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h @@ -214,8 +214,9 @@ struct wpan_phy { /* the network namespace this phy lives in currently */ possible_net_t _net; - /* Transmission monitoring */ + /* Transmission monitoring and control */ atomic_t ongoing_txs; + atomic_t hold_txs; char priv[] __aligned(NETDEV_ALIGN); }; diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index dafe02548161..0540a2b014d2 100644 --- a/net/mac802154/cfg.c +++ b/net/mac802154/cfg.c @@ -46,6 +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); synchronize_net(); @@ -72,6 +73,7 @@ static int ieee802154_resume(struct wpan_phy *wpan_phy) return ret; wake_up: + ieee802154_release_queue(local); ieee802154_wake_queue(local); local->suspended = false; return 0; diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 3f59a291b481..b55fdefb0b34 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -142,6 +142,30 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer); */ void ieee802154_wake_queue(struct ieee802154_local *local); +/** + * ieee802154_hold_queue - hold ieee802154 queue + * @local: main mac object + * + * Hold a queue, this queue cannot be woken up while this is active. + */ +void ieee802154_hold_queue(struct ieee802154_local *local); + +/** + * ieee802154_release_queue - release ieee802154 queue + * @local: main mac object + * + * Release a queue which is held. The queue can now be woken up. + */ +void ieee802154_release_queue(struct ieee802154_local *local); + +/** + * ieee802154_queue_is_held - checks whether the ieee802154 queue is held + * @local: main mac object + * + * Checks whether the queue is currently held. + */ +bool ieee802154_queue_is_held(struct ieee802154_local *local); + /** * ieee802154_stop_queue - stop ieee802154 queue * @local: main mac object diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index 8c0bad7796ba..d088aa8119e8 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -106,6 +106,21 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) return NETDEV_TX_OK; } +void ieee802154_hold_queue(struct ieee802154_local *local) +{ + atomic_inc(&local->phy->hold_txs); +} + +void ieee802154_release_queue(struct ieee802154_local *local) +{ + atomic_dec(&local->phy->hold_txs); +} + +bool ieee802154_queue_is_held(struct ieee802154_local *local) +{ + return atomic_read(&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 4bcc9cd2eb9d..847e0864b575 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -17,6 +17,9 @@ void ieee802154_wake_queue(struct ieee802154_local *local) { struct ieee802154_sub_if_data *sdata; + if (ieee802154_queue_is_held(local)) + return; + rcu_read_lock(); list_for_each_entry_rcu(sdata, &local->interfaces, list) { if (!sdata->dev) From patchwork Wed Apr 27 16:46:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829198 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83BB1C433EF for ; Wed, 27 Apr 2022 16:47:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243588AbiD0Quk (ORCPT ); Wed, 27 Apr 2022 12:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243556AbiD0Qu0 (ORCPT ); Wed, 27 Apr 2022 12:50:26 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1EA3A6AEF; Wed, 27 Apr 2022 09:47:14 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 76CE5100004; Wed, 27 Apr 2022 16:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078033; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IYIqvJTwu0bd9MyK1FEYDFg2VmvBo/CFuwJH9CPsXY0=; b=B74oLQpcutdnsX852UtoMp3zdYJNns/kHFxxnbQijeblBz2/6TZizfJWq/KP0wXxgavSh1 Hrtm18sGHvOcUPXtnhpkSRqR6lmcL+KhdNaJhyWOQGepHAEbn37vhWl40FO8Jz1ZEbhesp L8gYsPqz0biEELR6GbN10DO+ncXDxh5nRsCXWAmhk0mJR1HVVb189tpLrGSXGzzw82BMha xSn9liE5NvYSgFm9OLWNR+oKO+To/DAKcI1slCOh2b1OykPqDOnRfb120nIFpqbOMmqoas DnmQ9oXYKiCudYxUt+eN6k9VlHG3TuUo59M0Ur1riOMYTS1aNrfAggO/Zle1Kw== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 07/11] net: mac802154: Create a hot tx path Date: Wed, 27 Apr 2022 18:46:55 +0200 Message-Id: <20220427164659.106447-8-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org Let's rename the current Tx path to show that this is the "hot" Tx path. We will soon introduce a slower Tx path for MLME commands. Signed-off-by: Miquel Raynal --- net/mac802154/tx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index d088aa8119e8..a8a83f0167bf 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -121,6 +121,12 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local) return atomic_read(&local->phy->hold_txs); } +static netdev_tx_t +ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb) +{ + return ieee802154_tx(local, skb); +} + netdev_tx_t ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -128,7 +134,7 @@ ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev) skb->skb_iif = dev->ifindex; - return ieee802154_tx(sdata->local, skb); + return ieee802154_hot_tx(sdata->local, skb); } netdev_tx_t @@ -150,5 +156,5 @@ ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev) skb->skb_iif = dev->ifindex; - return ieee802154_tx(sdata->local, skb); + return ieee802154_hot_tx(sdata->local, skb); } From patchwork Wed Apr 27 16:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 000F9C433FE for ; Wed, 27 Apr 2022 16:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243614AbiD0Qul (ORCPT ); Wed, 27 Apr 2022 12:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243557AbiD0Qu2 (ORCPT ); Wed, 27 Apr 2022 12:50:28 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C54B13B2FE8; Wed, 27 Apr 2022 09:47:16 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 022F010000C; Wed, 27 Apr 2022 16:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UYcW7qXTukp8gAmJtzYIXgiO9r5Z22F+sU4J8lU9bZE=; b=Wq+SGdHLQnifOpnQzK8sZjQMLAqnquYIT8ERq7OGT9hjePepWu3vhJyIXxR76wb0xD7GFR 5QlY7NnSR+g8vStLuwRUPULagPUfWmHYAxfMmhxDgFmm1OKnyNekJYYMpjtEJCb0G77KwP yvWRSEui9ZREO86LdehCraspGdQhj+HVqLkXR136+Yy0ADCvYXaM2Dhjxn1xFUnC1/pEAA ZLiAckKS9ImKeHDcOlhtv4EXpwgTuqQoad9jRXjCDQPISpnaT7sr69NfI8ARAbfMB3Po4D 9J3zlI5X2vpjHtEtLrave3HxS7u7oY5DfPZG1If0Vk3kiHjtDHCVZwSuji3TNA== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 08/11] net: mac802154: Add a warning in the hot path Date: Wed, 27 Apr 2022 18:46:56 +0200 Message-Id: <20220427164659.106447-9-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org We should never start a transmission after the queue has been stopped. But because it might work we don't kill the function here but rather warn loudly the user that something is wrong. Signed-off-by: Miquel Raynal --- net/mac802154/ieee802154_i.h | 8 ++++++++ net/mac802154/tx.c | 2 ++ net/mac802154/util.c | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index b55fdefb0b34..cb61a4abaf37 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -178,6 +178,14 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local); */ void ieee802154_stop_queue(struct ieee802154_local *local); +/** + * ieee802154_queue_is_stopped - check whether ieee802154 queue was stopped + * @local: main mac object + * + * Goes through all the interfaces and indicates if they are all stopped or not. + */ +bool ieee802154_queue_is_stopped(struct ieee802154_local *local); + /* MIB callbacks */ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan); diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index a8a83f0167bf..021dddfea542 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -124,6 +124,8 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local) static netdev_tx_t ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb) { + WARN_ON_ONCE(ieee802154_queue_is_stopped(local)); + return ieee802154_tx(local, skb); } diff --git a/net/mac802154/util.c b/net/mac802154/util.c index 847e0864b575..cfd17a7db532 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -44,6 +44,24 @@ void ieee802154_stop_queue(struct ieee802154_local *local) rcu_read_unlock(); } +bool ieee802154_queue_is_stopped(struct ieee802154_local *local) +{ + struct ieee802154_sub_if_data *sdata; + bool stopped = true; + + rcu_read_lock(); + list_for_each_entry_rcu(sdata, &local->interfaces, list) { + if (!sdata->dev) + continue; + + if (!netif_queue_stopped(sdata->dev)) + stopped = false; + } + rcu_read_unlock(); + + return stopped; +} + enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer) { struct ieee802154_local *local = From patchwork Wed Apr 27 16:46:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829200 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CF93C433F5 for ; Wed, 27 Apr 2022 16:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243577AbiD0Qum (ORCPT ); Wed, 27 Apr 2022 12:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243570AbiD0Quk (ORCPT ); Wed, 27 Apr 2022 12:50:40 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F8BB3BBF48; Wed, 27 Apr 2022 09:47:18 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B45F8100012; Wed, 27 Apr 2022 16:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uprKRxpPNS2FwGoP4geeX0dLZY5C2SdqPpJ1poentmI=; b=ncSTJKYAJdxGXm12AahQLu5RgQ3rsaNYgLy+h+2j4aZnFgsZ026IEouBm6Oo68XLxyl8e7 wRbGKJP1WcVdYiqy4QP+bU8yKdFau3ZKbpc+3of1UIParc3hrPeXJfpTY/qhKQCxDjsG7Y EIyQFRpi5i9bhNFL/DWtcek2wWo3r2tDjBcucZKKZKHlYRoho54dLB46vibifm9tXUYVDi 1ZY9ylT0jQkk3M4QMrxinBy6JYyAnuJqg6HPNb1UlikX05T20yJwaBkLZhSNh0x5eLmCPM 9w2rVtfbDu5Sh+pQRQukpceGiYVBjzYsOK245qYLQb5J6pwsDsuME4eFXYpxLw== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 09/11] net: mac802154: Introduce a helper to disable the queue Date: Wed, 27 Apr 2022 18:46:57 +0200 Message-Id: <20220427164659.106447-10-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org Sometimes calling the stop queue helper is not enough because it does not hold any lock. In order to be safe and avoid racy situations when trying to (soon) sync the Tx queue, for instance before sending an MLME frame, let's now introduce an helper which actually hold the necessary locks when doing so. Suggested-by: Alexander Aring Signed-off-by: Miquel Raynal --- net/mac802154/ieee802154_i.h | 12 ++++++++++++ net/mac802154/util.c | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index cb61a4abaf37..c686a027555a 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -186,6 +186,18 @@ void ieee802154_stop_queue(struct ieee802154_local *local); */ bool ieee802154_queue_is_stopped(struct ieee802154_local *local); +/** + * ieee802154_disable_queue - disable ieee802154 queue + * @local: main mac object + * + * When trying to sync the Tx queue, we cannot just stop the queue + * (which is basically a bit being set without proper lock handling) + * because it would be racy. We actually need to call netif_tx_disable() + * instead, which is done by this helper. Restarting the queue can + * however still be done with a regular wake call. + */ +void ieee802154_disable_queue(struct ieee802154_local *local); + /* MIB callbacks */ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan); diff --git a/net/mac802154/util.c b/net/mac802154/util.c index cfd17a7db532..3e2b157b34b1 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -62,6 +62,21 @@ bool ieee802154_queue_is_stopped(struct ieee802154_local *local) return stopped; } +void ieee802154_disable_queue(struct ieee802154_local *local) +{ + struct ieee802154_sub_if_data *sdata; + + rcu_read_lock(); + list_for_each_entry_rcu(sdata, &local->interfaces, list) { + if (!sdata->dev) + continue; + + netif_tx_disable(sdata->dev); + } + rcu_read_unlock(); +} +EXPORT_SYMBOL(ieee802154_disable_queue); + enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer) { struct ieee802154_local *local = From patchwork Wed Apr 27 16:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 432F3C433EF for ; Wed, 27 Apr 2022 16:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243674AbiD0Qu4 (ORCPT ); Wed, 27 Apr 2022 12:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243598AbiD0Quk (ORCPT ); Wed, 27 Apr 2022 12:50:40 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C08093BD070; Wed, 27 Apr 2022 09:47:20 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 78766100002; Wed, 27 Apr 2022 16:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vKzkq+CfZY3IbT17d7R/+82HSGULbkE/4tJqMeFNIFk=; b=nizfKK0bL96mWpudc/adrCC/RXKdp9ljR4SCE+4LlycfpkBLcozPdpaNotg8jvZIOPl3bw Qs/FvvX8nZ4tR92ud/XU7jFo7XRvHYHlYxR49685NWhe/NJqhYJ/pgeMb3jQJF3Bb/0NKr SJHgFbAERKSz1jssj90ZgujKRwm/6tss6faY0NQ5LgP4SBjeONrE1z/0BE/0BE+rEGgdDt KkkjdqPPpELDMOeIQCQNYk2VdH6qUQI4EWe/ZdcHG8R7FOUzb+VxJn0FRKyRC1b4wuteNP 5zkARqDYEurUFbL2NbuPl58OA55e3J3bspKTj90JL77oZ3v3aA/HEd4ZzHNXgQ== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 10/11] net: mac802154: Introduce a tx queue flushing mechanism Date: Wed, 27 Apr 2022 18:46:58 +0200 Message-Id: <20220427164659.106447-11-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org 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 | 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"); } @@ -121,6 +122,27 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local) return atomic_read(&local->phy->hold_txs); } +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); + ieee802154_wake_queue(local); + + return ret; +} + +int ieee802154_sync_and_hold_queue(struct ieee802154_local *local) +{ + ieee802154_hold_queue(local); + + return ieee802154_sync_queue(local); +} + static netdev_tx_t ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb) { diff --git a/net/mac802154/util.c b/net/mac802154/util.c index 3e2b157b34b1..056f8c4e6bcd 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -120,7 +120,8 @@ void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb, } dev_consume_skb_any(skb); - atomic_dec(&hw->phy->ongoing_txs); + if (!atomic_dec_and_test(&hw->phy->ongoing_txs)) + wake_up(&hw->phy->sync_txq); } EXPORT_SYMBOL(ieee802154_xmit_complete); @@ -132,7 +133,9 @@ void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb, local->tx_result = reason; ieee802154_wake_queue(local); dev_kfree_skb_any(skb); - atomic_dec(&hw->phy->ongoing_txs); + + if (!atomic_dec_and_test(&hw->phy->ongoing_txs)) + wake_up(&hw->phy->sync_txq); } EXPORT_SYMBOL(ieee802154_xmit_error); From patchwork Wed Apr 27 16:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A8A3C433EF for ; Wed, 27 Apr 2022 16:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243456AbiD0QvA (ORCPT ); Wed, 27 Apr 2022 12:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243518AbiD0Qul (ORCPT ); Wed, 27 Apr 2022 12:50:41 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AE83BDE4C; Wed, 27 Apr 2022 09:47:21 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id DE6D7100008; Wed, 27 Apr 2022 16:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BIiG20WZvkHQ4ep4wdahDp0PX+zvyjhFTQ2/0CC9xKE=; b=dkfZlUwUt9kqDyy5AKoaowaBywT+wnU+nZcW6YYhZnwqsEgYBn1BkilD2IV3TyBR3SAA0J 1xniS1RC05PgLqyPC7pTpDgaPHQSx37CcuC5EWxFzicHs+MkShn7KTWf21sh6G6OVaN88m ddUY3QB+byws1Yp4nR9i1rnx9lTaKuaG+k+Du8v/lVgSSQ/Sc0Bm4RsSPX9iwi7r5Amc5f CS0IPnojUrqvGJ+LK1pLxgypt6XKNqOM6Kmy5WyNoKm8Yv7i+YMbRIJnoSwwRAu8t+gPcr 6u4S6EVLw0g/gDLdRxVdoSsH9tzS9Ce3tmmutpV+Up+5E26kJ8TgMKOoRiN7ug== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next 11/11] net: mac802154: Introduce a synchronous API for MLME commands Date: Wed, 27 Apr 2022 18:46:59 +0200 Message-Id: <20220427164659.106447-12-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org This is the slow path, we need to wait for each command to be processed before continuing so let's introduce an helper which does the transmission and blocks until it gets notified of its asynchronous completion. This helper is going to be used when introducing scan support. Signed-off-by: Miquel Raynal --- net/mac802154/ieee802154_i.h | 1 + net/mac802154/tx.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index c87c7fa04435..8aa8d0dd9c41 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -125,6 +125,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); +int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb); 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 5f94973b57e4..17244293c59a 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -143,6 +143,25 @@ int ieee802154_sync_and_hold_queue(struct ieee802154_local *local) return ieee802154_sync_queue(local); } +int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb) +{ + bool queue_held = ieee802154_queue_is_held(local); + int ret; + + if (!queue_held) + ieee802154_sync_and_hold_queue(local); + + ieee802154_tx(local, skb); + ret = ieee802154_sync_queue(local); + + if (!queue_held) + ieee802154_release_queue(local); + + ieee802154_wake_queue(local); + + return ret; +} + static netdev_tx_t ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb) {