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 9160145E66; Tue, 10 Dec 2024 08:07:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8047640264; Tue, 10 Dec 2024 08:07:20 +0100 (CET) Received: from zg8tmja5ljk3lje4ms43mwaa.icoremail.net (zg8tmja5ljk3lje4ms43mwaa.icoremail.net [209.97.181.73]) by mails.dpdk.org (Postfix) with ESMTP id 1122B4025A for ; Tue, 10 Dec 2024 08:07:19 +0100 (CET) Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-6 (Coremail) with SMTP id AQAAfwDHz9+j6FdnABNCCA--.28377S2; Tue, 10 Dec 2024 15:07:15 +0800 (CST) Received: from localhost.localdomain (unknown [218.76.62.144]) by mail (Coremail) with SMTP id AQAAfwDXJ3Sh6FdnsX1mAA--.10077S3; Tue, 10 Dec 2024 15:07:13 +0800 (CST) From: Wencheng Li To: stephen@networkplumber.org Cc: dev@dpdk.org, liwencheng@phytium.com.cn Subject: [PATCH v3 3/6] net/macb: fix logic error in macb_rxq_rearm function Date: Tue, 10 Dec 2024 07:07:06 +0000 Message-Id: <1733814426-412107-1-git-send-email-liwencheng@phytium.com.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1731310965-1743397-1-git-send-email-liwencheng@phytium.com.cn> References: <1731310965-1743397-1-git-send-email-liwencheng@phytium.com.cn> X-CM-TRANSID: AQAAfwDXJ3Sh6FdnsX1mAA--.10077S3 X-CM-SenderInfo: polzv0xfkh0wo6sk53xlxphulrpou0/ Authentication-Results: hzbj-icmmx-6; spf=neutral smtp.mail=liwencheng @phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7Kr4DWFy3Ar4fKF4rZr4UXFb_yoW8KFW8pF nxA3WUWw1rJFW7Gws5Ca1fW345Gasxtry8WF47Wwn8ZF4akr1rXa15Jr40vFW8CrWrZa1v vw4DGF9xXwn8XaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU 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 Fixed an issue in the macb_rxq_rearm function where descriptors were incorrectly set when mbuf allocation failed, leading to abnormal behavior of the network card. Fixes: e02b0b31cbdc ("net/macb: add NEON vectorized Rx/Tx") Cc: liwencheng@phytium.com.cn Signed-off-by: Wencheng Li --- drivers/net/macb/macb_rxtx_vec_neon.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/net/macb/macb_rxtx_vec_neon.c b/drivers/net/macb/macb_rxtx_vec_neon.c index 7f02a57..3888d5d 100644 --- a/drivers/net/macb/macb_rxtx_vec_neon.c +++ b/drivers/net/macb/macb_rxtx_vec_neon.c @@ -70,8 +70,6 @@ static inline void macb_rxq_rearm(struct macb_rx_queue *rxq) struct macb *bp; register int i = 0; struct macb_rx_entry *rxe; - - uint32x2_t zero = vdup_n_u32(0); uint8x8_t rearm_data_vec; bp = rxq->bp; @@ -85,14 +83,7 @@ static inline void macb_rxq_rearm(struct macb_rx_queue *rxq) /* Pull 'n' more MBUFs into the software ring */ if (unlikely(rte_mempool_get_bulk(rxq->mb_pool, (void *)rxe, MACB_RXQ_REARM_THRESH) < 0)) { - if (rxq->rxrearm_nb + (unsigned int)MACB_RXQ_REARM_THRESH >= - rxq->nb_rx_desc) { - MACB_LOG(ERR, "allocate mbuf fail!\n"); - for (i = 0; i < MACB_DESCS_PER_LOOP; i++) { - rxe[i].mbuf = &rxq->fake_mbuf; - vst1_u32((uint32_t *)&desc[MACB_DESC_ADDR_INTERVAL * i], zero); - } - } + MACB_LOG(ERR, "allocate mbuf fail!\n"); rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed += MACB_RXQ_REARM_THRESH; return; @@ -173,16 +164,16 @@ static uint16_t macb_recv_raw_pkts_vec(struct macb_rx_queue *rxq, }; uint16x8_t crc_adjust = {0, 0, rxq->crc_len, 0, rxq->crc_len, 0, 0, 0}; - /* nb_pkts shall be less equal than MACB_MAX_RX_BURST */ - nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, MACB_DESCS_PER_LOOP); - nb_pkts = RTE_MIN(nb_pkts, MACB_MAX_RX_BURST); - desc = rxq->rx_ring + rxq->rx_tail * MACB_DESC_ADDR_INTERVAL; rte_prefetch_non_temporal(desc); if (rxq->rxrearm_nb >= MACB_RXQ_REARM_THRESH) macb_rxq_rearm(rxq); + nb_pkts = RTE_MIN(nb_pkts, rxq->nb_rx_desc - rxq->rxrearm_nb); + nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, MACB_DESCS_PER_LOOP); + nb_pkts = RTE_MIN(nb_pkts, MACB_MAX_RX_BURST); + /* Make hw descriptor updates visible to CPU */ rte_rmb(); -- 2.7.4