developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 1 | From e5184f1fcbbeba3543d267190e886b1fb68cc757 Mon Sep 17 00:00:00 2001 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 2 | From: TomLiu <tomml.liu@mediatek.com> |
| 3 | Date: Wed, 21 Sep 2022 13:55:15 -0700 |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1126/1128] mt76: mt7915: add AMPDU/AMSDU OnOff ctonrol |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 5 | |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 6 | Change-Id: I6030b3a420e96b02e83b0c7a3c3626a3b23c97e3 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 7 | --- |
| 8 | mt7915/mac.c | 28 ++++++++++++++++++++++++++++ |
| 9 | mt7915/mt7915.h | 2 ++ |
| 10 | mt7915/vendor.c | 39 +++++++++++++++++++++++++++++++++++++++ |
| 11 | mt7915/vendor.h | 14 ++++++++++++++ |
| 12 | 4 files changed, 83 insertions(+) |
| 13 | |
| 14 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 15 | index acc9871b..5a809c2c 100644 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 16 | --- a/mt7915/mac.c |
| 17 | +++ b/mt7915/mac.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 18 | @@ -2020,6 +2020,34 @@ static void mt7915_mac_severe_check(struct mt7915_phy *phy) |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 19 | phy->trb_ts = trb; |
| 20 | } |
| 21 | |
| 22 | +void mt7915_set_wireless_ampdu(struct ieee80211_hw *hw, u8 en) |
| 23 | +{ |
| 24 | + ieee80211_del_all_station(hw); |
| 25 | + /* clear/set the feature ampdu support */ |
| 26 | + if (en) |
| 27 | + ieee80211_hw_set(hw, AMPDU_AGGREGATION); |
| 28 | + else |
| 29 | + ieee80211_hw_clear(hw, AMPDU_AGGREGATION); |
| 30 | +} |
| 31 | + |
| 32 | +void mt7915_set_wireless_amsdu(struct ieee80211_hw *hw, u8 en) { |
| 33 | + struct mt76_phy *mphy = hw->priv; |
| 34 | + struct mt76_dev *mdev = mphy->dev; |
| 35 | + |
| 36 | + if (!ieee80211_hw_check(hw, AMPDU_AGGREGATION)) { |
| 37 | + dev_err(mdev->dev, "AMSDU set failed, please enable ampdu first!\n"); |
| 38 | + return; |
| 39 | + } |
| 40 | + |
| 41 | + ieee80211_del_all_station(hw); |
| 42 | + |
| 43 | + /* clear/set the feature ampdu support */ |
| 44 | + if (en) |
| 45 | + ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU); |
| 46 | + else |
| 47 | + ieee80211_hw_clear(hw, SUPPORTS_AMSDU_IN_AMPDU); |
| 48 | +} |
| 49 | + |
| 50 | #ifdef CONFIG_MTK_VENDOR |
| 51 | void mt7915_capi_sta_rc_work(void *data, struct ieee80211_sta *sta) |
| 52 | { |
| 53 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 54 | index 7c7c4882..c43661f5 100644 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 55 | --- a/mt7915/mt7915.h |
| 56 | +++ b/mt7915/mt7915.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 57 | @@ -737,6 +737,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 58 | bool pci, int *irq); |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 59 | |
| 60 | #ifdef CONFIG_MTK_VENDOR |
| 61 | +void mt7915_set_wireless_ampdu(struct ieee80211_hw *hw, u8 en); |
| 62 | +void mt7915_set_wireless_amsdu(struct ieee80211_hw *hw, u8 en); |
| 63 | void mt7915_capi_sta_rc_work(void *data, struct ieee80211_sta *sta); |
| 64 | void mt7915_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif); |
| 65 | void mt7915_mcu_set_rfeature_starec(void *data, struct mt7915_dev *dev, |
| 66 | diff --git a/mt7915/vendor.c b/mt7915/vendor.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 67 | index cbbb0843..d73fdd4c 100644 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 68 | --- a/mt7915/vendor.c |
| 69 | +++ b/mt7915/vendor.c |
| 70 | @@ -30,10 +30,18 @@ wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = { |
| 71 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA] = {.type = NLA_U8 }, |
| 72 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO] = {.type = NLA_U8 }, |
| 73 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE] = {.type = NLA_U16 }, |
| 74 | + [MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU] = {.type = NLA_U8 }, |
| 75 | + [MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU] = {.type = NLA_U8 }, |
| 76 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_MU_EDCA] = {.type = NLA_U8 }, |
| 77 | [MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT] = {.type = NLA_U8 }, |
| 78 | }; |
| 79 | |
| 80 | +static const struct nla_policy |
| 81 | +wireless_dump_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP] = { |
| 82 | + [MTK_VENDOR_ATTR_WIRELESS_DUMP_AMPDU] = { .type = NLA_U8 }, |
| 83 | + [MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU] = { .type = NLA_U8 }, |
| 84 | +}; |
| 85 | + |
| 86 | static const struct nla_policy |
| 87 | hemu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_HEMU_CTRL] = { |
| 88 | [MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF] = {.type = NLA_U8 }, |
| 89 | @@ -981,11 +989,41 @@ static int mt7915_vendor_wireless_ctrl(struct wiphy *wiphy, |
| 90 | val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]); |
| 91 | mt7915_mcu_set_cfg(phy, CFGINFO_CERT_CFG, val8); /* Cert Enable for OMI */ |
| 92 | mt7915_mcu_set_bypass_smthint(phy, val8); /* Cert bypass smooth interpolation */ |
| 93 | + } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU]) { |
| 94 | + val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU]); |
| 95 | + mt7915_set_wireless_ampdu(hw, val8); |
| 96 | + } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU]) { |
| 97 | + val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU]); |
| 98 | + mt7915_set_wireless_amsdu(hw, val8); |
| 99 | } |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | +static int |
| 105 | +mt7915_vendor_wireless_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 106 | + struct sk_buff *skb, const void *data, int data_len, |
| 107 | + unsigned long *storage) |
| 108 | +{ |
| 109 | + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 110 | + struct mt7915_phy *phy = mt7915_hw_phy(hw); |
| 111 | + struct mt7915_dev *dev = phy->dev; |
| 112 | + int len = 0; |
| 113 | + if (*storage == 1) |
| 114 | + return -ENOENT; |
| 115 | + *storage = 1; |
| 116 | + |
| 117 | + |
| 118 | + if (nla_put_u8(skb, |
| 119 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_AMPDU, ieee80211_hw_check(hw, AMPDU_AGGREGATION)) || |
| 120 | + nla_put_u8(skb, |
| 121 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU, ieee80211_hw_check(hw, SUPPORTS_AMSDU_IN_AMPDU))) |
| 122 | + return -ENOMEM; |
| 123 | + len += 2; |
| 124 | + |
| 125 | + return len; |
| 126 | +} |
| 127 | + |
| 128 | static int mt7915_vendor_hemu_ctrl(struct wiphy *wiphy, |
| 129 | struct wireless_dev *wdev, |
| 130 | const void *data, |
| 131 | @@ -1223,6 +1261,7 @@ static const struct wiphy_vendor_command mt7915_vendor_commands[] = { |
| 132 | .flags = WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 133 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 134 | .doit = mt7915_vendor_wireless_ctrl, |
| 135 | + .dumpit = mt7915_vendor_wireless_ctrl_dump, |
| 136 | .policy = wireless_ctrl_policy, |
| 137 | .maxattr = MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX, |
| 138 | }, |
| 139 | diff --git a/mt7915/vendor.h b/mt7915/vendor.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 140 | index 5aac5595..53abb100 100644 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 141 | --- a/mt7915/vendor.h |
| 142 | +++ b/mt7915/vendor.h |
| 143 | @@ -58,6 +58,8 @@ enum mtk_vendor_attr_wireless_ctrl { |
| 144 | MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA, |
| 145 | MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE, |
| 146 | MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO, |
| 147 | + MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU, |
| 148 | + MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU, |
| 149 | MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT = 9, |
| 150 | |
| 151 | MTK_VENDOR_ATTR_WIRELESS_CTRL_MU_EDCA, /* reserve */ |
| 152 | @@ -67,6 +69,18 @@ enum mtk_vendor_attr_wireless_ctrl { |
| 153 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1 |
| 154 | }; |
| 155 | |
| 156 | +enum mtk_vendor_attr_wireless_dump { |
| 157 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_UNSPEC, |
| 158 | + |
| 159 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_AMPDU, |
| 160 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU, |
| 161 | + |
| 162 | + /* keep last */ |
| 163 | + NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP, |
| 164 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_MAX = |
| 165 | + NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP - 1 |
| 166 | +}; |
| 167 | + |
| 168 | enum mtk_vendor_attr_hemu_ctrl { |
| 169 | MTK_VENDOR_ATTR_HEMU_CTRL_UNSPEC, |
| 170 | |
| 171 | -- |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 172 | 2.18.0 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 173 | |