developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 1 | From c2a099c2d4c02f67232cf98ee7d4e4b241b6befc 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> |
| 3 | Date: Tue, 30 Aug 2022 15:29:38 +0800 |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1123/1124] mt76: mt7915: add vendor subcmd three wire (PTA) |
| 5 | ctrl |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 6 | |
| 7 | Change-Id: Ie092d63af9a1e06bef36fc5a5bac40fdab73dba5 |
| 8 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 9 | --- |
| 10 | mt76_connac_mcu.h | 2 +- |
| 11 | mt7915/mcu.c | 51 ++++++++++++++++++++++------------------------- |
| 12 | mt7915/mcu.h | 29 +++++++++++++++++++++++++++ |
| 13 | mt7915/mt7915.h | 1 + |
| 14 | mt7915/vendor.c | 42 +++++++++++++++++++++++++++++++++++++- |
| 15 | mt7915/vendor.h | 12 +++++++++++ |
| 16 | 6 files changed, 108 insertions(+), 29 deletions(-) |
| 17 | |
| 18 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 19 | index 6143d8e..27a3624 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 | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 22 | @@ -1156,7 +1156,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, |
| 30 | }; |
| 31 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 32 | index 8dcc54e..477a41c 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 33 | --- a/mt7915/mcu.c |
| 34 | +++ b/mt7915/mcu.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 35 | @@ -4019,37 +4019,34 @@ 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 | }; |
| 71 | + struct sk_buff *skb; |
| 72 | + int tlv_len; |
| 73 | + |
| 74 | + switch (cfg_info) { |
| 75 | + case CFGINFO_CERT_CFG: |
| 76 | + tlv_len = sizeof(struct cert_cfg); |
| 77 | + req.cert.tag = cpu_to_le16(cfg_info); |
| 78 | + req.cert.length = cpu_to_le16(tlv_len); |
| 79 | + req.cert.cert_program = type; |
| 80 | + break; |
| 81 | + case CFGINFO_3WIRE_EN_CFG: |
| 82 | + tlv_len = sizeof(struct three_wire_cfg); |
| 83 | + req.three_wire.tag = cpu_to_le16(cfg_info); |
| 84 | + req.three_wire.length = cpu_to_le16(tlv_len); |
| 85 | + req.three_wire.three_wire_en = type; |
| 86 | + break; |
| 87 | + default: |
| 88 | + return -EOPNOTSUPP; |
| 89 | + } |
| 90 | |
| 91 | - mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(CERT_CFG), |
| 92 | - &req, sizeof(req), false); |
| 93 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_CFG), &req, sizeof(req), false); |
| 94 | } |
| 95 | |
| 96 | void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val) |
| 97 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 98 | index b8a433e..9d0fac4 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 99 | --- a/mt7915/mcu.h |
| 100 | +++ b/mt7915/mcu.h |
| 101 | @@ -576,6 +576,35 @@ struct csi_data { |
| 102 | }; |
| 103 | #endif |
| 104 | |
| 105 | +struct cert_cfg { |
| 106 | + __le16 tag; |
| 107 | + __le16 length; |
| 108 | + u8 cert_program; |
| 109 | + u8 rsv[3]; |
| 110 | +} __packed; |
| 111 | + |
| 112 | +struct three_wire_cfg { |
| 113 | + __le16 tag; |
| 114 | + __le16 length; |
| 115 | + u8 three_wire_en; |
| 116 | + u8 rsv[3]; |
| 117 | +} __packed; |
| 118 | + |
| 119 | +struct cfg_basic_info { |
| 120 | + u8 dbdc_idx; |
| 121 | + u8 rsv[3]; |
| 122 | + __le32 tlv_num; |
| 123 | + union { |
| 124 | + struct cert_cfg cert; |
| 125 | + struct three_wire_cfg three_wire; |
| 126 | + }; |
| 127 | +} __packed; |
| 128 | + |
| 129 | +enum { |
| 130 | + CFGINFO_CERT_CFG = 4, |
| 131 | + CFGINFO_3WIRE_EN_CFG = 10, |
| 132 | +}; |
| 133 | + |
| 134 | /* MURU */ |
| 135 | #define OFDMA_DL BIT(0) |
| 136 | #define OFDMA_UL BIT(1) |
| 137 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 138 | index 5fa1dfa..f403820 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 139 | --- a/mt7915/mt7915.h |
| 140 | +++ b/mt7915/mt7915.h |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 141 | @@ -727,6 +727,7 @@ void mt7915_mcu_set_mimo(struct mt7915_phy *phy, u8 direction); |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 142 | void mt7915_mcu_set_dynalgo(struct mt7915_phy *phy, u8 enable); |
| 143 | int mt7915_mcu_set_mu_edca(struct mt7915_phy *phy, u8 val); |
| 144 | void mt7915_mcu_set_cert(struct mt7915_phy *phy, u8 type); |
| 145 | +int mt7915_mcu_set_cfg(struct mt7915_phy *phy, u8 cfg_info, u8 type); |
| 146 | void mt7915_mcu_set_bypass_smthint(struct mt7915_phy *phy, u8 val); |
| 147 | void mt7915_vendor_register(struct mt7915_phy *phy); |
| 148 | int mt7915_mcu_set_csi(struct mt7915_phy *phy, u8 mode, |
| 149 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 150 | index 7acb330..7f67c0d 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 151 | --- a/mt7915/vendor.c |
| 152 | +++ b/mt7915/vendor.c |
| 153 | @@ -40,6 +40,11 @@ hemu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_HEMU_CTRL] = { |
| 154 | [MTK_VENDOR_ATTR_HEMU_CTRL_DUMP] = {.type = NLA_U8 }, |
| 155 | }; |
| 156 | |
| 157 | +static const struct nla_policy |
| 158 | +three_wire_ctrl_policy[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL] = { |
| 159 | + [MTK_VENDOR_ATTR_3WIRE_CTRL_MODE] = {.type = NLA_U8 }, |
| 160 | +}; |
| 161 | + |
| 162 | static const struct nla_policy |
| 163 | rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = { |
| 164 | [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 }, |
| 165 | @@ -964,7 +969,7 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
| 166 | mt7915_set_wireless_vif, &val32); |
| 167 | } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]) { |
| 168 | val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]); |
| 169 | - mt7915_mcu_set_cert(phy, val8); /* Cert Enable for OMI */ |
| 170 | + mt7915_mcu_set_cfg(phy, CFGINFO_CERT_CFG, val8); /* Cert Enable for OMI */ |
| 171 | mt7915_mcu_set_bypass_smthint(phy, val8); /* Cert bypass smooth interpolation */ |
| 172 | } |
| 173 | |
| 174 | @@ -1091,6 +1096,30 @@ static int mt7915_vendor_edcca_ctrl(struct wiphy *wiphy, |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | +static int mt7915_vendor_3wire_ctrl(struct wiphy *wiphy, |
| 179 | + struct wireless_dev *wdev, |
| 180 | + const void *data, |
| 181 | + int data_len) |
| 182 | +{ |
| 183 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 184 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 185 | + struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL]; |
| 186 | + int err; |
| 187 | + u8 three_wire_mode; |
| 188 | + |
| 189 | + err = nla_parse(tb, MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, data, data_len, |
| 190 | + three_wire_ctrl_policy, NULL); |
| 191 | + if (err) |
| 192 | + return err; |
| 193 | + |
| 194 | + if (!tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE]) |
| 195 | + return -EINVAL; |
| 196 | + |
| 197 | + three_wire_mode = nla_get_u8(tb[MTK_VENDOR_ATTR_3WIRE_CTRL_MODE]); |
| 198 | + |
| 199 | + return mt7915_mcu_set_cfg(phy, CFGINFO_3WIRE_EN_CFG, three_wire_mode); |
| 200 | +} |
| 201 | + |
| 202 | |
| 203 | static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 204 | { |
| 205 | @@ -1172,6 +1201,17 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 206 | .doit = mt7915_vendor_edcca_ctrl, |
| 207 | .policy = edcca_ctrl_policy, |
| 208 | .maxattr = MTK_VENDOR_ATTR_EDCCA_CTRL_MAX, |
| 209 | + }, |
| 210 | + { |
| 211 | + .info = { |
| 212 | + .vendor_id = MTK_NL80211_VENDOR_ID, |
| 213 | + .subcmd = MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL, |
| 214 | + }, |
| 215 | + .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 216 | + WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 217 | + .doit = mt7915_vendor_3wire_ctrl, |
| 218 | + .policy = three_wire_ctrl_policy, |
| 219 | + .maxattr = MTK_VENDOR_ATTR_3WIRE_CTRL_MAX, |
| 220 | } |
| 221 | }; |
| 222 | |
| 223 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 224 | index 57f52f3..e0c5fd9 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 225 | --- a/mt7915/vendor.h |
| 226 | +++ b/mt7915/vendor.h |
| 227 | @@ -11,6 +11,7 @@ enum mtk_nl80211_vendor_subcmds { |
| 228 | MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5, |
| 229 | MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL = 0xc6, |
| 230 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 231 | + MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8 |
| 232 | }; |
| 233 | |
| 234 | |
| 235 | @@ -30,6 +31,17 @@ enum mtk_vendor_attr_edcca_ctrl { |
| 236 | NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL - 1 |
| 237 | }; |
| 238 | |
| 239 | +enum mtk_vendor_attr_3wire_ctrl { |
| 240 | + MTK_VENDOR_ATTR_3WIRE_CTRL_UNSPEC, |
| 241 | + |
| 242 | + MTK_VENDOR_ATTR_3WIRE_CTRL_MODE, |
| 243 | + |
| 244 | + /* keep last */ |
| 245 | + NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL, |
| 246 | + MTK_VENDOR_ATTR_3WIRE_CTRL_MAX = |
| 247 | + NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL - 1 |
| 248 | +}; |
| 249 | + |
| 250 | |
| 251 | enum mtk_capi_control_changed { |
| 252 | CAPI_RFEATURE_CHANGED = BIT(16), |
| 253 | -- |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame^] | 254 | 2.18.0 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 255 | |