developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 1 | From d8381a4d6847fcfeb96bbfd0fbb6bcbfd9a4bd61 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 | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1125/1128] 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 | --- |
| 8 | mt7915/vendor.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ |
| 9 | mt7915/vendor.h | 25 +++++++++++++++++- |
| 10 | 2 files changed, 94 insertions(+), 1 deletion(-) |
| 11 | |
| 12 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 13 | index 7f67c0d3..cbbb0843 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 14 | --- a/mt7915/vendor.c |
| 15 | +++ b/mt7915/vendor.c |
| 16 | @@ -78,6 +78,16 @@ edcca_ctrl_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL] = { |
| 17 | [MTK_VENDOR_ATTR_EDCCA_CTRL_COMPENSATE] = { .type = NLA_S8 }, |
| 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 | + |
| 30 | |
| 31 | struct csi_null_tone { |
| 32 | u8 start; |
| 33 | @@ -1120,6 +1130,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy, |
| 34 | return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode); |
| 35 | } |
| 36 | |
| 37 | +static int mt7915_vendor_ibf_ctrl(struct wiphy *wiphy, |
| 38 | + struct wireless_dev *wdev, |
| 39 | + const void *data, |
| 40 | + int data_len) |
| 41 | +{ |
| 42 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 43 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 44 | + struct mt7915_dev *dev = phy->dev; |
| 45 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_IBF_CTRL]; |
| 46 | + int err; |
| 47 | + u8 val; |
| 48 | + |
| 49 | + err = nla_parse(tb, MTK_VENDOR_ATTR_IBF_CTRL_MAX, data, data_len, |
| 50 | + ibf_ctrl_policy, NULL); |
| 51 | + if (err) |
| 52 | + return err; |
| 53 | + |
| 54 | + if (tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]) { |
| 55 | + val = nla_get_u8(tb[MTK_VENDOR_ATTR_IBF_CTRL_ENABLE]); |
| 56 | + |
| 57 | + dev->ibf = !!val; |
| 58 | + |
| 59 | + err = mt7915_mcu_set_txbf(dev, MT_BF_TYPE_UPDATE); |
| 60 | + if (err) |
| 61 | + return err; |
| 62 | + } |
| 63 | + return 0; |
| 64 | +} |
| 65 | + |
| 66 | +static int |
| 67 | +mt7915_vendor_ibf_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 68 | + struct sk_buff *skb, const void *data, int data_len, |
| 69 | + unsigned long *storage) |
| 70 | +{ |
| 71 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 72 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 73 | + struct mt7915_dev *dev = phy->dev; |
| 74 | + |
| 75 | + if (*storage == 1) |
| 76 | + return -ENOENT; |
| 77 | + *storage = 1; |
| 78 | + |
| 79 | + if (nla_put_u8(skb, MTK_VENDOR_ATTR_IBF_DUMP_ENABLE, dev->ibf)) |
| 80 | + return -ENOMEM; |
| 81 | + |
| 82 | + return 1; |
| 83 | +} |
| 84 | + |
| 85 | |
| 86 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 87 | { |
| 88 | @@ -1212,6 +1270,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 89 | .doit = mt7915_vendor_3wire_ctrl, |
| 90 | .policy = three_wire_ctrl_policy, |
| 91 | .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, |
| 92 | + }, |
| 93 | + { |
| 94 | + .info = { |
| 95 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 96 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL, |
| 97 | + }, |
| 98 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 99 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 100 | + .doit = mt7915_vendor_ibf_ctrl, |
| 101 | + .dumpit = mt7915_vendor_ibf_ctrl_dump, |
| 102 | + .policy = ibf_ctrl_policy, |
| 103 | + .maxattr = MTK_VENDOR_ATTR_IBF_CTRL_MAX, |
| 104 | } |
| 105 | }; |
| 106 | |
| 107 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 108 | index e0c5fd94..5aac5595 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 109 | --- a/mt7915/vendor.h |
| 110 | +++ b/mt7915/vendor.h |
| 111 | @@ -11,7 +11,8 @@ enum mtk_nl80211_vendor_subcmds { |
| 112 | MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5, |
| 113 | MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6, |
| 114 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 115 | - MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8 |
| 116 | + MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8, |
| 117 | + MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9, |
| 118 | }; |
| 119 | |
| 120 | |
| 121 | @@ -206,4 +207,26 @@ enum mtk_vendor_attr_phy_capa_dump { |
| 122 | NUM_MTK_VENDOR_ATTRS_PHY_CAPA_DUMP - 1 |
| 123 | }; |
| 124 | |
| 125 | +enum mtk_vendor_attr_ibf_ctrl { |
| 126 | + MTK_VENDOR_ATTR_IBF_CTRL_UNSPEC, |
| 127 | + |
| 128 | + MTK_VENDOR_ATTR_IBF_CTRL_ENABLE, |
| 129 | + |
| 130 | + /* keep last */ |
| 131 | + NUM_MTK_VENDOR_ATTRS_IBF_CTRL, |
| 132 | + MTK_VENDOR_ATTR_IBF_CTRL_MAX = |
| 133 | + NUM_MTK_VENDOR_ATTRS_IBF_CTRL - 1 |
| 134 | +}; |
| 135 | + |
| 136 | +enum mtk_vendor_attr_ibf_dump { |
| 137 | + MTK_VENDOR_ATTR_IBF_DUMP_UNSPEC, |
| 138 | + |
| 139 | + MTK_VENDOR_ATTR_IBF_DUMP_ENABLE, |
| 140 | + |
| 141 | + /* keep last */ |
| 142 | + NUM_MTK_VENDOR_ATTRS_IBF_DUMP, |
| 143 | + MTK_VENDOR_ATTR_IBF_DUMP_MAX = |
| 144 | + NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1 |
| 145 | +}; |
| 146 | + |
| 147 | #endif |
| 148 | -- |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 149 | 2.18.0 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 150 | |