Newer
Older
MAC2STR(node->almacaddr), MAC2STR(r->radio_el->macaddr));
continue;
}
cntlr_warn(LOG_CHANNEL, "acs node " MACFMT " " MACFMT " switch to best channel %d/%d ctrl %d mid %u\n",
MAC2STR(node->almacaddr), MAC2STR(r->radio_el->macaddr), acs_params.best_channel,
acs_params.best_bw, ctrl_channel, ret);
last_acs->mid = ret;
last_acs->status = ACS_RECALC_STATUS_BEST_REQUESTED;
timestamp_update(&last_acs->entry_time);
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
static void cntlr_radio_acs_timer(atimer_t *t)
{
struct acs *acs = container_of(t, struct acs, acs_timer);
struct netif_radio *r = acs->radio;
struct controller *c = acs->cntlr;
struct node *n = acs->node;
struct acs_params *last_acs;
last_acs = cntlr_radio_get_last_acs(r);
if (!last_acs)
return;
if (cntlr_acs_radio_is_bsta_connected(c, r)) {
cntlr_dbg(LOG_CHANNEL, "acs timer recalc (bsta connected) " MACFMT " " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
last_acs->status = ACS_RECALC_STATUS_BSTA_CONNECTED;
timestamp_update(&last_acs->entry_time);
return;
}
if (last_acs->recalc) {
cntlr_dbg(LOG_CHANNEL, "acs timer recalc (recalc already set) " MACFMT " " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
return;
}
if (c->cfg.acs_scan_before_recalc == false) {
cntlr_dbg(LOG_CHANNEL, "acs timer recalc node (don't scan) " MACFMT " " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
last_acs->scan_mid = 0xffff;
last_acs->recalc = true;
/* Send node preference request */
cntlr_acs_send_pref_request(n);
} else {
cntlr_dbg(LOG_CHANNEL, "acs timer recalc node (scan) " MACFMT " " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
/* Send scan request */
last_acs->recalc = true;
last_acs->scan_mid = cntlr_acs_send_scan_request(n, r);
if (last_acs->scan_mid != 0xffff) {
last_acs->status = ACS_RECALC_STATUS_SCAN_REQUESTED;
timestamp_update(&last_acs->entry_time);
}
}
}
void cntlr_acs_recalc(struct controller *c)
/* Handle main timer - prevent scan/switch at same time */
list_for_each_entry(n, &c->nodelist, list) {
struct netif_radio *r = NULL;
/* Run fresh scan before preference recalc */
list_for_each_entry(r, &n->radiolist, list) {
cntlr_dbg(LOG_CHANNEL, "acs setup recalc timer %u seconds " MACFMT " " MACFMT "\n",
delay, MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
/* In the future check more params - possible recalc postpond */
cntlr_radio_acs_timer_set(r, delay * 1000);
delay += 60;
}
static uint8_t cntlr_dfs_cac_method(uint32_t methods)
{
uint8_t cac_method = 0;
/* allow only bgcac methods */
if (methods & (1 << WIFI_CAC_MIMO_REDUCED))
cac_method = CAC_METHOD_MIMO_DIM_REDUCED;
else if (methods & (1 << WIFI_CAC_DEDICATED))
cac_method = CAC_METHOD_DEDICATED_RADIO;
else if (methods & (1 << WIFI_CAC_TIME_SLICED))
cac_method = CAC_METHOD_TIME_SLICED;
return cac_method;
}
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
static bool cntlr_dfs_cac_ongoing(struct wifi_radio_element *radio)
{
struct wifi_radio_opclass_entry *entry;
struct wifi_radio_opclass *opclass;
int i, j;
opclass = &radio->pref_opclass;
for (i = 0; i < opclass->num_opclass; i++) {
entry = &opclass->opclass[i];
for (j = 0; j < entry->num_channel; j++) {
if (entry->channel[j].dfs == WIFI_RADIO_OPCLASS_CHANNEL_DFS_CAC)
return true;
}
}
return false;
}
static bool cntlr_dfs_get_usable(struct wifi_radio_opclass_entry *entry, struct acs_cac_data *cac)
{
uint8_t reas;
int i;
for (i = 0; i < entry->num_channel; i++) {
reas = entry->channel[i].preference & CHANNEL_PREF_REASON;
if (reas != CHANNEL_PREF_REASON_DFS_USABLE)
continue;
/* Check if background CAC supported */
cac->data.cac_method = cntlr_dfs_cac_method(entry->channel[i].cac_methods);
if (!cac->data.cac_method)
cac->data.channel = entry->channel[i].channel;
cac->data.opclass = entry->id;
cac->cac_time = entry->channel[i].cac_time;
}
return false;
}
static bool cntlr_radio_is_ap_iface(struct netif_radio *radio)
list_for_each_entry(iface, &radio->iflist, list) {
/* Check if AP iface connected */
if (iface->bss->is_fbss)
if (iface->bss->is_bbss)
return true;
}
return false;
}
static bool cntlr_dfs_get_cac_data(struct wifi_radio_element *radio, struct acs_cac_data *cac, uint16_t bw)
struct wifi_radio_opclass_entry *entry;
struct wifi_radio_opclass *opclass;
uint32_t cur_bw = 0;
uint32_t cur_chan = 0;
if (!bw) {
cur_bw = ctrl_radio_cur_opclass_max_bw(radio);
cur_chan = ctrl_radio_cur_opclass_chan(radio);
} else {
cur_bw = bw;
cur_chan = 0;
}
if (!cur_bw)
return false;
for (i = 0; i < opclass->num_opclass; i++) {
entry = &opclass->opclass[i];
if (entry->bandwidth != cur_bw)
memcpy(cac->data.radio, radio->macaddr, sizeof(cac->data.radio));
return true;
}
return false;
}
void cntlr_dfs_radio_cleanup(struct node *node, struct netif_radio *radio)
{
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
struct acs_cac_data cac_data = {};
struct acs_cac_data *last_cac_data;
last_cac_data = cntlr_radio_get_last_cac(radio);
if (!last_cac_data)
return;
if (!radio->radio_el->pref_opclass.num_opclass ||
!radio->radio_el->cur_opclass.num_opclass) {
/* We don't know preferences and channels DFS state */
cntlr_dbg(LOG_CHANNEL, "dfs radio preCAC not yet " MACFMT "\n", MAC2STR(radio->radio_el->macaddr));
timestamp_update(&last_cac_data->entry_time);
last_cac_data->status = ACS_CLEANUP_STATUS_SKIPPED;
return;
}
if (!radio->radio_el->bgcac_supported) {
/* Some nodes don't even support it */
cntlr_dbg(LOG_CHANNEL, "dfs radio preCAC not supported " MACFMT "\n", MAC2STR(radio->radio_el->macaddr));
timestamp_update(&last_cac_data->entry_time);
last_cac_data->status = ACS_CLEANUP_STATUS_NOT_SUPPORTED;
return;
}
cntlr_dbg(LOG_CHANNEL, "dfs radio preCAC cleanup " MACFMT "\n", MAC2STR(radio->radio_el->macaddr));
if (!cntlr_radio_is_ap_iface(radio)) {
cntlr_dbg(LOG_CHANNEL, "dfs radio preCAC no AP ifaces, skip radio\n");
timestamp_update(&last_cac_data->entry_time);
last_cac_data->status = ACS_CLEANUP_STATUS_NO_APS;
/* So far keep it simple - don't start new CAC request if one ongoing */
if (cntlr_dfs_cac_ongoing(radio->radio_el)) {
/* Could be device run own background CAC */
cntlr_dbg(LOG_CHANNEL, "dfs radio CAC ongoing " MACFMT "\n", MAC2STR(radio->radio_el->macaddr));
timestamp_update(&last_cac_data->entry_time);
last_cac_data->status = ACS_CLEANUP_STATUS_ALREADY_ONGOING;
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
if (!cntlr_dfs_get_cac_data(radio->radio_el, &cac_data, 0)) {
/* First use current bandwidth for clearing. Finally switch to 20MHz for left channels */
cntlr_dbg(LOG_CHANNEL, "dfs radio preCAC cleanup no channels left check 20MHz\n");
if (!cntlr_dfs_get_cac_data(radio->radio_el, &cac_data, 20)) {
cntlr_dbg(LOG_CHANNEL, "dfs radio preCAC cleanup no channels left\n");
timestamp_update(&last_cac_data->entry_time);
last_cac_data->status = ACS_CLEANUP_STATUS_ALL_CLEAN;
return;
}
}
cntlr_warn(LOG_CHANNEL, "dfs node " MACFMT " radio " MACFMT " preCAC run chan %d opclass %d\n",
MAC2STR(node->almacaddr), MAC2STR(radio->radio_el->macaddr),
cac_data.data.channel, cac_data.data.opclass);
memcpy(last_cac_data, &cac_data, sizeof(*last_cac_data));
timestamp_update(&last_cac_data->entry_time);
last_cac_data->status = ACS_CLEANUP_STATUS_SELECTED;
cac_data.mid = cntlr_send_cac_req(node->cntlr, node->almacaddr, 1, &cac_data.data);
last_cac_data->mid = cac_data.mid;
if (cac_data.mid != 0xffff)
last_cac_data->status = ACS_CLEANUP_STATUS_REQUESTED;
}
void cntlr_dfs_node_cleanup(struct node *node)
{
cntlr_trace(LOG_CHANNEL, "dfs node preCAC cleanup " MACFMT "\n", MAC2STR(node->almacaddr));
list_for_each_entry(radio, &node->radiolist, list) {
if (radio->radio_el->band != BAND_5)
continue;
cntlr_dfs_radio_cleanup(node, radio);
}
}
void cntlr_dfs_cleanup(struct controller *c)
{
struct node *n = NULL;
list_for_each_entry(n, &c->nodelist, list) {
cntlr_dfs_node_cleanup(n);
}
}
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
/* CMDU callbacks we expect to receive from nodes */
void cntlr_acs_channel_sel_response(struct netif_radio *r, uint16_t mid, uint8_t status)
{
struct acs_params *acs;
cntlr_dbg(LOG_CHANNEL, "new channel selection response radio " MACFMT " mid %u status %u\n",
MAC2STR(r->radio_el->macaddr), mid, status);
acs = cntlr_radio_get_last_acs(r);
if (!acs)
return;
if (acs->status != ACS_RECALC_STATUS_BEST_REQUESTED)
return;
if (acs->mid != mid)
return;
if (status == 0)
acs->status = ACS_RECALC_STATUS_BEST_ACCEPTED;
else
acs->status = ACS_RECALC_STATUS_BEST_REJECTED;
timestamp_update(&acs->entry_time);
}
void cntlr_acs_oper_channel_report(struct netif_radio *r)
{
struct acs_params *acs;
struct wifi_radio_opclass_entry *entry;
struct wifi_radio_opclass *cur;
int i, j;
cntlr_dbg(LOG_CHANNEL, "new oper channel report radio " MACFMT " %u/%u\n",
MAC2STR(r->radio_el->macaddr),
ctrl_radio_cur_opclass_ctrl_chan(r->radio_el),
ctrl_radio_cur_opclass_max_bw(r->radio_el));
acs = cntlr_radio_get_last_acs(r);
if (!acs)
return;
if (acs->status != ACS_RECALC_STATUS_BEST_REQUESTED &&
acs->status != ACS_RECALC_STATUS_BEST_ACCEPTED)
return;
cur = &r->radio_el->cur_opclass;
for (i = 0; i < cur->num_opclass; i++) {
entry = &cur->opclass[i];
if (entry->bandwidth != acs->best_bw)
continue;
for (j = 0; j < entry->num_channel; j++) {
if (entry->channel[j].channel == acs->best_channel) {
acs->status = ACS_RECALC_STATUS_BEST_SET;
timestamp_update(&acs->entry_time);
return;
}
}
}
/* timeout check - worst case when continous CAC required */
if (timestamp_elapsed_sec(&acs->entry_time) > 30 + acs->best_cac_time) {
acs->status = ACS_RECALC_STATUS_BEST_SET_TIMEOUT;
timestamp_update(&acs->entry_time);
}
}
void cntlr_acs_cac_completion(struct netif_radio *r, uint8_t classid,
uint8_t channel, uint8_t status)
{
struct acs_params *acs;
struct acs_cac_data *cac;
cntlr_dbg(LOG_CHANNEL, "new cac completion radio " MACFMT " opclass %u channel %u status %u\n",
MAC2STR(r->radio_el->macaddr), classid, channel, status);
cac = cntlr_radio_get_last_cac(r);
if (!cac)
return;
acs = cntlr_radio_get_last_acs(r);
if (cac->status != ACS_CLEANUP_STATUS_REQUESTED)
return;
if (cac->data.channel != channel)
return;
if (cac->data.opclass != classid)
return;
switch (status) {
case CAC_COMP_REPORT_STATUS_SUCCESSFUL:
cac->status = ACS_CLEANUP_STATUS_DONE;
/* Kick ACS recalc - we have new available channel */
if (acs && acs->scan_mid == 0xffff)
cntlr_radio_acs_timer_set(r, 5 * 1000);
break;
case CAC_COMP_REPORT_STATUS_CAC_NOT_SUPPORTED:
case CAC_COMP_REPORT_STATUS_TOO_BUSY:
case CAC_COMP_REPORT_STATUS_NON_CONFORMANT:
case CAC_COMP_REPORT_STATUS_OTHER:
cac->status = ACS_CLEANUP_STATUS_REJECTED;
break;
case CAC_COMP_REPORT_STATUS_RADAR_DETECTED:
cac->status = ACS_CLEANUP_STATUS_RADAR;
break;
default:
break;
}
}
void cntlr_acs_channel_pref_report(struct node *n, struct netif_radio *r)
{
struct acs_params *acs;
struct acs_cac_data *cac;
cntlr_dbg(LOG_CHANNEL, "new pref report node " MACFMT " radio " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
cac = cntlr_radio_get_last_cac(r);
if (!cac)
return;
acs = cntlr_radio_get_last_acs(r);
if (!acs)
return;
/* ACS status update */
if (acs->status == ACS_RECALC_STATUS_BEST_REQUESTED ||
acs->status == ACS_RECALC_STATUS_BEST_ACCEPTED) {
struct wifi_radio_opclass_channel *chan;
chan = wifi_opclass_get_channel(&r->radio_el->pref_opclass,
acs->best_opclass,
acs->best_channel);
if (chan) {
switch (chan->dfs) {
case WIFI_RADIO_OPCLASS_CHANNEL_DFS_CAC:
acs->status = ACS_RECALC_STATUS_BEST_CAC;
timestamp_update(&acs->entry_time);
break;
case WIFI_RADIO_OPCLASS_CHANNEL_DFS_NOP:
acs->status = ACS_RECALC_STATUS_BEST_CAC_RADAR;
timestamp_update(&acs->entry_time);
break;
default:
break;
}
}
}
/* Background CAC status update */
if (cac->status == ACS_CLEANUP_STATUS_REQUESTED ||
cac->status == ACS_CLEANUP_STATUS_ACCEPTED ||
cac->status == ACS_CLEANUP_STATUS_TIMEOUT) {
struct wifi_radio_opclass_channel *chan;
chan = wifi_opclass_get_channel(&r->radio_el->pref_opclass,
cac->data.opclass,
cac->data.channel);
if (chan) {
switch (chan->dfs) {
case WIFI_RADIO_OPCLASS_CHANNEL_DFS_AVAILABLE:
cac->status = ACS_CLEANUP_STATUS_DONE;
break;
case WIFI_RADIO_OPCLASS_CHANNEL_DFS_CAC:
cac->status = ACS_CLEANUP_STATUS_ACCEPTED;
break;
case WIFI_RADIO_OPCLASS_CHANNEL_DFS_NOP:
cac->status = ACS_CLEANUP_STATUS_RADAR;
break;
case WIFI_RADIO_OPCLASS_CHANNEL_DFS_USABLE:
/* change CAC -> USABLE - abort possible */
if (cac->status == ACS_CLEANUP_STATUS_ACCEPTED)
cac->status = ACS_CLEANUP_STATUS_REJECTED;
if (timestamp_elapsed_sec(&cac->entry_time) > 30 + cac->cac_time)
cac->status = ACS_CLEANUP_STATUS_TIMEOUT;
break;
default:
break;
}
}
}
/* Kick CAC background clearing */
if (n->cntlr->cfg.dfs_cleanup &&
r->radio_el->band == BAND_5 &&
r->radio_el->bgcac_supported &&
cac->status != ACS_CLEANUP_STATUS_REQUESTED &&
cac->status != ACS_CLEANUP_STATUS_ACCEPTED) {
cntlr_dbg(LOG_CHANNEL, "kick dfs cleanup " MACFMT " radio " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
cntlr_dfs_radio_cleanup(n, r);
}
/* Kick ACS recalc code */
if (acs->recalc && n->cntlr->cfg.acs && acs->scan_mid == 0xffff) {
cntlr_dbg(LOG_CHANNEL, "kick acs reclac " MACFMT " radio " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
acs->recalc = false;
cntlr_acs_node_channel_recalc(n, r->radio_el->band, 0, 0,
n->cntlr->cfg.acs_skip_dfs,
n->cntlr->cfg.acs_prevent_cac,
n->cntlr->cfg.acs_highest_bandwidth);
}
}
static uint8_t ewma(uint8_t cur, uint8_t prev, uint8_t alpha)
{
uint8_t new;
if (alpha > 100)
alpha = 100;
new = (alpha * cur)/100 + ((100 - alpha) * prev) / 100;
return new;
}
static bool cntlr_acs_radio_add_and_check_metrics(struct netif_radio *r, uint8_t anpi, uint8_t obss)
{
struct acs_radio_metrics *m;
struct acs_radio_metrics_entry *last, *next;
m = cntlr_radio_get_metrics(r);
if (!m)
return false;
timestamp_update(&m->time);
m->anpi = ewma(anpi, m->anpi, 60);
m->obss = ewma(obss, m->obss, 60);
last = &m->entry[m->idx];
cntlr_trace(LOG_CHANNEL, "radio ewma metrics " MACFMT " anpi %u obss %u\n",
MAC2STR(r->radio_el->macaddr), m->anpi, m->obss);
/* Update ring buffer */
if (timestamp_invalid(&last->time)) {
timestamp_update(&last->time);
last->anpi = m->anpi;
last->obss = m->obss;
}
/* Save/check data to ring buffer each 300 seconds */
if (timestamp_elapsed_sec(&last->time) >= 300) {
m->idx++;
m->idx %= ARRAY_SIZE(m->entry);
next = &m->entry[m->idx];
timestamp_update(&next->time);
next->anpi = m->anpi;
next->obss = m->obss;
cntlr_dbg(LOG_CHANNEL, "metrics[%u] radio " MACFMT " anpi %u (%d) obss %u (%d)\n",
m->idx, MAC2STR(r->radio_el->macaddr), next->anpi,
next->anpi - last->anpi, next->obss, next->obss - last->obss);
/* If other BSS busy increase - worth to check it (100% == 255) */
if (next->obss - last->obss > 30)
return true;
/* If noise level worst - worth to check it (0.5 dBm) */
if (next->anpi - last->anpi > 20)
return true;
}
return false;
}
void cntlr_acs_radio_metrics(struct node *n, struct netif_radio *r,
uint8_t anpi, uint8_t obss)
{
struct acs_params *acs;
struct acs_cac_data *cac;
cntlr_trace(LOG_CHANNEL, "new radio metrics node " MACFMT " radio " MACFMT " anpi %u busy %u\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr), anpi, obss);
cac = cntlr_radio_get_last_cac(r);
if (!cac)
return;
acs = cntlr_radio_get_last_acs(r);
if (!acs)
return;
/* Kick CAC background clearing - check AP apears */
if (n->cntlr->cfg.dfs_cleanup &&
r->radio_el->band == BAND_5 &&
r->radio_el->bgcac_supported &&
cac->status == ACS_CLEANUP_STATUS_NO_APS &&
timestamp_elapsed_sec(&cac->entry_time) >= 30) {
cntlr_dbg(LOG_CHANNEL, "kick dfs cleanup (NO_APS before) " MACFMT " radio " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
cntlr_dfs_radio_cleanup(n, r);
}
if (!n->cntlr->cfg.acs)
return;
/* Store data for future use/compare */
if (!cntlr_acs_radio_add_and_check_metrics(r, anpi, obss))
return;
/* Smth changed in current channel noise/busy */
cntlr_dbg(LOG_CHANNEL, "issue ACS recalc due to metrics (request fresh pref) " MACFMT " radio " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
/* Trigger scan/pref_req and get fresh preference report */
cntlr_radio_acs_timer_set(r, 5 * 1000);
}
void cntlr_acs_scan_report(struct node *n, struct netif_radio *r, uint16_t mid)
{
struct acs_params *acs;
cntlr_dbg(LOG_CHANNEL, "new scan report node " MACFMT " radio " MACFMT " mid %u\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr), mid);
acs = cntlr_radio_get_last_acs(r);
if (!acs)
return;
if (!n->cntlr->cfg.acs)
return;
/* Scan done for this radio, safe to switch channel */
if (acs->recalc && acs->scan_mid != 0xffff) {
acs->status = ACS_RECALC_STATUS_SCAN_DONE;
timestamp_update(&acs->entry_time);
}
acs->scan_mid = 0xffff;
/* Request fresh preferences if required */
if (cntlr_node_pref_opclass_expired(n, 10) || acs->recalc)
/* Preference responose with new data will trigger actions */
cntlr_acs_send_pref_request(n);
}
void cntlr_acs_dev_supp_opclass(struct node *n, struct netif_radio *r)
{
cntlr_trace(LOG_CHANNEL, "new dev supp opclass " MACFMT " radio " MACFMT "\n",
MAC2STR(n->almacaddr), MAC2STR(r->radio_el->macaddr));
if (r->radio_el->pref_opclass.num_opclass == 0)
cntlr_acs_send_pref_request(n);
}