Skip to content
Snippets Groups Projects
Commit e6dbe8a6 authored by Filip Matusiak's avatar Filip Matusiak
Browse files

Utilize mac-addresses hashtable for object lookup

parent f5709fd5
No related branches found
No related tags found
No related merge requests found
Pipeline #99373 passed
......@@ -57,21 +57,15 @@
extern bool waitext;
/* find interface by macaddress - no radio argument */
struct netif_iface *find_interface_by_mac_nor(struct controller *c,
uint8_t *hwaddr)
/* deprecated */
struct netif_iface *_find_interface_by_mac(struct controller *c,
struct netif_radio *r, uint8_t *hwaddr)
{
struct netif_iface *p = NULL; /* fh anf bk iface */
struct netif_radio *r = NULL;
struct node *n = NULL;
struct netif_iface *p = NULL;
list_for_each_entry(n, &c->nodelist, list) {
list_for_each_entry(r, &n->radiolist, list) {
list_for_each_entry(p, &r->iflist, list) {
if (!memcmp(p->bss->bssid, hwaddr, 6))
return p;
}
}
list_for_each_entry(p, &r->iflist, list) {
if (!memcmp(p->bss->bssid, hwaddr, 6))
return p;
}
return NULL;
......@@ -81,14 +75,15 @@ struct netif_iface *find_interface_by_mac_nor(struct controller *c,
struct netif_iface *find_interface_by_mac(struct controller *c,
struct netif_radio *r, uint8_t *hwaddr)
{
struct netif_iface *p = NULL;
struct map_macaddr_entry *entry = NULL;
list_for_each_entry(p, &r->iflist, list) {
if (!memcmp(p->bss->bssid, hwaddr, 6))
return p;
}
entry = allmac_lookup(&c->mac_table, hwaddr, MAC_ENTRY_FBSS);
return NULL;
if (WARN_ON(!entry))
/* fall back to old find - TODO: deprecate */
return _find_interface_by_mac(c, r, hwaddr);
return (struct netif_iface*)entry->data;
}
/* find radio by ssid, node known */
......@@ -144,8 +139,8 @@ struct netif_iface *find_interface_by_ssid(struct controller *c,
return NULL;
}
/* find radio by node */
struct netif_radio *find_radio_by_node(struct controller *c, struct node *n,
/* deprecated */
struct netif_radio *_find_radio_by_node(struct controller *c, struct node *n,
uint8_t *radio_mac)
{
struct netif_radio *p = NULL;
......@@ -158,8 +153,23 @@ struct netif_radio *find_radio_by_node(struct controller *c, struct node *n,
return NULL;
}
/* find radio by macaddress, search all nodes */
struct netif_radio *find_radio_by_mac(struct controller *c, uint8_t *mac)
/* find radio by node */
struct netif_radio *find_radio_by_node(struct controller *c, struct node *n,
uint8_t *radio_mac)
{
struct map_macaddr_entry *entry = NULL;
entry = allmac_lookup(&c->mac_table, radio_mac, MAC_ENTRY_RADIO);
if (WARN_ON(!entry))
/* fall back to old find - TODO: deprecate */
return _find_radio_by_node(c, n, radio_mac);
return (struct netif_radio*)entry->data;
}
/* deprecated */
struct netif_radio *_find_radio_by_mac(struct controller *c, uint8_t *mac)
{
struct node *n = NULL;
struct netif_radio *r = NULL;
......@@ -173,6 +183,20 @@ struct netif_radio *find_radio_by_mac(struct controller *c, uint8_t *mac)
return NULL;
}
/* find radio by macaddress, search all nodes */
struct netif_radio *find_radio_by_mac(struct controller *c, uint8_t *mac)
{
struct map_macaddr_entry *entry = NULL;
entry = allmac_lookup(&c->mac_table, mac, MAC_ENTRY_RADIO);
if (WARN_ON(!entry))
/* fall back to old find - TODO: deprecate */
return _find_radio_by_mac(c, mac);
return (struct netif_radio*)entry->data;
}
/* finds radio struct from interface macaddr */
struct netif_radio *find_radio_by_bssid(struct controller *c, uint8_t *bssid)
{
......@@ -206,8 +230,8 @@ struct netif_link *find_link_by_mac(struct controller *c, uint8_t *upstream, uin
return NULL;
}
/* find node by macaddress */
struct node *cntlr_find_node(struct controller *c, uint8_t *almac)
/* deprecated */
struct node *_cntlr_find_node(struct controller *c, uint8_t *almac)
{
struct node *n = NULL;
......@@ -219,8 +243,22 @@ struct node *cntlr_find_node(struct controller *c, uint8_t *almac)
return NULL;
}
/* find sta by macaddress */
struct sta *cntlr_find_sta(struct controller *c, uint8_t *mac)
/* find node by macaddress */
struct node *cntlr_find_node(struct controller *c, uint8_t *mac)
{
struct map_macaddr_entry *entry = NULL;
entry = allmac_lookup(&c->mac_table, mac, MAC_ENTRY_ALID);
if (WARN_ON(!entry))
/* fall back to old find - TODO: deprecate */
return _cntlr_find_node(c, mac);
return (struct node*)entry->data;
}
/* deprecated */
struct sta *_cntlr_find_sta(struct controller *c, uint8_t *mac)
{
struct sta *s = NULL;
......@@ -232,6 +270,20 @@ struct sta *cntlr_find_sta(struct controller *c, uint8_t *mac)
return NULL;
}
/* find sta by macaddress */
struct sta *cntlr_find_sta(struct controller *c, uint8_t *mac)
{
struct map_macaddr_entry *entry = NULL;
entry = allmac_lookup(&c->mac_table, mac, MAC_ENTRY_ALID);
if (WARN_ON(!entry))
/* fall back to old find - TODO: deprecate */
return _cntlr_find_sta(c, mac);
return (struct sta*)entry->data;
}
struct bcnreq *cntlr_find_bcnreq(struct controller *c, uint8_t *sta, uint8_t *alid)
{
struct bcnreq *br = NULL;
......@@ -246,23 +298,8 @@ struct bcnreq *cntlr_find_bcnreq(struct controller *c, uint8_t *sta, uint8_t *al
return NULL;
}
#if 0
/* find node by macaddress */
struct netif_iface *cntlr_get_fbss_by_mac(struct controller *c, struct node *n,
uint8_t *mac)
{
struct netif_iface *p;
list_for_each_entry(p, &n->iflist, list) {
if (!memcmp(p->bss->bssid, mac, 6))
return p;
}
return NULL;
}
#endif
/* find fbss based on macaddr */
struct netif_iface *cntlr_iterate_fbss(struct controller *c, uint8_t *mac)
/* deprecated */
struct netif_iface *_cntlr_iterate_fbss(struct controller *c, uint8_t *mac)
{
struct node *n = NULL;
struct netif_radio *r = NULL;
......@@ -280,6 +317,20 @@ struct netif_iface *cntlr_iterate_fbss(struct controller *c, uint8_t *mac)
return NULL;
}
/* find fbss based on macaddr */
struct netif_iface *cntlr_iterate_fbss(struct controller *c, uint8_t *mac)
{
struct map_macaddr_entry *entry = NULL;
entry = allmac_lookup(&c->mac_table, mac, MAC_ENTRY_FBSS);
if (WARN_ON(!entry))
/* fall back to old find - TODO: deprecate */
return _cntlr_iterate_fbss(c, mac);
return (struct netif_iface*)entry->data;
}
/* find node based on bssid */
struct node *cntlr_find_node_by_iface(struct controller *c, uint8_t *bssid)
{
......@@ -1200,8 +1251,7 @@ void cntlr_clean_bcnreqlist(struct controller *c)
free(b);
}
}
void cntlr_clean_linklist(struct controller *c)
void node_clean_linklist(struct controller *c)
{
struct netif_link *l = NULL, *tmp;
......@@ -1327,11 +1377,11 @@ struct netif_link *alloc_link_init(struct controller *c,
if (!l->metrics)
goto out;
l->upstream = find_interface_by_mac_nor(c, upstream);
l->upstream = cntlr_iterate_fbss(c, upstream);
if (!l->upstream)
goto out_metrics;
l->downstream = find_interface_by_mac_nor(c, downstream);
l->downstream = cntlr_iterate_fbss(c, downstream);
if (!l->downstream)
goto out_metrics;
......@@ -2093,7 +2143,7 @@ out_exit:
cntlr_clean_mac_hashtable(c);
cntlr_clean_stalist(c);
cntlr_clean_bcnreqlist(c);
cntlr_clean_linklist(c);
node_clean_linklist(c);
cntlr_clean_nodelist(c);
ubus_unregister_event_handler(ctx, &c->evh);
cntlr_remove_object(c);
......
......@@ -397,8 +397,6 @@ struct steer_control_config *get_steer_control_config(struct controller *c);
struct sta *cntlr_add_sta(struct controller *c, uint8_t *macaddr);
struct sta *cntlr_find_sta(struct controller *c, uint8_t *mac);
struct bcnreq *cntlr_find_bcnreq(struct controller *c, uint8_t *sta, uint8_t *alid);
struct netif_iface *cntlr_get_fbss_by_mac(struct controller *c, struct node *n,
uint8_t *mac);
bool cntlr_resync_config(struct controller *c, bool reload);
int cntlr_radio_clean_scanlist_el(struct wifi_scanres_element *el);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment