Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp333218pxb; Sat, 18 Sep 2021 04:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJP2cEA9OQ/zBVRhsQUvOfMyWkCleITv/NZ7h2xSysceI2l7AgZIIc7TE9lsZbas8kDhI2 X-Received: by 2002:a05:6e02:2194:: with SMTP id j20mr10549179ila.268.1631963845321; Sat, 18 Sep 2021 04:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631963845; cv=none; d=google.com; s=arc-20160816; b=tBm2hLFKKmmUGRyF0VNWqnV5ab/54dfjhyHQLtPJupj1NybT1Tu6qmDREQdmTkyy/W sUhREbhylRQQTnbkRRqZ+92aUjH9TkahuvjGi69zSC/MUTQigIuVGvUC1DYNCGdVAnBc 6maU7bTYXq3i4e2Ws+VL8j1+eA0968xuMpaeFpIOm6hP//x6X+0RdjsC7677btE3Imj7 gIHTXrvDxKJ0tFVkd1Cd1ajKtkgg0zvzFVfHzvGcNSK2gC/j47O8+Tq0+V13VlXTaZKM 6IvCvTwNPsO6Hpc5D2ueW6LeOg7HCZTN6ZkiSNz5qLee5jKpFJrbIVnb7aBvyUMTzd9/ f33w== 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=hlc6dsYT1dBrpYS7vgXpbF1ZIpoEsiYUrqnjatu7/kY=; b=ZEGTdBcALb1MEpeYJAjhZz2dSlPu5QnJW76EbbqPKvT04vGdyqDZarc+VY76ui8EPI GNbDWzjhz9ttZn0RV0T7i04UymGLSgDL7qL3KqEFqqkiOq8sqRE1abyrv8Aayuz+iniW Yifu3e7j/o5BbeTS1oqoNp/gL3vlsXZU/8z3O/QnyGld+eV51fxeP2U8f7fhcGcGpLD/ MA109BDowxml3u1kVUICjmUPzNhALBNogIz1ki3fenuNn6XhJV5ktvWEvNG6gpZe5grc XT7vUV3SmJeTFga6BkAqerz2IQvyb5P4IS3o8sP4pJprXSIst98eoKdnHoPl+Tcwe5/7 n5og== 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 m11si5195268ilh.66.2021.09.18.04.16.39; Sat, 18 Sep 2021 04:17:25 -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 S1344190AbhIRALJ (ORCPT + 78 others); Fri, 17 Sep 2021 20:11:09 -0400 Received: from mailgw01.mediatek.com ([216.200.240.184]:63455 "EHLO mailgw01.mediatek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242810AbhIRALI (ORCPT ); Fri, 17 Sep 2021 20:11:08 -0400 X-UUID: 7f0555820b8949f2983713966d2dfd5a-20210917 X-UUID: 7f0555820b8949f2983713966d2dfd5a-20210917 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 880480670; Fri, 17 Sep 2021 17:09:45 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Sep 2021 17:00:32 -0700 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 18 Sep 2021 08:00:32 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 14/16] mt76: mt7921: refactor mt7921_mcu_send_message Date: Sat, 18 Sep 2021 07:59:30 +0800 Message-ID: <9a52336fcd705f448e4a05823a1457208212af6e.1631918993.git.objelf@gmail.com> 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 10e1ee505716..2c65fe23a83c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -225,12 +225,11 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, EXPORT_SYMBOL_GPL(mt7921_mcu_parse_response); -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) { 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; @@ -252,10 +251,8 @@ int 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); @@ -319,9 +316,9 @@ int 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 2082b4d2a23d..f4b85ec530bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -381,7 +381,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