From patchwork Mon Feb 19 17:02:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 10228307 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33888602B7 for ; Mon, 19 Feb 2018 17:02:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F1312880B for ; Mon, 19 Feb 2018 17:02:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 119B528A85; Mon, 19 Feb 2018 17:02:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0A602880B for ; Mon, 19 Feb 2018 17:02:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753220AbeBSRCz (ORCPT ); Mon, 19 Feb 2018 12:02:55 -0500 Received: from mail.toke.dk ([52.28.52.200]:40035 "EHLO mail.toke.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753208AbeBSRCy (ORCPT ); Mon, 19 Feb 2018 12:02:54 -0500 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1519059772; bh=t7xcEaU9o9HU234ErDakiSw9v0I6kAlXl2P3ZLXnIwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qzkN3KKALce5uUnkiVxRfa1NGTe/Umhr2DFelmQy8e/A+D/6DkM5HP2axpuZwbhpB qYWUcPYGWqbAe2sOIiMk7HqIX1x/k9IxXyGN0Niz8PtLyv1lfkBJZ+fWoACXIvIqff jF1wJ6OZoMhkHam29luX1Y/2k9OFISEMFcSrTP19daVI28qjs99v0syzrzFEMXmJ1l gD6wxNZLR03JETZdMNwtdg2d1QjiDJpVvwoh7fRe5Ep/IaZpH7Ii2aBFa2I3TWEat+ u0XNAOI4eJ12nVrqk2FrW+7MaIi3PRELGsh8suz1EF1tchlIv4xn2kqdhT3coZC4Ic o7GW9n0U/kDlA== To: make-wifi-fast@lists.bufferbloat.net, linux-wireless@vger.kernel.org Cc: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Subject: [PATCH 3/3] iw: Add getting and setting of TXQ params for phy Date: Mon, 19 Feb 2018 18:02:24 +0100 Message-Id: <20180219170224.14816-4-toke@toke.dk> In-Reply-To: <20180219170224.14816-1-toke@toke.dk> References: <20180219170224.14816-1-toke@toke.dk> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds commands to get and set the per-phy TXQ parameters for drivers that use the intermediate TXQs. These are the settings and statistics that are also available through /sys/kernel/debug/ieee80211/phyX/aqm. Sample output: $ iw phy phy0 get txq Packet limit: 8192 pkts Memory limit: 4194304 bytes Quantum: 300 bytes Number of queues: 4096 Backlog: 12 pkts Memory usage: 52224 bytes Packet limit overflows: 0 Memory limit overflows: 0 Hash collisions: 1 # iw phy phy0 set txq limit 1024 # iw phy phy0 set txq memory_limit 1024000 # iw phy phy0 set txq quantum 1000 Signed-off-by: Toke Høiland-Jørgensen --- info.c | 3 ++ phy.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/info.c b/info.c index 1eba5c9..291cf24 100644 --- a/info.c +++ b/info.c @@ -609,6 +609,9 @@ broken_combination: if (ext_feature_isset(nla_data(tb), nla_len(tb), NL80211_EXT_FEATURE_VHT_IBSS)) printf("\tDevice supports VHT-IBSS.\n"); + if (ext_feature_isset(nla_data(tb), nla_len(tb), + NL80211_EXT_FEATURE_TXQS)) + printf("\tDriver supports FQ-CoDel-enabled intermediate TXQs.\n"); } if (tb_msg[NL80211_ATTR_TDLS_SUPPORT]) diff --git a/phy.c b/phy.c index be31820..77df7a7 100644 --- a/phy.c +++ b/phy.c @@ -727,3 +727,119 @@ COMMAND(set, antenna, " | all | ", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_antenna, "Set a bitmap of allowed antennas to use for TX and RX.\n" "The driver may reject antenna configurations it cannot support."); + +static int handle_set_txq(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + unsigned int argval; + char *end; + + if (argc != 2) + return 1; + + if (!*argv[0] || !*argv[1]) + return 1; + + argval = strtoul(argv[1], &end, 10); + + if (*end) + return 1; + + if (!argval) + return 1; + + if (strcmp("limit", argv[0]) == 0) + NLA_PUT_U32(msg, NL80211_ATTR_TXQ_LIMIT, argval); + else if (strcmp("memory_limit", argv[0]) == 0) + NLA_PUT_U32(msg, NL80211_ATTR_TXQ_MEMORY_LIMIT, argval); + else if (strcmp("quantum", argv[0]) == 0) + NLA_PUT_U32(msg, NL80211_ATTR_TXQ_QUANTUM, argval); + else + return -1; + + return 0; + nla_put_failure: + return -ENOBUFS; +} +COMMAND(set, txq, "limit | memory_limit | quantum ", + NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_set_txq, + "Set TXQ parameters. The limit and memory_limit are global queue limits\n" + "for the whole phy. The quantum is the DRR scheduler quantum setting.\n" + "Valid values: 1 - 2**32"); + +static int print_txq_handler(struct nl_msg *msg, void *arg) +{ + struct nlattr *attrs[NL80211_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *txqstats_info[NL80211_TXQ_STATS_MAX + 1], *txqinfo; + static struct nla_policy txqstats_policy[NL80211_TXQ_STATS_MAX + 1] = { + [NL80211_TXQ_STATS_BACKLOG_PACKETS] = { .type = NLA_U32 }, + [NL80211_TXQ_STATS_BACKLOG_BYTES] = { .type = NLA_U32 }, + [NL80211_TXQ_STATS_OVERLIMIT] = { .type = NLA_U32 }, + [NL80211_TXQ_STATS_OVERMEMORY] = { .type = NLA_U32 }, + [NL80211_TXQ_STATS_COLLISIONS] = { .type = NLA_U32 }, + [NL80211_TXQ_STATS_MAX_FLOWS] = { .type = NLA_U32 }, + }; + + nla_parse(attrs, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + + if (attrs[NL80211_ATTR_TXQ_LIMIT]) + printf("Packet limit:\t\t%u pkts\n", + nla_get_u32(attrs[NL80211_ATTR_TXQ_LIMIT])); + if (attrs[NL80211_ATTR_TXQ_MEMORY_LIMIT]) + printf("Memory limit:\t\t%u bytes\n", + nla_get_u32(attrs[NL80211_ATTR_TXQ_MEMORY_LIMIT])); + if (attrs[NL80211_ATTR_TXQ_QUANTUM]) + printf("Quantum:\t\t%u bytes\n", + nla_get_u32(attrs[NL80211_ATTR_TXQ_QUANTUM])); + + if (attrs[NL80211_ATTR_TXQ_STATS]) { + if (nla_parse_nested(txqstats_info, NL80211_TXQ_STATS_MAX, + attrs[NL80211_ATTR_TXQ_STATS], + txqstats_policy)) { + printf("failed to parse nested TXQ stats attributes!"); + return 0; + } + txqinfo = txqstats_info[NL80211_TXQ_STATS_MAX_FLOWS]; + if (txqinfo) + printf("Number of queues:\t%u\n", nla_get_u32(txqinfo)); + + txqinfo = txqstats_info[NL80211_TXQ_STATS_BACKLOG_PACKETS]; + if (txqinfo) + printf("Backlog:\t\t%u pkts\n", nla_get_u32(txqinfo)); + + txqinfo = txqstats_info[NL80211_TXQ_STATS_BACKLOG_BYTES]; + if (txqinfo) + printf("Memory usage:\t\t%u bytes\n", nla_get_u32(txqinfo)); + + txqinfo = txqstats_info[NL80211_TXQ_STATS_OVERLIMIT]; + if (txqinfo) + printf("Packet limit overflows:\t%u\n", nla_get_u32(txqinfo)); + + txqinfo = txqstats_info[NL80211_TXQ_STATS_OVERMEMORY]; + if (txqinfo) + printf("Memory limit overflows:\t%u\n", nla_get_u32(txqinfo)); + txqinfo = txqstats_info[NL80211_TXQ_STATS_COLLISIONS]; + if (txqinfo) + printf("Hash collisions:\t%u\n", nla_get_u32(txqinfo)); + } + return NL_SKIP; +} + +static int handle_get_txq(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP); + nlmsg_hdr(msg)->nlmsg_flags |= NLM_F_DUMP; + register_handler(print_txq_handler, NULL); + return 0; +} +COMMAND(get, txq, "", + NL80211_CMD_GET_WIPHY, 0, CIB_PHY, handle_get_txq, + "Get TXQ parameters.");