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 CE8EAA0C47; Thu, 2 Dec 2021 04:19:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 584D740DDA; Thu, 2 Dec 2021 04:19:11 +0100 (CET) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mails.dpdk.org (Postfix) with ESMTP id BBFDE4067B for ; Thu, 2 Dec 2021 04:19:09 +0100 (CET) Received: by mail-pf1-f179.google.com with SMTP id o4so26584638pfp.13 for ; Wed, 01 Dec 2021 19:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sLf/x7cqwkBR0oICR0vzxvfNc5UvyJm1qT30HeGJawc=; b=VD907Me8iyi+dV/+1eEIJwxBWCb8m3gD5d14BqPAocaeEOIIk4imr8KfR+Hh5Cm+CD Wi9iI614wUx7vB/RblG98JJKuELXldvzbJpzwJxm2s533piGziRBWfS0M7PQeFT1XXRX OW0Rs0AMMwPgnGgqApoYs5HrfneLWWa2S6iwrG6Uc+162HVgY1/0IT2p/GsX4118QdHS 8kULg1DtVzts/h8V0GgG8IsRtUDbqo3gRsu68xT5KM8B9FvGZQxT2yT0GAkyvTkUJ65+ X2AG0YgF/u15bNFUMDgYbky5/tGRtv/zBOgcgpvbHfjeGE/aVmkIwdAQIzfjkHCzOlEr fduA== 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=sLf/x7cqwkBR0oICR0vzxvfNc5UvyJm1qT30HeGJawc=; b=dbtJUelTxBWS2GHFgPQ9ImCUfNaKTUSp0hCShsLQ9z7JOoHj48FAD+UAW6qLBCTxmf aFYy321fD5CUB3lmIILA1www31ZfctA25tcUa0PrIwHP0qaIGqKalPT5oYBVmsYi4dl1 X+Cl8nh9Mnog9Xa1f1WrrlUDl3pYJI0r6z4AJh1RZZZWynWgqpLrQfdIYGmp88S01/lA ytgadIH+g42yE+bJ1e/APnJGuUoncDNESIuFpXpRPsqlOjksZMPufmXNCJle0104ErkN NIt2/JosiC+vrk9WpFxFf8uGy6cBJN9qkdky5Q7k7QxlAfWxvQtte+JAH0NqNfKKzP96 DMtQ== X-Gm-Message-State: AOAM533BzLSwNJzfnyJHtQ9aUjOuip0ZUvMvgHyDRElcavpZ6nk7xlPR 8A+s1VaYljQaDcIuzyeD+rHEU55+GpBCSQ== X-Google-Smtp-Source: ABdhPJwndx8ZbpPlgbdZyhjDmYyGPXZrvBfeeUkSY53NIdZicVAVxJU+w5WwKwqGkje4g3cwJMcGtQ== X-Received: by 2002:a63:5b18:: with SMTP id p24mr2770577pgb.589.1638415148579; Wed, 01 Dec 2021 19:19:08 -0800 (PST) Received: from workstation-Precision-3640-Tower.bytedance.net ([61.120.150.75]) by smtp.gmail.com with ESMTPSA id bt2sm623392pjb.57.2021.12.01.19.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 19:19:07 -0800 (PST) From: Bin Zheng To: dev@dpdk.org Cc: haiyue.wang@intel.com, liangma@liangbit.com, Bin Zheng , jia.guo@intel.com, stable@dpdk.org Subject: [PATCH] net/ixgbe: add vector Rx parameter check Date: Thu, 2 Dec 2021 11:18:57 +0800 Message-Id: <20211202031857.1808705-1-zhengbin.89740@bytedance.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 Under the circumstance that `rx_tail` wrap back to zero and the advance speed of `rx_tail` is greater than `rxrearm_start`, `rx_tail` will catch up with `rxrearm_start` and surpass it. This may cause some mbufs be reused by applicaion. So we need to make some restrictions to ensure that `rx_tail` will not exceed `rxrearm_start`. e.g. RDH: 972 RDT: 991 rxrearm_nb: 991 rxrearm_start: 992 rx_tail: 959 RDH: 1004 RDT: 1023 rxrearm_nb: 991 rxrearm_start: 0 rx_tail: 991 RDH: 12 RDT: 31 rxrearm_nb: 991 rxrearm_start: 32 rx_tail: 1023 RDH: 31 RDT: 63 rxrearm_nb: 960 rxrearm_start: 64 rx_tail: 0 RDH: 95 RDT: 95 rxrearm_nb: 1016 rxrearm_start: 96 rx_tail: 88 RDH: 95 RDT: 127 rxrearm_nb: 991 rxrearm_start: 128 rx_tail: 95 ... RDH: 908 RDT: 927 rxrearm_nb: 991 rxrearm_start: 928 rx_tail: 895 RDH: 940 RDT: 959 rxrearm_nb: 991 rxrearm_start: 960 rx_tail: 927 RDH: 980 RDT: 991 rxrearm_nb: 991 rxrearm_start: 992 rx_tail: 959 RDH: 991 RDT: 991 rxrearm_nb: 1026 rxrearm_start: 992 rx_tail: 994 when `rx_tail` catches up with `rxrearm_start`, 2(994 - 992) mbufs be reused by applicaion ! Bugzilla ID: 882 Fixes: 5a3cca342417 ("net/ixgbe: fix vector Rx") Cc: jia.guo@intel.com Cc: stable@dpdk.org Signed-off-by: Bin Zheng --- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c index 1eed949495..5811749b95 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c @@ -364,6 +364,17 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts, uint8_t vlan_flags; uint16_t udp_p_flag = 0; /* Rx Descriptor UDP header present */ + /* + * Under the circumstance that `rx_tail` wrap back to zero + * and the advance speed of `rx_tail` is greater than `rxrearm_start`, + * `rx_tail` will catch up with `rxrearm_start` and surpass it. + * This may cause some mbufs be reused by applicaion. + * + * So we need to make some restrictions to ensure that + * `rx_tail` will not exceed `rxrearm_start`. + */ + nb_pkts = RTE_MIN(nb_pkts, RTE_IXGBE_RXQ_REARM_THRESH); + /* nb_pkts has to be floor-aligned to RTE_IXGBE_DESCS_PER_LOOP */ nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_IXGBE_DESCS_PER_LOOP); -- 2.25.1