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 DDBC3A0C41 for ; Tue, 30 Nov 2021 17:38:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D45C3411B8; Tue, 30 Nov 2021 17:38:12 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id 91670410F7 for ; Tue, 30 Nov 2021 17:38:09 +0100 (CET) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 61E1C3F1B1 for ; Tue, 30 Nov 2021 16:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1638290289; bh=4zbt3DlyHT2Megdy2RVrdfdDw/pw/tKFVDXmrnbAXvw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GCwGMEUhiD/eSFAPwLdjUyfN+rPFFXflamGXpDOaNLKSjpS2lpgiQbjCzh8ipHgrV YmMcamK9tmBQcvs1aYBC/tLo3GHuNsZrq4EBVswAbeKUTPh8EADBNWnoEEYv/bAVXQ l8WAQMbwY4xR09RRZzQYRdHmw287XqK2BcJpMRfqlI9XQXgmKSvx/E1qIDHI9fnODb Qy2S93D6VSW22ktyu0myxsUAORbqIFgnyTB3znJPuyYe7LfQhZVeYanfmpWhq5PyCC 4VsGuMpwE96Swm4gZwXYHAldFHSGwn9yVhODPl0WyZUwqjGi5I9k7r0I6RfAUrynLk ThvEGlca4lZ5g== Received: by mail-ed1-f70.google.com with SMTP id p4-20020aa7d304000000b003e7ef120a37so17397531edq.16 for ; Tue, 30 Nov 2021 08:38:09 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=4zbt3DlyHT2Megdy2RVrdfdDw/pw/tKFVDXmrnbAXvw=; b=HVY3dLQi0aKfGv/2Od9YxaKuSI4jguiOu9swI3XIiJVmcFvFRpSHnrgEj0MDTt2EU2 0qhMvrqHE5hLja+O6587ZL+6ic4zBQxOlbFxbJLAn6hgqGtCTY48xl3srjJdqhwDL20L Ze3Vfb88ftyMYn2L2Trd4PVFUShhTLRjpGLLS1QvATT3aCMCLW8oOON8dq2xVJMEfJq2 WssylIrcqkruUESnAwAV/FYRA4ly7nScZZjfJQI7AL8xgKoj2bP0nickWQF3UGTulAXb JFacY4QTUJ/feSW5EAS2bDtAPH5o8chU/zyKQkM2FgBrtpRehOtvpkJ4a8EIpN6QJmfi C6eQ== X-Gm-Message-State: AOAM531eQegSefENRZf84cvJwnVs7s35iniknqEQBYHwq9nLLy6ACKpR vQh/3O0AW/pdXJuujFqIN0+5xJf5nv38MF90vRWHpnH4wHF769NkiKFZUPIqogFy8pcyhbJy/CL K/ecGCVljWjq9uHPgl9q3/IQN X-Received: by 2002:a05:6402:34c1:: with SMTP id w1mr25963edc.179.1638290288841; Tue, 30 Nov 2021 08:38:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJ5of5X1ECEam1JnSqoE7iOydgDzs5/xv1cDiErbxe2Ej6jbIkRK2l6KAKSP/S7E9UQICnOw== X-Received: by 2002:a05:6402:34c1:: with SMTP id w1mr25951edc.179.1638290288710; Tue, 30 Nov 2021 08:38:08 -0800 (PST) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c4ad]) by smtp.gmail.com with ESMTPSA id gt18sm9745641ejc.46.2021.11.30.08.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 08:38:08 -0800 (PST) From: christian.ehrhardt@canonical.com To: Junxiao Shi Cc: Jakub Grajciar , dpdk stable Subject: patch 'net/memif: fix chained mbuf determination' has been queued to stable release 19.11.11 Date: Tue, 30 Nov 2021 17:34:04 +0100 Message-Id: <20211130163605.2460997-40-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211130163605.2460997-1-christian.ehrhardt@canonical.com> References: <20211130163605.2460997-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 19.11.11 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before December 10th 2021. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/331267709a220bd79e72a8455bad2affb7c05119 Thanks. Christian Ehrhardt --- >From 331267709a220bd79e72a8455bad2affb7c05119 Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Thu, 9 Sep 2021 14:42:06 +0000 Subject: [PATCH] net/memif: fix chained mbuf determination [ upstream commit 3e3f736e50fba910d1d484b9c763d884dff6688f ] Previously, TX functions call rte_pktmbuf_is_contiguous to determine whether an mbuf is chained. However, rte_pktmbuf_is_contiguous is designed to work on the first mbuf of a packet only. In case a packet contains three or more segment mbufs in a chain, it may cause truncated packets or rte_mbuf_sanity_check panics. This patch updates TX functions to determine chained mbufs using mbuf_head->nb_segs field, which works in all cases. Moreover, it maintains that the second cacheline is only accessed when chained mbuf is actually present. Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD") Fixes: 43b815d88188 ("net/memif: support zero-copy slave") Signed-off-by: Junxiao Shi Reviewed-by: Jakub Grajciar --- drivers/net/memif/rte_eth_memif.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index e275366720..13758c6d9e 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -190,6 +190,7 @@ memif_dev_info(struct rte_eth_dev *dev __rte_unused, struct rte_eth_dev_info *de dev_info->max_rx_queues = ETH_MEMIF_MAX_NUM_Q_PAIRS; dev_info->max_tx_queues = ETH_MEMIF_MAX_NUM_Q_PAIRS; dev_info->min_rx_bufsize = 0; + dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MULTI_SEGS; return 0; } @@ -540,7 +541,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) rte_eth_devices[mq->in_port].process_private; memif_ring_t *ring = memif_get_ring_from_queue(proc_private, mq); uint16_t slot, saved_slot, n_free, ring_size, mask, n_tx_pkts = 0; - uint16_t src_len, src_off, dst_len, dst_off, cp_len; + uint16_t src_len, src_off, dst_len, dst_off, cp_len, nb_segs; memif_ring_type_t type = mq->type; memif_desc_t *d0; struct rte_mbuf *mbuf; @@ -588,6 +589,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) while (n_tx_pkts < nb_pkts && n_free) { mbuf_head = *bufs++; + nb_segs = mbuf_head->nb_segs; mbuf = mbuf_head; saved_slot = slot; @@ -631,7 +633,7 @@ next_in_chain: d0->length = dst_off; } - if (rte_pktmbuf_is_contiguous(mbuf) == 0) { + if (--nb_segs > 0) { mbuf = mbuf->next; goto next_in_chain; } @@ -668,6 +670,7 @@ memif_tx_one_zc(struct pmd_process_private *proc_private, struct memif_queue *mq uint16_t slot, uint16_t n_free) { memif_desc_t *d0; + uint16_t nb_segs = mbuf->nb_segs; int used_slots = 1; next_in_chain: @@ -688,7 +691,7 @@ next_in_chain: d0->flags = 0; /* check if buffer is chained */ - if (rte_pktmbuf_is_contiguous(mbuf) == 0) { + if (--nb_segs > 0) { if (n_free < 2) return 0; /* mark buffer as chained */ -- 2.34.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-30 16:50:08.411404472 +0100 +++ 0040-net-memif-fix-chained-mbuf-determination.patch 2021-11-30 16:50:05.654872532 +0100 @@ -1 +1 @@ -From 3e3f736e50fba910d1d484b9c763d884dff6688f Mon Sep 17 00:00:00 2001 +From 331267709a220bd79e72a8455bad2affb7c05119 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 3e3f736e50fba910d1d484b9c763d884dff6688f ] + @@ -19 +20,0 @@ -Cc: stable@dpdk.org @@ -28 +29 @@ -index de6becd45e..fd9e877c3d 100644 +index e275366720..13758c6d9e 100644 @@ -31 +32 @@ -@@ -199,6 +199,7 @@ memif_dev_info(struct rte_eth_dev *dev __rte_unused, struct rte_eth_dev_info *de +@@ -190,6 +190,7 @@ memif_dev_info(struct rte_eth_dev *dev __rte_unused, struct rte_eth_dev_info *de @@ -39 +40 @@ -@@ -567,7 +568,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +@@ -540,7 +541,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) @@ -48 +49 @@ -@@ -615,6 +616,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) +@@ -588,6 +589,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) @@ -56 +57 @@ -@@ -659,7 +661,7 @@ next_in_chain: +@@ -631,7 +633,7 @@ next_in_chain: @@ -65 +66 @@ -@@ -696,6 +698,7 @@ memif_tx_one_zc(struct pmd_process_private *proc_private, struct memif_queue *mq +@@ -668,6 +670,7 @@ memif_tx_one_zc(struct pmd_process_private *proc_private, struct memif_queue *mq @@ -73 +74 @@ -@@ -716,7 +719,7 @@ next_in_chain: +@@ -688,7 +691,7 @@ next_in_chain: