developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From a2610e02282fb1825cdc2d76ebff9e979a6a977c Mon Sep 17 00:00:00 2001 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 28 Oct 2022 10:15:56 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1018/1052] wifi: mt76: mt7915: add vendor subcmd three wire |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame] | 5 | (PTA) ctrl |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 6 | |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 8 | --- |
| 9 | mt76_connac_mcu.h | 2 +- |
| 10 | mt7915/mcu.c | 50 ++++++++++++++++++++++------------------------- |
| 11 | mt7915/mcu.h | 29 +++++++++++++++++++++++++++ |
| 12 | mt7915/mt7915.h | 1 + |
| 13 | mt7915/vendor.c | 44 ++++++++++++++++++++++++++++++++++++++++- |
| 14 | mt7915/vendor.h | 14 +++++++++++++ |
| 15 | 6 files changed, 111 insertions(+), 29 deletions(-) |
| 16 | |
| 17 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 18 | index a85179b8..e7eb6a93 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 19 | --- a/mt76_connac_mcu.h |
| 20 | +++ b/mt76_connac_mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 21 | @@ -1253,7 +1253,7 @@ enum { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 22 | MCU_EXT_CMD_SMESH_CTRL = 0xae, |
| 23 | MCU_EXT_CMD_RX_STAT_USER_CTRL = 0xb3, |
developer | dad89a3 | 2024-04-29 14:17:17 +0800 | [diff] [blame] | 24 | MCU_EXT_CMD_SET_QOS_MAP = 0xb4, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 25 | - MCU_EXT_CMD_CERT_CFG = 0xb7, |
| 26 | + MCU_EXT_CMD_SET_CFG = 0xb7, |
| 27 | MCU_EXT_CMD_EDCCA = 0xba, |
| 28 | MCU_EXT_CMD_CSI_CTRL = 0xc2, |
| 29 | MCU_EXT_CMD_IPI_HIST_SCAN = 0xc5, |
| 30 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 31 | index f83d969c..3e4239f6 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 32 | --- a/mt7915/mcu.c |
| 33 | +++ b/mt7915/mcu.c |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 34 | @@ -4736,37 +4736,33 @@ void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable) |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 35 | &req, sizeof(req), false); |
| 36 | } |
| 37 | |
| 38 | -void mt7915_mcu_set_cert(struct mt7915_phy *phy, u8 type) |
| 39 | +int mt7915_mcu_set_cfg(struct mt7915_phy *phy, u8 cfg_info, u8 type) |
| 40 | { |
| 41 | -#define CFGINFO_CERT_CFG 4 |
| 42 | struct mt7915_dev *dev = phy->dev; |
| 43 | - struct { |
| 44 | - struct basic_info{ |
| 45 | - u8 dbdc_idx; |
| 46 | - u8 rsv[3]; |
| 47 | - __le32 tlv_num; |
| 48 | - u8 tlv_buf[0]; |
| 49 | - } hdr; |
| 50 | - struct cert_cfg{ |
| 51 | - __le16 tag; |
| 52 | - __le16 length; |
| 53 | - u8 cert_program; |
| 54 | - u8 rsv[3]; |
| 55 | - } tlv; |
| 56 | - } req = { |
| 57 | - .hdr = { |
| 58 | - .dbdc_idx = phy != &dev->phy, |
| 59 | - .tlv_num = cpu_to_le32(1), |
| 60 | - }, |
| 61 | - .tlv = { |
| 62 | - .tag = cpu_to_le16(CFGINFO_CERT_CFG), |
| 63 | - .length = cpu_to_le16(sizeof(struct cert_cfg)), |
| 64 | - .cert_program = type, /* 1: CAPI Enable */ |
| 65 | - } |
| 66 | + struct cfg_basic_info req = { |
| 67 | + .dbdc_idx = phy != &dev->phy, |
| 68 | + .tlv_num = cpu_to_le32(1), |
| 69 | }; |
| 70 | + int tlv_len; |
| 71 | + |
| 72 | + switch (cfg_info) { |
| 73 | + case CFGINFO_CERT_CFG: |
| 74 | + tlv_len = sizeof(struct cert_cfg); |
| 75 | + req.cert.tag = cpu_to_le16(cfg_info); |
| 76 | + req.cert.length = cpu_to_le16(tlv_len); |
| 77 | + req.cert.cert_program = type; |
| 78 | + break; |
| 79 | + case CFGINFO_3WIRE_EN_CFG: |
| 80 | + tlv_len = sizeof(struct three_wire_cfg); |
| 81 | + req.three_wire.tag = cpu_to_le16(cfg_info); |
| 82 | + req.three_wire.length = cpu_to_le16(tlv_len); |
| 83 | + req.three_wire.three_wire_en = type; |
| 84 | + break; |
| 85 | + default: |
| 86 | + return -EOPNOTSUPP; |
| 87 | + } |
| 88 | |
| 89 | - mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(CERT_CFG), |
| 90 | - &req, sizeof(req), false); |
| 91 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_CFG), &req, sizeof(req), false); |
| 92 | } |
| 93 | |
| 94 | void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val) |
| 95 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 96 | index 1682c117..1b0bd06b 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 97 | --- a/mt7915/mcu.h |
| 98 | +++ b/mt7915/mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 99 | @@ -916,6 +916,35 @@ struct mt7915_mcu_rdd_ipi_scan { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 100 | u8 tx_assert_time; /* unit: us */ |
| 101 | } __packed; |
| 102 | |
| 103 | +struct cert_cfg { |
| 104 | + __le16 tag; |
| 105 | + __le16 length; |
| 106 | + u8 cert_program; |
| 107 | + u8 rsv[3]; |
| 108 | +} __packed; |
| 109 | + |
| 110 | +struct three_wire_cfg { |
| 111 | + __le16 tag; |
| 112 | + __le16 length; |
| 113 | + u8 three_wire_en; |
| 114 | + u8 rsv[3]; |
| 115 | +} __packed; |
| 116 | + |
| 117 | +struct cfg_basic_info { |
| 118 | + u8 dbdc_idx; |
| 119 | + u8 rsv[3]; |
| 120 | + __le32 tlv_num; |
| 121 | + union { |
| 122 | + struct cert_cfg cert; |
| 123 | + struct three_wire_cfg three_wire; |
| 124 | + }; |
| 125 | +} __packed; |
| 126 | + |
| 127 | +enum { |
| 128 | + CFGINFO_CERT_CFG = 4, |
| 129 | + CFGINFO_3WIRE_EN_CFG = 10, |
| 130 | +}; |
| 131 | + |
| 132 | /* MURU */ |
| 133 | #define OFDMA_DL BIT(0) |
| 134 | #define OFDMA_UL BIT(1) |
| 135 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 136 | index 2fb8e2fb..6027e7f7 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 137 | --- a/mt7915/mt7915.h |
| 138 | +++ b/mt7915/mt7915.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 139 | @@ -781,6 +781,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction); |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 140 | void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable); |
| 141 | int mt7915_mcu_set_mu_edca(struct mt7915_phy *phy, u8 val); |
| 142 | void mt7915_mcu_set_cert(struct mt7915_phy *phy, u8 type); |
| 143 | +int mt7915_mcu_set_cfg(struct mt7915_phy *phy, u8 cfg_info, u8 type); |
| 144 | void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val); |
| 145 | void mt7915_vendor_register(struct mt7915_phy *phy); |
| 146 | int mt7915_mcu_set_csi(struct mt7915_phy *phy, u8 mode, |
| 147 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 148 | index eb0b380d..54b89030 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 149 | --- a/mt7915/vendor.c |
| 150 | +++ b/mt7915/vendor.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 151 | @@ -42,6 +42,11 @@ mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 152 | [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 }, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | +static const struct nla_policy |
| 156 | +three_wire_ctrl_policy[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL] = { |
| 157 | + [MTK_VENDOR_ATTR_3WIRE_CTRL_MODE] = {.type = NLA_U8 }, |
| 158 | +}; |
| 159 | + |
| 160 | static const struct nla_policy |
| 161 | rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = { |
| 162 | [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 }, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 163 | @@ -1128,7 +1133,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 164 | mt7915_set_wireless_vif, &val32); |
| 165 | } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]) { |
| 166 | val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]); |
| 167 | - mt7915_mcu_set_cert(phy, val8); /* Cert Enable for OMI */ |
| 168 | + mt7915_mcu_set_cfg(phy, CFGINFO_CERT_CFG, val8); /* Cert Enable for OMI */ |
| 169 | mt7915_mcu_set_bypass_smthint(phy, val8); /* Cert bypass smooth interpolation */ |
| 170 | } |
| 171 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 172 | @@ -1272,6 +1277,7 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | + |
| 177 | static int |
| 178 | mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 179 | struct sk_buff *skb, const void *data, int data_len, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 180 | @@ -1315,6 +1321,31 @@ mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 181 | return len; |
| 182 | } |
| 183 | |
| 184 | +static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy, |
| 185 | + struct wireless_dev *wdev, |
| 186 | + const void *data, |
| 187 | + int data_len) |
| 188 | +{ |
| 189 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 190 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 191 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL]; |
| 192 | + int err; |
| 193 | + u8 three_wire_mode; |
| 194 | + |
| 195 | + err = nla_parse(tb, MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, data, data_len, |
| 196 | + three_wire_ctrl_policy, NULL); |
| 197 | + if (err) |
| 198 | + return err; |
| 199 | + |
| 200 | + if (!tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE]) |
| 201 | + return -EINVAL; |
| 202 | + |
| 203 | + three_wire_mode = nla_get_u8(tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE]); |
| 204 | + |
| 205 | + return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode); |
| 206 | +} |
| 207 | + |
| 208 | + |
| 209 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 210 | { |
| 211 | .info = { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 212 | @@ -1396,6 +1427,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 213 | .dumpit = mt7915_vendor_edcca_ctrl_dump, |
| 214 | .policy = edcca_ctrl_policy, |
| 215 | .maxattr = MTK_VENDOR_ATTR_EDCCA_CTRL_MAX, |
| 216 | + }, |
| 217 | + { |
| 218 | + .info = { |
| 219 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 220 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL, |
| 221 | + }, |
| 222 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 223 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 224 | + .doit = mt7915_vendor_3wire_ctrl, |
| 225 | + .policy = three_wire_ctrl_policy, |
| 226 | + .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, |
| 227 | } |
| 228 | }; |
| 229 | |
| 230 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 231 | index c61ba260..ddde0cc0 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 232 | --- a/mt7915/vendor.h |
| 233 | +++ b/mt7915/vendor.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 234 | @@ -13,6 +13,7 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 235 | MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 236 | MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6, |
| 237 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 238 | + MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8 |
| 239 | }; |
| 240 | |
| 241 | |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 242 | @@ -32,6 +33,7 @@ enum mtk_vendor_attr_edcca_ctrl { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 243 | NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1 |
| 244 | }; |
| 245 | |
| 246 | + |
| 247 | enum mtk_vendor_attr_edcca_dump { |
| 248 | MTK_VENDOR_ATTR_EDCCA_DUMP_UNSPEC = 0, |
| 249 | |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 250 | @@ -46,6 +48,18 @@ enum mtk_vendor_attr_edcca_dump { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 251 | NUM_MTK_VENDOR_ATTRS_EDCCA_DUMP - 1 |
| 252 | }; |
| 253 | |
| 254 | +enum mtk_vendor_attr_3wire_ctrl { |
| 255 | + MTK_VENDOR_ATTR_3WIRE_CTRL_UNSPEC, |
| 256 | + |
| 257 | + MTK_VENDOR_ATTR_3WIRE_CTRL_MODE, |
| 258 | + |
| 259 | + /* keep last */ |
| 260 | + NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL, |
| 261 | + MTK_VENDOR_ATTR_3WIRE_CTRL_MAX = |
| 262 | + NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL - 1 |
| 263 | +}; |
| 264 | + |
| 265 | + |
| 266 | enum mtk_capi_control_changed { |
| 267 | CAPI_RFEATURE_CHANGED = BIT(16), |
| 268 | CAPI_WIRELESS_CHANGED = BIT(17), |
| 269 | -- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 270 | 2.18.0 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 271 | |