From patchwork Wed Mar 29 14:44:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xing, Beilei" X-Patchwork-Id: 22715 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 376DFF60C; Wed, 29 Mar 2017 17:06:36 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 9AD4637AC for ; Wed, 29 Mar 2017 16:45:20 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP; 29 Mar 2017 07:45:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,241,1486454400"; d="scan'208";a="71600698" Received: from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31]) by orsmga004.jf.intel.com with ESMTP; 29 Mar 2017 07:45:19 -0700 From: Beilei Xing To: jingjing.wu@intel.com Cc: helin.zhang@intel.com, dev@dpdk.org Date: Wed, 29 Mar 2017 22:44:10 +0800 Message-Id: <1490798651-116457-6-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1490798651-116457-1-git-send-email-beilei.xing@intel.com> References: <1490790397-81848-1-git-send-email-beilei.xing@intel.com> <1490798651-116457-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH v7 5/6] app/testpmd: add command for getting loaded profiles X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch is to add testpmd CLI for getting all loaded profiles. Signed-off-by: Beilei Xing --- app/test-pmd/cmdline.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 42d0b24..0b47692 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -214,6 +214,9 @@ static void cmd_help_long_parsed(void *parsed_result, "read txd (port_id) (queue_id) (txd_id)\n" " Display a TX descriptor of a port TX queue.\n\n" + + "get ddp list (port_id)\n" + " Get ddp profile info list\n\n" ); } @@ -12812,6 +12815,93 @@ cmdline_parse_inst_t cmd_add_ddp = { }, }; +/* Get Dynamic Device Profile list*/ +#define PROFILE_INFO_SIZE 48 +#define MAX_PROFILE_NUM 16 + +struct cmd_get_ddp_list_result { + cmdline_fixed_string_t get; + cmdline_fixed_string_t ddp; + cmdline_fixed_string_t list; + uint8_t port_id; +}; + +cmdline_parse_token_string_t cmd_get_ddp_list_get = + TOKEN_STRING_INITIALIZER(struct cmd_get_ddp_list_result, get, "get"); +cmdline_parse_token_string_t cmd_get_ddp_list_ddp = + TOKEN_STRING_INITIALIZER(struct cmd_get_ddp_list_result, ddp, "ddp"); +cmdline_parse_token_string_t cmd_get_ddp_list_list = + TOKEN_STRING_INITIALIZER(struct cmd_get_ddp_list_result, list, "list"); +cmdline_parse_token_num_t cmd_get_ddp_list_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_get_ddp_list_result, port_id, UINT8); + +static void +cmd_get_ddp_list_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_get_ddp_list_result *res = parsed_result; +#ifdef RTE_LIBRTE_I40E_PMD + struct rte_pmd_i40e_profile_list *p_list; + struct rte_pmd_i40e_profile_info *p_info; + uint32_t p_num; + uint32_t size; + uint32_t i; +#endif + int ret = -ENOTSUP; + + if (res->port_id > nb_ports) { + printf("Invalid port, range is [0, %d]\n", nb_ports - 1); + return; + } + +#ifdef RTE_LIBRTE_I40E_PMD + size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; + p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); + if (!p_list) + printf("%s: Failed to malloc buffer\n", __func__); + + if (ret == -ENOTSUP) + ret = rte_pmd_i40e_get_ddp_list(res->port_id, + (uint8_t *)p_list, size); + + if (!ret) { + p_num = p_list->p_count; + printf("Profile number is: %d\n\n", p_num); + + for (i = 0; i < p_num; i++) { + p_info = &p_list->p_info[i]; + printf("Profile %d:\n", i); + printf("Track id: 0x%x\n", p_info->track_id); + printf("Version: %d.%d.%d.%d \n", + p_info->version.major, + p_info->version.minor, + p_info->version.update, + p_info->version.draft); + printf("Profile name: %s\n\n", p_info->name); + } + } + + free(p_list); +#endif + + if (ret < 0) + printf("Failed to get ddp list\n"); +} + +cmdline_parse_inst_t cmd_get_ddp_list = { + .f = cmd_get_ddp_list_parsed, + .data = NULL, + .help_str = "get ddp list ", + .tokens = { + (void *)&cmd_get_ddp_list_get, + (void *)&cmd_get_ddp_list_ddp, + (void *)&cmd_get_ddp_list_list, + (void *)&cmd_get_ddp_list_port_id, + NULL, + }, +}; /* ******************************************************************************** */ /* list of instructions */ @@ -12992,6 +13082,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, (cmdline_parse_inst_t *)&cmd_strict_link_prio, (cmdline_parse_inst_t *)&cmd_add_ddp, + (cmdline_parse_inst_t *)&cmd_get_ddp_list, NULL, };