[v3,3/5] app/testpmd: re-implement commands by using private API

Message ID 20200701082451.34511-4-chenxux.di@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series re-implement legacy filter functions by private API |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Chenxu Di July 1, 2020, 8:24 a.m. UTC
  The legacy filter API will be superseded. This patch use
private api to change the implementation of commands
global_config <port_id> gre-key-len <key_len> and
show port fdir <port_id>

Signed-off-by: Chenxu Di <chenxux.di@intel.com>
---
 app/test-pmd/cmdline.c |  6 ++++
 app/test-pmd/config.c  | 65 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 61 insertions(+), 10 deletions(-)
  

Comments

Guo, Jia July 3, 2020, 5:54 a.m. UTC | #1
hi, chenxu

Please use --in-relpy-to  next time to help reviewers check all relevant 
comments,

and some minor comment, after fix it you could bring my ACK in the 
coming version, thanks.

On 7/1/2020 4:24 PM, Chenxu Di wrote:
> The legacy filter API will be superseded. This patch use
> private api to change the implementation of commands
> global_config <port_id> gre-key-len <key_len> and
> show port fdir <port_id>
>
> Signed-off-by: Chenxu Di <chenxux.di@intel.com>
> ---
>   app/test-pmd/cmdline.c |  6 ++++
>   app/test-pmd/config.c  | 65 +++++++++++++++++++++++++++++++++++-------
>   2 files changed, 61 insertions(+), 10 deletions(-)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 996a49876..466c54aa9 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -9287,6 +9287,12 @@ cmd_global_config_parsed(void *parsed_result,
>   	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);
> +


This blank line is no need.


> +#ifdef RTE_LIBRTE_I40E_PMD
> +	if (ret == -ENOTSUP)
> +		ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
> +#endif
> +


This blank line is also no need, since if the above macro is no defined, 
there will be two blank lines here.


>   	if (ret != 0)
>   		printf("Global config error\n");
>   }
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index a7112c998..ed341c715 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -3727,6 +3727,50 @@ 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;
> +
> +	ret = rte_eth_dev_filter_supported(port_id,
> +					   RTE_ETH_FILTER_FDIR);
> +	if (!ret)
> +		rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
> +					RTE_ETH_FILTER_INFO, fdir_info);
> +
> +#ifdef RTE_LIBRTE_I40E_PMD
> +	if (ret == -ENOTSUP)
> +		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
> +	return ret;
> +}
> +
> +static int
> +get_fdir_stat(portid_t port_id, struct rte_eth_fdir_stats *fdir_stat)
> +{
> +	int ret;
> +
> +	ret = rte_eth_dev_filter_supported(port_id,
> +					   RTE_ETH_FILTER_FDIR);
> +	if (!ret)
> +		rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
> +					RTE_ETH_FILTER_STATS, fdir_stat);
> +
> +#ifdef RTE_LIBRTE_I40E_PMD
> +	if (ret == -ENOTSUP)
> +		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
> +	return ret;
> +}
> +
>   void
>   fdir_get_infos(portid_t port_id)
>   {
> @@ -3738,19 +3782,20 @@ fdir_get_infos(portid_t port_id)
>   
>   	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);
> +	ret = get_fdir_info(port_id, &fdir_info);
> +	if (ret) {
> +		printf("Get fdir infos error: (%s)\n", strerror(-ret));
> +		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);
> +	ret = get_fdir_stat(port_id, &fdir_stat);
> +	if (ret) {
> +		printf("Get fdir status error: (%s)\n", strerror(-ret));
> +		return;
> +	}
> +
>   	printf("\n  %s FDIR infos for port %-2d     %s\n",
>   	       fdir_stats_border, port_id, fdir_stats_border);
>   	printf("  MODE: ");
  
Qiming Yang July 6, 2020, 9:10 a.m. UTC | #2
> -----Original Message-----
> From: Di, ChenxuX <chenxux.di@intel.com>
> Sent: Wednesday, July 1, 2020 16:25
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Guo, Jia <jia.guo@intel.com>; Di,
> ChenxuX <chenxux.di@intel.com>
> Subject: [PATCH v3 3/5] app/testpmd: re-implement commands by using
> private API
> 
> The legacy filter API will be superseded. This patch use private api to change
> the implementation of commands global_config <port_id> gre-key-len
> <key_len> and show port fdir <port_id>
> 
> Signed-off-by: Chenxu Di <chenxux.di@intel.com>
> ---
>  app/test-pmd/cmdline.c |  6 ++++
>  app/test-pmd/config.c  | 65 +++++++++++++++++++++++++++++++++++---
> ----
>  2 files changed, 61 insertions(+), 10 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> 996a49876..466c54aa9 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -9287,6 +9287,12 @@ cmd_global_config_parsed(void *parsed_result,
>  	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);
> +
> +#ifdef RTE_LIBRTE_I40E_PMD
> +	if (ret == -ENOTSUP)
> +		ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res-
> >len); #endif
> +
>  	if (ret != 0)
>  		printf("Global config error\n");
>  }
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> a7112c998..ed341c715 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -3727,6 +3727,50 @@ 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;
> +
> +	ret = rte_eth_dev_filter_supported(port_id,
> +					   RTE_ETH_FILTER_FDIR);
> +	if (!ret)
> +		rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
> +					RTE_ETH_FILTER_INFO, fdir_info);
> +
> +#ifdef RTE_LIBRTE_I40E_PMD
> +	if (ret == -ENOTSUP)
> +		ret = rte_pmd_i40e_get_fdir_info(port_id, fdir_info); #endif

No return value check.

> #ifdef
> +RTE_LIBRTE_IXGBE_PMD
> +	if (ret == -ENOTSUP)
> +		ret = rte_pmd_ixgbe_get_fdir_info(port_id, fdir_info);
> #endif

We'd better use
If(ret == -ENOTSUP)
#ifdef RTE_LIBRTE_I40E_PMD
...
#endif
#ifdef RTE_LIBRTE_IXGBE_PMD
...
#endif

Same issue in patch 5

> +	return ret;
> +}
> +
> +static int
> +get_fdir_stat(portid_t port_id, struct rte_eth_fdir_stats *fdir_stat) {
> +	int ret;
> +
> +	ret = rte_eth_dev_filter_supported(port_id,
> +					   RTE_ETH_FILTER_FDIR);
> +	if (!ret)
> +		rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
> +					RTE_ETH_FILTER_STATS, fdir_stat);
> +
> +#ifdef RTE_LIBRTE_I40E_PMD
> +	if (ret == -ENOTSUP)
> +		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

Same as above

> +	return ret;
> +}
> +
>  void
>  fdir_get_infos(portid_t port_id)
>  {
> @@ -3738,19 +3782,20 @@ fdir_get_infos(portid_t port_id)
> 
>  	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);
> +	ret = get_fdir_info(port_id, &fdir_info);
> +	if (ret) {
> +		printf("Get fdir infos error: (%s)\n", strerror(-ret));
> +		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);
> +	ret = get_fdir_stat(port_id, &fdir_stat);

Why you add new function here, it's no need to do that

> +	if (ret) {
> +		printf("Get fdir status error: (%s)\n", strerror(-ret));
> +		return;
> +	}
> +
>  	printf("\n  %s FDIR infos for port %-2d     %s\n",
>  	       fdir_stats_border, port_id, fdir_stats_border);
>  	printf("  MODE: ");
> --
> 2.17.1
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 996a49876..466c54aa9 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -9287,6 +9287,12 @@  cmd_global_config_parsed(void *parsed_result,
 	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);
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
+#endif
+
 	if (ret != 0)
 		printf("Global config error\n");
 }
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a7112c998..ed341c715 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3727,6 +3727,50 @@  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;
+
+	ret = rte_eth_dev_filter_supported(port_id,
+					   RTE_ETH_FILTER_FDIR);
+	if (!ret)
+		rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
+					RTE_ETH_FILTER_INFO, fdir_info);
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		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
+	return ret;
+}
+
+static int
+get_fdir_stat(portid_t port_id, struct rte_eth_fdir_stats *fdir_stat)
+{
+	int ret;
+
+	ret = rte_eth_dev_filter_supported(port_id,
+					   RTE_ETH_FILTER_FDIR);
+	if (!ret)
+		rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
+					RTE_ETH_FILTER_STATS, fdir_stat);
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		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
+	return ret;
+}
+
 void
 fdir_get_infos(portid_t port_id)
 {
@@ -3738,19 +3782,20 @@  fdir_get_infos(portid_t port_id)
 
 	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);
+	ret = get_fdir_info(port_id, &fdir_info);
+	if (ret) {
+		printf("Get fdir infos error: (%s)\n", strerror(-ret));
+		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);
+	ret = get_fdir_stat(port_id, &fdir_stat);
+	if (ret) {
+		printf("Get fdir status error: (%s)\n", strerror(-ret));
+		return;
+	}
+
 	printf("\n  %s FDIR infos for port %-2d     %s\n",
 	       fdir_stats_border, port_id, fdir_stats_border);
 	printf("  MODE: ");