From patchwork Fri Dec 9 17:25:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iremonger, Bernard" X-Patchwork-Id: 17820 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3E1775679; Fri, 9 Dec 2016 18:26:41 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 49A302E83 for ; Fri, 9 Dec 2016 18:26:18 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP; 09 Dec 2016 09:26:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.33,324,1477983600"; d="scan'208"; a="1070136266" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga001.jf.intel.com with ESMTP; 09 Dec 2016 09:26:16 -0800 From: Bernard Iremonger To: thomas.monjalon@6wind.com, dev@dpdk.org Cc: Bernard Iremonger Date: Fri, 9 Dec 2016 17:25:56 +0000 Message-Id: <1481304361-16032-5-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1481282878-26176-1-git-send-email-bernard.iremonger@intel.com> References: <1481282878-26176-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [PATCH v2 4/9] app/testpmd: add command for set VF receive X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" add the following command to testpmd: set vf rx on|off add command to the testpmd user guide. Signed-off-by: Bernard Iremonger --- app/test-pmd/cmdline.c | 85 +++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ 2 files changed, 92 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 947c698..4424c0a 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -274,6 +274,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set vf mac antispoof (port_id) (vf_id) (on|off).\n" " Set MAC antispoof for a VF from the PF.\n\n" + + "set vf rx (port_id) (vf_id) (on|off).\n" + " Enable or disable RX for a VF from the PF.\n\n" #endif "vlan set strip (on|off) (port_id)\n" @@ -11236,6 +11239,87 @@ cmdline_parse_inst_t cmd_set_vf_vlan_filter = { }, }; +/* vf rx configuration */ + +/* Common result structure for vf rx */ +struct cmd_vf_rx_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t vf; + cmdline_fixed_string_t rx; + uint8_t port_id; + uint16_t vf_id; + cmdline_fixed_string_t on_off; +}; + +/* Common CLI fields for vf rx enable disable */ +cmdline_parse_token_string_t cmd_vf_rx_set = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + set, "set"); +cmdline_parse_token_string_t cmd_vf_rx_vf = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + vf, "vf"); +cmdline_parse_token_string_t cmd_vf_rx_rx = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + rx, "rx"); +cmdline_parse_token_num_t cmd_vf_rx_port_id = + TOKEN_NUM_INITIALIZER + (struct cmd_vf_rx_result, + port_id, UINT8); +cmdline_parse_token_num_t cmd_vf_rx_vf_id = + TOKEN_NUM_INITIALIZER + (struct cmd_vf_rx_result, + vf_id, UINT16); +cmdline_parse_token_string_t cmd_vf_rx_on_off = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_rx_result, + on_off, "on#off"); + +static void +cmd_set_vf_rx_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_vf_rx_result *res = parsed_result; + int ret = 0; + int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; + + ret = rte_pmd_ixgbe_set_vf_rx(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_rx = { + .f = cmd_set_vf_rx_parsed, + .data = NULL, + .help_str = "set vf rx on|off", + .tokens = { + (void *)&cmd_vf_rx_set, + (void *)&cmd_vf_rx_vf, + (void *)&cmd_vf_rx_rx, + (void *)&cmd_vf_rx_port_id, + (void *)&cmd_vf_rx_vf_id, + (void *)&cmd_vf_rx_on_off, + NULL, + }, +}; + /* tx loopback configuration */ /* Common result structure for tx loopback */ @@ -11722,6 +11806,7 @@ cmdline_parse_ctx_t main_ctx[] = { (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_rx, #endif NULL, }; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 60dcd91..6a058e9 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -507,6 +507,13 @@ Set mac antispoof for a VF from the PF:: testpmd> set vf mac antispoof (port_id) (vf_id) (on|off) +set rx (for VF) +~~~~~~~~~~~~~~~ + +Enable/disable rx for a VF from the PF:: + + testpmd> set vf rx (port_id) (vf_id) (on|off) + vlan set strip ~~~~~~~~~~~~~~