Commit 9b121acd authored by Shayne Chen's avatar Shayne Chen Committed by Felix Fietkau
Browse files

mt76: mt7915: add WA firmware log support



Support to turn on/off WA firmware log from debugfs.

Signed-off-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 2be10a97
Loading
Loading
Loading
Loading
+40 −10
Original line number Original line Diff line number Diff line
@@ -82,7 +82,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_trigger, NULL,
			 mt7915_radar_trigger, "%lld\n");
			 mt7915_radar_trigger, "%lld\n");


static int
static int
mt7915_fw_debug_set(void *data, u64 val)
mt7915_fw_debug_wm_set(void *data, u64 val)
{
{
	struct mt7915_dev *dev = data;
	struct mt7915_dev *dev = data;
	enum {
	enum {
@@ -92,29 +92,58 @@ mt7915_fw_debug_set(void *data, u64 val)
		DEBUG_SPL,
		DEBUG_SPL,
		DEBUG_RPT_RX,
		DEBUG_RPT_RX,
	} debug;
	} debug;
	int ret;

	dev->fw_debug_wm = val ? MCU_FW_LOG_TO_HOST : 0;

	ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, dev->fw_debug_wm);
	if (ret)
		return ret;


	dev->fw_debug = !!val;
	for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) {
		ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, !!dev->fw_debug_wm);
		if (ret)
			return ret;
	}

	return 0;
}


	mt7915_mcu_fw_log_2_host(dev, dev->fw_debug ? 2 : 0);
static int
mt7915_fw_debug_wm_get(void *data, u64 *val)
{
	struct mt7915_dev *dev = data;


	for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++)
	*val = dev->fw_debug_wm;
		mt7915_mcu_fw_dbg_ctrl(dev, debug, dev->fw_debug);


	return 0;
	return 0;
}
}


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
static int
mt7915_fw_debug_get(void *data, u64 *val)
mt7915_fw_debug_wa_get(void *data, u64 *val)
{
{
	struct mt7915_dev *dev = data;
	struct mt7915_dev *dev = data;


	*val = dev->fw_debug;
	*val = dev->fw_debug_wa;


	return 0;
	return 0;
}
}


DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug, mt7915_fw_debug_get,
DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_wa, mt7915_fw_debug_wa_get,
			 mt7915_fw_debug_set, "%lld\n");
			 mt7915_fw_debug_wa_set, "%lld\n");


static void
static void
mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy,
mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy,
@@ -460,7 +489,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
	debugfs_create_file("xmit-queues", 0400, dir, phy,
	debugfs_create_file("xmit-queues", 0400, dir, phy,
			    &mt7915_xmit_queues_fops);
			    &mt7915_xmit_queues_fops);
	debugfs_create_file("tx_stats", 0400, dir, phy, &mt7915_tx_stats_fops);
	debugfs_create_file("tx_stats", 0400, dir, phy, &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,
	debugfs_create_file("implicit_txbf", 0600, dir, dev,
			    &fops_implicit_txbf);
			    &fops_implicit_txbf);
	debugfs_create_file("txpower_sku", 0400, dir, phy,
	debugfs_create_file("txpower_sku", 0400, dir, phy,
+10 −2
Original line number Original line Diff line number Diff line
@@ -2980,7 +2980,7 @@ static int mt7915_load_firmware(struct mt7915_dev *dev)
	return 0;
	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 {
	struct {
		u8 ctrl_val;
		u8 ctrl_val;
@@ -2989,6 +2989,10 @@ int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 ctrl)
		.ctrl_val = 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,
	return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(FW_LOG_2_HOST), &data,
				 sizeof(data), true);
				 sizeof(data), true);
}
}
@@ -3101,7 +3105,11 @@ int mt7915_mcu_init(struct mt7915_dev *dev)
		return ret;
		return ret;


	set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
	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)
	if (ret)
		return ret;
		return ret;


+5 −0
Original line number Original line Diff line number Diff line
@@ -229,6 +229,11 @@ enum {
	MCU_S2D_H2CN
	MCU_S2D_H2CN
};
};


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_ID	GENMASK(7, 0)
#define __MCU_CMD_FIELD_EXT_ID	GENMASK(15, 8)
#define __MCU_CMD_FIELD_EXT_ID	GENMASK(15, 8)
+3 −2
Original line number Original line Diff line number Diff line
@@ -270,8 +270,9 @@ struct mt7915_dev {


	bool dbdc_support;
	bool dbdc_support;
	bool flash_mode;
	bool flash_mode;
	bool fw_debug;
	bool ibf;
	bool ibf;
	u8 fw_debug_wm;
	u8 fw_debug_wa;


	void *cal;
	void *cal;


@@ -449,7 +450,7 @@ int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
			   struct ieee80211_sta *sta, struct rate_info *rate);
			   struct ieee80211_sta *sta, struct rate_info *rate);
int mt7915_mcu_rdd_cmd(struct mt7915_dev *dev, enum mt7915_rdd_cmd cmd,
int mt7915_mcu_rdd_cmd(struct mt7915_dev *dev, enum mt7915_rdd_cmd cmd,
		       u8 index, u8 rx_sel, u8 val);
		       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);
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_rx_event(struct mt7915_dev *dev, struct sk_buff *skb);
void mt7915_mcu_exit(struct mt7915_dev *dev);
void mt7915_mcu_exit(struct mt7915_dev *dev);