developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame] | 1 | From b523d127286292b2915eda127d35001ee67ab461 Mon Sep 17 00:00:00 2001 |
developer | e2cfb52 | 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 | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1019/1051] wifi: mt76: mt7915: add ibf control vendor cmd |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: mtk27835 <shurong.wen@mediatek.com> |
| 7 | --- |
developer | aa5b1b2 | 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 | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 11 | |
| 12 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 13 | index eeac18d..a21cbce 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 14 | --- a/mt7915/vendor.c |
| 15 | +++ b/mt7915/vendor.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 16 | @@ -87,6 +87,11 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = { |
developer | e2cfb52 | 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 | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 25 | struct csi_null_tone { |
| 26 | u8 start; |
| 27 | u8 end; |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 28 | @@ -1209,6 +1214,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy, |
developer | e2cfb52 | 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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 83 | @@ -1302,6 +1355,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | e2cfb52 | 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 | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 103 | index e61a6aa..876edf3 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 104 | --- a/mt7915/vendor.h |
| 105 | +++ b/mt7915/vendor.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 106 | @@ -13,7 +13,8 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 107 | MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | e2cfb52 | 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 | |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 116 | @@ -225,4 +226,26 @@ enum mtk_vendor_attr_phy_capa_dump { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 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 | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 144 | 2.18.0 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 145 | |