From patchwork Thu Sep 12 09:41:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 13801827 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 C6C1119F11E for ; Thu, 12 Sep 2024 09:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726134453; cv=none; b=A0xSU3s1QnUKdZyydpeWUGJNekO1S8iVdNqyq893UigxdibWBD6PStQiujsWVAGk55AaDzvmAb1gi98/tr4+S1g7Qhh1zNZAepJ2uh3cstCvmwn8JKRJDikhX3B0iit5bGcNFGAWoxNPlyPGqofAL+Sqii4y2DcArIk65tgAuEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726134453; c=relaxed/simple; bh=F3a1J2Wnut0KCExr728UdIQgzs7ZdC2IsmfQUmp9RbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kMsWrVw2dxf2HWhoN9RK61RfMepaEWP45jwpdNfCu4NjXzjTLSpEowkwn7zFSIVdh82OSuclp7LZx/Ia9XCmGMQzfagpQ1yX63RjYYFf/u6+u2E29tr/pc/1e6RGnLsZ93tLot8/WukXOOgkJqdXFIk1lCAsJdPmF7Pbw0FVuYI= 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=k/K3mXLM; arc=none smtp.client-ip=198.175.65.13 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="k/K3mXLM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726134452; x=1757670452; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F3a1J2Wnut0KCExr728UdIQgzs7ZdC2IsmfQUmp9RbY=; b=k/K3mXLM//hxQwc88U3FaxP1G5LQtMFeIE3xxitYvnZKwvpfmDR9R/6R FqKOza0i+KfzncChfyM/xUEod5fblC7eI0VMVvCoEp3Oah18S0PWEXhCR Kvee3VJ7uBziqlkohMjYZMTaVaE/bOU7tixjiS7q2dSROQGiA0MXaI3dz XNJ7F2sj/Yk5NGNWDpRg3E4+4ky5UL7Yu4BH9/ZGQU42uwq/924HhUrzw JqaW7tUqYc4whihVcE7O/iAjZa10jenjyuU4YZVMjkIqLHWUCwkUSqn/q 68TwVANWMEAMlrT6XzIzHPWsLXFcIGOlKZemEqxSojpNHFOkj94Lh51Wj g==; X-CSE-ConnectionGUID: XiTX/VLJT4+FTKNV7L5gtg== X-CSE-MsgGUID: LLHDYF1qTE6fVR+4eGX+jA== X-IronPort-AV: E=McAfee;i="6700,10204,11192"; a="36115370" X-IronPort-AV: E=Sophos;i="6.10,222,1719903600"; d="scan'208";a="36115370" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 02:47:31 -0700 X-CSE-ConnectionGUID: dR/ZY+ipTOy5IC2EakKPwA== X-CSE-MsgGUID: zaQjENsSThaMmJfpVirqBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,222,1719903600"; d="scan'208";a="72650681" Received: from kkolacin-desk1.igk.intel.com ([10.217.160.108]) by orviesa004.jf.intel.com with ESMTP; 12 Sep 2024 02:47:29 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, Karol Kolacinski , Simon Horman Subject: [PATCH v10 iwl-next 3/7] ice: Use FIELD_PREP for timestamp values Date: Thu, 12 Sep 2024 11:41:48 +0200 Message-ID: <20240912094720.832348-12-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912094720.832348-9-karol.kolacinski@intel.com> References: <20240912094720.832348-9-karol.kolacinski@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 Instead of using shifts and casts, use FIELD_PREP after reading 40b timestamp values. Reviewed-by: Simon Horman Signed-off-by: Karol Kolacinski --- V5 -> V6: Replaced removed macros with the new ones drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 9 ++++++--- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 13 +++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c index 0fc4092fd261..65a66225797e 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c @@ -1520,7 +1520,8 @@ static int ice_read_ptp_tstamp_eth56g(struct ice_hw *hw, u8 port, u8 idx, * lower 8 bits in the low register, and the upper 32 bits in the high * register. */ - *tstamp = ((u64)hi) << TS_PHY_HIGH_S | ((u64)lo & TS_PHY_LOW_M); + *tstamp = FIELD_PREP(PHY_40B_HIGH_M, hi) | + FIELD_PREP(PHY_40B_LOW_M, lo); return 0; } @@ -3199,7 +3200,8 @@ ice_read_phy_tstamp_e82x(struct ice_hw *hw, u8 quad, u8 idx, u64 *tstamp) * lower 8 bits in the low register, and the upper 32 bits in the high * register. */ - *tstamp = FIELD_PREP(TS_PHY_HIGH_M, hi) | FIELD_PREP(TS_PHY_LOW_M, lo); + *tstamp = FIELD_PREP(PHY_40B_HIGH_M, hi) | + FIELD_PREP(PHY_40B_LOW_M, lo); return 0; } @@ -4952,7 +4954,8 @@ ice_read_phy_tstamp_e810(struct ice_hw *hw, u8 lport, u8 idx, u64 *tstamp) /* For E810 devices, the timestamp is reported with the lower 32 bits * in the low register, and the upper 8 bits in the high register. */ - *tstamp = ((u64)hi) << TS_HIGH_S | ((u64)lo & TS_LOW_M); + *tstamp = FIELD_PREP(PHY_EXT_40B_HIGH_M, hi) | + FIELD_PREP(PHY_EXT_40B_LOW_M, lo); return 0; } diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h index 62bd8dafe19c..6328c0bbddd6 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h @@ -674,15 +674,12 @@ static inline bool ice_is_dual(struct ice_hw *hw) /* Source timer incval macros */ #define INCVAL_HIGH_M 0xFF -/* Timestamp block macros */ +/* PHY 40b registers macros */ +#define PHY_EXT_40B_LOW_M GENMASK(31, 0) +#define PHY_EXT_40B_HIGH_M GENMASK_ULL(39, 32) +#define PHY_40B_LOW_M GENMASK(7, 0) +#define PHY_40B_HIGH_M GENMASK_ULL(39, 8) #define TS_VALID BIT(0) -#define TS_LOW_M 0xFFFFFFFF -#define TS_HIGH_M 0xFF -#define TS_HIGH_S 32 - -#define TS_PHY_LOW_M 0xFF -#define TS_PHY_HIGH_M 0xFFFFFFFF -#define TS_PHY_HIGH_S 8 #define BYTES_PER_IDX_ADDR_L_U 8 #define BYTES_PER_IDX_ADDR_L 4