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

Function pipeline_table_rule_add_default

dpdk/examples/ip_pipeline/thread.c:1436–1532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1434}
1435
1436int
1437pipeline_table_rule_add_default(const char *pipeline_name,
1438 uint32_t table_id,
1439 struct table_rule_action *action)
1440{
1441 struct pipeline *p;
1442 struct table *table;
1443 struct pipeline_msg_req *req;
1444 struct pipeline_msg_rsp *rsp;
1445 struct table_rule *rule;
1446 int status;
1447
1448 /* Check input params */
1449 if ((pipeline_name == NULL) ||
1450 (action == NULL))
1451 return -1;
1452
1453 p = pipeline_find(pipeline_name);
1454 if ((p == NULL) ||
1455 (table_id >= p->n_tables) ||
1456 action_default_check(action, p, table_id))
1457 return -1;
1458
1459 table = &p->table[table_id];
1460
1461 rule = calloc(1, sizeof(struct table_rule));
1462 if (rule == NULL)
1463 return -1;
1464
1465 memcpy(&rule->action, action, sizeof(*action));
1466
1467 if (!pipeline_is_running(p)) {
1468 struct rte_pipeline_table_entry *data_in, *data_out;
1469 uint8_t *buffer;
1470
1471 buffer = calloc(TABLE_RULE_ACTION_SIZE_MAX, sizeof(uint8_t));
1472 if (buffer == NULL) {
1473 free(rule);
1474 return -1;
1475 }
1476
1477 /* Apply actions */
1478 data_in = (struct rte_pipeline_table_entry *)buffer;
1479
1480 data_in->action = action->fwd.action;
1481 if (action->fwd.action == RTE_PIPELINE_ACTION_PORT)
1482 data_in->port_id = action->fwd.id;
1483 if (action->fwd.action == RTE_PIPELINE_ACTION_TABLE)
1484 data_in->table_id = action->fwd.id;
1485
1486 /* Add default rule to table */
1487 status = rte_pipeline_table_default_entry_add(p->p,
1488 table_id,
1489 data_in,
1490 &data_out);
1491 if (status) {
1492 free(buffer);
1493 free(rule);

Callers 1

Calls 11

action_default_checkFunction · 0.85
callocFunction · 0.85
pipeline_is_runningFunction · 0.85
table_rule_default_addFunction · 0.85
pipeline_msg_allocFunction · 0.85
pipeline_msg_send_recvFunction · 0.85
pipeline_msg_freeFunction · 0.85
pipeline_findFunction · 0.70
memcpyFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected