developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1 | From fe038594fb92fae539bf05f86022953810e4e1e6 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 22 Sep 2023 12:33:06 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 4 | Subject: [PATCH 039/223] mtk: mt76: mt7996: add zwdfs cert mode |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 7 | --- |
| 8 | mt7996/mcu.c | 44 ++++++++++++++++++++++++++++++++------------ |
| 9 | mt7996/mcu.h | 14 ++++++++++++++ |
| 10 | mt7996/mt7996.h | 5 +++++ |
| 11 | mt7996/vendor.c | 37 +++++++++++++++++++++++++++++++++++++ |
| 12 | mt7996/vendor.h | 12 ++++++++++++ |
| 13 | 5 files changed, 100 insertions(+), 12 deletions(-) |
| 14 | |
| 15 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 16 | index c0bd2d13..9e548100 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 17 | --- a/mt7996/mcu.c |
| 18 | +++ b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 19 | @@ -4532,18 +4532,7 @@ int mt7996_mcu_set_radio_en(struct mt7996_phy *phy, bool enable) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 20 | int mt7996_mcu_rdd_cmd(struct mt7996_dev *dev, int cmd, u8 index, |
| 21 | u8 rx_sel, u8 val) |
| 22 | { |
| 23 | - struct { |
| 24 | - u8 _rsv[4]; |
| 25 | - |
| 26 | - __le16 tag; |
| 27 | - __le16 len; |
| 28 | - |
| 29 | - u8 ctrl; |
| 30 | - u8 rdd_idx; |
| 31 | - u8 rdd_rx_sel; |
| 32 | - u8 val; |
| 33 | - u8 rsv[4]; |
| 34 | - } __packed req = { |
| 35 | + struct mt7996_rdd_ctrl req = { |
| 36 | .tag = cpu_to_le16(UNI_RDD_CTRL_PARM), |
| 37 | .len = cpu_to_le16(sizeof(req) - 4), |
| 38 | .ctrl = cmd, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 39 | @@ -4556,6 +4545,37 @@ int mt7996_mcu_rdd_cmd(struct mt7996_dev *dev, int cmd, u8 index, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 40 | &req, sizeof(req), true); |
| 41 | } |
| 42 | |
| 43 | +int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, bool disable_timer) |
| 44 | +{ |
| 45 | + struct mt7996_rdd_ctrl req = { |
| 46 | + .tag = cpu_to_le16(UNI_RDD_CTRL_PARM), |
| 47 | + .len = cpu_to_le16(sizeof(req) - 4), |
| 48 | + .ctrl = RDD_DISABLE_ZW_TIMER, |
| 49 | + .rdd_idx = MT_RX_SEL2, |
| 50 | + .disable_timer = disable_timer, |
| 51 | + }; |
| 52 | + |
| 53 | + if (!is_mt7996(&dev->mt76) || |
| 54 | + (mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) % 2)) |
| 55 | + return 0; |
| 56 | + |
| 57 | + switch (dev->mt76.region) { |
| 58 | + case NL80211_DFS_ETSI: |
| 59 | + req.val = 0; |
| 60 | + break; |
| 61 | + case NL80211_DFS_JP: |
| 62 | + req.val = 2; |
| 63 | + break; |
| 64 | + case NL80211_DFS_FCC: |
| 65 | + default: |
| 66 | + req.val = 1; |
| 67 | + break; |
| 68 | + } |
| 69 | + |
| 70 | + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(RDD_CTRL), |
| 71 | + &req, sizeof(req), true); |
| 72 | +} |
| 73 | + |
| 74 | int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev, |
| 75 | struct ieee80211_vif *vif, |
| 76 | struct ieee80211_sta *sta) |
| 77 | diff --git a/mt7996/mcu.h b/mt7996/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 78 | index c6bb93b3..3025f849 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 79 | --- a/mt7996/mcu.h |
| 80 | +++ b/mt7996/mcu.h |
| 81 | @@ -119,6 +119,20 @@ struct mt7996_mcu_rdd_report { |
| 82 | } hw_pulse[32]; |
| 83 | } __packed; |
| 84 | |
| 85 | +struct mt7996_rdd_ctrl { |
| 86 | + u8 _rsv[4]; |
| 87 | + |
| 88 | + __le16 tag; |
| 89 | + __le16 len; |
| 90 | + |
| 91 | + u8 ctrl; |
| 92 | + u8 rdd_idx; |
| 93 | + u8 rdd_rx_sel; |
| 94 | + u8 val; |
| 95 | + u8 disable_timer; |
| 96 | + u8 rsv[3]; |
| 97 | +} __packed; |
| 98 | + |
| 99 | struct mt7996_mcu_background_chain_ctrl { |
| 100 | u8 _rsv[4]; |
| 101 | |
| 102 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 103 | index 32a0ffd8..e406dc87 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 104 | --- a/mt7996/mt7996.h |
| 105 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 106 | @@ -536,8 +536,11 @@ enum mt7996_rdd_cmd { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 107 | RDD_READ_PULSE, |
| 108 | RDD_RESUME_BF, |
| 109 | RDD_IRQ_OFF, |
| 110 | + RDD_DISABLE_ZW_TIMER, |
| 111 | }; |
| 112 | |
| 113 | +#define RDD_ZW_TIMER_OFF BIT(31) |
| 114 | + |
| 115 | static inline struct mt7996_phy * |
| 116 | mt7996_hw_phy(struct ieee80211_hw *hw) |
| 117 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 118 | @@ -697,6 +700,8 @@ int mt7996_mcu_set_thermal_protect(struct mt7996_phy *phy, bool enable); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 119 | int mt7996_mcu_set_txpower_sku(struct mt7996_phy *phy); |
| 120 | int mt7996_mcu_rdd_cmd(struct mt7996_dev *dev, int cmd, u8 index, |
| 121 | u8 rx_sel, u8 val); |
| 122 | +int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, |
| 123 | + bool disable_timer); |
| 124 | int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy, |
| 125 | struct cfg80211_chan_def *chandef); |
| 126 | int mt7996_mcu_set_fixed_rate_table(struct mt7996_phy *phy, u8 table_idx, |
| 127 | diff --git a/mt7996/vendor.c b/mt7996/vendor.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 128 | index 7ab64471..ba00ef35 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 129 | --- a/mt7996/vendor.c |
| 130 | +++ b/mt7996/vendor.c |
| 131 | @@ -108,6 +108,11 @@ rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = { |
| 132 | [MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TXBF] = { .type = NLA_U8 }, |
| 133 | }; |
| 134 | |
| 135 | +static const struct nla_policy |
| 136 | +background_radar_ctrl_policy[NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL] = { |
| 137 | + [MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE] = {.type = NLA_U8 }, |
| 138 | +}; |
| 139 | + |
| 140 | struct mt7996_amnt_data { |
| 141 | u8 idx; |
| 142 | u8 addr[ETH_ALEN]; |
| 143 | @@ -916,6 +921,27 @@ static int mt7996_vendor_wireless_ctrl(struct wiphy *wiphy, |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | +static int mt7996_vendor_background_radar_mode_ctrl(struct wiphy *wiphy, |
| 148 | + struct wireless_dev *wdev, |
| 149 | + const void *data, |
| 150 | + int data_len) |
| 151 | +{ |
| 152 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 153 | + struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 154 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL]; |
| 155 | + int err; |
| 156 | + u8 background_radar_mode; |
| 157 | + |
| 158 | + err = nla_parse(tb, MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX, data, data_len, |
| 159 | + background_radar_ctrl_policy, NULL); |
| 160 | + if (err) |
| 161 | + return err; |
| 162 | + |
| 163 | + background_radar_mode = nla_get_u8(tb[MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE]); |
| 164 | + |
| 165 | + return mt7996_mcu_rdd_background_disable_timer(dev, !!background_radar_mode); |
| 166 | +} |
| 167 | + |
| 168 | static const struct wiphy_vendor_command mt7996_vendor_commands[] = { |
| 169 | { |
| 170 | .info = { |
| 171 | @@ -1021,6 +1047,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = { |
| 172 | .policy = rfeature_ctrl_policy, |
| 173 | .maxattr = MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX, |
| 174 | }, |
| 175 | + { |
| 176 | + .info = { |
| 177 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 178 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL, |
| 179 | + }, |
| 180 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 181 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 182 | + .doit = mt7996_vendor_background_radar_mode_ctrl, |
| 183 | + .policy = background_radar_ctrl_policy, |
| 184 | + .maxattr = MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX, |
| 185 | + }, |
| 186 | }; |
| 187 | |
| 188 | void mt7996_vendor_register(struct mt7996_phy *phy) |
| 189 | diff --git a/mt7996/vendor.h b/mt7996/vendor.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 190 | index 2ee1339a..7c812f91 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 191 | --- a/mt7996/vendor.h |
| 192 | +++ b/mt7996/vendor.h |
| 193 | @@ -14,6 +14,7 @@ enum mtk_nl80211_vendor_subcmds { |
| 194 | MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8, |
| 195 | MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9, |
| 196 | MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca, |
| 197 | + MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL = 0xcb, |
| 198 | MTK_NL80211_VENDOR_SUBCMD_PP_CTRL = 0xcc, |
| 199 | }; |
| 200 | |
| 201 | @@ -127,6 +128,17 @@ enum mtk_vendor_attr_wireless_dump { |
| 202 | NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP - 1 |
| 203 | }; |
| 204 | |
| 205 | +enum mtk_vendor_attr_background_radar_ctrl { |
| 206 | + MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_UNSPEC, |
| 207 | + |
| 208 | + MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE, |
| 209 | + |
| 210 | + /* keep last */ |
| 211 | + NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL, |
| 212 | + MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX = |
| 213 | + NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL - 1 |
| 214 | +}; |
| 215 | + |
| 216 | enum bw_sig { |
| 217 | BW_SIGNALING_DISABLE, |
| 218 | BW_SIGNALING_STATIC, |
| 219 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 220 | 2.45.2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 221 | |