From patchwork Fri Mar 4 18:06:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 108544 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id 9431BA034E; Fri, 4 Mar 2022 19:06:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BDC65427E9; Fri, 4 Mar 2022 19:06:30 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 801C4427A9 for ; Fri, 4 Mar 2022 19:06:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646417188; x=1677953188; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=gRddU94qQSV69vqT0JKEiNgCoD5fLLKswPVkP2D8Nyc=; b=TivZGX5g8w4l+De0KjrTMW3uEO23iKx9BTNEgpFP6NIzD7ziXNHTAvEd qNxLsOyGlBB2sIkQetk0rTAjSmXed/4bKjmfhDO9AIZFY8LIJN3ylaHYF 0VPUMoXj4g53dbzK/UheMCaUf635JDcSATuzcfIovdYmxh0G3Bv0vs8PX ov+j4OfMaf4ViOPZKQuOZXAPMCgkb2VCx8/hJVsXCBFmJnS6WdbDxxe4M nYME1sXpeRhD4+7MYK4fL2mygI3+2kZfrjR3UVGUKjRL6gNDepw2czcOx qXOAgbgIFPO1rcgSz/CtiB/+J8vpadAzBp1yrvbO38UZPFQ40GBzWSJK7 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10276"; a="251604403" X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="251604403" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 10:06:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="552309349" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga008.jf.intel.com with ESMTP; 04 Mar 2022 10:06:26 -0800 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Yogesh Jangra Subject: [PATCH 3/3] examples/pipeline: support packet mirroring Date: Fri, 4 Mar 2022 18:06:23 +0000 Message-Id: <20220304180623.74893-3-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220304180623.74893-1-cristian.dumitrescu@intel.com> References: <20220304180623.74893-1-cristian.dumitrescu@intel.com> 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 packet mirroring. Signed-off-by: Cristian Dumitrescu Signed-off-by: Yogesh Jangra --- examples/pipeline/cli.c | 154 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index edae63dae6..e983cdd21d 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -2697,6 +2697,131 @@ cmd_pipeline_stats(char **tokens, } } +static const char cmd_pipeline_mirror_help[] = +"pipeline mirror slots sessions \n"; + +static void +cmd_pipeline_mirror(char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size, + void *obj) +{ + struct rte_swx_pipeline_mirroring_params params; + struct pipeline *p; + int status; + + if (n_tokens != 7) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[0], "pipeline")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline"); + return; + } + + p = pipeline_find(obj, tokens[1]); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "mirror")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mirror"); + return; + } + + if (strcmp(tokens[3], "slots")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "slots"); + return; + } + + if (parser_read_uint32(¶ms.n_slots, tokens[4])) { + snprintf(out, out_size, MSG_ARG_INVALID, "n_slots"); + return; + } + + if (strcmp(tokens[5], "sessions")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "sessions"); + return; + } + + if (parser_read_uint32(¶ms.n_sessions, tokens[6])) { + snprintf(out, out_size, MSG_ARG_INVALID, "n_sessions"); + return; + } + + status = rte_swx_pipeline_mirroring_config(p->p, ¶ms); + if (status) { + snprintf(out, out_size, "Command failed!\n"); + return; + } +} + +static const char cmd_pipeline_mirror_session_help[] = +"pipeline mirror session port \n"; + +static void +cmd_pipeline_mirror_session(char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size, + void *obj) +{ + struct rte_swx_pipeline_mirroring_session_params params; + struct pipeline *p; + uint32_t session_id; + int status; + + if (n_tokens != 7) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[0], "pipeline")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline"); + return; + } + + p = pipeline_find(obj, tokens[1]); + if (!p || !p->ctl) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "mirror")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mirror"); + return; + } + + if (strcmp(tokens[3], "session")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "session"); + return; + } + + if (parser_read_uint32(&session_id, tokens[4])) { + snprintf(out, out_size, MSG_ARG_INVALID, "session_id"); + return; + } + + if (strcmp(tokens[5], "port")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port"); + return; + } + + if (parser_read_uint32(¶ms.port_id, tokens[6])) { + snprintf(out, out_size, MSG_ARG_INVALID, "port_id"); + return; + } + + status = rte_swx_ctl_pipeline_mirroring_session_set(p->p, session_id, ¶ms); + if (status) { + snprintf(out, out_size, "Command failed!\n"); + return; + } +} + static const char cmd_thread_pipeline_enable_help[] = "thread pipeline enable\n"; @@ -2837,6 +2962,8 @@ cmd_help(char **tokens, "\tpipeline meter set\n" "\tpipeline meter stats\n" "\tpipeline stats\n" + "\tpipeline mirror\n" + "\tpipeline mirror session\n" "\tthread pipeline enable\n" "\tthread pipeline disable\n\n"); return; @@ -3056,6 +3183,19 @@ cmd_help(char **tokens, return; } + if (!strcmp(tokens[0], "pipeline") && + (n_tokens == 2) && !strcmp(tokens[1], "mirror")) { + snprintf(out, out_size, "\n%s\n", cmd_pipeline_mirror_help); + return; + } + + if (!strcmp(tokens[0], "pipeline") && + (n_tokens == 3) && !strcmp(tokens[1], "mirror") + && !strcmp(tokens[2], "session")) { + snprintf(out, out_size, "\n%s\n", cmd_pipeline_mirror_session_help); + return; + } + if ((n_tokens == 3) && (strcmp(tokens[0], "thread") == 0) && (strcmp(tokens[1], "pipeline") == 0)) { @@ -3310,6 +3450,20 @@ cli_process(char *in, char *out, size_t out_size, void *obj) obj); return; } + + if ((n_tokens >= 4) && + (strcmp(tokens[2], "mirror") == 0) && + (strcmp(tokens[3], "slots") == 0)) { + cmd_pipeline_mirror(tokens, n_tokens, out, out_size, obj); + return; + } + + if ((n_tokens >= 4) && + (strcmp(tokens[2], "mirror") == 0) && + (strcmp(tokens[3], "session") == 0)) { + cmd_pipeline_mirror_session(tokens, n_tokens, out, out_size, obj); + return; + } } if (strcmp(tokens[0], "thread") == 0) {