[dpdk-dev] [PATCH v10 18/26] app/testpmd: use VFD APIs on i40e

Wenzhuo Lu wenzhuo.lu at intel.com
Mon Jan 16 06:51:43 CET 2017


The new VF Daemon (VFD) APIs is implemented on i40e. Change
testpmd code to use them, including VF MAC anti-spoofing,
VF VLAN anti-spoofing, TX loopback, VF VLAN strip, VF VLAN
insert.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu at intel.com>
Signed-off-by: Chen Jing D(Mark) <jing.d.chen at intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger at intel.com>
---
 app/test-pmd/Makefile  |   1 +
 app/test-pmd/cmdline.c | 136 ++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 106 insertions(+), 31 deletions(-)

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index 050663a..a1500bb 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -61,6 +61,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += -lrte_pmd_ixgbe
+_LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += -lrte_pmd_i40e
 endif
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4e8b0d8..fdb7cf5 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -91,6 +91,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;
@@ -263,19 +266,19 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set portlist (x[,y]*)\n"
 			"    Set the list of forwarding ports.\n\n"
 
-#ifdef RTE_LIBRTE_IXGBE_PMD
 			"set tx loopback (port_id) (on|off)\n"
 			"    Enable or disable tx loopback.\n\n"
 
+#ifdef RTE_LIBRTE_IXGBE_PMD
 			"set all queues drop (port_id) (on|off)\n"
 			"    Set drop enable bit for all queues.\n\n"
 
 			"set vf split drop (port_id) (vf_id) (on|off)\n"
 			"    Set split drop enable bit for a VF from the PF.\n\n"
+#endif
 
 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
 			"    Set MAC antispoof for a VF from the PF.\n\n"
-#endif
 
 			"vlan set strip (on|off) (port_id)\n"
 			"    Set the VLAN strip on a port.\n\n"
@@ -283,7 +286,6 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"vlan set stripq (on|off) (port_id,queue_id)\n"
 			"    Set the VLAN strip for a queue on a port.\n\n"
 
-#ifdef RTE_LIBRTE_IXGBE_PMD
 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
 
@@ -292,7 +294,6 @@ static void cmd_help_long_parsed(void *parsed_result,
 
 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
 			"    Set VLAN antispoof for a VF from the PF.\n\n"
-#endif
 
 			"vlan set filter (on|off) (port_id)\n"
 			"    Set the VLAN filter on a port.\n\n"
@@ -387,10 +388,8 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
 			"    Add a MAC address for a VF on the port.\n\n"
 
-#ifdef RTE_LIBRTE_IXGBE_PMD
 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
 			"    Set the MAC address for a VF from the PF.\n\n"
-#endif
 
 			"set port (port_id) uta (mac_address|all) (on|off)\n"
 			"    Add/Remove a or all unicast hash filter(s)"
@@ -6703,9 +6702,7 @@ struct cmd_set_vf_traffic {
 		NULL,
 	},
 };
-#endif
 
-#ifdef RTE_LIBRTE_IXGBE_PMD
 /* *** CONFIGURE VF RECEIVE MODE *** */
 struct cmd_set_vf_rxmode {
 	cmdline_fixed_string_t set;
@@ -10839,7 +10836,6 @@ struct cmd_config_e_tag_result {
 		NULL,
 	},
 };
-#ifdef RTE_LIBRTE_IXGBE_PMD
 
 /* vf vlan anti spoof configuration */
 
@@ -10891,11 +10887,21 @@ struct cmd_vf_vlan_anti_spoof_result {
 	__attribute__((unused)) void *data)
 {
 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
-	int ret = 0;
-	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	int ret = -ENOTSUP;
+
+	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
+				res->vf_id, is_on);
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
+				res->vf_id, is_on);
+#endif
 
-	ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
-			is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -10905,6 +10911,9 @@ struct cmd_vf_vlan_anti_spoof_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOTSUP:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -10976,11 +10985,21 @@ struct cmd_vf_mac_anti_spoof_result {
 	__attribute__((unused)) void *data)
 {
 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
-	int ret;
-	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	int ret = -ENOTSUP;
+
+	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
+			res->vf_id, is_on);
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
+			res->vf_id, is_on);
+#endif
 
-	ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
-			is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -10990,6 +11009,9 @@ struct cmd_vf_mac_anti_spoof_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOTSUP:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -11061,10 +11083,21 @@ struct cmd_vf_vlan_stripq_result {
 	__attribute__((unused)) void *data)
 {
 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
-	int ret = 0;
-	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	int ret = -ENOTSUP;
+
+	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
+			res->vf_id, is_on);
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
+			res->vf_id, is_on);
+#endif
 
-	ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -11145,9 +11178,19 @@ struct cmd_vf_vlan_insert_result {
 	__attribute__((unused)) void *data)
 {
 	struct cmd_vf_vlan_insert_result *res = parsed_result;
-	int ret;
+	int ret = -ENOTSUP;
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
+			res->vlan_id);
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
+			res->vlan_id);
+#endif
 
-	ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
 	switch (ret) {
 	case 0:
 		break;
@@ -11157,6 +11200,9 @@ struct cmd_vf_vlan_insert_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOTSUP:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -11218,10 +11264,19 @@ struct cmd_tx_loopback_result {
 	__attribute__((unused)) void *data)
 {
 	struct cmd_tx_loopback_result *res = parsed_result;
-	int ret;
-	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+	int ret = -ENOTSUP;
+
+	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
+#endif
 
-	ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
 	switch (ret) {
 	case 0:
 		break;
@@ -11231,6 +11286,9 @@ struct cmd_tx_loopback_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOTSUP:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -11250,6 +11308,7 @@ struct cmd_tx_loopback_result {
 	},
 };
 
+#ifdef RTE_LIBRTE_IXGBE_PMD
 /* all queues drop enable configuration */
 
 /* Common result structure for all queues drop enable */
@@ -11308,6 +11367,9 @@ struct cmd_all_queues_drop_en_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOTSUP:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -11412,6 +11474,7 @@ struct cmd_vf_split_drop_en_result {
 		NULL,
 	},
 };
+#endif
 
 /* vf mac address configuration */
 
@@ -11463,10 +11526,19 @@ struct cmd_set_vf_mac_addr_result {
 	__attribute__((unused)) void *data)
 {
 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
-	int ret;
+	int ret = -ENOTSUP;
+
+#ifdef RTE_LIBRTE_IXGBE_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
+				&res->mac_addr);
+#endif
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
+				&res->mac_addr);
+#endif
 
-	ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
-			&res->mac_addr);
 	switch (ret) {
 	case 0:
 		break;
@@ -11476,6 +11548,9 @@ struct cmd_set_vf_mac_addr_result {
 	case -ENODEV:
 		printf("invalid port_id %d\n", res->port_id);
 		break;
+	case -ENOTSUP:
+		printf("function not implemented\n");
+		break;
 	default:
 		printf("programming error: (%s)\n", strerror(-ret));
 	}
@@ -11496,7 +11571,6 @@ struct cmd_set_vf_mac_addr_result {
 		NULL,
 	},
 };
-#endif
 
 /* ******************************************************************************** */
 
@@ -11651,20 +11725,20 @@ struct cmd_set_vf_mac_addr_result {
 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
-#ifdef RTE_LIBRTE_IXGBE_PMD
 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
+#ifdef RTE_LIBRTE_IXGBE_PMD
 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
-	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
 #endif
+	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
 	NULL,
 };
 
-- 
1.9.3



More information about the dev mailing list