Lines Matching full:ptp

181  * @info: the driver's PTP info structure
222 * @info: the driver's PTP info structure
288 pf->ptp.tstamp_config.tx_type = on ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; in ice_set_tx_tstamp()
312 pf->ptp.tstamp_config.rx_filter = on ? HWTSTAMP_FILTER_ALL : in ice_set_rx_tstamp()
321 * This function will configure timestamping during PTP initialization
331 * ice_get_ptp_clock_index - Get the PTP clock index
334 * Determine the clock index of the PTP clock associated with this device. If
341 * Returns: the index of the PTP clock associated with this device, or -1 if
354 if (pf->ptp.clock) in ice_get_ptp_clock_index()
355 return ptp_clock_index(pf->ptp.clock); in ice_get_ptp_clock_index()
365 dev_err(dev, "Failed to read PTP clock index parameter, err %d aq_err %s\n", in ice_get_ptp_clock_index()
370 /* The PTP clock index is an integer, and will be between 0 and in ice_get_ptp_clock_index()
381 * ice_set_ptp_clock_index - Set the PTP clock index
384 * Set the PTP clock index for this device into the shared driver parameters,
388 * will continue operating PTP.
399 if (!pf->ptp.clock) in ice_set_ptp_clock_index()
408 value = (u32)ptp_clock_index(pf->ptp.clock); in ice_set_ptp_clock_index()
410 dev_err(dev, "PTP Clock index is too large to store\n"); in ice_set_ptp_clock_index()
417 dev_err(dev, "Failed to set PTP clock index parameter, err %d aq_err %s\n", in ice_set_ptp_clock_index()
423 * ice_clear_ptp_clock_index - Clear the PTP clock index
426 * Clear the PTP clock index for this device. Must be called when
427 * unregistering the PTP clock, in order to ensure other PFs stop reporting
450 dev_dbg(dev, "Failed to clear PTP clock index parameter, err %d aq_err %s\n", in ice_clear_ptp_clock_index()
580 * time stored in the device private PTP structure as the basis for timestamp
592 discard_time = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_extend_40b_ts()
594 pf->ptp.tx_hwtstamp_discarded++; in ice_ptp_extend_40b_ts()
598 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
604 * @tx: the PTP Tx timestamp tracker to check
606 * Check that a given PTP Tx timestamp tracker is up, i.e. that it is ready
621 * @tx: the PTP Tx timestamp tracker
654 * In cases where the PTP hardware clock was directly adjusted, some
704 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_process_tx_tstamp()
882 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
897 * This should be called when the PTP clock is modified such as after a set
994 * Note that the cached copy in the PF PTP structure is always updated, even
1008 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
1009 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
1011 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
1015 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
1022 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
1023 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
1080 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
1089 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1163 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1171 * @port: PTP port for which Tx FIFO is checked
1197 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1258 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1270 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1279 * @ptp_port: PTP port to stop
1298 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1308 * @ptp_port: PTP port for which the PHY start is set
1348 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0); in ice_ptp_port_phy_restart()
1352 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1361 * ice_ptp_link_change - Reconfigure PTP after link status change
1376 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1429 dev_err(ice_pf_to_dev(pf), "PTP failed in intr ena, err %d\n", in ice_ptp_tx_ena_intr()
1440 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1445 * @info: the driver's PTP info structure
1461 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1470 * ice_ptp_extts_event - Process PTP external clock event
1488 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_event()
1496 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_event()
1497 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_event()
1518 if (chan > (unsigned int)pf->ptp.info.n_ext_ts) in ice_ptp_cfg_extts()
1546 pf->ptp.ext_ts_chan |= (1 << chan); in ice_ptp_cfg_extts()
1551 pf->ptp.ext_ts_chan &= ~(1 << chan); in ice_ptp_cfg_extts()
1552 if (!pf->ptp.ext_ts_chan) in ice_ptp_cfg_extts()
1595 gpio_pin = pf->ptp.perout_channels[chan].gpio_pin; in ice_ptp_cfg_clkout()
1600 memset(&pf->ptp.perout_channels[chan], 0, in ice_ptp_cfg_clkout()
1660 memcpy(&pf->ptp.perout_channels[chan], config, in ice_ptp_cfg_clkout()
1662 pf->ptp.perout_channels[chan].start_time = phase; in ice_ptp_cfg_clkout()
1667 dev_err(ice_pf_to_dev(pf), "PTP failed to cfg per_clk\n"); in ice_ptp_cfg_clkout()
1676 * certain changes to the PTP hardware clock. Use ice_ptp_enable_all_clkout to
1683 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_clkout()
1684 if (pf->ptp.perout_channels[i].ena) in ice_ptp_disable_all_clkout()
1700 for (i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_clkout()
1701 if (pf->ptp.perout_channels[i].ena) in ice_ptp_enable_all_clkout()
1702 ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i], in ice_ptp_enable_all_clkout()
1708 * @info: the driver's PTP info structure
1783 * @info: the driver's PTP info structure
1815 * @info: the driver's PTP info structure
1831 dev_err(ice_pf_to_dev(pf), "PTP failed to get time\n"); in ice_ptp_gettimex64()
1843 * @info: the driver's PTP info structure
1860 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1861 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_settime64()
1881 if (pf->ptp.port.link_up) in ice_ptp_settime64()
1882 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_settime64()
1885 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
1894 * @info: the driver's PTP info structure
1913 * @info: the driver's PTP info structure
1935 dev_err(dev, "PTP failed to acquire semaphore in adjtime\n"); in ice_ptp_adjtime()
1950 dev_err(dev, "PTP failed to adjust time, err %d\n", err); in ice_ptp_adjtime()
1982 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2030 * @info: the driver's PTP info structure
2033 * Capture a cross timestamp between the ART and the device PTP hardware
2068 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2143 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2192 * @info: PTP clock info structure
2215 * @info: PTP clock info structure
2242 * ice_ptp_setup_pins_e810 - Setup PTP pins in sysfs
2244 * @info: PTP clock capabilities
2267 * ice_ptp_setup_pins_e823 - Setup PTP pins in sysfs
2269 * @info: PTP clock capabilities
2282 * @info: PTP info to fill
2284 * Assign functions to the PTP capabiltiies structure for E822 devices.
2302 * @info: PTP info to fill
2304 * Assign functions to the PTP capabiltiies structure for E810 devices.
2319 * @info: PTP info to fill
2321 * Assign functions to the PTP capabiltiies structure for E823 devices.
2334 * ice_ptp_set_caps - Set PTP capabilities
2339 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2360 * ice_ptp_create_clock - Create PTP clock device for userspace
2363 * This function creates a new PTP clock device. It only creates one if we
2375 if (pf->ptp.clock) in ice_ptp_create_clock()
2380 info = &pf->ptp.info; in ice_ptp_create_clock()
2388 pf->ptp.clock = clock; in ice_ptp_create_clock()
2395 * @tx: the PTP Tx timestamp tracker to request from
2437 * ice_ptp_process_ts - Process the PTP Tx timestamps
2445 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2450 struct ice_ptp *ptp = container_of(work, struct ice_ptp, work.work); in ice_ptp_periodic_work() local
2451 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work()
2460 kthread_queue_delayed_work(ptp->kworker, &ptp->work, in ice_ptp_periodic_work()
2465 * ice_ptp_reset - Initialize PTP hardware clock support after reset
2470 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_reset() local
2503 if (ptp->cached_phc_time) { in ice_ptp_reset()
2504 time_diff = ktime_get_real_ns() - ptp->reset_time; in ice_ptp_reset()
2505 ts = ns_to_timespec64(ptp->cached_phc_time + time_diff); in ice_ptp_reset()
2532 err = ice_ptp_init_tx_e810(pf, &ptp->port.tx); in ice_ptp_reset()
2534 kthread_init_delayed_work(&ptp->port.ov_work, in ice_ptp_reset()
2536 err = ice_ptp_init_tx_e822(pf, &ptp->port.tx, in ice_ptp_reset()
2537 ptp->port.port_num); in ice_ptp_reset()
2545 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_reset()
2547 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_reset()
2551 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_reset()
2555 * ice_ptp_prepare_for_reset - Prepare PTP for reset
2560 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset() local
2568 kthread_cancel_delayed_work_sync(&ptp->work); in ice_ptp_prepare_for_reset()
2573 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2584 ptp->reset_time = ktime_get_real_ns(); in ice_ptp_prepare_for_reset()
2591 * Setup and initialize a PTP clock device that represents the device hardware
2644 /* Store the PTP clock index for other PFs */ in ice_ptp_init_owner()
2650 pf->ptp.clock = NULL; in ice_ptp_init_owner()
2656 * ice_ptp_init_work - Initialize PTP work threads
2658 * @ptp: PF PTP structure
2660 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
2665 kthread_init_delayed_work(&ptp->work, ice_ptp_periodic_work); in ice_ptp_init_work()
2668 * connected to the PTP hardware clock. in ice_ptp_init_work()
2670 kworker = kthread_create_worker(0, "ice-ptp-%s", in ice_ptp_init_work()
2675 ptp->kworker = kworker; in ice_ptp_init_work()
2678 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_init_work()
2684 * ice_ptp_init_port - Initialize PTP port structure
2686 * @ptp_port: PTP port structure
2701 * ice_ptp_init - Initialize PTP hardware clock support
2704 * Set up the device for interacting with the PTP hardware clock for all
2714 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init() local
2719 * configure the PTP clock device to represent it. in ice_ptp_init()
2727 ptp->port.port_num = hw->pf_id; in ice_ptp_init()
2728 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
2736 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
2740 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
2744 /* If we registered a PTP clock, release it */ in ice_ptp_init()
2745 if (pf->ptp.clock) { in ice_ptp_init()
2746 ptp_clock_unregister(ptp->clock); in ice_ptp_init()
2747 pf->ptp.clock = NULL; in ice_ptp_init()
2750 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
2768 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
2772 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
2774 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
2775 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
2776 if (pf->ptp.kworker) { in ice_ptp_release()
2777 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
2778 pf->ptp.kworker = NULL; in ice_ptp_release()
2781 if (!pf->ptp.clock) in ice_ptp_release()
2788 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
2789 pf->ptp.clock = NULL; in ice_ptp_release()
2791 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()