From patchwork Sun Dec 22 20:11:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11307683 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A60FF138C for ; Sun, 22 Dec 2019 20:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79C03205C9 for ; Sun, 22 Dec 2019 20:11:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="i2+Bb54o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726777AbfLVULz (ORCPT ); Sun, 22 Dec 2019 15:11:55 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:48471 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725951AbfLVULz (ORCPT ); Sun, 22 Dec 2019 15:11:55 -0500 X-UUID: a72950ab0d3f4d32b3219b6bd3bea13e-20191223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=snNLFpI6iD8KtzouGrFPprybGRM2xQ+mm0t3hSBGidE=; b=i2+Bb54ojTGwYYLziYsEEQ7jKyUOoN5k1KZU2T8nMysfls3UjEDX3n5xjtwWqPR2+61FmJEjWd4N/dMjwlbEzijmo7kEyZb2Oqkghz1bb6BbvG6qn20hxiBr7w3PLbMJGM68qWsB/jlOF2M+GpCeEnotIY8MohTA2we8qFbLZic=; X-UUID: a72950ab0d3f4d32b3219b6bd3bea13e-20191223 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 2087857733; Mon, 23 Dec 2019 04:11:43 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 23 Dec 2019 04:11:16 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 23 Dec 2019 04:10:50 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: , , , Ryder Lee Subject: [PATCH v1 1/2] mt76: mt7615: rework set_channel function Date: Mon, 23 Dec 2019 04:11:38 +0800 Message-ID: <9a37e1340cc8c546587d7cf99d6c4d92e12e1a7d.1577044827.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-TM-SNTS-SMTP: 61A9F353F740679A2FA70EC917627447E2E9DB04B5870975D8AE200DC81804D42000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org No need to send both MCU_EXT_CMD_SET_RX_PATH and MCU_EXT_CMD_CHANNEL_SWITCH together to MCU. Split them out by passing the proper command in the corresponding flow. Signed-off-by: Ryder Lee --- Changes since v1: - add MCU_EXT_CMD_SET_RX_PATH to avoid creating a regression --- .../net/wireless/mediatek/mt76/mt7615/main.c | 5 ++++- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 18 ++++-------------- .../net/wireless/mediatek/mt76/mt7615/mt7615.h | 2 +- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index 4ffa920d4f4d..90c4e785a1a3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -11,6 +11,7 @@ #include #include #include "mt7615.h" +#include "mcu.h" static bool mt7615_dev_running(struct mt7615_dev *dev) { @@ -47,6 +48,8 @@ static int mt7615_start(struct ieee80211_hw *hw) mt7615_mcu_set_mac_enable(dev, 1, true); } + mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH); + set_bit(MT76_STATE_RUNNING, &phy->mt76->state); if (running) @@ -224,7 +227,7 @@ static int mt7615_set_channel(struct mt7615_phy *phy) phy->dfs_state = -1; mt76_set_channel(phy->mt76); - ret = mt7615_mcu_set_channel(phy); + ret = mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_CHANNEL_SWITCH); if (ret) goto out; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index fc091278d9e5..ffd09c8670d4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -1364,12 +1364,11 @@ int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev) &req, sizeof(req), false); } -int mt7615_mcu_set_channel(struct mt7615_phy *phy) +int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd) { struct mt7615_dev *dev = phy->dev; struct cfg80211_chan_def *chandef = &phy->mt76->chandef; int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2; - u8 n_chains = hweight8(phy->mt76->antenna_mask); struct { u8 control_chan; u8 center_chan; @@ -1391,11 +1390,10 @@ int mt7615_mcu_set_channel(struct mt7615_phy *phy) } req = { .control_chan = chandef->chan->hw_value, .center_chan = ieee80211_frequency_to_channel(freq1), - .tx_streams = n_chains, - .rx_streams_mask = n_chains, + .tx_streams = hweight8(phy->mt76->antenna_mask), + .rx_streams_mask = phy->chainmask, .center_chan2 = ieee80211_frequency_to_channel(freq2), }; - int ret; if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD; @@ -1434,15 +1432,7 @@ int mt7615_mcu_set_channel(struct mt7615_phy *phy) } memset(req.txpower_sku, 0x3f, 49); - ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_CHANNEL_SWITCH, - &req, sizeof(req), true); - if (ret) - return ret; - - req.rx_streams_mask = phy->chainmask; - - return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_SET_RX_PATH, - &req, sizeof(req), true); + return __mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true); } int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index 48810eda1cd6..fb461e761d59 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -251,7 +251,7 @@ int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif, struct ieee80211_sta *sta, bool en); int mt7615_mcu_set_bcn(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int en); -int mt7615_mcu_set_channel(struct mt7615_phy *phy); +int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd); int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue, const struct ieee80211_tx_queue_params *params); int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev,