From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2CD6A0548; Wed, 25 May 2022 08:12:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A11C400EF; Wed, 25 May 2022 08:12:43 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 68F9C400D6 for ; Wed, 25 May 2022 08:12:42 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id s28so28460116wrb.7 for ; Tue, 24 May 2022 23:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pPECfKDkxTgVn42aPbqPe2udFq6pxgwMnZ1ltyGPCxM=; b=z/PzEOrL8Fc8ogfhe7FFrRXT7dhYUZ1xoMsixWBJ0xYJU6wpUgERFN2gMKTR7/7rzh z1CrZfM2OCkpRh00hjrBzYnQhDc7XVpSa1q4aARvG0Mw7ii3J6rQy9+C4eOJ96zw9KTH EoPHv3cFA02vexXR059Rbf4ZpIXiS2cUvOy36Wa55E3qaRVJMiUq/2gC3ObNsWYF1SUJ GBACv59lHITBj2FHS/x7drni0vSdOqndNjnkuYpYqpy40m47ZR4tgRMDRlbtX1+mywJO 3qYQeKdzl817qbrWrs8NhzHfWrRGlSctAH5Y6KOJYBDHJzKhUC3jeDH+dlTY9jcF35Zd T/aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pPECfKDkxTgVn42aPbqPe2udFq6pxgwMnZ1ltyGPCxM=; b=Unu4VI0z4K+eneKgk8ABKqVpgRWvEVNq1iqS6ziarOZ2o8RWeabbHqxXLESgVZycw1 LMlpj95RLy8loOtUnuvQ9i5RbhbllSgUVR1IgZ4BYDv0/n0nBeJRdtEy2qrr2Gw+4RKF k2f5BWWE+LwM3nCO04oK22Vo7O3UWcsmw8C2Aq9qCjZBbUbMfBJ7RMLQtlzXs1GDXcRI LVxbc5ha68Q69VPMjKv6aKwfdHtSUXtieTG6zucLvRZRIfybypNgrsRPT25kJKDxl+L+ 61TSyY6vih/tHpCH7i4RS0jtvpTGwsQtyjefZb1x6xPpSitn6ecVXpNwK6m/ryccVLE3 lr4A== X-Gm-Message-State: AOAM531jccFSHBx+3xnEpzgL3l7HXyN7U73rw43G1iD0DBT69OL20Pc9 aqkLkf5WzEQalQWQpKVVTtrdaO+q9z2BUA== X-Google-Smtp-Source: ABdhPJwsQFoE28ioe9hraOWvfwCUAP3RQi9y34hYYre0No5IFONRD/f/PY0yMdcQLMckWs02ipQaNg== X-Received: by 2002:a5d:508c:0:b0:20d:7e7:4c36 with SMTP id a12-20020a5d508c000000b0020d07e74c36mr26441925wrt.153.1653459161946; Tue, 24 May 2022 23:12:41 -0700 (PDT) Received: from localhost.localdomain ([39.32.39.45]) by smtp.gmail.com with ESMTPSA id c15-20020a05600c0a4f00b003942a244f3asm864553wmq.19.2022.05.24.23.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 23:12:41 -0700 (PDT) From: Muhammad Jawad Hussain To: dev@dpdk.org Cc: jawad.hussain@emumba.com Subject: [PATCH] examples/ethtool: update rxmode to increase functionality Date: Wed, 25 May 2022 11:12:30 +0500 Message-Id: <20220525061230.123956-1-jawad.hussain@emumba.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org previously rxmode functionality did not allow the user to choose between different vfs nor did it allow the user to choose rxmode settings by default it was set to vf = 0, rxmode = AUPE and the on/off state toggled without letting the user know what state it is in also there were no error messages Changes: - added flag for vf id - added flags for AUPE|ROPE|BAM|MPE rxmodes - added flag for on/off - added error messages - added info messages Signed-off-by: Muhammad Jawad Hussain --- doc/guides/sample_app_ug/ethtool.rst | 2 +- examples/ethtool/ethtool-app/ethapp.c | 121 ++++++++++++++++++++------ 2 files changed, 95 insertions(+), 28 deletions(-) diff --git a/doc/guides/sample_app_ug/ethtool.rst b/doc/guides/sample_app_ug/ethtool.rst index 159e9e0639..2e53084cc3 100644 --- a/doc/guides/sample_app_ug/ethtool.rst +++ b/doc/guides/sample_app_ug/ethtool.rst @@ -53,7 +53,7 @@ they do as follows: * ``portstats``: Print port statistics * ``regs``: Dump port register(s) to file * ``ringparam``: Get/set ring parameters -* ``rxmode``: Toggle port Rx mode +* ``rxmode``: Set rxmode of vfs on ports * ``stop``: Stop port * ``validate``: Check that given MAC address is valid unicast address * ``vlan``: Add/remove VLAN id diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c index 78e86534e8..ba414c7af9 100644 --- a/examples/ethtool/ethtool-app/ethapp.c +++ b/examples/ethtool/ethtool-app/ethapp.c @@ -14,6 +14,19 @@ #define EEPROM_DUMP_CHUNKSIZE 1024 +typedef uint16_t portid_t; + +/* *** CONFIGURE VF RECEIVE MODE *** */ +struct cmd_set_vf_rxmode { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t vf; + uint8_t vf_id; + cmdline_fixed_string_t what; + cmdline_fixed_string_t mode; + cmdline_fixed_string_t on; +}; struct pcmd_get_params { cmdline_fixed_string_t cmd; @@ -65,8 +78,6 @@ cmdline_parse_token_string_t pcmd_open_token_cmd = TOKEN_STRING_INITIALIZER(struct pcmd_int_params, cmd, "open"); cmdline_parse_token_string_t pcmd_stop_token_cmd = TOKEN_STRING_INITIALIZER(struct pcmd_int_params, cmd, "stop"); -cmdline_parse_token_string_t pcmd_rxmode_token_cmd = - TOKEN_STRING_INITIALIZER(struct pcmd_int_params, cmd, "rxmode"); cmdline_parse_token_string_t pcmd_portstats_token_cmd = TOKEN_STRING_INITIALIZER(struct pcmd_int_params, cmd, "portstats"); cmdline_parse_token_num_t pcmd_int_token_port = @@ -133,6 +144,31 @@ cmdline_parse_token_string_t pcmd_vlan_token_mode = cmdline_parse_token_num_t pcmd_vlan_token_vid = TOKEN_NUM_INITIALIZER(struct pcmd_vlan_params, vid, RTE_UINT16); +/* rxmode */ +cmdline_parse_token_string_t cmd_set_vf_rxmode_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, + set, "set"); +cmdline_parse_token_string_t cmd_set_vf_rxmode_port = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, + port, "port"); +cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = + TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, + vf, "vf"); +cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = + TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, + vf_id, RTE_UINT8); +cmdline_parse_token_string_t cmd_set_vf_rxmode_what = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, + what, "rxmode"); +cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, + mode, "AUPE#ROPE#BAM#MPE"); +cmdline_parse_token_string_t cmd_set_vf_rxmode_on = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, + on, "on#off"); static void pcmd_quit_callback(__rte_unused void *ptr_params, @@ -142,7 +178,6 @@ pcmd_quit_callback(__rte_unused void *ptr_params, cmdline_quit(ctx); } - static void pcmd_drvinfo_callback(__rte_unused void *ptr_params, __rte_unused struct cmdline *ctx, @@ -150,7 +185,6 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params, { struct ethtool_drvinfo info; uint16_t id_port; - RTE_ETH_FOREACH_DEV(id_port) { memset(&info, 0, sizeof(info)); if (rte_ethtool_get_drvinfo(id_port, &info)) { @@ -447,26 +481,51 @@ pcmd_stop_callback(__rte_unused void *ptr_params, printf("Port %i: Error stopping device\n", params->port); } - static void -pcmd_rxmode_callback(void *ptr_params, - __rte_unused struct cmdline *ctx, - __rte_unused void *ptr_data) +pcmd_rxmode_callback(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) { - struct pcmd_intstr_params *params = ptr_params; - int stat; + int ret = -ENOTSUP; + uint16_t vf_rxmode = 0; + struct cmd_set_vf_rxmode *res = parsed_result; + + int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; + if (!strcmp(res->what, "rxmode")) { + if (!strcmp(res->mode, "AUPE")) + vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG; + else if (!strcmp(res->mode, "ROPE")) + vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC; + else if (!strcmp(res->mode, "BAM")) + vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST; + else if (!strncmp(res->mode, "MPE", 3)) + vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST; + } - if (!rte_eth_dev_is_valid_port(params->port)) { - printf("Error: Invalid port number %i\n", params->port); - return; + RTE_SET_USED(is_on); + RTE_SET_USED(vf_rxmode); + +#ifdef RTE_NET_IXGBE + if (ret == -ENOTSUP) { + ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, + vf_rxmode, (uint8_t)is_on); + if (ret == -ENOTSUP) + printf("ixgbe not supported\n"); } - stat = rte_ethtool_net_set_rx_mode(params->port); - if (stat == 0) - return; - else if (stat == -ENOTSUP) - printf("Port %i: Operation not supported\n", params->port); - else - printf("Port %i: Error setting rx mode\n", params->port); +#endif +#ifdef RTE_NET_BNXT + if (ret == -ENOTSUP) { + ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, + vf_rxmode, (uint8_t)is_on); + if (ret == -ENOTSUP) + printf("bnxt not supported\n"); + } +#endif + if (ret < 0) + fprintf(stderr, + "%d bad VF receive mode parameter, return code = %d\n", ret); + else if (ret == 0) + printf("Successful\n"); } @@ -763,16 +822,25 @@ cmdline_parse_inst_t pcmd_stop = { NULL }, }; -cmdline_parse_inst_t pcmd_rxmode = { + +cmdline_parse_inst_t cmd_set_vf_rxmode = { .f = pcmd_rxmode_callback, .data = NULL, - .help_str = "rxmode \n Toggle port Rx mode", + .help_str = "set port vf rxmode " + "AUPE|ROPE|BAM|MPE on|off", .tokens = { - (void *)&pcmd_rxmode_token_cmd, - (void *)&pcmd_int_token_port, - NULL + (void *)&cmd_set_vf_rxmode_set, + (void *)&cmd_set_vf_rxmode_port, + (void *)&cmd_set_vf_rxmode_portid, + (void *)&cmd_set_vf_rxmode_vf, + (void *)&cmd_set_vf_rxmode_vfid, + (void *)&cmd_set_vf_rxmode_what, + (void *)&cmd_set_vf_rxmode_mode, + (void *)&cmd_set_vf_rxmode_on, + NULL, }, }; + cmdline_parse_inst_t pcmd_macaddr_get = { .f = pcmd_macaddr_callback, .data = NULL, @@ -869,7 +937,6 @@ cmdline_parse_inst_t pcmd_vlan = { }, }; - cmdline_parse_ctx_t list_prompt_commands[] = { (cmdline_parse_inst_t *)&pcmd_drvinfo, (cmdline_parse_inst_t *)&pcmd_eeprom, @@ -885,7 +952,7 @@ cmdline_parse_ctx_t list_prompt_commands[] = { (cmdline_parse_inst_t *)&pcmd_regs, (cmdline_parse_inst_t *)&pcmd_ringparam, (cmdline_parse_inst_t *)&pcmd_ringparam_set, - (cmdline_parse_inst_t *)&pcmd_rxmode, + (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, (cmdline_parse_inst_t *)&pcmd_stop, (cmdline_parse_inst_t *)&pcmd_validate, (cmdline_parse_inst_t *)&pcmd_vlan, -- 2.32.0