diff --git a/modules/broadcom/wlctrl.c b/modules/broadcom/wlctrl.c index 8da1e18312b32cf93181eda80ea4d4537c024495..a917068238f749806b6f56c8c31820cd6fa0fe6d 100644 --- a/modules/broadcom/wlctrl.c +++ b/modules/broadcom/wlctrl.c @@ -588,25 +588,6 @@ int wl_ioctl_iface_get_assoc_info(const char *name, struct wifi_sta *sta) return 0; } -#ifndef LIBWIFI_USE_WL_IOCTL -static int wl_cli_get_noise(const char *name, int *noise) -{ - char buf[64] = {0}; - int val = 0; - int status; - - status = Cmd(buf, sizeof(buf), "wl -i %s noise", name); - - if (WARN_ON(status)) - return status; - - if (WARN_ON(sscanf(buf, "%d", &val) != 1)) - return -1; - - *noise = val; - return 0; -} - int bcmwl_radio_get_busy(const char *name, int *busy) { wl_chanim_stats_t param; @@ -639,45 +620,6 @@ int bcmwl_radio_get_busy(const char *name, int *busy) return 0; } -int bcmwl_radio_get_noise(const char *name, int *noise) -{ - uint32_t val = 0; - int ret; - struct wl_arg arg = { - .ifname = name, - .cmd = WLC_GET_PHY_NOISE, - .buf = &val, - .buflen = sizeof(val) - }; - - ret = wl_ioctl(&arg); - if (!ret) { - *noise = wl_swap_32(name, val); - return ret; - } - - libwifi_dbg("[%s] %s fallback to wl\n", name, __func__); - ret = wl_cli_get_noise(name, noise); - - return ret; -} - -static int bcmwl_get_country(const char *name, char *alpha2) -{ - char buf[256] = {0}; - int status; - - status = Cmd(buf, sizeof(buf), "wl -i %s country", name); - - if (WARN_ON(status)) - return status; - - if (WARN_ON(snprintf(alpha2, 3, "%s", buf) < 2)) - return -1; - - return 0; -} - int bcmwl_radio_get_countrylist(const char *name, char *cc, int *num) { char buf[WLC_IOCTL_MAXLEN] = { 0 }; @@ -725,86 +667,6 @@ int bcmwl_radio_get_countrylist(const char *name, char *cc, int *num) return ret; } - -int bcmwl_radio_get_country(const char *name, char *alpha2) -{ - char val[3]; - int ret; - struct wl_arg arg = { - .ifname = name, - .cmd = WLC_GET_COUNTRY, - .buf = &val, - .buflen = sizeof(val) - }; - - libwifi_dbg("[%s] %s called\n", name, __func__); - - ret = wl_ctl(&arg); - if (!ret) { - snprintf(alpha2, 3, "%s", val); - return ret; - } - - libwifi_dbg("[%s] %s fallback to wl\n", name, __func__); - ret = bcmwl_get_country(name, alpha2); - - return ret; -} - - -static int bcmwl_get_rssi(const char *name, int8_t *rssi) -{ - char buf[64] = {0}; - int status; - - status = Cmd(buf, sizeof(buf), "wl -i %s rssi", name); - if (WARN_ON(status)) - return status; - - if (WARN_ON(sscanf(buf, "%hhi", rssi) != 1)) - return -1; - - return 0; -} - -static int bcmwl_get_macaddr(const char *name, uint8_t *macaddr) -{ - char buf[512] = {0}; - int status; - - status = Cmd(buf, sizeof(buf), "wl -i %s cur_etheraddr", name); - if (WARN_ON(status)) - return status; - - status = sscanf(buf, "cur_etheraddr: %2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", - &macaddr[0], &macaddr[1], &macaddr[2], - &macaddr[3], &macaddr[4], &macaddr[5]); - - if (WARN_ON(status != 6)) - return -1; - - return 0; -} - -static int bcmwl_get_bssid(const char *name, uint8_t *bssid) -{ - char buf[512] = {0}; - int status; - - status = Cmd(buf, sizeof(buf), "wl -i %s bssid", name); - if (WARN_ON(status)) - return status; - - status = sscanf(buf, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", - &bssid[0], &bssid[1], &bssid[2], - &bssid[3], &bssid[4], &bssid[5]); - - if (WARN_ON(status != 6)) - return -1; - - return 0; -} - static const int * bcmwl_get_chans_from_line(const char *line) { const int *chans = NULL; @@ -845,209 +707,6 @@ static const int * bcmwl_get_chans_from_line(const char *line) return chans; } -static void bcmwl_radio_channels_update_preism(const char *ifname, struct chan_entry *channel, int num) -{ - char dfs_status[4096] = {0}; - const int *chans; - char *line; - char *ptr; - int i; - - if (WARN_ON(Cmd(dfs_status, sizeof(dfs_status), "wl -i %s dfs_ap_move", ifname))) - return; - - /* - * Check two lines of dfs_ap_move status: - * version=1, move status=3 - * AP Target Chanspec 36/160 (0xe832) - * Radar Scan Aborted - * version: 1, num_sub_status: 2 - * @0: state: PRE-ISM Channel Availability Check(CAC), time elapsed: 19050ms, chanspec: 100/80 (0xE06A), chanspec last cleared: none, sub type: 0x00 - * @1: state: IDLE, time elapsed: 0ms, chanspec: none, chanspec last cleared: none, sub type: 0x01 - */ - - ptr = dfs_status; - - while ((line = strsep(&ptr, "\r\n"))) { - if (!strstr(line, "@0") && !strstr(line, "@1")) - continue; - - if (!strstr(line, "PRE-ISM Channel Availability Check")) - continue; - - libwifi_dbg("line: %s\n", line); - chans = bcmwl_get_chans_from_line(line); - if (!chans) - continue; - while (*chans) { - libwifi_dbg("[%s] preism chan %d\n", ifname, *chans); - for (i = 0; i < num; i++) { - if (!channel[i].dfs) - continue; - if (channel[i].channel == *chans) - channel[i].dfs_state = WIFI_DFS_STATE_CAC; - } - chans++; - } - } -} - -int bcmwl_iface_chan_switch(const char *ifname, struct chan_switch_param *param) -{ - char buf[1024] = {0}; - char chanspec[128] = {0}; - enum wifi_band band; - int bandwidth; - int channel; - int count; - int status; - - libwifi_dbg("[%s] %s called\n", ifname, __func__); - - count = param->count; - channel = wifi_freq_to_channel(param->freq); - bandwidth = param->bandwidth; - band = wifi_freq_to_band(param->freq); - - if (band == BAND_6) - snprintf(chanspec, sizeof(chanspec), "6g%d/%d", channel, bandwidth); - else - snprintf(chanspec, sizeof(chanspec), "%d/%d", channel, bandwidth); - - if (bandwidth == 40 && channel <= 14 && band == BAND_2) { - switch (param->sec_chan_offset) { - case -1: - snprintf(chanspec, sizeof(chanspec), "%du", channel); - break; - case 1: - snprintf(chanspec, sizeof(chanspec), "%dl", channel); - break; - default: - break; - } - } - - if (band == BAND_5) { - /* Just in case, skip bgcac and allow CSA */ - Cmd(buf, sizeof(buf), "wl -i %s dfs_ap_move -1", ifname); - } - - status = Cmd(buf, sizeof(buf), "wl -i %s csa 0 %d %s", ifname, count, chanspec); - WARN_ON(status); - - libwifi_dbg("[%s] %s %s status %d\n", ifname, __func__, chanspec, status); - return status; -} - -static int bcmwl_get_macmode(const char *name, int *macmode) -{ - char buf[64] = {0}; - int val = 0; - int status; - - status = Cmd(buf, sizeof(buf), "wl -i %s macmode", name); - - if (WARN_ON(status)) - return status; - - if (WARN_ON(sscanf(buf, "%d", &val) != 1)) - return -1; - - *macmode = val; - return 0; -} - -static int bcmwl_set_macmode(const char *name, int macmode) -{ - int ret; - char buf[64] = {0}; - - ret = Cmd(buf, sizeof(buf), "wl -i %s macmode %d", - name, macmode); - - return ret; -} - -static int bcmwl_get_probresp_mac_filter(const char *name, bool *prmf) -{ - char buf[64] = {0}; - int ret, val = 0; - - ret = Cmd(buf, sizeof(buf), "wl -i %s probresp_mac_filter", name); - - if (WARN_ON(ret)) - return -1; - - if (WARN_ON(sscanf(buf, "%d", &val) != 1)) - return -1; - - *prmf = (val == 1) ? true : false; - - return ret; -} - -static int bcmwl_set_probresp_mac_filter(const char *name, bool prmf) -{ - int ret; - char buf[64] = {0}; - - ret = Cmd(buf, sizeof(buf), "wl -i %s probresp_mac_filter %d", - name, prmf ? 1 : 0); - - return ret; -} - -static int bcmwl_get_authresp_mac_filter(const char *name, bool *auth_filter) -{ - char buf[64] = {0}; - int ret, val = 0; - - ret = Cmd(buf, sizeof(buf), "wl -i %s authresp_mac_filter", name); - - if (WARN_ON(ret)) - return -1; - - if (WARN_ON(sscanf(buf, "%d", &val) != 1)) - return -1; - - *auth_filter = (val == 1) ? true : false; - - return ret; -} - -static int bcmwl_set_authresp_mac_filter(const char *name, bool auth_filter) -{ - int ret; - char buf[64] = {0}; - - ret = Cmd(buf, sizeof(buf), "wl -i %s authresp_mac_filter %d", - name, auth_filter ? 1 : 0); - - return ret; -} - -static int bcmwl_iface_is_maclist_empty(const char *name, bool *is_empty) -{ - int ret; - char buf[WLC_IOCTL_MAXLEN] = {0}; - - ret = Cmd(buf, sizeof(buf), "wl -i %s mac", name); - *is_empty = strlen(buf) ? false : true; - - return ret; -} - -static int bcmwl_iface_update_maclist(const char *name, uint8_t *sta, bool remove) -{ - int ret = 0; - char buf[64] = {0}; - - ret = Cmd(buf, sizeof(buf), "wl -i %s mac %s " MACSTR, name, - remove ? "del" : "", MAC2STR(sta)); - - return ret; -} - int bcmwl_radio_reset_chanim_stats(const char *name) { int ret = 0; @@ -1211,24 +870,6 @@ static int bcmwl_radio_channels_update_max_txpower(const char *name, struct chan return ret; } -static int bcmwl_get_cur_txpower(const char *name, int8_t *txpower) -{ - char buf[1024] = {}; - int8_t pwrA, pwrB; - uint32_t chanspec; - int ret; - - ret = Cmd(buf, sizeof(buf), "wl -i %s txpwr_target_max", name); - if (ret) - return -1; - - if (sscanf(buf, "Maximum Tx Power Target (chanspec:0x%x):\t%2hhd.%02hhd", &chanspec, &pwrA, &pwrB) != 3) - return -1; - - *txpower = pwrA; - return 0; -} -#else int bcmwl_radio_get_noise(const char *name, int *noise) { uint32_t val = 0; @@ -1785,7 +1426,6 @@ static int bcmwl_get_cur_txpower(const char *name, int8_t *txpower) *txpower = target_pwr.txpwr[0]/4; return 0; } -#endif static int wl_cli_get_chanspec(const char *name, chanspec_t *val) {