From 6720b9482f523f7385c6eaef9c27361d30a9c954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Date: Wed, 20 Mar 2019 15:58:52 +0100 Subject: [PATCH] nl80211: Station airtime weight configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This provides a mechanism for configuring per-STA airtime weight for airtime policy configuration. Signed-off-by: Toke Høiland-Jørgensen --- src/ap/ap_drv_ops.c | 10 ++++++++++ src/ap/ap_drv_ops.h | 2 ++ src/drivers/driver.h | 10 ++++++++++ src/drivers/driver_nl80211.c | 22 ++++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index 067cf863e..61390f93d 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -583,6 +583,16 @@ int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr, } +int hostapd_sta_set_airtime_weight(struct hostapd_data *hapd, const u8 *addr, + unsigned int weight) +{ + if (!hapd->driver || !hapd->driver->sta_set_airtime_weight) + return 0; + return hapd->driver->sta_set_airtime_weight(hapd->drv_priv, addr, + weight); +} + + int hostapd_set_country(struct hostapd_data *hapd, const char *country) { if (hapd->driver == NULL || diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index de40171e1..5905be053 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -67,6 +67,8 @@ int hostapd_set_rts(struct hostapd_data *hapd, int rts); int hostapd_set_frag(struct hostapd_data *hapd, int frag); int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr, int total_flags, int flags_or, int flags_and); +int hostapd_sta_set_airtime_weight(struct hostapd_data *hapd, const u8 *addr, + unsigned int weight); int hostapd_set_country(struct hostapd_data *hapd, const char *country); int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs, int cw_min, int cw_max, int burst_time); diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 351622afc..496bd522e 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2947,6 +2947,16 @@ struct wpa_driver_ops { unsigned int total_flags, unsigned int flags_or, unsigned int flags_and); + /** + * sta_set_airtime_weight - Set station airtime weight (AP only) + * @priv: Private driver interface data + * @addr: Station address + * @weight: New weight for station airtime assignment + * Returns: 0 on success, -1 on failure + */ + int (*sta_set_airtime_weight)(void *priv, const u8 *addr, + unsigned int weight); + /** * set_tx_queue_params - Set TX queue parameters * @priv: Private driver interface data diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 090f74ecc..3556b6d69 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -5183,6 +5183,28 @@ fail: } +static int driver_nl80211_sta_set_airtime_weight(void *priv, const u8 *addr, + unsigned int weight) +{ + struct i802_bss *bss = priv; + struct nl_msg *msg; + + wpa_printf(MSG_DEBUG, + "nl80211: Set STA airtime weight - ifname=%s addr=" MACSTR + " weight=%u", bss->ifname, MAC2STR(addr), weight); + + if (!(msg = nl80211_bss_msg(bss, 0, NL80211_CMD_SET_STATION)) || + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) || + nla_put_u16(msg, NL80211_ATTR_AIRTIME_WEIGHT, weight)) + goto fail; + + return send_and_recv_msgs(bss->drv, msg, NULL, NULL); +fail: + nlmsg_free(msg); + return -ENOBUFS; +} + + static int wpa_driver_nl80211_ap(struct wpa_driver_nl80211_data *drv, struct wpa_driver_associate_params *params) {