From patchwork Mon Feb 11 17:04:34 2019 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: 10806367 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-2.web.codeaurora.org (Postfix) with ESMTP id 674AE6C2 for ; Mon, 11 Feb 2019 17:04:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 521492A473 for ; Mon, 11 Feb 2019 17:04:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 461EC2A528; Mon, 11 Feb 2019 17:04:39 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 7F7EE2A473 for ; Mon, 11 Feb 2019 17:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729806AbfBKREh (ORCPT ); Mon, 11 Feb 2019 12:04:37 -0500 Received: from mail.toke.dk ([52.28.52.200]:39217 "EHLO mail.toke.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728106AbfBKREg (ORCPT ); Mon, 11 Feb 2019 12:04:36 -0500 Subject: [PATCH 1/3] iw: Add command to set airtime weight DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1549904674; bh=sxwTZCTFZvn0qpe9FpwDc9n7OJoBbdRCnW+i3x5MFZA=; h=Subject:From:To:Date:From; b=vBQJmP41guX2YDAOmZp35IvMM70ewKq71FXIf9lhCsAZGoHz83EezSBqzh8EqFKB+ a4oOZNoPc/fGS9OmIWA4ZA0miE3P+eyr9SOmHC6nT3FocCbMuShT3ro//VnHae5uiq ULROwtCiZ/TWSXPN9+6MaGtp6cqYIx/8b4MytrqK0BWAXFXcLjLwrPT9cZKx28OkEG l4Ihw0/+vxRhSBaflqBoCyOlTQAsF5dWYW2t5gr5zpIVmveTRYxr2OfnooMyv/1t2o bR5ZReBI1GkstcFE4BXTwYUlNbw+uvo9sOaAXaY5Dw4YzQjP2g0zm9JpXSpu9um2W5 J3x7iB+37nWfw== From: Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rgensen?= To: linux-wireless@vger.kernel.org Date: Mon, 11 Feb 2019 18:04:34 +0100 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <154990467406.6770.8841156470323507480.stgit@alrua-x1> 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 a new iw command to set the airtime weight for a station, support for which was recently introduced into mac80211. Signed-off-by: Toke Høiland-Jørgensen --- station.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/station.c b/station.c index e1477ef..536120c 100644 --- a/station.c +++ b/station.c @@ -651,6 +651,7 @@ COMMAND(station, del, " [subtype ] [reason-code ]", static const struct cmd *station_set_plink; static const struct cmd *station_set_vlan; static const struct cmd *station_set_mesh_power_mode; +static const struct cmd *station_set_airtime_weight; static const struct cmd *select_station_cmd(int argc, char **argv) { @@ -662,6 +663,8 @@ static const struct cmd *select_station_cmd(int argc, char **argv) return station_set_vlan; if (strcmp(argv[1], "mesh_power_mode") == 0) return station_set_mesh_power_mode; + if (strcmp(argv[1], "airtime_weight") == 0) + return station_set_airtime_weight; return NULL; } @@ -813,6 +816,54 @@ COMMAND_ALIAS(station, set, " mesh_power_mode " "Set link-specific mesh power mode for this station", select_station_cmd, station_set_mesh_power_mode); +static int handle_station_set_airtime_weight(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + unsigned char mac_addr[ETH_ALEN]; + unsigned long airtime_weight = 0; + char *err = NULL; + + if (argc < 3) + return 1; + + if (mac_addr_a2n(mac_addr, argv[0])) { + fprintf(stderr, "invalid mac address\n"); + return 2; + } + argc--; + argv++; + + if (strcmp("airtime_weight", argv[0]) != 0) + return 1; + argc--; + argv++; + + airtime_weight = strtoul(argv[0], &err, 0); + if (err && *err) { + fprintf(stderr, "invalid airtime weight\n"); + return 2; + } + argc--; + argv++; + + if (argc) + return 1; + + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); + NLA_PUT_U16(msg, NL80211_ATTR_AIRTIME_WEIGHT, airtime_weight); + + return 0; + nla_put_failure: + return -ENOBUFS; + +} +COMMAND_ALIAS(station, set, " airtime_weight ", + NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_airtime_weight, + "Set airtime weight for this station.", + select_station_cmd, station_set_airtime_weight); + static int handle_station_dump(struct nl80211_state *state, struct nl_msg *msg, int argc, char **argv,