Lines Matching refs:adapter
157 static void ixgbe_ptp_setup_sdp_X540(struct ixgbe_adapter *adapter) in ixgbe_ptp_setup_sdp_X540() argument
159 struct cyclecounter *cc = &adapter->hw_cc; in ixgbe_ptp_setup_sdp_X540()
160 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_setup_sdp_X540()
169 if (!(adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED)) in ixgbe_ptp_setup_sdp_X540()
195 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X540()
196 ns = timecounter_read(&adapter->hw_tc); in ixgbe_ptp_setup_sdp_X540()
197 clock_edge = adapter->hw_tc.cycle_last; in ixgbe_ptp_setup_sdp_X540()
198 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X540()
236 static void ixgbe_ptp_setup_sdp_X550(struct ixgbe_adapter *adapter) in ixgbe_ptp_setup_sdp_X550() argument
239 struct cyclecounter *cc = &adapter->hw_cc; in ixgbe_ptp_setup_sdp_X550()
240 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_setup_sdp_X550()
249 if (!(adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED)) in ixgbe_ptp_setup_sdp_X550()
278 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X550()
279 ns = timecounter_read(&adapter->hw_tc); in ixgbe_ptp_setup_sdp_X550()
280 clock_edge = adapter->hw_tc.cycle_last; in ixgbe_ptp_setup_sdp_X550()
281 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X550()
328 struct ixgbe_adapter *adapter = in ixgbe_ptp_read_X550() local
330 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_read_X550()
365 struct ixgbe_adapter *adapter = in ixgbe_ptp_read_82599() local
367 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_read_82599()
393 static void ixgbe_ptp_convert_to_hwtstamp(struct ixgbe_adapter *adapter, in ixgbe_ptp_convert_to_hwtstamp() argument
403 switch (adapter->hw.mac.type) { in ixgbe_ptp_convert_to_hwtstamp()
429 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_convert_to_hwtstamp()
430 ns = timecounter_cyc2time(&adapter->hw_tc, timestamp); in ixgbe_ptp_convert_to_hwtstamp()
431 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_convert_to_hwtstamp()
446 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjfreq_82599() local
448 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_adjfreq_82599()
459 incval = READ_ONCE(adapter->base_incval); in ixgbe_ptp_adjfreq_82599()
497 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjfreq_X550() local
499 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_adjfreq_X550()
533 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjtime() local
537 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_adjtime()
538 timecounter_adjtime(&adapter->hw_tc, delta); in ixgbe_ptp_adjtime()
539 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_adjtime()
541 if (adapter->ptp_setup_sdp) in ixgbe_ptp_adjtime()
542 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_adjtime()
560 struct ixgbe_adapter *adapter = in ixgbe_ptp_gettimex() local
562 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_gettimex()
566 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_gettimex()
568 switch (adapter->hw.mac.type) { in ixgbe_ptp_gettimex()
592 ns = timecounter_cyc2time(&adapter->hw_tc, stamp); in ixgbe_ptp_gettimex()
594 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_gettimex()
612 struct ixgbe_adapter *adapter = in ixgbe_ptp_settime() local
618 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_settime()
619 timecounter_init(&adapter->hw_tc, &adapter->hw_cc, ns); in ixgbe_ptp_settime()
620 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_settime()
622 if (adapter->ptp_setup_sdp) in ixgbe_ptp_settime()
623 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_settime()
639 struct ixgbe_adapter *adapter = in ixgbe_ptp_feature_enable() local
648 if (rq->type != PTP_CLK_REQ_PPS || !adapter->ptp_setup_sdp) in ixgbe_ptp_feature_enable()
652 adapter->flags2 |= IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_feature_enable()
654 adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_feature_enable()
656 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_feature_enable()
667 void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter) in ixgbe_ptp_check_pps_event() argument
669 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_check_pps_event()
678 if (!adapter->ptp_clock) in ixgbe_ptp_check_pps_event()
683 ptp_clock_event(adapter->ptp_clock, &event); in ixgbe_ptp_check_pps_event()
698 void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter) in ixgbe_ptp_overflow_check() argument
700 bool timeout = time_is_before_jiffies(adapter->last_overflow_check + in ixgbe_ptp_overflow_check()
706 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_overflow_check()
707 timecounter_read(&adapter->hw_tc); in ixgbe_ptp_overflow_check()
708 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_overflow_check()
710 adapter->last_overflow_check = jiffies; in ixgbe_ptp_overflow_check()
723 void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter) in ixgbe_ptp_rx_hang() argument
725 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_rx_hang()
735 adapter->last_rx_ptp_check = jiffies; in ixgbe_ptp_rx_hang()
740 rx_event = adapter->last_rx_ptp_check; in ixgbe_ptp_rx_hang()
741 for (n = 0; n < adapter->num_rx_queues; n++) { in ixgbe_ptp_rx_hang()
742 rx_ring = adapter->rx_ring[n]; in ixgbe_ptp_rx_hang()
750 adapter->last_rx_ptp_check = jiffies; in ixgbe_ptp_rx_hang()
752 adapter->rx_hwtstamp_cleared++; in ixgbe_ptp_rx_hang()
765 static void ixgbe_ptp_clear_tx_timestamp(struct ixgbe_adapter *adapter) in ixgbe_ptp_clear_tx_timestamp() argument
767 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_clear_tx_timestamp()
770 if (adapter->ptp_tx_skb) { in ixgbe_ptp_clear_tx_timestamp()
771 dev_kfree_skb_any(adapter->ptp_tx_skb); in ixgbe_ptp_clear_tx_timestamp()
772 adapter->ptp_tx_skb = NULL; in ixgbe_ptp_clear_tx_timestamp()
774 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_ptp_clear_tx_timestamp()
781 void ixgbe_ptp_tx_hang(struct ixgbe_adapter *adapter) in ixgbe_ptp_tx_hang() argument
783 bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + in ixgbe_ptp_tx_hang()
786 if (!adapter->ptp_tx_skb) in ixgbe_ptp_tx_hang()
789 if (!test_bit(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state)) in ixgbe_ptp_tx_hang()
797 cancel_work_sync(&adapter->ptp_tx_work); in ixgbe_ptp_tx_hang()
798 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_tx_hang()
799 adapter->tx_hwtstamp_timeouts++; in ixgbe_ptp_tx_hang()
812 static void ixgbe_ptp_tx_hwtstamp(struct ixgbe_adapter *adapter) in ixgbe_ptp_tx_hwtstamp() argument
814 struct sk_buff *skb = adapter->ptp_tx_skb; in ixgbe_ptp_tx_hwtstamp()
815 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_tx_hwtstamp()
821 ixgbe_ptp_convert_to_hwtstamp(adapter, &shhwtstamps, regval); in ixgbe_ptp_tx_hwtstamp()
828 adapter->ptp_tx_skb = NULL; in ixgbe_ptp_tx_hwtstamp()
829 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_ptp_tx_hwtstamp()
846 struct ixgbe_adapter *adapter = container_of(work, struct ixgbe_adapter, in ixgbe_ptp_tx_hwtstamp_work() local
848 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_tx_hwtstamp_work()
849 bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + in ixgbe_ptp_tx_hwtstamp_work()
854 if (!adapter->ptp_tx_skb) { in ixgbe_ptp_tx_hwtstamp_work()
855 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_tx_hwtstamp_work()
862 ixgbe_ptp_tx_hwtstamp(adapter); in ixgbe_ptp_tx_hwtstamp_work()
867 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_tx_hwtstamp_work()
868 adapter->tx_hwtstamp_timeouts++; in ixgbe_ptp_tx_hwtstamp_work()
872 schedule_work(&adapter->ptp_tx_work); in ixgbe_ptp_tx_hwtstamp_work()
901 ixgbe_ptp_convert_to_hwtstamp(q_vector->adapter, skb_hwtstamps(skb), in ixgbe_ptp_rx_pktstamp()
917 struct ixgbe_adapter *adapter; in ixgbe_ptp_rx_rgtstamp() local
923 if (!q_vector || !q_vector->adapter) in ixgbe_ptp_rx_rgtstamp()
926 adapter = q_vector->adapter; in ixgbe_ptp_rx_rgtstamp()
927 hw = &adapter->hw; in ixgbe_ptp_rx_rgtstamp()
940 ixgbe_ptp_convert_to_hwtstamp(adapter, skb_hwtstamps(skb), regval); in ixgbe_ptp_rx_rgtstamp()
952 int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) in ixgbe_ptp_get_ts_config() argument
954 struct hwtstamp_config *config = &adapter->tstamp_config; in ixgbe_ptp_get_ts_config()
985 static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, in ixgbe_ptp_set_timestamp_mode() argument
988 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_set_timestamp_mode()
1013 adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED | in ixgbe_ptp_set_timestamp_mode()
1019 adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED | in ixgbe_ptp_set_timestamp_mode()
1025 adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED | in ixgbe_ptp_set_timestamp_mode()
1040 adapter->flags |= (IXGBE_FLAG_RX_HWTSTAMP_ENABLED | in ixgbe_ptp_set_timestamp_mode()
1052 adapter->flags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED; in ixgbe_ptp_set_timestamp_mode()
1063 adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED | in ixgbe_ptp_set_timestamp_mode()
1070 adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED | in ixgbe_ptp_set_timestamp_mode()
1096 adapter->flags |= IXGBE_FLAG_RX_HWTSTAMP_ENABLED; in ixgbe_ptp_set_timestamp_mode()
1097 adapter->flags &= ~IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER; in ixgbe_ptp_set_timestamp_mode()
1131 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_set_timestamp_mode()
1145 int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) in ixgbe_ptp_set_ts_config() argument
1153 err = ixgbe_ptp_set_timestamp_mode(adapter, &config); in ixgbe_ptp_set_ts_config()
1158 memcpy(&adapter->tstamp_config, &config, in ixgbe_ptp_set_ts_config()
1159 sizeof(adapter->tstamp_config)); in ixgbe_ptp_set_ts_config()
1165 static void ixgbe_ptp_link_speed_adjust(struct ixgbe_adapter *adapter, in ixgbe_ptp_link_speed_adjust() argument
1182 switch (adapter->link_speed) { in ixgbe_ptp_link_speed_adjust()
1209 void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter) in ixgbe_ptp_start_cyclecounter() argument
1211 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_start_cyclecounter()
1266 ixgbe_ptp_link_speed_adjust(adapter, &cc.shift, &incval); in ixgbe_ptp_start_cyclecounter()
1272 ixgbe_ptp_link_speed_adjust(adapter, &cc.shift, &incval); in ixgbe_ptp_start_cyclecounter()
1284 WRITE_ONCE(adapter->base_incval, incval); in ixgbe_ptp_start_cyclecounter()
1288 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_start_cyclecounter()
1289 memcpy(&adapter->hw_cc, &cc, sizeof(adapter->hw_cc)); in ixgbe_ptp_start_cyclecounter()
1290 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_start_cyclecounter()
1305 void ixgbe_ptp_reset(struct ixgbe_adapter *adapter) in ixgbe_ptp_reset() argument
1307 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_reset()
1311 ixgbe_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config); in ixgbe_ptp_reset()
1317 ixgbe_ptp_start_cyclecounter(adapter); in ixgbe_ptp_reset()
1319 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_reset()
1320 timecounter_init(&adapter->hw_tc, &adapter->hw_cc, in ixgbe_ptp_reset()
1322 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_reset()
1324 adapter->last_overflow_check = jiffies; in ixgbe_ptp_reset()
1329 if (adapter->ptp_setup_sdp) in ixgbe_ptp_reset()
1330 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_reset()
1343 static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter) in ixgbe_ptp_create_clock() argument
1345 struct net_device *netdev = adapter->netdev; in ixgbe_ptp_create_clock()
1349 if (!IS_ERR_OR_NULL(adapter->ptp_clock)) in ixgbe_ptp_create_clock()
1352 switch (adapter->hw.mac.type) { in ixgbe_ptp_create_clock()
1354 snprintf(adapter->ptp_caps.name, in ixgbe_ptp_create_clock()
1355 sizeof(adapter->ptp_caps.name), in ixgbe_ptp_create_clock()
1357 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
1358 adapter->ptp_caps.max_adj = 250000000; in ixgbe_ptp_create_clock()
1359 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
1360 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
1361 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
1362 adapter->ptp_caps.pps = 1; in ixgbe_ptp_create_clock()
1363 adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq_82599; in ixgbe_ptp_create_clock()
1364 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
1365 adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex; in ixgbe_ptp_create_clock()
1366 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
1367 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
1368 adapter->ptp_setup_sdp = ixgbe_ptp_setup_sdp_X540; in ixgbe_ptp_create_clock()
1371 snprintf(adapter->ptp_caps.name, in ixgbe_ptp_create_clock()
1372 sizeof(adapter->ptp_caps.name), in ixgbe_ptp_create_clock()
1374 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
1375 adapter->ptp_caps.max_adj = 250000000; in ixgbe_ptp_create_clock()
1376 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
1377 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
1378 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
1379 adapter->ptp_caps.pps = 0; in ixgbe_ptp_create_clock()
1380 adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq_82599; in ixgbe_ptp_create_clock()
1381 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
1382 adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex; in ixgbe_ptp_create_clock()
1383 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
1384 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
1389 snprintf(adapter->ptp_caps.name, 16, "%s", netdev->name); in ixgbe_ptp_create_clock()
1390 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
1391 adapter->ptp_caps.max_adj = 30000000; in ixgbe_ptp_create_clock()
1392 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
1393 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
1394 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
1395 adapter->ptp_caps.pps = 1; in ixgbe_ptp_create_clock()
1396 adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq_X550; in ixgbe_ptp_create_clock()
1397 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
1398 adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex; in ixgbe_ptp_create_clock()
1399 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
1400 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
1401 adapter->ptp_setup_sdp = ixgbe_ptp_setup_sdp_X550; in ixgbe_ptp_create_clock()
1404 adapter->ptp_clock = NULL; in ixgbe_ptp_create_clock()
1405 adapter->ptp_setup_sdp = NULL; in ixgbe_ptp_create_clock()
1409 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, in ixgbe_ptp_create_clock()
1410 &adapter->pdev->dev); in ixgbe_ptp_create_clock()
1411 if (IS_ERR(adapter->ptp_clock)) { in ixgbe_ptp_create_clock()
1412 err = PTR_ERR(adapter->ptp_clock); in ixgbe_ptp_create_clock()
1413 adapter->ptp_clock = NULL; in ixgbe_ptp_create_clock()
1416 } else if (adapter->ptp_clock) in ixgbe_ptp_create_clock()
1423 adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ixgbe_ptp_create_clock()
1424 adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ixgbe_ptp_create_clock()
1437 void ixgbe_ptp_init(struct ixgbe_adapter *adapter) in ixgbe_ptp_init() argument
1443 spin_lock_init(&adapter->tmreg_lock); in ixgbe_ptp_init()
1446 if (ixgbe_ptp_create_clock(adapter)) in ixgbe_ptp_init()
1450 INIT_WORK(&adapter->ptp_tx_work, ixgbe_ptp_tx_hwtstamp_work); in ixgbe_ptp_init()
1453 ixgbe_ptp_reset(adapter); in ixgbe_ptp_init()
1456 set_bit(__IXGBE_PTP_RUNNING, &adapter->state); in ixgbe_ptp_init()
1468 void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter) in ixgbe_ptp_suspend() argument
1471 if (!test_and_clear_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_ptp_suspend()
1474 adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_suspend()
1475 if (adapter->ptp_setup_sdp) in ixgbe_ptp_suspend()
1476 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_suspend()
1479 cancel_work_sync(&adapter->ptp_tx_work); in ixgbe_ptp_suspend()
1480 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_suspend()
1490 void ixgbe_ptp_stop(struct ixgbe_adapter *adapter) in ixgbe_ptp_stop() argument
1493 ixgbe_ptp_suspend(adapter); in ixgbe_ptp_stop()
1496 if (adapter->ptp_clock) { in ixgbe_ptp_stop()
1497 ptp_clock_unregister(adapter->ptp_clock); in ixgbe_ptp_stop()
1498 adapter->ptp_clock = NULL; in ixgbe_ptp_stop()
1500 adapter->netdev->name); in ixgbe_ptp_stop()