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