Lines Matching full:ptp
181 * @info: the driver's PTP info structure
222 * @info: the driver's PTP info structure
271 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_cfg_tx_interrupt()
284 enable = pf->ptp.tstamp_config.tx_type == HWTSTAMP_TX_ON; in ice_ptp_cfg_tx_interrupt()
353 enable_rx = pf->ptp.tstamp_config.rx_filter == HWTSTAMP_FILTER_ALL; in ice_ptp_restore_timestamp_mode()
488 * time stored in the device private PTP structure as the basis for timestamp
500 discard_time = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_extend_40b_ts()
502 pf->ptp.tx_hwtstamp_discarded++; in ice_ptp_extend_40b_ts()
506 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
512 * @tx: the PTP Tx timestamp tracker to check
514 * Check that a given PTP Tx timestamp tracker is up, i.e. that it is ready
529 * @tx: the PTP Tx timestamp tracker
547 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_req_tx_single_tstamp()
568 * @tx: the PTP Tx timestamp tracker
642 * @tx: the PTP Tx timestamp tracker
675 * In cases where the PTP hardware clock was directly adjusted, some
723 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_process_tx_tstamp()
805 mutex_lock(&pf->ptp.ports_owner.lock); in ice_ptp_tx_tstamp_owner()
806 list_for_each_entry(port, &pf->ptp.ports_owner.ports, list_member) { in ice_ptp_tx_tstamp_owner()
814 mutex_unlock(&pf->ptp.ports_owner.lock); in ice_ptp_tx_tstamp_owner()
939 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
954 * This should be called when the PTP clock is modified such as after a set
1055 * Note that the cached copy in the PF PTP structure is always updated, even
1069 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
1070 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
1072 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
1076 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
1083 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
1084 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
1141 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
1150 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1224 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1232 * @port: PTP port for which Tx FIFO is checked
1258 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1319 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1331 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1340 * @ptp_port: PTP port to stop
1359 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1369 * @ptp_port: PTP port for which the PHY start is set
1410 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0); in ice_ptp_port_phy_restart()
1414 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1423 * ice_ptp_link_change - Reconfigure PTP after link status change
1439 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1497 dev_err(ice_pf_to_dev(pf), "PTP failed in intr ena, err %d\n", in ice_ptp_tx_ena_intr()
1508 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1519 list_for_each(entry, &pf->ptp.ports_owner.ports) { in ice_ptp_restart_all_phy()
1531 * @info: the driver's PTP info structure
1547 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1556 * ice_ptp_extts_event - Process PTP external clock event
1574 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_event()
1582 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_event()
1583 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_event()
1604 if (chan > (unsigned int)pf->ptp.info.n_ext_ts) in ice_ptp_cfg_extts()
1631 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
1636 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
1637 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
1680 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
1685 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
1745 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
1747 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
1752 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
1761 * certain changes to the PTP hardware clock. Use ice_ptp_enable_all_clkout to
1768 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
1769 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
1785 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
1786 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
1787 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
1793 * @info: the driver's PTP info structure
1868 * @info: the driver's PTP info structure
1900 * @info: the driver's PTP info structure
1916 dev_err(ice_pf_to_dev(pf), "PTP failed to get time\n"); in ice_ptp_gettimex64()
1928 * @info: the driver's PTP info structure
1945 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1946 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_settime64()
1970 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
1979 * @info: the driver's PTP info structure
1998 * @info: the driver's PTP info structure
2020 dev_err(dev, "PTP failed to acquire semaphore in adjtime\n"); in ice_ptp_adjtime()
2035 dev_err(dev, "PTP failed to adjust time, err %d\n", err); in ice_ptp_adjtime()
2077 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2130 * @info: the driver's PTP info structure
2133 * Capture a cross timestamp between the ART and the device PTP hardware
2168 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2184 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ice_ptp_set_timestamp_mode()
2187 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; in ice_ptp_set_timestamp_mode()
2195 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ice_ptp_set_timestamp_mode()
2211 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL; in ice_ptp_set_timestamp_mode()
2246 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2289 * @info: PTP clock info structure
2312 * @info: PTP clock info structure
2339 * ice_ptp_setup_pins_e810 - Setup PTP pins in sysfs
2341 * @info: PTP clock capabilities
2364 * ice_ptp_setup_pins_e823 - Setup PTP pins in sysfs
2366 * @info: PTP clock capabilities
2379 * @info: PTP info to fill
2381 * Assign functions to the PTP capabiltiies structure for E82x devices.
2399 * @info: PTP info to fill
2401 * Assign functions to the PTP capabiltiies structure for E810 devices.
2416 * @info: PTP info to fill
2418 * Assign functions to the PTP capabiltiies structure for E823 devices.
2433 * ice_ptp_set_caps - Set PTP capabilities
2438 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2459 * ice_ptp_create_clock - Create PTP clock device for userspace
2462 * This function creates a new PTP clock device. It only creates one if we
2473 if (pf->ptp.clock) in ice_ptp_create_clock()
2478 info = &pf->ptp.info; in ice_ptp_create_clock()
2482 pf->ptp.clock = ptp_clock_register(info, dev); in ice_ptp_create_clock()
2483 if (IS_ERR(pf->ptp.clock)) { in ice_ptp_create_clock()
2484 dev_err(ice_pf_to_dev(pf), "Failed to register PTP clock device"); in ice_ptp_create_clock()
2485 return PTR_ERR(pf->ptp.clock); in ice_ptp_create_clock()
2493 * @tx: the PTP Tx timestamp tracker to request from
2540 * ice_ptp_process_ts - Process the PTP Tx timestamps
2548 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_process_ts()
2554 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2560 pf->ptp.tx_interrupt_mode); in ice_ptp_process_ts()
2606 …dev_dbg(dev, "PTP periodic task detected waiting timestamps. Triggering Tx timestamp interrupt now… in ice_ptp_maybe_trigger_tx_interrupt()
2615 struct ice_ptp *ptp = container_of(work, struct ice_ptp, work.work); in ice_ptp_periodic_work() local
2616 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work()
2627 kthread_queue_delayed_work(ptp->kworker, &ptp->work, in ice_ptp_periodic_work()
2632 * ice_ptp_reset - Initialize PTP hardware clock support after reset
2637 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_reset() local
2668 if (ptp->cached_phc_time) { in ice_ptp_reset()
2669 time_diff = ktime_get_real_ns() - ptp->reset_time; in ice_ptp_reset()
2670 ts = ns_to_timespec64(ptp->cached_phc_time + time_diff); in ice_ptp_reset()
2693 err = ice_ptp_init_tx_e810(pf, &ptp->port.tx); in ice_ptp_reset()
2695 kthread_init_delayed_work(&ptp->port.ov_work, in ice_ptp_reset()
2697 err = ice_ptp_init_tx_e82x(pf, &ptp->port.tx, in ice_ptp_reset()
2698 ptp->port.port_num); in ice_ptp_reset()
2711 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_reset()
2713 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_reset()
2717 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_reset()
2733 return container_of(aux_ptp, struct ice_pf, ptp); in ice_ptp_aux_dev_to_aux_pf()
2754 return container_of(owner_ptp, struct ice_pf, ptp); in ice_ptp_aux_dev_to_owner_pf()
2771 INIT_LIST_HEAD(&aux_pf->ptp.port.list_member); in ice_ptp_auxbus_probe()
2772 mutex_lock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_probe()
2773 list_add(&aux_pf->ptp.port.list_member, in ice_ptp_auxbus_probe()
2774 &owner_pf->ptp.ports_owner.ports); in ice_ptp_auxbus_probe()
2775 mutex_unlock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_probe()
2789 mutex_lock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_remove()
2790 list_del(&aux_pf->ptp.port.list_member); in ice_ptp_auxbus_remove()
2791 mutex_unlock(&owner_pf->ptp.ports_owner.lock); in ice_ptp_auxbus_remove()
2847 * ice_ptp_register_auxbus_driver - Register PTP auxiliary bus driver
2853 struct ice_ptp *ptp; in ice_ptp_register_auxbus_driver() local
2858 ptp = &pf->ptp; in ice_ptp_register_auxbus_driver()
2860 aux_driver = &ptp->ports_owner.aux_driver; in ice_ptp_register_auxbus_driver()
2861 INIT_LIST_HEAD(&ptp->ports_owner.ports); in ice_ptp_register_auxbus_driver()
2862 mutex_init(&ptp->ports_owner.lock); in ice_ptp_register_auxbus_driver()
2890 * ice_ptp_unregister_auxbus_driver - Unregister PTP auxiliary bus driver
2895 struct auxiliary_driver *aux_driver = &pf->ptp.ports_owner.aux_driver; in ice_ptp_unregister_auxbus_driver()
2900 mutex_destroy(&pf->ptp.ports_owner.lock); in ice_ptp_unregister_auxbus_driver()
2904 * ice_ptp_clock_index - Get the PTP clock index for this device
2907 * Returns: the PTP clock index associated with this PF, or -1 if no PTP clock
2916 aux_dev = &pf->ptp.port.aux_dev; in ice_ptp_clock_index()
2920 clock = owner_pf->ptp.clock; in ice_ptp_clock_index()
2926 * ice_ptp_prepare_for_reset - Prepare PTP for reset
2931 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset() local
2939 kthread_cancel_delayed_work_sync(&ptp->work); in ice_ptp_prepare_for_reset()
2944 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2955 ptp->reset_time = ktime_get_real_ns(); in ice_ptp_prepare_for_reset()
2962 * Setup and initialize a PTP clock device that represents the device hardware
3017 dev_err(ice_pf_to_dev(pf), "Failed to register PTP auxbus driver"); in ice_ptp_init_owner()
3023 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_init_owner()
3025 pf->ptp.clock = NULL; in ice_ptp_init_owner()
3031 * ice_ptp_init_work - Initialize PTP work threads
3033 * @ptp: PF PTP structure
3035 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
3040 kthread_init_delayed_work(&ptp->work, ice_ptp_periodic_work); in ice_ptp_init_work()
3043 * connected to the PTP hardware clock. in ice_ptp_init_work()
3045 kworker = kthread_create_worker(0, "ice-ptp-%s", in ice_ptp_init_work()
3050 ptp->kworker = kworker; in ice_ptp_init_work()
3053 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_init_work()
3059 * ice_ptp_init_port - Initialize PTP port structure
3061 * @ptp_port: PTP port structure
3093 * ice_ptp_create_auxbus_device - Create PTP auxiliary bus device
3099 struct ice_ptp *ptp; in ice_ptp_create_auxbus_device() local
3105 ptp = &pf->ptp; in ice_ptp_create_auxbus_device()
3106 id = ptp->port.port_num; in ice_ptp_create_auxbus_device()
3109 aux_dev = &ptp->port.aux_dev; in ice_ptp_create_auxbus_device()
3134 dev_err(dev, "Failed to create PTP auxiliary bus device <%s>\n", name); in ice_ptp_create_auxbus_device()
3140 * ice_ptp_remove_auxbus_device - Remove PTP auxiliary bus device
3145 struct auxiliary_device *aux_dev = &pf->ptp.port.aux_dev; in ice_ptp_remove_auxbus_device()
3170 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_ALL; in ice_ptp_init_tx_interrupt_mode()
3172 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_NONE; in ice_ptp_init_tx_interrupt_mode()
3176 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_SELF; in ice_ptp_init_tx_interrupt_mode()
3181 * ice_ptp_init - Initialize PTP hardware clock support
3184 * Set up the device for interacting with the PTP hardware clock for all
3194 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init() local
3203 * configure the PTP clock device to represent it. in ice_ptp_init()
3211 ptp->port.port_num = hw->pf_id; in ice_ptp_init()
3212 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
3223 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
3231 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
3235 /* If we registered a PTP clock, release it */ in ice_ptp_init()
3236 if (pf->ptp.clock) { in ice_ptp_init()
3237 ptp_clock_unregister(ptp->clock); in ice_ptp_init()
3238 pf->ptp.clock = NULL; in ice_ptp_init()
3241 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
3261 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
3265 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
3267 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
3268 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
3269 if (pf->ptp.kworker) { in ice_ptp_release()
3270 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
3271 pf->ptp.kworker = NULL; in ice_ptp_release()
3274 if (!pf->ptp.clock) in ice_ptp_release()
3280 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
3281 pf->ptp.clock = NULL; in ice_ptp_release()
3285 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()