From patchwork Fri Nov 11 12:04:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingjin Ye X-Patchwork-Id: 119738 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F38DAA0542; Fri, 11 Nov 2022 05:17:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55CBC40697; Fri, 11 Nov 2022 05:17:08 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 0D011400EF; Fri, 11 Nov 2022 05:17:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668140227; x=1699676227; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q8i/myDNUtWCUNSwselhYGHG9I+qjV+vr5b3RshO/co=; b=NE8mECYka9qmf7BIo9+7RTPI4nv+n66vb1styVmEMjFQqwXoreUnyNrh d/kLIiSZjOgBhEq2IGLJpj1SDEoQghjW9mbWi6JpoNQnhKSseGMiXxLP7 /zbZ6WFD2CZ7/zVZssuT7ubMZOV1uBkRuIq99Ax8af4i6L+S9fxsEHVkb zwrANvJwCu4iZ3PyYUtsPwfHUJLRSoBL/MLkTQJdO/OaVWBcIj8TMeAca 2vtWNX4pFfCrkg+gs6CzfZK51L93S8GC8SsdRLzxeMC1EJr03uecytp3k nbgbig4mKQjBYvDFre1vA32aRqnZ8Ck/FwGZzYafFGklpat9enO0pxlCc g==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="397815419" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="397815419" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 20:17:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="966690104" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="966690104" Received: from unknown (HELO yemj..) ([10.239.252.253]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 20:17:03 -0800 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, stable@dpdk.org, yidingx.zhou@intel.com, Mingjin Ye , Qi Zhang , Ferruh Yigit , Jingjing Wu , Wenzhuo Lu , Xiaoyun Li Subject: [PATCH v3 1/2] net/ice: fix scalar Rx path segment Date: Fri, 11 Nov 2022 12:04:00 +0000 Message-Id: <20221111120401.802805-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109125609.724612-1-mingjinx.ye@intel.com> References: <20221109125609.724612-1-mingjinx.ye@intel.com> MIME-Version: 1.0 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. The last buffer is invalid if it's packet length is zero. This patch adds a judgment for the last buffer length to fix this issue, 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 Acked-by: Qi Zhang --- drivers/net/ice/ice_rxtx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 0a2b0376ac..e6ddd2513d 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; From patchwork Fri Nov 11 12:04:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingjin Ye X-Patchwork-Id: 119739 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A1BE0A0542; Fri, 11 Nov 2022 05:17:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5BD0342B7E; Fri, 11 Nov 2022 05:17:15 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 74D4A40141; Fri, 11 Nov 2022 05:17:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668140233; x=1699676233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ggxn/Qg9uUy5g5kJX8gH2yj9MHKXUG8aKeoVVjNM1RM=; b=PqhmsPeDWt8uL6IeqTjfWWUlxC73o4geU/iCYXq4/9VC305mTYvKz+/I c0lgysTjCKbbqWMWu7YiyYEE5KeSF8AqnFrjSBRnMbY0OjpViKxoPSJHl DkKIwRrpgJfMSYnSzU/EXNnnJdA7Ey1G6x7V8tEi/+fJMLlgAxxW5dguz B5c7Xel0OGxhBW9CD+J8bN1B3RQS0JForgoA08PEfkO2dfRo1+tE3/vRc 6WIL9hjVKeBkjzPtjXEzNu5kh2K5wMLqZfnk7n+y6EJqB4YocCZfQlvOE 5Wc6tHlfe3UVq7lkPyY8ccjR83ugkqsy58jVJ/3RoNx78Q2hirLFfhiUt w==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="373647559" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="373647559" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 20:17:12 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="966690140" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="966690140" Received: from unknown (HELO yemj..) ([10.239.252.253]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 20:17:09 -0800 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, stable@dpdk.org, yidingx.zhou@intel.com, Mingjin Ye , Qi Zhang , Jingjing Wu , Wenzhuo Lu , Ferruh Yigit , Xiaoyun Li , Kevin Liu Subject: [PATCH v3 2/2] net/ice: fix scalar Tx path segment Date: Fri, 11 Nov 2022 12:04:01 +0000 Message-Id: <20221111120401.802805-2-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111120401.802805-1-mingjinx.ye@intel.com> References: <20221109125609.724612-1-mingjinx.ye@intel.com> <20221111120401.802805-1-mingjinx.ye@intel.com> MIME-Version: 1.0 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 The scalar Tx path would send empty buffer that causes the Tx queue to overflow. This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is empty. Fixes: 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx") Fixes: ccf33dccf7aa ("net/ice: check illegal packet sizes") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye --- drivers/net/ice/ice_rxtx.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index e6ddd2513d..69358f6a3a 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) #define ICE_MIN_TSO_MSS 64 #define ICE_MAX_TSO_MSS 9728 #define ICE_MAX_TSO_FRAME_SIZE 262144 + +/*Check for invalid mbuf*/ +static inline uint16_t +ice_check_mbuf(struct rte_mbuf *tx_pkt) +{ + struct rte_mbuf *txd = tx_pkt; + + while (txd != NULL) { + if (txd->data_len == 0) + return -1; + txd = txd->next; + } + + return 0; +} + uint16_t ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) @@ -3653,6 +3669,7 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, struct ice_tx_queue *txq = tx_queue; struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id]; uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD; + uint16_t nb_used; for (i = 0; i < nb_pkts; i++) { m = tx_pkts[i]; @@ -3689,6 +3706,13 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, rte_errno = -ret; return i; } + + if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) && + ice_check_mbuf(m)) { + rte_errno = EINVAL; + PMD_DRV_LOG(ERR, "INVALID mbuf: last mbuf data_len=[0]"); + return i; + } } return i; }