From patchwork Tue Mar 26 11:51:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Polchlopek X-Patchwork-Id: 13604017 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 319396F06F for ; Tue, 26 Mar 2024 12:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711454448; cv=none; b=j8d3CH6AxynI4xTa8QieBtEXme2Hx0hFg7e1bGCBRQIP4s1cP1O/NVFgIejhtAIQX/TwsybF1BDJ70fiSp7cYUWIF13QReaTV6uUo86IEEAeacAZekbOh134y2YALgLDF6nqXXoy/OvSU/3EvW7eMyT87Dr2R+egi2HzCH2gDbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711454448; c=relaxed/simple; bh=tYbBYDMLSQVsOXeyyC8DsZGcWzL9vGmFv9B1ulDlnVA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AZp5d34ZUStOtb1wSexwQRjgOdTkN15NJQ83Zdf7otFQRldbZqXt5gOCHryo8vixJs55t59xfmaPN1DsQ2S5BHjjPCdQc56h6nDZMnpDqdXI2rg+7Dfpq2VTGjz5wOqbltn8aqOa9hd+cdCDgE8vQVFv+9F8blcSHYwIgsceoBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=M44CzvYu; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="M44CzvYu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711454447; x=1742990447; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tYbBYDMLSQVsOXeyyC8DsZGcWzL9vGmFv9B1ulDlnVA=; b=M44CzvYuyj3J6e6fDJj+Qt+k8QeuUIYwYDaVNgJVh3uzXIkj5EcCrkcG zxcSG0ILsWK7Tqa09ky8y6tXTH7uTlm9aVr+6oG1xL8Xn/ETnC9TBlFvN M3klFKNogWkm9MmKhKRavVaxWn//DuzYpSO3hprmPTfTrHrWGGtUIGRUR OPXRwu+p0lf1DaTHfsspSRJPg/+2/Dw3ix7SxsrhAhdtSFqXOqN8z3nQW G0rGLs8q5eVOb8xFoLCJod+QeRgivQ0ldLBevtg5APzz7Y9iNhzEVRrtP onVBvDrvWUylJ8qYG8/ZsLZWn0NGvvPsNluXmNbIiboWhgqOn5pjF2wCM Q==; X-CSE-ConnectionGUID: MBMZ7kE3QWuawq2C21OyaQ== X-CSE-MsgGUID: PhAtb2wwT+m7xxU9Dsdn3Q== X-IronPort-AV: E=McAfee;i="6600,9927,11024"; a="6366371" X-IronPort-AV: E=Sophos;i="6.07,156,1708416000"; d="scan'208";a="6366371" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2024 05:00:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,156,1708416000"; d="scan'208";a="20657416" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa005.jf.intel.com with ESMTP; 26 Mar 2024 05:00:44 -0700 Received: from fedora.igk.intel.com (Metan_eth.igk.intel.com [10.123.220.124]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 63F9F28197; Tue, 26 Mar 2024 12:00:43 +0000 (GMT) From: Mateusz Polchlopek To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, Mateusz Polchlopek , Wojciech Drewek Subject: [Intel-wired-lan] [PATCH iwl-next v1 10/12] iavf: Implement checking DD desc field Date: Tue, 26 Mar 2024 07:51:15 -0400 Message-Id: <20240326115116.10040-11-mateusz.polchlopek@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20240326115116.10040-1-mateusz.polchlopek@intel.com> References: <20240326115116.10040-1-mateusz.polchlopek@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Rx timestamping introduced in PF driver caused the need of refactoring the VF driver mechanism to check packet fields. The function to check errors in descriptor has been removed and from now only previously set struct fields are being checked. The field DD (descriptor done) needs to be checked at the very beginning, before extracting other fields. Reviewed-by: Wojciech Drewek Signed-off-by: Mateusz Polchlopek --- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 26 ++++++++++++++++++++- drivers/net/ethernet/intel/iavf/iavf_txrx.h | 17 -------------- drivers/net/ethernet/intel/iavf/iavf_type.h | 1 + 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c index e03694d0e1b1..4762126c77db 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -8,6 +8,26 @@ #include "iavf_trace.h" #include "iavf_prototype.h" +/** + * iavf_is_descriptor_done - tests DD bit in Rx descriptor + * @rx_ring: the ring parameter to distinguish descriptor type (flex/legacy) + * @rx_desc: pointer to receive descriptor + * + * This function tests the descriptor done bit in specified descriptor. Because + * there are two types of descriptors (legacy and flex) the parameter rx_ring + * is used to distinguish. + */ +static bool iavf_is_descriptor_done(struct iavf_ring *rx_ring, + union iavf_rx_desc *rx_desc) +{ + if (rx_ring->rxdid == VIRTCHNL_RXDID_1_32B_BASE) + return !!(FIELD_GET(cpu_to_le64(IAVF_RX_DESC_STATUS_DD_MASK), + rx_desc->wb.qword1.status_error_len)); + + return !!(FIELD_GET(cpu_to_le16(IAVF_RX_FLEX_DESC_STATUS_ERR0_DD_BIT), + rx_desc->flex_wb.status_error0)); +} + static __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, u32 td_tag) { @@ -1722,7 +1742,11 @@ static int iavf_clean_rx_irq(struct iavf_ring *rx_ring, int budget) * verified the descriptor has been written back. */ dma_rmb(); - if (!iavf_test_staterr(rx_desc, IAVF_RX_DESC_STATUS_DD_MASK)) + + /* If DD field (descriptor done) is unset then other fields are + * not valid + */ + if (!iavf_is_descriptor_done(rx_ring, rx_desc)) break; iavf_extract_rx_fields(rx_ring, rx_desc, &fields); diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.h b/drivers/net/ethernet/intel/iavf/iavf_txrx.h index 67e51b4883bc..54d858303839 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.h +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.h @@ -153,23 +153,6 @@ static inline int iavf_skb_pad(void) #define IAVF_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN) #endif -/** - * iavf_test_staterr - tests bits in Rx descriptor status and error fields - * @rx_desc: pointer to receive descriptor (in le64 format) - * @stat_err_bits: value to mask - * - * This function does some fast chicanery in order to return the - * value of the mask which is really only used for boolean tests. - * The status_error_len doesn't need to be shifted because it begins - * at offset zero. - */ -static inline bool iavf_test_staterr(union iavf_rx_desc *rx_desc, - const u64 stat_err_bits) -{ - return !!(rx_desc->wb.qword1.status_error_len & - cpu_to_le64(stat_err_bits)); -} - struct iavf_rx_extracted { unsigned int size; u16 vlan_tag; diff --git a/drivers/net/ethernet/intel/iavf/iavf_type.h b/drivers/net/ethernet/intel/iavf/iavf_type.h index 90447a8c3a7a..b84416918e7d 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_type.h +++ b/drivers/net/ethernet/intel/iavf/iavf_type.h @@ -318,6 +318,7 @@ union iavf_32byte_rx_desc { */ #define IAVF_RX_DESC_STATUS_INT_UDP_0_MASK BIT(18) +#define IAVF_RX_FLEX_DESC_STATUS_ERR0_DD_BIT BIT(0) #define IAVF_RX_FLEX_DESC_STATUS_ERR0_EOP_BIT BIT(1) #define IAVF_RX_FLEX_DESC_STATUS_ERR0_RXE_BIT BIT(10)