Lines Matching full:pf
60 static struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf) in ice_get_ctrl_pf() argument
62 return !pf->adapter ? NULL : pf->adapter->ctrl_pf; in ice_get_ctrl_pf()
65 static struct ice_ptp *ice_get_ctrl_ptp(struct ice_pf *pf) in ice_get_ctrl_ptp() argument
67 struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf); in ice_get_ctrl_ptp()
74 * @pf: Board private structure
80 static int ice_ptp_find_pin_idx(struct ice_pf *pf, enum ptp_pin_function func, in ice_ptp_find_pin_idx() argument
83 const struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_find_pin_idx()
97 * @pf: Board private structure
101 static void ice_ptp_update_sma_data(struct ice_pf *pf, unsigned int sma_pins[], in ice_ptp_update_sma_data() argument
147 dev_dbg(ice_pf_to_dev(pf), "%s, %s\n", state1, state2); in ice_ptp_update_sma_data()
152 * @pf: Board private structure
156 static int ice_ptp_set_sma_cfg(struct ice_pf *pf) in ice_ptp_set_sma_cfg() argument
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()
165 err = ice_read_sma_ctrl(&pf->hw, &data); in ice_ptp_set_sma_cfg()
170 for (int i = 0; i < pf->ptp.info.n_pins; i++) in ice_ptp_set_sma_cfg()
186 ice_ptp_update_sma_data(pf, sma_pins, &data); in ice_ptp_set_sma_cfg()
187 return ice_write_sma_ctrl(&pf->hw, data); in ice_ptp_set_sma_cfg()
192 * @pf: Board private structure
197 static void ice_ptp_cfg_tx_interrupt(struct ice_pf *pf) in ice_ptp_cfg_tx_interrupt() argument
199 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_tx_interrupt()
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()
231 * @pf: The PF pointer to search in
234 static void ice_set_rx_tstamp(struct ice_pf *pf, bool on) in ice_set_rx_tstamp() argument
239 vsi = ice_get_main_vsi(pf); in ice_set_rx_tstamp()
253 * @pf: Board private structure
259 static void ice_ptp_disable_timestamp_mode(struct ice_pf *pf) in ice_ptp_disable_timestamp_mode() argument
261 struct ice_hw *hw = &pf->hw; in ice_ptp_disable_timestamp_mode()
268 ice_set_rx_tstamp(pf, false); in ice_ptp_disable_timestamp_mode()
273 * @pf: Board private structure
278 void ice_ptp_restore_timestamp_mode(struct ice_pf *pf) in ice_ptp_restore_timestamp_mode() argument
280 struct ice_hw *hw = &pf->hw; in ice_ptp_restore_timestamp_mode()
283 ice_ptp_cfg_tx_interrupt(pf); in ice_ptp_restore_timestamp_mode()
285 enable_rx = pf->ptp.tstamp_config.rx_filter == HWTSTAMP_FILTER_ALL; in ice_ptp_restore_timestamp_mode()
286 ice_set_rx_tstamp(pf, enable_rx); in ice_ptp_restore_timestamp_mode()
297 * @pf: Board private structure
302 ice_ptp_read_src_clk_reg(struct ice_pf *pf, struct ptp_system_timestamp *sts) in ice_ptp_read_src_clk_reg() argument
304 struct ice_hw *hw = &pf->hw; in ice_ptp_read_src_clk_reg()
309 guard(spinlock)(&pf->adapter->ptp_gltsyn_time_lock); in ice_ptp_read_src_clk_reg()
403 * @pf: Board private structure
427 static u64 ice_ptp_extend_40b_ts(struct ice_pf *pf, u64 in_tstamp) in ice_ptp_extend_40b_ts() argument
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()
469 struct ice_pf *pf; in ice_ptp_req_tx_single_tstamp() local
475 pf = ptp_port_to_pf(ptp_port); in ice_ptp_req_tx_single_tstamp()
480 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_req_tx_single_tstamp()
492 /* Write TS index to read to the PF register so the FW can read it */ in ice_ptp_req_tx_single_tstamp()
493 wr32(&pf->hw, PF_SB_ATQBAL, in ice_ptp_req_tx_single_tstamp()
511 struct ice_pf *pf; in ice_ptp_complete_tx_single_tstamp() local
518 pf = ptp_port_to_pf(ptp_port); in ice_ptp_complete_tx_single_tstamp()
522 val = rd32(&pf->hw, PF_SB_ATQBAL); in ice_ptp_complete_tx_single_tstamp()
526 dev_err(ice_pf_to_dev(pf), "Failed to get the Tx tstamp - FW not ready"); in ice_ptp_complete_tx_single_tstamp()
535 raw_tstamp |= (u64)rd32(&pf->hw, PF_SB_ATQBAH); in ice_ptp_complete_tx_single_tstamp()
559 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_complete_tx_single_tstamp()
621 struct ice_pf *pf; in ice_ptp_process_tx_tstamp() local
629 pf = ptp_port_to_pf(ptp_port); in ice_ptp_process_tx_tstamp()
630 hw = &pf->hw; in ice_ptp_process_tx_tstamp()
654 pf->ptp.tx_hwtstamp_timeouts++; in ice_ptp_process_tx_tstamp()
717 tstamp = ice_ptp_extend_40b_ts(pf, raw_tstamp); in ice_ptp_process_tx_tstamp()
730 * @pf: Board private structure
732 static enum ice_tx_tstamp_work ice_ptp_tx_tstamp_owner(struct ice_pf *pf) in ice_ptp_tx_tstamp_owner() argument
737 mutex_lock(&pf->adapter->ports.lock); in ice_ptp_tx_tstamp_owner()
738 list_for_each_entry(port, &pf->adapter->ports.ports, list_node) { in ice_ptp_tx_tstamp_owner()
746 mutex_unlock(&pf->adapter->ports.lock); in ice_ptp_tx_tstamp_owner()
748 for (i = 0; i < ICE_GET_QUAD_NUM(pf->hw.ptp.num_lports); i++) { in ice_ptp_tx_tstamp_owner()
753 err = ice_get_phy_tx_tstamp_ready(&pf->hw, i, &tstamp_ready); in ice_ptp_tx_tstamp_owner()
830 * @pf: Board private structure
836 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
838 struct ice_hw *hw = &pf->hw; in ice_ptp_flush_tx_tracker()
846 dev_dbg(ice_pf_to_dev(pf), "Failed to get the Tx tstamp ready bitmap for block %u, err %d\n", in ice_ptp_flush_tx_tracker()
871 pf->ptp.tx_hwtstamp_flushed++; in ice_ptp_flush_tx_tracker()
901 * @pf: Board private structure
907 ice_ptp_flush_all_tx_tracker(struct ice_pf *pf) in ice_ptp_flush_all_tx_tracker() argument
911 list_for_each_entry(port, &pf->adapter->ports.ports, list_node) in ice_ptp_flush_all_tx_tracker()
917 * @pf: Board private structure
923 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
932 synchronize_irq(pf->oicr_irq.virq); in ice_ptp_release_tx_tracker()
934 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
950 * @pf: Board private structure
959 static int ice_ptp_init_tx_eth56g(struct ice_pf *pf, struct ice_ptp_tx *tx, in ice_ptp_init_tx_eth56g() argument
972 * @pf: Board private structure
982 ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) in ice_ptp_init_tx_e82x() argument
994 * @pf: Board private structure
997 * Initialize the Tx timestamp tracker for this PF. For E810 devices, each
1001 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
1003 tx->block = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
1017 * @pf: Board specific private structure
1019 * This function updates the system time values which are cached in the PF
1025 * Note that the cached copy in the PF PTP structure is always updated, even
1030 * * -EAGAIN - PF was busy, need to reschedule the update
1032 static int ice_ptp_update_cached_phctime(struct ice_pf *pf) in ice_ptp_update_cached_phctime() argument
1034 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_update_cached_phctime()
1039 update_before = pf->ptp.cached_phc_jiffies + msecs_to_jiffies(2000); in ice_ptp_update_cached_phctime()
1040 if (pf->ptp.cached_phc_time && in ice_ptp_update_cached_phctime()
1042 unsigned long time_taken = jiffies - pf->ptp.cached_phc_jiffies; in ice_ptp_update_cached_phctime()
1046 pf->ptp.late_cached_phc_updates++; in ice_ptp_update_cached_phctime()
1050 systime = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_update_cached_phctime()
1052 /* Update the cached PHC time stored in the PF structure */ in ice_ptp_update_cached_phctime()
1053 WRITE_ONCE(pf->ptp.cached_phc_time, systime); in ice_ptp_update_cached_phctime()
1054 WRITE_ONCE(pf->ptp.cached_phc_jiffies, jiffies); in ice_ptp_update_cached_phctime()
1056 if (test_and_set_bit(ICE_CFG_BUSY, pf->state)) in ice_ptp_update_cached_phctime()
1059 ice_for_each_vsi(pf, i) { in ice_ptp_update_cached_phctime()
1060 struct ice_vsi *vsi = pf->vsi[i]; in ice_ptp_update_cached_phctime()
1075 clear_bit(ICE_CFG_BUSY, pf->state); in ice_ptp_update_cached_phctime()
1082 * @pf: Board specific private structure
1086 * timestamps as stale and updates the cached PHC time for both the PF and Rx
1093 static void ice_ptp_reset_cached_phctime(struct ice_pf *pf) in ice_ptp_reset_cached_phctime() argument
1095 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_reset_cached_phctime()
1101 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_reset_cached_phctime()
1111 kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work, in ice_ptp_reset_cached_phctime()
1120 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1125 * @pf: Board private structure
1130 static int ice_ptp_write_init(struct ice_pf *pf, struct timespec64 *ts) in ice_ptp_write_init() argument
1133 struct ice_hw *hw = &pf->hw; in ice_ptp_write_init()
1140 * @pf: Board private structure
1146 static int ice_ptp_write_adj(struct ice_pf *pf, s32 adj) in ice_ptp_write_adj() argument
1148 struct ice_hw *hw = &pf->hw; in ice_ptp_write_adj()
1155 * @pf: Board private structure
1162 static u64 ice_base_incval(struct ice_pf *pf) in ice_base_incval() argument
1164 struct ice_hw *hw = &pf->hw; in ice_base_incval()
1169 dev_dbg(ice_pf_to_dev(pf), "PTP: using base increment value of 0x%016llx\n", in ice_base_incval()
1183 struct ice_pf *pf; in ice_ptp_check_tx_fifo() local
1188 pf = ptp_port_to_pf(port); in ice_ptp_check_tx_fifo()
1189 hw = &pf->hw; in ice_ptp_check_tx_fifo()
1203 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1220 dev_dbg(ice_pf_to_dev(pf), "Try %d, port %d FIFO not empty\n", in ice_ptp_check_tx_fifo()
1224 dev_dbg(ice_pf_to_dev(pf), in ice_ptp_check_tx_fifo()
1253 struct ice_pf *pf; in ice_ptp_wait_for_offsets() local
1259 pf = ptp_port_to_pf(port); in ice_ptp_wait_for_offsets()
1260 hw = &pf->hw; in ice_ptp_wait_for_offsets()
1262 if (ice_is_reset_in_progress(pf->state)) { in ice_ptp_wait_for_offsets()
1264 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1276 kthread_queue_delayed_work(pf->ptp.kworker, in ice_ptp_wait_for_offsets()
1290 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_stop() local
1292 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_stop()
1313 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d down, err %d\n", in ice_ptp_port_phy_stop()
1332 struct ice_pf *pf = ptp_port_to_pf(ptp_port); in ice_ptp_port_phy_restart() local
1334 struct ice_hw *hw = &pf->hw; in ice_ptp_port_phy_restart()
1372 kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, in ice_ptp_port_phy_restart()
1380 dev_err(ice_pf_to_dev(pf), "PTP failed to set PHY port %d up, err %d\n", in ice_ptp_port_phy_restart()
1390 * @pf: Board private structure
1394 void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) in ice_ptp_link_change() argument
1397 struct ice_hw *hw = &pf->hw; in ice_ptp_link_change()
1399 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_link_change()
1405 ptp_port = &pf->ptp.port; in ice_ptp_link_change()
1415 if (pf->hw.reset_ongoing) in ice_ptp_link_change()
1426 dev_warn(ice_pf_to_dev(pf), "%s: Unknown PHY type\n", __func__); in ice_ptp_link_change()
1432 * @pf: PF private structure
1443 static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold) in ice_ptp_cfg_phy_interrupt() argument
1445 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_cfg_phy_interrupt()
1446 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_phy_interrupt()
1496 * @pf: Board private structure
1498 static void ice_ptp_reset_phy_timestamping(struct ice_pf *pf) in ice_ptp_reset_phy_timestamping() argument
1500 ice_ptp_port_phy_restart(&pf->ptp.port); in ice_ptp_reset_phy_timestamping()
1505 * @pf: Board private structure
1507 static void ice_ptp_restart_all_phy(struct ice_pf *pf) in ice_ptp_restart_all_phy() argument
1511 list_for_each(entry, &pf->adapter->ports.ports) { in ice_ptp_restart_all_phy()
1531 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjfine() local
1532 struct ice_hw *hw = &pf->hw; in ice_ptp_adjfine()
1536 incval = adjust_by_scaled_ppm(ice_base_incval(pf), scaled_ppm); in ice_ptp_adjfine()
1539 dev_err(ice_pf_to_dev(pf), "PTP failed to set incval, err %d\n", in ice_ptp_adjfine()
1549 * @pf: Board private structure
1551 void ice_ptp_extts_event(struct ice_pf *pf) in ice_ptp_extts_event() argument
1554 struct ice_hw *hw = &pf->hw; in ice_ptp_extts_event()
1559 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_extts_event()
1570 if (pf->ptp.ext_ts_irq & (1 << chan)) { in ice_ptp_extts_event()
1578 ptp_clock_event(pf->ptp.clock, &event); in ice_ptp_extts_event()
1579 pf->ptp.ext_ts_irq &= ~(1 << chan); in ice_ptp_extts_event()
1586 * @pf: Board private structure
1594 static int ice_ptp_cfg_extts(struct ice_pf *pf, struct ptp_extts_request *rq, in ice_ptp_cfg_extts() argument
1598 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_extts()
1614 pin_desc_idx = ice_ptp_find_pin_idx(pf, PTP_PF_EXTTS, chan); in ice_ptp_cfg_extts()
1618 gpio_pin = pf->ptp.ice_pin_desc[pin_desc_idx].gpio[0]; in ice_ptp_cfg_extts()
1648 for (unsigned int i = 0; i < pf->ptp.info.n_ext_ts; i++) in ice_ptp_cfg_extts()
1649 if ((pf->ptp.extts_rqs[i].flags & in ice_ptp_cfg_extts()
1668 * @pf: Board private structure
1670 static void ice_ptp_disable_all_extts(struct ice_pf *pf) in ice_ptp_disable_all_extts() argument
1672 for (unsigned int i = 0; i < pf->ptp.info.n_ext_ts ; i++) in ice_ptp_disable_all_extts()
1673 if (pf->ptp.extts_rqs[i].flags & PTP_ENABLE_FEATURE) in ice_ptp_disable_all_extts()
1674 ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[i], in ice_ptp_disable_all_extts()
1677 synchronize_irq(pf->oicr_irq.virq); in ice_ptp_disable_all_extts()
1682 * @pf: Board private structure
1686 static void ice_ptp_enable_all_extts(struct ice_pf *pf) in ice_ptp_enable_all_extts() argument
1688 for (unsigned int i = 0; i < pf->ptp.info.n_ext_ts ; i++) in ice_ptp_enable_all_extts()
1689 if (pf->ptp.extts_rqs[i].flags & PTP_ENABLE_FEATURE) in ice_ptp_enable_all_extts()
1690 ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[i], in ice_ptp_enable_all_extts()
1763 * @pf: Board private structure
1772 static int ice_ptp_cfg_perout(struct ice_pf *pf, struct ptp_perout_request *rq, in ice_ptp_cfg_perout() argument
1776 struct ice_hw *hw = &pf->hw; in ice_ptp_cfg_perout()
1783 pin_desc_idx = ice_ptp_find_pin_idx(pf, PTP_PF_PEROUT, rq->index); in ice_ptp_cfg_perout()
1787 gpio_pin = pf->ptp.ice_pin_desc[pin_desc_idx].gpio[1]; in ice_ptp_cfg_perout()
1796 if (strncmp(pf->ptp.pin_desc[pin_desc_idx].name, "1PPS", 64) == 0 && in ice_ptp_cfg_perout()
1798 dev_err(ice_pf_to_dev(pf), "1PPS pin supports only 1 s period\n"); in ice_ptp_cfg_perout()
1803 dev_err(ice_pf_to_dev(pf), "CLK Period must be an even value\n"); in ice_ptp_cfg_perout()
1818 clk = ice_ptp_read_src_clk_reg(pf, NULL); in ice_ptp_cfg_perout()
1830 * @pf: Board private structure
1836 static void ice_ptp_disable_all_perout(struct ice_pf *pf) in ice_ptp_disable_all_perout() argument
1838 for (unsigned int i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_disable_all_perout()
1839 if (pf->ptp.perout_rqs[i].period.sec || in ice_ptp_disable_all_perout()
1840 pf->ptp.perout_rqs[i].period.nsec) in ice_ptp_disable_all_perout()
1841 ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[i], in ice_ptp_disable_all_perout()
1847 * @pf: Board private structure
1853 static void ice_ptp_enable_all_perout(struct ice_pf *pf) in ice_ptp_enable_all_perout() argument
1855 for (unsigned int i = 0; i < pf->ptp.info.n_per_out; i++) in ice_ptp_enable_all_perout()
1856 if (pf->ptp.perout_rqs[i].period.sec || in ice_ptp_enable_all_perout()
1857 pf->ptp.perout_rqs[i].period.nsec) in ice_ptp_enable_all_perout()
1858 ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[i], in ice_ptp_enable_all_perout()
1864 * @pf: Board private structure
1870 static int ice_ptp_disable_shared_pin(struct ice_pf *pf, unsigned int pin, in ice_ptp_disable_shared_pin() argument
1877 gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[1]; in ice_ptp_disable_shared_pin()
1880 gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[0]; in ice_ptp_disable_shared_pin()
1886 for (unsigned int i = 0; i < pf->ptp.info.n_pins; i++) { in ice_ptp_disable_shared_pin()
1887 struct ptp_pin_desc *pin_desc = &pf->ptp.pin_desc[i]; in ice_ptp_disable_shared_pin()
1895 pf->ptp.ice_pin_desc[i].gpio[1] == gpio_pin) { in ice_ptp_disable_shared_pin()
1896 pf->ptp.perout_rqs[chan].period.sec = 0; in ice_ptp_disable_shared_pin()
1897 pf->ptp.perout_rqs[chan].period.nsec = 0; in ice_ptp_disable_shared_pin()
1900 dev_dbg(ice_pf_to_dev(pf), "Disabling pin %u with shared output GPIO pin %u\n", in ice_ptp_disable_shared_pin()
1902 return ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[chan], in ice_ptp_disable_shared_pin()
1904 } else if (pf->ptp.pin_desc->func == PTP_PF_EXTTS && in ice_ptp_disable_shared_pin()
1905 pf->ptp.ice_pin_desc[i].gpio[0] == gpio_pin) { in ice_ptp_disable_shared_pin()
1906 pf->ptp.extts_rqs[chan].flags &= ~PTP_ENABLE_FEATURE; in ice_ptp_disable_shared_pin()
1909 dev_dbg(ice_pf_to_dev(pf), "Disabling pin %u with shared input GPIO pin %u\n", in ice_ptp_disable_shared_pin()
1911 return ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[chan], in ice_ptp_disable_shared_pin()
1931 struct ice_pf *pf = ptp_info_to_pf(info); in ice_verify_pin() local
1934 pin_desc = &pf->ptp.ice_pin_desc[pin]; in ice_verify_pin()
1954 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) { in ice_verify_pin()
1955 ice_ptp_disable_shared_pin(pf, pin, func); in ice_verify_pin()
1956 pf->ptp.pin_desc[pin].func = func; in ice_verify_pin()
1957 pf->ptp.pin_desc[pin].chan = chan; in ice_verify_pin()
1958 return ice_ptp_set_sma_cfg(pf); in ice_verify_pin()
1975 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gpio_enable() local
1982 &pf->ptp.perout_rqs[rq->perout.index]; in ice_ptp_gpio_enable()
1984 err = ice_ptp_cfg_perout(pf, &rq->perout, on); in ice_ptp_gpio_enable()
1996 &pf->ptp.extts_rqs[rq->extts.index]; in ice_ptp_gpio_enable()
1998 err = ice_ptp_cfg_extts(pf, &rq->extts, on); in ice_ptp_gpio_enable()
2024 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_gettimex64() local
2027 time_ns = ice_ptp_read_src_clk_reg(pf, sts); in ice_ptp_gettimex64()
2043 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_settime64() local
2045 struct ice_hw *hw = &pf->hw; in ice_ptp_settime64()
2054 dev_warn(ice_pf_to_dev(pf), "Failed to mark timestamps as invalid before settime\n"); in ice_ptp_settime64()
2063 ice_ptp_disable_all_perout(pf); in ice_ptp_settime64()
2065 err = ice_ptp_write_init(pf, &ts64); in ice_ptp_settime64()
2069 ice_ptp_reset_cached_phctime(pf); in ice_ptp_settime64()
2072 ice_ptp_enable_all_perout(pf); in ice_ptp_settime64()
2076 ice_ptp_restart_all_phy(pf); in ice_ptp_settime64()
2079 dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err); in ice_ptp_settime64()
2112 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_adjtime() local
2113 struct ice_hw *hw = &pf->hw; in ice_ptp_adjtime()
2117 dev = ice_pf_to_dev(pf); in ice_ptp_adjtime()
2134 ice_ptp_disable_all_perout(pf); in ice_ptp_adjtime()
2136 err = ice_ptp_write_adj(pf, delta); in ice_ptp_adjtime()
2139 ice_ptp_enable_all_perout(pf); in ice_ptp_adjtime()
2148 ice_ptp_reset_cached_phctime(pf); in ice_ptp_adjtime()
2168 struct ice_pf *pf = (struct ice_pf *)ctx; in ice_ptp_get_syncdevicetime() local
2169 struct ice_hw *hw = &pf->hw; in ice_ptp_get_syncdevicetime()
2186 dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n"); in ice_ptp_get_syncdevicetime()
2257 struct ice_pf *pf = ptp_info_to_pf(info); in ice_ptp_getcrosststamp_e82x() local
2260 pf, NULL, cts); in ice_ptp_getcrosststamp_e82x()
2266 * @pf: Board private structure
2271 int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_get_ts_config() argument
2275 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_get_ts_config()
2278 config = &pf->ptp.tstamp_config; in ice_ptp_get_ts_config()
2286 * @pf: Board private structure
2290 ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) in ice_ptp_set_timestamp_mode() argument
2294 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ice_ptp_set_timestamp_mode()
2297 pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; in ice_ptp_set_timestamp_mode()
2305 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ice_ptp_set_timestamp_mode()
2321 pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL; in ice_ptp_set_timestamp_mode()
2328 ice_ptp_restore_timestamp_mode(pf); in ice_ptp_set_timestamp_mode()
2335 * @pf: Board private structure
2340 int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) in ice_ptp_set_ts_config() argument
2345 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_set_ts_config()
2351 err = ice_ptp_set_timestamp_mode(pf, &config); in ice_ptp_set_ts_config()
2356 config = pf->ptp.tstamp_config; in ice_ptp_set_ts_config()
2385 * PHC value, rather than accessing the PF. This also allows us to in ice_ptp_get_rx_hwts()
2398 * @pf: Board private structure
2400 static void ice_ptp_setup_pin_cfg(struct ice_pf *pf) in ice_ptp_setup_pin_cfg() argument
2402 for (unsigned int i = 0; i < pf->ptp.info.n_pins; i++) { in ice_ptp_setup_pin_cfg()
2403 const struct ice_ptp_pin_desc *desc = &pf->ptp.ice_pin_desc[i]; in ice_ptp_setup_pin_cfg()
2404 struct ptp_pin_desc *pin = &pf->ptp.pin_desc[i]; in ice_ptp_setup_pin_cfg()
2407 if (!ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) in ice_ptp_setup_pin_cfg()
2417 pf->ptp.info.pin_config = pf->ptp.pin_desc; in ice_ptp_setup_pin_cfg()
2422 * @pf: pointer to the PF structure
2427 static void ice_ptp_disable_pins(struct ice_pf *pf) in ice_ptp_disable_pins() argument
2429 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_disable_pins()
2431 dev_warn(ice_pf_to_dev(pf), "Failed to configure PTP pin control\n"); in ice_ptp_disable_pins()
2442 * @pf: pointer to the PF structure
2449 static int ice_ptp_parse_sdp_entries(struct ice_pf *pf, __le16 *entries, in ice_ptp_parse_sdp_entries() argument
2491 strscpy(pf->ptp.pin_desc[idx].name, in ice_ptp_parse_sdp_entries()
2493 sizeof(pf->ptp.pin_desc[idx] in ice_ptp_parse_sdp_entries()
2503 dev_dbg(ice_pf_to_dev(pf), in ice_ptp_parse_sdp_entries()
2508 pf->ptp.info.n_pins = n_pins; in ice_ptp_parse_sdp_entries()
2514 * @pf: Board private structure
2521 static void ice_ptp_set_funcs_e82x(struct ice_pf *pf) in ice_ptp_set_funcs_e82x() argument
2526 pf->ptp.info.getcrosststamp = ice_ptp_getcrosststamp_e82x; in ice_ptp_set_funcs_e82x()
2529 if (ice_is_e825c(&pf->hw)) { in ice_ptp_set_funcs_e82x()
2530 pf->ptp.ice_pin_desc = ice_pin_desc_e825c; in ice_ptp_set_funcs_e82x()
2531 pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e825c); in ice_ptp_set_funcs_e82x()
2533 pf->ptp.ice_pin_desc = ice_pin_desc_e82x; in ice_ptp_set_funcs_e82x()
2534 pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e82x); in ice_ptp_set_funcs_e82x()
2536 ice_ptp_setup_pin_cfg(pf); in ice_ptp_set_funcs_e82x()
2541 * @pf: Board private structure
2548 static void ice_ptp_set_funcs_e810(struct ice_pf *pf) in ice_ptp_set_funcs_e810() argument
2552 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_set_funcs_e810()
2556 err = ice_ptp_read_sdp_ac(&pf->hw, entries, &num_entries); in ice_ptp_set_funcs_e810()
2559 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) { in ice_ptp_set_funcs_e810()
2564 pf->ptp.ice_pin_desc = ice_pin_desc_e810; in ice_ptp_set_funcs_e810()
2565 pf->ptp.info.n_pins = in ice_ptp_set_funcs_e810()
2570 desc = devm_kcalloc(ice_pf_to_dev(pf), ICE_N_PINS_MAX, in ice_ptp_set_funcs_e810()
2576 err = ice_ptp_parse_sdp_entries(pf, entries, num_entries, desc); in ice_ptp_set_funcs_e810()
2584 ice_ptp_setup_pin_cfg(pf); in ice_ptp_set_funcs_e810()
2586 if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) in ice_ptp_set_funcs_e810()
2587 err = ice_ptp_set_sma_cfg(pf); in ice_ptp_set_funcs_e810()
2590 devm_kfree(ice_pf_to_dev(pf), desc); in ice_ptp_set_funcs_e810()
2591 ice_ptp_disable_pins(pf); in ice_ptp_set_funcs_e810()
2597 * @pf: Board private structure
2599 static void ice_ptp_set_caps(struct ice_pf *pf) in ice_ptp_set_caps() argument
2601 struct ptp_clock_info *info = &pf->ptp.info; in ice_ptp_set_caps()
2602 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_set_caps()
2617 if (ice_is_e810(&pf->hw)) in ice_ptp_set_caps()
2618 ice_ptp_set_funcs_e810(pf); in ice_ptp_set_caps()
2620 ice_ptp_set_funcs_e82x(pf); in ice_ptp_set_caps()
2625 * @pf: Board private structure
2632 static long ice_ptp_create_clock(struct ice_pf *pf) in ice_ptp_create_clock() argument
2638 if (pf->ptp.clock) in ice_ptp_create_clock()
2641 ice_ptp_set_caps(pf); in ice_ptp_create_clock()
2643 info = &pf->ptp.info; in ice_ptp_create_clock()
2644 dev = ice_pf_to_dev(pf); in ice_ptp_create_clock()
2647 pf->ptp.clock = ptp_clock_register(info, dev); in ice_ptp_create_clock()
2648 if (IS_ERR(pf->ptp.clock)) { in ice_ptp_create_clock()
2649 dev_err(ice_pf_to_dev(pf), "Failed to register PTP clock device"); in ice_ptp_create_clock()
2650 return PTR_ERR(pf->ptp.clock); in ice_ptp_create_clock()
2706 * @pf: Board private structure
2711 enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf) in ice_ptp_process_ts() argument
2713 switch (pf->ptp.tx_interrupt_mode) { in ice_ptp_process_ts()
2719 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2722 return ice_ptp_tx_tstamp_owner(pf); in ice_ptp_process_ts()
2725 pf->ptp.tx_interrupt_mode); in ice_ptp_process_ts()
2732 * @pf: Board private structure
2743 static void ice_ptp_maybe_trigger_tx_interrupt(struct ice_pf *pf) in ice_ptp_maybe_trigger_tx_interrupt() argument
2745 struct device *dev = ice_pf_to_dev(pf); in ice_ptp_maybe_trigger_tx_interrupt()
2746 struct ice_hw *hw = &pf->hw; in ice_ptp_maybe_trigger_tx_interrupt()
2753 if (!ice_pf_src_tmr_owned(pf)) in ice_ptp_maybe_trigger_tx_interrupt()
2760 err = ice_get_phy_tx_tstamp_ready(&pf->hw, i, &tstamp_ready); in ice_ptp_maybe_trigger_tx_interrupt()
2781 struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); in ice_ptp_periodic_work() local
2784 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_periodic_work()
2787 err = ice_ptp_update_cached_phctime(pf); in ice_ptp_periodic_work()
2789 ice_ptp_maybe_trigger_tx_interrupt(pf); in ice_ptp_periodic_work()
2798 * @pf: Board private structure
2801 void ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) in ice_ptp_prepare_for_reset() argument
2803 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_prepare_for_reset()
2812 ice_ptp_disable_timestamp_mode(pf); in ice_ptp_prepare_for_reset()
2819 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
2822 ice_ptp_disable_all_perout(pf); in ice_ptp_prepare_for_reset()
2824 src_tmr = ice_get_ptp_src_clock_index(&pf->hw); in ice_ptp_prepare_for_reset()
2827 wr32(&pf->hw, GLTSYN_ENA(src_tmr), (u32)~GLTSYN_ENA_TSYN_ENA_M); in ice_ptp_prepare_for_reset()
2835 * @pf: Board private structure
2840 static int ice_ptp_rebuild_owner(struct ice_pf *pf) in ice_ptp_rebuild_owner() argument
2842 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_rebuild_owner()
2843 struct ice_hw *hw = &pf->hw; in ice_ptp_rebuild_owner()
2859 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_rebuild_owner()
2873 err = ice_ptp_write_init(pf, &ts); in ice_ptp_rebuild_owner()
2883 ice_ptp_flush_all_tx_tracker(pf); in ice_ptp_rebuild_owner()
2887 err = ice_ptp_cfg_phy_interrupt(pf, true, 1); in ice_ptp_rebuild_owner()
2891 ice_ptp_restart_all_phy(pf); in ice_ptp_rebuild_owner()
2895 ice_ptp_enable_all_perout(pf); in ice_ptp_rebuild_owner()
2896 ice_ptp_enable_all_extts(pf); in ice_ptp_rebuild_owner()
2907 * @pf: Board private structure
2910 void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) in ice_ptp_rebuild() argument
2912 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_rebuild()
2916 ice_ptp_prepare_for_reset(pf, reset_type); in ice_ptp_rebuild()
2919 dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); in ice_ptp_rebuild()
2923 if (ice_pf_src_tmr_owned(pf) && reset_type != ICE_RESET_PFR) { in ice_ptp_rebuild()
2924 err = ice_ptp_rebuild_owner(pf); in ice_ptp_rebuild()
2934 dev_info(ice_pf_to_dev(pf), "PTP reset successful\n"); in ice_ptp_rebuild()
2939 dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); in ice_ptp_rebuild()
2948 static int ice_ptp_setup_adapter(struct ice_pf *pf) in ice_ptp_setup_adapter() argument
2950 if (!ice_pf_src_tmr_owned(pf) || !ice_is_primary(&pf->hw)) in ice_ptp_setup_adapter()
2953 pf->adapter->ctrl_pf = pf; in ice_ptp_setup_adapter()
2958 static int ice_ptp_setup_pf(struct ice_pf *pf) in ice_ptp_setup_pf() argument
2960 struct ice_ptp *ctrl_ptp = ice_get_ctrl_ptp(pf); in ice_ptp_setup_pf()
2961 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_setup_pf()
2963 if (WARN_ON(!ctrl_ptp) || ice_get_phy_model(&pf->hw) == ICE_PHY_UNSUP) in ice_ptp_setup_pf()
2967 mutex_lock(&pf->adapter->ports.lock); in ice_ptp_setup_pf()
2970 &pf->adapter->ports.ports); in ice_ptp_setup_pf()
2971 mutex_unlock(&pf->adapter->ports.lock); in ice_ptp_setup_pf()
2976 static void ice_ptp_cleanup_pf(struct ice_pf *pf) in ice_ptp_cleanup_pf() argument
2978 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_cleanup_pf()
2980 if (ice_get_phy_model(&pf->hw) != ICE_PHY_UNSUP) { in ice_ptp_cleanup_pf()
2981 mutex_lock(&pf->adapter->ports.lock); in ice_ptp_cleanup_pf()
2983 mutex_unlock(&pf->adapter->ports.lock); in ice_ptp_cleanup_pf()
2989 * @pf: Board private structure
2991 * Returns: the PTP clock index associated with this PF, or -1 if no PTP clock
2994 int ice_ptp_clock_index(struct ice_pf *pf) in ice_ptp_clock_index() argument
2996 struct ice_ptp *ctrl_ptp = ice_get_ctrl_ptp(pf); in ice_ptp_clock_index()
3008 * @pf: Board private structure
3014 static int ice_ptp_init_owner(struct ice_pf *pf) in ice_ptp_init_owner() argument
3016 struct ice_hw *hw = &pf->hw; in ice_ptp_init_owner()
3022 dev_err(ice_pf_to_dev(pf), "Failed to initialize PHC, err %d\n", in ice_ptp_init_owner()
3034 err = ice_ptp_write_incval(hw, ice_base_incval(pf)); in ice_ptp_init_owner()
3040 err = ice_ptp_write_init(pf, &ts); in ice_ptp_init_owner()
3048 err = ice_ptp_cfg_phy_interrupt(pf, true, 1); in ice_ptp_init_owner()
3053 err = ice_ptp_create_clock(pf); in ice_ptp_init_owner()
3059 pf->ptp.clock = NULL; in ice_ptp_init_owner()
3070 * @pf: Board private structure
3071 * @ptp: PF PTP structure
3073 static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) in ice_ptp_init_work() argument
3084 dev_name(ice_pf_to_dev(pf))); in ice_ptp_init_work()
3098 * @pf: Board private structure
3101 static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) in ice_ptp_init_port() argument
3103 struct ice_hw *hw = &pf->hw; in ice_ptp_init_port()
3109 return ice_ptp_init_tx_eth56g(pf, &ptp_port->tx, in ice_ptp_init_port()
3112 return ice_ptp_init_tx_e810(pf, &ptp_port->tx); in ice_ptp_init_port()
3117 return ice_ptp_init_tx_e82x(pf, &ptp_port->tx, in ice_ptp_init_port()
3126 * @pf: Board private structure
3129 * types, each PF processes the interrupt and manages its own timestamps. For
3133 static void ice_ptp_init_tx_interrupt_mode(struct ice_pf *pf) in ice_ptp_init_tx_interrupt_mode() argument
3135 switch (ice_get_phy_model(&pf->hw)) { in ice_ptp_init_tx_interrupt_mode()
3140 if (ice_pf_src_tmr_owned(pf)) in ice_ptp_init_tx_interrupt_mode()
3141 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_ALL; in ice_ptp_init_tx_interrupt_mode()
3143 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_NONE; in ice_ptp_init_tx_interrupt_mode()
3147 pf->ptp.tx_interrupt_mode = ICE_PTP_TX_INTERRUPT_SELF; in ice_ptp_init_tx_interrupt_mode()
3153 * @pf: Board private structure
3163 void ice_ptp_init(struct ice_pf *pf) in ice_ptp_init() argument
3165 struct ice_ptp *ptp = &pf->ptp; in ice_ptp_init()
3166 struct ice_hw *hw = &pf->hw; in ice_ptp_init()
3173 ice_ptp_init_tx_interrupt_mode(pf); in ice_ptp_init()
3178 if (ice_pf_src_tmr_owned(pf) && ice_is_primary(hw)) { in ice_ptp_init()
3179 err = ice_ptp_setup_adapter(pf); in ice_ptp_init()
3182 err = ice_ptp_init_owner(pf); in ice_ptp_init()
3187 err = ice_ptp_setup_pf(pf); in ice_ptp_init()
3195 err = ice_ptp_init_port(pf, &ptp->port); in ice_ptp_init()
3200 ice_ptp_reset_phy_timestamping(pf); in ice_ptp_init()
3203 ice_ptp_cfg_tx_interrupt(pf); in ice_ptp_init()
3207 err = ice_ptp_init_work(pf, ptp); in ice_ptp_init()
3211 dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); in ice_ptp_init()
3216 if (pf->ptp.clock) { in ice_ptp_init()
3218 pf->ptp.clock = NULL; in ice_ptp_init()
3221 dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); in ice_ptp_init()
3226 * @pf: Board private structure
3231 void ice_ptp_release(struct ice_pf *pf) in ice_ptp_release() argument
3233 if (pf->ptp.state != ICE_PTP_READY) in ice_ptp_release()
3236 pf->ptp.state = ICE_PTP_UNINIT; in ice_ptp_release()
3239 ice_ptp_disable_timestamp_mode(pf); in ice_ptp_release()
3241 ice_ptp_cleanup_pf(pf); in ice_ptp_release()
3243 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()
3245 ice_ptp_disable_all_extts(pf); in ice_ptp_release()
3247 kthread_cancel_delayed_work_sync(&pf->ptp.work); in ice_ptp_release()
3249 ice_ptp_port_phy_stop(&pf->ptp.port); in ice_ptp_release()
3250 mutex_destroy(&pf->ptp.port.ps_lock); in ice_ptp_release()
3251 if (pf->ptp.kworker) { in ice_ptp_release()
3252 kthread_destroy_worker(pf->ptp.kworker); in ice_ptp_release()
3253 pf->ptp.kworker = NULL; in ice_ptp_release()
3256 if (!pf->ptp.clock) in ice_ptp_release()
3260 ice_ptp_disable_all_perout(pf); in ice_ptp_release()
3262 ptp_clock_unregister(pf->ptp.clock); in ice_ptp_release()
3263 pf->ptp.clock = NULL; in ice_ptp_release()
3265 dev_info(ice_pf_to_dev(pf), "Removed PTP clock\n"); in ice_ptp_release()