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 9E915A0C41; Thu, 2 Dec 2021 10:20:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64869426D7; Thu, 2 Dec 2021 10:20:15 +0100 (CET) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id DC62940692 for ; Thu, 2 Dec 2021 10:20:13 +0100 (CET) Received: by mail-pf1-f181.google.com with SMTP id n26so27349322pff.3 for ; Thu, 02 Dec 2021 01:20:13 -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=k4ko+OiEH0B52VbGQ6UTI6RMsiTAr398IgSg6Xt5tws=; b=fWrDjo0W601cSvN1zWntKKOdKmmghxU09OmYU+K/MDbCGQ0ev2i/APwappn+kKdcEj GDyub/n4mFbrr4NNIaG9H2r/K4TGAUmq1GlNzH7Ti8CjJfPf7E2tTFh6gkkGo9/WyMmA qkEUzMYMiI14dJhMBk1RGADSApmTkeniLMse7flxiWdmz812UyKO5jfxhnHRAqyzYNDs kdHFTcLUbH1hG45y+sxGUb4V2C4kbQkToXXpu2zb+cgXOXuGaVucz55a0uHd2Wq2/+w7 vY9GeY0FWNWQLPOi+le4zAxyov4N+Fl7KeuIhTB6lwsuXbOD7kQ8MQtgCBZUVwTxyq53 WdyA== 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=k4ko+OiEH0B52VbGQ6UTI6RMsiTAr398IgSg6Xt5tws=; b=76i3vMb/s7fTR1rZM+rPhiTXRw/4mmqReqOq2eBq3Q+tvYqRX0eyIcf/0XFymOkxj7 JdmeIDQmYwxE/L3rml4ftnE2MrazTDp1KhFgLUpKRVLJQjJiuw0nBYBzus3NXvfsYmfU 2YJpfvWdwHdziE/Psyxa3mWxPjZvKbYk3ogze7sRzfrosR+qe/4Xui4ui9pa/h+Onnku sdbpJ3PInTiK6TAJOaHEjzFppQ3gVg3ERvKLmRGXeEVsbxP64DDvjxYZ6garySYyUTCJ Sxf40l2O24O+OdRHjX+vXP7uyttk8pPOXMIz9tD3U0nshZc+rpfNPk3wDmOFaBTUtGTo Kceg== X-Gm-Message-State: AOAM532vIYI1mzIb6n0gjSnDzTDjtkAue6QB2LYWIWOJt4ittaOeSUee J0iZTAN18yC4z2coOgNbSZlxD9WLs4mSgw== X-Google-Smtp-Source: ABdhPJxsw0EO4J0WJviaPgKAse+9vVsS6W7itCqsUIG7Dy1p9/xhOVJP7EJM/QwiOW4W2SZGpcpN5g== X-Received: by 2002:a05:6a00:1816:b0:49f:cd0d:b51b with SMTP id y22-20020a056a00181600b0049fcd0db51bmr11173494pfa.6.1638436812523; Thu, 02 Dec 2021 01:20:12 -0800 (PST) Received: from workstation-Precision-3640-Tower.bytedance.net ([61.120.150.75]) by smtp.gmail.com with ESMTPSA id w142sm2545761pfc.115.2021.12.02.01.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 01:20:12 -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 v2 1/2] net/ixgbe: add vector Rx parameter check Date: Thu, 2 Dec 2021 17:20:00 +0800 Message-Id: <20211202092001.1830481-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 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..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