diff options
author | Lorenzo Bianconi <lorenzo@kernel.org> | 2019-05-04 17:28:56 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2019-06-25 12:55:26 +0200 |
commit | 77eaa281c20e6227f4fdd73006e4ced113bd30b2 (patch) | |
tree | 104b439f10504517b481c5de00251c9153833744 /drivers | |
parent | b876457c6a40c109b5ad127805a4441f11e6e537 (diff) |
mt7615: mcu: use proper msg size in mt7615_mcu_add_wtbl_bmc
Use proper mcu message size in mt7615_mcu_add_wtbl_bmc and do not
allocate a huge buffer. Moreover use stack memory instead of heap one
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 2a73ac8b0d90..ab72e34f5d0c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -987,39 +987,33 @@ int mt7615_mcu_set_wtbl_key(struct mt7615_dev *dev, int wcid, &wtbl_sec_key, buf_len); } -int mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif) +int mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, + struct ieee80211_vif *vif) { struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; - struct wtbl_generic *wtbl_generic; - struct wtbl_rx *wtbl_rx; - int buf_len, ret; - u8 *buf; - - buf = kzalloc(MT7615_WTBL_UPDATE_MAX_SIZE, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - wtbl_generic = (struct wtbl_generic *)buf; - buf_len = sizeof(*wtbl_generic); - wtbl_generic->tag = cpu_to_le16(WTBL_GENERIC); - wtbl_generic->len = cpu_to_le16(buf_len); - eth_broadcast_addr(wtbl_generic->peer_addr); - wtbl_generic->muar_idx = 0xe; - - wtbl_rx = (struct wtbl_rx *)(buf + buf_len); - buf_len += sizeof(*wtbl_rx); - wtbl_rx->tag = cpu_to_le16(WTBL_RX); - wtbl_rx->len = cpu_to_le16(sizeof(*wtbl_rx)); - wtbl_rx->rca1 = 1; - wtbl_rx->rca2 = 1; - wtbl_rx->rv = 1; - - ret = __mt7615_mcu_set_wtbl(dev, mvif->sta.wcid.idx, - WTBL_RESET_AND_SET, 2, buf, - buf_len); + struct { + struct wtbl_generic g_wtbl; + struct wtbl_rx rx_wtbl; + } data = { + .g_wtbl = { + .tag = cpu_to_le16(WTBL_GENERIC), + .len = cpu_to_le16(sizeof(struct wtbl_generic)), + .muar_idx = 0xe, + }, + .rx_wtbl = { + .tag = cpu_to_le16(WTBL_RX), + .len = cpu_to_le16(sizeof(struct wtbl_rx)), + .rca1 = 1, + .rca2 = 1, + .rv = 1, + }, + }; + eth_broadcast_addr(data.g_wtbl.peer_addr); - kfree(buf); - return ret; + return __mt7615_mcu_set_wtbl(dev, mvif->sta.wcid.idx, + WTBL_RESET_AND_SET, 2, &data, + sizeof(struct wtbl_generic) + + sizeof(struct wtbl_rx)); } int mt7615_mcu_del_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif) |