From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 183E31B3CF for ; Fri, 22 Dec 2017 15:41:30 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2017 06:41:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,441,1508828400"; d="scan'208";a="14451074" Received: from rhorton-mobl1.ger.corp.intel.com (HELO FC23.ir.intel.com) ([163.33.230.236]) by orsmga003.jf.intel.com with ESMTP; 22 Dec 2017 06:41:29 -0800 From: Remy Horton To: dev@dpdk.org Cc: Wenzhuo Lu , Jingjing Wu Date: Fri, 22 Dec 2017 14:41:21 +0000 Message-Id: <20171222144121.10041-6-remy.horton@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171222144121.10041-1-remy.horton@intel.com> References: <20171222144121.10041-1-remy.horton@intel.com> Subject: [dpdk-dev] [DPDK 5/5] app/test-pmd: add Port Representor commands 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: , X-List-Received-Date: Fri, 22 Dec 2017 14:41:31 -0000 Port Representors provide a logical presentation in DPDK of VF (virtual function) ports for the purposes of control and monitoring. Each port representor device represents a single VF and is associated with it's parent physical function (PF) PMD which provides the back-end hooks for the representor device ops and defines the control domain to which that port belongs. This allows to use existing DPDK APIs to monitor and control the port without the need to create and maintain VF specific APIs. This patch adds the 'add representor' and 'del representor' commands to test-pmd, which respectively allow the adding and removing of port representors. Signed-off-by: Remy Horton --- app/test-pmd/cmdline.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index f71d963..1a831ba 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include @@ -15535,6 +15536,91 @@ cmdline_parse_inst_t cmd_load_from_file = { }, }; +struct cmd_add_representor_result { + cmdline_fixed_string_t cmd; + cmdline_fixed_string_t representor; + cmdline_fixed_string_t pf; + uint16_t vport; +}; + +cmdline_parse_token_string_t cmd_addrepresentor_add = +TOKEN_STRING_INITIALIZER(struct cmd_add_representor_result, + cmd, "add"); +cmdline_parse_token_string_t cmd_addrepresentor_del = +TOKEN_STRING_INITIALIZER(struct cmd_add_representor_result, + cmd, "del"); +cmdline_parse_token_string_t cmd_addrepresentor_rep = +TOKEN_STRING_INITIALIZER(struct cmd_add_representor_result, + representor, "representor"); +cmdline_parse_token_string_t cmd_addrepresentor_pf = +TOKEN_STRING_INITIALIZER(struct cmd_add_representor_result, + pf, NULL); +cmdline_parse_token_num_t cmd_addrepresentor_vport = +TOKEN_NUM_INITIALIZER(struct cmd_add_representor_result, + vport, UINT16); + +static void cmd_add_representor_callback(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_add_representor_result *res = parsed_result; + uint16_t port_id; + int ret; + + rte_log(RTE_LOG_INFO, RTE_LOGTYPE_USER1, "%s(): addr:%s vport:%i\n", + __func__, res->pf, res->vport); + + ret = rte_representor_port_register(res->pf, res->vport, &port_id); + if (ret != 0) + printf("Registering port representor failed\n"); + else + printf("Port Representor registered with port id %i\n", + port_id); +} + +static void cmd_del_representor_callback(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_add_representor_result *res = parsed_result; + int ret; + + rte_log(RTE_LOG_INFO, RTE_LOGTYPE_USER1, "%s(): port:%i\n", __func__, + res->vport); + ret = rte_representor_port_unregister(res->pf, res->vport); + if (ret != 0) + printf("Port %i is not a valid port representor.\n", + res->vport); +} + +cmdline_parse_inst_t cmd_add_representor = { + .f = cmd_add_representor_callback, + .help_str = "add representor " + "Add a Port Representor", + .data = NULL, + .tokens = { + (void *)&cmd_addrepresentor_add, + (void *)&cmd_addrepresentor_rep, + (void *)&cmd_addrepresentor_pf, + (void *)&cmd_addrepresentor_vport, + NULL + } +}; + +cmdline_parse_inst_t cmd_del_representor = { + .f = cmd_del_representor_callback, + .help_str = "del representor " + "Delete a Port Representor", + .data = NULL, + .tokens = { + (void *)&cmd_addrepresentor_del, + (void *)&cmd_addrepresentor_rep, + (void *)&cmd_addrepresentor_pf, + (void *)&cmd_addrepresentor_vport, + NULL + } +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -15576,6 +15662,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *) &cmd_show_bonding_config, (cmdline_parse_inst_t *) &cmd_set_bonding_primary, (cmdline_parse_inst_t *) &cmd_add_bonding_slave, + (cmdline_parse_inst_t *) &cmd_add_representor, + (cmdline_parse_inst_t *) &cmd_del_representor, (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, (cmdline_parse_inst_t *) &cmd_create_bonded_device, (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, -- 2.9.5