From patchwork Tue Jul 2 11:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Temerkhanov X-Patchwork-Id: 13719419 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 0799415B11D for ; Tue, 2 Jul 2024 11:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719919017; cv=none; b=Rw+eZTgIt+Rizph78U3FdXCSekPYC/oJfwOXQHOe4fsMrqbU/AN+eqBi16Qr4lPbeJztZaXIJmPVwpXqQGd6j5qX98B4V1oiwrMVUjaIi+ql9pMXF2c8R1fQ1UvLiSzGUQ/vN/Cw0KmAySgQK8pX2aZdl7K4rI8RRkzmY2hgIJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719919017; c=relaxed/simple; bh=0T11+bz0LjiGyoVeqekgMAkfL5OU8ZTFK7RUN6GjbXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NbVLfOLWK55mcJBunXk61/sf3+1XXWIpTtdoqjVzpTi8Ffr8OcEXmn9C4wHSvQznbEhuIIMZdL7Gtrqb92qkq86S2UThmrRQ+qOzwHRRPsJMPKsAPLmIbwk6Guf/h5zDI26z6Re7SxS5hvHE8FFXYpEnu/Bd0kk8HaxLiYrGzZI= 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=mYl/CxBJ; arc=none smtp.client-ip=198.175.65.12 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="mYl/CxBJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719919016; x=1751455016; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0T11+bz0LjiGyoVeqekgMAkfL5OU8ZTFK7RUN6GjbXk=; b=mYl/CxBJ27hDqDJHPxPfYq0RtdUApb2p4xiH3XtTV7XS4cVAcpT7YtSL 5ClHc7BoB0aecSovaQDvMc75GobBG3fYl1bZMvdEHh8W3ghr6LovniIIa ao3xz01GkyBirbIU8kvEQ5KkXXJKSTt9e/Xvg+/LkUQKJ/gp7OF1nWzM3 8E/JoJFldywepUbF95RmgsVfoHnzmO2SIvUVNaSYBeSve/xj2Lv7jDlLq 4GvQEXcq0bBawd4QGcnGwP152u+0HOoIQJYxET0fdazW86p4S4QTfdJL3 sHtjtYX/h+OAYcfjPbcKXBrLv0th9nnXjHpnfD2boo83VYaW3XH3ODKEA Q==; X-CSE-ConnectionGUID: XTJRQz+zQxiIYpCtBkKzUg== X-CSE-MsgGUID: 7uwBTv0gRC6Tnj3xMy95Jw== X-IronPort-AV: E=McAfee;i="6700,10204,11120"; a="28481848" X-IronPort-AV: E=Sophos;i="6.09,178,1716274800"; d="scan'208";a="28481848" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2024 04:16:56 -0700 X-CSE-ConnectionGUID: +Pk4ra+ASwyER5tc9v0uhA== X-CSE-MsgGUID: mSQu9ctAQz6BBTge93oOqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,178,1716274800"; d="scan'208";a="46005728" Received: from unknown (HELO localhost.igk.intel.com) ([10.211.13.141]) by orviesa009.jf.intel.com with ESMTP; 02 Jul 2024 04:16:54 -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 v3 2/4] ice: Add ice_get_ctrl_ptp() wrapper to simplify the code Date: Tue, 2 Jul 2024 13:15:31 +0200 Message-ID: <20240702111533.83485-3-sergey.temerkhanov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240702111533.83485-1-sergey.temerkhanov@intel.com> References: <20240702111533.83485-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 --- 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 2f32dcd42581..53a3b6fc9dec 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -16,6 +16,18 @@ static const struct ptp_pin_desc ice_pin_desc_e810t[] = { { "U.FL2", UFL2, PTP_PF_NONE, 2, { 0, } }, }; +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_get_sma_config_e810t * @hw: pointer to the hw struct