Skip to content

Commit

Permalink
wifi: mt76: mt7915: wed: enable red per-band token drop
Browse files Browse the repository at this point in the history
Enable RED to limit the number of token used by each band. If single band
uses too many tokens, it would hurt the throughput of the other bands.The
software path can solve this problem by AQL so enable RED for HW path only.

Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
  • Loading branch information
Peter Chiu authored and intel-lab-lkp committed Jan 5, 2023
1 parent 22de7b6 commit 344aa22
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@ enum {
MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
MCU_EXT_CMD_TXDPD_CAL = 0x60,
MCU_EXT_CMD_CAL_CACHE = 0x67,
MCU_EXT_CMD_RED_ENABLE = 0x68,
MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
Expand Down
54 changes: 52 additions & 2 deletions drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,57 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev)
sizeof(req), true);
}

static int mt7915_red_set_watermark(struct mt7915_dev *dev)
{
#define RED_GLOBAL_TOKEN_WATERMARK 2
u16 nbuf = dev->mt76.mmio.wed.wlan.nbuf;
struct {
__le32 args[3];

u8 cmd;
u8 version;
u8 __rsv1[4];
u16 len;

__le16 high_mark;
__le16 low_mark;
u8 __rsv2[12];
} __packed req = {
.args[0] = cpu_to_le32(MCU_WA_PARAM_RED_SETTING),
.cmd = RED_GLOBAL_TOKEN_WATERMARK,
.len = cpu_to_le16(sizeof(req) - sizeof(req.args)),

.high_mark = cpu_to_le16(nbuf - 256),
.low_mark = cpu_to_le16(nbuf - 256 - 1536),
};

return mt76_mcu_send_msg(&dev->mt76, MCU_WA_PARAM_CMD(SET), &req,
sizeof(req), false);
}

int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
{
#define RED_DISABLE 0
#define RED_BY_WA_ENABLE 2
int ret;
u32 red_type = enabled ? RED_BY_WA_ENABLE : RED_DISABLE;
__le32 req = cpu_to_le32(red_type);

if (enabled) {
ret = mt7915_red_set_watermark(dev);
if (ret < 0)
return ret;
}

ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
sizeof(req), false);
if (ret < 0)
return ret;

return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
MCU_WA_PARAM_RED, enabled, 0);
}

int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
{
int ret;
Expand Down Expand Up @@ -2339,8 +2390,7 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
if (ret)
return ret;

return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
MCU_WA_PARAM_RED, 0, 0);
return mt7915_mcu_set_red(dev, mtk_wed_device_active(&dev->mt76.mmio.wed));
}

int mt7915_mcu_init(struct mt7915_dev *dev)
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ enum {
MCU_WA_PARAM_PDMA_RX = 0x04,
MCU_WA_PARAM_CPU_UTIL = 0x0b,
MCU_WA_PARAM_RED = 0x0e,
MCU_WA_PARAM_RED_SETTING = 0x40,
};

enum mcu_mmps_mode {
Expand Down

0 comments on commit 344aa22

Please sign in to comment.