ice: add PTP auxiliary bus support
Subsystems (2)
cover ice: add PTP auxiliary bus support
Auxiliary bus allow exchanging information between PFs, which allows both fixing problems and simplifying new features implementation. The auxiliary bus is enabled for all devices supported by ice driver.
Michal Michalik (3):
ice: Auxbus devices & driver for E822 TS
ice: Use PTP auxbus for all PHYs restart in E822
ice: PTP: add clock domain number to auxiliary interface
drivers/net/ethernet/intel/ice/ice.h | 14 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_hw_autogen.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 11 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 586 +++++++++++++++++------- drivers/net/ethernet/intel/ice/ice_ptp.h | 41 +- 6 files changed, 493 insertions(+), 162 deletions(-)
Signature · 6 lines
2.9.5 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 1/3 ice: Auxbus devices & driver for E822 TS
There is a problem in HW in E822-based devices leading to race condition.
It might happen that, in order:
- PF0 (which owns the PHC) requests few timestamps,
- PF1 requests a timestamp,
- interrupt is being triggered and both PF0 and PF1 threads are woken up,
- PF0 got one timestamp, still waiting for others so not going to sleep,
- PF1 gets it's timestamp, process it and go to sleep,
- PF1 requests a timestamp again,
- just before PF0 goes to sleep timestamp of PF1 appear,
- PF0 finishes all it's timestamps and go to sleep (PF1 also sleeping). That leaves PF1 timestamp memory not read, which lead to blocking the next interrupt from arriving.
Fix it by adding auxiliary devices and only one driver to handle all the timestamps for all PF's by PHC owner. In the past each PF requested it's own timestamps and process it from the start till the end which causes problem described above. Currently each PF requests the timestamps as before, but the actual reading of the completed timestamps is being done by the PTP auxilary driver, which is registered by the PF which owns PHC.
Additionally, the newly introduced auxiliary driver/devices for PTP clock owner will be used for other features in all products (including E810).
--- drivers/net/ethernet/intel/ice/ice.h | 14 + drivers/net/ethernet/intel/ice/ice_hw_autogen.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 11 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 403 +++++++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_ptp.h | 30 ++ 5 files changed, 440 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +14 -0
@@ -195,6 +195,8 @@#define ice_pf_to_dev (pf) (&((pf)->pdev->dev)) +#define ice_pf_src_tmr_owned (pf) ((pf)->hw.func_caps.ts_func_info.src_tmr_owned) +enum ice_feature {ICE_F_DSCP ,ICE_F_PTP_EXTTS ,
@@ -660,6 +662,18 @@ static inline bool ice_vector_ch_enabled(struct ice_q_vector *qv) }/** +* ice_ptp_pf_handles_tx_interrupt - Check if PF handles Tx interrupt +* @pf: Board private structure +* +* Return true if this PF should respond to the Tx timestamp interrupt +* indication in the miscellaneous OICR interrupt handler. +*/ +static inline bool ice_ptp_pf_handles_tx_interrupt (struct ice_pf *pf) +{ +return pf->ptp.tx_interrupt_mode !=ICE_PTP_TX_INTERRUPT_NONE ; +} + +/** * ice_irq_dynamic_ena - Enable default interrupt generation settings * @hw: pointer to HW struct * @vsi: pointer to VSI struct, can be NULL
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +1 -0
@@ -231,6 +231,7 @@#define PFINT_SB_CTL 0x0016B600#define PFINT_SB_CTL_MSIX_INDX_M ICE_M(0x7FF, 0)#define PFINT_SB_CTL_CAUSE_ENA_M BIT(30) +#define PFINT_TSYN_MSK 0x0016C980#define QINT_RQCTL (_QRX) (0x00150000 + ((_QRX) * 4))#define QINT_RQCTL_MSIX_INDX_S 0#define QINT_RQCTL_MSIX_INDX_M ICE_M(0x7FF, 0)
drivers/net/ethernet/intel/ice/ice_main.c +8 -3
@@ -3137,7 +3137,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)if (oicr &PFINT_OICR_TSYN_TX_M ) { ena_mask &= ~PFINT_OICR_TSYN_TX_M ; -if (!hw->reset_ongoing) +if (!hw->reset_ongoing &&ice_ptp_pf_handles_tx_interrupt (pf))set_bit (ICE_MISC_THREAD_TX_TSTAMP , pf->misc_thread); }
@@ -7298,8 +7298,13 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) }/* configure PTP timestamping after VSI rebuild */ -if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags)) -ice_ptp_cfg_timestamp (pf, false); +if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags)) { +if (pf->ptp.tx_interrupt_mode ==ICE_PTP_TX_INTERRUPT_SELF ) +ice_ptp_cfg_timestamp (pf, false); +else if (pf->ptp.tx_interrupt_mode ==ICE_PTP_TX_INTERRUPT_ALL ) +/* for E82x PHC owner always need to have interrupts */ +ice_ptp_cfg_timestamp (pf, true); + } err =ice_vsi_rebuild_by_type (pf,ICE_VSI_SWITCHDEV_CTRL );if (err) {
drivers/net/ethernet/intel/ice/ice_ptp.c +387 -16
497 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp.h +30 -0
@@ -157,7 +157,9 @@ 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 * @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
@@ -165,7 +167,9 @@ struct ice_ptp_tx {* @port_num: the port number this structure represents */ struct ice_ptp_port { +struct list_head list_member;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;
@@ -173,11 +177,35 @@ struct ice_ptp_port {u8 port_num; }; +enum ice_ptp_tx_interrupt { +ICE_PTP_TX_INTERRUPT_NONE =0 , +ICE_PTP_TX_INTERRUPT_SELF , +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 4/** * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK +* @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
@@ -197,7 +225,9 @@ struct ice_ptp_port {* @late_cached_phc_updates: number of times cached PHC update is late */ struct ice_ptp { +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 · 6 lines
2.9.5 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 2/3 ice: Use PTP auxbus for all PHYs restart in E822
In reply to Michal MichalikThe E822 (and other devices based on the same PHY) is having issue while setting the PHC timer - the PHY timers are drifting from the PHC. After such a set all PHYs need to be restarted and resynchronised - do it using auxiliary bus.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +21 -3
@@ -1491,6 +1491,24 @@ static void ice_ptp_reset_phy_timestamping(struct ice_pf *pf) }/** +* ice_ptp_restart_all_phy - Restart all PHYs to recalibrate timestamping +* @pf: Board private structure +*/ +static void ice_ptp_restart_all_phy (struct ice_pf *pf) +{ +struct list_head *entry; + +list_for_each (entry, &pf->ptp.ports_owner.ports) { +struct ice_ptp_port *port =list_entry (entry, + struct ice_ptp_port, + list_member); + +if (port->link_up) +ice_ptp_port_phy_restart (port); + } +} + +/** * ice_ptp_adjfine - Adjust clock increment rate * @info: the driver's PTP info structure * @scaled_ppm: Parts per million with 16-bit fractional field
@@ -1927,9 +1945,9 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)/* Reenable periodic outputs */ ice_ptp_enable_all_clkout (pf); -/* Recalibrate and re-enable timestamp block */ -if (pf->ptp.port.link_up) -ice_ptp_port_phy_restart (&pf->ptp.port); +/* Recalibrate and re-enable timestamp blocks for E822/E823 */ +if (!ice_is_e810 (hw)) +ice_ptp_restart_all_phy (pf); exit:if (err) {dev_err (ice_pf_to_dev (pf),"PTP failed to set time %d\n" , err);
Signature · 6 lines
2.9.5 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 3/3 ice: PTP: add clock domain number to auxiliary interface
In reply to Michal MichalikThe PHC clock id used to be moved between PFs using FW admin queue shared parameters - move the implementation to auxiliary bus.
--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 163 +++++---------------------- drivers/net/ethernet/intel/ice/ice_ptp.h | 11 +- 3 files changed, 34 insertions(+), 142 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +1 -1
@@ -3276,7 +3276,7 @@ ice_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)SOF_TIMESTAMPING_RX_HARDWARE |SOF_TIMESTAMPING_RAW_HARDWARE ; - info->phc_index =ice_get_ptp_clock_index (pf); + info->phc_index =ice_ptp_clock_index (pf); info->tx_types =BIT (HWTSTAMP_TX_OFF ) |BIT (HWTSTAMP_TX_ON );
drivers/net/ethernet/intel/ice/ice_ptp.c +27 -136
205 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp.h +6 -5
@@ -287,12 +287,12 @@ struct ice_ptp {#define N_EXT_TS_NO_SMA_E810T 2#define ETH_GLTSYN_ENA (_i) (0x03000348 + ((_i) * 4)) +int ice_ptp_clock_index (struct ice_pf *pf);#if IS_ENABLED (CONFIG_PTP_1588_CLOCK )struct ice_pf ;int ice_ptp_set_ts_config (struct ice_pf *pf,struct ifreq *ifr);int ice_ptp_get_ts_config (struct ice_pf *pf,struct ifreq *ifr);void ice_ptp_cfg_timestamp (struct ice_pf *pf,bool ena); -int ice_get_ptp_clock_index (struct ice_pf *pf);void ice_ptp_extts_event (struct ice_pf *pf);s8 ice_ptp_request_ts (struct ice_ptp_tx *tx,struct sk_buff *skb);
@@ -318,10 +318,6 @@ static inline int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) }static inline void ice_ptp_cfg_timestamp (struct ice_pf *pf,bool ena) { } -static inline int ice_get_ptp_clock_index (struct ice_pf *pf) -{ -return -1 ; -}static inline void ice_ptp_extts_event (struct ice_pf *pf) { } static inline s8
@@ -344,5 +340,10 @@ static inline void ice_ptp_release(struct ice_pf *pf) { }static inline void ice_ptp_link_change (struct ice_pf *pf,u8 port,bool linkup) { } + +static inline int ice_ptp_clock_index (struct ice_pf *pf) +{ +return -1 ; +}#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */ #endif /* _ICE_PTP_H_ */
Signature · 6 lines
2.9.5 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 3/3 ice: PTP: add clock domain number to auxiliary interface
From: Michalik, Michal <[email protected]>
Sent: Thursday, July 20 2023 2:13 PM
To: [email protected] <[email protected]>
Cc: Keller, Jacob E <[email protected]>; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>; Michalik, Michal <[email protected]>
Subject: [PATCH net-next v1 3/3] ice: PTP: add clock domain number to auxiliary interface
Quoted 6 lines
-
tmr_idx=hw->func_caps.ts_func_info.tmr_index_assoc; - if (!tmr_idx)
-param_idx=ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0; - else
-param_idx=ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1;
Are the parameters ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 and _TMR1 used anywhere else? If not, their definitions should be deleted too.
Thanks,
Karol
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next v1 3/3] ice: PTP: add clock domain number to auxiliary interface
Quoted 19 lines · Karol
From: Michalik, Michal <[email protected]>
Sent: Thursday, July 20 2023 2:13 PM
To: [email protected] <[email protected]>
Cc: Keller, Jacob E <[email protected]>; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>; Michalik, Michal <[email protected]>
Subject: [PATCH net-next v1 3/3] ice: PTP: add clock domain number to auxiliary interfacedrivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena) · line 373
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +0
-5- tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc; -if (!tmr_idx) - param_idx =ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0 ; -else - param_idx =ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR1 ;
Quoted 5 lines
Are the parameters
ICE_AQC_DRIVER_PARAM_CLK_IDX_TMR0and_TMR1used anywhere else? If not, their definitions should be deleted too.Thanks,
Karol
Great catch Karol, thanks - will fix it with the v2.
BR,
M^2
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
kernel test robot
build botRe: [Intel-wired-lan] [PATCH net-next v1 3/3] ice: PTP: add clock domain number to auxiliary interface
In reply to Michal Michalikkernel test robot noticed the following build errors:
Hi Michal,
kernel test robot noticed the following build errors:
[auto build test ERROR on tnguy-next-queue/dev-queue]
[cannot apply to net-next/main tnguy-net-queue/dev-queue linus/master v6.5-rc2 next-20230720] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Michal-Michalik/ice-Auxbus-devices-driver-for-E822-TS/20230720-202358 base: https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue patch link: https://lore.kernel.org/r/20230720121357.26739-4-michal.michalik%40intel.com patch subject: [Intel-wired-lan] [PATCH net-next v1 3/3] ice: PTP: add clock domain number to auxiliary interface config: x86_64-randconfig-x014-20230720 (https://download.01.org/0day-ci/archive/20230720/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230720/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/net/ethernet/intel/ice/ice.h:69,
from drivers/net/ethernet/intel/ice/ice_virtchnl.c:6:
>> drivers/net/ethernet/intel/ice/ice_ptp.h:344:19: error: static declaration of 'ice_ptp_clock_index' follows non-static declaration
344 | static inline int ice_ptp_clock_index(struct ice_pf *pf)
| ^~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/ice/ice_ptp.h:290:5: note: previous declaration of 'ice_ptp_clock_index' with type 'int(struct ice_pf *)'
290 | int ice_ptp_clock_index(struct ice_pf *pf);
| ^~~~~~~~~~~~~~~~~~~vim +/ice_ptp_clock_index +344 drivers/net/ethernet/intel/ice/ice_ptp.h
343
> 344 static inline int ice_ptp_clock_index(struct ice_pf *pf)
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki