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 74DC5A0032; Fri, 24 Jun 2022 09:27:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 680F6415D7; Fri, 24 Jun 2022 09:27:40 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id C2C9140A82 for ; Fri, 24 Jun 2022 09:27:38 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LTpX631SPzShK1; Fri, 24 Jun 2022 15:24:06 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:39 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:38 +0800 From: Huisong Li To: , , , CC: , , , , Subject: [PATCH V5 5/7] app/testpmd: compact RSS types output in some commands Date: Fri, 24 Jun 2022 15:23:59 +0800 Message-ID: <20220624072401.21839-6-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com> References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected 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 From: Ferruh Yigit In port info command output, 'show port info all', supported RSS offload types printed one type per line, and although this information is not most important part of the command it takes big part of the command output. In port RSS hash and flow RSS command output, 'show port 0 rss-hash', and 'flow query 0 0 rss', all enabled RSS types are printed on one line. If there are many types, the print will be very long. Compacting these RSS offloads and types output by fixing the length of the character string printed on each line, instead of one per line or one line. Output becomes as following: Supported RSS offload flow types: ipv4-frag ipv4-tcp ipv4-udp ipv4-sctp ipv4-other ipv6-frag ipv6-tcp ipv6-udp ipv6-sctp ipv6-other l4-dst-only l4-src-only l3-dst-only l3-src-only Signed-off-by: Ferruh Yigit Signed-off-by: Huisong Li --- app/test-pmd/config.c | 68 +++++++++++++++++++++++++++++++----------- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a0a5f12c71..b3cb68003c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -699,6 +699,38 @@ rsstypes_to_str(uint64_t rss_type) return NULL; } +static void +rss_offload_types_display(uint64_t offload_types, uint16_t char_num_per_line) +{ + uint16_t unknown_offload_str_len; + uint16_t total_len = 0; + uint16_t str_len = 0; + uint64_t rss_offload; + uint16_t i; + + for (i = 0; i < sizeof(offload_types) * CHAR_BIT; i++) { + rss_offload = RTE_BIT64(i); + if ((offload_types & rss_offload) != 0) { + const char *p = rsstypes_to_str(rss_offload); + + unknown_offload_str_len = + strlen("unknown_offload(BIT())") + (i / 10 + 1); + str_len = p ? strlen(p) : unknown_offload_str_len; + str_len += 2; /* add two spaces */ + if (total_len + str_len >= char_num_per_line) { + total_len = 0; + printf("\n"); + } + + if (p) + printf(" %s", p); + else + printf(" unknown_offload(BIT(%u))", i); + total_len += str_len; + } + } +} + void port_infos_display(portid_t port_id) { @@ -803,21 +835,10 @@ port_infos_display(portid_t port_id) if (!dev_info.flow_type_rss_offloads) printf("No RSS offload flow type is supported.\n"); else { - uint64_t rss_offload_types = dev_info.flow_type_rss_offloads; - uint16_t i; - printf("Supported RSS offload flow types:\n"); - for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) { - uint64_t rss_offload = RTE_BIT64(i); - if ((rss_offload_types & rss_offload) != 0) { - const char *p = rsstypes_to_str(rss_offload); - if (p) - printf(" %s\n", p); - else - printf(" unknown_offload(BIT(%u))\n", - i); - } - } + rss_offload_types_display(dev_info.flow_type_rss_offloads, + TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); + printf("\n"); } printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize); @@ -1570,8 +1591,10 @@ port_flow_complain(struct rte_flow_error *error) } static void -rss_types_display(uint64_t rss_types) +rss_types_display(uint64_t rss_types, uint16_t char_num_per_line) { + uint16_t total_len = 0; + uint16_t str_len; uint16_t i; if (rss_types == 0) @@ -1580,9 +1603,18 @@ rss_types_display(uint64_t rss_types) for (i = 0; rss_type_table[i].str; i++) { if (rss_type_table[i].rss_type == 0) continue; + if ((rss_types & rss_type_table[i].rss_type) == - rss_type_table[i].rss_type) + rss_type_table[i].rss_type) { + /* contain two spces */ + str_len = strlen(rss_type_table[i].str) + 2; + if (total_len + str_len > char_num_per_line) { + printf("\n"); + total_len = 0; + } printf(" %s", rss_type_table[i].str); + total_len += str_len; + } } } @@ -1628,7 +1660,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) printf(" none\n"); return; } - rss_types_display(rss_conf->types); + rss_types_display(rss_conf->types, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); } static struct port_indirect_action * @@ -3859,7 +3891,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key) return; } printf("RSS functions:\n"); - rss_types_display(rss_hf); + rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); printf("\n"); if (!show_rss_key) return; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 2e2987eb66..9cc5752f62 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -113,6 +113,8 @@ struct pkt_burst_stats { unsigned int pkt_burst_spread[MAX_PKT_BURST + 1]; }; + +#define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64 /** Information for a given RSS type. */ struct rss_type_info { const char *str; /**< Type name. */ -- 2.33.0