Add phy subcommands to enable/disable AMPDU/AMSDU aggregation.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich...@quantenna.com>
---
 nl80211.h |  6 ++++++
 phy.c     | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/nl80211.h b/nl80211.h
index 1766a12..41eec4a 100644
--- a/nl80211.h
+++ b/nl80211.h
@@ -2241,6 +2241,9 @@ enum nl80211_commands {
  *     association request when used with NL80211_CMD_NEW_STATION). Can be set
  *     only if %NL80211_STA_FLAG_WME is set.
  *
+ * @NL80211_ATTR_WIPHY_AMPDU_ENABLED: enable/disable AMPDU aggregation.
+ * @NL80211_ATTR_WIPHY_AMSDU_ENABLED: enable/disable AMSDU aggregation.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2682,6 +2685,9 @@ enum nl80211_attrs {
 
        NL80211_ATTR_HE_CAPABILITY,
 
+       NL80211_ATTR_WIPHY_AMPDU_ENABLED,
+       NL80211_ATTR_WIPHY_AMSDU_ENABLED,
+
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
diff --git a/phy.c b/phy.c
index 77df7a7..be949e7 100644
--- a/phy.c
+++ b/phy.c
@@ -843,3 +843,63 @@ static int handle_get_txq(struct nl80211_state *state,
 COMMAND(get, txq, "",
        NL80211_CMD_GET_WIPHY, 0, CIB_PHY, handle_get_txq,
        "Get TXQ parameters.");
+
+static int handle_ampdu(struct nl80211_state *state,
+                       struct nl_msg *msg,
+                       int argc, char **argv,
+                       enum id_input id)
+{
+       unsigned int ampdu;
+
+       if (argc != 1)
+               return 1;
+
+       if (strcmp(argv[0], "on") == 0)
+               ampdu = 1;
+       else if (strcmp(argv[0], "off") == 0)
+               ampdu = 0;
+       else {
+               printf("Invalid parameter: %s\n", argv[0]);
+               return 2;
+       }
+
+       NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_AMPDU_ENABLED, ampdu);
+
+       return 0;
+
+ nla_put_failure:
+       return -ENOBUFS;
+}
+COMMAND(set, ampdu, "<on|off>",
+       NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_ampdu,
+       "Enable/disable AMPDU aggregation.");
+
+static int handle_amsdu(struct nl80211_state *state,
+                       struct nl_msg *msg,
+                       int argc, char **argv,
+                       enum id_input id)
+{
+       unsigned int amsdu;
+
+       if (argc != 1)
+               return 1;
+
+       if (strcmp(argv[0], "on") == 0)
+               amsdu = 1;
+       else if (strcmp(argv[0], "off") == 0)
+               amsdu = 0;
+       else {
+               printf("Invalid parameter: %s\n", argv[0]);
+               return 2;
+       }
+
+       NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_AMSDU_ENABLED, amsdu);
+
+       return 0;
+
+ nla_put_failure:
+       return -ENOBUFS;
+}
+COMMAND(set, amsdu, "<on|off>",
+       NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_amsdu,
+       "Enable/disable AMSDU aggregation.");
-- 
2.11.0

Reply via email to