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

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

Checks

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

Commit Message

Chenxu Di June 11, 2020, 6:01 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 | 23 ++++++++-----
 app/test-pmd/config.c  | 74 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 78 insertions(+), 19 deletions(-)
  

Comments

Kevin Traynor June 16, 2020, 8:12 p.m. UTC | #1
On 11/06/2020 07:01, 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 | 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;

this looks like it won't compile if the RTE_LIBRTE_I40E_PMD is
undefined, you'll need to initialize 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;

Same comment as above

> +#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: ");
>
  
Chenxu Di June 17, 2020, 10:12 a.m. UTC | #2
> -----Original Message-----
> From: Kevin Traynor [mailto:ktraynor@redhat.com]
> Sent: Wednesday, June 17, 2020 4:12 AM
> To: Di, ChenxuX <chenxux.di@intel.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>
> Subject: Re: [dpdk-dev] [PATCH 3/5] app/testpmd: re-implement commands by
> using private API
> 
> On 11/06/2020 07:01, 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 | 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;
> 
> this looks like it won't compile if the RTE_LIBRTE_I40E_PMD is undefined, you'll
> need to initialize ret
> 

Yes, got it, I will fix it in next version patch.

> > +#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;
> 
> Same comment as above
> 

OK

> > +#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: ");
> >
  
Guo, Jia June 30, 2020, 6:20 a.m. UTC | #3
hi, chenxu

On 6/17/2020 6:12 PM, Di, ChenxuX wrote:
>
>> -----Original Message-----
>> From: Kevin Traynor [mailto:ktraynor@redhat.com]
>> Sent: Wednesday, June 17, 2020 4:12 AM
>> To: Di, ChenxuX <chenxux.di@intel.com>; dev@dpdk.org
>> Cc: Xing, Beilei <beilei.xing@intel.com>; Yang, Qiming <qiming.yang@intel.com>
>> Subject: Re: [dpdk-dev] [PATCH 3/5] app/testpmd: re-implement commands by
>> using private API
>>
>> On 11/06/2020 07:01, 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 | 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)


you init ret to be default value and then check if ret to be default 
value, it that need?


>>> +		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;
>> this looks like it won't compile if the RTE_LIBRTE_I40E_PMD is undefined, you'll
>> need to initialize ret
>>
> Yes, got it, I will fix it in next version patch.
>
>>> +#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)


Suggest not init ret to be -ENOTSUP, so this checking of if (ret == 
-ENOTSUP) is no need.


>>> +		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;
>> Same comment as above
>>
> OK
>
>>> +#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)


if (ret) should be enough.


>>> +		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;


Suggest print error log out of the caller but not in the calling, it 
should be better.


>>>   	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: ");
>>>
  

Patch

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: ");