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 DD407A00C4; Thu, 28 Jul 2022 00:55:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D26E42BAB; Thu, 28 Jul 2022 00:54:46 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id BA4FB4284D for ; Thu, 28 Jul 2022 00:54:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962482; x=1690498482; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JszzWG6YpTg73IuGcweOO4hXjXzQIxz92sm+yet532g=; b=N9X0ppuiYajhm11upsMpKOVRSh2y00W4FWLUorImK+KnD3q34RSN4YE9 70cWF+jS+gWRY8UHbQ+Od7xfcwYLAY/ocNcheUQNTw3VyaEVVGnzPkTpf K3JK5fGpFpwNdV0LOsVrJWgoz+JXx2iYA9AmWvdsHRkxZ2RYyCUgpLHha xUqJZ0iW6BnFDmCijLl3ePKRF6v50kxJb4g8CbxBUrF728MTQ3+BAzQ8Q NFG6ztrVtJrP2volMlbC1TaLrlAUsF7Ok+zNGwGcuXcdg5p3xNjrpMaoA ZmmZk7A4kp1ztCmtoyuetE6zZ1I1CXCiLxouhUsmziQcjVqiPmrE1aZv5 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="285912178" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="285912178" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 15:54:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="628572598" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by orsmga008.jf.intel.com with ESMTP; 27 Jul 2022 15:54:41 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V4 09/17] examples/pipeline: add CLI command for pipeline code generation Date: Wed, 27 Jul 2022 22:54:23 +0000 Message-Id: <20220727225431.600913-9-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727225431.600913-1-cristian.dumitrescu@intel.com> References: <20220727223639.598932-1-cristian.dumitrescu@intel.com> <20220727225431.600913-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 command for the pipeline code generation operation. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index f0285675b3..2b38977be1 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -983,6 +983,53 @@ cmd_pipeline_port_out(char **tokens, } } +static const char cmd_pipeline_codegen_help[] = +"pipeline codegen \n"; + +static void +cmd_pipeline_codegen(char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size, + void *obj __rte_unused) +{ + FILE *spec_file = NULL; + FILE *code_file = NULL; + uint32_t err_line; + const char *err_msg; + int status; + + if (n_tokens != 4) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + spec_file = fopen(tokens[2], "r"); + if (!spec_file) { + snprintf(out, out_size, "Cannot open file %s.\n", tokens[2]); + return; + } + + code_file = fopen(tokens[3], "w"); + if (!code_file) { + snprintf(out, out_size, "Cannot open file %s.\n", tokens[3]); + return; + } + + status = rte_swx_pipeline_codegen(spec_file, + code_file, + &err_line, + &err_msg); + + fclose(spec_file); + fclose(code_file); + + if (status) { + snprintf(out, out_size, "Error %d at line %u: %s\n.", + status, err_line, err_msg); + return; + } +} static const char cmd_pipeline_build_help[] = "pipeline build lib io numa \n"; @@ -3009,6 +3056,7 @@ cmd_help(char **tokens, "\tpipeline create\n" "\tpipeline port in\n" "\tpipeline port out\n" + "\tpipeline codegen\n" "\tpipeline build\n" "\tpipeline table add\n" "\tpipeline table delete\n" @@ -3078,6 +3126,12 @@ cmd_help(char **tokens, } } + if ((strcmp(tokens[0], "pipeline") == 0) && + (n_tokens == 2) && (strcmp(tokens[1], "codegen") == 0)) { + snprintf(out, out_size, "\n%s\n", cmd_pipeline_codegen_help); + return; + } + if ((strcmp(tokens[0], "pipeline") == 0) && (n_tokens == 2) && (strcmp(tokens[1], "build") == 0)) { snprintf(out, out_size, "\n%s\n", cmd_pipeline_build_help); @@ -3356,6 +3410,13 @@ cli_process(char *in, char *out, size_t out_size, void *obj) return; } + if ((n_tokens >= 3) && + (strcmp(tokens[1], "codegen") == 0)) { + cmd_pipeline_codegen(tokens, n_tokens, out, out_size, + obj); + return; + } + if ((n_tokens >= 3) && (strcmp(tokens[2], "build") == 0)) { cmd_pipeline_build(tokens, n_tokens, out, out_size, -- 2.34.1