Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5432952rwb; Wed, 17 Aug 2022 18:05:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WAqkjjFJUWNrY0UW6/u5m3cBDtN5GhAx0O9lxH0FRi5WH0v+02mTu7K4YLszZcBwyWvAi X-Received: by 2002:a17:907:271b:b0:730:aa8e:74eb with SMTP id w27-20020a170907271b00b00730aa8e74ebmr390693ejk.478.1660784729740; Wed, 17 Aug 2022 18:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660784729; cv=none; d=google.com; s=arc-20160816; b=wP4SJgyXXGp4ui0dO//WT7R0GN7B8zbDZCczjt4T4IoqAnOMQWC+3//QvySBvsYAZx CeqO6EY6Up0lWN8qKckuBRVFK2BI/RhHz1U04E+CjpGBPOp3wGf83XJpTTPcf0ASKrY9 1AvxQeHFx4vgMo+FDg4gf3pnPT2lydXydnkCNRgNgH1MzzqVrzWosnOrVmLJ6kI6lybL 5QDs0srLlUhskFLFrdiydbVF018b66MWPxz3dIFDl3nBtWe57oNRonMzXdRZt3y5HErk g86MzjcHADOzV4hB2QB2Sv29NIhQyH8UbKGDsz9qdMxDlc41ZzvdEesuKg/eSK9JuDOS Yveg== 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=SI7RFlp0x+DBJDSS3/HfizGBcM9feWYKDKG4bjli0GA=; b=mybtO8Q+iEMV8vOFUYC1H59Ut+z89bxaL+O+ovfO7BnZgyU0F1O9XvvZblfUUd0a3n HBn5z2lNq5qhHNTAJdGZALArl10Q7YoGr7aWICubnQANlWQ+8y/ku97z/F9i1QUiPlr9 tGapFBxtu9HNPEuShbCLpvYPK2RzV6EbrWvXbt3MkKSsC0OwjBWhuLt1opi9tXkwc550 Ic+vNw3vQDpWI3qnXWVxd3uk8Q7+QNsa7hHU7/U+skWFN6SnkIJxNk0bCr8pJ0/MPwvW XVLP3xCP6j7OvvBwa4jbaAl2n/LWn6CfQ/II22S0HTmmKT+hfwKSP8LgascI/9tlXYDq 5exg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="VFfn/5yH"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn7-20020a05640222e700b0043c7ceb229asi165020edb.207.2022.08.17.18.05.13; Wed, 17 Aug 2022 18:05:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="VFfn/5yH"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239076AbiHRBD2 (ORCPT + 65 others); Wed, 17 Aug 2022 21:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233425AbiHRBDY (ORCPT ); Wed, 17 Aug 2022 21:03:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3520D9FE0 for ; Wed, 17 Aug 2022 18:03:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EAA7A613FB for ; Thu, 18 Aug 2022 01:03:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5643AC433D7 for ; Thu, 18 Aug 2022 01:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660784597; bh=rWdT6qEModoSI9xXRcIpm8iqNE6nUY/RnIJFj+s1hjs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VFfn/5yHujdXlip5BPm0k4QrS9IltOL1xcC4sXAB/iuvQqe8vsUDdIF5L+2ZWhvca Oua+zDm7GLtrGpQIuh7UY16Y8/QQnuAQ6YVxmACK4ChnkS603lawcj8/mA03yn5Xoc z6d97vQnYNwxu1M71cE84b5QoU7kXrswS+WsggIral07Dg96eyjxPTngX4fDS6dsXg oRAW7i2z5GmOfpJ2fhnlyLg1Wo9hAxnDtlUG/Z6fDTzyDmpkpYH7G03+CWNYuSqy7T w6DG4vAeNpaLQaT3OEanHt/nst3s0hIYUKQqVDoUTRKPecKzQCa7nf6P3ZJnfqSOCi UOmMjr10x/UEg== Received: by mail-wr1-f42.google.com with SMTP id bs25so50419wrb.2 for ; Wed, 17 Aug 2022 18:03:17 -0700 (PDT) X-Gm-Message-State: ACgBeo2js5bFu4J+vxrkkg3I+EuSpXbB3K0kEmTFNplJC08FNWqzehfQ lNNms0NNWzBibtlrH9IwVGCcZIdnm8D1dDl2Hvw= X-Received: by 2002:a5d:4601:0:b0:21d:8db4:37c with SMTP id t1-20020a5d4601000000b0021d8db4037cmr240113wrq.390.1660784595575; Wed, 17 Aug 2022 18:03:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sean Wang Date: Wed, 17 Aug 2022 18:03:03 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 8/9] wifi: mt76: mt7921: introduce remain_on_channel support To: Lorenzo Bianconi Cc: =?UTF-8?B?U2VhbiBXYW5nICjnjovlv5fkupgp?= , Felix Fietkau , lorenzo.bianconi@redhat.com, Soul.Huang@mediatek.com, YN.Chen@mediatek.com, Leon.Yen@mediatek.com, Eric-SY.Chang@mediatek.com, Deren Wu , km.lin@mediatek.com, jenhao.yang@mediatek.com, robin.chiu@mediatek.com, Eddie.Chen@mediatek.com, ch.yeh@mediatek.com, posh.sun@mediatek.com, ted.huang@mediatek.com, Stella.Chang@mediatek.com, Tom.Chou@mediatek.com, steve.lee@mediatek.com, jsiuda@google.com, frankgor@google.com, kuabhs@google.com, druth@google.com, abhishekpandit@google.com, shawnku@google.com, linux-wireless@vger.kernel.org, "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Lorenzo, On Wed, Aug 17, 2022 at 12:18 AM Lorenzo Bianconi wrote: > > > From: Sean Wang > > > > Introduce remain_on_channel support. Additionally, we add > > mt7921_check_offload_capability to disable .remain_on_channel and > > .cancel_remain_on_channel and related configuration because those > > operations would rely on the fundamental MCU commands that will be only > > supported with newer firmware. > > > > Co-developed-by: Deren Wu > > Signed-off-by: Deren Wu > > Signed-off-by: Sean Wang > > --- > > .../net/wireless/mediatek/mt76/mt7921/init.c | 36 ++++++ > > .../net/wireless/mediatek/mt76/mt7921/main.c | 112 ++++++++++++++++++ > > .../net/wireless/mediatek/mt76/mt7921/mcu.c | 24 ++++ > > .../wireless/mediatek/mt76/mt7921/mt7921.h | 34 ++++++ > > .../net/wireless/mediatek/mt76/mt7921/pci.c | 13 +- > > .../net/wireless/mediatek/mt76/mt7921/sdio.c | 11 +- > > .../net/wireless/mediatek/mt76/mt7921/usb.c | 1 + > > 7 files changed, 225 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c > > index cd960e23770f..1b7a18d42f5b 100644 > > --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c > > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c > > @@ -44,6 +44,35 @@ mt7921_regd_notifier(struct wiphy *wiphy, > > mt7921_mutex_release(dev); > > } > > > > +static int mt7921_check_offload_capability(struct mt7921_dev *dev) > > +{ > > + struct ieee80211_hw *hw = mt76_hw(dev); > > + int year, mon, day, hour, min, sec; > > + struct wiphy *wiphy = hw->wiphy; > > + bool fw_can_roc = false; > > + int ret; > > + > > + ret = sscanf(dev->mt76.hw->wiphy->fw_version + 11, "%4d%2d%2d%2d%2d%2d", > > + &year, &mon, &day, &hour, &min, &sec); > > does the fw have a differnt base version with respect to the previous ones? > checking the date is a bit ugly. I admitted that way was a bit ugly, but I have investigated for a while, and that is the only way we can use to distinguish the version in current mt7921 firmware. > > > + if (ret != 6) > > + goto out; > > + > > + /* Old firmware cannot support remained on channel and channel > > + * context management. > > + */ > > + fw_can_roc = mktime64(year, mon, day, hour, min, sec) >= > > + mktime64(2022, 7, 15, 12, 1, 1); > > +out: > > + if (!fw_can_roc) { > > + dev->ops->remain_on_channel = NULL; > > + dev->ops->cancel_remain_on_channel = NULL; > > + > > + wiphy->flags &= ~WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; > > + } > > + > > + return 0; > > +} > > + > > - mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7921_ops, > > - &drv_ops); > > + ops = devm_kmemdup(&pdev->dev, &mt7921_ops, sizeof(mt7921_ops), > > + GFP_KERNEL); > > why do we need to copy mt7921_ops? > As the old fw cannot support the roc and chanctx and considering backward compatibility, I need to copy the mt7921_ops here and disable related operations for old fw before registering the hw to mac80211. Sean > Regards, > Lorenzo > > > + if (!ops) { > > + ret = -ENOMEM; > > + goto err_free_pci_vec; > > + } > > + > > + mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), ops, &drv_ops); > > if (!mdev) { > > ret = -ENOMEM; > > goto err_free_pci_vec; > > @@ -286,7 +293,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev, > > > > dev = container_of(mdev, struct mt7921_dev, mt76); > > dev->hif_ops = &mt7921_pcie_ops; > > - > > + dev->ops = ops; > > mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]); > > tasklet_init(&dev->irq_tasklet, mt7921_irq_tasklet, (unsigned long)dev); > > > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c b/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c > > index 487acd6e2be8..6d27875f41b8 100644 > > --- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c > > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c > > @@ -120,18 +120,23 @@ static int mt7921s_probe(struct sdio_func *func, > > .fw_own = mt7921s_mcu_fw_pmctrl, > > }; > > > > + struct ieee80211_ops *ops; > > struct mt7921_dev *dev; > > struct mt76_dev *mdev; > > int ret; > > > > - mdev = mt76_alloc_device(&func->dev, sizeof(*dev), &mt7921_ops, > > - &drv_ops); > > + ops = devm_kmemdup(&func->dev, &mt7921_ops, sizeof(mt7921_ops), > > + GFP_KERNEL); > > + if (!ops) > > + return -ENOMEM; > > + > > + mdev = mt76_alloc_device(&func->dev, sizeof(*dev), ops, &drv_ops); > > if (!mdev) > > return -ENOMEM; > > > > dev = container_of(mdev, struct mt7921_dev, mt76); > > dev->hif_ops = &mt7921_sdio_ops; > > - > > + dev->ops = ops; > > sdio_set_drvdata(func, dev); > > > > ret = mt76s_init(mdev, func, &mt7921s_ops); > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/usb.c b/drivers/net/wireless/mediatek/mt76/mt7921/usb.c > > index d06cee386acd..cf3ec59a4270 100644 > > --- a/drivers/net/wireless/mediatek/mt76/mt7921/usb.c > > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/usb.c > > @@ -217,6 +217,7 @@ static int mt7921u_probe(struct usb_interface *usb_intf, > > > > dev = container_of(mdev, struct mt7921_dev, mt76); > > dev->hif_ops = &hif_ops; > > + dev->ops = ops; > > > > udev = usb_get_dev(udev); > > usb_reset_device(udev); > > -- > > 2.25.1 > >