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 A076AA0032; Thu, 1 Sep 2022 16:23:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7688842BD8; Thu, 1 Sep 2022 16:21:25 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 9F5EC42B6D for ; Thu, 1 Sep 2022 16:21:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662042070; x=1693578070; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PF3mhNENA3pdhPV+EdP3c6pqTgqQ/pnNr4AmnA+yjE4=; b=gs1IIp6DoUeBcZx6Gr4oCRLZQTBgoIe3au9tBAdxnKVtyDFQrNx4Dec1 npFw/gGke1WfYAQEEQDFV7KtlhpavCcbZOOaBWBqW5b5cmVNoJSTwgrt/ GiPK7GhNk+Vmj7JjPYw5xYApMr5x4KX8dTki/1LxyiNV95msmjaG7dY6N drIKyG7RSPmdlqPjNfbtRdT+w9W0qSUIc/AEf14+u4Xa/VxCfvuYOtgcL M+A07acYILT4D8sh7bP61boLlf5uFhjHPRA+T2vyqywcgb2hxiA7aDOZ9 Pj27edvv7HrFLTOlQPzCJcJZ/mHButLu77/d2TuNr/egl0bFLZ++lGElp g==; X-IronPort-AV: E=McAfee;i="6500,9779,10457"; a="357444085" X-IronPort-AV: E=Sophos;i="5.93,281,1654585200"; d="scan'208";a="357444085" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 07:20:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,281,1654585200"; d="scan'208";a="680870234" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga004.fm.intel.com with ESMTP; 01 Sep 2022 07:20:58 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Yogesh Jangra Subject: [PATCH V3 18/21] net/softnic: add the pipeline meter CLI commands Date: Thu, 1 Sep 2022 14:20:38 +0000 Message-Id: <20220901142041.2628537-19-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220901142041.2628537-1-cristian.dumitrescu@intel.com> References: <20220804165839.1074817-1-cristian.dumitrescu@intel.com> <20220901142041.2628537-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 Add CLI commands for pipeline meter configuration. Signed-off-by: Cristian Dumitrescu Signed-off-by: Yogesh Jangra --- drivers/net/softnic/rte_eth_softnic_cli.c | 423 ++++++++++++++++++++++ 1 file changed, 423 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index b1f7460f47..bbbf3babda 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -1520,6 +1520,395 @@ cmd_softnic_pipeline_regwr(struct pmd_internals *softnic, } } +/** + * pipeline meter profile add cir pir cbs pbs + */ +static void +cmd_softnic_pipeline_meter_profile_add(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct rte_meter_trtcm_params params; + struct pipeline *p; + const char *profile_name; + int status; + + if (n_tokens != 14) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + p = softnic_pipeline_find(softnic, tokens[1]); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "meter")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter"); + return; + } + + if (strcmp(tokens[3], "profile")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile"); + return; + } + + profile_name = tokens[4]; + + if (strcmp(tokens[5], "add")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add"); + return; + } + + if (strcmp(tokens[6], "cir")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir"); + return; + } + + if (parser_read_uint64(¶ms.cir, tokens[7])) { + snprintf(out, out_size, MSG_ARG_INVALID, "cir"); + return; + } + + if (strcmp(tokens[8], "pir")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pir"); + return; + } + + if (parser_read_uint64(¶ms.pir, tokens[9])) { + snprintf(out, out_size, MSG_ARG_INVALID, "pir"); + return; + } + + if (strcmp(tokens[10], "cbs")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs"); + return; + } + + if (parser_read_uint64(¶ms.cbs, tokens[11])) { + snprintf(out, out_size, MSG_ARG_INVALID, "cbs"); + return; + } + + if (strcmp(tokens[12], "pbs")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pbs"); + return; + } + + if (parser_read_uint64(¶ms.pbs, tokens[13])) { + snprintf(out, out_size, MSG_ARG_INVALID, "pbs"); + return; + } + + status = rte_swx_ctl_meter_profile_add(p->p, profile_name, ¶ms); + if (status) { + snprintf(out, out_size, "Command failed.\n"); + return; + } +} + +/** + * pipeline meter profile delete + */ +static void +cmd_softnic_pipeline_meter_profile_delete(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct pipeline *p; + const char *profile_name; + int status; + + if (n_tokens != 6) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + p = softnic_pipeline_find(softnic, tokens[1]); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "meter")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter"); + return; + } + + if (strcmp(tokens[3], "profile")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile"); + return; + } + + profile_name = tokens[4]; + + if (strcmp(tokens[5], "delete")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete"); + return; + } + + status = rte_swx_ctl_meter_profile_delete(p->p, profile_name); + if (status) { + snprintf(out, out_size, "Command failed.\n"); + return; + } +} + +/** + * pipeline meter from to reset + */ +static void +cmd_softnic_pipeline_meter_reset(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct pipeline *p; + const char *name; + uint32_t idx0 = 0, idx1 = 0; + + if (n_tokens != 9) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + p = softnic_pipeline_find(softnic, tokens[1]); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "meter")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter"); + return; + } + + name = tokens[3]; + + if (strcmp(tokens[4], "from")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "from"); + return; + } + + if (parser_read_uint32(&idx0, tokens[5])) { + snprintf(out, out_size, MSG_ARG_INVALID, "index0"); + return; + } + + if (strcmp(tokens[6], "to")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "to"); + return; + } + + if (parser_read_uint32(&idx1, tokens[7]) || idx1 < idx0) { + snprintf(out, out_size, MSG_ARG_INVALID, "index1"); + return; + } + + if (strcmp(tokens[8], "reset")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "reset"); + return; + } + + for ( ; idx0 <= idx1; idx0++) { + int status; + + status = rte_swx_ctl_meter_reset(p->p, name, idx0); + if (status) { + snprintf(out, out_size, "Command failed for index %u.\n", idx0); + return; + } + } +} + +/** + * pipeline meter from to set + * profile + */ +static void +cmd_softnic_pipeline_meter_set(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct pipeline *p; + const char *name, *profile_name; + uint32_t idx0 = 0, idx1 = 0; + + if (n_tokens != 11) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + p = softnic_pipeline_find(softnic, tokens[1]); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "meter")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter"); + return; + } + + name = tokens[3]; + + if (strcmp(tokens[4], "from")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "from"); + return; + } + + if (parser_read_uint32(&idx0, tokens[5])) { + snprintf(out, out_size, MSG_ARG_INVALID, "index0"); + return; + } + + if (strcmp(tokens[6], "to")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "to"); + return; + } + + if (parser_read_uint32(&idx1, tokens[7]) || idx1 < idx0) { + snprintf(out, out_size, MSG_ARG_INVALID, "index1"); + return; + } + + if (strcmp(tokens[8], "set")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "set"); + return; + } + + if (strcmp(tokens[9], "profile")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile"); + return; + } + + profile_name = tokens[10]; + + for ( ; idx0 <= idx1; idx0++) { + int status; + + status = rte_swx_ctl_meter_set(p->p, name, idx0, profile_name); + if (status) { + snprintf(out, out_size, "Command failed for index %u.\n", idx0); + return; + } + } +} + +/** + * pipeline meter from to stats + */ +static void +cmd_softnic_pipeline_meter_stats(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct rte_swx_ctl_meter_stats stats; + struct pipeline *p; + const char *name; + uint32_t idx0 = 0, idx1 = 0; + + if (n_tokens != 9) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + p = softnic_pipeline_find(softnic, tokens[1]); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "meter")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter"); + return; + } + + name = tokens[3]; + + if (strcmp(tokens[4], "from")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "from"); + return; + } + + if (parser_read_uint32(&idx0, tokens[5])) { + snprintf(out, out_size, MSG_ARG_INVALID, "index0"); + return; + } + + if (strcmp(tokens[6], "to")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "to"); + return; + } + + if (parser_read_uint32(&idx1, tokens[7]) || idx1 < idx0) { + snprintf(out, out_size, MSG_ARG_INVALID, "index1"); + return; + } + + if (strcmp(tokens[8], "stats")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats"); + return; + } + + /* Table header. */ + snprintf(out, out_size, "+-%7s-+-%16s-+-%16s-+-%16s-+-%16s-+-%16s-+-%16s-+\n", + "-------", + "----------------", "----------------", "----------------", + "----------------", "----------------", "----------------"); + out_size -= strlen(out); + out += strlen(out); + + snprintf(out, out_size, "| %4s | %16s | %16s | %16s | %16s | %16s | %16s |\n", + "METER #", + "GREEN (packets)", "YELLOW (packets)", "RED (packets)", + "GREEN (bytes)", "YELLOW (bytes)", "RED (bytes)"); + out_size -= strlen(out); + out += strlen(out); + + snprintf(out, out_size, "+-%7s-+-%16s-+-%16s-+-%16s-+-%16s-+-%16s-+-%16s-+\n", + "-------", + "----------------", "----------------", "----------------", + "----------------", "----------------", "----------------"); + out_size -= strlen(out); + out += strlen(out); + + /* Table rows. */ + for ( ; idx0 <= idx1; idx0++) { + int status; + + status = rte_swx_ctl_meter_stats_read(p->p, name, idx0, &stats); + if (status) { + snprintf(out, out_size, "Pipeline meter stats error at index %u.\n", idx0); + out_size -= strlen(out); + out += strlen(out); + return; + } + + snprintf(out, out_size, "| %7d | %16" PRIx64 " | %16" PRIx64 " | %16" PRIx64 + " | %16" PRIx64 " | %16" PRIx64 " | %16" PRIx64 " |\n", + idx0, + stats.n_pkts[RTE_COLOR_GREEN], + stats.n_pkts[RTE_COLOR_YELLOW], + stats.n_pkts[RTE_COLOR_RED], + stats.n_bytes[RTE_COLOR_GREEN], + stats.n_bytes[RTE_COLOR_YELLOW], + stats.n_bytes[RTE_COLOR_RED]); + out_size -= strlen(out); + out += strlen(out); + } +} + /** * thread pipeline enable [ period ] */ @@ -1760,6 +2149,40 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg) cmd_softnic_pipeline_regwr(softnic, tokens, n_tokens, out, out_size); return; } + + if (n_tokens >= 6 && + !strcmp(tokens[2], "meter") && + !strcmp(tokens[3], "profile") && + !strcmp(tokens[5], "add")) { + cmd_softnic_pipeline_meter_profile_add(softnic, tokens, n_tokens, + out, out_size); + return; + } + + if (n_tokens >= 6 && + !strcmp(tokens[2], "meter") && + !strcmp(tokens[3], "profile") && + !strcmp(tokens[5], "delete")) { + cmd_softnic_pipeline_meter_profile_delete(softnic, tokens, n_tokens, + out, out_size); + return; + } + + if (n_tokens >= 9 && !strcmp(tokens[2], "meter") && !strcmp(tokens[8], "reset")) { + cmd_softnic_pipeline_meter_reset(softnic, tokens, n_tokens, out, out_size); + return; + } + + if (n_tokens >= 9 && !strcmp(tokens[2], "meter") && !strcmp(tokens[8], "set")) { + cmd_softnic_pipeline_meter_set(softnic, tokens, n_tokens, out, out_size); + return; + } + + if (n_tokens >= 9 && !strcmp(tokens[2], "meter") && !strcmp(tokens[8], "stats")) { + cmd_softnic_pipeline_meter_stats(softnic, tokens, n_tokens, out, out_size); + return; + } + } if (strcmp(tokens[0], "thread") == 0) { -- 2.34.1