blob: 2012df4abe08f3a2cd8b34805b799d9cf35cd48d [file] [log] [blame]
developerbcc85ca2022-12-05 11:29:56 +08001From b7a732694ec0bffaa3ff2805cdd6600ba3b598a9 Mon Sep 17 00:00:00 2001
developerd4975692022-07-15 18:30:03 +08002From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
3Date: Tue, 12 Jul 2022 10:04:35 -0700
developerbcc85ca2022-12-05 11:29:56 +08004Subject: [PATCH 1120/1128] mt76: mt7915: add phy capability vendor command
developerd4975692022-07-15 18:30:03 +08005
6---
developer27b55252022-09-05 19:09:45 +08007 mt7915/mt7915.h | 1 +
8 mt7915/vendor.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
9 mt7915/vendor.h | 25 ++++++++++++++++++++++++
developerd4975692022-07-15 18:30:03 +080010 3 files changed, 78 insertions(+)
11
12diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer3d5faf22022-11-29 18:07:22 +080013index 0cbd02e2..69f1b6b4 100644
developerd4975692022-07-15 18:30:03 +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
developer2cbf2fb2022-11-16 12:20:48 +080025index c7551848..77d71e48 100644
developerd4975692022-07-15 18:30:03 +080026--- a/mt7915/vendor.c
27+++ b/mt7915/vendor.c
28@@ -50,6 +50,18 @@ rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
developer3262bf82022-07-12 11:37:54 +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;
developerd4975692022-07-15 18:30:03 +080047@@ -974,6 +986,35 @@ static int mt7915_vendor_hemu_ctrl(struct wiphy *wiphy,
developer3262bf82022-07-12 11:37:54 +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 = {
developerd4975692022-07-15 18:30:03 +080083@@ -1031,6 +1072,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = {
developer3262bf82022-07-12 11:37:54 +080084 .doit = mt7915_vendor_hemu_ctrl,
85 .policy = hemu_ctrl_policy,
86 .maxattr = MTK_VENDOR_ATTR_HEMU_CTRL_MAX,
87+ },
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
developerd4975692022-07-15 18:30:03 +0800101diff --git a/mt7915/vendor.h b/mt7915/vendor.h
developer2cbf2fb2022-11-16 12:20:48 +0800102index a8e4ebf9..719b851f 100644
developerd4975692022-07-15 18:30:03 +0800103--- a/mt7915/vendor.h
104+++ b/mt7915/vendor.h
developer3262bf82022-07-12 11:37:54 +0800105@@ -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,
108 MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5,
109+ 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
developerd4975692022-07-15 18:30:03 +0800142--
developerbcc85ca2022-12-05 11:29:56 +08001432.36.1
developerd4975692022-07-15 18:30:03 +0800144