blob: 750042c69163b02f98cf410ff99586d20ed1003c [file] [log] [blame]
developer78848c62023-04-06 13:44:00 +08001From e46917c20feeb88fe69f51198cd6810a06e9b1b9 Mon Sep 17 00:00:00 2001
developerf8871e82023-03-08 17:22:32 +08002From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
3Date: Thu, 26 Jan 2023 08:50:47 +0800
developer78848c62023-04-06 13:44:00 +08004Subject: [PATCH 1031/1031] wifi: mt76: mt7915: add vendor cmd to get available
5 color bitmap
developerf8871e82023-03-08 17:22:32 +08006
7Add a vendor cmd to notify user space available color bitmap.
8The OBSS BSS color bitmap is maintained in mac80211, so mt76 will make use of that.
9
10Signed-off-by: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
11---
12 mt7915/vendor.c | 37 +++++++++++++++++++++++++++++++++++++
13 mt7915/vendor.h | 11 +++++++++++
14 2 files changed, 48 insertions(+)
15
16diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developer78848c62023-04-06 13:44:00 +080017index 3b7ac098..b021bd5d 100644
developerf8871e82023-03-08 17:22:32 +080018--- a/mt7915/vendor.c
19+++ b/mt7915/vendor.c
developer78848c62023-04-06 13:44:00 +080020@@ -98,6 +98,11 @@ ibf_ctrl_policy[NUM_MTK_VENDOR_ATTRS_IBF_CTRL] = {
developerf8871e82023-03-08 17:22:32 +080021 [MTK_VENDOR_ATTR_IBF_CTRL_ENABLE] = { .type = NLA_U8 },
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 csi_null_tone {
30 u8 start;
31 u8 end;
developer78848c62023-04-06 13:44:00 +080032@@ -1275,6 +1280,27 @@ mt7915_vendor_ibf_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
developerf8871e82023-03-08 17:22:32 +080033 return 1;
34 }
35
36+static int
37+mt7915_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,
50+ MTK_VENDOR_ATTR_AVAL_BSS_COLOR_BMP,
developer81e9eb72023-03-14 14:09:34 +080051+ ~bss_conf->used_color_bitmap, NL80211_ATTR_PAD))
developerf8871e82023-03-08 17:22:32 +080052+ return -ENOMEM;
53+ len += 1;
54+
55+ return len;
56+}
57
58 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
59 {
developer78848c62023-04-06 13:44:00 +080060@@ -1381,6 +1407,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developerf8871e82023-03-08 17:22:32 +080061 .dumpit = mt7915_vendor_ibf_ctrl_dump,
62 .policy = ibf_ctrl_policy,
63 .maxattr = MTK_VENDOR_ATTR_IBF_CTRL_MAX,
64+ },
65+ {
66+ .info = {
67+ .vendor_id = MTK_NL80211_VENDOR_ID,
68+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL,
69+ },
70+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
71+ WIPHY_VENDOR_CMD_NEED_RUNNING,
72+ .dumpit = mt7915_vendor_bss_color_ctrl_dump,
73+ .policy = bss_color_ctrl_policy,
74+ .maxattr = MTK_VENDOR_ATTR_BSS_COLOR_CTRL_MAX,
75 }
76 };
77
78diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer78848c62023-04-06 13:44:00 +080079index 6001ce4a..358a16f2 100644
developerf8871e82023-03-08 17:22:32 +080080--- a/mt7915/vendor.h
81+++ b/mt7915/vendor.h
82@@ -14,6 +14,7 @@ enum mtk_nl80211_vendor_subcmds {
83 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
84 MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
85 MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
86+ MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca,
87 };
88
89
developer78848c62023-04-06 13:44:00 +080090@@ -258,4 +259,14 @@ enum mtk_vendor_attr_ibf_dump {
developerf8871e82023-03-08 17:22:32 +080091 NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1
92 };
93
94+enum mtk_vendor_attr_bss_color_ctrl {
95+ MTK_VENDOR_ATTR_BSS_COLOR_CTRL_UNSPEC,
96+
97+ MTK_VENDOR_ATTR_AVAL_BSS_COLOR_BMP,
98+
99+ /* keep last */
100+ NUM_MTK_VENDOR_ATTRS_BSS_COLOR_CTRL,
101+ MTK_VENDOR_ATTR_BSS_COLOR_CTRL_MAX =
102+ NUM_MTK_VENDOR_ATTRS_BSS_COLOR_CTRL - 1
103+};
104 #endif
105--
1062.39.0
107