developer | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 1 | From 3a2c9490ebaeaf644076eeff40299dd59b996728 Mon Sep 17 00:00:00 2001 |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [diff] [blame] | 2 | From: mtk27835 <shurong.wen@mediatek.com> |
| 3 | Date: Wed, 7 Sep 2022 14:01:29 -0700 |
developer | c923344 | 2023-04-04 06:06:17 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1024/1031] wifi: mt76: mt7915: add ibf control vendor cmd |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: mtk27835 <shurong.wen@mediatek.com> |
| 7 | --- |
developer | eb6a018 | 2022-12-12 18:53:32 +0800 | [diff] [blame] | 8 | mt7915/vendor.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ |
| 9 | mt7915/vendor.h | 25 ++++++++++++++++++- |
| 10 | 2 files changed, 89 insertions(+), 1 deletion(-) |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [diff] [blame] | 11 | |
| 12 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 13 | index b26b1cc..3e5c479 100644 |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [diff] [blame] | 14 | --- a/mt7915/vendor.c |
| 15 | +++ b/mt7915/vendor.c |
developer | eb6a018 | 2022-12-12 18:53:32 +0800 | [diff] [blame] | 16 | @@ -86,6 +86,11 @@ edcca_dump_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP] = { |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 17 | [MTK_VENDOR_ATTR_EDCCA_DUMP_SEC80_VAL] = { .type = NLA_U8 }, |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [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 | + |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [diff] [blame] | 25 | struct csi_null_tone { |
| 26 | u8 start; |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 27 | u8 end; |
developer | fd8e115 | 2023-02-14 11:29:23 +0800 | [diff] [blame] | 28 | @@ -1188,6 +1193,54 @@ static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy, |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [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 | fd8e115 | 2023-02-14 11:29:23 +0800 | [diff] [blame] | 83 | @@ -1281,6 +1334,18 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [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 | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 103 | index de3cbe2..a6309a3 100644 |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [diff] [blame] | 104 | --- a/mt7915/vendor.h |
| 105 | +++ b/mt7915/vendor.h |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 106 | @@ -12,7 +12,8 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 107 | MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [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 | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 116 | @@ -222,4 +223,26 @@ enum mtk_vendor_attr_phy_capa_dump { |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [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 | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 144 | 2.18.0 |
developer | 125799c | 2022-09-07 15:14:50 -0700 | [diff] [blame] | 145 | |