Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp722774pxb; Fri, 14 Jan 2022 15:02:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxE0olnHgm6AY5pfLMaYgWM+4uCWfZV/tQr4QcF7jL4P1F6aRcqM2W0ymbgYKa8VPer3f5I X-Received: by 2002:a17:906:6156:: with SMTP id p22mr8781747ejl.323.1642201348574; Fri, 14 Jan 2022 15:02:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642201348; cv=none; d=google.com; s=arc-20160816; b=lfLti5lhDpw7pURlQPGKwiZCJTJgSEpbNlIQVY7atfZPDYA2No7HMYxLIYZBiGr5qN PT4Ty2OLphbAC95cuN0lAF9/G4eQkVAmoDg8XXRJOgRO/tb1gi+cCcm9AHD+GcS6BBp6 SVQqwATcm7x1LNFqc1bNCDquErpnjGkHvenLGMcERRg5dk4DMpsqrOtw1ciIGrpjlSNj S8lQBO3A9p4Qka8zyaoqTAvPj3YoEsQbXjyM07cX+kXmN7v8EEvesDu+vhelRXXmKRy2 w2VozMPyP6Wg2fIgKeq90wx2PyYk+7jEi5oT8+Ca1gcKMgLIgVzmA8Gq6X0IA5e8K4n4 fvXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=cj0PaZNyKStQQbtG87DgLce0UYfbhkr+xD+8kfR3aMA=; b=Dp9T1wKcJ26WXqTjOqjBEnSH2Cit0Q1q5YKbTnSNuMgDoy++ScCiQekeom9rfy0BMc pGMzLXycdeHR8ab06EFwIuwYLZCsQCSKVtRdINYOh3hdKaSS2UbPBrr+cXuxD6NgOaHT AV5JtThAQmPXNBuG7SjMEo8Dv20LD6Fcyuw3hOR5jSt0wVsj0Bvos21xFINKaow9jFSE S3pvNDduOqz8zNqfxwgdajUvNKWr8haY79ApdrT1a7z8op9Wpahmo9o3jqHC8OLTa5sZ U7QdckG3Ek97xsnJYE5I3TZgFgwVYT9OfGFX40GGh+g89qlLMbloCYBXZuNXPvepFdIv XA6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lb18si3634779ejc.999.2022.01.14.15.02.11; Fri, 14 Jan 2022 15:02:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243120AbiANSoc convert rfc822-to-8bit (ORCPT + 71 others); Fri, 14 Jan 2022 13:44:32 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:50923 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236181AbiANSob (ORCPT ); Fri, 14 Jan 2022 13:44:31 -0500 Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id E532FFF805; Fri, 14 Jan 2022 18:44:26 +0000 (UTC) Date: Fri, 14 Jan 2022 19:44:25 +0100 From: Miquel Raynal To: Alexander Aring Cc: Stefan Schmidt , linux-wpan - ML , "David S. Miller" , Jakub Kicinski , "open list:NETWORKING [GENERAL]" , Michael Hennerich , Harry Morris , Varka Bhadram , Xue Liu , Alan Ott , David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , "linux-wireless@vger.kernel.org Wireless" Subject: Re: [wpan-next v2 18/27] net: mac802154: Handle scan requests Message-ID: <20220114194425.3df06391@xps13> In-Reply-To: References: <20220112173312.764660-1-miquel.raynal@bootlin.com> <20220112173312.764660-19-miquel.raynal@bootlin.com> <20220113180709.0dade123@xps13> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Alexander, alex.aring@gmail.com wrote on Thu, 13 Jan 2022 19:01:56 -0500: > Hi, > > On Thu, 13 Jan 2022 at 12:07, Miquel Raynal wrote: > > > > Hi Alexander, > > > > alex.aring@gmail.com wrote on Wed, 12 Jan 2022 17:44:02 -0500: > > > > > Hi, > > > > > > On Wed, 12 Jan 2022 at 12:33, Miquel Raynal wrote: > > > ... > > > > + return 0; > > > > +} > > > > diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c > > > > index c829e4a75325..40656728c624 100644 > > > > --- a/net/mac802154/tx.c > > > > +++ b/net/mac802154/tx.c > > > > @@ -54,6 +54,9 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) > > > > struct net_device *dev = skb->dev; > > > > int ret; > > > > > > > > + if (unlikely(mac802154_scan_is_ongoing(local))) > > > > + return NETDEV_TX_BUSY; > > > > + > > > > > > Please look into the functions "ieee802154_wake_queue()" and > > > "ieee802154_stop_queue()" which prevent this function from being > > > called. Call stop before starting scanning and wake after scanning is > > > done or stopped. > > > > Mmmh all this is already done, isn't it? > > - mac802154_trigger_scan_locked() stops the queue before setting the > > promiscuous mode > > - mac802154_end_of_scan() wakes the queue after resetting the > > promiscuous mode to its original state > > > > Should I drop the check which stands for an extra precaution? > > > > no, I think then it should be a WARN_ON() more without any return > (hopefully it will survive). This case should never happen otherwise > we have a bug that we wake the queue when we "took control about > transmissions" only. > Change the name, I think it will be in future not only scan related. > Maybe "mac802154_queue_stopped()". Everything which is queued from > socket/upperlayer(6lowpan) goes this way. Got it. I've changed the name of the helper, and used an atomic variable there to follow the count. > > But overall I think I don't understand well this part. What is > > a bit foggy to me is why the (async) tx implementation does: > > > > *Core* *Driver* > > > > stop_queue() > > drv_async_xmit() ------- > > \------> do something > > ------- calls ieee802154_xmit_complete() > > wakeup_queue() <--------/ > > > > So we actually disable the queue for transmitting. Why?? > > > > Because all transceivers have either _one_ transmit framebuffer or one > framebuffer for transmit and receive one time. We need to report to > stop giving us more skb's while we are busy with one to transmit. > This all will/must be changed in future if there is hardware outside > which is more powerful and the driver needs to control the flow here. > > That ieee802154_xmit_complete() calls wakeup_queue need to be > forbidden when we are in "synchronous transmit mode"/the queue is > stopped. The synchronous transmit mode is not for any hotpath, it's > for MLME and I think we also need a per phy lock to avoid multiple > synchronous transmissions at one time. Please note that I don't think > here only about scan operation, also for other possible MLME-ops. > First, thank you very much for all your guidance and reviews, I think I have a much clearer understanding now. I've tried to follow your advices, creating: - a way of tracking ongoing transmissions - a synchronous API for MLME transfers I've decided to use the wait_queue + atomic combo which looks nice. Everything seems to work, I just need a bit of time to clean and rework a bit the series before sending a v3. Thanks, Miquèl