Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1062970pxb; Fri, 1 Oct 2021 02:38:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJU27Cq9Qvr6XWg48G2TLRZExGNx3oq/r5QlnaDP4jmsRBYbvA3LwWbekDjSnBHJe8fZl0 X-Received: by 2002:a17:90b:38c6:: with SMTP id nn6mr11947282pjb.94.1633081128687; Fri, 01 Oct 2021 02:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633081128; cv=none; d=google.com; s=arc-20160816; b=onfKRTjFTZzFr62BfBYlurj7fLuB8y6Oape9TYsEcU4ZoTka3PJurbFnLORsIYkwDO MfkdkfOeqcW9ZEU4HXL7EGPhzcHG2jq8le3ALRF8VorvHMVF4M+SztvPaIBlN1o9hokB xC2Mj8uXFi318G8ewEn7iiMGc22JfAf09Ns0zkDDBmqtWtoK4hrP+xm/YlWVZZoshr2H z0iJ76O0YbHyVlUgMTJ2BMH8nBBMNoF3cFw2hUy//FoE6natIgPyx+hFjymk6w6o3NXJ /ycZnXMZgWi+kyfcgY9tiGNi9XF27gDM6cS/TbKdVxpRrUh1vdRNvqs/Ftt+0bnP3wVA V6KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=UylWFrypzKHATJDYn5toduBOHFqsvmmqAU4cKmYuch0=; b=KnxLLVTOB0ym1Yz0wNXr6Sx0OZY9awllSOHZWDRK7jznjCIivdWPgt+b5kPNiyuiub 2qel5Kp1ZiccxGvnik+9BvanR4PvZVOLhYztjR4Txzqa2F1bFEuSlNxFepvFAg+G7Xw8 8zssUPl4Xa+F6cIN7M7gxE1ZJO19TQ5lmpfmMb0Y8NtryfbqevGEwt0bBi63UcDmQq8I JACU4zbbjFzuCpSIufQ+upugfj6eJaLUzsX+2+HtfBlsA5//mtfxABXGS0EV4FJ9m7jF 6PzZdCCqblOo5AlsDyNDLxHQD6jH/F0f7z6FQ1ZMyD7Yv7OggEdK+QXTGp5y88/ECEfq 51dA== 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 z12si6662377pgp.539.2021.10.01.02.38.36; Fri, 01 Oct 2021 02:38:48 -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 S1353071AbhJAJj1 (ORCPT + 77 others); Fri, 1 Oct 2021 05:39:27 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:39386 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1352790AbhJAJj0 (ORCPT ); Fri, 1 Oct 2021 05:39:26 -0400 X-UUID: 0609553555314843a80af864e8aedb73-20211001 X-UUID: 0609553555314843a80af864e8aedb73-20211001 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1374579807; Fri, 01 Oct 2021 17:37:39 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 1 Oct 2021 17:37:37 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 1 Oct 2021 17:37:37 +0800 From: Shayne Chen To: Felix Fietkau CC: linux-wireless , Lorenzo Bianconi , Ryder Lee , "Evelyn Tsai" , linux-mediatek , Shayne Chen Subject: [PATCH v3 1/2] mt76: mt7915: add WA firmware log support Date: Fri, 1 Oct 2021 17:36:35 +0800 Message-ID: <20211001093636.10501-1-shayne.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Support to turn on/off WA firmware log from debugfs. Signed-off-by: Shayne Chen --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 42 +++++++++++++++---- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 12 +++++- .../net/wireless/mediatek/mt76/mt7915/mcu.h | 6 +++ .../wireless/mediatek/mt76/mt7915/mt7915.h | 5 ++- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index 8c1725c00126..b9689762f529 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -82,7 +82,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_trigger, NULL, mt7915_radar_trigger, "%lld\n"); static int -mt7915_fw_debug_set(void *data, u64 val) +mt7915_fw_debug_wm_set(void *data, u64 val) { struct mt7915_dev *dev = data; enum { @@ -93,28 +93,51 @@ mt7915_fw_debug_set(void *data, u64 val) DEBUG_RPT_RX, } debug; - dev->fw_debug = !!val; + dev->fw_debug_wm = val ? MCU_FW_LOG_TO_HOST : 0; - mt7915_mcu_fw_log_2_host(dev, dev->fw_debug ? 2 : 0); + mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, dev->fw_debug_wm); for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) - mt7915_mcu_fw_dbg_ctrl(dev, debug, dev->fw_debug); + mt7915_mcu_fw_dbg_ctrl(dev, debug, !!dev->fw_debug_wm); return 0; } static int -mt7915_fw_debug_get(void *data, u64 *val) +mt7915_fw_debug_wm_get(void *data, u64 *val) { struct mt7915_dev *dev = data; - *val = dev->fw_debug; + *val = dev->fw_debug_wm; return 0; } -DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug, mt7915_fw_debug_get, - mt7915_fw_debug_set, "%lld\n"); +DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_wm, mt7915_fw_debug_wm_get, + mt7915_fw_debug_wm_set, "%lld\n"); + +static int +mt7915_fw_debug_wa_set(void *data, u64 val) +{ + struct mt7915_dev *dev = data; + + dev->fw_debug_wa = val ? MCU_FW_LOG_TO_HOST : 0; + + return mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, dev->fw_debug_wa); +} + +static int +mt7915_fw_debug_wa_get(void *data, u64 *val) +{ + struct mt7915_dev *dev = data; + + *val = dev->fw_debug_wa; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_wa, mt7915_fw_debug_wa_get, + mt7915_fw_debug_wa_set, "%lld\n"); static void mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy, @@ -455,7 +478,8 @@ int mt7915_init_debugfs(struct mt7915_dev *dev) debugfs_create_devm_seqfile(dev->mt76.dev, "hw-queues", dir, mt7915_hw_queues_read); debugfs_create_file("tx_stats", 0400, dir, dev, &mt7915_tx_stats_fops); - debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug); + debugfs_create_file("fw_debug_wm", 0600, dir, dev, &fops_fw_debug_wm); + debugfs_create_file("fw_debug_wa", 0600, dir, dev, &fops_fw_debug_wa); debugfs_create_file("implicit_txbf", 0600, dir, dev, &fops_implicit_txbf); debugfs_create_u32("dfs_hw_pattern", 0400, dir, &dev->hw_pattern); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 7415b9391175..419b2acad41d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -2824,7 +2824,7 @@ static int mt7915_load_firmware(struct mt7915_dev *dev) return 0; } -int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 ctrl) +int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl) { struct { u8 ctrl_val; @@ -2833,6 +2833,10 @@ int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 ctrl) .ctrl_val = ctrl }; + if (type == MCU_FW_LOG_WA) + return mt76_mcu_send_msg(&dev->mt76, MCU_WA_EXT_CMD(FW_LOG_2_HOST), + &data, sizeof(data), true); + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(FW_LOG_2_HOST), &data, sizeof(data), true); } @@ -2889,7 +2893,11 @@ int mt7915_mcu_init(struct mt7915_dev *dev) return ret; set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); - ret = mt7915_mcu_fw_log_2_host(dev, 0); + ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0); + if (ret) + return ret; + + ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0); if (ret) return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h index e02659272f9e..4a601bdee156 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h @@ -230,6 +230,12 @@ enum { }; +enum { + MCU_FW_LOG_WM, + MCU_FW_LOG_WA, + MCU_FW_LOG_TO_HOST, +}; + #define __MCU_CMD_FIELD_ID GENMASK(7, 0) #define __MCU_CMD_FIELD_EXT_ID GENMASK(15, 8) #define __MCU_CMD_FIELD_QUERY BIT(16) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index ff3be5ba2ce9..50c7c8c09d83 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -184,8 +184,9 @@ struct mt7915_dev { bool dbdc_support; bool flash_mode; - bool fw_debug; bool ibf; + u8 fw_debug_wm; + u8 fw_debug_wa; void *cal; }; @@ -355,7 +356,7 @@ int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct rate_info *rate); int mt7915_mcu_rdd_cmd(struct mt7915_dev *dev, enum mt7915_rdd_cmd cmd, u8 index, u8 rx_sel, u8 val); -int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 ctrl); +int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl); int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level); void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb); void mt7915_mcu_exit(struct mt7915_dev *dev); -- 2.25.1