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 D93F4A00C2; Thu, 3 Nov 2022 10:33:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C787341147; Thu, 3 Nov 2022 10:33:53 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 8035A40693; Thu, 3 Nov 2022 10:33:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667468031; x=1699004031; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=X/yK2BUVlbzeqXE7sdu1PvTgaB7CZfltXA8JtXuOPBc=; b=IGW6isnxhE8C6oFC15rRBh6ZBbPLGZbhetBHhOc8nMuV2uQnsoBVMSHl +meHFofY4bdrF9OH19w5ZPVAHISCAFHzTy4AARM7oxFBDg3GkWgPN+qre /161lkMHWGdwxlLhWtJMs4KH2xSRJCg2RVj5E8TZ3906Yq0sKLPi5WtyY HEI8/n62tblKqqMDJy6vZTrFE3rQ/5H0OGqloz26TkA+hz3WHsMGmmsSh QjiVlthSqpCLoAesu3rTtnjoub0gvB+H9d4J6f9ZBc8nuicq6rzpVY3zC 3UBGGkFWQd9CLELl8qRmtY0vj4LDLOMRiRJoPgXgnH54Hrb9Laiw/NwnP g==; X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="292955707" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="292955707" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 02:33:50 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10519"; a="637107664" X-IronPort-AV: E=Sophos;i="5.95,235,1661842800"; d="scan'208";a="637107664" Received: from unknown (HELO yemj..) ([10.239.252.253]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 02:33:47 -0700 From: Mingjin Ye To: dev@dpdk.org Cc: stable@dpdk.org, yidingx.zhou@intel.com, Mingjin Ye , Qiming Yang , Qi Zhang , Jingjing Wu , Wenzhuo Lu , Ferruh Yigit , Xiaoyun Li Subject: [PATCH] net/ice: fix scalar Rx and Tx path segment Date: Thu, 3 Nov 2022 17:20:40 +0000 Message-Id: <20221103172040.388518-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.34.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 CRC is stripped by the hardware in the scattered Rx path. If the last buffer packet length is '0', the scalar Tx path would send empty buffer that causes the Tx queue to overflow. This patch adds a judgment for the last buffer length to fix this issue, so that it would free the mbuf associated to the last one if the last buffer is empty. Fixes: 6eac0b7fde95 ("net/ice: support advance Rx/Tx") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye --- drivers/net/ice/ice_rxtx.c | 53 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 0a2b0376ac..4f9c29eaf6 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue, } else rxm->data_len = (uint16_t)(rx_packet_len - RTE_ETHER_CRC_LEN); + } else if (rx_packet_len == 0) { + rte_pktmbuf_free_seg(rxm); + first_seg->nb_segs--; + last_seg->next = NULL; } first_seg->port = rxq->port_id; @@ -2903,6 +2907,35 @@ ice_calc_pkt_desc(struct rte_mbuf *tx_pkt) return count; } +/*Check the number of valid mbufs and free the invalid mbufs*/ +static inline uint16_t +ice_check_mbuf(struct rte_mbuf *tx_pkt) +{ + struct rte_mbuf *txd = tx_pkt; + struct rte_mbuf *txd_removal = NULL; + struct rte_mbuf *txd_pre = NULL; + uint16_t count = 0; + uint16_t removal = 0; + + while (txd != NULL) { + if (removal == 1 || txd->data_len == 0) { + txd_removal = txd; + txd = txd->next; + if (removal == 0) { + removal = 1; + txd_pre->next = NULL; + } + rte_pktmbuf_free_seg(txd_removal); + } else { + ++count; + txd_pre = txd; + txd = txd->next; + } + } + + return count; +} + uint16_t ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { @@ -2960,11 +2993,27 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) * the mbuf data size exceeds max data size that hw allows * per tx desc. */ - if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) + if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) { nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) + nb_ctx); - else + } else { + nb_used = ice_check_mbuf(tx_pkt); + if (nb_used == 0) { + PMD_TX_LOG(ERR, + "Check packets is empty " + "(port=%d queue=%d)\n", + txq->port_id, txq->queue_id); + continue; + } else if (nb_used < tx_pkt->nb_segs) { + PMD_TX_LOG(WRINING, + "Check packets valid num =" + "%4u total num = %4u (port=%d queue=%d)\n", + nb_used, tx_pkt->nb_segs, txq->port_id, txq->queue_id); + tx_pkt->nb_segs = nb_used; + } nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx); + } + tx_last = (uint16_t)(tx_id + nb_used - 1); /* Circular ring */ -- 2.34.1