From patchwork Wed Aug 21 13:09:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Temerkhanov X-Patchwork-Id: 13771602 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 B3FEA19994B for ; Wed, 21 Aug 2024 13:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724245916; cv=none; b=nalrZjCZ1g81Dp11kpoRtNVqxsm95ZTkWR9szBg4ycY/UidSSFgGRYvTfSncjD/UxM7JVsG4NB1GjhmE7CCb+hPPTg5E9gu7BjTyMemOvTnwG392KJ89zIkWRSgVlbgV0Ldo51fUUBKwjRwOV5NVh7CoB+Ny5J/Dcc4e7wKqCyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724245916; c=relaxed/simple; bh=ce4Gm9sK8DtjolFBXVB0Ofy9mfw0ari2vWHuCBCGd8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PUo97etnhPmyyLcgkHq49W2sdvLRtfbO+e0Fb23U1+6m/ws7sh0uzufr/mUIes78S6lkV2XH1qv18qf02SZK/Dqijjdig1ePZtdM460C8LqFyQnEy7QA0DgZVu9FkxgbUExhp+yYEct4ZU8Qm5glJ5d8051jnS18NrlqdwkPrNU= 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=BfC2cjj1; arc=none smtp.client-ip=198.175.65.15 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="BfC2cjj1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724245914; x=1755781914; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ce4Gm9sK8DtjolFBXVB0Ofy9mfw0ari2vWHuCBCGd8A=; b=BfC2cjj1cscCf5IKCfGJgDYVwjGpUrC5gu6Pry0wVKSUwACn5JsuCfUc Te9Wb6HTotfsDAWjKqLrY4ri3Ug30CcHQnhC7NvQhLVEDEu7BpsB/gUKb pp7w0j+uvUniHepRu1037kuBFKQv0DSG22dQOWX0F2mKyIw922j3Yym9V RP104XH/8xNWbJSq4hS4Yn77osT/dd73gMyOSU65mln8jtCRBwhndufFc ULTOoHtvRsxgsytj6NhMjsyrLYj5wqDsEp4eQ9tEIqhVfvWecR7REEZlu YWEy5IO8+vFdYjAULGznGsL4hIL7eu/b9pogO6CId5IjFcRgwqB5g9plJ A==; X-CSE-ConnectionGUID: fXx8rbdcTni4YPy3jqbVVg== X-CSE-MsgGUID: VPdGspyvTpugrmgzpN5u8w== X-IronPort-AV: E=McAfee;i="6700,10204,11171"; a="26356926" X-IronPort-AV: E=Sophos;i="6.10,164,1719903600"; d="scan'208";a="26356926" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2024 06:11:54 -0700 X-CSE-ConnectionGUID: HIWqhZZ5SQybPwFcOpHMcA== X-CSE-MsgGUID: wsSfEur3QxS+8pZnif7M9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,164,1719903600"; d="scan'208";a="65432395" Received: from unknown (HELO localhost.igk.intel.com) ([10.211.13.141]) by fmviesa005.fm.intel.com with ESMTP; 21 Aug 2024 06:11:53 -0700 From: Sergey Temerkhanov To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, Sergey Temerkhanov , Przemek Kitszel , Simon Horman Subject: [PATCH iwl-next v6 2/5] ice: Add ice_get_ctrl_ptp() wrapper to simplify the code Date: Wed, 21 Aug 2024 15:09:54 +0200 Message-ID: <20240821130957.55043-3-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240821130957.55043-1-sergey.temerkhanov@intel.com> References: <20240821130957.55043-1-sergey.temerkhanov@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-Patchwork-Delegate: kuba@kernel.org Add ice_get_ctrl_ptp() wrapper to simplify the PTP support code in the functions that do not use ctrl_pf directly. Add the control PF pointer to struct ice_adapter Rearrange fields in struct ice_adapter Signed-off-by: Sergey Temerkhanov Reviewed-by: Przemek Kitszel Reviewed-by: Simon Horman Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) --- drivers/net/ethernet/intel/ice/ice_adapter.h | 5 ++++- drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.h b/drivers/net/ethernet/intel/ice/ice_adapter.h index 9d11014ec02f..eb7cac01c242 100644 --- a/drivers/net/ethernet/intel/ice/ice_adapter.h +++ b/drivers/net/ethernet/intel/ice/ice_adapter.h @@ -8,18 +8,21 @@ #include struct pci_dev; +struct ice_pf; /** * struct ice_adapter - PCI adapter resources shared across PFs * @ptp_gltsyn_time_lock: Spinlock protecting access to the GLTSYN_TIME * register of the PTP clock. * @refcount: Reference count. struct ice_pf objects hold the references. + * @ctrl_pf: Control PF of the adapter */ struct ice_adapter { + refcount_t refcount; /* For access to the GLTSYN_TIME register */ spinlock_t ptp_gltsyn_time_lock; - refcount_t refcount; + struct ice_pf *ctrl_pf; }; struct ice_adapter *ice_adapter_get(const struct pci_dev *pdev); diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 31d1ab575ec2..f6c50063d374 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -57,6 +57,18 @@ static const struct ice_ptp_pin_desc ice_pin_desc_e810_sma[] = { { UFL2, { -1, 3 }}, }; +static struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf) +{ + return !pf->adapter ? NULL : pf->adapter->ctrl_pf; +} + +static __maybe_unused struct ice_ptp *ice_get_ctrl_ptp(struct ice_pf *pf) +{ + struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf); + + return !ctrl_pf ? NULL : &ctrl_pf->ptp; +} + /** * ice_ptp_find_pin_idx - Find pin index in ptp_pin_desc * @pf: Board private structure