mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-01 19:07:47 +00:00
WIFI-1807-Channel-Change
This patch will resolve the channel switching issue when there is a single SSID on each radio Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
This commit is contained in:
committed by
Rick Sommerville
parent
e5bc8c9550
commit
cc8e30e1d4
@@ -13,6 +13,7 @@ struct mode_map {
|
|||||||
char *ucihwmode;
|
char *ucihwmode;
|
||||||
char *htmode;
|
char *htmode;
|
||||||
char *ucihtmode;
|
char *ucihtmode;
|
||||||
|
int sec_channel_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct mode_map *mode_map_get_uci(const char *band, const char *htmode, const char *hwmode);
|
extern struct mode_map *mode_map_get_uci(const char *band, const char *htmode, const char *hwmode);
|
||||||
@@ -39,4 +40,5 @@ extern int iface_is_up(const char *ifname);
|
|||||||
extern int net_get_mtu(char *iface);
|
extern int net_get_mtu(char *iface);
|
||||||
extern int net_get_mac(char *iface, char *mac);
|
extern int net_get_mac(char *iface, char *mac);
|
||||||
extern int net_is_bridge(char *iface);
|
extern int net_is_bridge(char *iface);
|
||||||
|
extern char* get_max_channel_bw_channel(int channel_freq, const char* htmode);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -406,8 +406,9 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((changed->ht_mode) || (changed->hw_mode) || (changed->freq_band)) {
|
if ((changed->ht_mode) || (changed->hw_mode) || (changed->freq_band)) {
|
||||||
struct mode_map *m = mode_map_get_uci(rconf->freq_band, rconf->ht_mode,
|
int channel_freq;
|
||||||
rconf->hw_mode);
|
channel_freq = ieee80211_channel_to_frequency(rconf->channel);
|
||||||
|
struct mode_map *m = mode_map_get_uci(rconf->freq_band, get_max_channel_bw_channel(channel_freq, rconf->ht_mode), rconf->hw_mode);
|
||||||
if (m) {
|
if (m) {
|
||||||
blobmsg_add_string(&b, "htmode", m->ucihtmode);
|
blobmsg_add_string(&b, "htmode", m->ucihtmode);
|
||||||
blobmsg_add_string(&b, "hwmode", m->ucihwmode);
|
blobmsg_add_string(&b, "hwmode", m->ucihwmode);
|
||||||
|
|||||||
@@ -23,41 +23,79 @@
|
|||||||
#include "vif.h"
|
#include "vif.h"
|
||||||
|
|
||||||
static struct mode_map mode_map[] = {
|
static struct mode_map mode_map[] = {
|
||||||
{ 0, "11b", "11b", NULL, "NOHT" },
|
{ 0, "11b", "11b", NULL, "NOHT", 0 },
|
||||||
{ 0, "11g", "11g", NULL, "NOHT" },
|
{ 0, "11g", "11g", NULL, "NOHT", 0 },
|
||||||
{ 1, "11a", "11a", NULL, "NOHT" },
|
{ 1, "11a", "11a", NULL, "NOHT", 0 },
|
||||||
{ 0, "11n", "11g", "HT20", "HT20" },
|
{ 0, "11n", "11g", "HT20", "HT20", 0 },
|
||||||
{ 0, "11n", "11g", "HT40", "HT40" },
|
{ 0, "11n", "11g", "HT40", "HT40", 1 },
|
||||||
{ 0, "11n", "11g", "HT40-", "HT40-" },
|
{ 0, "11n", "11g", "HT40-", "HT40-", 1 },
|
||||||
{ 0, "11n", "11g", "HT40+", "HT40+" },
|
{ 0, "11n", "11g", "HT40+", "HT40+", 1 },
|
||||||
{ 0, "11n", "11g", "HT80", "HT40" },
|
{ 0, "11n", "11g", "HT80", "HT40", 1 },
|
||||||
{ 0, "11n", "11g", "HT160", "HT40" },
|
{ 0, "11n", "11g", "HT160", "HT40", 1 },
|
||||||
{ 1, "11n", "11a", "HT20", "HT20" },
|
{ 1, "11n", "11a", "HT20", "HT20", 0 },
|
||||||
{ 1, "11n", "11a", "HT40", "HT40" },
|
{ 1, "11n", "11a", "HT40", "HT40", 1 },
|
||||||
{ 1, "11n", "11a", "HT40-", "HT40-" },
|
{ 1, "11n", "11a", "HT40-", "HT40-", 1 },
|
||||||
{ 1, "11n", "11a", "HT40+", "HT40+" },
|
{ 1, "11n", "11a", "HT40+", "HT40+", 1 },
|
||||||
{ 1, "11n", "11a", "HT80", "HT40" },
|
{ 1, "11n", "11a", "HT80", "HT40", 1 },
|
||||||
{ 1, "11n", "11a", "HT160", "HT40" },
|
{ 1, "11n", "11a", "HT160", "HT40", 1 },
|
||||||
{ 1, "11ac", "11a", "HT20", "VHT20" },
|
{ 1, "11ac", "11a", "HT20", "VHT20", 0 },
|
||||||
{ 1, "11ac", "11a", "HT40", "VHT40" },
|
{ 1, "11ac", "11a", "HT40", "VHT40", 1 },
|
||||||
{ 1, "11ac", "11a", "HT40-", "VHT40" },
|
{ 1, "11ac", "11a", "HT40-", "VHT40", 1 },
|
||||||
{ 1, "11ac", "11a", "HT40+", "VHT40" },
|
{ 1, "11ac", "11a", "HT40+", "VHT40", 1 },
|
||||||
{ 1, "11ac", "11a", "HT80", "VHT80" },
|
{ 1, "11ac", "11a", "HT80", "VHT80", 1 },
|
||||||
{ 1, "11ac", "11a", "HT160", "VHT160" },
|
{ 1, "11ac", "11a", "HT160", "VHT160", 1 },
|
||||||
{ 0, "11ax", "11g", "HT20", "HE20" },
|
{ 0, "11ax", "11g", "HT20", "HE20", 0 },
|
||||||
{ 0, "11ax", "11g", "HT40", "HE40" },
|
{ 0, "11ax", "11g", "HT40", "HE40", 1 },
|
||||||
{ 0, "11ax", "11g", "HT40-", "HE40" },
|
{ 0, "11ax", "11g", "HT40-", "HE40", 1 },
|
||||||
{ 0, "11ax", "11g", "HT40+", "HE40" },
|
{ 0, "11ax", "11g", "HT40+", "HE40", 1 },
|
||||||
{ 0, "11ax", "11g", "HT80", "HE80" },
|
{ 0, "11ax", "11g", "HT80", "HE80", 1 },
|
||||||
{ 0, "11ax", "11g", "HT160", "HE80" },
|
{ 0, "11ax", "11g", "HT160", "HE80", 1 },
|
||||||
{ 1, "11ax", "11a", "HT20", "HE20" },
|
{ 1, "11ax", "11a", "HT20", "HE20", 0 },
|
||||||
{ 1, "11ax", "11a", "HT40", "HE40" },
|
{ 1, "11ax", "11a", "HT40", "HE40", 1 },
|
||||||
{ 1, "11ax", "11a", "HT40-", "HE40" },
|
{ 1, "11ax", "11a", "HT40-", "HE40", 1 },
|
||||||
{ 1, "11ax", "11a", "HT40+", "HE40" },
|
{ 1, "11ax", "11a", "HT40+", "HE40", 1 },
|
||||||
{ 1, "11ax", "11a", "HT80", "HE80" },
|
{ 1, "11ax", "11a", "HT80", "HE80", 1 },
|
||||||
{ 1, "11ax", "11a", "HT160", "HE160" },
|
{ 1, "11ax", "11a", "HT160", "HE160", 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MHz20=0,
|
||||||
|
MHz40 = 1,
|
||||||
|
MHz80 = 2,
|
||||||
|
MHz160 = 4
|
||||||
|
} bm_AllowedBw;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int freq;
|
||||||
|
bm_AllowedBw bw;
|
||||||
|
} freqBwListEntry;
|
||||||
|
|
||||||
|
freqBwListEntry freqBwList[] ={{2412, MHz20},{2417, MHz20},{2422, MHz20},{2427, MHz20},{2432, MHz20},{2437, MHz20},{2442, MHz20},{2447, MHz20},{2452, MHz20},{2457, MHz20},{2462, MHz20},{2467, MHz20},{2472, MHz20}, {2484, MHz20},
|
||||||
|
{ 5180, MHz20|MHz40|MHz80},{5200, MHz20},{5220, MHz20|MHz40},{5240, MHz20},{5260, MHz20|MHz40|MHz80},{5280, MHz20},{5300,MHz20|MHz40},{5320, MHz20},{5500, MHz20|MHz40|MHz80},{5520, MHz20},{5540, MHz20|MHz40}, {5560, MHz20},
|
||||||
|
{5580, MHz20|MHz40|MHz80},{5600, MHz20},{5620, MHz20|MHz40},{5640, MHz20},{5660, MHz20|MHz40|MHz80},{5680, MHz20},{5700, MHz20|MHz40},{5720, MHz20},{5745, MHz20|MHz40|MHz80},{5765, MHz20},{5785, MHz20|MHz40},{5805, MHz20},{5825, MHz20}};
|
||||||
|
|
||||||
|
#define REQ_BW(htmode) (!strcmp(htmode, "HT20") ? MHz20 : !strcmp(htmode, "HT40") ? MHz40 : !strcmp(htmode, "HT80") ? MHz80 : !strcmp(htmode, "HT160") ? MHz160 : MHz20)
|
||||||
|
#define REQ_MODE(bw) (bw==MHz20 ? "HT20": bw==MHz40 ? "HT40" : bw==MHz80 ? "HT80" : bw==MHz160 ? "HT160" : "HT20")
|
||||||
|
|
||||||
|
char * get_max_channel_bw_channel(int channel_freq, const char* htmode)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
bm_AllowedBw requestedBw;
|
||||||
|
|
||||||
|
requestedBw = REQ_BW(htmode);
|
||||||
|
|
||||||
|
for ( i = 0; i < ARRAY_SIZE(freqBwList); i++) {
|
||||||
|
if(freqBwList[i].freq == channel_freq) {
|
||||||
|
while (requestedBw) {
|
||||||
|
if (freqBwList[i].bw & requestedBw) {
|
||||||
|
return REQ_MODE(requestedBw);
|
||||||
|
}
|
||||||
|
requestedBw >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "HT20";
|
||||||
|
}
|
||||||
struct mode_map *mode_map_get_uci(const char *band, const char *htmode, const char *hwmode)
|
struct mode_map *mode_map_get_uci(const char *band, const char *htmode, const char *hwmode)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ int rrm_setup_monitor(void);
|
|||||||
void rrm_channel_init(void);
|
void rrm_channel_init(void);
|
||||||
int rrm_ubus_init(struct ev_loop *loop);
|
int rrm_ubus_init(struct ev_loop *loop);
|
||||||
int ubus_get_noise(const char *if_name, uint32_t *noise);
|
int ubus_get_noise(const char *if_name, uint32_t *noise);
|
||||||
int ubus_set_channel_switch(const char *if_name, uint32_t frequency);
|
int ubus_set_channel_switch(const char *if_name, uint32_t frequency, int channel_bandwidth, int sec_chan_offset);
|
||||||
void set_rrm_parameters(rrm_entry_t *rrm_data);
|
void set_rrm_parameters(rrm_entry_t *rrm_data);
|
||||||
ds_tree_t* rrm_get_rrm_config_list(void);
|
ds_tree_t* rrm_get_rrm_config_list(void);
|
||||||
ds_tree_t* rrm_get_radio_list(void);
|
ds_tree_t* rrm_get_radio_list(void);
|
||||||
|
|||||||
@@ -94,6 +94,15 @@ radio_entry_t* rrm_get_radio_config(radio_type_t band)
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
void get_channel_bandwidth(const char* htmode, int *channel_bandwidth)
|
||||||
|
{
|
||||||
|
if(!strcmp(htmode, "HT20"))
|
||||||
|
*channel_bandwidth=20;
|
||||||
|
else if (!strcmp(htmode, "HT40"))
|
||||||
|
*channel_bandwidth=40;
|
||||||
|
else if(!strcmp(htmode, "HT80"))
|
||||||
|
*channel_bandwidth=80;
|
||||||
|
}
|
||||||
|
|
||||||
void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
|
void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
|
||||||
{
|
{
|
||||||
@@ -161,9 +170,19 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
|
|||||||
rrm_config->rrm_data.noise_lwm,
|
rrm_config->rrm_data.noise_lwm,
|
||||||
rrm_config->rrm_data.snr_percentage_drop,
|
rrm_config->rrm_data.snr_percentage_drop,
|
||||||
nf_drop_threshold);
|
nf_drop_threshold);
|
||||||
|
int channel_bandwidth;
|
||||||
|
int sec_chan_offset=0;
|
||||||
|
struct mode_map *m = mode_map_get_uci(radio->schema.freq_band, get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel),
|
||||||
|
radio->schema.ht_mode), radio->schema.hw_mode);
|
||||||
|
if (m) {
|
||||||
|
sec_chan_offset = m->sec_channel_offset;
|
||||||
|
} else
|
||||||
|
LOGE("failed to get channel offset");
|
||||||
|
|
||||||
|
get_channel_bandwidth(get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel),
|
||||||
|
radio->schema.ht_mode), &channel_bandwidth);
|
||||||
ubus_set_channel_switch(radio->config.if_name,
|
ubus_set_channel_switch(radio->config.if_name,
|
||||||
ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel));
|
ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), channel_bandwidth, sec_chan_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ int ubus_get_noise(const char *if_name, uint32_t *noise)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ubus_set_channel_switch(const char *if_name, uint32_t frequency)
|
int ubus_set_channel_switch(const char *if_name, uint32_t frequency, int channel_bandwidth, int sec_chan_offset)
|
||||||
{
|
{
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
static struct blob_buf b;
|
static struct blob_buf b;
|
||||||
@@ -61,10 +61,21 @@ int ubus_set_channel_switch(const char *if_name, uint32_t frequency)
|
|||||||
|
|
||||||
if (ubus_lookup_id(ubus, path, &id))
|
if (ubus_lookup_id(ubus, path, &id))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
|
if (channel_bandwidth == 20 || channel_bandwidth == 40) {
|
||||||
|
blobmsg_add_bool(&b, "ht", 1);
|
||||||
|
} else if (channel_bandwidth == 80) {
|
||||||
|
blobmsg_add_bool(&b, "vht", 1);
|
||||||
|
}
|
||||||
|
if (channel_bandwidth == 40 || channel_bandwidth == 80) {
|
||||||
|
blobmsg_add_u32(&b, "center_freq1", frequency+30);
|
||||||
|
}
|
||||||
|
|
||||||
blobmsg_add_u32(&b, "freq", frequency);
|
blobmsg_add_u32(&b, "freq", frequency);
|
||||||
blobmsg_add_u32(&b, "bcn_count", 1);
|
blobmsg_add_u32(&b, "bcn_count", 1);
|
||||||
|
blobmsg_add_u32(&b, "bandwidth", channel_bandwidth);
|
||||||
|
blobmsg_add_u32(&b, "sec_channel_offset", sec_chan_offset);
|
||||||
return ubus_invoke(ubus, id, "switch_chan", b.head, NULL, NULL, 1000);
|
return ubus_invoke(ubus, id, "switch_chan", b.head, NULL, NULL, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user