[dpdk-dev,v2,5/9] app/testpmd: add command for set VF transmit
diff mbox

Message ID 1481304361-16032-6-git-send-email-bernard.iremonger@intel.com
State Superseded, archived
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bernard Iremonger Dec. 9, 2016, 5:25 p.m. UTC
add the following command to testpmd:

set vf tx <port_id> <vf_id> on|off

add command to the testpmd user guide.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/cmdline.c                      | 85 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  7 +++
 2 files changed, 92 insertions(+)

Patch
diff mbox

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4424c0a..e385732 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -277,6 +277,9 @@  static void cmd_help_long_parsed(void *parsed_result,
 
 			"set vf rx (port_id) (vf_id) (on|off).\n"
 			"    Enable or disable RX for a VF from the PF.\n\n"
+
+			"set vf tx (port_id) (vf_id) (on|off).\n"
+			"    Enable or disable TX for a VF from the PF.\n\n"
 #endif
 
 			"vlan set strip (on|off) (port_id)\n"
@@ -11320,6 +11323,87 @@  cmdline_parse_inst_t cmd_set_vf_rx = {
 	},
 };
 
+/* vf tx configuration */
+
+/* Common result structure for vf tx */
+struct cmd_vf_tx_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t vf;
+	cmdline_fixed_string_t tx;
+	uint8_t port_id;
+	uint16_t vf_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf tx enable disable */
+cmdline_parse_token_string_t cmd_vf_tx_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_tx_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_vf_tx_vf =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_tx_result,
+		 vf, "vf");
+cmdline_parse_token_string_t cmd_vf_tx_tx =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_tx_result,
+		 tx, "tx");
+cmdline_parse_token_num_t cmd_vf_tx_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_tx_result,
+		 port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_tx_vf_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_tx_result,
+		 vf_id, UINT16);
+cmdline_parse_token_string_t cmd_vf_tx_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_tx_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_vf_tx_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_vf_tx_result *res = parsed_result;
+	int ret = 0;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_pmd_ixgbe_set_vf_tx(res->port_id, res->vf_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	case -ENOTSUP:
+		printf("not supported on vf port %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_vf_tx = {
+	.f = cmd_set_vf_tx_parsed,
+	.data = NULL,
+	.help_str = "set vf tx <port_id> <vf_id> on|off",
+	.tokens = {
+		(void *)&cmd_vf_tx_set,
+		(void *)&cmd_vf_tx_vf,
+		(void *)&cmd_vf_tx_tx,
+		(void *)&cmd_vf_tx_port_id,
+		(void *)&cmd_vf_tx_vf_id,
+		(void *)&cmd_vf_tx_on_off,
+		NULL,
+	},
+};
+
 /* tx loopback configuration */
 
 /* Common result structure for tx loopback */
@@ -11807,6 +11891,7 @@  cmdline_parse_ctx_t main_ctx[] = {
 	(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_rx,
+	(cmdline_parse_inst_t *)&cmd_set_vf_tx,
 #endif
 	NULL,
 };
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 6a058e9..1de4c5f 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -514,6 +514,13 @@  Enable/disable rx for a VF from the PF::
 
    testpmd> set vf rx (port_id) (vf_id) (on|off)
 
+set tx (for VF)
+~~~~~~~~~~~~~~~
+
+Enable/disable tx for a VF from the PF::
+
+   testpmd> set vf tx (port_id) (vf_id) (on|off)
+
 vlan set strip
 ~~~~~~~~~~~~~~