diff --git a/src/cntlr.c b/src/cntlr.c index 000a8c34cdd37c9a225e0332c76cecb464522300..ef8938df5cdcb440ff606ddbd8c37b567a64aeef 100644 --- a/src/cntlr.c +++ b/src/cntlr.c @@ -53,6 +53,7 @@ #include "utils/utils.h" #include "wifi_dataelements.h" #include "wifi_opclass.h" +#include "steer.h" #define map_plugin "ieee1905.map" @@ -1471,6 +1472,26 @@ static void cntlr_dfs_cleanup_run(atimer_t *t) timer_set(&c->dfs_cleanup, c->cfg.dfs_cleanup_timeout * 1000); } +static void cntlr_steer_sched_run(atimer_t *t) +{ + struct controller *c = container_of(t, struct controller, steer_sched_timer); + int i; + + cntlr_dbg(LOG_STEER, "%s: --->\n", __func__); + + for (i = 0; i < c->inform_sta_num; i++) { + struct sta *s = cntlr_find_sta(c->sta_table, &c->inform_stalist[i * 6]); + + if (!s) + continue; + + if (c->cfg.steer.enable_sta_steer && !s->is_bsta) + cntlr_inform_steer_modules(c, s, c->inform_cmdu_type); + else if (c->cfg.steer.enable_bsta_steer && s->is_bsta) + cntlr_inform_bsteer_modules(c, s, c->inform_cmdu_type); + } +} + static void cntlr_start(atimer_t *t) { struct controller *c = container_of(t, struct controller, start_timer); @@ -1859,6 +1880,7 @@ void run_controller(void *opts) timer_init(&c->query_nodes, cntlr_query_nodes); timer_init(&c->acs, cntlr_acs_run); timer_init(&c->dfs_cleanup, cntlr_dfs_cleanup_run); + timer_init(&c->steer_sched_timer, cntlr_steer_sched_run); timer_set(&c->heartbeat, 1 * 1000); timer_set(&c->start_timer, waitext ? 5 * 1000 : 0); diff --git a/src/cntlr.h b/src/cntlr.h index 5e787f747b5a2d9266ef8560d8a68678bf7c9523..58139fdc2176b41903c19196d4f05bbfafaa2a7b 100644 --- a/src/cntlr.h +++ b/src/cntlr.h @@ -326,6 +326,12 @@ struct controller { void *subscriber; bool subscribed; +#define INFORM_STA_MAXNUM 64 + atimer_t steer_sched_timer; + uint16_t inform_cmdu_type; + uint32_t inform_sta_num; + uint8_t inform_stalist[INFORM_STA_MAXNUM * 6]; + struct list_head sclist; /* struct steer_control list */ #if (EASYMESH_VERSION > 2) diff --git a/src/cntlr_map.c b/src/cntlr_map.c index 7b56e9e8c2d265af14800299951111ad93205b04..a2a83d41eb691f661ed180e8040f97bc7654fe8c 100644 --- a/src/cntlr_map.c +++ b/src/cntlr_map.c @@ -292,10 +292,11 @@ inform_steer_plugins: if (s) { cntlr_update_sta_steer_data(c, s); - if (c->cfg.steer.enable_sta_steer && !s->is_bsta) - cntlr_inform_steer_modules(c, s, CMDU_TYPE_TOPOLOGY_NOTIFICATION); - else if (c->cfg.steer.enable_bsta_steer && s->is_bsta) - cntlr_inform_bsteer_modules(c, s, CMDU_TYPE_TOPOLOGY_NOTIFICATION); + c->inform_cmdu_type = CMDU_TYPE_TOPOLOGY_NOTIFICATION; + c->inform_sta_num = 1; + memset(c->inform_stalist, 0, sizeof(c->inform_stalist)); + memcpy(c->inform_stalist, s->macaddr, 6); + timer_set(&c->steer_sched_timer, 0); } return 0; @@ -2458,8 +2459,7 @@ int handle_link_metrics_response(struct controller *c, struct cmdu_buff *cmdu, int handle_sta_link_metrics_response(void *cntlr, struct cmdu_buff *cmdu, struct node *n) { -#define INFORM_STA_MAXNUM 64 - struct sta *inform_stalist[INFORM_STA_MAXNUM] = {0}; + uint8_t inform_stalist[INFORM_STA_MAXNUM * 6] = {0}; struct controller *c = (struct controller *)cntlr; struct tlv *tv[ASSOC_STA_LINK_METRICS_RESP_NUM_OF_TLV_TYPES][TLV_MAXNUM] = { 0 }; int offset = 0; @@ -2521,7 +2521,7 @@ int handle_sta_link_metrics_response(void *cntlr, struct cmdu_buff *cmdu, } if (iidx < INFORM_STA_MAXNUM - 1) - inform_stalist[iidx++] = s; + memcpy(&inform_stalist[6 * iidx++], s->de_sta->macaddr, 6); } idx = 0; @@ -2574,16 +2574,12 @@ int handle_sta_link_metrics_response(void *cntlr, struct cmdu_buff *cmdu, * * For now, inform steer plugins about the STAs. */ - for (i = 0; i < iidx; i++) { - struct sta *s = inform_stalist[i]; + c->inform_cmdu_type = CMDU_ASSOC_STA_LINK_METRICS_RESPONSE; + c->inform_sta_num = iidx; + memset(c->inform_stalist, 0, sizeof(c->inform_stalist)); + memcpy(c->inform_stalist, inform_stalist, iidx * 6); - sta_link_metrics_process(s); - - if (c->cfg.steer.enable_sta_steer && !s->is_bsta) - cntlr_inform_steer_modules(c, s, CMDU_ASSOC_STA_LINK_METRICS_RESPONSE); - else if (c->cfg.steer.enable_bsta_steer && s->is_bsta) - cntlr_inform_bsteer_modules(c, s, CMDU_ASSOC_STA_LINK_METRICS_RESPONSE); - } + timer_set(&c->steer_sched_timer, 0); return 0; } @@ -2610,8 +2606,7 @@ int handle_unassoc_sta_link_metrics_response(void *cntlr, struct cmdu_buff *cmdu, struct node *n) { -#define INFORM_STA_MAXNUM 64 - struct sta *inform_stalist[INFORM_STA_MAXNUM] = {0}; + uint8_t inform_stalist[INFORM_STA_MAXNUM * 6] = {0}; struct controller *c = (struct controller *) cntlr; struct tlv *tv[UNASTA_LINK_METRICS_RESP_NUM_OF_TLV_TYPES][TLV_MAXNUM] = {0}; int iidx = 0; @@ -2706,20 +2701,19 @@ int handle_unassoc_sta_link_metrics_response(void *cntlr, u->ul_rcpi); if (iidx < INFORM_STA_MAXNUM - 1) - inform_stalist[iidx++] = s; + memcpy(&inform_stalist[6 * iidx++], s->de_sta->macaddr, 6); offset += sizeof(*b); } } - for (i = 0; i < iidx; i++) { - struct sta *s = inform_stalist[i]; + /* inform steer plugins of the responses */ + c->inform_cmdu_type = CMDU_UNASSOC_STA_LINK_METRIC_RESPONSE; + c->inform_sta_num = iidx; + memset(c->inform_stalist, 0, sizeof(c->inform_stalist)); + memcpy(c->inform_stalist, inform_stalist, iidx * 6); - if (!s->is_bsta) - cntlr_inform_steer_modules(c, s, CMDU_UNASSOC_STA_LINK_METRIC_RESPONSE); - else - cntlr_inform_bsteer_modules(c, s, CMDU_UNASSOC_STA_LINK_METRIC_RESPONSE); - } + timer_set(&c->steer_sched_timer, 0); return 0; } @@ -2845,10 +2839,13 @@ int handle_beacon_metrics_response(void *cntlr, struct cmdu_buff *cmdu, ppos = ppos + elem->tag_length + 2; } - if (!s->is_bsta) - cntlr_inform_steer_modules(c, s, CMDU_BEACON_METRICS_RESPONSE); - else - cntlr_inform_bsteer_modules(c, s, CMDU_BEACON_METRICS_RESPONSE); + /* inform steer plugins of the responses */ + c->inform_cmdu_type = CMDU_BEACON_METRICS_RESPONSE; + c->inform_sta_num = 1; + memset(c->inform_stalist, 0, sizeof(c->inform_stalist)); + memcpy(c->inform_stalist, s->de_sta->macaddr, 6); + + timer_set(&c->steer_sched_timer, 0); //ret = cntlr_notify_plugins(c, cmdu); @@ -2936,10 +2933,12 @@ int handle_sta_steer_btm_report(void *cntlr, struct cmdu_buff *cmdu, } /* Inform steering plugins */ - if (c->cfg.steer.enable_sta_steer && !s->is_bsta) - cntlr_inform_steer_modules(c, s, CMDU_CLIENT_STEERING_BTM_REPORT); - else if (c->cfg.steer.enable_bsta_steer && s->is_bsta) - cntlr_inform_bsteer_modules(c, s, CMDU_CLIENT_STEERING_BTM_REPORT); + c->inform_cmdu_type = CMDU_CLIENT_STEERING_BTM_REPORT; + c->inform_sta_num = 1; + memset(c->inform_stalist, 0, sizeof(c->inform_stalist)); + memcpy(c->inform_stalist, s->de_sta->macaddr, 6); + + timer_set(&c->steer_sched_timer, 0); return 0; }