| 1434 | } |
| 1435 | |
| 1436 | int |
| 1437 | pipeline_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); |
no test coverage detected