From patchwork Wed Apr 10 12:17:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Polchlopek X-Patchwork-Id: 13624193 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 8A98515B54E for ; Wed, 10 Apr 2024 12:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712751999; cv=none; b=tj6+9wrn+uakJ4vUemngkOh9BXruQEZgAWgleGumJQ2vdoHB3kfTcxiSEnqL0cQILV6+QdLBK0VJbKTWKvVlHMkHiSBxgtVKk4NvRnn4/LlnfFsk7gY1CouKrRKMn36iXTm4lkCvLP1Ka4YMlDbExm0mI5ezSJSNpB2ip9NTTX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712751999; c=relaxed/simple; bh=qqI4Hy9HQ5zxSze1eLps1lHtL5YfZRaJ9DXMxGzdzmE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iZz2wqaLMj26cO9PD91mpHTkAS8mXmo5Ax7LgO4ITVQ42e90mUgHFCrqlylGiQNVg+dsAeexHzVF1SSHdTMAnl+UhcpFJs1/E2TCwV1gxjuh6eAJZXW7fU4EHeJL7Zf+FwtiJSlc92T7iG1gEHKm83luGD5ubqxxsaqmGNOVwHc= 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=lMZzkQuC; arc=none smtp.client-ip=198.175.65.19 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="lMZzkQuC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712751997; x=1744287997; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qqI4Hy9HQ5zxSze1eLps1lHtL5YfZRaJ9DXMxGzdzmE=; b=lMZzkQuCw+x1ZL+4WTdRCo1WmQTFKrp80FNwfYu7W2xBAz2VEvWsHFUY d879Kr66FTfT6Ks90+i3GeVz0Pbmd36xJFZYV1N8M18RLtR/Z9qx5CrgM IqXGRK48sQxXfIeB5uz/LuCdsCvXSaFklzxoV6XEv0yI8V1Nkdl4ZZ48Q L8PR8LEiEr0GH9V9SrcFdv01wPHcoUl/H5q6dcp8uIoVuKdz1LKAdtIxy l4cfEVWZk8jGgKk8FPiCU2QjqJh/tKIKtQBssGVuc1Tias508wu0B3iFy d45DVVsrRjNh0Oo9iJrh0t+NEhwzaKP0DIN86n9adpx9lbLDPrnNc95wa A==; X-CSE-ConnectionGUID: h7Ao89swTxKwJADf6kEpNA== X-CSE-MsgGUID: gGn5JC24QEiE7oKwFR4xVg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7982250" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="7982250" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 05:26:37 -0700 X-CSE-ConnectionGUID: wqOM62NhSMCFyCItO6kLAQ== X-CSE-MsgGUID: 1ONi6RqaSj+wFRjnzPRn2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="51760112" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa001.fm.intel.com with ESMTP; 10 Apr 2024 05:26:35 -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 244A528798; Wed, 10 Apr 2024 13:26:34 +0100 (IST) From: Mateusz Polchlopek To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, horms@kernel.org, anthony.l.nguyen@intel.com, Mateusz Polchlopek , Wojciech Drewek Subject: [Intel-wired-lan] [PATCH iwl-next v4 10/12] iavf: Implement checking DD desc field Date: Wed, 10 Apr 2024 08:17:04 -0400 Message-Id: <20240410121706.6223-11-mateusz.polchlopek@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20240410121706.6223-1-mateusz.polchlopek@intel.com> References: <20240410121706.6223-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 | 28 ++++++++++++++++++++- drivers/net/ethernet/intel/iavf/iavf_txrx.h | 17 ------------- drivers/net/ethernet/intel/iavf/iavf_type.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c index e2f46e29945f..b97da9c946ce 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -8,6 +8,28 @@ #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) +{ + u64 status_error_len = le64_to_cpu(rx_desc->wb.qword1.status_error_len); + + if (rx_ring->rxdid == VIRTCHNL_RXDID_1_32B_BASE) + return !!(FIELD_GET(IAVF_RX_DESC_STATUS_DD_MASK, + status_error_len)); + + return !!(FIELD_GET((IAVF_RX_FLEX_DESC_STATUS_ERR0_DD_BIT), + le16_to_cpu(rx_desc->flex_wb.status_error0))); +} + static __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, u32 td_tag) { @@ -1718,7 +1740,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 e80d1f7b3052..5527e6479ebd 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)