MCPcopy Create free account
hub / github.com/F-Stack/f-stack / acl_build_tries

Function acl_build_tries

dpdk/lib/acl/acl_bld.c:1344–1417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1342}
1343
1344static int
1345acl_build_tries(struct acl_build_context *context,
1346 struct rte_acl_build_rule *head)
1347{
1348 uint32_t n, num_tries;
1349 struct rte_acl_config *config;
1350 struct rte_acl_build_rule *last;
1351 struct rte_acl_build_rule *rule_sets[RTE_ACL_MAX_TRIES];
1352
1353 config = head->config;
1354 rule_sets[0] = head;
1355
1356 /* initialize tries */
1357 for (n = 0; n < RTE_DIM(context->tries); n++) {
1358 context->tries[n].type = RTE_ACL_UNUSED_TRIE;
1359 context->bld_tries[n].trie = NULL;
1360 context->tries[n].count = 0;
1361 }
1362
1363 context->tries[0].type = RTE_ACL_FULL_TRIE;
1364
1365 /* calc wildness of each field of each rule */
1366 acl_calc_wildness(head, config);
1367
1368 for (n = 0;; n = num_tries) {
1369
1370 num_tries = n + 1;
1371
1372 last = build_one_trie(context, rule_sets, n, context->node_max);
1373 if (context->bld_tries[n].trie == NULL) {
1374 RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n);
1375 return -ENOMEM;
1376 }
1377
1378 /* Build of the last trie completed. */
1379 if (last == NULL)
1380 break;
1381
1382 if (num_tries == RTE_DIM(context->tries)) {
1383 RTE_LOG(ERR, ACL,
1384 "Exceeded max number of tries: %u\n",
1385 num_tries);
1386 return -ENOMEM;
1387 }
1388
1389 /* Trie is getting too big, split remaining rule set. */
1390 rule_sets[num_tries] = last->next;
1391 last->next = NULL;
1392 acl_free_node(context, context->bld_tries[n].trie);
1393
1394 /* Create a new copy of config for remaining rules. */
1395 config = acl_build_alloc(context, 1, sizeof(*config));
1396 memcpy(config, rule_sets[n]->config, sizeof(*config));
1397
1398 /* Make remaining rules use new config. */
1399 for (head = rule_sets[num_tries]; head != NULL;
1400 head = head->next)
1401 head->config = config;

Callers 1

acl_bldFunction · 0.85

Calls 5

acl_calc_wildnessFunction · 0.85
build_one_trieFunction · 0.85
acl_free_nodeFunction · 0.85
acl_build_allocFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected