Lines Matching full:ptp

69 	return !ctrl_pf ? NULL : &ctrl_pf->ptp;  in ice_get_ctrl_ptp()
83 const struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_find_pin_idx()
158 const struct ice_ptp_pin_desc *ice_pins = pf->ptp.ice_pin_desc; in ice_ptp_set_sma_cfg()
159 struct ptp_pin_desc *pins = pf->ptp.pin_desc; in ice_ptp_set_sma_cfg()
170 for (int i = 0; i < pf->ptp.info.n_pins; i++) in ice_ptp_set_sma_cfg()
203 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_cfg_tx_interrupt()
216 enable = pf->ptp.tstamp_config.tx_type == HWTSTAMP_TX_ON; in ice_ptp_cfg_tx_interrupt()
285 enable_rx = pf->ptp.tstamp_config.rx_filter == HWTSTAMP_FILTER_ALL; in ice_ptp_restore_timestamp_mode()
421 * time stored in the device private PTP structure as the basis for timestamp
433 discard_time = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_extend_40b_ts()
435 pf->ptp.tx_hwtstamp_discarded++; in ice_ptp_extend_40b_ts()
439 return ice_ptp_extend_32b_ts(pf->ptp.cached_phc_time, in ice_ptp_extend_40b_ts()
445 * @tx: the PTP Tx timestamp tracker to check
447 * Check that a given PTP Tx timestamp tracker is up, i.e. that it is ready
462 * @tx: the PTP Tx timestamp tracker
478 params = &pf->hw.ptp.phy.e810; in ice_ptp_req_tx_single_tstamp()
483 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_req_tx_single_tstamp()
510 * @tx: the PTP Tx timestamp tracker
532 params = &pf->hw.ptp.phy.e810; in ice_ptp_complete_tx_single_tstamp()
597 * @tx: the PTP Tx timestamp tracker
630 * In cases where the PTP hardware clock was directly adjusted, some
680 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_process_tx_tstamp()
774 for (i = 0; i < ICE_GET_QUAD_NUM(pf->hw.ptp.num_lports); i++) { in ice_ptp_tx_tstamp_owner()
897 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
912 * This should be called when the PTP clock is modified such as after a set
1051 * Note that the cached copy in the PF PTP structure is always updated, even
1065 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
1066 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
1068 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
1072 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
1079 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
1080 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
1137 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
1146 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1195 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1203 * @port: PTP port for which Tx FIFO is checked
1229 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1290 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1302 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1311 * @ptp_port: PTP port to stop
1339 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1349 * @ptp_port: PTP port for which the PHY start is set
1398 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, in ice_ptp_port_phy_restart()
1406 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1415 * ice_ptp_link_change - Reconfigure PTP after link status change
1424 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_link_change()
1427 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1472 for (port = 0; port < hw->ptp.num_lports; port++) { in ice_ptp_cfg_phy_interrupt()
1488 for (quad = 0; quad < ICE_GET_QUAD_NUM(hw->ptp.num_lports); in ice_ptp_cfg_phy_interrupt()
1518 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1541 * @info: the driver's PTP info structure
1557 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1566 * ice_ptp_extts_event - Process PTP external clock event
1576 /* Don't process timestamp events if PTP is not ready */ in ice_ptp_extts_event()
1577 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_extts_event()
1590 if (!(pf->ptp.ext_ts_irq & (1 << chan))) in ice_ptp_extts_event()
1602 desc = &pf->ptp.ice_pin_desc[pin_desc_idx]; in ice_ptp_extts_event()
1608 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_event()
1609 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_event()
1647 gpio_pin = pf->ptp.ice_pin_desc[pin_desc_idx].gpio[0]; in ice_ptp_cfg_extts()
1677 for (unsigned int i = 0; i < pf->ptp.info.n_ext_ts; i++) in ice_ptp_cfg_extts()
1678 if ((pf->ptp.extts_rqs[i].flags & in ice_ptp_cfg_extts()
1701 for (unsigned int i = 0; i < pf->ptp.info.n_ext_ts ; i++) in ice_ptp_disable_all_extts()
1702 if (pf->ptp.extts_rqs[i].flags & PTP_ENABLE_FEATURE) in ice_ptp_disable_all_extts()
1703 ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[i], in ice_ptp_disable_all_extts()
1717 for (unsigned int i = 0; i < pf->ptp.info.n_ext_ts ; i++) in ice_ptp_enable_all_extts()
1718 if (pf->ptp.extts_rqs[i].flags & PTP_ENABLE_FEATURE) in ice_ptp_enable_all_extts()
1719 ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[i], in ice_ptp_enable_all_extts()
1817 gpio_pin = pf->ptp.ice_pin_desc[pin_desc_idx].gpio[1]; in ice_ptp_cfg_perout()
1818 prop_delay_ns = pf->ptp.ice_pin_desc[pin_desc_idx].delay[1]; in ice_ptp_cfg_perout()
1827 if (strncmp(pf->ptp.pin_desc[pin_desc_idx].name, "1PPS", 64) == 0 && in ice_ptp_cfg_perout()
1828 period != NSEC_PER_SEC && hw->ptp.phy_model == ICE_PHY_E82X) { in ice_ptp_cfg_perout()
1865 * certain changes to the PTP hardware clock. Use ice_ptp_enable_all_perout to
1870 for (unsigned int i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_perout()
1871 if (pf->ptp.perout_rqs[i].period.sec || in ice_ptp_disable_all_perout()
1872 pf->ptp.perout_rqs[i].period.nsec) in ice_ptp_disable_all_perout()
1873 ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[i], in ice_ptp_disable_all_perout()
1887 for (unsigned int i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_perout()
1888 if (pf->ptp.perout_rqs[i].period.sec || in ice_ptp_enable_all_perout()
1889 pf->ptp.perout_rqs[i].period.nsec) in ice_ptp_enable_all_perout()
1890 ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[i], in ice_ptp_enable_all_perout()
1909 gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[1]; in ice_ptp_disable_shared_pin()
1912 gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[0]; in ice_ptp_disable_shared_pin()
1918 for (unsigned int i = 0; i < pf->ptp.info.n_pins; i++) { in ice_ptp_disable_shared_pin()
1919 struct ptp_pin_desc *pin_desc = &pf->ptp.pin_desc[i]; in ice_ptp_disable_shared_pin()
1927 pf->ptp.ice_pin_desc[i].gpio[1] == gpio_pin) { in ice_ptp_disable_shared_pin()
1928 pf->ptp.perout_rqs[chan].period.sec = 0; in ice_ptp_disable_shared_pin()
1929 pf->ptp.perout_rqs[chan].period.nsec = 0; in ice_ptp_disable_shared_pin()
1934 return ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[chan], in ice_ptp_disable_shared_pin()
1936 } else if (pf->ptp.pin_desc->func == PTP_PF_EXTTS && in ice_ptp_disable_shared_pin()
1937 pf->ptp.ice_pin_desc[i].gpio[0] == gpio_pin) { in ice_ptp_disable_shared_pin()
1938 pf->ptp.extts_rqs[chan].flags &= ~PTP_ENABLE_FEATURE; in ice_ptp_disable_shared_pin()
1943 return ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[chan], in ice_ptp_disable_shared_pin()
1953 * @info: the driver's PTP info structure
1966 pin_desc = &pf->ptp.ice_pin_desc[pin]; in ice_verify_pin()
1988 pf->ptp.pin_desc[pin].func = func; in ice_verify_pin()
1989 pf->ptp.pin_desc[pin].chan = chan; in ice_verify_pin()
1998 * @info: The driver's PTP info structure
2014 &pf->ptp.perout_rqs[rq->perout.index]; in ice_ptp_gpio_enable()
2028 &pf->ptp.extts_rqs[rq->extts.index]; in ice_ptp_gpio_enable()
2044 * @info: the driver's PTP info structure
2066 * @info: the driver's PTP info structure
2111 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
2120 * @info: the driver's PTP info structure
2139 * @info: the driver's PTP info structure
2161 dev_err(dev, "PTP failed to acquire semaphore in adjtime\n"); in ice_ptp_adjtime()
2176 dev_err(dev, "PTP failed to adjust time, err %d\n", err); in ice_ptp_adjtime()
2218 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2272 * @info: the driver's PTP info structure
2275 * Capture a cross timestamp between the ART and the device PTP hardware
2307 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_get_ts_config()
2310 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2326 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ice_ptp_set_timestamp_mode()
2329 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; in ice_ptp_set_timestamp_mode()
2337 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ice_ptp_set_timestamp_mode()
2353 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL; in ice_ptp_set_timestamp_mode()
2377 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_set_ts_config()
2388 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2429 * ice_ptp_setup_pin_cfg - setup PTP pin_config structure
2434 for (unsigned int i = 0; i < pf->ptp.info.n_pins; i++) { in ice_ptp_setup_pin_cfg()
2435 const struct ice_ptp_pin_desc *desc = &pf->ptp.ice_pin_desc[i]; in ice_ptp_setup_pin_cfg()
2436 struct ptp_pin_desc *pin = &pf->ptp.pin_desc[i]; in ice_ptp_setup_pin_cfg()
2449 pf->ptp.info.pin_config = pf->ptp.pin_desc; in ice_ptp_setup_pin_cfg()
2453 * ice_ptp_disable_pins - Disable PTP pins
2461 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_disable_pins()
2463 dev_warn(ice_pf_to_dev(pf), "Failed to configure PTP pin control\n"); in ice_ptp_disable_pins()
2477 * @pins: PTP pins array to update
2523 strscpy(pf->ptp.pin_desc[idx].name, in ice_ptp_parse_sdp_entries()
2525 sizeof(pf->ptp.pin_desc[idx] in ice_ptp_parse_sdp_entries()
2540 pf->ptp.info.n_pins = n_pins; in ice_ptp_parse_sdp_entries()
2548 * Assign functions to the PTP capabilities structure for E82X devices.
2558 pf->ptp.info.getcrosststamp = ice_ptp_getcrosststamp_e82x; in ice_ptp_set_funcs_e82x()
2562 pf->ptp.ice_pin_desc = ice_pin_desc_e825c; in ice_ptp_set_funcs_e82x()
2563 pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e825c); in ice_ptp_set_funcs_e82x()
2565 pf->ptp.ice_pin_desc = ice_pin_desc_e82x; in ice_ptp_set_funcs_e82x()
2566 pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e82x); in ice_ptp_set_funcs_e82x()
2575 * Assign functions to the PTP capabiltiies structure for E810 devices.
2584 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_set_funcs_e810() local
2592 ptp->ice_pin_desc = ice_pin_desc_e810_sma; in ice_ptp_set_funcs_e810()
2593 ptp->info.n_pins = in ice_ptp_set_funcs_e810()
2596 pf->ptp.ice_pin_desc = ice_pin_desc_e810; in ice_ptp_set_funcs_e810()
2597 pf->ptp.info.n_pins = in ice_ptp_set_funcs_e810()
2612 ptp->ice_pin_desc = (const struct ice_ptp_pin_desc *)desc; in ice_ptp_set_funcs_e810()
2615 ptp->info.pin_config = ptp->pin_desc; in ice_ptp_set_funcs_e810()
2628 * ice_ptp_set_caps - Set PTP capabilities
2633 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2656 * ice_ptp_create_clock - Create PTP clock device for userspace
2659 * This function creates a new PTP clock device. It only creates one if we
2670 if (pf->ptp.clock) in ice_ptp_create_clock()
2675 info = &pf->ptp.info; in ice_ptp_create_clock()
2679 pf->ptp.clock = ptp_clock_register(info, dev); in ice_ptp_create_clock()
2680 if (IS_ERR(pf->ptp.clock)) { in ice_ptp_create_clock()
2681 dev_err(ice_pf_to_dev(pf), "Failed to register PTP clock device"); in ice_ptp_create_clock()
2682 return PTR_ERR(pf->ptp.clock); in ice_ptp_create_clock()
2690 * @tx: the PTP Tx timestamp tracker to request from
2737 * ice_ptp_process_ts - Process the PTP Tx timestamps
2745 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_process_ts()
2751 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2757 pf->ptp.tx_interrupt_mode); in ice_ptp_process_ts()
2788 for (i = 0; i < ICE_GET_QUAD_NUM(hw->ptp.num_lports); i++) { in ice_ptp_maybe_trigger_tx_interrupt()
2803 …dev_dbg(dev, "PTP periodic task detected waiting timestamps. Triggering Tx timestamp interrupt now… in ice_ptp_maybe_trigger_tx_interrupt()
2812 struct ice_ptp *ptp = container_of(work, struct ice_ptp, work.work); in ice_ptp_periodic_work() local
2813 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work()
2816 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_periodic_work()
2824 kthread_queue_delayed_work(ptp->kworker, &ptp->work, in ice_ptp_periodic_work()
2829 * ice_ptp_prepare_for_reset - Prepare PTP for reset
2835 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset() local
2838 if (ptp->state != ICE_PTP_READY) in ice_ptp_prepare_for_reset()
2841 ptp->state = ICE_PTP_RESETTING; in ice_ptp_prepare_for_reset()
2846 kthread_cancel_delayed_work_sync(&ptp->work); in ice_ptp_prepare_for_reset()
2851 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2862 ptp->reset_time = ktime_get_real_ns(); in ice_ptp_prepare_for_reset()
2866 * ice_ptp_rebuild_owner - Initialize PTP clock owner after reset
2870 * PTP clock owner instance should perform.
2874 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_rebuild_owner() local
2899 if (ptp->cached_phc_time) { in ice_ptp_rebuild_owner()
2900 time_diff = ktime_get_real_ns() - ptp->reset_time; in ice_ptp_rebuild_owner()
2901 ts = ns_to_timespec64(ptp->cached_phc_time + time_diff); in ice_ptp_rebuild_owner()
2938 * ice_ptp_rebuild - Initialize PTP hardware clock support after reset
2944 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_rebuild() local
2947 if (ptp->state == ICE_PTP_READY) { in ice_ptp_rebuild()
2949 } else if (ptp->state != ICE_PTP_RESETTING) { in ice_ptp_rebuild()
2951 dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); in ice_ptp_rebuild()
2961 ptp->state = ICE_PTP_READY; in ice_ptp_rebuild()
2964 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_rebuild()
2966 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_rebuild()
2970 ptp->state = ICE_PTP_ERROR; in ice_ptp_rebuild()
2971 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_rebuild()
2993 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_setup_pf() local
2998 INIT_LIST_HEAD(&ptp->port.list_node); in ice_ptp_setup_pf()
3001 list_add(&ptp->port.list_node, in ice_ptp_setup_pf()
3010 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_cleanup_pf() local
3014 list_del(&ptp->port.list_node); in ice_ptp_cleanup_pf()
3020 * ice_ptp_clock_index - Get the PTP clock index for this device
3023 * Returns: the PTP clock index associated with this PF, or -1 if no PTP clock
3042 * Setup and initialize a PTP clock device that represents the device hardware
3091 pf->ptp.clock = NULL; in ice_ptp_init_owner()
3101 * ice_ptp_init_work - Initialize PTP work threads
3103 * @ptp: PF PTP structure
3105 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
3110 kthread_init_delayed_work(&ptp->work, ice_ptp_periodic_work); in ice_ptp_init_work()
3113 * connected to the PTP hardware clock. in ice_ptp_init_work()
3115 kworker = kthread_run_worker(0, "ice-ptp-%s", in ice_ptp_init_work()
3120 ptp->kworker = kworker; in ice_ptp_init_work()
3123 kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); in ice_ptp_init_work()
3129 * ice_ptp_init_port - Initialize PTP port structure
3131 * @ptp_port: PTP port structure
3173 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_ALL; in ice_ptp_init_tx_interrupt_mode()
3175 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_NONE; in ice_ptp_init_tx_interrupt_mode()
3179 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_SELF; in ice_ptp_init_tx_interrupt_mode()
3184 * ice_ptp_init - Initialize PTP hardware clock support
3187 * Set up the device for interacting with the PTP hardware clock for all
3197 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init() local
3201 ptp->state = ICE_PTP_INITIALIZING; in ice_ptp_init()
3209 ptp->port.port_num = (u8)lane_num; in ice_ptp_init()
3215 * configure the PTP clock device to represent it. in ice_ptp_init()
3230 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
3240 ptp->state = ICE_PTP_READY; in ice_ptp_init()
3242 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
3246 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
3250 /* If we registered a PTP clock, release it */ in ice_ptp_init()
3251 if (pf->ptp.clock) { in ice_ptp_init()
3252 ptp_clock_unregister(ptp->clock); in ice_ptp_init()
3253 pf->ptp.clock = NULL; in ice_ptp_init()
3255 ptp->state = ICE_PTP_ERROR; in ice_ptp_init()
3256 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
3268 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_release()
3271 pf->ptp.state = ICE_PTP_UNINIT; in ice_ptp_release()
3278 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
3282 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
3284 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
3285 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
3286 if (pf->ptp.kworker) { in ice_ptp_release()
3287 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
3288 pf->ptp.kworker = NULL; in ice_ptp_release()
3291 if (!pf->ptp.clock) in ice_ptp_release()
3297 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
3298 pf->ptp.clock = NULL; in ice_ptp_release()
3300 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()