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 81F39A0C41 for ; Thu, 2 Dec 2021 09:31:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4971F4067B; Thu, 2 Dec 2021 09:31:54 +0100 (CET) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id 71CF64067B for ; Thu, 2 Dec 2021 09:31:52 +0100 (CET) Received: by mail-pg1-f169.google.com with SMTP id l190so26329841pge.7 for ; Thu, 02 Dec 2021 00:31:52 -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=HEBljtqxSFa77rNK97eh/EdZes7wk4Lv+5FoeV/qgXgpLIC7D7c/jJcpyLLTnTo4+r PCaGNC/1HiWhpnsqRU1DGmyBpMUziPtZWelFckMLwu3eu0xzFUIr5JMtv1hFM/rf6vqY o20nUGZFOGvZceLOdrIzDtbEUJ8dmuQwUcAydXdHSAoyplxyoV2Ett8bJK996atEfyEy 3trozIGyy3sLaH2J9ozMGFgrMK6P4tHmTqsQA5lDvSAdMcL6Z5BPifTQQjICPxdUxZTY L8klMNwWmVModIgMRQeskwiVZtSr0udub90b+SZDxW+L99Ir2oIXBq3PZkOTVYjL6eT/ zdag== 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=FdzaxCSqFHr0KWyvLb9aq+3ZVvDmq0jfhhLsn3c8Wy+xYOR2a1XmjklIAYys9xsY4R 3vdNWA0cbUNTTPX5PmWmRh61Kq2EXGdiKwU2ZoiZM+gtB670QoWvUVMawhqHpzeYQPd7 RMpXq7mrpd9x+Rs+LR1DvWm1cusf2sBL8HYCuVWBoIntTTSVgeK5ljzCgUJgQOtcm/16 F1M7n9gNX82DiuzRpjZUbCX+QvnlgEFnq3f8r2sdzilRk9J0R67vV7zleFEZBCS2MfA0 v9+AQjZyQC2wCKTXDP6dtjzNNX562n8Of4eg3rck47sQdyXH1RRH+zpj6QivVGSjjKIt zahg== X-Gm-Message-State: AOAM532HVRU0pxyhCtkKkD6z3U5iq7fH3RmitMsv4Ah0H8qMC0QtRS5L yFOau2GCA6zg0JtBv8XKfUqzug== X-Google-Smtp-Source: ABdhPJwEXngkwa8VDjQ7WycQRlgLsjGD8mhB4yIGgHYTngZhxfqRFniLBD5Px3qUIupOA6w3QOC91A== X-Received: by 2002:aa7:8e48:0:b0:4a7:fe01:5971 with SMTP id d8-20020aa78e48000000b004a7fe015971mr11168936pfr.20.1638433911331; Thu, 02 Dec 2021 00:31:51 -0800 (PST) Received: from workstation-Precision-3640-Tower.bytedance.net ([61.120.150.75]) by smtp.gmail.com with ESMTPSA id d3sm2510697pfv.57.2021.12.02.00.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 00:31:50 -0800 (PST) From: Bin Zheng To: zhengbin89740@163.com Cc: 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 16:31:40 +0800 Message-Id: <20211202083141.1828057-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 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