Replace auxbus with ice_adapter in the PTP support code
Subsystems (3)
v4 cover Replace auxbus with ice_adapter in the PTP support code
This series replaces multiple aux buses and devices used in the PTP support code with struct ice_adapter holding the necessary shared data
Patches 1,2 add convenience wrappers
Patch 3 does the main refactoring
Patch 4 finalizes the refactoring
Previous discussion: https://lists.osuosl.org/pipermail/intel-wired-lan/Week-of-Mon-20240715/042744.html
v1->v2: Code rearrangement between patchesv2->v3: Patch cleanupv3->v4: E825C support in ice_adapterv4->v5: Rebased on top of the latest changes
Sergey Temerkhanov (5):
ice: Introduce ice_get_phy_model() wrapper
ice: Add ice_get_ctrl_ptp() wrapper to simplify the code
ice: Initial support for E825C hardware in ice_adapter
ice: Use ice_adapter for PTP shared data instead of auxdev
ice: Drop auxbus use for PTP to finalize ice_adapter move
drivers/net/ethernet/intel/ice/ice.h | 5 + drivers/net/ethernet/intel/ice/ice_adapter.c | 22 +- drivers/net/ethernet/intel/ice/ice_adapter.h | 22 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 340 ++++--------------- drivers/net/ethernet/intel/ice/ice_ptp.h | 24 +- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 22 +- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 5 + 7 files changed, 129 insertions(+), 311 deletions(-)
Signature · 1 line
2.43.0
PATCH v5 1/5 ice: Introduce ice_get_phy_model() wrapper
Introduce ice_get_phy_model() to improve code readability
--- drivers/net/ethernet/intel/ice/ice.h | 5 +++++ drivers/net/ethernet/intel/ice/ice_ptp.c | 19 +++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 22 ++++++++++----------- 3 files changed, 25 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +5 -0
@@ -1045,5 +1045,10 @@ static inline void ice_clear_rdma_cap(struct ice_pf *pf) clear_bit(ICE_FLAG_RDMA_ENA, pf->flags); } +static inline enum ice_phy_model ice_get_phy_model (const struct ice_hw *hw) +{ +return hw->ptp.phy_model; +} +extern const struct xdp_metadata_ops ice_xdp_md_ops;#endif /* _ICE_H_ */
drivers/net/ethernet/intel/ice/ice_ptp.c +9 -10
@@ -1285,7 +1285,7 @@ ice_ptp_port_phy_stop(struct ice_ptp_port *ptp_port)mutex_lock (&ptp_port->ps_lock); -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G : err =ice_stop_phy_timer_eth56g (hw, port, true);break ;
@@ -1331,7 +1331,7 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port)mutex_lock (&ptp_port->ps_lock); -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G : err =ice_start_phy_timer_eth56g (hw, port);break ;
@@ -1402,8 +1402,7 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)/* Skip HW writes if reset is in progress */ if (pf->hw.reset_ongoing)return ; - -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_E810 :/* Do not reconfigure E810 PHY */ return ;
@@ -1436,7 +1435,7 @@ static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold)ice_ptp_reset_ts_memory (hw); -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G : {int port;
@@ -1475,7 +1474,7 @@ static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold)case ICE_PHY_UNSUP :default :dev_warn (dev,"%s: Unexpected PHY model %d\n" , __func__, - hw->ptp.phy_model); +ice_get_phy_model (hw));return -EOPNOTSUPP ; } }
@@ -2046,7 +2045,7 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)/* For Vernier mode on E82X, we need to recalibrate after new settime. * Start with marking timestamps as invalid. */ -if (hw->ptp.phy_model ==ICE_PHY_E82X ) { +if (ice_get_phy_model (hw) ==ICE_PHY_E82X ) { err =ice_ptp_clear_phy_offset_ready_e82x (hw);if (err)dev_warn (ice_pf_to_dev (pf),"Failed to mark timestamps as invalid before settime\n" );
@@ -2070,7 +2069,7 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)ice_ptp_enable_all_perout (pf);/* Recalibrate and re-enable timestamp blocks for E822/E823 */ -if (hw->ptp.phy_model ==ICE_PHY_E82X ) +if (ice_get_phy_model (hw) ==ICE_PHY_E82X )ice_ptp_restart_all_phy (pf); exit:if (err) {
@@ -3265,7 +3264,7 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port)mutex_init (&ptp_port->ps_lock); -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G :return ice_ptp_init_tx_eth56g (pf, &ptp_port->tx, ptp_port->port_num);
@@ -3363,7 +3362,7 @@ static void ice_ptp_remove_auxbus_device(struct ice_pf *pf)*/ static void ice_ptp_init_tx_interrupt_mode (struct ice_pf *pf) { -switch (pf->hw.ptp.phy_model) { +switch (ice_get_phy_model (&pf->hw)) {case ICE_PHY_E82X :/* E822 based PHY has the clock owner process the interrupt * for all ports.
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +11 -11
@@ -829,7 +829,7 @@ static u32 ice_ptp_tmr_cmd_to_port_reg(struct ice_hw *hw,/* Certain hardware families share the same register values for the * port register and source timer register. */ -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_E810 :return ice_ptp_tmr_cmd_to_src_reg (hw, cmd) &TS_CMD_MASK_E810 ;default :
@@ -5502,7 +5502,7 @@ void ice_ptp_init_hw(struct ice_hw *hw)static int ice_ptp_write_port_cmd (struct ice_hw *hw,u8 port,enum ice_ptp_tmr_cmd cmd) { -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G :return ice_ptp_write_port_cmd_eth56g (hw, port, cmd);case ICE_PHY_E82X :
@@ -5567,7 +5567,7 @@ static int ice_ptp_port_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)u32 port;/* PHY models which can program all ports simultaneously */ -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_E810 :return ice_ptp_port_cmd_e810 (hw, cmd);default :
@@ -5646,7 +5646,7 @@ int ice_ptp_init_time(struct ice_hw *hw, u64 time)/* PHY timers */ /* Fill Rx and Tx ports and send msg to PHY */ -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G : err =ice_ptp_prep_phy_time_eth56g (hw, (u32)(time &0xFFFFFFFF ));
@@ -5692,7 +5692,7 @@ int ice_ptp_write_incval(struct ice_hw *hw, u64 incval)wr32 (hw,GLTSYN_SHADJ_L (tmr_idx),lower_32_bits (incval));wr32 (hw,GLTSYN_SHADJ_H (tmr_idx),upper_32_bits (incval)); -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G : err =ice_ptp_prep_phy_incval_eth56g (hw, incval);break ;
@@ -5761,7 +5761,7 @@ int ice_ptp_adj_clock(struct ice_hw *hw, s32 adj)wr32 (hw,GLTSYN_SHADJ_L (tmr_idx),0 );wr32 (hw,GLTSYN_SHADJ_H (tmr_idx), adj); -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G : err =ice_ptp_prep_phy_adj_eth56g (hw, adj);break ;
@@ -5794,7 +5794,7 @@ int ice_ptp_adj_clock(struct ice_hw *hw, s32 adj)*/ int ice_read_phy_tstamp (struct ice_hw *hw,u8 block,u8 idx,u64 *tstamp) { -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G :return ice_read_ptp_tstamp_eth56g (hw, block, idx, tstamp);case ICE_PHY_E810 :
@@ -5824,7 +5824,7 @@ int ice_read_phy_tstamp(struct ice_hw *hw, u8 block, u8 idx, u64 *tstamp)*/ int ice_clear_phy_tstamp (struct ice_hw *hw,u8 block,u8 idx) { -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G :return ice_clear_ptp_tstamp_eth56g (hw, block, idx);case ICE_PHY_E810 :
@@ -5887,7 +5887,7 @@ static int ice_get_pf_c827_idx(struct ice_hw *hw, u8 *idx)*/ void ice_ptp_reset_ts_memory (struct ice_hw *hw) { -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G :ice_ptp_reset_ts_memory_eth56g (hw);break ;
@@ -5916,7 +5916,7 @@ int ice_ptp_init_phc(struct ice_hw *hw)/* Clear event err indications for auxiliary pins */ (void )rd32 (hw,GLTSYN_STAT (src_idx)); -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G :return ice_ptp_init_phc_eth56g (hw);case ICE_PHY_E810 :
@@ -5941,7 +5941,7 @@ int ice_ptp_init_phc(struct ice_hw *hw)*/ int ice_get_phy_tx_tstamp_ready (struct ice_hw *hw,u8 block,u64 *tstamp_ready) { -switch (hw->ptp.phy_model) { +switch (ice_get_phy_model (hw)) {case ICE_PHY_ETH56G :return ice_get_phy_tx_tstamp_ready_eth56g (hw, block, tstamp_ready);
Signature · 1 line
2.43.0
PATCH v5 2/5 ice: Add ice_get_ctrl_ptp() wrapper to simplify the code
In reply to Sergey TemerkhanovAdd 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
--- 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(-)
drivers/net/ethernet/intel/ice/ice_adapter.h +4 -1
@@ -8,18 +8,21 @@#include <linux/refcount_types.h> 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);
drivers/net/ethernet/intel/ice/ice_ptp.c +12 -0
@@ -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
Signature · 1 line
2.43.0
PATCH v5 3/5 ice: Initial support for E825C hardware in ice_adapter
In reply to Sergey TemerkhanovAddress E825C devices by PCI ID since dual IP core configurations need 1 ice_adapter for both devices.
--- drivers/net/ethernet/intel/ice/ice_adapter.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_adapter.c +13 -3
@@ -9,12 +9,14 @@#include <linux/spinlock.h> #include <linux/xarray.h> #include "ice_adapter.h" +#include "ice.h" static DEFINE_XARRAY (ice_adapters);static DEFINE_MUTEX (ice_adapters_mutex);/* PCI bus number is 8 bits. Slot is 5 bits. Domain can have the rest. */ #define INDEX_FIELD_DOMAIN GENMASK(BITS_PER_LONG - 1, 13) +#define INDEX_FIELD_DEV GENMASK(31, 16)#define INDEX_FIELD_BUS GENMASK(12, 5)#define INDEX_FIELD_SLOT GENMASK(4, 0)
@@ -24,9 +26,17 @@ static unsigned long ice_adapter_index(const struct pci_dev *pdev)WARN_ON (domain >FIELD_MAX (INDEX_FIELD_DOMAIN )); -return FIELD_PREP (INDEX_FIELD_DOMAIN , domain) | -FIELD_PREP (INDEX_FIELD_BUS , pdev->bus->number) | -FIELD_PREP (INDEX_FIELD_SLOT ,PCI_SLOT (pdev->devfn)); +switch (pdev->device) { +case ICE_DEV_ID_E825C_BACKPLANE : +case ICE_DEV_ID_E825C_QSFP : +case ICE_DEV_ID_E825C_SFP : +case ICE_DEV_ID_E825C_SGMII : +return FIELD_PREP (INDEX_FIELD_DEV , pdev->device); +default : +return FIELD_PREP (INDEX_FIELD_DOMAIN , domain) | +FIELD_PREP (INDEX_FIELD_BUS , pdev->bus->number) | +FIELD_PREP (INDEX_FIELD_SLOT ,PCI_SLOT (pdev->devfn)); + } }static struct ice_adapter *ice_adapter_new (void )
Signature · 1 line
2.43.0
PATCH v5 4/5 ice: Use ice_adapter for PTP shared data instead of auxdev
In reply to Sergey TemerkhanovUse struct ice_adapter to hold shared PTP data and control PTP related actions instead of auxbus. This allows significant code simplification and faster access to the container fields used in the PTP support code.
Move the PTP port list to the ice_adapter container to simplify the code and avoid race conditions which could occur due to the synchronous nature of the initialization/access and certain memory saving can be achieved by moving PTP data into the ice_adapter itself.
--- drivers/net/ethernet/intel/ice/ice_adapter.c | 6 + drivers/net/ethernet/intel/ice/ice_adapter.h | 17 +++ drivers/net/ethernet/intel/ice/ice_ptp.c | 115 ++++++++++++------- drivers/net/ethernet/intel/ice/ice_ptp.h | 5 +- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 5 + 5 files changed, 105 insertions(+), 43 deletions(-)
drivers/net/ethernet/intel/ice/ice_adapter.c +6 -0
@@ -50,11 +50,17 @@ static struct ice_adapter *ice_adapter_new(void)spin_lock_init (&adapter->ptp_gltsyn_time_lock);refcount_set (&adapter->refcount,1 ); +mutex_init (&adapter->ports.lock); +INIT_LIST_HEAD (&adapter->ports.ports); +return adapter; }static void ice_adapter_free (struct ice_adapter *adapter) { +WARN_ON (!list_empty (&adapter->ports.ports)); +mutex_destroy (&adapter->ports.lock); +kfree (adapter); }
drivers/net/ethernet/intel/ice/ice_adapter.h +17 -0
@@ -4,18 +4,34 @@ #ifndef _ICE_ADAPTER_H_ #define _ICE_ADAPTER_H_ +#include <linux/types.h> #include <linux/spinlock_types.h> #include <linux/refcount_types.h> struct pci_dev; struct ice_pf; +/** + * struct ice_port_list - data used to store the list of adapter ports + * + * This structure contains data used to maintain a list of adapter ports + * + * @ports: list of ports + * @lock: protect access to the ports list + */ +struct ice_port_list { + struct list_head ports; + /* To synchronize the ports list operations */ + struct mutex lock; +}; + /** * 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 + * @ports: Ports list */ struct ice_adapter { refcount_t refcount;
@@ -23,6 +39,7 @@ struct ice_adapter {spinlock_t ptp_gltsyn_time_lock;struct ice_pf *ctrl_pf; +struct ice_port_list ports; };struct ice_adapter *ice_adapter_get (const struct pci_dev *pdev);
drivers/net/ethernet/intel/ice/ice_ptp.c +74 -41
248 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp.h +3 -2
@@ -138,7 +138,7 @@ struct ice_ptp_tx {* ready for PTP functionality. It is used to track the port initialization * and determine when the port's PHY offset is valid. * -* @list_member: list member structure of auxiliary device +* @list_node: list member structure * @tx: Tx timestamp tracking for this port * @aux_dev: auxiliary device associated with this port * @ov_work: delayed work task for tracking when PHY offset is valid
@@ -148,7 +148,7 @@ struct ice_ptp_tx {* @port_num: the port number this structure represents */ struct ice_ptp_port { -struct list_head list_member; +struct list_head list_node;struct ice_ptp_tx tx;struct auxiliary_device aux_dev;struct kthread_delayed_work ov_work;
@@ -174,6 +174,7 @@ enum ice_ptp_tx_interrupt {* @ports: list of porst handled by this port owner * @lock: protect access to ports list */ +struct ice_ptp_port_owner {struct auxiliary_driver aux_driver;struct list_head ports;
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +5 -0
@@ -468,6 +468,11 @@ static inline u64 ice_get_base_incval(struct ice_hw *hw) } } +static inline bool ice_is_dual (struct ice_hw *hw) +{ +return !!(hw->dev_caps.nac_topo.mode &ICE_NAC_TOPO_DUAL_M ); +} +#define PFTSYN_SEM_BYTES 4#define ICE_PTP_CLOCK_INDEX_0 0x00
Signature · 1 line
2.43.0
Tony Nguyen
maintainerRe: [PATCH iwl-next v5 4/5] ice: Use ice_adapter for PTP shared data instead of auxdev
On 8/14/2024 12:54 PM, Sergey Temerkhanov wrote:
...
Quoted 1 line
+static inline bool
ice_is_primary(struct ice_hw *hw)
No 'inline' functions in c files please.
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +5
-0+{ +return ice_is_e825c (hw) &&ice_is_dual (hw) ? + !!(hw->dev_caps.nac_topo.mode &ICE_NAC_TOPO_PRIMARY_M ) : true; +} +
...
drivers/net/ethernet/intel/ice/ice_ptp_hw.h static inline u64 ice_get_base_incval(struct ice_hw *hw) · line 474
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +4
-0@@ -468,6 +468,11 @@ static inline u64 ice_get_base_incval(struct ice_hw *hw) } } +static inline bool ice_is_dual (struct ice_hw *hw) +{ +return !!(hw->dev_caps.nac_topo.mode &ICE_NAC_TOPO_DUAL_M ); +}
From checkpatch:
ERROR: code indent should use tabs where possible #408: FILE: drivers/net/ethernet/intel/ice/ice_ptp_hw.h:473:
+ return !!(hw->dev_caps.nac_topo.mode & ICE_NAC_TOPO_DUAL_M);$
WARNING: please, no spaces at the start of a line #408: FILE: drivers/net/ethernet/intel/ice/ice_ptp_hw.h:473:
+ return !!(hw->dev_caps.nac_topo.mode & ICE_NAC_TOPO_DUAL_M);$
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0
-0#define PFTSYN_SEM_BYTES 4#define ICE_PTP_CLOCK_INDEX_0 0x00
PATCH v5 5/5 ice: Drop auxbus use for PTP to finalize ice_adapter move
In reply to Sergey TemerkhanovDrop unused auxbus/auxdev support from the PTP code due to move to the ice_adapter.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 252 ----------------------- drivers/net/ethernet/intel/ice/ice_ptp.h | 21 -- 2 files changed, 273 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +0 -252
@@ -3006,188 +3006,6 @@ static void ice_ptp_cleanup_pf(struct ice_pf *pf)mutex_unlock (&pf->adapter->ports.lock); } } -/** -* ice_ptp_aux_dev_to_aux_pf - Get auxiliary PF handle for the auxiliary device -* @aux_dev: auxiliary device to get the auxiliary PF for -*/ -static struct ice_pf * -ice_ptp_aux_dev_to_aux_pf (struct auxiliary_device *aux_dev) -{ -struct ice_ptp_port *aux_port; -struct ice_ptp *aux_ptp; - - aux_port = container_of(aux_dev, struct ice_ptp_port, aux_dev); - aux_ptp = container_of(aux_port, struct ice_ptp, port); - - return container_of(aux_ptp, struct ice_pf, ptp); -} - -/** -* ice_ptp_aux_dev_to_owner_pf - Get PF handle for the auxiliary device -* @aux_dev: auxiliary device to get the PF for -*/ -static struct ice_pf * -ice_ptp_aux_dev_to_owner_pf (struct auxiliary_device *aux_dev) -{ -struct ice_ptp_port_owner *ports_owner; -const struct auxiliary_driver *aux_drv; -struct ice_ptp *owner_ptp; - -if (!aux_dev->dev.driver) -return NULL ; - - aux_drv =to_auxiliary_drv (aux_dev->dev.driver); - ports_owner = container_of(aux_drv, struct ice_ptp_port_owner, - aux_driver); - owner_ptp = container_of(ports_owner, struct ice_ptp, ports_owner); - return container_of(owner_ptp, struct ice_pf, ptp); -} - -/** -* ice_ptp_auxbus_probe - Probe auxiliary devices -* @aux_dev: PF's auxiliary device -* @id: Auxiliary device ID -*/ -static int ice_ptp_auxbus_probe (struct auxiliary_device *aux_dev, -const struct auxiliary_device_id *id) -{ -struct ice_pf *owner_pf =ice_ptp_aux_dev_to_owner_pf (aux_dev); -struct ice_pf *aux_pf =ice_ptp_aux_dev_to_aux_pf (aux_dev); - -if (WARN_ON (!owner_pf)) -return -ENODEV ; - -INIT_LIST_HEAD (&aux_pf->ptp.port.list_node); -mutex_lock (&owner_pf->ptp.ports_owner.lock); -list_add (&aux_pf->ptp.port.list_node, - &owner_pf->ptp.ports_owner.ports); -mutex_unlock (&owner_pf->ptp.ports_owner.lock); - -return 0 ; -} - -/** -* ice_ptp_auxbus_remove - Remove auxiliary devices from the bus -* @aux_dev: PF's auxiliary device -*/ -static void ice_ptp_auxbus_remove (struct auxiliary_device *aux_dev) -{ -struct ice_pf *owner_pf =ice_ptp_aux_dev_to_owner_pf (aux_dev); -struct ice_pf *aux_pf =ice_ptp_aux_dev_to_aux_pf (aux_dev); - -mutex_lock (&owner_pf->ptp.ports_owner.lock); -list_del (&aux_pf->ptp.port.list_node); -mutex_unlock (&owner_pf->ptp.ports_owner.lock); -} - -/** -* ice_ptp_auxbus_shutdown -* @aux_dev: PF's auxiliary device -*/ -static void ice_ptp_auxbus_shutdown (struct auxiliary_device *aux_dev) -{ -/* Doing nothing here, but handle to auxbus driver must be satisfied */ -} - -/** -* ice_ptp_auxbus_suspend -* @aux_dev: PF's auxiliary device -* @state: power management state indicator -*/ -static int -ice_ptp_auxbus_suspend (struct auxiliary_device *aux_dev,pm_message_t state) -{ -/* Doing nothing here, but handle to auxbus driver must be satisfied */ -return 0 ; -} - -/** -* ice_ptp_auxbus_resume -* @aux_dev: PF's auxiliary device -*/ -static int ice_ptp_auxbus_resume (struct auxiliary_device *aux_dev) -{ -/* Doing nothing here, but handle to auxbus driver must be satisfied */ -return 0 ; -} - -/** -* ice_ptp_auxbus_create_id_table - Create auxiliary device ID table -* @pf: Board private structure -* @name: auxiliary bus driver name -*/ -static struct auxiliary_device_id * -ice_ptp_auxbus_create_id_table (struct ice_pf *pf,const char *name) -{ -struct auxiliary_device_id *ids; - -/* Second id left empty to terminate the array */ - ids =devm_kcalloc (ice_pf_to_dev (pf),2 , -sizeof (struct auxiliary_device_id ),GFP_KERNEL ); -if (!ids) -return NULL ; - -snprintf (ids[0 ].name,sizeof (ids[0 ].name),"ice.%s" , name); - -return ids; -} - -/** -* ice_ptp_register_auxbus_driver - Register PTP auxiliary bus driver -* @pf: Board private structure -*/ -static int __always_unused ice_ptp_register_auxbus_driver (struct ice_pf *pf) -{ -struct auxiliary_driver *aux_driver; -struct ice_ptp *ptp; -struct device *dev; -char *name; -int err; - - ptp = &pf->ptp; - dev =ice_pf_to_dev (pf); - aux_driver = &ptp->ports_owner.aux_driver; -INIT_LIST_HEAD (&ptp->ports_owner.ports); -mutex_init (&ptp->ports_owner.lock); - name =devm_kasprintf (dev,GFP_KERNEL ,"ptp_aux_dev_%u_%u_clk%u" , - pf->pdev->bus->number,PCI_SLOT (pf->pdev->devfn), -ice_get_ptp_src_clock_index (&pf->hw)); -if (!name) -return -ENOMEM ; - - aux_driver->name = name; - aux_driver->shutdown = ice_ptp_auxbus_shutdown; - aux_driver->suspend = ice_ptp_auxbus_suspend; - aux_driver->remove = ice_ptp_auxbus_remove; - aux_driver->resume = ice_ptp_auxbus_resume; - aux_driver->probe = ice_ptp_auxbus_probe; - aux_driver->id_table =ice_ptp_auxbus_create_id_table (pf, name); -if (!aux_driver->id_table) -return -ENOMEM ; - - err =auxiliary_driver_register (aux_driver); -if (err) { -devm_kfree (dev, aux_driver->id_table); -dev_err (dev,"Failed registering aux_driver, name <%s>\n" , - name); - } - -return err; -} - -/** -* ice_ptp_unregister_auxbus_driver - Unregister PTP auxiliary bus driver -* @pf: Board private structure -*/ -static void __always_unused ice_ptp_unregister_auxbus_driver (struct ice_pf *pf) -{ -struct auxiliary_driver *aux_driver = &pf->ptp.ports_owner.aux_driver; - -auxiliary_driver_unregister (aux_driver); -devm_kfree (ice_pf_to_dev (pf), aux_driver->id_table); - -mutex_destroy (&pf->ptp.ports_owner.lock); -}/** * ice_ptp_clock_index - Get the PTP clock index for this device
@@ -3326,76 +3144,6 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) } } -/** -* ice_ptp_release_auxbus_device -* @dev: device that utilizes the auxbus -*/ -static void ice_ptp_release_auxbus_device (struct device *dev) -{ -/* Doing nothing here, but handle to auxbux device must be satisfied */ -} - -/** -* ice_ptp_create_auxbus_device - Create PTP auxiliary bus device -* @pf: Board private structure -*/ -static __always_unused int ice_ptp_create_auxbus_device (struct ice_pf *pf) -{ -struct auxiliary_device *aux_dev; -struct ice_ptp *ptp; -struct device *dev; -char *name; -int err; -u32 id; - - ptp = &pf->ptp; - id = ptp->port.port_num; - dev =ice_pf_to_dev (pf); - - aux_dev = &ptp->port.aux_dev; - - name =devm_kasprintf (dev,GFP_KERNEL ,"ptp_aux_dev_%u_%u_clk%u" , - pf->pdev->bus->number,PCI_SLOT (pf->pdev->devfn), -ice_get_ptp_src_clock_index (&pf->hw)); -if (!name) -return -ENOMEM ; - - aux_dev->name = name; - aux_dev->id = id; - aux_dev->dev.release = ice_ptp_release_auxbus_device; - aux_dev->dev.parent = dev; - - err =auxiliary_device_init (aux_dev); -if (err) - goto aux_err; - - err =auxiliary_device_add (aux_dev); -if (err) { -auxiliary_device_uninit (aux_dev); - goto aux_err; - } - -return 0 ; -aux_err: -dev_err (dev,"Failed to create PTP auxiliary bus device <%s>\n" , name); -devm_kfree (dev, name); -return err; -} - -/** -* ice_ptp_remove_auxbus_device - Remove PTP auxiliary bus device -* @pf: Board private structure -*/ -static __always_unused void ice_ptp_remove_auxbus_device (struct ice_pf *pf) -{ -struct auxiliary_device *aux_dev = &pf->ptp.port.aux_dev; - -auxiliary_device_delete (aux_dev); -auxiliary_device_uninit (aux_dev); - -memset (aux_dev,0 ,sizeof (*aux_dev)); -} -/** * ice_ptp_init_tx_interrupt_mode - Initialize device Tx interrupt mode * @pf: Board private structure
drivers/net/ethernet/intel/ice/ice_ptp.h +0 -21
@@ -140,7 +140,6 @@ struct ice_ptp_tx {* * @list_node: list member structure * @tx: Tx timestamp tracking for this port -* @aux_dev: auxiliary device associated with this port * @ov_work: delayed work task for tracking when PHY offset is valid * @ps_lock: mutex used to protect the overall PTP PHY start procedure * @link_up: indicates whether the link is up
@@ -150,7 +149,6 @@ struct ice_ptp_tx {struct ice_ptp_port {struct list_head list_node;struct ice_ptp_tx tx; -struct auxiliary_device aux_dev;struct kthread_delayed_work ov_work;struct mutex ps_lock;/* protects overall PTP PHY start procedure */ bool link_up;
@@ -164,23 +162,6 @@ enum ice_ptp_tx_interrupt { ICE_PTP_TX_INTERRUPT_ALL, }; -/** -* struct ice_ptp_port_owner - data used to handle the PTP clock owner info -* -* This structure contains data necessary for the PTP clock owner to correctly -* handle the timestamping feature for all attached ports. -* -* @aux_driver: the structure carring the auxiliary driver information -* @ports: list of porst handled by this port owner -* @lock: protect access to ports list -*/ - -struct ice_ptp_port_owner { -struct auxiliary_driver aux_driver; -struct list_head ports; -struct mutex lock; -}; -#define GLTSYN_TGT_H_IDX_MAX 4enum ice_ptp_state {
@@ -245,7 +226,6 @@ struct ice_ptp_pin_desc {* @state: current state of PTP state machine * @tx_interrupt_mode: the TX interrupt mode for the PTP clock * @port: data for the PHY port initialization procedure -* @ports_owner: data for the auxiliary driver owner * @work: delayed work function for periodic tasks * @cached_phc_time: a cached copy of the PHC time for timestamp extension * @cached_phc_jiffies: jiffies when cached_phc_time was last updated
@@ -270,7 +250,6 @@ struct ice_ptp {enum ice_ptp_state state;enum ice_ptp_tx_interrupt tx_interrupt_mode;struct ice_ptp_port port; -struct ice_ptp_port_owner ports_owner;struct kthread_delayed_work work;u64 cached_phc_time;unsigned long cached_phc_jiffies;
Signature · 1 line
2.43.0