Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp53015pxb; Tue, 14 Sep 2021 18:25:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygNKW3a2semwg0FbZw7aokV360ETGUUBGunOAuZTvEDWhf2TGouH45nHNR4TPjnh8kU/he X-Received: by 2002:a05:6638:1352:: with SMTP id u18mr17274527jad.147.1631669139866; Tue, 14 Sep 2021 18:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631669139; cv=none; d=google.com; s=arc-20160816; b=G4JJ8Vy+4MK5rqHz8UXc3bAH9xQjolesMRShZ6UaFc8F9JqrWMMm0Hy4/T3NeScYmF DMV414rFF9dIxovqnmf10UHPCIeWHNy4DVsPzkDd2dC0il1tSrtQxsOT94r1I0cVlDXZ Gx/EUBfpa7xEpwT1GEkggt9Df0sy+vaVErmxbgyDF1Mc0MIJ7UWqYcMqhLDf+NIaJ02F jBFlLgM9irfh9+WZ8agWVrxOGidT6Nz5Dwv0/NuMx/jVQmEryjuLzGs4ctPUD8SMZB4F MTP+hAnjIy7o1SPNWNeSc3CxmcyeOssDGYj+FwUjpiomsSoEXlDT66nwoYVh6E3eRGul Enkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=8oHy+zbYIVGuSLAO/7T0oVyBPAlGw1A+JM3yBj0JhCY=; b=BxPpWMWsmAsQRwNwCwCNCRT0l0QEPEV5GELxIeT5++LNo6j0Fmz1cn4iox+nQHUPz1 IT6Q62iYQG3lvAz0VxGQL5VHWwBpeKe/2Up+SpXlIS9hrOTyiBhefpD8uupkBV8XbWhM UQLiYeKJjiMxPn2RzcrwvEN32pqY924P9/1GWfvETNh0WGKLvy2Oo0qNwhfPbuk9lb/E Pgl7n2EHbQBgwTxlGjq3e83Rt43XnhYFmy7kmQcgIdlI7zz52bxzA05zttbLXM4kDbJt 2tCmORlk6Dkq+POap7OHGmTe56SUG4M1DWmLfdCX0s0B2hGe7Hzvu2rOuP0dgQjZ+OQV QQtw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si9994420ilm.87.2021.09.14.18.25.27; Tue, 14 Sep 2021 18:25:39 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231156AbhIOB0i (ORCPT + 99 others); Tue, 14 Sep 2021 21:26:38 -0400 Received: from mailgw01.mediatek.com ([216.200.240.184]:53475 "EHLO mailgw01.mediatek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhIOB0i (ORCPT ); Tue, 14 Sep 2021 21:26:38 -0400 X-UUID: 5c3ebdeeeda14d98acc7616cf8967cfe-20210914 X-UUID: 5c3ebdeeeda14d98acc7616cf8967cfe-20210914 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2138603018; Tue, 14 Sep 2021 18:25:18 -0700 Received: from mtkcas11.mediatek.inc (172.21.101.40) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 14 Sep 2021 18:15:51 -0700 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 15 Sep 2021 09:15:50 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v1 14/16] mt76: mt7921: refactor mt7921_mcu_send_message Date: Wed, 15 Sep 2021 09:14:47 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang This is a preliminary patch to introduce mt7921s support. Refactor mt7921_mcu_send_message to be sharable between mt7921e and mt7921e. Tested-by: Deren Wu Signed-off-by: Sean Wang --- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 11 ++++------- .../net/wireless/mediatek/mt76/mt7921/mt7921.h | 2 +- .../wireless/mediatek/mt76/mt7921/pci_mcu.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index b3e257594f92..2de5a2ba43b2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -227,12 +227,11 @@ EXPORT_SYMBOL_GPL(mt7921_mcu_parse_response); int -mt7921_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, +mt7921_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb, int cmd, int *wait_seq) { struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); int txd_len, mcu_cmd = cmd & MCU_CMD_MASK; - enum mt76_mcuq_id txq = MT_MCUQ_WM; struct mt7921_uni_txd *uni_txd; struct mt7921_mcu_txd *mcu_txd; __le32 *txd; @@ -254,10 +253,8 @@ mt7921_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, if (!seq) seq = ++dev->mt76.mcu.msg_seq & 0xf; - if (cmd == MCU_CMD_FW_SCATTER) { - txq = MT_MCUQ_FWDL; + if (cmd == MCU_CMD_FW_SCATTER) goto exit; - } txd_len = cmd & MCU_UNI_PREFIX ? sizeof(*uni_txd) : sizeof(*mcu_txd); txd = (__le32 *)skb_push(skb, txd_len); @@ -321,9 +318,9 @@ mt7921_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, if (wait_seq) *wait_seq = seq; - return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[txq], skb, 0); + return 0; } -EXPORT_SYMBOL_GPL(mt7921_mcu_send_message); +EXPORT_SYMBOL_GPL(mt7921_mcu_fill_message); static void mt7921_mcu_scan_event(struct mt7921_dev *dev, struct sk_buff *skb) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index bd52e39e8181..01c356b315ec 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -376,7 +376,7 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi, bool beacon); void mt7921_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi); void mt7921_mac_sta_poll(struct mt7921_dev *dev); -int mt7921_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, +int mt7921_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb, int cmd, int *wait_seq); int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, struct sk_buff *skb, int seq); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c index 9ac3bc25f067..583a89a34734 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c @@ -18,6 +18,24 @@ static int mt7921e_driver_own(struct mt7921_dev *dev) return 0; } +static int +mt7921_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, + int cmd, int *seq) +{ + struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); + enum mt76_mcuq_id txq = MT_MCUQ_WM; + int ret; + + ret = mt7921_mcu_fill_message(mdev, skb, cmd, seq); + if (ret) + return ret; + + if (cmd == MCU_CMD_FW_SCATTER) + txq = MT_MCUQ_FWDL; + + return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[txq], skb, 0); +} + int mt7921e_mcu_init(struct mt7921_dev *dev) { static const struct mt76_mcu_ops mt7921_mcu_ops = { -- 2.25.1