[dpdk-dev,20/31] app/testpmd: use VFD APIs on i40e

Message ID 1480637533-37425-21-git-send-email-wenzhuo.lu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
checkpatch/checkpatch warning coding style issues

Commit Message

Wenzhuo Lu Dec. 2, 2016, 12:12 a.m. UTC
  The new VF Daemon (VFD) APIs is implemented on i40e. Change
testpmd code to use them, inlcuding VF MAC anti-spoofing,
VF VLAN anti-spoofing, TX loopback, VF VLAN strip, VF VLAN
insert.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/cmdline.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 85 insertions(+), 7 deletions(-)
  

Comments

Ferruh Yigit Dec. 13, 2016, 4:57 p.m. UTC | #1
On 12/2/2016 12:12 AM, Wenzhuo Lu wrote:
> The new VF Daemon (VFD) APIs is implemented on i40e. Change
> testpmd code to use them, inlcuding VF MAC anti-spoofing,
> VF VLAN anti-spoofing, TX loopback, VF VLAN strip, VF VLAN
> insert.
> 
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  app/test-pmd/cmdline.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 85 insertions(+), 7 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 63b55dc..1284d6c 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
<...>
> @@ -11059,8 +11109,20 @@ struct cmd_vf_vlan_insert_result {
>  {
>  	struct cmd_vf_vlan_insert_result *res = parsed_result;
>  	int ret;
> +	struct rte_eth_dev_info dev_info;
> +
> +	memset(&dev_info, 0, sizeof(dev_info));
> +	rte_eth_dev_info_get(res->port_id, &dev_info);
> +
> +	if (strstr(dev_info.driver_name, "ixgbe") != NULL)
> +		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
> +						       res->vlan_id);
> +	else if (strstr(dev_info.driver_name, "i40e") != NULL)
> +		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
> +						      res->vlan_id);

This code is within "#ifdef RTE_LIBRTE_IXGBE_PMD", so i40e check can
fail if IXGBE_PMD disabled, need to update surrounding ifdef.

Same for rest.

<...>
  
Wenzhuo Lu Dec. 14, 2016, 12:44 a.m. UTC | #2
Hi Ferruh,


> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, December 14, 2016 12:57 AM
> To: Lu, Wenzhuo; dev@dpdk.org
> Cc: Chen, Jing D; Iremonger, Bernard
> Subject: Re: [dpdk-dev] [PATCH 20/31] app/testpmd: use VFD APIs on i40e
> 
> On 12/2/2016 12:12 AM, Wenzhuo Lu wrote:
> > The new VF Daemon (VFD) APIs is implemented on i40e. Change testpmd
> > code to use them, inlcuding VF MAC anti-spoofing, VF VLAN
> > anti-spoofing, TX loopback, VF VLAN strip, VF VLAN insert.
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> >  app/test-pmd/cmdline.c | 92
> > ++++++++++++++++++++++++++++++++++++++++++++++----
> >  1 file changed, 85 insertions(+), 7 deletions(-)
> >
> > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> > 63b55dc..1284d6c 100644
> > --- a/app/test-pmd/cmdline.c
> > +++ b/app/test-pmd/cmdline.c
> <...>
> > @@ -11059,8 +11109,20 @@ struct cmd_vf_vlan_insert_result {  {
> >  	struct cmd_vf_vlan_insert_result *res = parsed_result;
> >  	int ret;
> > +	struct rte_eth_dev_info dev_info;
> > +
> > +	memset(&dev_info, 0, sizeof(dev_info));
> > +	rte_eth_dev_info_get(res->port_id, &dev_info);
> > +
> > +	if (strstr(dev_info.driver_name, "ixgbe") != NULL)
> > +		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
> > +						       res->vlan_id);
> > +	else if (strstr(dev_info.driver_name, "i40e") != NULL)
> > +		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
> > +						      res->vlan_id);
> 
> This code is within "#ifdef RTE_LIBRTE_IXGBE_PMD", so i40e check can fail if
> IXGBE_PMD disabled, need to update surrounding ifdef.
> 
> Same for rest.
Yes, will handle it. Thanks.

> 
> <...>
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 63b55dc..1284d6c 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -90,6 +90,9 @@ 
 #ifdef RTE_LIBRTE_IXGBE_PMD
 #include <rte_pmd_ixgbe.h>
 #endif
+#ifdef RTE_LIBRTE_I40E_PMD
+#include <rte_pmd_i40e.h>
+#endif
 #include "testpmd.h"
 
 static struct cmdline *testpmd_cl;
@@ -10806,9 +10809,22 @@  struct cmd_vf_vlan_anti_spoof_result {
 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
 	int ret = 0;
 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	struct rte_eth_dev_info dev_info;
+
+	memset(&dev_info, 0, sizeof(dev_info));
+	rte_eth_dev_info_get(res->port_id, &dev_info);
+
+	if (strstr(dev_info.driver_name, "ixgbe") != NULL)
+		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
+							   res->vf_id,
+							   is_on);
+	else if (strstr(dev_info.driver_name, "i40e") != NULL)
+		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
+							  res->vf_id,
+							  is_on);
+	else
+		ret = -ENOSYS;
 
-	ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
-			is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -10818,6 +10834,9 @@  struct cmd_vf_vlan_anti_spoof_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOSYS:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -10891,9 +10910,22 @@  struct cmd_vf_mac_anti_spoof_result {
 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
 	int ret;
 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	struct rte_eth_dev_info dev_info;
+
+	memset(&dev_info, 0, sizeof(dev_info));
+	rte_eth_dev_info_get(res->port_id, &dev_info);
+
+	if (strstr(dev_info.driver_name, "ixgbe") != NULL)
+		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
+							  res->vf_id,
+							  is_on);
+	else if (strstr(dev_info.driver_name, "i40e") != NULL)
+		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
+							 res->vf_id,
+							 is_on);
+	else
+		ret = -ENOSYS;
 
-	ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
-			is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -10903,6 +10935,9 @@  struct cmd_vf_mac_anti_spoof_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOSYS:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -10976,8 +11011,20 @@  struct cmd_vf_vlan_stripq_result {
 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
 	int ret = 0;
 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	struct rte_eth_dev_info dev_info;
+
+	memset(&dev_info, 0, sizeof(dev_info));
+	rte_eth_dev_info_get(res->port_id, &dev_info);
+
+	if (strstr(dev_info.driver_name, "ixgbe") != NULL)
+		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
+						       res->vf_id, is_on);
+	else if (strstr(dev_info.driver_name, "i40e") != NULL)
+		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
+						      res->vf_id, is_on);
+	else
+		ret = -ENOSYS;
 
-	ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -10987,6 +11034,9 @@  struct cmd_vf_vlan_stripq_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOSYS:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -11059,8 +11109,20 @@  struct cmd_vf_vlan_insert_result {
 {
 	struct cmd_vf_vlan_insert_result *res = parsed_result;
 	int ret;
+	struct rte_eth_dev_info dev_info;
+
+	memset(&dev_info, 0, sizeof(dev_info));
+	rte_eth_dev_info_get(res->port_id, &dev_info);
+
+	if (strstr(dev_info.driver_name, "ixgbe") != NULL)
+		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
+						       res->vlan_id);
+	else if (strstr(dev_info.driver_name, "i40e") != NULL)
+		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
+						      res->vlan_id);
+	else
+		ret = -ENOSYS;
 
-	ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
 	switch (ret) {
 	case 0:
 		break;
@@ -11070,6 +11132,9 @@  struct cmd_vf_vlan_insert_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOSYS:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -11133,8 +11198,18 @@  struct cmd_tx_loopback_result {
 	struct cmd_tx_loopback_result *res = parsed_result;
 	int ret;
 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	struct rte_eth_dev_info dev_info;
+
+	memset(&dev_info, 0, sizeof(dev_info));
+	rte_eth_dev_info_get(res->port_id, &dev_info);
+
+	if (strstr(dev_info.driver_name, "ixgbe") != NULL)
+		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
+	else if (strstr(dev_info.driver_name, "i40e") != NULL)
+		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
+	else
+		ret = -ENOSYS;
 
-	ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -11144,6 +11219,9 @@  struct cmd_tx_loopback_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOSYS:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}