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

Function pipeline_learner_default_entry_add

dpdk/examples/pipeline/cli.c:1656–1703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1654}
1655
1656static int
1657pipeline_learner_default_entry_add(struct rte_swx_ctl_pipeline *p,
1658 const char *learner_name,
1659 FILE *file,
1660 uint32_t *file_line_number)
1661{
1662 char *line = NULL;
1663 uint32_t line_id = 0;
1664 int status = 0;
1665
1666 /* Buffer allocation. */
1667 line = malloc(MAX_LINE_SIZE);
1668 if (!line)
1669 return -ENOMEM;
1670
1671 /* File read. */
1672 for (line_id = 1; ; line_id++) {
1673 struct rte_swx_table_entry *entry;
1674 int is_blank_or_comment;
1675
1676 if (fgets(line, MAX_LINE_SIZE, file) == NULL)
1677 break;
1678
1679 entry = rte_swx_ctl_pipeline_learner_default_entry_read(p,
1680 learner_name,
1681 line,
1682 &is_blank_or_comment);
1683 if (!entry) {
1684 if (is_blank_or_comment)
1685 continue;
1686
1687 status = -EINVAL;
1688 goto error;
1689 }
1690
1691 status = rte_swx_ctl_pipeline_learner_default_entry_add(p,
1692 learner_name,
1693 entry);
1694 table_entry_free(entry);
1695 if (status)
1696 goto error;
1697 }
1698
1699error:
1700 *file_line_number = line_id;
1701 free(line);
1702 return status;
1703}
1704
1705static const char cmd_pipeline_learner_default_help[] =
1706"pipeline <pipeline_name> learner <learner_name> default <file_name>\n";

Callers 1

Calls 5

mallocFunction · 0.85
table_entry_freeFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected