Commit 0467448d authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt7615: mcu: simplify __mt7615_mcu_set_sta_rec

Do not loop over cmd payload in __mt7615_mcu_set_sta_rec since it is
already done in before running __mt7615_mcu_set_sta_rec (e.g.
mt7615_mcu_set_sta_rec)
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 8e309f7d
...@@ -1101,9 +1101,10 @@ int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev) ...@@ -1101,9 +1101,10 @@ int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev)
return __mt7615_mcu_set_wtbl(dev, 0, WTBL_RESET_ALL, 0, NULL, 0); return __mt7615_mcu_set_wtbl(dev, 0, WTBL_RESET_ALL, 0, NULL, 0);
} }
static int __mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, int bss_idx, static int
int wlan_idx, int muar_idx, void *buf, __mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, int bss_idx,
int buf_len) int wlan_idx, int muar_idx, int ntlv,
void *buf, int buf_len)
{ {
struct req_hdr { struct req_hdr {
u8 bss_idx; u8 bss_idx;
...@@ -1112,31 +1113,16 @@ static int __mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, int bss_idx, ...@@ -1112,31 +1113,16 @@ static int __mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, int bss_idx,
u8 is_tlv_append; u8 is_tlv_append;
u8 muar_idx; u8 muar_idx;
u8 rsv[2]; u8 rsv[2];
} __packed req_hdr = {0}; } __packed req_hdr = {
struct tlv { .bss_idx = bss_idx,
__le16 tag; .wlan_idx = wlan_idx,
__le16 len; .tlv_num = cpu_to_le16(ntlv),
u8 buf[0]; .is_tlv_append = !!ntlv,
} __packed; .muar_idx = muar_idx,
};
struct sk_buff *skb; struct sk_buff *skb;
u16 tlv_num = 0;
int offset = 0;
while (offset < buf_len) {
struct tlv *tlv = (struct tlv *)((u8 *)buf + offset);
tlv_num++;
offset += tlv->len;
}
skb = mt7615_mcu_msg_alloc(NULL, sizeof(req_hdr) + buf_len); skb = mt7615_mcu_msg_alloc(NULL, sizeof(req_hdr) + buf_len);
req_hdr.bss_idx = bss_idx;
req_hdr.wlan_idx = wlan_idx;
req_hdr.tlv_num = cpu_to_le16(tlv_num);
req_hdr.is_tlv_append = tlv_num ? 1 : 0;
req_hdr.muar_idx = muar_idx;
memcpy(skb_put(skb, sizeof(req_hdr)), &req_hdr, sizeof(req_hdr)); memcpy(skb_put(skb, sizeof(req_hdr)), &req_hdr, sizeof(req_hdr));
if (buf && buf_len) if (buf && buf_len)
...@@ -1167,7 +1153,7 @@ int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev, ...@@ -1167,7 +1153,7 @@ int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev,
} }
return __mt7615_mcu_set_sta_rec(dev, mvif->idx, mvif->sta.wcid.idx, return __mt7615_mcu_set_sta_rec(dev, mvif->idx, mvif->sta.wcid.idx,
mvif->omac_idx, &sta_rec_basic, mvif->omac_idx, 1, &sta_rec_basic,
buf_len); buf_len);
} }
...@@ -1216,7 +1202,7 @@ int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1216,7 +1202,7 @@ int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif,
} }
return __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx, return __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx,
mvif->omac_idx, &sta_rec_basic, mvif->omac_idx, 1, &sta_rec_basic,
buf_len); buf_len);
} }
...@@ -1435,6 +1421,7 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1435,6 +1421,7 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
sta_rec_ht->tag = cpu_to_le16(STA_REC_HT); sta_rec_ht->tag = cpu_to_le16(STA_REC_HT);
sta_rec_ht->len = cpu_to_le16(sizeof(*sta_rec_ht)); sta_rec_ht->len = cpu_to_le16(sizeof(*sta_rec_ht));
sta_rec_ht->ht_cap = cpu_to_le16(sta->ht_cap.cap); sta_rec_ht->ht_cap = cpu_to_le16(sta->ht_cap.cap);
ntlv = 1;
if (sta->vht_cap.vht_supported) { if (sta->vht_cap.vht_supported) {
struct sta_rec_vht *sta_rec_vht; struct sta_rec_vht *sta_rec_vht;
...@@ -1448,10 +1435,12 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -1448,10 +1435,12 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
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_rec_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_set_sta_rec(dev, mvif->idx, msta->wcid.idx,
mvif->omac_idx, buf, buf_len); mvif->omac_idx, ntlv, buf,
buf_len);
kfree(buf); kfree(buf);
return ret; return ret;
} }
...@@ -1508,7 +1497,8 @@ int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev, ...@@ -1508,7 +1497,8 @@ int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev,
sta_rec_ba.winsize = cpu_to_le16(ba_size); sta_rec_ba.winsize = cpu_to_le16(ba_size);
return __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx, return __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx,
mvif->omac_idx, &sta_rec_ba, buf_len); 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,
...@@ -1535,7 +1525,8 @@ int mt7615_mcu_set_rx_ba(struct mt7615_dev *dev, ...@@ -1535,7 +1525,8 @@ int mt7615_mcu_set_rx_ba(struct mt7615_dev *dev,
sta_rec_ba.winsize = cpu_to_le16(params->buf_size); sta_rec_ba.winsize = cpu_to_le16(params->buf_size);
ret = __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx, ret = __mt7615_mcu_set_sta_rec(dev, mvif->idx, msta->wcid.idx,
mvif->omac_idx, &sta_rec_ba, buf_len); mvif->omac_idx, 1, &sta_rec_ba,
buf_len);
if (ret || !add) if (ret || !add)
return ret; return ret;
......
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