Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/115520/?format=api
https://patches.dpdk.org/api/patches/115520/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220826131737.1741743-14-cristian.dumitrescu@intel.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20220826131737.1741743-14-cristian.dumitrescu@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20220826131737.1741743-14-cristian.dumitrescu@intel.com", "date": "2022-08-26T13:17:29", "name": "[V2,13/21] net/softnic: add pipeline table CLI commands", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "f36e423b0deabe26b9a69a3583f112f005105d45", "submitter": { "id": 19, "url": "https://patches.dpdk.org/api/people/19/?format=api", "name": "Cristian Dumitrescu", "email": "cristian.dumitrescu@intel.com" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20220826131737.1741743-14-cristian.dumitrescu@intel.com/mbox/", "series": [ { "id": 24429, "url": "https://patches.dpdk.org/api/series/24429/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=24429", "date": "2022-08-26T13:17:16", "name": "net/softnic: replace the legacy pipeline with SWX pipeline", "version": 2, "mbox": "https://patches.dpdk.org/series/24429/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/115520/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/115520/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 17CCCA0550;\n\tFri, 26 Aug 2022 15:19:50 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 4221942B9D;\n\tFri, 26 Aug 2022 15:18:18 +0200 (CEST)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by mails.dpdk.org (Postfix) with ESMTP id 05F7D427F4\n for <dev@dpdk.org>; Fri, 26 Aug 2022 15:18:01 +0200 (CEST)", "from orsmga002.jf.intel.com ([10.7.209.21])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 26 Aug 2022 06:17:51 -0700", "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com.) ([10.237.223.157])\n by orsmga002.jf.intel.com with ESMTP; 26 Aug 2022 06:17:50 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1661519882; x=1693055882;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=MHsu06n+SRjpMnPChVfcPAD46ZEC+V5pjHGYQ8bcxZs=;\n b=hL1UfpPXkmY4XYnmpTr6qRp4ak/NsjdueKfLFwrJExU0hJZbCL3tedid\n N0mqJxtsxcM3Hl/RpO1iZMQPycmaSFMEL0MN9svZ5Zq6fbu80CgEl0TSA\n GONrc+qhhdW3P8iXecqY4qr0DuRgz32ss2PpQWf8VdCj5W3q3NSL+ex5/\n OVQpKjD4VPFK7EtrHYHd7yvGDu+F5B+llp+iH4Lr+0pY1gpIq9MwF4OXk\n KP4edtUrJ383e/2M1lfzeSjNBr4/4sxouSdyucobXaOhvLgfJZa/j2Qx8\n iP/kghNtTDCzozKe4Ad4CMrbK5/0o8F5p5nIWMBW7hDGB7k7IawhlGeyf w==;", "X-IronPort-AV": [ "E=McAfee;i=\"6500,9779,10450\"; a=\"320598597\"", "E=Sophos;i=\"5.93,265,1654585200\"; d=\"scan'208\";a=\"320598597\"", "E=Sophos;i=\"5.93,265,1654585200\"; d=\"scan'208\";a=\"610561649\"" ], "X-ExtLoop1": "1", "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>", "To": "dev@dpdk.org", "Cc": "Yogesh Jangra <yogesh.jangra@intel.com>", "Subject": "[PATCH V2 13/21] net/softnic: add pipeline table CLI commands", "Date": "Fri, 26 Aug 2022 13:17:29 +0000", "Message-Id": "<20220826131737.1741743-14-cristian.dumitrescu@intel.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220826131737.1741743-1-cristian.dumitrescu@intel.com>", "References": "<20220804165839.1074817-1-cristian.dumitrescu@intel.com>\n <20220826131737.1741743-1-cristian.dumitrescu@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "Add CLI commands for pipeline table entry management.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\nSigned-off-by: Yogesh Jangra <yogesh.jangra@intel.com>\n---\n drivers/net/softnic/rte_eth_softnic_cli.c | 370 ++++++++++++++++++++++\n 1 file changed, 370 insertions(+)", "diff": "diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c\nindex cf71aa7b96..4443b62009 100644\n--- a/drivers/net/softnic/rte_eth_softnic_cli.c\n+++ b/drivers/net/softnic/rte_eth_softnic_cli.c\n@@ -426,6 +426,354 @@ cmd_softnic_pipeline_build(struct pmd_internals *softnic,\n \t\tsnprintf(out, out_size, \"Pipeline creation failed.\\n\");\n }\n \n+static void\n+table_entry_free(struct rte_swx_table_entry *entry)\n+{\n+\tif (!entry)\n+\t\treturn;\n+\n+\tfree(entry->key);\n+\tfree(entry->key_mask);\n+\tfree(entry->action_data);\n+\tfree(entry);\n+}\n+\n+static int\n+pipeline_table_entries_add(struct rte_swx_ctl_pipeline *p,\n+\t\t\t const char *table_name,\n+\t\t\t FILE *file,\n+\t\t\t uint32_t *file_line_number)\n+{\n+\tchar *line = NULL;\n+\tuint32_t line_id = 0;\n+\tint status = 0;\n+\n+\t/* Buffer allocation. */\n+\tline = malloc(MAX_LINE_SIZE);\n+\tif (!line)\n+\t\treturn -ENOMEM;\n+\n+\t/* File read. */\n+\tfor (line_id = 1; ; line_id++) {\n+\t\tstruct rte_swx_table_entry *entry;\n+\t\tint is_blank_or_comment;\n+\n+\t\tif (fgets(line, MAX_LINE_SIZE, file) == NULL)\n+\t\t\tbreak;\n+\n+\t\tentry = rte_swx_ctl_pipeline_table_entry_read(p,\n+\t\t\t\t\t\t\t table_name,\n+\t\t\t\t\t\t\t line,\n+\t\t\t\t\t\t\t &is_blank_or_comment);\n+\t\tif (!entry) {\n+\t\t\tif (is_blank_or_comment)\n+\t\t\t\tcontinue;\n+\n+\t\t\tstatus = -EINVAL;\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\tstatus = rte_swx_ctl_pipeline_table_entry_add(p,\n+\t\t\t\t\t\t\t table_name,\n+\t\t\t\t\t\t\t entry);\n+\t\ttable_entry_free(entry);\n+\t\tif (status)\n+\t\t\tgoto error;\n+\t}\n+\n+error:\n+\tfree(line);\n+\t*file_line_number = line_id;\n+\treturn status;\n+}\n+\n+/**\n+ * pipeline <pipeline_name> table <table_name> add <file_name>\n+ */\n+static void\n+cmd_softnic_pipeline_table_add(struct pmd_internals *softnic,\n+\tchar **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size)\n+{\n+\tstruct pipeline *p;\n+\tchar *pipeline_name, *table_name, *file_name;\n+\tFILE *file = NULL;\n+\tuint32_t file_line_number = 0;\n+\tint status;\n+\n+\tif (n_tokens != 6) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tpipeline_name = tokens[1];\n+\tp = softnic_pipeline_find(softnic, pipeline_name);\n+\tif (!p) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\ttable_name = tokens[3];\n+\n+\tfile_name = tokens[5];\n+\tfile = fopen(file_name, \"r\");\n+\tif (!file) {\n+\t\tsnprintf(out, out_size, \"Cannot open file %s.\\n\", file_name);\n+\t\treturn;\n+\t}\n+\n+\tstatus = pipeline_table_entries_add(p->ctl,\n+\t\t\t\t\t table_name,\n+\t\t\t\t\t file,\n+\t\t\t\t\t &file_line_number);\n+\tif (status)\n+\t\tsnprintf(out, out_size, \"Invalid entry in file %s at line %u\\n\",\n+\t\t\t file_name,\n+\t\t\t file_line_number);\n+\n+\tfclose(file);\n+}\n+\n+static int\n+pipeline_table_entries_delete(struct rte_swx_ctl_pipeline *p,\n+\t\t\t const char *table_name,\n+\t\t\t FILE *file,\n+\t\t\t uint32_t *file_line_number)\n+{\n+\tchar *line = NULL;\n+\tuint32_t line_id = 0;\n+\tint status = 0;\n+\n+\t/* Buffer allocation. */\n+\tline = malloc(MAX_LINE_SIZE);\n+\tif (!line)\n+\t\treturn -ENOMEM;\n+\n+\t/* File read. */\n+\tfor (line_id = 1; ; line_id++) {\n+\t\tstruct rte_swx_table_entry *entry;\n+\t\tint is_blank_or_comment;\n+\n+\t\tif (fgets(line, MAX_LINE_SIZE, file) == NULL)\n+\t\t\tbreak;\n+\n+\t\tentry = rte_swx_ctl_pipeline_table_entry_read(p,\n+\t\t\t\t\t\t\t table_name,\n+\t\t\t\t\t\t\t line,\n+\t\t\t\t\t\t\t &is_blank_or_comment);\n+\t\tif (!entry) {\n+\t\t\tif (is_blank_or_comment)\n+\t\t\t\tcontinue;\n+\n+\t\t\tstatus = -EINVAL;\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\tstatus = rte_swx_ctl_pipeline_table_entry_delete(p,\n+\t\t\t\t\t\t\t\t table_name,\n+\t\t\t\t\t\t\t\t entry);\n+\t\ttable_entry_free(entry);\n+\t\tif (status)\n+\t\t\tgoto error;\n+\t}\n+\n+error:\n+\t*file_line_number = line_id;\n+\tfree(line);\n+\treturn status;\n+}\n+\n+/**\n+ * pipeline <pipeline_name> table <table_name> delete <file_name>\n+ */\n+static void\n+cmd_softnic_pipeline_table_delete(struct pmd_internals *softnic,\n+\tchar **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size)\n+{\n+\tstruct pipeline *p;\n+\tchar *pipeline_name, *table_name, *file_name;\n+\tFILE *file = NULL;\n+\tuint32_t file_line_number = 0;\n+\tint status;\n+\n+\tif (n_tokens != 6) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tpipeline_name = tokens[1];\n+\tp = softnic_pipeline_find(softnic, pipeline_name);\n+\tif (!p) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\ttable_name = tokens[3];\n+\n+\tfile_name = tokens[5];\n+\tfile = fopen(file_name, \"r\");\n+\tif (!file) {\n+\t\tsnprintf(out, out_size, \"Cannot open file %s.\\n\", file_name);\n+\t\treturn;\n+\t}\n+\n+\tstatus = pipeline_table_entries_delete(p->ctl,\n+\t\t\t\t\t table_name,\n+\t\t\t\t\t file,\n+\t\t\t\t\t &file_line_number);\n+\tif (status)\n+\t\tsnprintf(out, out_size, \"Invalid entry in file %s at line %u\\n\",\n+\t\t\t file_name,\n+\t\t\t file_line_number);\n+\n+\tfclose(file);\n+}\n+\n+static int\n+pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *p,\n+\t\t\t\t const char *table_name,\n+\t\t\t\t FILE *file,\n+\t\t\t\t uint32_t *file_line_number)\n+{\n+\tchar *line = NULL;\n+\tuint32_t line_id = 0;\n+\tint status = 0;\n+\n+\t/* Buffer allocation. */\n+\tline = malloc(MAX_LINE_SIZE);\n+\tif (!line)\n+\t\treturn -ENOMEM;\n+\n+\t/* File read. */\n+\tfor (line_id = 1; ; line_id++) {\n+\t\tstruct rte_swx_table_entry *entry;\n+\t\tint is_blank_or_comment;\n+\n+\t\tif (fgets(line, MAX_LINE_SIZE, file) == NULL)\n+\t\t\tbreak;\n+\n+\t\tentry = rte_swx_ctl_pipeline_table_entry_read(p,\n+\t\t\t\t\t\t\t table_name,\n+\t\t\t\t\t\t\t line,\n+\t\t\t\t\t\t\t &is_blank_or_comment);\n+\t\tif (!entry) {\n+\t\t\tif (is_blank_or_comment)\n+\t\t\t\tcontinue;\n+\n+\t\t\tstatus = -EINVAL;\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\tstatus = rte_swx_ctl_pipeline_table_default_entry_add(p,\n+\t\t\t\t\t\t\t\t table_name,\n+\t\t\t\t\t\t\t\t entry);\n+\t\ttable_entry_free(entry);\n+\t\tif (status)\n+\t\t\tgoto error;\n+\t}\n+\n+error:\n+\t*file_line_number = line_id;\n+\tfree(line);\n+\treturn status;\n+}\n+\n+/**\n+ * pipeline <pipeline_name> table <table_name> default <file_name>\n+ */\n+static void\n+cmd_softnic_pipeline_table_default(struct pmd_internals *softnic,\n+\tchar **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size)\n+{\n+\tstruct pipeline *p;\n+\tchar *pipeline_name, *table_name, *file_name;\n+\tFILE *file = NULL;\n+\tuint32_t file_line_number = 0;\n+\tint status;\n+\n+\tif (n_tokens != 6) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tpipeline_name = tokens[1];\n+\tp = softnic_pipeline_find(softnic, pipeline_name);\n+\tif (!p) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\ttable_name = tokens[3];\n+\n+\tfile_name = tokens[5];\n+\tfile = fopen(file_name, \"r\");\n+\tif (!file) {\n+\t\tsnprintf(out, out_size, \"Cannot open file %s.\\n\", file_name);\n+\t\treturn;\n+\t}\n+\n+\tstatus = pipeline_table_default_entry_add(p->ctl,\n+\t\t\t\t\t\t table_name,\n+\t\t\t\t\t\t file,\n+\t\t\t\t\t\t &file_line_number);\n+\tif (status)\n+\t\tsnprintf(out, out_size, \"Invalid entry in file %s at line %u\\n\",\n+\t\t\t file_name,\n+\t\t\t file_line_number);\n+\n+\tfclose(file);\n+}\n+\n+/**\n+ * pipeline <pipeline_name> table <table_name> show [filename]\n+ */\n+static void\n+cmd_softnic_pipeline_table_show(struct pmd_internals *softnic __rte_unused,\n+\tchar **tokens,\n+\tuint32_t n_tokens,\n+\tchar *out,\n+\tsize_t out_size)\n+{\n+\tstruct pipeline *p;\n+\tchar *pipeline_name, *table_name;\n+\tFILE *file = NULL;\n+\tint status;\n+\n+\tif (n_tokens != 5 && n_tokens != 6) {\n+\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\treturn;\n+\t}\n+\n+\tpipeline_name = tokens[1];\n+\tp = softnic_pipeline_find(softnic, pipeline_name);\n+\tif (!p) {\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n+\t\treturn;\n+\t}\n+\n+\ttable_name = tokens[3];\n+\tfile = (n_tokens == 6) ? fopen(tokens[5], \"w\") : stdout;\n+\tif (!file) {\n+\t\tsnprintf(out, out_size, \"Cannot open file %s.\\n\", tokens[5]);\n+\t\treturn;\n+\t}\n+\n+\tstatus = rte_swx_ctl_pipeline_table_fprintf(file, p->ctl, table_name);\n+\tif (status)\n+\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"table_name\");\n+\n+\tif (file)\n+\t\tfclose(file);\n+}\n+\n /**\n * thread <thread_id> pipeline <pipeline_name> enable [ period <timer_period_ms> ]\n */\n@@ -570,6 +918,28 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg)\n \t\t\tcmd_softnic_pipeline_build(softnic, tokens, n_tokens, out, out_size);\n \t\t\treturn;\n \t\t}\n+\n+\t\tif (n_tokens >= 5 && !strcmp(tokens[2], \"table\") && !strcmp(tokens[4], \"add\")) {\n+\t\t\tcmd_softnic_pipeline_table_add(softnic, tokens, n_tokens, out, out_size);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (n_tokens >= 5 && !strcmp(tokens[2], \"table\") && !strcmp(tokens[4], \"delete\")) {\n+\t\t\tcmd_softnic_pipeline_table_delete(softnic, tokens, n_tokens,\n+\t\t\t\tout, out_size);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (n_tokens >= 5 && !strcmp(tokens[2], \"table\") && !strcmp(tokens[4], \"default\")) {\n+\t\t\tcmd_softnic_pipeline_table_default(softnic, tokens, n_tokens,\n+\t\t\t\tout, out_size);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (n_tokens >= 5 && !strcmp(tokens[2], \"table\") && !strcmp(tokens[4], \"show\")) {\n+\t\t\tcmd_softnic_pipeline_table_show(softnic, tokens, n_tokens, out, out_size);\n+\t\t\treturn;\n+\t\t}\n \t}\n \n \tif (strcmp(tokens[0], \"thread\") == 0) {\n", "prefixes": [ "V2", "13/21" ] }{ "id": 115520, "url": "