Lines Matching refs:adapter

119 static void ixgbe_ptp_setup_sdp(struct ixgbe_adapter *adapter)  in ixgbe_ptp_setup_sdp()  argument
121 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_setup_sdp()
122 int shift = adapter->cc.shift; in ixgbe_ptp_setup_sdp()
126 if ((adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED) && in ixgbe_ptp_setup_sdp()
161 ns = timecounter_cyc2time(&adapter->tc, clock_edge); in ixgbe_ptp_setup_sdp()
194 struct ixgbe_adapter *adapter = in ixgbe_ptp_read() local
196 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_read()
215 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjfreq() local
217 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_adjfreq()
228 incval = ACCESS_ONCE(adapter->base_incval); in ixgbe_ptp_adjfreq()
261 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjtime() local
265 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_adjtime()
266 timecounter_adjtime(&adapter->tc, delta); in ixgbe_ptp_adjtime()
267 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_adjtime()
269 ixgbe_ptp_setup_sdp(adapter); in ixgbe_ptp_adjtime()
284 struct ixgbe_adapter *adapter = in ixgbe_ptp_gettime() local
289 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_gettime()
290 ns = timecounter_read(&adapter->tc); in ixgbe_ptp_gettime()
291 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_gettime()
309 struct ixgbe_adapter *adapter = in ixgbe_ptp_settime() local
317 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_settime()
318 timecounter_init(&adapter->tc, &adapter->cc, ns); in ixgbe_ptp_settime()
319 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_settime()
321 ixgbe_ptp_setup_sdp(adapter); in ixgbe_ptp_settime()
337 struct ixgbe_adapter *adapter = in ixgbe_ptp_feature_enable() local
347 switch (adapter->hw.mac.type) { in ixgbe_ptp_feature_enable()
350 adapter->flags2 |= IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_feature_enable()
352 adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_feature_enable()
354 ixgbe_ptp_setup_sdp(adapter); in ixgbe_ptp_feature_enable()
372 void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr) in ixgbe_ptp_check_pps_event() argument
374 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_check_pps_event()
383 if (!adapter->ptp_clock) in ixgbe_ptp_check_pps_event()
388 ptp_clock_event(adapter->ptp_clock, &event); in ixgbe_ptp_check_pps_event()
403 void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter) in ixgbe_ptp_overflow_check() argument
405 bool timeout = time_is_before_jiffies(adapter->last_overflow_check + in ixgbe_ptp_overflow_check()
410 ixgbe_ptp_gettime(&adapter->ptp_caps, &ts); in ixgbe_ptp_overflow_check()
411 adapter->last_overflow_check = jiffies; in ixgbe_ptp_overflow_check()
424 void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter) in ixgbe_ptp_rx_hang() argument
426 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_rx_hang()
434 adapter->last_rx_ptp_check = jiffies; in ixgbe_ptp_rx_hang()
439 rx_event = adapter->last_rx_ptp_check; in ixgbe_ptp_rx_hang()
440 if (time_after(adapter->last_rx_timestamp, rx_event)) in ixgbe_ptp_rx_hang()
441 rx_event = adapter->last_rx_timestamp; in ixgbe_ptp_rx_hang()
446 adapter->last_rx_ptp_check = jiffies; in ixgbe_ptp_rx_hang()
460 static void ixgbe_ptp_tx_hwtstamp(struct ixgbe_adapter *adapter) in ixgbe_ptp_tx_hwtstamp() argument
462 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_tx_hwtstamp()
470 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_tx_hwtstamp()
471 ns = timecounter_cyc2time(&adapter->tc, regval); in ixgbe_ptp_tx_hwtstamp()
472 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_tx_hwtstamp()
476 skb_tstamp_tx(adapter->ptp_tx_skb, &shhwtstamps); in ixgbe_ptp_tx_hwtstamp()
478 dev_kfree_skb_any(adapter->ptp_tx_skb); in ixgbe_ptp_tx_hwtstamp()
479 adapter->ptp_tx_skb = NULL; in ixgbe_ptp_tx_hwtstamp()
480 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_ptp_tx_hwtstamp()
493 struct ixgbe_adapter *adapter = container_of(work, struct ixgbe_adapter, in ixgbe_ptp_tx_hwtstamp_work() local
495 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_tx_hwtstamp_work()
496 bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + in ixgbe_ptp_tx_hwtstamp_work()
501 dev_kfree_skb_any(adapter->ptp_tx_skb); in ixgbe_ptp_tx_hwtstamp_work()
502 adapter->ptp_tx_skb = NULL; in ixgbe_ptp_tx_hwtstamp_work()
503 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_ptp_tx_hwtstamp_work()
510 ixgbe_ptp_tx_hwtstamp(adapter); in ixgbe_ptp_tx_hwtstamp_work()
513 schedule_work(&adapter->ptp_tx_work); in ixgbe_ptp_tx_hwtstamp_work()
525 void ixgbe_ptp_rx_hwtstamp(struct ixgbe_adapter *adapter, struct sk_buff *skb) in ixgbe_ptp_rx_hwtstamp() argument
527 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_rx_hwtstamp()
540 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_rx_hwtstamp()
541 ns = timecounter_cyc2time(&adapter->tc, regval); in ixgbe_ptp_rx_hwtstamp()
542 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_rx_hwtstamp()
550 adapter->last_rx_timestamp = jiffies; in ixgbe_ptp_rx_hwtstamp()
553 int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) in ixgbe_ptp_get_ts_config() argument
555 struct hwtstamp_config *config = &adapter->tstamp_config; in ixgbe_ptp_get_ts_config()
586 static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, in ixgbe_ptp_set_timestamp_mode() argument
589 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_set_timestamp_mode()
695 int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) in ixgbe_ptp_set_ts_config() argument
703 err = ixgbe_ptp_set_timestamp_mode(adapter, &config); in ixgbe_ptp_set_ts_config()
708 memcpy(&adapter->tstamp_config, &config, in ixgbe_ptp_set_ts_config()
709 sizeof(adapter->tstamp_config)); in ixgbe_ptp_set_ts_config()
725 void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter) in ixgbe_ptp_start_cyclecounter() argument
727 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_start_cyclecounter()
746 switch (adapter->link_speed) { in ixgbe_ptp_start_cyclecounter()
785 ACCESS_ONCE(adapter->base_incval) = incval; in ixgbe_ptp_start_cyclecounter()
789 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_start_cyclecounter()
791 memset(&adapter->cc, 0, sizeof(adapter->cc)); in ixgbe_ptp_start_cyclecounter()
792 adapter->cc.read = ixgbe_ptp_read; in ixgbe_ptp_start_cyclecounter()
793 adapter->cc.mask = CYCLECOUNTER_MASK(64); in ixgbe_ptp_start_cyclecounter()
794 adapter->cc.shift = shift; in ixgbe_ptp_start_cyclecounter()
795 adapter->cc.mult = 1; in ixgbe_ptp_start_cyclecounter()
797 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_start_cyclecounter()
812 void ixgbe_ptp_reset(struct ixgbe_adapter *adapter) in ixgbe_ptp_reset() argument
814 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_reset()
823 ixgbe_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config); in ixgbe_ptp_reset()
825 ixgbe_ptp_start_cyclecounter(adapter); in ixgbe_ptp_reset()
827 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_reset()
830 timecounter_init(&adapter->tc, &adapter->cc, in ixgbe_ptp_reset()
833 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_reset()
839 ixgbe_ptp_setup_sdp(adapter); in ixgbe_ptp_reset()
852 static int ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter) in ixgbe_ptp_create_clock() argument
854 struct net_device *netdev = adapter->netdev; in ixgbe_ptp_create_clock()
858 if (!IS_ERR_OR_NULL(adapter->ptp_clock)) in ixgbe_ptp_create_clock()
861 switch (adapter->hw.mac.type) { in ixgbe_ptp_create_clock()
863 snprintf(adapter->ptp_caps.name, in ixgbe_ptp_create_clock()
864 sizeof(adapter->ptp_caps.name), in ixgbe_ptp_create_clock()
866 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
867 adapter->ptp_caps.max_adj = 250000000; in ixgbe_ptp_create_clock()
868 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
869 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
870 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
871 adapter->ptp_caps.pps = 1; in ixgbe_ptp_create_clock()
872 adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq; in ixgbe_ptp_create_clock()
873 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
874 adapter->ptp_caps.gettime64 = ixgbe_ptp_gettime; in ixgbe_ptp_create_clock()
875 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
876 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
879 snprintf(adapter->ptp_caps.name, in ixgbe_ptp_create_clock()
880 sizeof(adapter->ptp_caps.name), in ixgbe_ptp_create_clock()
882 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
883 adapter->ptp_caps.max_adj = 250000000; in ixgbe_ptp_create_clock()
884 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
885 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
886 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
887 adapter->ptp_caps.pps = 0; in ixgbe_ptp_create_clock()
888 adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq; in ixgbe_ptp_create_clock()
889 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
890 adapter->ptp_caps.gettime64 = ixgbe_ptp_gettime; in ixgbe_ptp_create_clock()
891 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
892 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
895 adapter->ptp_clock = NULL; in ixgbe_ptp_create_clock()
899 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, in ixgbe_ptp_create_clock()
900 &adapter->pdev->dev); in ixgbe_ptp_create_clock()
901 if (IS_ERR(adapter->ptp_clock)) { in ixgbe_ptp_create_clock()
902 err = PTR_ERR(adapter->ptp_clock); in ixgbe_ptp_create_clock()
903 adapter->ptp_clock = NULL; in ixgbe_ptp_create_clock()
913 adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ixgbe_ptp_create_clock()
914 adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ixgbe_ptp_create_clock()
927 void ixgbe_ptp_init(struct ixgbe_adapter *adapter) in ixgbe_ptp_init() argument
933 spin_lock_init(&adapter->tmreg_lock); in ixgbe_ptp_init()
936 if (ixgbe_ptp_create_clock(adapter)) in ixgbe_ptp_init()
940 INIT_WORK(&adapter->ptp_tx_work, ixgbe_ptp_tx_hwtstamp_work); in ixgbe_ptp_init()
943 ixgbe_ptp_reset(adapter); in ixgbe_ptp_init()
946 set_bit(__IXGBE_PTP_RUNNING, &adapter->state); in ixgbe_ptp_init()
958 void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter) in ixgbe_ptp_suspend() argument
961 if (!test_and_clear_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_ptp_suspend()
967 IXGBE_WRITE_REG(&adapter->hw, IXGBE_TSAUXC, 0x0); in ixgbe_ptp_suspend()
970 cancel_work_sync(&adapter->ptp_tx_work); in ixgbe_ptp_suspend()
971 if (adapter->ptp_tx_skb) { in ixgbe_ptp_suspend()
972 dev_kfree_skb_any(adapter->ptp_tx_skb); in ixgbe_ptp_suspend()
973 adapter->ptp_tx_skb = NULL; in ixgbe_ptp_suspend()
974 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_ptp_suspend()
985 void ixgbe_ptp_stop(struct ixgbe_adapter *adapter) in ixgbe_ptp_stop() argument
988 ixgbe_ptp_suspend(adapter); in ixgbe_ptp_stop()
991 if (adapter->ptp_clock) { in ixgbe_ptp_stop()
992 ptp_clock_unregister(adapter->ptp_clock); in ixgbe_ptp_stop()
993 adapter->ptp_clock = NULL; in ixgbe_ptp_stop()
995 adapter->netdev->name); in ixgbe_ptp_stop()