From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.toke.dk (mail.toke.dk [52.28.52.200]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 28DA23CB35 for ; Tue, 8 May 2018 07:22:14 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1525778532; bh=rP3E8RKvbF5EyDqax9WRAMXbco16lv7ztUUFU+J91Zs=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=nqzacdXooC9W2gP0a47l8zw2nlVRNYYQLG6XX0aYiNXyqUb0ITZQc0uwcHixcQ7ON XM9XdOMIeit+Fp6w1OYiTpcHtwq6QDTtUoaNzFzG13c8Tk6VJAEbMWt7h7SiLtprjW kb751yi9F0dJMY54rktUHIs4YdKePuIJsAbcHfMviKvxaep8wazehWEknPPHCG0OfK NhzkxzT0kboCdP/lOmc3AVxTK0nqSKKGw21cj363YDyFTW9q6E/fXr4DAxlB9ip2tB TiGI078/0ZT2+bDSNeQqomRweFsTaIwJxyCsDTRaoxDAawLicGGzAFFz7i97CEGyWu 6w4//vzGEBRCQ== From: Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rgensen?= To: linux-wireless@vger.kernel.org Cc: make-wifi-fast@lists.bufferbloat.net Date: Tue, 08 May 2018 13:22:11 +0200 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <152577853191.32130.8121936914570715577.stgit@alrua-kau> In-Reply-To: <152577853186.32130.16532617444736581736.stgit@alrua-kau> References: <152577853186.32130.16532617444736581736.stgit@alrua-kau> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: [Make-wifi-fast] [PATCH v2 2/2] iw: Add getting and setting of TXQ params for phy X-BeenThere: make-wifi-fast@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2018 11:22:14 -0000 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 Signed-off-by: Toke Høiland-Jørgensen --- info.c | 2 + phy.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/info.c b/info.c index be68571..fbf3ee0 100644 --- a/info.c +++ b/info.c @@ -686,6 +686,8 @@ broken_combination: ext_feat_print(tb, NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211, "CONTROL_PORT_OVER_NL80211", "control port over nl80211"); + ext_feat_print(tb, NL80211_EXT_FEATURE_TXQS, + "TXQS", "FQ-CoDel-enabled intermediate TXQs"); } if (tb_msg[NL80211_ATTR_COALESCE_RULE]) { 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.");