Lines Matching full:ptp
179 * @info: the driver's PTP info structure
220 * @info: the driver's PTP info structure
269 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_cfg_tx_interrupt()
282 enable = pf->ptp.tstamp_config.tx_type == HWTSTAMP_TX_ON; in ice_ptp_cfg_tx_interrupt()
351 enable_rx = pf->ptp.tstamp_config.rx_filter == HWTSTAMP_FILTER_ALL; in ice_ptp_restore_timestamp_mode()
487 * time stored in the device private PTP structure as the basis for timestamp
499 discard_time = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_extend_40b_ts()
501 pf->ptp.tx_hwtstamp_discarded++; in ice_ptp_extend_40b_ts()
505 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
511 * @tx: the PTP Tx timestamp tracker to check
513 * Check that a given PTP Tx timestamp tracker is up, i.e. that it is ready
528 * @tx: the PTP Tx timestamp tracker
546 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_req_tx_single_tstamp()
567 * @tx: the PTP Tx timestamp tracker
637 * @tx: the PTP Tx timestamp tracker
670 * In cases where the PTP hardware clock was directly adjusted, some
720 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_process_tx_tstamp()
803 mutex_lock(&pf->ptp.ports_owner.lock); in ice_ptp_tx_tstamp_owner()
804 list_for_each_entry(port, &pf->ptp.ports_owner.ports, list_member) { in ice_ptp_tx_tstamp_owner()
812 mutex_unlock(&pf->ptp.ports_owner.lock); in ice_ptp_tx_tstamp_owner()
814 for (i = 0; i < ICE_GET_QUAD_NUM(pf->hw.ptp.num_lports); i++) { in ice_ptp_tx_tstamp_owner()
937 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
952 * This should be called when the PTP clock is modified such as after a set
977 list_for_each_entry(port, &pf->ptp.ports_owner.ports, list_member) in ice_ptp_flush_all_tx_tracker()
1091 * Note that the cached copy in the PF PTP structure is always updated, even
1105 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
1106 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
1108 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
1112 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
1119 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
1120 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
1177 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
1186 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1235 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1243 * @port: PTP port for which Tx FIFO is checked
1269 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1330 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1342 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1351 * @ptp_port: PTP port to stop
1366 switch (hw->ptp.phy_model) { in ice_ptp_port_phy_stop()
1379 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1389 * @ptp_port: PTP port for which the PHY start is set
1412 switch (hw->ptp.phy_model) { in ice_ptp_port_phy_restart()
1438 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, in ice_ptp_port_phy_restart()
1446 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1455 * ice_ptp_link_change - Reconfigure PTP after link status change
1465 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_link_change()
1468 if (WARN_ON_ONCE(port >= hw->ptp.num_lports)) in ice_ptp_link_change()
1471 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1472 if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo) in ice_ptp_link_change()
1484 switch (hw->ptp.phy_model) { in ice_ptp_link_change()
1517 switch (hw->ptp.phy_model) { in ice_ptp_cfg_phy_interrupt()
1521 for (port = 0; port < hw->ptp.num_lports; port++) { in ice_ptp_cfg_phy_interrupt()
1537 for (quad = 0; quad < ICE_GET_QUAD_NUM(hw->ptp.num_lports); in ice_ptp_cfg_phy_interrupt()
1556 hw->ptp.phy_model); in ice_ptp_cfg_phy_interrupt()
1567 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1578 list_for_each(entry, &pf->ptp.ports_owner.ports) { in ice_ptp_restart_all_phy()
1590 * @info: the driver's PTP info structure
1606 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1615 * ice_ptp_extts_event - Process PTP external clock event
1625 /* Don't process timestamp events if PTP is not ready */ in ice_ptp_extts_event()
1626 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_extts_event()
1637 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_event()
1645 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_event()
1646 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_event()
1700 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
1705 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
1706 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
1715 memcpy(&pf->ptp.extts_channels[chan], config, sizeof(*config)); in ice_ptp_cfg_extts()
1729 for (i = 0; i < pf->ptp.info.n_ext_ts; i++) { in ice_ptp_disable_all_extts()
1730 if (pf->ptp.extts_channels[i].ena) { in ice_ptp_disable_all_extts()
1731 extts_cfg.gpio_pin = pf->ptp.extts_channels[i].gpio_pin; in ice_ptp_disable_all_extts()
1750 for (i = 0; i < pf->ptp.info.n_ext_ts; i++) { in ice_ptp_enable_all_extts()
1751 if (pf->ptp.extts_channels[i].ena) in ice_ptp_enable_all_extts()
1752 ice_ptp_cfg_extts(pf, i, &pf->ptp.extts_channels[i], in ice_ptp_enable_all_extts()
1792 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
1797 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
1856 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
1858 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
1863 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
1872 * certain changes to the PTP hardware clock. Use ice_ptp_enable_all_clkout to
1879 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
1880 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
1896 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
1897 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
1898 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
1904 * @info: the driver's PTP info structure
1985 * @info: the driver's PTP info structure
2023 * @info: the driver's PTP info structure
2045 * @info: the driver's PTP info structure
2062 if (hw->ptp.phy_model == ICE_PHY_E82X) { in ice_ptp_settime64()
2086 if (hw->ptp.phy_model == ICE_PHY_E82X) in ice_ptp_settime64()
2090 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
2099 * @info: the driver's PTP info structure
2118 * @info: the driver's PTP info structure
2140 dev_err(dev, "PTP failed to acquire semaphore in adjtime\n"); in ice_ptp_adjtime()
2155 dev_err(dev, "PTP failed to adjust time, err %d\n", err); in ice_ptp_adjtime()
2197 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2251 * @info: the driver's PTP info structure
2254 * Capture a cross timestamp between the ART and the device PTP hardware
2286 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_get_ts_config()
2289 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2305 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ice_ptp_set_timestamp_mode()
2308 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; in ice_ptp_set_timestamp_mode()
2316 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ice_ptp_set_timestamp_mode()
2332 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL; in ice_ptp_set_timestamp_mode()
2356 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_set_ts_config()
2367 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2410 * @info: PTP clock info structure
2433 * @info: PTP clock info structure
2460 * ice_ptp_setup_pins_e810 - Setup PTP pins in sysfs
2462 * @info: PTP clock capabilities
2485 * ice_ptp_setup_pins_e823 - Setup PTP pins in sysfs
2487 * @info: PTP clock capabilities
2500 * @info: PTP info to fill
2502 * Assign functions to the PTP capabiltiies structure for E82x devices.
2520 * @info: PTP info to fill
2522 * Assign functions to the PTP capabiltiies structure for E810 devices.
2537 * @info: PTP info to fill
2539 * Assign functions to the PTP capabiltiies structure for E823 devices.
2554 * ice_ptp_set_caps - Set PTP capabilities
2559 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2580 * ice_ptp_create_clock - Create PTP clock device for userspace
2583 * This function creates a new PTP clock device. It only creates one if we
2594 if (pf->ptp.clock) in ice_ptp_create_clock()
2599 info = &pf->ptp.info; in ice_ptp_create_clock()
2603 pf->ptp.clock = ptp_clock_register(info, dev); in ice_ptp_create_clock()
2604 if (IS_ERR(pf->ptp.clock)) { in ice_ptp_create_clock()
2605 dev_err(ice_pf_to_dev(pf), "Failed to register PTP clock device"); in ice_ptp_create_clock()
2606 return PTR_ERR(pf->ptp.clock); in ice_ptp_create_clock()
2614 * @tx: the PTP Tx timestamp tracker to request from
2661 * ice_ptp_process_ts - Process the PTP Tx timestamps
2669 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_process_ts()
2675 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2681 pf->ptp.tx_interrupt_mode); in ice_ptp_process_ts()
2712 for (i = 0; i < ICE_GET_QUAD_NUM(hw->ptp.num_lports); i++) { in ice_ptp_maybe_trigger_tx_interrupt()
2727 …dev_dbg(dev, "PTP periodic task detected waiting timestamps. Triggering Tx timestamp interrupt now… in ice_ptp_maybe_trigger_tx_interrupt()
2736 struct ice_ptp *ptp = container_of(work, struct ice_ptp, work.work); in ice_ptp_periodic_work() local
2737 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work()
2740 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_periodic_work()
2748 kthread_queue_delayed_work(ptp->kworker, &ptp->work, in ice_ptp_periodic_work()
2753 * ice_ptp_prepare_for_reset - Prepare PTP for reset
2759 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset() local
2762 if (ptp->state != ICE_PTP_READY) in ice_ptp_prepare_for_reset()
2765 ptp->state = ICE_PTP_RESETTING; in ice_ptp_prepare_for_reset()
2770 kthread_cancel_delayed_work_sync(&ptp->work); in ice_ptp_prepare_for_reset()
2775 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2786 ptp->reset_time = ktime_get_real_ns(); in ice_ptp_prepare_for_reset()
2790 * ice_ptp_rebuild_owner - Initialize PTP clock owner after reset
2794 * PTP clock owner instance should perform.
2798 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_rebuild_owner() local
2825 if (ptp->cached_phc_time) { in ice_ptp_rebuild_owner()
2826 time_diff = ktime_get_real_ns() - ptp->reset_time; in ice_ptp_rebuild_owner()
2827 ts = ns_to_timespec64(ptp->cached_phc_time + time_diff); in ice_ptp_rebuild_owner()
2862 * ice_ptp_rebuild - Initialize PTP hardware clock support after reset
2868 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_rebuild() local
2871 if (ptp->state == ICE_PTP_READY) { in ice_ptp_rebuild()
2873 } else if (ptp->state != ICE_PTP_RESETTING) { in ice_ptp_rebuild()
2875 dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); in ice_ptp_rebuild()
2885 ptp->state = ICE_PTP_READY; in ice_ptp_rebuild()
2888 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_rebuild()
2890 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_rebuild()
2894 ptp->state = ICE_PTP_ERROR; in ice_ptp_rebuild()
2895 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_rebuild()
2911 return container_of(aux_ptp, struct ice_pf, ptp); in ice_ptp_aux_dev_to_aux_pf()
2932 return container_of(owner_ptp, struct ice_pf, ptp); in ice_ptp_aux_dev_to_owner_pf()
2949 INIT_LIST_HEAD(&aux_pf->ptp.port.list_member); in ice_ptp_auxbus_probe()
2950 mutex_lock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_probe()
2951 list_add(&aux_pf->ptp.port.list_member, in ice_ptp_auxbus_probe()
2952 &owner_pf->ptp.ports_owner.ports); in ice_ptp_auxbus_probe()
2953 mutex_unlock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_probe()
2967 mutex_lock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_remove()
2968 list_del(&aux_pf->ptp.port.list_member); in ice_ptp_auxbus_remove()
2969 mutex_unlock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_remove()
3025 * ice_ptp_register_auxbus_driver - Register PTP auxiliary bus driver
3031 struct ice_ptp *ptp; in ice_ptp_register_auxbus_driver() local
3036 ptp = &pf->ptp; in ice_ptp_register_auxbus_driver()
3038 aux_driver = &ptp->ports_owner.aux_driver; in ice_ptp_register_auxbus_driver()
3039 INIT_LIST_HEAD(&ptp->ports_owner.ports); in ice_ptp_register_auxbus_driver()
3040 mutex_init(&ptp->ports_owner.lock); in ice_ptp_register_auxbus_driver()
3068 * ice_ptp_unregister_auxbus_driver - Unregister PTP auxiliary bus driver
3073 struct auxiliary_driver *aux_driver = &pf->ptp.ports_owner.aux_driver; in ice_ptp_unregister_auxbus_driver()
3078 mutex_destroy(&pf->ptp.ports_owner.lock); in ice_ptp_unregister_auxbus_driver()
3082 * ice_ptp_clock_index - Get the PTP clock index for this device
3085 * Returns: the PTP clock index associated with this PF, or -1 if no PTP clock
3094 aux_dev = &pf->ptp.port.aux_dev; in ice_ptp_clock_index()
3098 clock = owner_pf->ptp.clock; in ice_ptp_clock_index()
3107 * Setup and initialize a PTP clock device that represents the device hardware
3160 dev_err(ice_pf_to_dev(pf), "Failed to register PTP auxbus driver"); in ice_ptp_init_owner()
3166 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_init_owner()
3168 pf->ptp.clock = NULL; in ice_ptp_init_owner()
3174 * ice_ptp_init_work - Initialize PTP work threads
3176 * @ptp: PF PTP structure
3178 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
3183 kthread_init_delayed_work(&ptp->work, ice_ptp_periodic_work); in ice_ptp_init_work()
3186 * connected to the PTP hardware clock. in ice_ptp_init_work()
3188 kworker = kthread_create_worker(0, "ice-ptp-%s", in ice_ptp_init_work()
3193 ptp->kworker = kworker; in ice_ptp_init_work()
3196 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_init_work()
3202 * ice_ptp_init_port - Initialize PTP port structure
3204 * @ptp_port: PTP port structure
3212 switch (hw->ptp.phy_model) { in ice_ptp_init_port()
3239 * ice_ptp_create_auxbus_device - Create PTP auxiliary bus device
3245 struct ice_ptp *ptp; in ice_ptp_create_auxbus_device() local
3251 ptp = &pf->ptp; in ice_ptp_create_auxbus_device()
3252 id = ptp->port.port_num; in ice_ptp_create_auxbus_device()
3255 aux_dev = &ptp->port.aux_dev; in ice_ptp_create_auxbus_device()
3280 dev_err(dev, "Failed to create PTP auxiliary bus device <%s>\n", name); in ice_ptp_create_auxbus_device()
3286 * ice_ptp_remove_auxbus_device - Remove PTP auxiliary bus device
3291 struct auxiliary_device *aux_dev = &pf->ptp.port.aux_dev; in ice_ptp_remove_auxbus_device()
3310 switch (pf->hw.ptp.phy_model) { in ice_ptp_init_tx_interrupt_mode()
3316 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_ALL; in ice_ptp_init_tx_interrupt_mode()
3318 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_NONE; in ice_ptp_init_tx_interrupt_mode()
3322 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_SELF; in ice_ptp_init_tx_interrupt_mode()
3327 * ice_ptp_init - Initialize PTP hardware clock support
3330 * Set up the device for interacting with the PTP hardware clock for all
3340 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init() local
3344 ptp->state = ICE_PTP_INITIALIZING; in ice_ptp_init()
3351 * configure the PTP clock device to represent it. in ice_ptp_init()
3359 ptp->port.port_num = hw->pf_id; in ice_ptp_init()
3360 if (ice_is_e825c(hw) && hw->ptp.is_2x50g_muxed_topo) in ice_ptp_init()
3361 ptp->port.port_num = hw->pf_id * 2; in ice_ptp_init()
3363 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
3377 ptp->state = ICE_PTP_READY; in ice_ptp_init()
3379 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
3383 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
3387 /* If we registered a PTP clock, release it */ in ice_ptp_init()
3388 if (pf->ptp.clock) { in ice_ptp_init()
3389 ptp_clock_unregister(ptp->clock); in ice_ptp_init()
3390 pf->ptp.clock = NULL; in ice_ptp_init()
3392 ptp->state = ICE_PTP_ERROR; in ice_ptp_init()
3393 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
3405 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_release()
3408 pf->ptp.state = ICE_PTP_UNINIT; in ice_ptp_release()
3415 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
3419 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
3421 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
3422 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
3423 if (pf->ptp.kworker) { in ice_ptp_release()
3424 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
3425 pf->ptp.kworker = NULL; in ice_ptp_release()
3431 if (!pf->ptp.clock) in ice_ptp_release()
3437 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
3438 pf->ptp.clock = NULL; in ice_ptp_release()
3440 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()