Commit 516c3e38 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt7615: mcu: use standard signature for mt7615_mcu_msg_send

Use mt76 common signature for mt7615_mcu_msg_send. Move skb allocation
in mt7615_mcu_msg_send and remove duplicated code. Remove
__mt7615_mcu_set_wtbl and __mt7615_mcu_set_sta_rec since now are used
just to send mcu msgs.  This is a preliminary patch for mt7615-mt7603 mcu
code unification
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent eb2024b0
...@@ -57,9 +57,6 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb, ...@@ -57,9 +57,6 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb,
u32 val; u32 val;
__le32 *txd; __le32 *txd;
if (!skb)
return -EINVAL;
seq = ++dev->mt76.mmio.mcu.msg_seq & 0xf; seq = ++dev->mt76.mmio.mcu.msg_seq & 0xf;
if (!seq) if (!seq)
seq = ++dev->mt76.mmio.mcu.msg_seq & 0xf; seq = ++dev->mt76.mmio.mcu.msg_seq & 0xf;
...@@ -116,19 +113,25 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb, ...@@ -116,19 +113,25 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb,
} }
static int static int
mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb, int cmd) mt7615_mcu_msg_send(struct mt7615_dev *dev, int cmd, const void *data,
int len, bool wait_resp)
{ {
unsigned long expires = jiffies + 10 * HZ; unsigned long expires = jiffies + 10 * HZ;
struct mt7615_mcu_rxd *rxd; struct mt7615_mcu_rxd *rxd;
struct sk_buff *skb;
int ret, seq; int ret, seq;
skb = mt7615_mcu_msg_alloc(data, len);
if (!skb)
return -ENOMEM;
mutex_lock(&dev->mt76.mmio.mcu.mutex); mutex_lock(&dev->mt76.mmio.mcu.mutex);
ret = __mt7615_mcu_msg_send(dev, skb, cmd, &seq); ret = __mt7615_mcu_msg_send(dev, skb, cmd, &seq);
if (ret) if (ret)
goto out; goto out;
while (1) { while (wait_resp) {
skb = mt76_mcu_get_response(&dev->mt76, expires); skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) { if (!skb) {
dev_err(dev->mt76.dev, "Message %d (seq %d) timeout\n", dev_err(dev->mt76.dev, "Message %d (seq %d) timeout\n",
...@@ -167,9 +170,9 @@ static int mt7615_mcu_init_download(struct mt7615_dev *dev, u32 addr, ...@@ -167,9 +170,9 @@ static int mt7615_mcu_init_download(struct mt7615_dev *dev, u32 addr,
.len = cpu_to_le32(len), .len = cpu_to_le32(len),
.mode = cpu_to_le32(mode), .mode = cpu_to_le32(mode),
}; };
struct sk_buff *skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, -MCU_CMD_TARGET_ADDRESS_LEN_REQ); return mt7615_mcu_msg_send(dev, -MCU_CMD_TARGET_ADDRESS_LEN_REQ,
&req, sizeof(req), true);
} }
static int mt7615_mcu_send_firmware(struct mt7615_dev *dev, const void *data, static int mt7615_mcu_send_firmware(struct mt7615_dev *dev, const void *data,
...@@ -208,16 +211,15 @@ static int mt7615_mcu_start_firmware(struct mt7615_dev *dev, u32 addr, ...@@ -208,16 +211,15 @@ static int mt7615_mcu_start_firmware(struct mt7615_dev *dev, u32 addr,
.option = cpu_to_le32(option), .option = cpu_to_le32(option),
.addr = cpu_to_le32(addr), .addr = cpu_to_le32(addr),
}; };
struct sk_buff *skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, -MCU_CMD_FW_START_REQ); return mt7615_mcu_msg_send(dev, -MCU_CMD_FW_START_REQ,
&req, sizeof(req), true);
} }
static int mt7615_mcu_restart(struct mt7615_dev *dev) static int mt7615_mcu_restart(struct mt7615_dev *dev)
{ {
struct sk_buff *skb = mt7615_mcu_msg_alloc(NULL, 0); return mt7615_mcu_msg_send(dev, -MCU_CMD_RESTART_DL_REQ,
NULL, 0, true);
return mt7615_mcu_msg_send(dev, skb, -MCU_CMD_RESTART_DL_REQ);
} }
static int mt7615_mcu_patch_sem_ctrl(struct mt7615_dev *dev, bool get) static int mt7615_mcu_patch_sem_ctrl(struct mt7615_dev *dev, bool get)
...@@ -227,9 +229,9 @@ static int mt7615_mcu_patch_sem_ctrl(struct mt7615_dev *dev, bool get) ...@@ -227,9 +229,9 @@ static int mt7615_mcu_patch_sem_ctrl(struct mt7615_dev *dev, bool get)
} req = { } req = {
.op = cpu_to_le32(get ? PATCH_SEM_GET : PATCH_SEM_RELEASE), .op = cpu_to_le32(get ? PATCH_SEM_GET : PATCH_SEM_RELEASE),
}; };
struct sk_buff *skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, -MCU_CMD_PATCH_SEM_CONTROL); return mt7615_mcu_msg_send(dev, -MCU_CMD_PATCH_SEM_CONTROL,
&req, sizeof(req), true);
} }
static int mt7615_mcu_start_patch(struct mt7615_dev *dev) static int mt7615_mcu_start_patch(struct mt7615_dev *dev)
...@@ -240,9 +242,9 @@ static int mt7615_mcu_start_patch(struct mt7615_dev *dev) ...@@ -240,9 +242,9 @@ static int mt7615_mcu_start_patch(struct mt7615_dev *dev)
} req = { } req = {
.check_crc = 0, .check_crc = 0,
}; };
struct sk_buff *skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, -MCU_CMD_PATCH_FINISH_REQ); return mt7615_mcu_msg_send(dev, -MCU_CMD_PATCH_FINISH_REQ,
&req, sizeof(req), true);
} }
static int mt7615_driver_own(struct mt7615_dev *dev) static int mt7615_driver_own(struct mt7615_dev *dev)
...@@ -502,9 +504,6 @@ void mt7615_mcu_exit(struct mt7615_dev *dev) ...@@ -502,9 +504,6 @@ void mt7615_mcu_exit(struct mt7615_dev *dev)
int mt7615_mcu_set_eeprom(struct mt7615_dev *dev) int mt7615_mcu_set_eeprom(struct mt7615_dev *dev)
{ {
struct req_data {
u8 val;
} __packed;
struct { struct {
u8 buffer_mode; u8 buffer_mode;
u8 pad; u8 pad;
...@@ -513,22 +512,22 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev) ...@@ -513,22 +512,22 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev)
.buffer_mode = 1, .buffer_mode = 1,
.len = __MT_EE_MAX - MT_EE_NIC_CONF_0, .len = __MT_EE_MAX - MT_EE_NIC_CONF_0,
}; };
struct sk_buff *skb; int ret, len = sizeof(req_hdr) + __MT_EE_MAX - MT_EE_NIC_CONF_0;
struct req_data *data; u8 *req, *eep = (u8 *)dev->mt76.eeprom.data;
const int size = (__MT_EE_MAX - MT_EE_NIC_CONF_0) *
sizeof(struct req_data);
u8 *eep = (u8 *)dev->mt76.eeprom.data;
u16 off;
skb = mt7615_mcu_msg_alloc(NULL, size + sizeof(req_hdr)); req = kzalloc(len, GFP_KERNEL);
memcpy(skb_put(skb, sizeof(req_hdr)), &req_hdr, sizeof(req_hdr)); if (!req)
data = (struct req_data *)skb_put(skb, size); return -ENOMEM;
memset(data, 0, size);
memcpy(req, &req_hdr, sizeof(req_hdr));
memcpy(req + sizeof(req_hdr), eep + MT_EE_NIC_CONF_0,
__MT_EE_MAX - MT_EE_NIC_CONF_0);
for (off = MT_EE_NIC_CONF_0; off < __MT_EE_MAX; off++) ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_EFUSE_BUFFER_MODE,
data[off - MT_EE_NIC_CONF_0].val = eep[off]; req, len, true);
kfree(req);
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_EFUSE_BUFFER_MODE); return ret;
} }
int mt7615_mcu_init_mac(struct mt7615_dev *dev) int mt7615_mcu_init_mac(struct mt7615_dev *dev)
...@@ -541,9 +540,9 @@ int mt7615_mcu_init_mac(struct mt7615_dev *dev) ...@@ -541,9 +540,9 @@ int mt7615_mcu_init_mac(struct mt7615_dev *dev)
.enable = 1, .enable = 1,
.band = 0, .band = 0,
}; };
struct sk_buff *skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_MAC_INIT_CTRL); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_MAC_INIT_CTRL,
&req, sizeof(req), true);
} }
int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val) int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val)
...@@ -560,9 +559,9 @@ int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val) ...@@ -560,9 +559,9 @@ int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val)
.len_thresh = cpu_to_le32(val), .len_thresh = cpu_to_le32(val),
.pkt_thresh = cpu_to_le32(0x2), .pkt_thresh = cpu_to_le32(0x2),
}; };
struct sk_buff *skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_PROTECT_CTRL); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_PROTECT_CTRL,
&req, sizeof(req), true);
} }
int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue, int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
...@@ -588,7 +587,6 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue, ...@@ -588,7 +587,6 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
.aifs = params->aifs, .aifs = params->aifs,
.txop = cpu_to_le16(params->txop), .txop = cpu_to_le16(params->txop),
}; };
struct sk_buff *skb;
if (params->cw_min) { if (params->cw_min) {
req.valid |= WMM_CW_MIN_SET; req.valid |= WMM_CW_MIN_SET;
...@@ -599,8 +597,8 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue, ...@@ -599,8 +597,8 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
req.cw_max = cpu_to_le16(params->cw_max); req.cw_max = cpu_to_le16(params->cw_max);
} }
skb = mt7615_mcu_msg_alloc(&req, sizeof(req)); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_EDCA_UPDATE,
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_EDCA_UPDATE); &req, sizeof(req), true);
} }
int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter) int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter)
...@@ -628,9 +626,9 @@ int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter) ...@@ -628,9 +626,9 @@ int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter)
.pm_state = (enter) ? ENTER_PM_STATE : EXIT_PM_STATE, .pm_state = (enter) ? ENTER_PM_STATE : EXIT_PM_STATE,
.band_idx = 0, .band_idx = 0,
}; };
struct sk_buff *skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_PM_STATE_CTRL); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_PM_STATE_CTRL,
&req, sizeof(req), true);
} }
int mt7615_mcu_set_dev_info(struct mt7615_dev *dev, int mt7615_mcu_set_dev_info(struct mt7615_dev *dev,
...@@ -666,14 +664,10 @@ int mt7615_mcu_set_dev_info(struct mt7615_dev *dev, ...@@ -666,14 +664,10 @@ int mt7615_mcu_set_dev_info(struct mt7615_dev *dev,
.band_idx = mvif->band_idx, .band_idx = mvif->band_idx,
}, },
}; };
struct sk_buff *skb;
memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN); memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN);
skb = mt7615_mcu_msg_alloc(&data, sizeof(data)); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_DEV_INFO_UPDATE,
if (!skb) &data, sizeof(data), true);
return -ENOMEM;
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_DEV_INFO_UPDATE);
} }
static void static void
...@@ -744,7 +738,6 @@ int mt7615_mcu_set_bss_info(struct mt7615_dev *dev, ...@@ -744,7 +738,6 @@ int mt7615_mcu_set_bss_info(struct mt7615_dev *dev,
u32 conn_type = 0, net_type = NETWORK_INFRA; u32 conn_type = 0, net_type = NETWORK_INFRA;
u8 *buf, *data, tx_wlan_idx = 0; u8 *buf, *data, tx_wlan_idx = 0;
struct req_hdr *hdr; struct req_hdr *hdr;
struct sk_buff *skb;
if (en) { if (en) {
len += sizeof(struct bss_info_omac); len += sizeof(struct bss_info_omac);
...@@ -819,46 +812,13 @@ int mt7615_mcu_set_bss_info(struct mt7615_dev *dev, ...@@ -819,46 +812,13 @@ int mt7615_mcu_set_bss_info(struct mt7615_dev *dev,
} }
} }
skb = mt7615_mcu_msg_alloc(buf, len); ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_BSS_INFO_UPDATE,
if (!skb) { buf, len, true);
ret = -ENOMEM;
goto out;
}
ret = mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_BSS_INFO_UPDATE);
out:
kfree(buf); kfree(buf);
return ret; return ret;
} }
static int
__mt7615_mcu_set_wtbl(struct mt7615_dev *dev, int wlan_idx,
int operation, int ntlv, void *buf,
int buf_len)
{
struct req_hdr {
u8 wlan_idx;
u8 operation;
__le16 tlv_num;
u8 rsv[4];
} __packed req_hdr = {
.wlan_idx = wlan_idx,
.operation = operation,
.tlv_num = cpu_to_le16(ntlv),
};
struct sk_buff *skb;
skb = mt7615_mcu_msg_alloc(NULL, sizeof(req_hdr) + buf_len);
memcpy(skb_put(skb, sizeof(req_hdr)), &req_hdr, sizeof(req_hdr));
if (buf && buf_len)
memcpy(skb_put(skb, buf_len), buf, buf_len);
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_WTBL_UPDATE);
}
static enum mt7615_cipher_type static enum mt7615_cipher_type
mt7615_get_key_info(struct ieee80211_key_conf *key, u8 *key_data) mt7615_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
{ {
...@@ -896,28 +856,38 @@ int mt7615_mcu_set_wtbl_key(struct mt7615_dev *dev, int wcid, ...@@ -896,28 +856,38 @@ int mt7615_mcu_set_wtbl_key(struct mt7615_dev *dev, int wcid,
struct ieee80211_key_conf *key, struct ieee80211_key_conf *key,
enum set_key_cmd cmd) enum set_key_cmd cmd)
{ {
struct wtbl_sec_key wtbl_sec_key = {0}; struct {
int buf_len = sizeof(struct wtbl_sec_key); struct wtbl_req_hdr hdr;
u8 cipher; struct wtbl_sec_key key;
} req = {
wtbl_sec_key.tag = cpu_to_le16(WTBL_SEC_KEY); .hdr = {
wtbl_sec_key.len = cpu_to_le16(buf_len); .wlan_idx = wcid,
wtbl_sec_key.add = cmd; .operation = WTBL_SET,
.tlv_num = cpu_to_le16(1),
},
.key = {
.tag = cpu_to_le16(WTBL_SEC_KEY),
.len = cpu_to_le16(sizeof(struct wtbl_sec_key)),
.add = cmd,
},
};
if (cmd == SET_KEY) { if (cmd == SET_KEY) {
cipher = mt7615_get_key_info(key, wtbl_sec_key.key_material); u8 cipher;
cipher = mt7615_get_key_info(key, req.key.key_material);
if (cipher == MT_CIPHER_NONE && key) if (cipher == MT_CIPHER_NONE && key)
return -EOPNOTSUPP; return -EOPNOTSUPP;
wtbl_sec_key.cipher_id = cipher; req.key.cipher_id = cipher;
wtbl_sec_key.key_id = key->keyidx; req.key.key_id = key->keyidx;
wtbl_sec_key.key_len = key->keylen; req.key.key_len = key->keylen;
} else { } else {
wtbl_sec_key.key_len = sizeof(wtbl_sec_key.key_material); req.key.key_len = sizeof(req.key.key_material);
} }
return __mt7615_mcu_set_wtbl(dev, wcid, WTBL_SET, 1, return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
&wtbl_sec_key, buf_len); &req, sizeof(req), true);
} }
static int static int
...@@ -925,9 +895,15 @@ mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, ...@@ -925,9 +895,15 @@ mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev,
struct mt7615_vif *mvif) struct mt7615_vif *mvif)
{ {
struct { struct {
struct wtbl_req_hdr hdr;
struct wtbl_generic g_wtbl; struct wtbl_generic g_wtbl;
struct wtbl_rx rx_wtbl; struct wtbl_rx rx_wtbl;
} data = { } req = {
.hdr = {
.wlan_idx = mvif->sta.wcid.idx,
.operation = WTBL_RESET_AND_SET,
.tlv_num = cpu_to_le16(2),
},
.g_wtbl = { .g_wtbl = {
.tag = cpu_to_le16(WTBL_GENERIC), .tag = cpu_to_le16(WTBL_GENERIC),
.len = cpu_to_le16(sizeof(struct wtbl_generic)), .len = cpu_to_le16(sizeof(struct wtbl_generic)),
...@@ -941,12 +917,10 @@ mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, ...@@ -941,12 +917,10 @@ mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev,
.rv = 1, .rv = 1,
}, },
}; };
eth_broadcast_addr(data.g_wtbl.peer_addr); eth_broadcast_addr(req.g_wtbl.peer_addr);
return __mt7615_mcu_set_wtbl(dev, mvif->sta.wcid.idx, return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
WTBL_RESET_AND_SET, 2, &data, &req, sizeof(req), true);
sizeof(struct wtbl_generic) +
sizeof(struct wtbl_rx));
} }
int mt7615_mcu_wtbl_bmc(struct mt7615_dev *dev, int mt7615_mcu_wtbl_bmc(struct mt7615_dev *dev,
...@@ -954,11 +928,17 @@ int mt7615_mcu_wtbl_bmc(struct mt7615_dev *dev, ...@@ -954,11 +928,17 @@ int mt7615_mcu_wtbl_bmc(struct mt7615_dev *dev,
{ {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
if (enable) if (!enable) {
return mt7615_mcu_add_wtbl_bmc(dev, mvif); struct wtbl_req_hdr req = {
.wlan_idx = mvif->sta.wcid.idx,
.operation = WTBL_RESET_AND_SET,
};
return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
&req, sizeof(req), true);
}
return __mt7615_mcu_set_wtbl(dev, mvif->sta.wcid.idx, return mt7615_mcu_add_wtbl_bmc(dev, mvif);
WTBL_RESET_AND_SET, 0, NULL, 0);
} }
int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif,
...@@ -967,9 +947,15 @@ int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -967,9 +947,15 @@ int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif,
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
struct { struct {
struct wtbl_req_hdr hdr;
struct wtbl_generic g_wtbl; struct wtbl_generic g_wtbl;
struct wtbl_rx rx_wtbl; struct wtbl_rx rx_wtbl;
} data = { } req = {
.hdr = {
.wlan_idx = msta->wcid.idx,
.operation = WTBL_RESET_AND_SET,
.tlv_num = cpu_to_le16(2),
},
.g_wtbl = { .g_wtbl = {
.tag = cpu_to_le16(WTBL_GENERIC), .tag = cpu_to_le16(WTBL_GENERIC),
.len = cpu_to_le16(sizeof(struct wtbl_generic)), .len = cpu_to_le16(sizeof(struct wtbl_generic)),
...@@ -985,81 +971,69 @@ int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -985,81 +971,69 @@ int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif,
.rv = 1, .rv = 1,
}, },
}; };
memcpy(data.g_wtbl.peer_addr, sta->addr, ETH_ALEN); memcpy(req.g_wtbl.peer_addr, sta->addr, ETH_ALEN);
return __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
WTBL_RESET_AND_SET, 2, &data, &req, sizeof(req), true);
sizeof(struct wtbl_generic) +
sizeof(struct wtbl_rx));
} }
int mt7615_mcu_del_wtbl(struct mt7615_dev *dev, int mt7615_mcu_del_wtbl(struct mt7615_dev *dev,
struct ieee80211_sta *sta) struct ieee80211_sta *sta)
{ {
struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
struct wtbl_req_hdr req = {
.wlan_idx = msta->wcid.idx,
.operation = WTBL_RESET_AND_SET,
};
return __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
WTBL_RESET_AND_SET, 0, NULL, 0); &req, sizeof(req), true);
} }
int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev) int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev)
{ {
return __mt7615_mcu_set_wtbl(dev, 0, WTBL_RESET_ALL, 0, NULL, 0); struct wtbl_req_hdr req = {
} .operation = WTBL_RESET_ALL,
static int
__mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, int bss_idx,
int wlan_idx, int muar_idx, int ntlv,
void *buf, int buf_len)
{
struct req_hdr {
u8 bss_idx;
u8 wlan_idx;
__le16 tlv_num;
u8 is_tlv_append;
u8 muar_idx;
u8 rsv[2];
} __packed req_hdr = {
.bss_idx = bss_idx,
.wlan_idx = wlan_idx,
.tlv_num = cpu_to_le16(ntlv),
.is_tlv_append = !!ntlv,
.muar_idx = muar_idx,
}; };
struct sk_buff *skb;
skb = mt7615_mcu_msg_alloc(NULL, sizeof(req_hdr) + buf_len);
memcpy(skb_put(skb, sizeof(req_hdr)), &req_hdr, sizeof(req_hdr));
if (buf && buf_len) return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
memcpy(skb_put(skb, buf_len), buf, buf_len); &req, sizeof(req), true);
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_STA_REC_UPDATE);
} }
int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev, int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev,
struct ieee80211_vif *vif, bool en) struct ieee80211_vif *vif, bool en)
{ {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct sta_rec_basic sta_rec_basic = {0}; struct {
int buf_len = sizeof(struct sta_rec_basic); struct sta_req_hdr hdr;
struct sta_rec_basic basic;
} req = {
.hdr = {
.bss_idx = mvif->idx,
.wlan_idx = mvif->sta.wcid.idx,
.tlv_num = cpu_to_le16(1),
.is_tlv_append = 1,
.muar_idx = mvif->omac_idx,
},
.basic = {
.tag = cpu_to_le16(STA_REC_BASIC),
.len = cpu_to_le16(sizeof(struct sta_rec_basic)),
.conn_type = cpu_to_le32(CONNECTION_INFRA_BC),
},
};
eth_broadcast_addr(req.basic.peer_addr);
sta_rec_basic.tag = cpu_to_le16(STA_REC_BASIC);
sta_rec_basic.len = cpu_to_le16(buf_len);
sta_rec_basic.conn_type = cpu_to_le32(CONNECTION_INFRA_BC);
eth_broadcast_addr(sta_rec_basic.peer_addr);
if (en) { if (en) {
sta_rec_basic.conn_state = CONN_STATE_PORT_SECURE; req.basic.conn_state = CONN_STATE_PORT_SECURE;
sta_rec_basic.extra_info = req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER |
cpu_to_le16(EXTRA_INFO_VER | EXTRA_INFO_NEW); EXTRA_INFO_NEW);
} else { } else {
sta_rec_basic.conn_state = CONN_STATE_DISCONNECT; req.basic.conn_state = CONN_STATE_DISCONNECT;
sta_rec_basic.extra_info = cpu_to_le16(EXTRA_INFO_VER); req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER);
} }
return __mt7615_mcu_set_sta_rec(dev, mvif->idx, mvif->sta.wcid.idx, return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
mvif->omac_idx, 1, &sta_rec_basic, &req, sizeof(req), true);
buf_len);
} }
static void sta_rec_convert_vif_type(enum nl80211_iftype type, u32 *conn_type) static void sta_rec_convert_vif_type(enum nl80211_iftype type, u32 *conn_type)
...@@ -1084,36 +1058,49 @@ int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1084,36 +1058,49 @@ int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif,
{ {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
struct sta_rec_basic sta_rec_basic = {0};
int buf_len = sizeof(struct sta_rec_basic);
u32 conn_type = 0; u32 conn_type = 0;
sta_rec_convert_vif_type(vif->type, &conn_type); struct {
struct sta_req_hdr hdr;
struct sta_rec_basic basic;
} req = {
.hdr = {
.bss_idx = mvif->idx,
.wlan_idx = msta->wcid.idx,
.tlv_num = cpu_to_le16(1),
.is_tlv_append = 1,
.muar_idx = mvif->omac_idx,
},
.basic = {
.tag = cpu_to_le16(STA_REC_BASIC),
.len = cpu_to_le16(sizeof(struct sta_rec_basic)),
.qos = sta->wme,
.aid = cpu_to_le16(sta->aid),
},
};
memcpy(req.basic.peer_addr, sta->addr, ETH_ALEN);
sta_rec_basic.tag = cpu_to_le16(STA_REC_BASIC); sta_rec_convert_vif_type(vif->type, &conn_type);
sta_rec_basic.len = cpu_to_le16(buf_len); req.basic.conn_type = cpu_to_le32(conn_type);
sta_rec_basic.conn_type = cpu_to_le32(conn_type);
sta_rec_basic.qos = sta->wme;
sta_rec_basic.aid = cpu_to_le16(sta->aid);
memcpy(sta_rec_basic.peer_addr, sta->addr, ETH_ALEN);
if (en) { if (en) {
sta_rec_basic.conn_state = CONN_STATE_PORT_SECURE; req.basic.conn_state = CONN_STATE_PORT_SECURE;
sta_rec_basic.extra_info = req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER |
cpu_to_le16(EXTRA_INFO_VER | EXTRA_INFO_NEW); EXTRA_INFO_NEW);
} else { } else {
sta_rec_basic.conn_state = CONN_STATE_DISCONNECT; req.basic.conn_state = CONN_STATE_DISCONNECT;
sta_rec_basic.extra_info = cpu_to_le16(EXTRA_INFO_VER); req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER);
} }
return __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx, return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
mvif->omac_idx, 1, &sta_rec_basic, &req, sizeof(req), true);
buf_len);
} }
int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
int en) int en)
{ {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt76_wcid *wcid = &dev->mt76.global_wcid;
struct req { struct req {
u8 omac_idx; u8 omac_idx;
u8 enable; u8 enable;
...@@ -1129,14 +1116,18 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1129,14 +1116,18 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
/* bss color change */ /* bss color change */
u8 bcc_cnt; u8 bcc_cnt;
__le16 bcc_ie_pos; __le16 bcc_ie_pos;
} __packed req = {0}; } __packed req = {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; .omac_idx = mvif->omac_idx,
struct mt76_wcid *wcid = &dev->mt76.global_wcid; .enable = en,
struct sk_buff *skb; .wlan_idx = wcid->idx,
.band_idx = mvif->band_idx,
/* pky_type: 0 for bcn, 1 for tim */
.pkt_type = 0,
};
u16 tim_off, tim_len; u16 tim_off, tim_len;
struct sk_buff *skb;
skb = ieee80211_beacon_get_tim(mt76_hw(dev), vif, &tim_off, &tim_len); skb = ieee80211_beacon_get_tim(mt76_hw(dev), vif, &tim_off, &tim_len);
if (!skb) if (!skb)
return -EINVAL; return -EINVAL;
...@@ -1149,20 +1140,13 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1149,20 +1140,13 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
mt7615_mac_write_txwi(dev, (__le32 *)(req.pkt), skb, wcid, NULL, mt7615_mac_write_txwi(dev, (__le32 *)(req.pkt), skb, wcid, NULL,
0, NULL); 0, NULL);
memcpy(req.pkt + MT_TXD_SIZE, skb->data, skb->len); memcpy(req.pkt + MT_TXD_SIZE, skb->data, skb->len);
req.omac_idx = mvif->omac_idx;
req.enable = en;
req.wlan_idx = wcid->idx;
req.band_idx = mvif->band_idx;
/* pky_type: 0 for bcn, 1 for tim */
req.pkt_type = 0;
req.pkt_len = cpu_to_le16(MT_TXD_SIZE + skb->len); req.pkt_len = cpu_to_le16(MT_TXD_SIZE + skb->len);
req.tim_ie_pos = cpu_to_le16(MT_TXD_SIZE + tim_off); req.tim_ie_pos = cpu_to_le16(MT_TXD_SIZE + tim_off);
dev_kfree_skb(skb); dev_kfree_skb(skb);
skb = mt7615_mcu_msg_alloc(&req, sizeof(req));
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_BCN_OFFLOAD); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_BCN_OFFLOAD,
&req, sizeof(req), true);
} }
int mt7615_mcu_set_channel(struct mt7615_dev *dev) int mt7615_mcu_set_channel(struct mt7615_dev *dev)
...@@ -1187,7 +1171,6 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev) ...@@ -1187,7 +1171,6 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev)
u8 txpower_sku[53]; u8 txpower_sku[53];
u8 rsv2[3]; u8 rsv2[3];
} req = {0}; } req = {0};
struct sk_buff *skb;
int ret; int ret;
req.control_chan = chdef->chan->hw_value; req.control_chan = chdef->chan->hw_value;
...@@ -1223,16 +1206,15 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev) ...@@ -1223,16 +1206,15 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev)
default: default:
req.bw = CMD_CBW_20MHZ; req.bw = CMD_CBW_20MHZ;
} }
memset(req.txpower_sku, 0x3f, 49); memset(req.txpower_sku, 0x3f, 49);
skb = mt7615_mcu_msg_alloc(&req, sizeof(req)); ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_CHANNEL_SWITCH,
ret = mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_CHANNEL_SWITCH); &req, sizeof(req), true);
if (ret) if (ret)
return ret; return ret;
skb = mt7615_mcu_msg_alloc(&req, sizeof(req)); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_SET_RX_PATH,
return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_SET_RX_PATH); &req, sizeof(req), true);
} }
int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
...@@ -1240,9 +1222,11 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1240,9 +1222,11 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
{ {
struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct wtbl_ht *wtbl_ht; struct wtbl_req_hdr *wtbl_hdr;
struct sta_req_hdr *sta_hdr;
struct wtbl_raw *wtbl_raw; struct wtbl_raw *wtbl_raw;
struct sta_rec_ht *sta_rec_ht; struct sta_rec_ht *sta_ht;
struct wtbl_ht *wtbl_ht;
int buf_len, ret, ntlv = 2; int buf_len, ret, ntlv = 2;
u32 msk, val = 0; u32 msk, val = 0;
u8 *buf; u8 *buf;
...@@ -1251,15 +1235,20 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1251,15 +1235,20 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
wtbl_hdr = (struct wtbl_req_hdr *)buf;
wtbl_hdr->wlan_idx = msta->wcid.idx;
wtbl_hdr->operation = WTBL_SET;
buf_len = sizeof(*wtbl_hdr);
/* ht basic */ /* ht basic */
buf_len = sizeof(*wtbl_ht); wtbl_ht = (struct wtbl_ht *)(buf + buf_len);
wtbl_ht = (struct wtbl_ht *)buf;
wtbl_ht->tag = cpu_to_le16(WTBL_HT); wtbl_ht->tag = cpu_to_le16(WTBL_HT);
wtbl_ht->len = cpu_to_le16(sizeof(*wtbl_ht)); wtbl_ht->len = cpu_to_le16(sizeof(*wtbl_ht));
wtbl_ht->ht = 1; wtbl_ht->ht = 1;
wtbl_ht->ldpc = sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING; wtbl_ht->ldpc = sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING;
wtbl_ht->af = sta->ht_cap.ampdu_factor; wtbl_ht->af = sta->ht_cap.ampdu_factor;
wtbl_ht->mm = sta->ht_cap.ampdu_density; wtbl_ht->mm = sta->ht_cap.ampdu_density;
buf_len += sizeof(*wtbl_ht);
if (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) if (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20)
val |= MT_WTBL_W5_SHORT_GI_20; val |= MT_WTBL_W5_SHORT_GI_20;
...@@ -1309,41 +1298,48 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1309,41 +1298,48 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
wtbl_raw->msk = cpu_to_le32(~msk); wtbl_raw->msk = cpu_to_le32(~msk);
wtbl_raw->val = cpu_to_le32(val); wtbl_raw->val = cpu_to_le32(val);
ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, ntlv, wtbl_hdr->tlv_num = cpu_to_le16(ntlv);
buf, buf_len); ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
if (ret) { buf, buf_len, true);
kfree(buf); if (ret)
return ret; goto out;
}
memset(buf, 0, MT7615_WTBL_UPDATE_MAX_SIZE); memset(buf, 0, MT7615_WTBL_UPDATE_MAX_SIZE);
buf_len = sizeof(*sta_rec_ht); sta_hdr = (struct sta_req_hdr *)buf;
sta_rec_ht = (struct sta_rec_ht *)buf; sta_hdr->bss_idx = mvif->idx;
sta_rec_ht->tag = cpu_to_le16(STA_REC_HT); sta_hdr->wlan_idx = msta->wcid.idx;
sta_rec_ht->len = cpu_to_le16(sizeof(*sta_rec_ht)); sta_hdr->is_tlv_append = 1;
sta_rec_ht->ht_cap = cpu_to_le16(sta->ht_cap.cap); ntlv = sta->vht_cap.vht_supported ? 2 : 1;
ntlv = 1; sta_hdr->tlv_num = cpu_to_le16(ntlv);
sta_hdr->muar_idx = mvif->omac_idx;
buf_len = sizeof(*sta_hdr);
sta_ht = (struct sta_rec_ht *)(buf + buf_len);
sta_ht->tag = cpu_to_le16(STA_REC_HT);
sta_ht->len = cpu_to_le16(sizeof(*sta_ht));
sta_ht->ht_cap = cpu_to_le16(sta->ht_cap.cap);
buf_len += sizeof(*sta_ht);
if (sta->vht_cap.vht_supported) { if (sta->vht_cap.vht_supported) {
struct sta_rec_vht *sta_rec_vht; struct sta_rec_vht *sta_vht;
sta_rec_vht = (struct sta_rec_vht *)(buf + buf_len); sta_vht = (struct sta_rec_vht *)(buf + buf_len);
buf_len += sizeof(*sta_rec_vht); buf_len += sizeof(*sta_vht);
sta_rec_vht->tag = cpu_to_le16(STA_REC_VHT); sta_vht->tag = cpu_to_le16(STA_REC_VHT);
sta_rec_vht->len = cpu_to_le16(sizeof(*sta_rec_vht)); sta_vht->len = cpu_to_le16(sizeof(*sta_vht));
sta_rec_vht->vht_cap = cpu_to_le32(sta->vht_cap.cap); sta_vht->vht_cap = cpu_to_le32(sta->vht_cap.cap);
sta_rec_vht->vht_rx_mcs_map = sta_vht->vht_rx_mcs_map =
cpu_to_le16(sta->vht_cap.vht_mcs.rx_mcs_map); cpu_to_le16(sta->vht_cap.vht_mcs.rx_mcs_map);
sta_rec_vht->vht_tx_mcs_map = sta_vht->vht_tx_mcs_map =
cpu_to_le16(sta->vht_cap.vht_mcs.tx_mcs_map); cpu_to_le16(sta->vht_cap.vht_mcs.tx_mcs_map);
ntlv++;
} }
ret = __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx, ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
mvif->omac_idx, ntlv, buf, buf, buf_len, true);
buf_len); out:
kfree(buf); kfree(buf);
return ret; return ret;
} }
...@@ -1351,100 +1347,128 @@ int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev, ...@@ -1351,100 +1347,128 @@ int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev,
struct ieee80211_ampdu_params *params, struct ieee80211_ampdu_params *params,
bool add) bool add)
{ {
struct ieee80211_sta *sta = params->sta; struct mt7615_sta *msta = (struct mt7615_sta *)params->sta->drv_priv;
struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
struct mt7615_vif *mvif = msta->vif; struct mt7615_vif *mvif = msta->vif;
u8 ba_range[8] = {4, 8, 12, 24, 36, 48, 54, 64}; struct {
u16 tid = params->tid; struct wtbl_req_hdr hdr;
u16 ba_size = params->buf_size; struct wtbl_ba ba;
u16 ssn = params->ssn; } wtbl_req = {
struct wtbl_ba wtbl_ba = {0}; .hdr = {
struct sta_rec_ba sta_rec_ba = {0}; .wlan_idx = msta->wcid.idx,
int ret, buf_len; .operation = WTBL_SET,
.tlv_num = cpu_to_le16(1),
buf_len = sizeof(struct wtbl_ba); },
.ba = {
wtbl_ba.tag = cpu_to_le16(WTBL_BA); .tag = cpu_to_le16(WTBL_BA),
wtbl_ba.len = cpu_to_le16(buf_len); .len = cpu_to_le16(sizeof(struct wtbl_ba)),
wtbl_ba.tid = tid; .tid = params->tid,
wtbl_ba.ba_type = MT_BA_TYPE_ORIGINATOR; .ba_type = MT_BA_TYPE_ORIGINATOR,
.sn = add ? cpu_to_le16(params->ssn) : 0,
.ba_en = add,
},
};
struct {
struct sta_req_hdr hdr;
struct sta_rec_ba ba;
} sta_req = {
.hdr = {
.bss_idx = mvif->idx,
.wlan_idx = msta->wcid.idx,
.tlv_num = cpu_to_le16(1),
.is_tlv_append = 1,
.muar_idx = mvif->omac_idx,
},
.ba = {
.tag = cpu_to_le16(STA_REC_BA),
.len = cpu_to_le16(sizeof(struct sta_rec_ba)),
.tid = params->tid,
.ba_type = MT_BA_TYPE_ORIGINATOR,
.amsdu = params->amsdu,
.ba_en = add << params->tid,
.ssn = cpu_to_le16(params->ssn),
.winsize = cpu_to_le16(params->buf_size),
},
};
int ret;
if (add) { if (add) {
u8 idx; u8 idx, ba_range[] = { 4, 8, 12, 24, 36, 48, 54, 64 };
for (idx = 7; idx > 0; idx--) { for (idx = 7; idx > 0; idx--) {
if (ba_size >= ba_range[idx]) if (params->buf_size >= ba_range[idx])
break; break;
} }
wtbl_ba.sn = cpu_to_le16(ssn); wtbl_req.ba.ba_winsize_idx = idx;
wtbl_ba.ba_en = 1;
wtbl_ba.ba_winsize_idx = idx;
} }
ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, 1, ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
&wtbl_ba, buf_len); &wtbl_req, sizeof(wtbl_req), true);
if (ret) if (ret)
return ret; return ret;
buf_len = sizeof(struct sta_rec_ba); return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
&sta_req, sizeof(sta_req), true);
sta_rec_ba.tag = cpu_to_le16(STA_REC_BA);
sta_rec_ba.len = cpu_to_le16(buf_len);
sta_rec_ba.tid = tid;
sta_rec_ba.ba_type = MT_BA_TYPE_ORIGINATOR;
sta_rec_ba.amsdu = params->amsdu;
sta_rec_ba.ba_en = add << tid;
sta_rec_ba.ssn = cpu_to_le16(ssn);
sta_rec_ba.winsize = cpu_to_le16(ba_size);
return __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx,
mvif->omac_idx, 1, &sta_rec_ba,
buf_len);
} }
int mt7615_mcu_set_rx_ba(struct mt7615_dev *dev, int mt7615_mcu_set_rx_ba(struct mt7615_dev *dev,
struct ieee80211_ampdu_params *params, struct ieee80211_ampdu_params *params,
bool add) bool add)
{ {
struct ieee80211_sta *sta = params->sta; struct mt7615_sta *msta = (struct mt7615_sta *)params->sta->drv_priv;
struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
struct mt7615_vif *mvif = msta->vif; struct mt7615_vif *mvif = msta->vif;
u16 tid = params->tid; struct {
struct wtbl_ba wtbl_ba = {0}; struct wtbl_req_hdr hdr;
struct sta_rec_ba sta_rec_ba = {0}; struct wtbl_ba ba;
int ret, buf_len; } wtbl_req = {
.hdr = {
buf_len = sizeof(struct sta_rec_ba); .wlan_idx = msta->wcid.idx,
.operation = WTBL_SET,
sta_rec_ba.tag = cpu_to_le16(STA_REC_BA); .tlv_num = cpu_to_le16(1),
sta_rec_ba.len = cpu_to_le16(buf_len); },
sta_rec_ba.tid = tid; .ba = {
sta_rec_ba.ba_type = MT_BA_TYPE_RECIPIENT; .tag = cpu_to_le16(WTBL_BA),
sta_rec_ba.amsdu = params->amsdu; .len = cpu_to_le16(sizeof(struct wtbl_ba)),
sta_rec_ba.ba_en = add << tid; .tid = params->tid,
sta_rec_ba.ssn = cpu_to_le16(params->ssn); .ba_type = MT_BA_TYPE_RECIPIENT,
sta_rec_ba.winsize = cpu_to_le16(params->buf_size); .rst_ba_tid = params->tid,
.rst_ba_sel = RST_BA_MAC_TID_MATCH,
ret = __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx, .rst_ba_sb = 1,
mvif->omac_idx, 1, &sta_rec_ba, },
buf_len); };
if (ret || !add) struct {
return ret; struct sta_req_hdr hdr;
struct sta_rec_ba ba;
} sta_req = {
.hdr = {
.bss_idx = mvif->idx,
.wlan_idx = msta->wcid.idx,
.tlv_num = cpu_to_le16(1),
.is_tlv_append = 1,
.muar_idx = mvif->omac_idx,
},
.ba = {
.tag = cpu_to_le16(STA_REC_BA),
.len = cpu_to_le16(sizeof(struct sta_rec_ba)),
.tid = params->tid,
.ba_type = MT_BA_TYPE_RECIPIENT,
.amsdu = params->amsdu,
.ba_en = add << params->tid,
.ssn = cpu_to_le16(params->ssn),
.winsize = cpu_to_le16(params->buf_size),
},
};
int ret;
buf_len = sizeof(struct wtbl_ba); memcpy(wtbl_req.ba.peer_addr, params->sta->addr, ETH_ALEN);
wtbl_ba.tag = cpu_to_le16(WTBL_BA); ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
wtbl_ba.len = cpu_to_le16(buf_len); &sta_req, sizeof(sta_req), true);
wtbl_ba.tid = tid; if (ret || !add)
wtbl_ba.ba_type = MT_BA_TYPE_RECIPIENT; return ret;
memcpy(wtbl_ba.peer_addr, sta->addr, ETH_ALEN);
wtbl_ba.rst_ba_tid = tid;
wtbl_ba.rst_ba_sel = RST_BA_MAC_TID_MATCH;
wtbl_ba.rst_ba_sb = 1;
return __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
1, &wtbl_ba, buf_len); &wtbl_req, sizeof(wtbl_req), true);
} }
void mt7615_mcu_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta, void mt7615_mcu_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta,
......
...@@ -201,6 +201,13 @@ enum { ...@@ -201,6 +201,13 @@ enum {
WTBL_RESET_ALL WTBL_RESET_ALL
}; };
struct wtbl_req_hdr {
u8 wlan_idx;
u8 operation;
__le16 tlv_num;
u8 rsv[4];
} __packed;
struct wtbl_generic { struct wtbl_generic {
__le16 tag; __le16 tag;
__le16 len; __le16 len;
...@@ -366,7 +373,8 @@ struct wtbl_raw { ...@@ -366,7 +373,8 @@ struct wtbl_raw {
__le32 val; __le32 val;
} __packed; } __packed;
#define MT7615_WTBL_UPDATE_MAX_SIZE (sizeof(struct wtbl_generic) + \ #define MT7615_WTBL_UPDATE_MAX_SIZE (sizeof(struct wtbl_req_hdr) + \
sizeof(struct wtbl_generic) + \
sizeof(struct wtbl_rx) + \ sizeof(struct wtbl_rx) + \
sizeof(struct wtbl_ht) + \ sizeof(struct wtbl_ht) + \
sizeof(struct wtbl_vht) + \ sizeof(struct wtbl_vht) + \
...@@ -400,6 +408,15 @@ enum { ...@@ -400,6 +408,15 @@ enum {
WTBL_MAX_NUM WTBL_MAX_NUM
}; };
struct sta_req_hdr {
u8 bss_idx;
u8 wlan_idx;
__le16 tlv_num;
u8 is_tlv_append;
u8 muar_idx;
u8 rsv[2];
} __packed;
struct sta_rec_basic { struct sta_rec_basic {
__le16 tag; __le16 tag;
__le16 len; __le16 len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment