developer | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 1 | From 07c6e8cd0e8ad51a294d4d2d3747f62dd22124ab Mon Sep 17 00:00:00 2001 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
developer | 887da63 | 2022-10-28 09:35:38 +0800 | [diff] [blame] | 3 | Date: Fri, 28 Oct 2022 10:15:56 +0800 |
developer | 8f0d89b | 2023-07-28 07:16:44 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1021/1034] wifi: mt76: mt7915: add vendor subcmd three wire |
developer | c923344 | 2023-04-04 06:06:17 +0800 | [diff] [blame] | 5 | (PTA) ctrl |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 6 | |
developer | 887da63 | 2022-10-28 09:35:38 +0800 | [diff] [blame] | 7 | Change-Id: Ic1044698f294455594a0c6254f55326fdab90580 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 8 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 9 | --- |
| 10 | mt76_connac_mcu.h | 2 +- |
developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 11 | mt7915/mcu.c | 50 ++++++++++++++++++++++------------------------- |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 12 | mt7915/mcu.h | 29 +++++++++++++++++++++++++++ |
| 13 | mt7915/mt7915.h | 1 + |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 14 | mt7915/vendor.c | 44 ++++++++++++++++++++++++++++++++++++++++- |
| 15 | mt7915/vendor.h | 14 +++++++++++++ |
| 16 | 6 files changed, 111 insertions(+), 29 deletions(-) |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 17 | |
| 18 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 19 | index da2f5dd0..daeec01f 100644 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 20 | --- a/mt76_connac_mcu.h |
| 21 | +++ b/mt76_connac_mcu.h |
developer | 2157bf8 | 2023-06-26 02:27:49 +0800 | [diff] [blame] | 22 | @@ -1204,7 +1204,7 @@ enum { |
developer | 6727afb | 2022-09-01 20:56:09 +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 | 887da63 | 2022-10-28 09:35:38 +0800 | [diff] [blame] | 30 | MCU_EXT_CMD_IPI_HIST_SCAN = 0xc5, |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 31 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 32 | index 96c47273..4aee1268 100644 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 33 | --- a/mt7915/mcu.c |
| 34 | +++ b/mt7915/mcu.c |
developer | 8f0d89b | 2023-07-28 07:16:44 +0800 | [diff] [blame] | 35 | @@ -4517,37 +4517,33 @@ void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable) |
developer | 6727afb | 2022-09-01 20:56:09 +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 | 6727afb | 2022-09-01 20:56:09 +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 | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 97 | index d271e2be..5fc4e2ef 100644 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 98 | --- a/mt7915/mcu.h |
| 99 | +++ b/mt7915/mcu.h |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 100 | @@ -904,6 +904,35 @@ struct mt7915_mcu_rdd_ipi_scan { |
developer | 887da63 | 2022-10-28 09:35:38 +0800 | [diff] [blame] | 101 | u8 tx_assert_time; /* unit: us */ |
| 102 | } __packed; |
developer | 6727afb | 2022-09-01 20:56:09 +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 | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 137 | index 6c4f407b..b5f76a32 100644 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 138 | --- a/mt7915/mt7915.h |
| 139 | +++ b/mt7915/mt7915.h |
developer | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 140 | @@ -704,6 +704,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction); |
developer | 6727afb | 2022-09-01 20:56:09 +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 | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 149 | index 0c0b47e7..b651cea2 100644 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 150 | --- a/mt7915/vendor.c |
| 151 | +++ b/mt7915/vendor.c |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 152 | @@ -40,6 +40,11 @@ mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = { |
| 153 | [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 }, |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 164 | @@ -973,7 +978,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
developer | 6727afb | 2022-09-01 20:56:09 +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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 173 | @@ -1117,6 +1122,7 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy, |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 174 | return 0; |
| 175 | } |
| 176 | |
developer | 335cbee | 2022-11-17 14:55:34 +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 | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 181 | @@ -1160,6 +1166,31 @@ mt7915_vendor_edcca_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 182 | return len; |
| 183 | } |
| 184 | |
developer | 6727afb | 2022-09-01 20:56:09 +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 | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 209 | + |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 210 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 211 | { |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 212 | .info = { |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 213 | @@ -1241,6 +1272,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 214 | .dumpit = mt7915_vendor_edcca_ctrl_dump, |
developer | 6727afb | 2022-09-01 20:56:09 +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 | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 232 | index d8e23d34..de3cbe2c 100644 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 233 | --- a/mt7915/vendor.h |
| 234 | +++ b/mt7915/vendor.h |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 235 | @@ -12,6 +12,7 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 57de9b7 | 2023-02-20 11:15:54 +0800 | [diff] [blame] | 236 | MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 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 | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 243 | @@ -31,6 +32,7 @@ enum mtk_vendor_attr_edcca_ctrl { |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 244 | NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1 |
| 245 | }; |
| 246 | |
developer | 335cbee | 2022-11-17 14:55:34 +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 | 6727afb | 2022-09-01 20:56:09 +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 | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 266 | + |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 267 | enum mtk_capi_control_changed { |
| 268 | CAPI_RFEATURE_CHANGED = BIT(16), |
developer | 335cbee | 2022-11-17 14:55:34 +0800 | [diff] [blame] | 269 | CAPI_WIRELESS_CHANGED = BIT(17), |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 270 | -- |
developer | 849549c | 2023-08-02 17:26:48 +0800 | [diff] [blame^] | 271 | 2.39.2 |
developer | 6727afb | 2022-09-01 20:56:09 +0800 | [diff] [blame] | 272 | |