Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2658059pxb; Mon, 17 Jan 2022 03:06:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYNAixSHxZo2djq8hVh+SjjgNg++77WfID+EZhPnXEOyEA4lqU5BxOMUkjSnlsfg6Xp2MY X-Received: by 2002:a17:902:e842:b0:14a:8735:1a5d with SMTP id t2-20020a170902e84200b0014a87351a5dmr18155561plg.69.1642417615177; Mon, 17 Jan 2022 03:06:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642417615; cv=none; d=google.com; s=arc-20160816; b=uv6L7WEUjak7MRJTAccZu9nuiwUodymd8psPE3C934j0OgrNpmN8hMFpRZ87oLkTYx P/nHJSHs7Rrvk67gW15F6m/cAcfXUGHF3lQGsOhjaT4+UHK5qe0IrxWceNhRvKR/1W1d W6/m2aorLhH9+ArNPImQxjdkwQ8st/cUtSluquDpMEvGH8O7roUKnidLkJViJdioXU/7 SlPe/6IrByzocFtz4Uf0KIF4B3+OZU3rjI7OVkK48v/padC4jQjW34gIzCH3MInHOvNf BDcyt421BXvmcQTJcDlUkA3de2jYhtYnxDD99G9gaXvKeIFrx3/RhKutw2aquyl4MQ0m mi9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RQNSz+9Ongl6D3vtokUiSrT++IM4wgxyZXz0eiKQvqI=; b=Hn7In0jwM3w5UYsok0TUlxK5RnYl0a03Zmo8Z4XE2SS3ZJYQx+gGBXVl4rPmr8NEsO jIoz6rf9IRrtNJ4eR5bQ7/JpojOs05vZy2cw7MV3XhsxKL1NE+E2Xk5dHZhes1LO1fhf 892k+BiHRFB/sRFoteug1jtrvN2Ugvxtq8YZIzoYfAWDIbIzj1IKSxRfJhxXgRXrqVJS QnFcVXbIz8L1xum7eEttCDdrx133q7H/8hG6bL9ftmbqV6/3ZtW3mLzwBVJTp0mH6wvJ CJXe/faNWhk3f5lYeD3za/HOsvm27AbS/k3BN3DliHpNnIIkiVZcsdDAeKawvWFvjmbj kA1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EcBk6Veg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si14201212pgg.636.2022.01.17.03.06.46; Mon, 17 Jan 2022 03:06:55 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EcBk6Veg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233879AbiAPWvB (ORCPT + 70 others); Sun, 16 Jan 2022 17:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbiAPWvA (ORCPT ); Sun, 16 Jan 2022 17:51:00 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68186C061574; Sun, 16 Jan 2022 14:51:00 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id ay4-20020a05600c1e0400b0034a81a94607so17674756wmb.1; Sun, 16 Jan 2022 14:51:00 -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 :cc; bh=RQNSz+9Ongl6D3vtokUiSrT++IM4wgxyZXz0eiKQvqI=; b=EcBk6VegNpRDxFNgkEtPbgyUSZGljDL6dhQ+CvYbTf6MsRixS6lVP7CJlHvMPBMBog ODv0rnjf1NuONh509lX8yXQMkJgTfIwNGkH5BAHkhABKV4pnw6AopApW/LdLrfoTB2vi wx5zh20eLh1p061bQh+5xVOgg8PLcTlcJVfLED38TR40AP2x/52ithvARtmb75mUW34f Yu4G9ZExfypcz5OLr8e7K7Comq25eGZTzYDPt/lrz2a7UXrTeytROFZfYjV0v/n8mpJf HrY/TCOhn2gnFHP7UIodHgLu6kyamimnoIPsqOr1uxuW+MoCFq/2PFz4cAQYeclZNX3Q oiQQ== 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:cc; bh=RQNSz+9Ongl6D3vtokUiSrT++IM4wgxyZXz0eiKQvqI=; b=d77Njyz9BccmjgZ0eluCGeVb112/43UBD9DnFmZEIENgFPHMOzFyWAd0yHoy/UtqCf 8VC+FWedZzZQ/pSIgiXJ59DISN8Pi/MOAS3jNgvKQZ9d0hzqFt96CbsU7h7Q7vWjoY+C ecr6SOzgC53DBvV1QCvzA4Ff0fnBENpmNYJFAZNQm3UkGd3SaXmL6AHyS/oAHtgU8s7t Hzbqi/tM/5ppxwBt38yYodkVwZUGRcBMBLgHd/evzfNl4PYVk4LkJM4CDTMVqA5DLWyG +TCMNY0XCaFAG/u0zEJRr30Et/+DhiRut+qPAhMu4F03DbYjeEEtgA7i0Uj3OA9BMnPK u/FQ== X-Gm-Message-State: AOAM533pkZAIppr2EFCxP9xoqU4rZbrj5BXrrDrHNCbdRAQe9H+zdYn4 zoU+ou8p/BovcaHXFBmmoN/2HOb7ep+B9RgQwXUJlTzpcp2G3Q== X-Received: by 2002:a1c:ed01:: with SMTP id l1mr25168995wmh.185.1642373458627; Sun, 16 Jan 2022 14:50:58 -0800 (PST) MIME-Version: 1.0 References: <20220112173312.764660-1-miquel.raynal@bootlin.com> <20220112173312.764660-19-miquel.raynal@bootlin.com> <20220113180709.0dade123@xps13> <20220114194425.3df06391@xps13> In-Reply-To: From: Alexander Aring Date: Sun, 16 Jan 2022 17:50:47 -0500 Message-ID: Subject: Re: [wpan-next v2 18/27] net: mac802154: Handle scan requests To: Miquel Raynal 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" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi, On Sun, 16 Jan 2022 at 17:44, Alexander Aring wrote: > > Hi, > > On Fri, 14 Jan 2022 at 13:44, Miquel Raynal wrote: > > > > 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 > > > > Please note that I think we cannot use netif_stop_queue() from context > outside of netif xmit() callback. It's because the atomic counter > itself is racy in xmit(), we need to be sure xmit() can't occur while > stopping the queue. I think maybe "netif_tx_disable()" is the right > call to stop from another context, because it holds the tx_lock, which > I believe is held while xmit(). > Where the wake queue call should be fine to call..., maybe we can > remove some EXPORT_SYMBOL() then? > I am sorry, that comment should go below. > I saw that some drivers call "ieee802154_wake_queue()" in error cases, > may we introduce a new helper "?ieee802154_xmit_error?" for error > cases so you can also catch error cases in your sync tx. See `grep -r > "ieee802154_wake_queue" drivers/net/ieee802154`, if we have more > information we might add more meaning into the error cases (e.g. > proper errno). maybe we can remove some EXPORT_SYMBOL() then? - Alex