From patchwork Sun Sep 3 04:01:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Tao X-Patchwork-Id: 131099 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 601FD424DC; Sun, 3 Sep 2023 06:01:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C576402AE; Sun, 3 Sep 2023 06:01:31 +0200 (CEST) Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.198]) by mails.dpdk.org (Postfix) with ESMTP id 7A46940274; Sun, 3 Sep 2023 06:01:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=xQ0eq a/0zVoffRlEAXhYO8wCxeglcy/iFagELkrtzbI=; b=M3mePAglx4bBz2g6r+Re8 E5yWPO++n+GHoUSteIbI+QSbb5lyWE/7f/B/k+NtL0uphAJBOTwZgs4Y2VdZMgbM bOLY1cnc7yZYy20T0NrFc1bkpNB/Kfv/TKcGXG8KuX0X1fmay6eEzgldApZargf1 mCD2Swr4l8yAwCsIFByXsg= Received: from u2204.. (unknown [49.76.25.150]) by zwqz-smtp-mta-g5-0 (Coremail) with SMTP id _____wC3PiMKBfRknkQqBA--.63655S2; Sun, 03 Sep 2023 12:01:21 +0800 (CST) From: Trevor Tao To: dev@dpdk.org Cc: thomas@monjalon.net, Trevor Tao , stable@dpdk.org Subject: [PATCH v1] examples/l3fwd: relax the RSS/Offload requirement Date: Sun, 3 Sep 2023 04:01:11 +0000 Message-Id: <20230903040111.126695-1-taozj888@163.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: _____wC3PiMKBfRknkQqBA--.63655S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxWFy8ZFy3AryrZrWDZF43Jrb_yoWrCw15pF srG397Xrs7XFy3XF13ZayI9r1Y9r18CFZ09F1fA343tF42yr97Ar4jkryYvFW7t3Z8GrZ2 vrWrWrs3KF1kA3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRBbyQUUUUU= X-Originating-IP: [49.76.25.150] X-CM-SenderInfo: hwdr6yqyyyqiywtou0bp/xtbBdBXfx1gi7QUm6gAAsn 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 Now the port Rx mq_mode had been set to RTE_ETH_MQ_RX_RSS, and offload mode set to RTE_ETH_RX_OFFLOAD_CHECKSUM by default, but some hardware and/or virtual interface does not support the RSS and offload mode presupposed, e.g., some virtio interfaces in the cloud don't support RSS and may only partly support RTE_ETH_RX_OFFLOAD_UDP_CKSUM/ RTE_ETH_RX_OFFLOAD_TCP_CKSUM, but not RTE_ETH_RX_OFFLOAD_IPV4_CKSUM, and the error msg here: virtio_dev_configure(): RSS support requested but not supported by the device Port0 dev_configure = -95 and: Ethdev port_id=0 requested Rx offloads 0xe does not match Rx offloads capabilities 0x201d in rte_eth_dev_configure() So to enable the l3fwd running in that environment, the Rx mode requirement can be relaxed to reflect the hardware feature reality here, and the l3fwd can run smoothly then. A warning msg would be provided to user in case it happens here. On the other side, enabling the software cksum check in case the hw support missing. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Trevor Tao --- examples/l3fwd/l3fwd.h | 12 +++++++++++- examples/l3fwd/main.c | 21 +++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index b55855c932..cc10643c4b 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -115,6 +115,8 @@ extern struct acl_algorithms acl_alg[]; extern uint32_t max_pkt_len; +extern struct rte_eth_conf port_conf; + /* Send burst of packets on an output interface */ static inline int send_burst(struct lcore_conf *qconf, uint16_t n, uint16_t port) @@ -170,7 +172,15 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len) return -1; /* 2. The IP checksum must be correct. */ - /* this is checked in H/W */ + /* if this is not checked in H/W, check it. */ + if ((port_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) == 0) { + uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum = 0; + expected_cksum = rte_ipv4_cksum(pkt); + if (actual_cksum != expected_cksum) + return -2; + } /* * 3. The IP version number must be 4. If the version number is not 4 diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 6063eb1399..37aec64718 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -117,7 +117,7 @@ static struct lcore_params * lcore_params = lcore_params_array_default; static uint16_t nb_lcore_params = sizeof(lcore_params_array_default) / sizeof(lcore_params_array_default[0]); -static struct rte_eth_conf port_conf = { +struct rte_eth_conf port_conf = { .rxmode = { .mq_mode = RTE_ETH_MQ_RX_RSS, .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM, @@ -1257,8 +1257,12 @@ l3fwd_poll_resource_setup(void) local_port_conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads; - if (dev_info.max_rx_queues == 1) + /* relax the rx rss requirement */ + if (dev_info.max_rx_queues == 1 || !local_port_conf.rx_adv_conf.rss_conf.rss_hf) { + printf("warning: modified the rx mq_mode to RTE_ETH_MQ_RX_NONE base on" + " device capability\n"); local_port_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_NONE; + } if (local_port_conf.rx_adv_conf.rss_conf.rss_hf != port_conf.rx_adv_conf.rss_conf.rss_hf) { @@ -1269,6 +1273,19 @@ l3fwd_poll_resource_setup(void) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } + /* relax the rx offload requirement */ + if ((local_port_conf.rxmode.offloads & dev_info.rx_offload_capa) != + local_port_conf.rxmode.offloads) { + printf("Port %u requested Rx offloads 0x%"PRIx64" does not" + " match Rx offloads capabilities 0x%"PRIx64"\n", + portid, local_port_conf.rxmode.offloads, + dev_info.rx_offload_capa); + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + printf("warning: modified the rx offload to 0x%"PRIx64" based on device" + " capability\n", local_port_conf.rxmode.offloads); + } + ret = rte_eth_dev_configure(portid, nb_rx_queue, (uint16_t)n_tx_queue, &local_port_conf); if (ret < 0)