blob: 2e16650003d3dccb163a4208a49e16e5168032ca [file] [log] [blame]
developera20cdc22024-05-31 18:57:31 +08001From 3982aaa49810c8f0b2c754bd6c7a2d2b21c45407 Mon Sep 17 00:00:00 2001
developere2cfb522022-12-08 18:09:45 +08002From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
3Date: Tue, 12 Jul 2022 10:04:35 -0700
developera20cdc22024-05-31 18:57:31 +08004Subject: [PATCH] wifi: mt76: mt7915: add phy capability vendor command
developere2cfb522022-12-08 18:09:45 +08005
6---
7 mt7915/mt7915.h | 1 +
8 mt7915/vendor.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
developera20cdc22024-05-31 18:57:31 +08009 mt7915/vendor.h | 26 +++++++++++++++++++++++++
10 3 files changed, 79 insertions(+)
developere2cfb522022-12-08 18:09:45 +080011
12diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developera20cdc22024-05-31 18:57:31 +080013index 1c1b3a1..f8ae363 100644
developere2cfb522022-12-08 18:09:45 +080014--- a/mt7915/mt7915.h
15+++ b/mt7915/mt7915.h
16@@ -11,6 +11,7 @@
17
18 #define MTK_DEBUG 1
19 #define MT7915_MAX_INTERFACES 19
20+#define MT7915_MAX_BSS 16
21 #define MT7915_WTBL_SIZE 288
22 #define MT7916_WTBL_SIZE 544
23 #define MT7915_WTBL_RESERVED (mt7915_wtbl_size(dev) - 1)
24diff --git a/mt7915/vendor.c b/mt7915/vendor.c
developera20cdc22024-05-31 18:57:31 +080025index 1beb603..e6cd79f 100644
developere2cfb522022-12-08 18:09:45 +080026--- a/mt7915/vendor.c
27+++ b/mt7915/vendor.c
developera20cdc22024-05-31 18:57:31 +080028@@ -52,6 +52,18 @@ rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
developere2cfb522022-12-08 18:09:45 +080029 [MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TXBF] = { .type = NLA_U8 },
30 };
31
32+static const struct nla_policy
33+phy_capa_ctrl_policy[NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL] = {
34+ [MTK_VENDOR_ATTR_PHY_CAPA_CTRL_SET] = { .type = NLA_NESTED },
35+ [MTK_VENDOR_ATTR_PHY_CAPA_CTRL_DUMP] = { .type = NLA_NESTED },
36+};
37+
38+static const struct nla_policy
39+phy_capa_dump_policy[NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP] = {
40+ [MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_BSS] = { .type = NLA_U16 },
41+ [MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_STA] = { .type = NLA_U16 },
42+};
43+
44 struct csi_null_tone {
45 u8 start;
46 u8 end;
developera20cdc22024-05-31 18:57:31 +080047@@ -1131,6 +1143,35 @@ static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy,
developere2cfb522022-12-08 18:09:45 +080048 return 0;
49 }
50
51+static int
52+mt7915_vendor_phy_capa_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
53+ struct sk_buff *skb, const void *data, int data_len,
54+ unsigned long *storage)
55+{
56+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
57+ struct mt7915_phy *phy = mt7915_hw_phy(hw);
58+ struct mt7915_dev *dev = phy->dev;
59+ void *a;
60+ int len = 0;
61+
62+ if (*storage == 1)
63+ return -ENOENT;
64+ *storage = 1;
65+
66+ a = nla_nest_start(skb, MTK_VENDOR_ATTR_PHY_CAPA_CTRL_DUMP);
67+
68+ if (nla_put_u16(skb,
69+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_BSS, MT7915_MAX_BSS) ||
70+ nla_put_u16(skb,
71+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_STA, MT7915_WTBL_STA))
72+ return -ENOMEM;
73+ len += 2;
74+
75+ nla_nest_end(skb, a);
76+
77+ return len;
78+}
79+
80 static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
81 {
82 .info = {
developera20cdc22024-05-31 18:57:31 +080083@@ -1188,6 +1229,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer2c78ce72023-02-24 11:26:12 +080084 .doit = mt7915_vendor_mu_ctrl,
85 .policy = mu_ctrl_policy,
86 .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX,
developere2cfb522022-12-08 18:09:45 +080087+ },
88+ {
89+ .info = {
90+ .vendor_id = MTK_NL80211_VENDOR_ID,
91+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL,
92+ },
93+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
94+ WIPHY_VENDOR_CMD_NEED_RUNNING,
95+ .dumpit = mt7915_vendor_phy_capa_ctrl_dump,
96+ .policy = phy_capa_ctrl_policy,
97+ .maxattr = MTK_VENDOR_ATTR_PHY_CAPA_CTRL_MAX,
98 }
99 };
100
101diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developera20cdc22024-05-31 18:57:31 +0800102index 9cb6755..e58884c 100644
developere2cfb522022-12-08 18:09:45 +0800103--- a/mt7915/vendor.h
104+++ b/mt7915/vendor.h
developer753619c2024-02-22 13:42:45 +0800105@@ -10,6 +10,7 @@ enum mtk_nl80211_vendor_subcmds {
developere2cfb522022-12-08 18:09:45 +0800106 MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
107 MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
developer2c78ce72023-02-24 11:26:12 +0800108 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developere2cfb522022-12-08 18:09:45 +0800109+ MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6,
110 };
111
112 enum mtk_capi_control_changed {
developera20cdc22024-05-31 18:57:31 +0800113@@ -164,4 +165,29 @@ enum mtk_vendor_attr_mnt_dump {
114 MTK_VENDOR_ATTR_AMNT_DUMP_MAX =
developere2cfb522022-12-08 18:09:45 +0800115 NUM_MTK_VENDOR_ATTRS_AMNT_DUMP - 1
116 };
developera20cdc22024-05-31 18:57:31 +0800117+
developere2cfb522022-12-08 18:09:45 +0800118+enum mtk_vendor_attr_phy_capa_ctrl {
119+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_UNSPEC,
120+
121+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_SET,
122+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_DUMP,
123+
124+ /* keep last */
125+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL,
126+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_MAX =
127+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL - 1
128+};
129+
130+enum mtk_vendor_attr_phy_capa_dump {
131+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_UNSPEC,
132+
133+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_BSS,
134+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_STA,
135+
136+ /* keep last */
137+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP,
138+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX =
139+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1
140+};
141+
142 #endif
143--
developerbd9fa1e2023-10-16 11:04:00 +08001442.18.0
developere2cfb522022-12-08 18:09:45 +0800145