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 09EB0A0C47 for ; Thu, 2 Dec 2021 04:15:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 011364067B; Thu, 2 Dec 2021 04:15:47 +0100 (CET) Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by mails.dpdk.org (Postfix) with ESMTP id 8605B40140 for ; Thu, 2 Dec 2021 04:15:45 +0100 (CET) Received: by mail-pg1-f175.google.com with SMTP id 71so25655257pgb.4 for ; Wed, 01 Dec 2021 19:15:45 -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=T/dlw7Hb+Bpb4ExJkWH0dW5ZA+vCeSr5rUD/0n/xw4U=; b=IUMAe0TrdeB1Yo0iw6esbb4/cQaPVrIp/+UKyU8I2tsHDv2qktNLmJ5VBcWWt7Tcv+ kZsF/jozsiy//LT4wkZYGnF7Lt3tXeiyz/4ck49S+a59V7hbjh5Zc+pA4jbXd6ulzVia +dj6nv7/YzS15saOB8NVPv3KdrtxQnCTHDGBkZrhq/DDR4WG1CcdbOzWDLFs0Yk/2Rmk 8RXeSqwzfUDfGsonX/yaNiSNCd67gjkx2bWwOIOFAJmZ8ROMd3yOymMh1rb6wpW6I0nY gsl4Qv+4HHq+CEnDKdW58r81lkY5jzYYLmTUgrD9Cu/TLHU7SBpjdT+mWSbMvwgHOYUq S2Sw== 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=T/dlw7Hb+Bpb4ExJkWH0dW5ZA+vCeSr5rUD/0n/xw4U=; b=XamLKKmjx3Mgw96OxtzS7hGEqa7CtZFZdl8jnNk0S0DONDkEsPoK1nn9+vmtvobnn8 KRf1mf3S0RgjIputP22ny55P28nrNu0hAKg+qF39gcg2QYLLkgUfmPqXU+is2WuWRXoX uKiNWFaUNeS8qKep2P+29H66k2lkvSWVpTAoVMYXNAruQEWgFYfknh4hyqm9QYmy2O6r /Fsr1biV0vmpg3hu5rhnrrqPfyxzH0Qn7QJTQpVjkdZl3LY9xCkCKoRDihX8SBFS/tDN dXhqJSa4wErdJHjcp4a9vVW7MwpJnTBl2MSflJizzNTbxyFthYX6go6xTpiFcD8p9K3o EXtg== X-Gm-Message-State: AOAM532fespnDhQb7U6U5rYs/MRk2mtjQv7MgFU2ObghWxFnwvpjdcXe 9R6G5EQP93kZCjJGKV/O7Cv11g== X-Google-Smtp-Source: ABdhPJxBMHAdh2hXi5LZQPafq04dU28ZyqxzpgvDMQgqW4fpAo0ewRMH9ghygqUgzH7b/o+L07kN4Q== X-Received: by 2002:aa7:950f:0:b0:4a2:54da:3a73 with SMTP id b15-20020aa7950f000000b004a254da3a73mr9853927pfp.18.1638414944463; Wed, 01 Dec 2021 19:15:44 -0800 (PST) Received: from workstation-Precision-3640-Tower.bytedance.net ([61.120.150.75]) by smtp.gmail.com with ESMTPSA id z22sm1310205pfe.93.2021.12.01.19.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 19:15:43 -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:15:30 +0800 Message-Id: <20211202031530.1808112-1-zhengbin.89740@bytedance.com> X-Mailer: git-send-email 2.25.1 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 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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c index 1eed949495..33d2e96266 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c @@ -364,9 +364,6 @@ _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 */ - /* 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); - /* Just the act of getting into the function from the application is * going to cost about 7 cycles */ @@ -380,6 +377,21 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts, if (rxq->rxrearm_nb > RTE_IXGBE_RXQ_REARM_THRESH) ixgbe_rxq_rearm(rxq); + /* + * 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`. + */ + if (rxq->rx_tail < rxq->rxrearm_start) + nb_pkts = RTE_MIN(nb_pkts, rxq->rxrearm_start - rxq->rx_tail - 1); + + /* 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); + /* Before we start moving massive data around, check to see if * there is actually a packet available */ -- 2.25.1