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 65FC9A0093 for ; Fri, 10 Dec 2021 09:22:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DDA140041; Fri, 10 Dec 2021 09:22:18 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id ACE5940041 for ; Fri, 10 Dec 2021 09:22:17 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id y7so5831204plp.0 for ; Fri, 10 Dec 2021 00:22:17 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=0oZMLKBxkd4XsnLb4SpEx6VFayeO5G7DQJd/FFAEwXo=; b=8OHsR0dsNfOCzeJn8ERCV8wfHTxFofrez4gxzBbJ4gwwJU+5e+uhlZIqjJ7WafeOte LLmuKom5zLYEOmqKR0drWcNFMRc60gYAL1VY2Bp0yr7ARxOpoRjYGaZ1aoBL0+Lj+iYR cLVDusEdAlazWtDIIGiNcCBXISTcP4+9j1Ahu8Go256avb0owwaa8GoNiJAxMe0o2KaN uKqBS9GhsFxgeDKotajaabKmI/ortEHxWRyEO41n96qylErOkySe/eK7ZDT6w4PQVSwU IxAmQjEeo5GksM5pmSnG6zLRTCEo3T54bai6+uMnqfCIokcXvN5GzxwMDJG3Dih9FyAQ oLUg== 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=0oZMLKBxkd4XsnLb4SpEx6VFayeO5G7DQJd/FFAEwXo=; b=ixUkFA+JOeee57VxLuZ6iM+Yla8WWOlmwpgM4gR3JTWE2hX17VA7PTeMIHoQ0EMorw rYTqL7u/5ebrVjx2v8up6PObNlLwrh1ajOISp52Kvi6AuebFK0HaOj36u4CODcgXwrOe rsAKOLqr5vgRrLwmsz+xK/ERykCLhnZIj4ax5uEXcQgLnHb3YDYtkH4VpYgReCaP2Zxk p0pydvqCfJTL/cU3wbUNZ5MgGOaSeH0mN7n4xZPIq8zVpaoNRDZSpsqvg6cSYhwriCQ4 cVAFTyzLPfgXcztXrT5C3JkyphKqG9mBvJVMxtQcSsl6LbvYxY+om9BirGP13n/binZ+ v6jg== X-Gm-Message-State: AOAM532NAAbzfsP4GCW4LqpeRO2P6pOkirlXnzX3WoZrFNUynP/14Hdw ijefuFdllldUy8S/T8VRiF1zQQ== X-Google-Smtp-Source: ABdhPJx/oSfh9oho7SSUF9562jXT9W1T6WHZzJfPVyP4qM93IL9x7BAFJDKIpLVlvWlWaCSjhpTL/w== X-Received: by 2002:a17:903:18d:b0:142:8ab:d11f with SMTP id z13-20020a170903018d00b0014208abd11fmr74413340plg.47.1639124536458; Fri, 10 Dec 2021 00:22:16 -0800 (PST) Received: from n248-168-070.byted.org. ([121.30.179.132]) by smtp.gmail.com with ESMTPSA id k18sm2543963pfc.155.2021.12.10.00.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 00:22:15 -0800 (PST) From: Bin Zheng To: dev@dpdk.org Cc: haiyue.wang@intel.com, liangma@liangbit.com, stable@dpdk.org, leyi.rong@intel.com, Bin Zheng , jia.guo@intel.com Subject: [PATCH v3] net/ixgbe: add vector Rx parameter check Date: Fri, 10 Dec 2021 16:22:09 +0800 Message-Id: <20211210082209.4102794-1-zhengbin.89740@bytedance.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211202092001.1830481-2-zhengbin.89740@bytedance.com> References: <20211202092001.1830481-2-zhengbin.89740@bytedance.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 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 application. 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 application ! 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..4654d0adec 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 application. + * + * 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