developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 1 | From 6de06b0f652673f2db19060161dcc94d47ff4ce3 Mon Sep 17 00:00:00 2001 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 2 | From: mtk27835 <shurong.wen@mediatek.com> |
| 3 | Date: Wed, 7 Sep 2022 14:01:29 -0700 |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 4 | Subject: [PATCH] mt76: add ibf control vendor cmd |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: mtk27835 <shurong.wen@mediatek.com> |
| 7 | --- |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 8 | mt7915/vendor.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ |
| 9 | mt7915/vendor.h | 25 ++++++++++++++++- |
| 10 | 2 files changed, 95 insertions(+), 1 deletion(-) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 11 | |
| 12 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 13 | index 84e088c9..648d2dfb 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 14 | --- a/mt7915/vendor.c |
| 15 | +++ b/mt7915/vendor.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 16 | @@ -86,6 +86,17 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = { |
| 17 | [MTK_VENDOR_ATTR_EDCCA_DUMP_SEC80_VAL] = { .type = NLA_U8 }, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 18 | }; |
| 19 | |
| 20 | +static const struct nla_policy |
| 21 | +ibf_ctrl_policy[NUM_MTK_VENDOR_ATTRS_IBF_CTRL] = { |
| 22 | + [MTK_VENDOR_ATTR_IBF_CTRL_ENABLE] = { .type = NLA_U8 }, |
| 23 | +}; |
| 24 | + |
| 25 | +static struct nla_policy |
| 26 | +ibf_dump_policy[NUM_MTK_VENDOR_ATTRS_IBF_DUMP] = { |
| 27 | + [MTK_VENDOR_ATTR_IBF_DUMP_ENABLE] = { .type = NLA_U8 }, |
| 28 | +}; |
| 29 | + |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 30 | + |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 31 | struct csi_null_tone { |
| 32 | u8 start; |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 33 | u8 end; |
| 34 | @@ -1194,6 +1205,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 35 | return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode); |
| 36 | } |
| 37 | |
| 38 | +static int mt7915_vendor_ibf_ctrl(struct wiphy *wiphy, |
| 39 | + struct wireless_dev *wdev, |
| 40 | + const void *data, |
| 41 | + int data_len) |
| 42 | +{ |
| 43 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 44 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 45 | + struct mt7915_dev *dev = phy->dev; |
| 46 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_IBF_CTRL]; |
| 47 | + int err; |
| 48 | + u8 val; |
| 49 | + |
| 50 | + err = nla_parse(tb, MTK_VENDOR_ATTR_IBF_CTRL_MAX, data, data_len, |
| 51 | + ibf_ctrl_policy, NULL); |
| 52 | + if (err) |
| 53 | + return err; |
| 54 | + |
| 55 | + if (tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]) { |
| 56 | + val = nla_get_u8(tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]); |
| 57 | + |
| 58 | + dev->ibf = !!val; |
| 59 | + |
| 60 | + err = mt7915_mcu_set_txbf(dev, MT_BF_TYPE_UPDATE); |
| 61 | + if (err) |
| 62 | + return err; |
| 63 | + } |
| 64 | + return 0; |
| 65 | +} |
| 66 | + |
| 67 | +static int |
| 68 | +mt7915_vendor_ibf_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 69 | + struct sk_buff *skb, const void *data, int data_len, |
| 70 | + unsigned long *storage) |
| 71 | +{ |
| 72 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 73 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 74 | + struct mt7915_dev *dev = phy->dev; |
| 75 | + |
| 76 | + if (*storage == 1) |
| 77 | + return -ENOENT; |
| 78 | + *storage = 1; |
| 79 | + |
| 80 | + if (nla_put_u8(skb, MTK_VENDOR_ATTR_IBF_DUMP_ENABLE, dev->ibf)) |
| 81 | + return -ENOMEM; |
| 82 | + |
| 83 | + return 1; |
| 84 | +} |
| 85 | + |
| 86 | |
| 87 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 88 | { |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 89 | @@ -1287,6 +1346,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 90 | .doit = mt7915_vendor_3wire_ctrl, |
| 91 | .policy = three_wire_ctrl_policy, |
| 92 | .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, |
| 93 | + }, |
| 94 | + { |
| 95 | + .info = { |
| 96 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 97 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL, |
| 98 | + }, |
| 99 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 100 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 101 | + .doit = mt7915_vendor_ibf_ctrl, |
| 102 | + .dumpit = mt7915_vendor_ibf_ctrl_dump, |
| 103 | + .policy = ibf_ctrl_policy, |
| 104 | + .maxattr = MTK_VENDOR_ATTR_IBF_CTRL_MAX, |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 109 | index d96e5c23..949c8853 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 110 | --- a/mt7915/vendor.h |
| 111 | +++ b/mt7915/vendor.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 112 | @@ -12,7 +12,8 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 113 | MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5, |
| 114 | MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6, |
| 115 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 116 | - MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8 |
| 117 | + MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8, |
| 118 | + MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9, |
| 119 | }; |
| 120 | |
| 121 | |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 122 | @@ -222,4 +223,26 @@ enum mtk_vendor_attr_phy_capa_dump { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 123 | NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1 |
| 124 | }; |
| 125 | |
| 126 | +enum mtk_vendor_attr_ibf_ctrl { |
| 127 | + MTK_VENDOR_ATTR_IBF_CTRL_UNSPEC, |
| 128 | + |
| 129 | + MTK_VENDOR_ATTR_IBF_CTRL_ENABLE, |
| 130 | + |
| 131 | + /* keep last */ |
| 132 | + NUM_MTK_VENDOR_ATTRS_IBF_CTRL, |
| 133 | + MTK_VENDOR_ATTR_IBF_CTRL_MAX = |
| 134 | + NUM_MTK_VENDOR_ATTRS_IBF_CTRL - 1 |
| 135 | +}; |
| 136 | + |
| 137 | +enum mtk_vendor_attr_ibf_dump { |
| 138 | + MTK_VENDOR_ATTR_IBF_DUMP_UNSPEC, |
| 139 | + |
| 140 | + MTK_VENDOR_ATTR_IBF_DUMP_ENABLE, |
| 141 | + |
| 142 | + /* keep last */ |
| 143 | + NUM_MTK_VENDOR_ATTRS_IBF_DUMP, |
| 144 | + MTK_VENDOR_ATTR_IBF_DUMP_MAX = |
| 145 | + NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1 |
| 146 | +}; |
| 147 | + |
| 148 | #endif |
| 149 | -- |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 150 | 2.18.0 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 151 | |