blob: 302d0abf5b4206a5728653b858b0587e9c543553 [file] [log] [blame]
developerb8853042023-02-17 11:50:45 +08001From 99d36c925c886a383d62fb3e9d009265161cf62a Mon Sep 17 00:00:00 2001
developer6a1998b2022-12-08 18:09:45 +08002From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
3Date: Tue, 12 Jul 2022 10:04:35 -0700
developerf3f5d9b2023-02-07 15:24:34 +08004Subject: [PATCH 1120/1133] mt76: mt7915: add phy capability vendor command
developer6a1998b2022-12-08 18:09:45 +08005
6---
7 mt7915/mt7915.h | 1 +
8 mt7915/vendor.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7915/vendor.h | 25 ++++++++++++++++++++++++
10 3 files changed, 78 insertions(+)
11
12diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developerb8853042023-02-17 11:50:45 +080013index bb9c374f..f6b7241d 100644
developer6a1998b2022-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
developerb8853042023-02-17 11:50:45 +080025index 5acbd2d7..526eb6b2 100644
developer6a1998b2022-12-08 18:09:45 +080026--- a/mt7915/vendor.c
27+++ b/mt7915/vendor.c
28@@ -50,6 +50,18 @@ rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
29 [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;
developere0a1e0e2023-02-24 11:26:12 +080047@@ -974,6 +986,35 @@ static int mt7915_vendor_mu_ctrl(struct wiphy *wiphy,
developer6a1998b2022-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 = {
83@@ -1031,6 +1072,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developere0a1e0e2023-02-24 11:26:12 +080084 .doit = mt7915_vendor_mu_ctrl,
85 .policy = mu_ctrl_policy,
86 .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX,
developer6a1998b2022-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
developerf3f5d9b2023-02-07 15:24:34 +0800102index a8e4ebf9..719b851f 100644
developer6a1998b2022-12-08 18:09:45 +0800103--- a/mt7915/vendor.h
104+++ b/mt7915/vendor.h
105@@ -9,6 +9,7 @@ enum mtk_nl80211_vendor_subcmds {
106 MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
107 MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
developere0a1e0e2023-02-24 11:26:12 +0800108 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
developer6a1998b2022-12-08 18:09:45 +0800109+ MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6,
110 };
111
112 enum mtk_capi_control_changed {
113@@ -149,4 +150,28 @@ enum mtk_vendor_attr_mnt_dump {
114 NUM_MTK_VENDOR_ATTRS_AMNT_DUMP - 1
115 };
116
117+enum mtk_vendor_attr_phy_capa_ctrl {
118+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_UNSPEC,
119+
120+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_SET,
121+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_DUMP,
122+
123+ /* keep last */
124+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL,
125+ MTK_VENDOR_ATTR_PHY_CAPA_CTRL_MAX =
126+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_CTRL - 1
127+};
128+
129+enum mtk_vendor_attr_phy_capa_dump {
130+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_UNSPEC,
131+
132+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_BSS,
133+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX_SUPPORTED_STA,
134+
135+ /* keep last */
136+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP,
137+ MTK_VENDOR_ATTR_PHY_CAPA_DUMP_MAX =
138+ NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1
139+};
140+
141 #endif
142--
developerf3f5d9b2023-02-07 15:24:34 +08001432.18.0
developer6a1998b2022-12-08 18:09:45 +0800144