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