From 1743d26e7ed6553aefa440903afe08294773142b Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Sun, 15 Oct 2017 15:21:25 +0000 Subject: Set default join preferences to prefer APs based on the RSSI, with a boost set to prefer 5GHz APs. --- sys/dev/ic/bwfm.c | 18 ++++++++++++++++-- sys/dev/ic/bwfmreg.h | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) (limited to 'sys/dev/ic') diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c index 69f2cc7d2dc..4bc84abb19e 100644 --- a/sys/dev/ic/bwfm.c +++ b/sys/dev/ic/bwfm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfm.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ +/* $OpenBSD: bwfm.c,v 1.2 2017/10/15 15:21:24 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -254,13 +254,27 @@ bwfm_init(struct ifnet *ifp) struct ieee80211com *ic = &sc->sc_ic; uint8_t evmask[BWFM_EVENT_MASK_LEN]; struct bwfm_ext_join_params *params; + struct bwfm_join_pref_params join_pref[2]; if (bwfm_fwvar_var_set_int(sc, "mpc", 1)) { printf("%s: could not set mpc\n", DEVNAME(sc)); return; } - /* TODO: joinpref defaults */ + /* Select target by RSSI (boost on 5GHz) */ + join_pref[0].type = BWFM_JOIN_PREF_RSSI_DELTA; + join_pref[0].len = 2; + join_pref[0].rssi_gain = BWFM_JOIN_PREF_RSSI_BOOST; + join_pref[0].band = BWFM_JOIN_PREF_BAND_5G; + join_pref[1].type = BWFM_JOIN_PREF_RSSI; + join_pref[1].len = 2; + join_pref[1].rssi_gain = 0; + join_pref[1].band = 0; + if (bwfm_fwvar_var_set_data(sc, "join_pref", join_pref, + sizeof(join_pref))) { + printf("%s: could not set join pref\n", DEVNAME(sc)); + return; + } if (bwfm_fwvar_var_get_data(sc, "event_msgs", evmask, sizeof(evmask))) { printf("%s: could not get event mask\n", DEVNAME(sc)); diff --git a/sys/dev/ic/bwfmreg.h b/sys/dev/ic/bwfmreg.h index 6ff9b745ce2..74fd3f73728 100644 --- a/sys/dev/ic/bwfmreg.h +++ b/sys/dev/ic/bwfmreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfmreg.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ +/* $OpenBSD: bwfmreg.h,v 1.2 2017/10/15 15:21:24 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -313,6 +313,22 @@ struct bwfm_assoc_params { uint16_t chanspec_list[]; } __packed; +struct bwfm_join_pref_params { + uint8_t type; +#define BWFM_JOIN_PREF_RSSI 1 +#define BWFM_JOIN_PREF_WPA 2 +#define BWFM_JOIN_PREF_BAND 3 +#define BWFM_JOIN_PREF_RSSI_DELTA 4 + uint8_t len; + uint8_t rssi_gain; +#define BWFM_JOIN_PREF_RSSI_BOOST 8 + uint8_t band; +#define BWFM_JOIN_PREF_BAND_AUTO 0 +#define BWFM_JOIN_PREF_BAND_5G 1 +#define BWFM_JOIN_PREF_BAND_2G 2 +#define BWFM_JOIN_PREF_BAND_ALL 3 +} __packed; + struct bwfm_join_params { struct bwfm_ssid ssid; struct bwfm_assoc_params assoc; -- cgit v1.2.3