Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2894652pxb; Tue, 12 Oct 2021 16:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2QE4MHgW8RQiYHsgw3eDYGxBu8CCPKRwWzP6l0lX0hXPIOeFIH6w6uR+QXsiUL05vx6E+ X-Received: by 2002:a17:902:9a83:b0:13e:5b1e:aa40 with SMTP id w3-20020a1709029a8300b0013e5b1eaa40mr32767597plp.41.1634079798475; Tue, 12 Oct 2021 16:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634079798; cv=none; d=google.com; s=arc-20160816; b=uwjCB7j2qhOjRLOIu2RmANQB7/c+PMokc+fO8/eYAWPBIt4gOYasm+b1omPnCvHzcn hyYcKLQkJT95FMB+gjRKEyinTRhsLzFKs0qSL7fVb8vKgXJEbazQLBKfv5NzNHR8ihHx i6HSZffP9WTcbmx8H714IlQyI6VIIMdyDc0hYuLe2Qql4qeBac2WuCOJC1a3Z9Cl+KDR 00GnyAXaI1PrOLXrXDUEmeIfayE2a5s0G7ltw6iTDS2TfOYenXervG04XwnUi0IsLmaQ uWwLH3pAjBe+jce/FV7SI0jg99BhsJf8MMp6c7SVNyyNcXkmLb31qb5izJjM6Tby0PJI B/tA== 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=2O9zS+TZZGj3/O+cwvNXDYTDHHR36V4/xp40khRVFJM=; b=jK/8n8XFtRP/szig6DtgH3rRCwlZS9lge7bqj7pqLvO+9274+hn8Ioogt4qqxhufL2 Kq34q1nq38wodcJgkeb/aWuZYtFSEhBEwy9G21fbCdBxYTdBLFuWxS56afCahWlfTu0S kPbRe/oQDnniZkMbRqGTTq1JcFbcdN2wtqjR3xxSZaSmkIBE2C33C1Mt4XEHj0iaL7aV HGJBuUiabfJowNViHK856mTcLAMGfuLDmjI9BWg8sklEzjTdj1URYmPuCKlWHFBYC4tb +pVgYrmWxp16uIB8iihoB2gV9f82m/XrapFk2UfnUVAOI86sGypFuCERBCvkUMgSYq91 9bhA== 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 j7si19793346plh.318.2021.10.12.16.02.59; Tue, 12 Oct 2021 16:03:18 -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 S235863AbhJLXEy (ORCPT + 63 others); Tue, 12 Oct 2021 19:04:54 -0400 Received: from mailgw02.mediatek.com ([216.200.240.185]:31520 "EHLO mailgw02.mediatek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234005AbhJLXEx (ORCPT ); Tue, 12 Oct 2021 19:04:53 -0400 X-UUID: 623d4b6ba52648d09742225da540072f-20211012 X-UUID: 623d4b6ba52648d09742225da540072f-20211012 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1611114897; Tue, 12 Oct 2021 16:02:50 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 12 Oct 2021 15:52:55 -0700 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 13 Oct 2021 06:52:54 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 14/16] mt76: mt7921: refactor mt7921_mcu_send_message Date: Wed, 13 Oct 2021 06:52:07 +0800 Message-ID: <3f770ad8fa14c6c424581b7c2d7dbeeaf1c6521b.1634077769.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 mt7921s and mt7921e. Tested-by: Deren Wu Acked-by: Lorenzo Bianconi 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 432aa534733d..7a9573b977f6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -224,12 +224,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; @@ -251,10 +250,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); @@ -318,9 +315,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