From patchwork Sat Sep 19 10:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 78117 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A381BA04C8; Sat, 19 Sep 2020 12:47:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E86CD1C232; Sat, 19 Sep 2020 12:47:32 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 8045D1C1FE for ; Sat, 19 Sep 2020 12:47:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=IdFGpcfdk4MhdHpENQ 0qN4CbRt70pmakc+QhfJPW/bo=; b=nw5j4Yzmc4ZuA8AM4Gv5gzuQrK/j/c1e+L qmJ0tR6xZ61PiN/R8GVuFB3NvWwZCoTBhDKpjsI2YWJ92tLZ1R5oNjpM1irpatVA SGl3hxPWYLn5RX+x3McNoEyssp0L0ft+o9F0GrEYLQWNQE4fiGPOCgWOuFd4dbt7 0quL1xbi8= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S3; Sat, 19 Sep 2020 18:47:24 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:03 +0800 Message-Id: <20200919104708.58451-2-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxWw15Kr48Ar1UZw47ZFyDtrb_yoW5AFy8pF 4DJFyIk3yDGFs3ur47AayF9r45Gr93Xa10qrZ7Zr1Yy3W5KFn7Jr40gwnIqr4fWry09ryS 9Fnxua4qyF1DXaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UKJmUUUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/xtbBZxqko1et0OWcjQABsl Subject: [dpdk-dev] [PATCH v3 1/6] app/testpmd: fix missing verification of port id 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" From: Chengchang Tang To set Tx vlan offloads, it is required to stop port firstly. But before checking whether the port is stopped, the port id entered by the user is not checked for validity. When the port id is illegal, it would lead to a segmentation fault since it attempts to access a member of non-existent port. This patch adds verification of port id in tx vlan offloads and remove duplicated check. Fixes: 597f9fafe13b ("app/testpmd: convert to new Tx offloads API") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Reviewed-by: Ferruh Yigit --- v1 -> v2: remove the duplicated check. --- app/test-pmd/cmdline.c | 9 +++++++++ app/test-pmd/config.c | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 5f93409..43b7c2f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -4291,6 +4291,9 @@ cmd_tx_vlan_set_parsed(void *parsed_result, { struct cmd_tx_vlan_set_result *res = parsed_result; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + if (!port_is_stopped(res->port_id)) { printf("Please stop port %d first\n", res->port_id); return; @@ -4345,6 +4348,9 @@ cmd_tx_vlan_set_qinq_parsed(void *parsed_result, { struct cmd_tx_vlan_set_qinq_result *res = parsed_result; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + if (!port_is_stopped(res->port_id)) { printf("Please stop port %d first\n", res->port_id); return; @@ -4458,6 +4464,9 @@ cmd_tx_vlan_reset_parsed(void *parsed_result, { struct cmd_tx_vlan_reset_result *res = parsed_result; + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + if (!port_is_stopped(res->port_id)) { printf("Please stop port %d first\n", res->port_id); return; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b6eb2a5..2bdec25 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3545,8 +3545,6 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id) struct rte_eth_dev_info dev_info; int ret; - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; if (vlan_id_is_invalid(vlan_id)) return; @@ -3577,8 +3575,6 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer) struct rte_eth_dev_info dev_info; int ret; - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; if (vlan_id_is_invalid(vlan_id)) return; if (vlan_id_is_invalid(vlan_id_outer)) @@ -3604,8 +3600,6 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer) void tx_vlan_reset(portid_t port_id) { - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; ports[port_id].dev_conf.txmode.offloads &= ~(DEV_TX_OFFLOAD_VLAN_INSERT | DEV_TX_OFFLOAD_QINQ_INSERT); From patchwork Sat Sep 19 10:47:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 78118 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36C08A04C8; Sat, 19 Sep 2020 12:47:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5FDF21C2B8; Sat, 19 Sep 2020 12:47:34 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id CB03B1C206 for ; Sat, 19 Sep 2020 12:47:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=vivlAkYnlXYA/IB3C2 IJd9xh0RuR1KTtWChekN4zkrY=; b=UmA+NWEiYrtI6k01X6r2gxymbr+AhXvDo9 0cTqeFuO4AyMAShoSm2XMVUa6Cz2VSAmWNmUDixxkN+aTBrsMJ11SK0a26slBu2C a9TmGHSJ/46e4AAeYO0gRxd53UB+v6/jWM6FitHPtZ6n28Q8qZhkve/6ieGPKcKj Xh0r/fRqM= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S4; Sat, 19 Sep 2020 18:47:30 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:04 +0800 Message-Id: <20200919104708.58451-3-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cry3JF4rZF43uw13WrW7urg_yoW8KFW3pF s3G3W8trWkJ3WfuF15Aa10kr4rWrs3JFsYvrWfGw4UAF13tryj9rWxK3sFqr1xGr97G345 ZrZ29F9Ivrn8GFUanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jwVyxUUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/xtbBZxqko1et0OWcjQACsm Subject: [dpdk-dev] [PATCH v3 2/6] app/testpmd: fix VLAN offload configuration when config fail 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" From: Chengchang Tang When failing to configure VLAN offloads after the port was started, there is no need to update the port configuration. Currently, when user configure an unsupported VLAN offloads and fails, and then restart the port, it will fails since the configuration has been refreshed. This patch makes the function return directly insead of refreshing the configuration when execution fails. Fixes: 384161e00627 ("app/testpmd: adjust on the fly VLAN configuration") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Reviewed-by: Ferruh Yigit --- app/test-pmd/config.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 2bdec25..4e33208 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3390,9 +3390,11 @@ vlan_extend_set(portid_t port_id, int on) } diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload); - if (diag < 0) + if (diag < 0) { printf("rx_vlan_extend_set(port_pi=%d, on=%d) failed " "diag=%d\n", port_id, on, diag); + return; + } ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads; } @@ -3417,9 +3419,11 @@ rx_vlan_strip_set(portid_t port_id, int on) } diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload); - if (diag < 0) + if (diag < 0) { printf("rx_vlan_strip_set(port_pi=%d, on=%d) failed " "diag=%d\n", port_id, on, diag); + return; + } ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads; } @@ -3458,9 +3462,11 @@ rx_vlan_filter_set(portid_t port_id, int on) } diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload); - if (diag < 0) + if (diag < 0) { printf("rx_vlan_filter_set(port_pi=%d, on=%d) failed " "diag=%d\n", port_id, on, diag); + return; + } ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads; } @@ -3485,9 +3491,11 @@ rx_vlan_qinq_strip_set(portid_t port_id, int on) } diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload); - if (diag < 0) + if (diag < 0) { printf("%s(port_pi=%d, on=%d) failed " "diag=%d\n", __func__, port_id, on, diag); + return; + } ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads; } From patchwork Sat Sep 19 10:47:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 78119 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 42CBBA04C8; Sat, 19 Sep 2020 12:47:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A7D51D9D6; Sat, 19 Sep 2020 12:47:36 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 20C4A1C1AD for ; Sat, 19 Sep 2020 12:47:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=rI2GL5Kf6Fe10OduMz 6n8CaFFq0fzChodrOez4FZ96c=; b=SfQg5En5lN01aVvrfQaxEoENUlmdxEed7G JCYCRylfLg0zSkAsUs7GzXY2aM6LAK1damgs7kPLBmDBRsilWXGORrO1DyyCKnF5 zntAo7RDk7hgINNL4R6SWCitZR3Dq4YPT1L5NLu/5VdCwCqsfXtN/a4OWG+eMweU GpDqROQFo= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S5; Sat, 19 Sep 2020 18:47:33 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:05 +0800 Message-Id: <20200919104708.58451-4-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cry7Aw1ktF4UGFW5Gw4DArb_yoW5JFy3pF 4fKa4Skw48tr4akrW3J3W8K3WfKr4fWw4UJr93Gr1DJr1kJF4xWr4kK34xZrykGryDJFWr ZrZIgFs5Kr1DX3DanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jDSdgUUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/1tbiQAWko1SIgZe27QAAsT Subject: [dpdk-dev] [PATCH v3 3/6] app/testpmd: remove restriction on txpkts set 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" From: Chengchang Tang Currently, if nb_txd is not set, the txpkts is not allowed to be set because the nb_txd is used to avoid the numer of segments exceed the Tx ring size and the default value of nb_txd is 0. And there is a bug that nb_txd is the global configuration for Tx ring size and the ring size could be changed by some command per queue. So these valid check is unreliable and introduced unnecessary constraints. This patch adds a valid check function to use the real Tx ring size to check the validity of txpkts. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- app/test-pmd/config.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 4e33208..882de2d 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2984,17 +2984,51 @@ show_tx_pkt_segments(void) printf("Split packet: %s\n", split); } +static bool +nb_segs_is_invalid(unsigned int nb_segs) +{ + uint16_t port_id; + + RTE_ETH_FOREACH_DEV(port_id) { + struct rte_port *port = &ports[port_id]; + uint16_t ring_size; + uint16_t queue_id; + + /* + * When configure the txq by rte_eth_tx_queue_setup with + * nb_tx_desc being 0, it will use a default value provided by + * PMDs to setup this txq. If the default value is 0, it will + * use the RTE_ETH_DEV_FALLBACK_TX_RINGSIZE to setup this txq. + */ + for (queue_id = 0; queue_id < nb_txq; queue_id++) { + if (port->nb_tx_desc[queue_id]) + ring_size = port->nb_tx_desc[queue_id]; + else if (port->dev_info.default_txportconf.ring_size) + ring_size = + port->dev_info.default_txportconf.ring_size; + else + ring_size = RTE_ETH_DEV_FALLBACK_TX_RINGSIZE; + + if (ring_size < nb_segs) { + printf("nb segments per TX packets=%u >= TX " + "queue(%u) ring_size=%u - ignored\n", + nb_segs, queue_id, ring_size); + return true; + } + } + } + + return false; +} + void set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs) { uint16_t tx_pkt_len; unsigned i; - if (nb_segs >= (unsigned) nb_txd) { - printf("nb segments per TX packets=%u >= nb_txd=%u - ignored\n", - nb_segs, (unsigned int) nb_txd); + if (nb_segs_is_invalid(nb_segs)) return; - } /* * Check that each segment length is greater or equal than From patchwork Sat Sep 19 10:47:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 78120 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9B2EAA04C8; Sat, 19 Sep 2020 12:48:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C65181D996; Sat, 19 Sep 2020 12:47:39 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 618CD1D996 for ; Sat, 19 Sep 2020 12:47:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=zaE4oFSCrKUufPxVee 6TsyBfdeBEBjha00wtyyYlh/A=; b=B26eCjfXQOiSLBcpvU7nSDhTsYHLNfCQLB IlznK/NTVzM2iUNCqSNtSChB/n4IUJgmE6IYlfvzr8MTD3XFe9wVE8dW4btXumDC APdE6LegzotcdSSNcw2GlPh1skpJ+dPrt9ghlzKgsQkSe1HBQA3fXvZiFUGJbzx+ TghXTRKCY= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S6; Sat, 19 Sep 2020 18:47:35 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:06 +0800 Message-Id: <20200919104708.58451-5-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S6 X-Coremail-Antispam: 1Uf129KBjvJXoWxAry7ZFyDJF4ftFWDtFW3GFg_yoWrJrW3pa y7Ga4rtr1rXr1IgF4fJa1fZr45Kr4F9r48tFZFkwnFkFsxtr1xGFy0kryjvF15Kry8ArZa va1DtFn8uF1Du3JanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j21vsUUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/xtbBZAmko1QHKxNQHwAAsO Subject: [dpdk-dev] [PATCH v3 4/6] app/testpmd: fix packet header in txonly mode 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" From: Chengchang Tang In txonly forward mode, the packet header is fixed by the initial setting, including the packet length and checksum. So when the packets varies, this may cause a packet header error. Currently, there are two methods in txonly mode to randomly change the packets. 1. Set txsplit random and txpkts (x[,y]*), the number of segments each packets will be a random value between 1 and total number of segments determined by txpkts settings. The step as follows: a) ./testpmd -w xxx -l xx -n 4 -- -i --disable-device-start b) port config 0 tx_offload multi_segs on c) set fwd txonly d) set txsplit rand e) set txpkts 2048,2048,2048,2048 f) start The nb_segs of the packets sent by testpmd will be 1~4. The real packet length will be 2048, 4096, 6144 and 8192. But in fact the packet length in ip header and udp header will be fixed by 8178 and 8158. 2. Set txonly-multi-flow. the ip address will be varied to generate multiple flow. The step as follows: a) ./testpmd -w xxx -l xx -n 4 -- -i --txonly-multi-flow b) set fwd txonly c) start The ip address of each pkts will change randomly, but since the header is fixed, the checksum may be a error value. Therefore, this patch adds a function to update the packet length and check sum in the pkts header when the txsplit mode is set to rand or multi-flow is set. Fixes: 82010ef55e7c ("app/testpmd: make txonly mode generate multiple flows") Fixes: 79bec05b32b7 ("app/testpmd: add ability to split outgoing packets") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- app/test-pmd/txonly.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 45def72..d55ee7c 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -156,6 +156,34 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr, ip_hdr->hdr_checksum = (uint16_t) ip_cksum; } +static inline void +update_pkt_header(struct rte_mbuf *pkt, uint32_t total_pkt_len) +{ + struct rte_ipv4_hdr *ip_hdr; + struct rte_udp_hdr *udp_hdr; + uint16_t pkt_data_len; + uint16_t pkt_len; + + pkt_data_len = (uint16_t) (total_pkt_len - ( + sizeof(struct rte_ether_hdr) + + sizeof(struct rte_ipv4_hdr) + + sizeof(struct rte_udp_hdr))); + /* updata udp pkt length */ + udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *, + sizeof(struct rte_ether_hdr) + + sizeof(struct rte_ipv4_hdr)); + pkt_len = (uint16_t) (pkt_data_len + sizeof(struct rte_udp_hdr)); + udp_hdr->dgram_len = RTE_CPU_TO_BE_16(pkt_len); + + /* updata ip pkt length and csum */ + ip_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *, + sizeof(struct rte_ether_hdr)); + ip_hdr->hdr_checksum = 0; + pkt_len = (uint16_t) (pkt_len + sizeof(struct rte_ipv4_hdr)); + ip_hdr->total_length = RTE_CPU_TO_BE_16(pkt_len); + ip_hdr->hdr_checksum = rte_ipv4_cksum(ip_hdr); +} + static inline bool pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp, struct rte_ether_hdr *eth_hdr, const uint16_t vlan_tci, @@ -223,6 +251,10 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp, copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt, sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr)); + + if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND) || txonly_multi_flow) + update_pkt_header(pkt, pkt_len); + if (unlikely(timestamp_enable)) { uint64_t skew = RTE_PER_LCORE(timestamp_qskew); struct { From patchwork Sat Sep 19 10:47:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 78121 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 11E5BA04C8; Sat, 19 Sep 2020 12:48:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 007B91D9E7; Sat, 19 Sep 2020 12:47:43 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id E0BB91D9E4 for ; Sat, 19 Sep 2020 12:47:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=Ry9bs1QYoXjeLTSW4m 3tk4aXyLgiTY+RvuS2tiymK5Y=; b=SIsCXUy1gAMlRkRgHT+5tKxNLLKXoKMOE8 wjpxqx9SXDdn/kYybYErb8rj2WAfpGjWaazuc9v99g7G6azmJ33O9N8FsohAyV9i yx3IwxLTybnZf6eIzcmoZcE76vX/MNlb+wW6YQ/lYvKO2CO23tfMnGj74XFqL19u ZRQQ9pFKI= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S7; Sat, 19 Sep 2020 18:47:38 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:07 +0800 Message-Id: <20200919104708.58451-6-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S7 X-Coremail-Antispam: 1Uf129KBjvJXoWxWrWxtr4UXF4kJw18urWrGrg_yoWrXFWDpF 45KayxA395Zr43Wr93Jw4rua1F9F4fWw4xWrZ3Jr1jvws8ZF4DGr1UKrn7XF95Jryqkr13 uwnIgana9F1DAFJanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j21vsUUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/1tbiDguko1XlxqS5bwAAsG Subject: [dpdk-dev] [PATCH v3 5/6] app/testpmd: fix valid desc id check 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" From: Chengchang Tang The number of desc is a per queue configuration. But in the check function, nb_txd & nb_rxd are used to check whether the desc_id is valid. nb_txd & nb_rxd are the global configuration of number of desc. If the queue configuration is changed by cmdline liks: "port config xx txq xx ring_size xxx", the real value will be changed. This patch use the real value to check whether the desc_id is valid. And if these are not configured by user. It will use the default value to check it, since the rte_eth_rx_queue_setup & rte_eth_tx_queue_setup will use a default value to confiure the queue if nb_rx_desc or nb_tx_desc is zero. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- app/test-pmd/config.c | 53 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 882de2d..b7851c7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1891,22 +1891,55 @@ tx_queue_id_is_invalid(queueid_t txq_id) } static int -rx_desc_id_is_invalid(uint16_t rxdesc_id) +rx_desc_id_is_invalid(portid_t port_id, queueid_t rxq_id, uint16_t rxdesc_id) { - if (rxdesc_id < nb_rxd) + struct rte_port *port = &ports[port_id]; + uint16_t ring_size; + + /* + * When configure the rxq by rte_eth_rx_queue_setup with nb_rx_desc + * being 0, it will use a default value provided by PMDs to setup this + * rxq. If the default value is 0, it will use the + * RTE_ETH_DEV_FALLBACK_RX_RINGSIZE to setup this rxq. + */ + if (port->nb_rx_desc[rxq_id]) + ring_size = port->nb_rx_desc[rxq_id]; + else if (port->dev_info.default_rxportconf.ring_size) + ring_size = port->dev_info.default_rxportconf.ring_size; + else + ring_size = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE; + + if (rxdesc_id < ring_size) return 0; - printf("Invalid RX descriptor %d (must be < nb_rxd=%d)\n", - rxdesc_id, nb_rxd); + printf("Invalid RX descriptor %d (must be < ring_size=%d)\n", + rxdesc_id, ring_size); return 1; } static int -tx_desc_id_is_invalid(uint16_t txdesc_id) +tx_desc_id_is_invalid(portid_t port_id, queueid_t txq_id, uint16_t txdesc_id) { - if (txdesc_id < nb_txd) + struct rte_port *port = &ports[port_id]; + uint16_t ring_size; + + /* + * When configure the txq by rte_eth_tx_queue_setup with nb_tx_desc + * being 0, it will use a default value provided by PMDs to setup this + * txq. If the default value is 0, it will use the + * RTE_ETH_DEV_FALLBACK_TX_RINGSIZE to setup this txq. + */ + if (port->nb_tx_desc[txq_id]) + ring_size = port->nb_tx_desc[txq_id]; + else if (port->dev_info.default_txportconf.ring_size) + ring_size = port->dev_info.default_txportconf.ring_size; + else + ring_size = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE; + + if (txdesc_id < ring_size) return 0; - printf("Invalid TX descriptor %d (must be < nb_txd=%d)\n", - txdesc_id, nb_txd); + + printf("Invalid TX descriptor %d (must be < ring_size=%d)\n", + txdesc_id, ring_size); return 1; } @@ -2031,7 +2064,7 @@ rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id) return; if (rx_queue_id_is_invalid(rxq_id)) return; - if (rx_desc_id_is_invalid(rxd_id)) + if (rx_desc_id_is_invalid(port_id, rxq_id, rxd_id)) return; rx_mz = ring_dma_zone_lookup("rx_ring", port_id, rxq_id); if (rx_mz == NULL) @@ -2048,7 +2081,7 @@ tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id) return; if (tx_queue_id_is_invalid(txq_id)) return; - if (tx_desc_id_is_invalid(txd_id)) + if (tx_desc_id_is_invalid(port_id, txq_id, txd_id)) return; tx_mz = ring_dma_zone_lookup("tx_ring", port_id, txq_id); if (tx_mz == NULL) From patchwork Sat Sep 19 10:47:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 78122 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 45086A04C8; Sat, 19 Sep 2020 12:48:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 896621D9F9; Sat, 19 Sep 2020 12:47:45 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 78D7D1D9F9 for ; Sat, 19 Sep 2020 12:47:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=IYyAjCe5VM2YY6gu2g PCefeIZBy7lsl0Pzmnf51epwM=; b=cAPRvMjF0wT4RhYE25ZiG7zwnzAjkjmu0M EHX0GJtRxVXPmKLIOWDuR3CRGQoyqjs+BQt3aqviJm4zkd1lPVFpp3r8M1zmcxl8 9y6bWflUhOvifTw5oajNVWi1MLVQzdhdrjQI65/jlRKR9HnfD1k3IFYif+Qtx/qc FdyylNNlk= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S8; Sat, 19 Sep 2020 18:47:41 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:08 +0800 Message-Id: <20200919104708.58451-7-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S8 X-Coremail-Antispam: 1Uf129KBjvJXoWxXr4DXryrJw1rWry8tw13urg_yoWrKF43pF W5AFs8Aw4fKFZxWr43XF1xur13Cr45XayUWF9Fg3WUur48CrWvgF17CFWDXr1UGFZxtw4S ya95Ja45WFyDXw7anT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UKfO7UUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/xtbBZA+ko1QHKxNQVQAAsC Subject: [dpdk-dev] [PATCH v3 6/6] app/testpmd: fix displaying Rx Tx queues information 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" From: Huisong Li Currently, the information of Rx/Tx queues from PMD driver is not displayed exactly in the rxtx_config_display function. Because "ports[pid].rx_conf" and "ports[pid].tx_conf" maintained in testpmd application may be not the value actually used by PMD driver. For instance, user does not set a field, but PMD driver has to use the default value. This patch fixes rxtx_config_display so that the information of Rx/Tx queues can be really displayed for the PMD driver that implement .rxq_info_get and .txq_info_get ops callback function. Fixes: 75c530c1bd5351 ("app/testpmd: fix port configuration print") Fixes: d44f8a485f5d1f ("app/testpmd: enable per queue configure") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) Reviewed-by: Ferruh Yigit --- app/test-pmd/config.c | 64 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b7851c7..03cd671 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2122,10 +2122,17 @@ rxtx_config_display(void) struct rte_eth_txconf *tx_conf = &ports[pid].tx_conf[0]; uint16_t *nb_rx_desc = &ports[pid].nb_rx_desc[0]; uint16_t *nb_tx_desc = &ports[pid].nb_tx_desc[0]; - uint16_t nb_rx_desc_tmp; - uint16_t nb_tx_desc_tmp; struct rte_eth_rxq_info rx_qinfo; struct rte_eth_txq_info tx_qinfo; + uint16_t rx_free_thresh_tmp; + uint16_t tx_free_thresh_tmp; + uint16_t tx_rs_thresh_tmp; + uint16_t nb_rx_desc_tmp; + uint16_t nb_tx_desc_tmp; + uint64_t offloads_tmp; + uint8_t pthresh_tmp; + uint8_t hthresh_tmp; + uint8_t wthresh_tmp; int32_t rc; /* per port config */ @@ -2139,41 +2146,64 @@ rxtx_config_display(void) /* per rx queue config only for first queue to be less verbose */ for (qid = 0; qid < 1; qid++) { rc = rte_eth_rx_queue_info_get(pid, qid, &rx_qinfo); - if (rc) + if (rc) { nb_rx_desc_tmp = nb_rx_desc[qid]; - else + rx_free_thresh_tmp = + rx_conf[qid].rx_free_thresh; + pthresh_tmp = rx_conf[qid].rx_thresh.pthresh; + hthresh_tmp = rx_conf[qid].rx_thresh.hthresh; + wthresh_tmp = rx_conf[qid].rx_thresh.wthresh; + offloads_tmp = rx_conf[qid].offloads; + } else { nb_rx_desc_tmp = rx_qinfo.nb_desc; + rx_free_thresh_tmp = + rx_qinfo.conf.rx_free_thresh; + pthresh_tmp = rx_qinfo.conf.rx_thresh.pthresh; + hthresh_tmp = rx_qinfo.conf.rx_thresh.hthresh; + wthresh_tmp = rx_qinfo.conf.rx_thresh.wthresh; + offloads_tmp = rx_qinfo.conf.offloads; + } printf(" RX queue: %d\n", qid); printf(" RX desc=%d - RX free threshold=%d\n", - nb_rx_desc_tmp, rx_conf[qid].rx_free_thresh); + nb_rx_desc_tmp, rx_free_thresh_tmp); printf(" RX threshold registers: pthresh=%d hthresh=%d " " wthresh=%d\n", - rx_conf[qid].rx_thresh.pthresh, - rx_conf[qid].rx_thresh.hthresh, - rx_conf[qid].rx_thresh.wthresh); - printf(" RX Offloads=0x%"PRIx64"\n", - rx_conf[qid].offloads); + pthresh_tmp, hthresh_tmp, wthresh_tmp); + printf(" RX Offloads=0x%"PRIx64"\n", offloads_tmp); } /* per tx queue config only for first queue to be less verbose */ for (qid = 0; qid < 1; qid++) { rc = rte_eth_tx_queue_info_get(pid, qid, &tx_qinfo); - if (rc) + if (rc) { nb_tx_desc_tmp = nb_tx_desc[qid]; - else + tx_free_thresh_tmp = + tx_conf[qid].tx_free_thresh; + pthresh_tmp = tx_conf[qid].tx_thresh.pthresh; + hthresh_tmp = tx_conf[qid].tx_thresh.hthresh; + wthresh_tmp = tx_conf[qid].tx_thresh.wthresh; + offloads_tmp = tx_conf[qid].offloads; + tx_rs_thresh_tmp = tx_conf[qid].tx_rs_thresh; + } else { nb_tx_desc_tmp = tx_qinfo.nb_desc; + tx_free_thresh_tmp = + tx_qinfo.conf.tx_free_thresh; + pthresh_tmp = tx_qinfo.conf.tx_thresh.pthresh; + hthresh_tmp = tx_qinfo.conf.tx_thresh.hthresh; + wthresh_tmp = tx_qinfo.conf.tx_thresh.wthresh; + offloads_tmp = tx_qinfo.conf.offloads; + tx_rs_thresh_tmp = tx_qinfo.conf.tx_rs_thresh; + } printf(" TX queue: %d\n", qid); printf(" TX desc=%d - TX free threshold=%d\n", - nb_tx_desc_tmp, tx_conf[qid].tx_free_thresh); + nb_tx_desc_tmp, tx_free_thresh_tmp); printf(" TX threshold registers: pthresh=%d hthresh=%d " " wthresh=%d\n", - tx_conf[qid].tx_thresh.pthresh, - tx_conf[qid].tx_thresh.hthresh, - tx_conf[qid].tx_thresh.wthresh); + pthresh_tmp, hthresh_tmp, wthresh_tmp); printf(" TX offloads=0x%"PRIx64" - TX RS bit threshold=%d\n", - tx_conf[qid].offloads, tx_conf->tx_rs_thresh); + offloads_tmp, tx_rs_thresh_tmp); } } }