From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84E55A00C4; Thu, 28 Jul 2022 01:03:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 455C742BE6; Thu, 28 Jul 2022 01:01:55 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id C1FA242BBB for ; Thu, 28 Jul 2022 01:01:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962908; x=1690498908; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mdd7xobB3yYeOf0ALMuS8NLNlQj9cuZS1V80eTZviNw=; b=jZVrjj4mRB+qmyEqNiqUDIynF7B7BaihrGIIuuUpecLkB7Uuaoh28gRS 2Pdatn8sHQWXd7Li/3uN3sQixACEjuyzHwQgD+XsVlYswYxYL6qlYnGYY b9ldC2x/t9E3IUyWHByhc5a/9Gn5iMr81gMT/K0+65rah+k42VMObbOnB Nxy6MApaJLG1eUv2SvydnixtV9Afl6bw12RDkV4veHtGsLiTDkxKXO4vz VifHm+yDSQZaF6XA7lakCHAxYErDj0eRYFf+A9hlQenWE1U3FZUmVsq4a 4QdE2m4YypwoTsJfKe8max8XwM8TlyAybb6MNbAh1ndEKZgBOJNyuT1Bb g==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="289135835" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="289135835" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444396" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:46 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 14/17] examples/pipeline: use the pipeline name query API Date: Wed, 27 Jul 2022 23:01:29 +0000 Message-Id: <20220727230132.601114-14-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Convert the CLI commands to use the pipeline name query API and remove the linked list of pipeline objects previously maintained by the application. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 268 ++++++++++++++++++++----------------- examples/pipeline/obj.c | 67 ---------- examples/pipeline/obj.h | 24 ---- examples/pipeline/thread.c | 65 ++++----- examples/pipeline/thread.h | 9 +- 5 files changed, 175 insertions(+), 258 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index fa828c008b..f48ff326be 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -858,9 +858,9 @@ cmd_pipeline_table_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -872,8 +872,8 @@ cmd_pipeline_table_add(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -887,7 +887,7 @@ cmd_pipeline_table_add(char **tokens, return; } - status = pipeline_table_entries_add(p->ctl, + status = pipeline_table_entries_add(ctl, table_name, file, &file_line_number); @@ -956,9 +956,9 @@ cmd_pipeline_table_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -970,8 +970,8 @@ cmd_pipeline_table_delete(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -985,7 +985,7 @@ cmd_pipeline_table_delete(char **tokens, return; } - status = pipeline_table_entries_delete(p->ctl, + status = pipeline_table_entries_delete(ctl, table_name, file, &file_line_number); @@ -1054,9 +1054,9 @@ cmd_pipeline_table_default(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1068,8 +1068,8 @@ cmd_pipeline_table_default(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1083,7 +1083,7 @@ cmd_pipeline_table_default(char **tokens, return; } - status = pipeline_table_default_entry_add(p->ctl, + status = pipeline_table_default_entry_add(ctl, table_name, file, &file_line_number); @@ -1103,9 +1103,9 @@ cmd_pipeline_table_show(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name; FILE *file = NULL; int status; @@ -1116,8 +1116,8 @@ cmd_pipeline_table_show(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1129,7 +1129,7 @@ cmd_pipeline_table_show(char **tokens, return; } - status = rte_swx_ctl_pipeline_table_fprintf(file, p->ctl, table_name); + status = rte_swx_ctl_pipeline_table_fprintf(file, ctl, table_name); if (status) snprintf(out, out_size, MSG_ARG_INVALID, "table_name"); @@ -1145,9 +1145,9 @@ cmd_pipeline_selector_group_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name; uint32_t group_id; int status; @@ -1158,8 +1158,8 @@ cmd_pipeline_selector_group_add(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1177,7 +1177,7 @@ cmd_pipeline_selector_group_add(char **tokens, return; } - status = rte_swx_ctl_pipeline_selector_group_add(p->ctl, + status = rte_swx_ctl_pipeline_selector_group_add(ctl, selector_name, &group_id); if (status) @@ -1194,9 +1194,9 @@ cmd_pipeline_selector_group_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name; uint32_t group_id; int status; @@ -1207,8 +1207,8 @@ cmd_pipeline_selector_group_delete(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1231,7 +1231,7 @@ cmd_pipeline_selector_group_delete(char **tokens, return; } - status = rte_swx_ctl_pipeline_selector_group_delete(p->ctl, + status = rte_swx_ctl_pipeline_selector_group_delete(ctl, selector_name, group_id); if (status) @@ -1402,9 +1402,9 @@ cmd_pipeline_selector_group_member_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1416,8 +1416,8 @@ cmd_pipeline_selector_group_member_add(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1443,7 +1443,7 @@ cmd_pipeline_selector_group_member_add(char **tokens, return; } - status = pipeline_selector_group_members_add(p->ctl, + status = pipeline_selector_group_members_add(ctl, selector_name, file, &file_line_number); @@ -1512,9 +1512,9 @@ cmd_pipeline_selector_group_member_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1526,8 +1526,8 @@ cmd_pipeline_selector_group_member_delete(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1553,7 +1553,7 @@ cmd_pipeline_selector_group_member_delete(char **tokens, return; } - status = pipeline_selector_group_members_delete(p->ctl, + status = pipeline_selector_group_members_delete(ctl, selector_name, file, &file_line_number); @@ -1573,9 +1573,9 @@ cmd_pipeline_selector_show(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name; FILE *file = NULL; int status; @@ -1586,8 +1586,8 @@ cmd_pipeline_selector_show(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1600,7 +1600,7 @@ cmd_pipeline_selector_show(char **tokens, return; } - status = rte_swx_ctl_pipeline_selector_fprintf(file, p->ctl, selector_name); + status = rte_swx_ctl_pipeline_selector_fprintf(file, ctl, selector_name); if (status) snprintf(out, out_size, MSG_ARG_INVALID, "selector_name"); @@ -1665,9 +1665,9 @@ cmd_pipeline_learner_default(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *learner_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1679,8 +1679,8 @@ cmd_pipeline_learner_default(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1694,7 +1694,7 @@ cmd_pipeline_learner_default(char **tokens, return; } - status = pipeline_learner_default_entry_add(p->ctl, + status = pipeline_learner_default_entry_add(ctl, learner_name, file, &file_line_number); @@ -1714,9 +1714,9 @@ cmd_pipeline_commit(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name; int status; @@ -1726,13 +1726,13 @@ cmd_pipeline_commit(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } - status = rte_swx_ctl_pipeline_commit(p->ctl, 1); + status = rte_swx_ctl_pipeline_commit(ctl, 1); if (status) snprintf(out, out_size, "Commit failed. " "Use \"commit\" to retry or \"abort\" to discard the pending work.\n"); @@ -1746,9 +1746,9 @@ cmd_pipeline_abort(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name; if (n_tokens != 3) { @@ -1757,13 +1757,13 @@ cmd_pipeline_abort(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } - rte_swx_ctl_pipeline_abort(p->ctl); + rte_swx_ctl_pipeline_abort(ctl); } static const char cmd_pipeline_regrd_help[] = @@ -1774,9 +1774,9 @@ cmd_pipeline_regrd(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint64_t value; uint32_t idx; @@ -1787,8 +1787,8 @@ cmd_pipeline_regrd(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1805,7 +1805,7 @@ cmd_pipeline_regrd(char **tokens, return; } - status = rte_swx_ctl_pipeline_regarray_read(p->p, name, idx, &value); + status = rte_swx_ctl_pipeline_regarray_read(p, name, idx, &value); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -1822,9 +1822,9 @@ cmd_pipeline_regwr(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint64_t value; uint32_t idx; @@ -1835,8 +1835,8 @@ cmd_pipeline_regwr(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1858,7 +1858,7 @@ cmd_pipeline_regwr(char **tokens, return; } - status = rte_swx_ctl_pipeline_regarray_write(p->p, name, idx, value); + status = rte_swx_ctl_pipeline_regarray_write(p, name, idx, value); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -1874,10 +1874,10 @@ cmd_pipeline_meter_profile_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_meter_trtcm_params params; - struct pipeline *p; + struct rte_swx_pipeline *p; const char *profile_name; int status; @@ -1886,8 +1886,8 @@ cmd_pipeline_meter_profile_add(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1949,7 +1949,7 @@ cmd_pipeline_meter_profile_add(char **tokens, return; } - status = rte_swx_ctl_meter_profile_add(p->p, profile_name, ¶ms); + status = rte_swx_ctl_meter_profile_add(p, profile_name, ¶ms); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -1964,9 +1964,9 @@ cmd_pipeline_meter_profile_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *profile_name; int status; @@ -1975,8 +1975,8 @@ cmd_pipeline_meter_profile_delete(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1998,7 +1998,7 @@ cmd_pipeline_meter_profile_delete(char **tokens, return; } - status = rte_swx_ctl_meter_profile_delete(p->p, profile_name); + status = rte_swx_ctl_meter_profile_delete(p, profile_name); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -2014,9 +2014,9 @@ cmd_pipeline_meter_reset(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint32_t idx0 = 0, idx1 = 0; @@ -2025,8 +2025,8 @@ cmd_pipeline_meter_reset(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2066,7 +2066,7 @@ cmd_pipeline_meter_reset(char **tokens, for ( ; idx0 <= idx1; idx0++) { int status; - status = rte_swx_ctl_meter_reset(p->p, name, idx0); + status = rte_swx_ctl_meter_reset(p, name, idx0); if (status) { snprintf(out, out_size, "Command failed for index %u.\n", idx0); return; @@ -2083,9 +2083,9 @@ cmd_pipeline_meter_set(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name, *profile_name; uint32_t idx0 = 0, idx1 = 0; @@ -2094,8 +2094,8 @@ cmd_pipeline_meter_set(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2142,7 +2142,7 @@ cmd_pipeline_meter_set(char **tokens, for ( ; idx0 <= idx1; idx0++) { int status; - status = rte_swx_ctl_meter_set(p->p, name, idx0, profile_name); + status = rte_swx_ctl_meter_set(p, name, idx0, profile_name); if (status) { snprintf(out, out_size, "Command failed for index %u.\n", idx0); return; @@ -2159,10 +2159,10 @@ cmd_pipeline_meter_stats(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_swx_ctl_meter_stats stats; - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint32_t idx0 = 0, idx1 = 0; @@ -2171,8 +2171,8 @@ cmd_pipeline_meter_stats(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2235,7 +2235,7 @@ cmd_pipeline_meter_stats(char **tokens, for ( ; idx0 <= idx1; idx0++) { int status; - status = rte_swx_ctl_meter_stats_read(p->p, name, idx0, &stats); + status = rte_swx_ctl_meter_stats_read(p, name, idx0, &stats); if (status) { snprintf(out, out_size, "Pipeline meter stats error at index %u.\n", idx0); out_size -= strlen(out); @@ -2265,10 +2265,10 @@ cmd_pipeline_stats(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_swx_ctl_pipeline_info info; - struct pipeline *p; + struct rte_swx_pipeline *p; uint32_t i; int status; @@ -2277,8 +2277,8 @@ cmd_pipeline_stats(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2288,7 +2288,7 @@ cmd_pipeline_stats(char **tokens, return; } - status = rte_swx_ctl_pipeline_info_get(p->p, &info); + status = rte_swx_ctl_pipeline_info_get(p, &info); if (status) { snprintf(out, out_size, "Pipeline info get error."); return; @@ -2301,7 +2301,7 @@ cmd_pipeline_stats(char **tokens, for (i = 0; i < info.n_ports_in; i++) { struct rte_swx_port_in_stats stats; - rte_swx_ctl_pipeline_port_in_stats_read(p->p, i, &stats); + rte_swx_ctl_pipeline_port_in_stats_read(p, i, &stats); snprintf(out, out_size, "\tPort %u:" " packets %" PRIu64 @@ -2319,7 +2319,7 @@ cmd_pipeline_stats(char **tokens, for (i = 0; i < info.n_ports_out; i++) { struct rte_swx_port_out_stats stats; - rte_swx_ctl_pipeline_port_out_stats_read(p->p, i, &stats); + rte_swx_ctl_pipeline_port_out_stats_read(p, i, &stats); if (i != info.n_ports_out - 1) snprintf(out, out_size, "\tPort %u:", i); @@ -2358,13 +2358,13 @@ cmd_pipeline_stats(char **tokens, }; uint32_t j; - status = rte_swx_ctl_table_info_get(p->p, i, &table_info); + status = rte_swx_ctl_table_info_get(p, i, &table_info); if (status) { snprintf(out, out_size, "Table info get error."); return; } - status = rte_swx_ctl_pipeline_table_stats_read(p->p, table_info.name, &stats); + status = rte_swx_ctl_pipeline_table_stats_read(p, table_info.name, &stats); if (status) { snprintf(out, out_size, "Table stats read error."); return; @@ -2382,7 +2382,7 @@ cmd_pipeline_stats(char **tokens, for (j = 0; j < info.n_actions; j++) { struct rte_swx_ctl_action_info action_info; - status = rte_swx_ctl_action_info_get(p->p, j, &action_info); + status = rte_swx_ctl_action_info_get(p, j, &action_info); if (status) { snprintf(out, out_size, "Action info get error."); return; @@ -2410,13 +2410,13 @@ cmd_pipeline_stats(char **tokens, }; uint32_t j; - status = rte_swx_ctl_learner_info_get(p->p, i, &learner_info); + status = rte_swx_ctl_learner_info_get(p, i, &learner_info); if (status) { snprintf(out, out_size, "Learner table info get error."); return; } - status = rte_swx_ctl_pipeline_learner_stats_read(p->p, learner_info.name, &stats); + status = rte_swx_ctl_pipeline_learner_stats_read(p, learner_info.name, &stats); if (status) { snprintf(out, out_size, "Learner table stats read error."); return; @@ -2442,7 +2442,7 @@ cmd_pipeline_stats(char **tokens, for (j = 0; j < info.n_actions; j++) { struct rte_swx_ctl_action_info action_info; - status = rte_swx_ctl_action_info_get(p->p, j, &action_info); + status = rte_swx_ctl_action_info_get(p, j, &action_info); if (status) { snprintf(out, out_size, "Action info get error."); return; @@ -2466,10 +2466,10 @@ cmd_pipeline_mirror_session(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_swx_pipeline_mirroring_session_params params; - struct pipeline *p; + struct rte_swx_pipeline *p; uint32_t session_id = 0; int status; @@ -2483,8 +2483,8 @@ cmd_pipeline_mirror_session(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2538,7 +2538,7 @@ cmd_pipeline_mirror_session(char **tokens, return; } - status = rte_swx_ctl_pipeline_mirroring_session_set(p->p, session_id, ¶ms); + status = rte_swx_ctl_pipeline_mirroring_session_set(p, session_id, ¶ms); if (status) { snprintf(out, out_size, "Command failed!\n"); return; @@ -2546,21 +2546,25 @@ cmd_pipeline_mirror_session(char **tokens, } static const char cmd_thread_pipeline_enable_help[] = -"thread pipeline enable\n"; +"thread pipeline enable [ period ]\n"; + +#ifndef TIMER_PERIOD_MS_DEFAULT +#define TIMER_PERIOD_MS_DEFAULT 10 +#endif static void cmd_thread_pipeline_enable(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { char *pipeline_name; - struct pipeline *p; - uint32_t thread_id; + struct rte_swx_pipeline *p; + uint32_t thread_id, timer_period_ms = TIMER_PERIOD_MS_DEFAULT; int status; - if (n_tokens != 5) { + if ((n_tokens != 5) && (n_tokens != 7)) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; } @@ -2576,8 +2580,8 @@ cmd_thread_pipeline_enable(char **tokens, } pipeline_name = tokens[3]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(pipeline_name); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2587,7 +2591,19 @@ cmd_thread_pipeline_enable(char **tokens, return; } - status = thread_pipeline_enable(thread_id, obj, pipeline_name); + if (n_tokens == 7) { + if (strcmp(tokens[5], "period") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "period"); + return; + } + + if (parser_read_uint32(&timer_period_ms, tokens[6]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "timer_period_ms"); + return; + } + } + + status = thread_pipeline_enable(thread_id, p, timer_period_ms); if (status) { snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable"); return; @@ -2602,9 +2618,9 @@ cmd_thread_pipeline_disable(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; char *pipeline_name; uint32_t thread_id; int status; @@ -2625,8 +2641,8 @@ cmd_thread_pipeline_disable(char **tokens, } pipeline_name = tokens[3]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(pipeline_name); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2636,7 +2652,7 @@ cmd_thread_pipeline_disable(char **tokens, return; } - status = thread_pipeline_disable(thread_id, obj, pipeline_name); + status = thread_pipeline_disable(thread_id, p); if (status) { snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline disable"); diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index 967342c580..d1f519180e 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "obj.h" @@ -41,11 +40,6 @@ TAILQ_HEAD(ring_list, ring); */ TAILQ_HEAD(tap_list, tap); -/* - * pipeline - */ -TAILQ_HEAD(pipeline_list, pipeline); - /* * obj */ @@ -53,7 +47,6 @@ struct obj { struct mempool_list mempool_list; struct link_list link_list; struct ring_list ring_list; - struct pipeline_list pipeline_list; struct tap_list tap_list; }; @@ -513,65 +506,6 @@ tap_create(struct obj *obj, const char *name) #endif -/* - * pipeline - */ -#ifndef PIPELINE_MSGQ_SIZE -#define PIPELINE_MSGQ_SIZE 64 -#endif - -struct pipeline * -pipeline_create(struct obj *obj, const char *name, int numa_node) -{ - struct pipeline *pipeline; - struct rte_swx_pipeline *p = NULL; - int status; - - /* Check input params */ - if ((name == NULL) || - pipeline_find(obj, name)) - return NULL; - - /* Resource create */ - status = rte_swx_pipeline_config(&p, name, numa_node); - if (status) - goto error; - - /* Node allocation */ - pipeline = calloc(1, sizeof(struct pipeline)); - if (pipeline == NULL) - goto error; - - /* Node fill in */ - strlcpy(pipeline->name, name, sizeof(pipeline->name)); - pipeline->p = p; - pipeline->timer_period_ms = 10; - - /* Node add to list */ - TAILQ_INSERT_TAIL(&obj->pipeline_list, pipeline, node); - - return pipeline; - -error: - rte_swx_pipeline_free(p); - return NULL; -} - -struct pipeline * -pipeline_find(struct obj *obj, const char *name) -{ - struct pipeline *pipeline; - - if (!obj || !name) - return NULL; - - TAILQ_FOREACH(pipeline, &obj->pipeline_list, node) - if (strcmp(name, pipeline->name) == 0) - return pipeline; - - return NULL; -} - /* * obj */ @@ -587,7 +521,6 @@ obj_init(void) TAILQ_INIT(&obj->mempool_list); TAILQ_INIT(&obj->link_list); TAILQ_INIT(&obj->ring_list); - TAILQ_INIT(&obj->pipeline_list); TAILQ_INIT(&obj->tap_list); return obj; diff --git a/examples/pipeline/obj.h b/examples/pipeline/obj.h index b921610554..e63a9c0e9a 100644 --- a/examples/pipeline/obj.h +++ b/examples/pipeline/obj.h @@ -143,28 +143,4 @@ tap_next(struct obj *obj, struct tap *tap); struct tap * tap_create(struct obj *obj, const char *name); -/* - * pipeline - */ -struct pipeline { - TAILQ_ENTRY(pipeline) node; - char name[NAME_SIZE]; - - struct rte_swx_pipeline *p; - struct rte_swx_ctl_pipeline *ctl; - - uint32_t timer_period_ms; - int enabled; - uint32_t thread_id; - uint32_t cpu_id; -}; - -struct pipeline * -pipeline_create(struct obj *obj, - const char *name, - int numa_node); - -struct pipeline * -pipeline_find(struct obj *obj, const char *name); - #endif /* _INCLUDE_OBJ_H_ */ diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c index 5fe7eae00e..6d15f51fb2 100644 --- a/examples/pipeline/thread.c +++ b/examples/pipeline/thread.c @@ -228,20 +228,33 @@ thread_msg_send_recv(uint32_t thread_id, return rsp; } +static int +thread_is_pipeline_enabled(uint32_t thread_id, struct rte_swx_pipeline *p) +{ + struct thread *t = &thread[thread_id]; + struct thread_data *td = &thread_data[thread_id]; + uint32_t i; + + if (!t->enabled) + return 0; /* Pipeline NOT enabled on this thread. */ + + for (i = 0; i < td->n_pipelines; i++) + if (td->p[i] == p) + return 1; /* Pipeline enabled on this thread. */ + + return 0 /* Pipeline NOT enabled on this thread. */; +} + int -thread_pipeline_enable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name) +thread_pipeline_enable(uint32_t thread_id, struct rte_swx_pipeline *p, uint32_t timer_period_ms) { - struct pipeline *p = pipeline_find(obj, pipeline_name); struct thread *t; struct thread_msg_req *req; struct thread_msg_rsp *rsp; int status; /* Check input params */ - if ((thread_id >= RTE_MAX_LCORE) || - (p == NULL)) + if ((thread_id >= RTE_MAX_LCORE) || !p || !timer_period_ms) return -1; t = &thread[thread_id]; @@ -256,19 +269,14 @@ thread_pipeline_enable(uint32_t thread_id, return -1; /* Data plane thread */ - td->p[td->n_pipelines] = p->p; + td->p[td->n_pipelines] = p; - tdp->p = p->p; - tdp->timer_period = - (rte_get_tsc_hz() * p->timer_period_ms) / 1000; + tdp->p = p; + tdp->timer_period = (rte_get_tsc_hz() * timer_period_ms) / 1000; tdp->time_next = rte_get_tsc_cycles() + tdp->timer_period; td->n_pipelines++; - /* Pipeline */ - p->thread_id = thread_id; - p->enabled = 1; - return 0; } @@ -279,8 +287,8 @@ thread_pipeline_enable(uint32_t thread_id, /* Write request */ req->type = THREAD_REQ_PIPELINE_ENABLE; - req->pipeline_enable.p = p->p; - req->pipeline_enable.timer_period_ms = p->timer_period_ms; + req->pipeline_enable.p = p; + req->pipeline_enable.timer_period_ms = timer_period_ms; /* Send request and wait for response */ rsp = thread_msg_send_recv(thread_id, req); @@ -295,38 +303,28 @@ thread_pipeline_enable(uint32_t thread_id, if (status) return status; - p->thread_id = thread_id; - p->enabled = 1; - return 0; } int -thread_pipeline_disable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name) +thread_pipeline_disable(uint32_t thread_id, struct rte_swx_pipeline *p) { - struct pipeline *p = pipeline_find(obj, pipeline_name); struct thread *t; struct thread_msg_req *req; struct thread_msg_rsp *rsp; int status; /* Check input params */ - if ((thread_id >= RTE_MAX_LCORE) || - (p == NULL)) + if ((thread_id >= RTE_MAX_LCORE) || !p) return -1; t = &thread[thread_id]; if (t->enabled == 0) return -1; - if (p->enabled == 0) + if (!thread_is_pipeline_enabled(thread_id, p)) return 0; - if (p->thread_id != thread_id) - return -1; - if (!thread_is_running(thread_id)) { struct thread_data *td = &thread_data[thread_id]; uint32_t i; @@ -334,7 +332,7 @@ thread_pipeline_disable(uint32_t thread_id, for (i = 0; i < td->n_pipelines; i++) { struct pipeline_data *tdp = &td->pipeline_data[i]; - if (tdp->p != p->p) + if (tdp->p != p) continue; /* Data plane thread */ @@ -350,9 +348,6 @@ thread_pipeline_disable(uint32_t thread_id, td->n_pipelines--; - /* Pipeline */ - p->enabled = 0; - break; } @@ -366,7 +361,7 @@ thread_pipeline_disable(uint32_t thread_id, /* Write request */ req->type = THREAD_REQ_PIPELINE_DISABLE; - req->pipeline_disable.p = p->p; + req->pipeline_disable.p = p; /* Send request and wait for response */ rsp = thread_msg_send_recv(thread_id, req); @@ -381,8 +376,6 @@ thread_pipeline_disable(uint32_t thread_id, if (status) return status; - p->enabled = 0; - return 0; } diff --git a/examples/pipeline/thread.h b/examples/pipeline/thread.h index d9d8645d4c..712cb25bbb 100644 --- a/examples/pipeline/thread.h +++ b/examples/pipeline/thread.h @@ -7,17 +7,16 @@ #include -#include "obj.h" +#include int thread_pipeline_enable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name); + struct rte_swx_pipeline *p, + uint32_t timer_period_ms); int thread_pipeline_disable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name); + struct rte_swx_pipeline *p); int thread_init(void); -- 2.34.1