From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B3DDA00C5; Thu, 11 Jun 2020 08:14:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3DF39397D; Thu, 11 Jun 2020 08:14:34 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 0715E37AF for ; Thu, 11 Jun 2020 08:14:32 +0200 (CEST) IronPort-SDR: d2zHL45PhlxA8geqoJgRVC39qy4QIkz7lR62zJ6Qn9RoQXIceBxW2z6mJrCJsd9kRDKm0Xu6j7 7VcVZsjZ0EjA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2020 23:14:32 -0700 IronPort-SDR: bZuGamcfFEp6c206ewLdStCRZQZlUHWMikOA92IagTjR1WojqazDtf5c4yrRbd6dMsOe6hubF/ zHK0Qg9fBiNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,498,1583222400"; d="scan'208";a="380296460" Received: from intel.sh.intel.com ([10.239.255.20]) by fmsmga001.fm.intel.com with ESMTP; 10 Jun 2020 23:14:30 -0700 From: Chenxu Di To: dev@dpdk.org Cc: beilei.xing@intel.com, Yang Qiming , Chenxu Di Date: Thu, 11 Jun 2020 06:01:40 +0000 Message-Id: <20200611060142.75465-4-chenxux.di@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200611060142.75465-1-chenxux.di@intel.com> References: <20200611060142.75465-1-chenxux.di@intel.com> Subject: [dpdk-dev] [PATCH 3/5] app/testpmd: re-implement commands by using private API 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" The legacy filter API will be superseded. This patch use private api to change the implementation of commands global_config gre-key-len and show port fdir Signed-off-by: Chenxu Di --- app/test-pmd/cmdline.c | 23 ++++++++----- app/test-pmd/config.c | 74 +++++++++++++++++++++++++++++++++++------- 2 files changed, 78 insertions(+), 19 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 996a49876..01d793e89 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -9280,15 +9280,22 @@ cmd_global_config_parsed(void *parsed_result, { struct cmd_global_config_result *res = parsed_result; struct rte_eth_global_cfg conf; - int ret; + int ret = -ENOTSUP; - memset(&conf, 0, sizeof(conf)); - conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; - conf.cfg.gre_key_len = res->len; - ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, - RTE_ETH_FILTER_SET, &conf); - if (ret != 0) - printf("Global config error\n"); +#ifdef RTE_LIBRTE_I40E_PMD + if (ret == -ENOTSUP) + ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len); +#endif + if (ret == -ENOTSUP) { + memset(&conf, 0, sizeof(conf)); + conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; + conf.cfg.gre_key_len = res->len; + ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, + RTE_ETH_FILTER_SET, &conf); + } + + if (ret < 0) + printf("Global config error: (%s)\n", strerror(-ret)); } cmdline_parse_token_string_t cmd_global_config_cmd = diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 016bcb09c..f519246c7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3729,30 +3729,82 @@ print_fdir_flow_type(uint32_t flow_types_mask) printf("\n"); } +static int +get_fdir_info(portid_t port_id, struct rte_eth_fdir_info *fdir_info) +{ + int ret; +#ifdef RTE_LIBRTE_I40E_PMD + ret = rte_pmd_i40e_get_fdir_info(port_id, fdir_info); +#endif +#ifdef RTE_LIBRTE_IXGBE_PMD + if (ret == -ENOTSUP) + ret = rte_pmd_ixgbe_get_fdir_info(port_id, fdir_info); +#endif + if (ret == -ENOTSUP) { + ret = rte_eth_dev_filter_supported(port_id, + RTE_ETH_FILTER_FDIR); + if (ret < 0) { + printf("\n FDIR is not supported on port %-2d\n", + port_id); + return ret; + } + rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR, + RTE_ETH_FILTER_INFO, fdir_info); + } + + if (ret < 0) + printf("Get fdir infos error: (%s)\n", strerror(-ret)); + + return ret; +} + +static int +get_fdir_stat(portid_t port_id, struct rte_eth_fdir_stats *fdir_stat) +{ + int ret; +#ifdef RTE_LIBRTE_I40E_PMD + ret = rte_pmd_i40e_get_fdir_stats(port_id, fdir_stat); +#endif +#ifdef RTE_LIBRTE_IXGBE_PMD + if (ret == -ENOTSUP) + ret = rte_pmd_ixgbe_get_fdir_stats(port_id, fdir_stat); +#endif + if (ret == -ENOTSUP) { + ret = rte_eth_dev_filter_supported(port_id, + RTE_ETH_FILTER_FDIR); + if (ret < 0) { + printf("\n FDIR is not supported on port %-2d\n", + port_id); + return ret; + } + rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR, + RTE_ETH_FILTER_STATS, fdir_stat); + } + + if (ret < 0) + printf("Get fdir infos error: (%s)\n", strerror(-ret)); + + return ret; +} + void fdir_get_infos(portid_t port_id) { struct rte_eth_fdir_stats fdir_stat; struct rte_eth_fdir_info fdir_info; - int ret; static const char *fdir_stats_border = "########################"; if (port_id_is_invalid(port_id, ENABLED_WARN)) return; - ret = rte_eth_dev_filter_supported(port_id, RTE_ETH_FILTER_FDIR); - if (ret < 0) { - printf("\n FDIR is not supported on port %-2d\n", - port_id); - return; - } memset(&fdir_info, 0, sizeof(fdir_info)); - rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR, - RTE_ETH_FILTER_INFO, &fdir_info); + if (get_fdir_info(port_id, &fdir_info)) + return; memset(&fdir_stat, 0, sizeof(fdir_stat)); - rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR, - RTE_ETH_FILTER_STATS, &fdir_stat); + if (get_fdir_stat(port_id, &fdir_stat)) + return; + printf("\n %s FDIR infos for port %-2d %s\n", fdir_stats_border, port_id, fdir_stats_border); printf(" MODE: "); -- 2.17.1