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 243E5A0093; Fri, 10 Dec 2021 08:59:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BD2240DDB; Fri, 10 Dec 2021 08:59:05 +0100 (CET) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id CAE5B4014F for ; Fri, 10 Dec 2021 08:59:03 +0100 (CET) Received: by mail-pj1-f49.google.com with SMTP id h24so6280508pjq.2 for ; Thu, 09 Dec 2021 23:59:03 -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=0oZMLKBxkd4XsnLb4SpEx6VFayeO5G7DQJd/FFAEwXo=; b=F7GF4ew1WkRJ6Flf9Y1P127M2YPUL2hXVbl7IWi1UkHSOlHvJnfZsRbMMw8Hn9Q3mv boBjy7bV0HlLBGsNQhi3Wt3pgUr3yTqM/vcwt+UxXMz03rlfkTE5vlfkz56LCj8MirHv uOeoZqhD8pNeKGnR/mblDou4lUGRiDtJbq3RrSV3x9SVu6d0InSL60Crfkpj79My7tW8 bLpwN5chO85cpX0PWiWNFWVZ9XGBjCJcAUmWor3j7LyEECbeFsWZW+ncCtoFJaRZ2MD8 KyjmTIriYz5M6uNbJbew0cQGsYnWyBGQzuTU59leqkfqObOzdC39DMeJfWkMi6ToGzBX 5VGg== 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=0oZMLKBxkd4XsnLb4SpEx6VFayeO5G7DQJd/FFAEwXo=; b=fqo5VcaQ3O1I+ancFH6XSAHAJZrECZkQUzmStURvBSNY77wKsfuklr+aHtAAqMneD5 9UPpOxxJ+ktHpJCe9yHgKBaMewO32DBKfin68PvW9qg7ExmxLtdIWaXcNRZKR2yriplD CkMc+HC1mZzghopeP8BN5bnBsssf7k6/G8/GKcfxx/wdXxT5WIfcgC5D/yulB/2gx4Ok yQLvSTbOGqpqWIB1C8Kz1iqKMbIiNmEjAx+5c8PoK+p89gzl3/iI85Gl7PBY9CNQEgnw wK4hK1efXVtCwSo/HzOrwGLs6e3E3WmCUMbqKX21Virw7g0zuMz0zK+HCc6pjAsFZRtx saOg== X-Gm-Message-State: AOAM5317L9v0Su/jwG+YNVvaYdAVjY0oZ5DsbUImK+yoB/qcRFSgynqS xLNmcMiD3n63b9nQVwhm5rJSYWXIKGISZYXg X-Google-Smtp-Source: ABdhPJzzNaVkeo3HP9mJmulMV6piVh6G29J64P647zKtC8zYIlB15uUq6W0WV3uup8gbWU6qzFm3+A== X-Received: by 2002:a17:90a:28c4:: with SMTP id f62mr21777694pjd.207.1639123142702; Thu, 09 Dec 2021 23:59:02 -0800 (PST) Received: from n248-168-070.byted.org. ([121.30.179.4]) by smtp.gmail.com with ESMTPSA id f8sm2273110pfc.77.2021.12.09.23.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 23:59:02 -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 15:58:55 +0800 Message-Id: <20211210075855.4095173-1-zhengbin.89740@bytedance.com> X-Mailer: git-send-email 2.20.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 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