Lines Matching full:pf

29  * @pf: Board private structure
37 static void i40e_ptp_read(struct i40e_pf *pf, struct timespec64 *ts, in i40e_ptp_read() argument
40 struct i40e_hw *hw = &pf->hw; in i40e_ptp_read()
57 * @pf: Board private structure
64 static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec64 *ts) in i40e_ptp_write() argument
66 struct i40e_hw *hw = &pf->hw; in i40e_ptp_write()
103 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); in i40e_ptp_adjfreq() local
104 struct i40e_hw *hw = &pf->hw; in i40e_ptp_adjfreq()
130 adj *= READ_ONCE(pf->ptp_adj_mult); in i40e_ptp_adjfreq()
147 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); in i40e_ptp_adjtime() local
151 mutex_lock(&pf->tmreg_lock); in i40e_ptp_adjtime()
153 i40e_ptp_read(pf, &now, NULL); in i40e_ptp_adjtime()
155 i40e_ptp_write(pf, (const struct timespec64 *)&now); in i40e_ptp_adjtime()
157 mutex_unlock(&pf->tmreg_lock); in i40e_ptp_adjtime()
174 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); in i40e_ptp_gettimex() local
176 mutex_lock(&pf->tmreg_lock); in i40e_ptp_gettimex()
177 i40e_ptp_read(pf, ts, sts); in i40e_ptp_gettimex()
178 mutex_unlock(&pf->tmreg_lock); in i40e_ptp_gettimex()
194 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); in i40e_ptp_settime() local
196 mutex_lock(&pf->tmreg_lock); in i40e_ptp_settime()
197 i40e_ptp_write(pf, ts); in i40e_ptp_settime()
198 mutex_unlock(&pf->tmreg_lock); in i40e_ptp_settime()
220 * @pf: the PF data structure
230 static u32 i40e_ptp_get_rx_events(struct i40e_pf *pf) in i40e_ptp_get_rx_events() argument
232 struct i40e_hw *hw = &pf->hw; in i40e_ptp_get_rx_events()
237 new_latch_events = prttsyn_stat & ~pf->latch_event_flags; in i40e_ptp_get_rx_events()
250 pf->latch_events[i] = jiffies; in i40e_ptp_get_rx_events()
254 pf->latch_event_flags = prttsyn_stat; in i40e_ptp_get_rx_events()
261 * @pf: The PF private data structure
268 void i40e_ptp_rx_hang(struct i40e_pf *pf) in i40e_ptp_rx_hang() argument
270 struct i40e_hw *hw = &pf->hw; in i40e_ptp_rx_hang()
278 if (!(pf->flags & I40E_FLAG_PTP) || !pf->ptp_rx) in i40e_ptp_rx_hang()
281 spin_lock_bh(&pf->ptp_rx_lock); in i40e_ptp_rx_hang()
284 i40e_ptp_get_rx_events(pf); in i40e_ptp_rx_hang()
293 if ((pf->latch_event_flags & BIT(i)) && in i40e_ptp_rx_hang()
294 time_is_before_jiffies(pf->latch_events[i] + HZ)) { in i40e_ptp_rx_hang()
296 pf->latch_event_flags &= ~BIT(i); in i40e_ptp_rx_hang()
301 spin_unlock_bh(&pf->ptp_rx_lock); in i40e_ptp_rx_hang()
310 dev_dbg(&pf->pdev->dev, in i40e_ptp_rx_hang()
315 pf->rx_hwtstamp_cleared += cleared; in i40e_ptp_rx_hang()
320 * @pf: The PF private data structure
327 void i40e_ptp_tx_hang(struct i40e_pf *pf) in i40e_ptp_tx_hang() argument
331 if (!(pf->flags & I40E_FLAG_PTP) || !pf->ptp_tx) in i40e_ptp_tx_hang()
335 if (!test_bit(__I40E_PTP_TX_IN_PROGRESS, pf->state)) in i40e_ptp_tx_hang()
342 if (time_is_before_jiffies(pf->ptp_tx_start + HZ)) { in i40e_ptp_tx_hang()
343 skb = pf->ptp_tx_skb; in i40e_ptp_tx_hang()
344 pf->ptp_tx_skb = NULL; in i40e_ptp_tx_hang()
345 clear_bit_unlock(__I40E_PTP_TX_IN_PROGRESS, pf->state); in i40e_ptp_tx_hang()
349 pf->tx_hwtstamp_timeouts++; in i40e_ptp_tx_hang()
355 * @pf: Board private structure
361 void i40e_ptp_tx_hwtstamp(struct i40e_pf *pf) in i40e_ptp_tx_hwtstamp() argument
364 struct sk_buff *skb = pf->ptp_tx_skb; in i40e_ptp_tx_hwtstamp()
365 struct i40e_hw *hw = &pf->hw; in i40e_ptp_tx_hwtstamp()
369 if (!(pf->flags & I40E_FLAG_PTP) || !pf->ptp_tx) in i40e_ptp_tx_hwtstamp()
373 if (!pf->ptp_tx_skb) in i40e_ptp_tx_hwtstamp()
387 pf->ptp_tx_skb = NULL; in i40e_ptp_tx_hwtstamp()
388 clear_bit_unlock(__I40E_PTP_TX_IN_PROGRESS, pf->state); in i40e_ptp_tx_hwtstamp()
397 * @pf: Board private structure
407 void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index) in i40e_ptp_rx_hwtstamp() argument
416 if (!(pf->flags & I40E_FLAG_PTP) || !pf->ptp_rx) in i40e_ptp_rx_hwtstamp()
419 hw = &pf->hw; in i40e_ptp_rx_hwtstamp()
421 spin_lock_bh(&pf->ptp_rx_lock); in i40e_ptp_rx_hwtstamp()
424 prttsyn_stat = i40e_ptp_get_rx_events(pf); in i40e_ptp_rx_hwtstamp()
428 spin_unlock_bh(&pf->ptp_rx_lock); in i40e_ptp_rx_hwtstamp()
433 pf->latch_event_flags &= ~BIT(index); in i40e_ptp_rx_hwtstamp()
438 spin_unlock_bh(&pf->ptp_rx_lock); in i40e_ptp_rx_hwtstamp()
447 * @pf: Board private structure
453 void i40e_ptp_set_increment(struct i40e_pf *pf) in i40e_ptp_set_increment() argument
456 struct i40e_hw *hw = &pf->hw; in i40e_ptp_set_increment()
462 i40e_aq_get_link_info(&pf->hw, true, NULL, NULL); in i40e_ptp_set_increment()
476 dev_warn(&pf->pdev->dev, in i40e_ptp_set_increment()
502 WRITE_ONCE(pf->ptp_adj_mult, mult); in i40e_ptp_set_increment()
508 * @pf: Board private structure
515 int i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr) in i40e_ptp_get_ts_config() argument
517 struct hwtstamp_config *config = &pf->tstamp_config; in i40e_ptp_get_ts_config()
519 if (!(pf->flags & I40E_FLAG_PTP)) in i40e_ptp_get_ts_config()
528 * @pf: Board private structure
538 static int i40e_ptp_set_timestamp_mode(struct i40e_pf *pf, in i40e_ptp_set_timestamp_mode() argument
541 struct i40e_hw *hw = &pf->hw; in i40e_ptp_set_timestamp_mode()
550 pf->ptp_tx = false; in i40e_ptp_set_timestamp_mode()
553 pf->ptp_tx = true; in i40e_ptp_set_timestamp_mode()
561 pf->ptp_rx = false; in i40e_ptp_set_timestamp_mode()
572 if (!(pf->hw_features & I40E_HW_PTP_L4_CAPABLE)) in i40e_ptp_set_timestamp_mode()
574 pf->ptp_rx = true; in i40e_ptp_set_timestamp_mode()
586 if (!(pf->hw_features & I40E_HW_PTP_L4_CAPABLE)) in i40e_ptp_set_timestamp_mode()
592 pf->ptp_rx = true; in i40e_ptp_set_timestamp_mode()
595 if (pf->hw_features & I40E_HW_PTP_L4_CAPABLE) { in i40e_ptp_set_timestamp_mode()
609 spin_lock_bh(&pf->ptp_rx_lock); in i40e_ptp_set_timestamp_mode()
616 pf->latch_event_flags = 0; in i40e_ptp_set_timestamp_mode()
617 spin_unlock_bh(&pf->ptp_rx_lock); in i40e_ptp_set_timestamp_mode()
621 if (pf->ptp_tx) in i40e_ptp_set_timestamp_mode()
628 if (pf->ptp_tx) in i40e_ptp_set_timestamp_mode()
638 * ignore Rx timestamps via the pf->ptp_rx flag. in i40e_ptp_set_timestamp_mode()
652 * @pf: Board private structure
664 int i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr) in i40e_ptp_set_ts_config() argument
669 if (!(pf->flags & I40E_FLAG_PTP)) in i40e_ptp_set_ts_config()
675 err = i40e_ptp_set_timestamp_mode(pf, &config); in i40e_ptp_set_ts_config()
680 pf->tstamp_config = config; in i40e_ptp_set_ts_config()
688 * @pf: Board private structure
696 static long i40e_ptp_create_clock(struct i40e_pf *pf) in i40e_ptp_create_clock() argument
699 if (!IS_ERR_OR_NULL(pf->ptp_clock)) in i40e_ptp_create_clock()
702 strlcpy(pf->ptp_caps.name, i40e_driver_name, in i40e_ptp_create_clock()
703 sizeof(pf->ptp_caps.name) - 1); in i40e_ptp_create_clock()
704 pf->ptp_caps.owner = THIS_MODULE; in i40e_ptp_create_clock()
705 pf->ptp_caps.max_adj = 999999999; in i40e_ptp_create_clock()
706 pf->ptp_caps.n_ext_ts = 0; in i40e_ptp_create_clock()
707 pf->ptp_caps.pps = 0; in i40e_ptp_create_clock()
708 pf->ptp_caps.adjfreq = i40e_ptp_adjfreq; in i40e_ptp_create_clock()
709 pf->ptp_caps.adjtime = i40e_ptp_adjtime; in i40e_ptp_create_clock()
710 pf->ptp_caps.gettimex64 = i40e_ptp_gettimex; in i40e_ptp_create_clock()
711 pf->ptp_caps.settime64 = i40e_ptp_settime; in i40e_ptp_create_clock()
712 pf->ptp_caps.enable = i40e_ptp_feature_enable; in i40e_ptp_create_clock()
715 pf->ptp_clock = ptp_clock_register(&pf->ptp_caps, &pf->pdev->dev); in i40e_ptp_create_clock()
716 if (IS_ERR(pf->ptp_clock)) in i40e_ptp_create_clock()
717 return PTR_ERR(pf->ptp_clock); in i40e_ptp_create_clock()
723 pf->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in i40e_ptp_create_clock()
724 pf->tstamp_config.tx_type = HWTSTAMP_TX_OFF; in i40e_ptp_create_clock()
727 ktime_get_real_ts64(&pf->ptp_prev_hw_time); in i40e_ptp_create_clock()
728 pf->ptp_reset_start = ktime_get(); in i40e_ptp_create_clock()
735 * @pf: Board private structure
737 * Read the current PTP time and save it into pf->ptp_prev_hw_time. This should
742 void i40e_ptp_save_hw_time(struct i40e_pf *pf) in i40e_ptp_save_hw_time() argument
745 if (!(pf->flags & I40E_FLAG_PTP)) in i40e_ptp_save_hw_time()
748 i40e_ptp_gettimex(&pf->ptp_caps, &pf->ptp_prev_hw_time, NULL); in i40e_ptp_save_hw_time()
750 pf->ptp_reset_start = ktime_get(); in i40e_ptp_save_hw_time()
755 * @pf: Board private structure
758 * hardware time as pf->ptp_prev_hw_time. To be as accurate as possible,
765 void i40e_ptp_restore_hw_time(struct i40e_pf *pf) in i40e_ptp_restore_hw_time() argument
767 ktime_t delta = ktime_sub(ktime_get(), pf->ptp_reset_start); in i40e_ptp_restore_hw_time()
770 timespec64_add_ns(&pf->ptp_prev_hw_time, ktime_to_ns(delta)); in i40e_ptp_restore_hw_time()
773 i40e_ptp_settime(&pf->ptp_caps, &pf->ptp_prev_hw_time); in i40e_ptp_restore_hw_time()
778 * @pf: Board private structure
785 * pf->ptp_prev_hw_time to the current system time. During resets, it is
789 void i40e_ptp_init(struct i40e_pf *pf) in i40e_ptp_init() argument
791 struct net_device *netdev = pf->vsi[pf->lan_vsi]->netdev; in i40e_ptp_init()
792 struct i40e_hw *hw = &pf->hw; in i40e_ptp_init()
796 /* Only one PF is assigned to control 1588 logic per port. Do not in i40e_ptp_init()
802 pf->flags &= ~I40E_FLAG_PTP; in i40e_ptp_init()
803 dev_info(&pf->pdev->dev, "%s: PTP not supported on %s\n", in i40e_ptp_init()
809 mutex_init(&pf->tmreg_lock); in i40e_ptp_init()
810 spin_lock_init(&pf->ptp_rx_lock); in i40e_ptp_init()
813 err = i40e_ptp_create_clock(pf); in i40e_ptp_init()
815 pf->ptp_clock = NULL; in i40e_ptp_init()
816 dev_err(&pf->pdev->dev, "%s: ptp_clock_register failed\n", in i40e_ptp_init()
818 } else if (pf->ptp_clock) { in i40e_ptp_init()
821 if (pf->hw.debug_mask & I40E_DEBUG_LAN) in i40e_ptp_init()
822 dev_info(&pf->pdev->dev, "PHC enabled\n"); in i40e_ptp_init()
823 pf->flags |= I40E_FLAG_PTP; in i40e_ptp_init()
834 i40e_ptp_set_increment(pf); in i40e_ptp_init()
837 i40e_ptp_set_timestamp_mode(pf, &pf->tstamp_config); in i40e_ptp_init()
840 i40e_ptp_restore_hw_time(pf); in i40e_ptp_init()
846 * @pf: Board private structure
851 void i40e_ptp_stop(struct i40e_pf *pf) in i40e_ptp_stop() argument
853 pf->flags &= ~I40E_FLAG_PTP; in i40e_ptp_stop()
854 pf->ptp_tx = false; in i40e_ptp_stop()
855 pf->ptp_rx = false; in i40e_ptp_stop()
857 if (pf->ptp_tx_skb) { in i40e_ptp_stop()
858 struct sk_buff *skb = pf->ptp_tx_skb; in i40e_ptp_stop()
860 pf->ptp_tx_skb = NULL; in i40e_ptp_stop()
861 clear_bit_unlock(__I40E_PTP_TX_IN_PROGRESS, pf->state); in i40e_ptp_stop()
865 if (pf->ptp_clock) { in i40e_ptp_stop()
866 ptp_clock_unregister(pf->ptp_clock); in i40e_ptp_stop()
867 pf->ptp_clock = NULL; in i40e_ptp_stop()
868 dev_info(&pf->pdev->dev, "%s: removed PHC on %s\n", __func__, in i40e_ptp_stop()
869 pf->vsi[pf->lan_vsi]->netdev->name); in i40e_ptp_stop()