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 96471423AF; Wed, 11 Jan 2023 21:57:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6215A42D6B; Wed, 11 Jan 2023 21:56:25 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id BC46F42D49 for ; Wed, 11 Jan 2023 21:56:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673470582; x=1705006582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=faaMpiWMBino5DScWfMbwJ05dbKLdSRr+WtTAYsuXjA=; b=DJwMLk1ruppTHPtMUJ2dTzxkatX8h0LvbmDmi7yPCW3lt/xwZ/1RpxgI EYVSjUdRAxoVzgKsZaU32bjI8sFtFMrZOWmnljbQ16Ag1kodzuCM6Iwxm BdXqmYXIBIRlLGi6C95nCwmNQohtmJNf4a+JZBJ8sxNwrF0i2v/deojUg ajTvqVqcq1mVfbSmzTG2FE7+aTY4NyooXbflrEMQeZzdjy3FI4ecHLGP6 mPOUPPDmB9TwmNqrTT1XGGFgb24b0hpEGZetZppZc67qkogUJkppBHZGJ KOZvha6BTjohz0lSorB4n6oZvlnfB1TEdj4XD6Ohutxu8MUAClPMQzCUI Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="303229799" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="303229799" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2023 12:56:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="607518903" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="607518903" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.222.53]) by orsmga003.jf.intel.com with ESMTP; 11 Jan 2023 12:56:20 -0800 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Kamalakannan R Subject: [PATCH 10/11] examples/pipeline: add block enable/disable CLI commands Date: Wed, 11 Jan 2023 20:56:07 +0000 Message-Id: <20230111205608.87953-11-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111205608.87953-1-cristian.dumitrescu@intel.com> References: <20230111205608.87953-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 to enable/disable block execution on data plane threads. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R --- examples/pipeline/cli.c | 154 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index d48cbb6240..fad855e1dd 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -3249,6 +3249,134 @@ cmd_pipeline_disable(char **tokens, pipeline_disable(p); } +static const char cmd_block_enable_help[] = +"block type instance enable thread \n"; + +static void +cmd_block_enable(char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size, + void *obj __rte_unused) +{ + char *block_type, *block_name; + block_run_f block_func = NULL; + void *block = NULL; + uint32_t thread_id; + int status; + + if (n_tokens != 8) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[1], "type") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "type"); + return; + } + + block_type = tokens[2]; + + if (strcmp(tokens[3], "instance") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "instance"); + return; + } + + block_name = tokens[4]; + + if (strcmp(tokens[5], "enable") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable"); + return; + } + + if (strcmp(tokens[6], "thread") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "thread"); + return; + } + + if (parser_read_uint32(&thread_id, tokens[7]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "thread_id"); + return; + } + + if (!strcmp(block_type, "ipsec")) { + struct rte_swx_ipsec *ipsec; + + ipsec = rte_swx_ipsec_find(block_name); + if (!ipsec) { + snprintf(out, out_size, MSG_ARG_INVALID, "block_name"); + return; + } + + block_func = (block_run_f)rte_swx_ipsec_run; + block = (void *)ipsec; + } else { + snprintf(out, out_size, MSG_ARG_INVALID, "block_type"); + return; + } + + status = block_enable(block_func, block, thread_id); + if (status) { + snprintf(out, out_size, MSG_CMD_FAIL, "block enable"); + return; + } +} + +static const char cmd_block_disable_help[] = +"block type instance disable\n"; + +static void +cmd_block_disable(char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size, + void *obj __rte_unused) +{ + char *block_type, *block_name; + void *block = NULL; + + if (n_tokens != 6) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + if (strcmp(tokens[1], "type") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "type"); + return; + } + + block_type = tokens[2]; + + if (strcmp(tokens[3], "instance") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "instance"); + return; + } + + block_name = tokens[4]; + + if (strcmp(tokens[5], "disable") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable"); + return; + } + + if (!strcmp(block_type, "ipsec")) { + struct rte_swx_ipsec *ipsec; + + ipsec = rte_swx_ipsec_find(block_name); + if (!ipsec) { + snprintf(out, out_size, MSG_ARG_INVALID, "block_name"); + return; + } + + block = (void *)ipsec; + } else { + snprintf(out, out_size, MSG_ARG_INVALID, "block_type"); + return; + } + + block_disable(block); +} + static void cmd_help(char **tokens, uint32_t n_tokens, @@ -3297,6 +3425,8 @@ cmd_help(char **tokens, "\tipsec create\n" "\tipsec sa add\n" "\tipsec sa delete\n" + "\tblock enable\n" + "\tblock disable\n" ); return; } @@ -3552,6 +3682,18 @@ cmd_help(char **tokens, return; } + if (!strcmp(tokens[0], "block") && + (n_tokens == 2) && !strcmp(tokens[1], "enable")) { + snprintf(out, out_size, "\n%s\n", cmd_block_enable_help); + return; + } + + if (!strcmp(tokens[0], "block") && + (n_tokens == 2) && !strcmp(tokens[1], "disable")) { + snprintf(out, out_size, "\n%s\n", cmd_block_disable_help); + return; + } + snprintf(out, out_size, "Invalid command\n"); } @@ -3811,6 +3953,18 @@ cli_process(char *in, char *out, size_t out_size, void *obj) } } + if (!strcmp(tokens[0], "block")) { + if (n_tokens >= 6 && !strcmp(tokens[5], "enable")) { + cmd_block_enable(tokens, n_tokens, out, out_size, obj); + return; + } + + if (n_tokens >= 6 && !strcmp(tokens[5], "disable")) { + cmd_block_disable(tokens, n_tokens, out, out_size, obj); + return; + } + } + snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]); } -- 2.34.1