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 3AB4BA0543; Fri, 26 Aug 2022 15:20:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0332342BB3; Fri, 26 Aug 2022 15:18:22 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id CBEF1427FF for ; Fri, 26 Aug 2022 15:18:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661519883; x=1693055883; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bzDdo54vdbceAhYABKHDpT9bbM4mHVsa2fl2Vljflvk=; b=F9c5VzrJ9UWthFu5og6MmAqFIshDLVO1mh/5AUu4iuiYGu6l9jpMo1gM o2IiRfcLOZnbT58jrVtJ1/Ic8WMJpyierFkq77Q0h/nJHCI9XsjapJ3Lp 81Lw1ukGKN2ASXVuwAMmNN+LKqbI4deeW1W+x+dcb8nqWsa6OK45xiiji COWPkK+OhlTI7hA5xpMaMWX7D6KcVRR3o6+bi2jBF9ZNFEFW9K8MlTFUi jPg+BKpiwkkiXuXk9i+93H45Yj1/Q2f1QeACTQSKtrhDBAcOUChGNeecc QFtzUcaZnVS/xPJm/w7On1V0Wf0Y6ezAACTik9Dz8yL876YP96djuUT8j Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="320598612" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="320598612" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 06:17:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="610561689" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by orsmga002.jf.intel.com with ESMTP; 26 Aug 2022 06:17:53 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Yogesh Jangra Subject: [PATCH V2 17/21] net/softnic: add the pipeline register read/write CLI commands Date: Fri, 26 Aug 2022 13:17:33 +0000 Message-Id: <20220826131737.1741743-18-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220826131737.1741743-1-cristian.dumitrescu@intel.com> References: <20220804165839.1074817-1-cristian.dumitrescu@intel.com> <20220826131737.1741743-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 registers read and write operations. Signed-off-by: Cristian Dumitrescu Signed-off-by: Yogesh Jangra --- drivers/net/softnic/rte_eth_softnic_cli.c | 127 ++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 7c25a502ec..b1f7460f47 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -34,6 +34,22 @@ #define MSG_FILE_NOT_ENOUGH "Not enough rules in file \"%s\".\n" #define MSG_CMD_FAIL "Command \"%s\" failed.\n" +static int +parser_read_uint64(uint64_t *value, char *p) +{ + uint64_t val = 0; + + if (!value || !p || !p[0]) + return -EINVAL; + + val = strtoull(p, &p, 0); + if (p[0]) + return -EINVAL; + + *value = val; + return 0; +} + static int parser_read_uint32(uint32_t *value, char *p) { @@ -1403,6 +1419,107 @@ cmd_softnic_pipeline_abort(struct pmd_internals *softnic, rte_swx_ctl_pipeline_abort(p->ctl); } +/** + * pipeline regrd + */ +static void +cmd_softnic_pipeline_regrd(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct pipeline *p; + const char *pipeline_name, *name; + uint64_t value; + uint32_t idx; + int status; + + if (n_tokens != 5) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + pipeline_name = tokens[1]; + p = softnic_pipeline_find(softnic, pipeline_name); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "regrd")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "regrd"); + return; + } + + name = tokens[3]; + + if (parser_read_uint32(&idx, tokens[4])) { + snprintf(out, out_size, MSG_ARG_INVALID, "index"); + return; + } + + status = rte_swx_ctl_pipeline_regarray_read(p->p, name, idx, &value); + if (status) { + snprintf(out, out_size, "Command failed.\n"); + return; + } + + snprintf(out, out_size, "0x%" PRIx64 "\n", value); +} + +/** + * pipeline regwr + */ +static void +cmd_softnic_pipeline_regwr(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct pipeline *p; + const char *pipeline_name, *name; + uint64_t value; + uint32_t idx; + int status; + + if (n_tokens != 6) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + pipeline_name = tokens[1]; + p = softnic_pipeline_find(softnic, pipeline_name); + if (!p) { + snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); + return; + } + + if (strcmp(tokens[2], "regwr")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "regwr"); + return; + } + + name = tokens[3]; + + if (parser_read_uint32(&idx, tokens[4])) { + snprintf(out, out_size, MSG_ARG_INVALID, "index"); + return; + } + + if (parser_read_uint64(&value, tokens[5])) { + snprintf(out, out_size, MSG_ARG_INVALID, "value"); + return; + } + + status = rte_swx_ctl_pipeline_regarray_write(p->p, name, idx, value); + if (status) { + snprintf(out, out_size, "Command failed.\n"); + return; + } +} + /** * thread pipeline enable [ period ] */ @@ -1633,6 +1750,16 @@ softnic_cli_process(char *in, char *out, size_t out_size, void *arg) cmd_softnic_pipeline_abort(softnic, tokens, n_tokens, out, out_size); return; } + + if (n_tokens >= 3 && !strcmp(tokens[2], "regrd")) { + cmd_softnic_pipeline_regrd(softnic, tokens, n_tokens, out, out_size); + return; + } + + if (n_tokens >= 3 && !strcmp(tokens[2], "regwr")) { + cmd_softnic_pipeline_regwr(softnic, tokens, n_tokens, out, out_size); + return; + } } if (strcmp(tokens[0], "thread") == 0) { -- 2.34.1