developer | 692ed9b | 2023-06-19 12:03:50 +0800 | [diff] [blame] | 1 | From a048ff567915954ca9cc68ef94c9a7786542b5d9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
| 3 | Date: Wed, 3 May 2023 05:08:07 +0800 |
| 4 | Subject: [PATCH 1012/1015] wifi: mt76: mt7996: add vendor cmd to get available |
| 5 | color bitmap |
| 6 | |
| 7 | Add a vendor cmd to notify user space available color bitmap. |
| 8 | The OBSS BSS color bitmap is maintained in mac80211, so mt76 will make use of that. |
| 9 | |
| 10 | Signed-off-by: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
| 11 | --- |
| 12 | mt7996/vendor.c | 36 ++++++++++++++++++++++++++++++++++++ |
| 13 | mt7996/vendor.h | 11 +++++++++++ |
| 14 | 2 files changed, 47 insertions(+) |
| 15 | |
| 16 | diff --git a/mt7996/vendor.c b/mt7996/vendor.c |
| 17 | index 8a021324..73f613aa 100644 |
| 18 | --- a/mt7996/vendor.c |
| 19 | +++ b/mt7996/vendor.c |
| 20 | @@ -34,6 +34,11 @@ amnt_dump_policy[NUM_MTK_VENDOR_ATTRS_AMNT_DUMP] = { |
| 21 | [MTK_VENDOR_ATTR_AMNT_DUMP_RESULT] = { .type = NLA_NESTED }, |
| 22 | }; |
| 23 | |
| 24 | +static struct nla_policy |
| 25 | +bss_color_ctrl_policy[NUM_MTK_VENDOR_ATTRS_BSS_COLOR_CTRL] = { |
| 26 | + [MTK_VENDOR_ATTR_AVAL_BSS_COLOR_BMP] = { .type = NLA_U64 }, |
| 27 | +}; |
| 28 | + |
| 29 | struct mt7996_amnt_data { |
| 30 | u8 idx; |
| 31 | u8 addr[ETH_ALEN]; |
| 32 | @@ -409,6 +414,26 @@ mt7966_vendor_amnt_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 33 | return len + 1; |
| 34 | } |
| 35 | |
| 36 | +static int |
| 37 | +mt7996_vendor_bss_color_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 38 | + struct sk_buff *skb, const void *data, int data_len, |
| 39 | + unsigned long *storage) |
| 40 | +{ |
| 41 | + struct ieee80211_vif *vif = wdev_to_ieee80211_vif(wdev); |
| 42 | + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
| 43 | + int len = 0; |
| 44 | + |
| 45 | + if (*storage == 1) |
| 46 | + return -ENOENT; |
| 47 | + *storage = 1; |
| 48 | + |
| 49 | + if (nla_put_u64_64bit(skb, MTK_VENDOR_ATTR_AVAL_BSS_COLOR_BMP, |
| 50 | + ~bss_conf->used_color_bitmap, NL80211_ATTR_PAD)) |
| 51 | + return -ENOMEM; |
| 52 | + len += 1; |
| 53 | + |
| 54 | + return len; |
| 55 | +} |
| 56 | |
| 57 | static const struct wiphy_vendor_command mt7996_vendor_commands[] = { |
| 58 | { |
| 59 | @@ -435,6 +460,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = { |
| 60 | .policy = amnt_ctrl_policy, |
| 61 | .maxattr = MTK_VENDOR_ATTR_AMNT_CTRL_MAX, |
| 62 | }, |
| 63 | + { |
| 64 | + .info = { |
| 65 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 66 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL, |
| 67 | + }, |
| 68 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 69 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 70 | + .dumpit = mt7996_vendor_bss_color_ctrl_dump, |
| 71 | + .policy = bss_color_ctrl_policy, |
| 72 | + .maxattr = MTK_VENDOR_ATTR_BSS_COLOR_CTRL_MAX, |
| 73 | + }, |
| 74 | }; |
| 75 | |
| 76 | void mt7996_vendor_register(struct mt7996_phy *phy) |
| 77 | diff --git a/mt7996/vendor.h b/mt7996/vendor.h |
| 78 | index 2078cafa..eec9e74a 100644 |
| 79 | --- a/mt7996/vendor.h |
| 80 | +++ b/mt7996/vendor.h |
| 81 | @@ -6,6 +6,7 @@ |
| 82 | enum mtk_nl80211_vendor_subcmds { |
| 83 | MTK_NL80211_VENDOR_SUBCMD_AMNT_CTRL = 0xae, |
| 84 | MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
| 85 | + MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca, |
| 86 | }; |
| 87 | |
| 88 | enum mtk_vendor_attr_mu_ctrl { |
| 89 | @@ -57,5 +58,15 @@ enum mtk_vendor_attr_mnt_dump { |
| 90 | NUM_MTK_VENDOR_ATTRS_AMNT_DUMP - 1 |
| 91 | }; |
| 92 | |
| 93 | +enum mtk_vendor_attr_bss_color_ctrl { |
| 94 | + MTK_VENDOR_ATTR_BSS_COLOR_CTRL_UNSPEC, |
| 95 | + |
| 96 | + MTK_VENDOR_ATTR_AVAL_BSS_COLOR_BMP, |
| 97 | + |
| 98 | + /* keep last */ |
| 99 | + NUM_MTK_VENDOR_ATTRS_BSS_COLOR_CTRL, |
| 100 | + MTK_VENDOR_ATTR_BSS_COLOR_CTRL_MAX = |
| 101 | + NUM_MTK_VENDOR_ATTRS_BSS_COLOR_CTRL - 1 |
| 102 | +}; |
| 103 | |
| 104 | #endif |
| 105 | -- |
| 106 | 2.39.2 |
| 107 | |