developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 1 | From e58fab916807bd40d8f3e7169e7a3e8df306878e Mon Sep 17 00:00:00 2001 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 3 | Date: Fri, 28 Oct 2022 10:15:56 +0800 |
developer | 1d6610e | 2022-12-14 13:09:20 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1125/1129] mt76: mt7915: add vendor subcmd three wire (PTA) |
developer | 3d5faf2 | 2022-11-29 18:07:22 +0800 | [diff] [blame] | 5 | ctrl |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 6 | |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 7 | Change-Id: Ic1044698f294455594a0c6254f55326fdab90580 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 8 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 9 | --- |
| 10 | mt76_connac_mcu.h | 2 +- |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 11 | mt7915/mcu.c | 50 ++++++++++++++++++++++------------------------- |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 12 | mt7915/mcu.h | 29 +++++++++++++++++++++++++++ |
| 13 | mt7915/mt7915.h | 1 + |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 14 | mt7915/vendor.c | 44 ++++++++++++++++++++++++++++++++++++++++- |
| 15 | mt7915/vendor.h | 14 +++++++++++++ |
| 16 | 6 files changed, 111 insertions(+), 29 deletions(-) |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 17 | |
| 18 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 19 | index 88bfd09f..5cff1a45 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 20 | --- a/mt76_connac_mcu.h |
| 21 | +++ b/mt76_connac_mcu.h |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 22 | @@ -1199,7 +1199,7 @@ enum { |
developer | 27b5525 | 2022-09-05 19: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, |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 30 | MCU_EXT_CMD_IPI_HIST_SCAN = 0xc5, |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 31 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 32 | index 7507344a..5791cb29 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 33 | --- a/mt7915/mcu.c |
| 34 | +++ b/mt7915/mcu.c |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 35 | @@ -4250,37 +4250,33 @@ void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable) |
developer | 27b5525 | 2022-09-05 19: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 | }; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 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 | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 97 | index 33e33d89..08476eb6 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 98 | --- a/mt7915/mcu.h |
| 99 | +++ b/mt7915/mcu.h |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 100 | @@ -674,6 +674,35 @@ struct mt7915_mcu_rdd_ipi_scan { |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 101 | u8 tx_assert_time; /* unit: us */ |
| 102 | } __packed; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 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 | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 137 | index 239eef58..22454b54 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 138 | --- a/mt7915/mt7915.h |
| 139 | +++ b/mt7915/mt7915.h |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 140 | @@ -756,6 +756,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction); |
developer | 27b5525 | 2022-09-05 19: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 | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 149 | index f7becce9..fb760e17 100644 |
developer | 27b5525 | 2022-09-05 19: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 }, |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 164 | @@ -971,7 +976,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 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 | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 173 | @@ -1116,6 +1121,7 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy, |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 174 | return 0; |
| 175 | } |
| 176 | |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 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 | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 181 | @@ -1159,6 +1165,31 @@ mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 182 | return len; |
| 183 | } |
| 184 | |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 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 | + |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 209 | + |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 210 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 211 | { |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 212 | .info = { |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 213 | @@ -1240,6 +1271,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 214 | .dumpit = mt7915_vendor_edcca_ctrl_dump, |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 232 | index c19ffe72..d96e5c23 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 233 | --- a/mt7915/vendor.h |
| 234 | +++ b/mt7915/vendor.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 235 | @@ -12,6 +12,7 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 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 | |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 243 | @@ -31,6 +32,7 @@ enum mtk_vendor_attr_edcca_ctrl { |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 244 | NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1 |
| 245 | }; |
| 246 | |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 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 | |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 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 | + |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 266 | + |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 267 | enum mtk_capi_control_changed { |
| 268 | CAPI_RFEATURE_CHANGED = BIT(16), |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 269 | CAPI_WIRELESS_CHANGED = BIT(17), |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 270 | -- |
developer | 2458e70 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 271 | 2.25.1 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 272 | |