Lines Matching refs:adapter

160 static void ixgbe_ptp_setup_sdp_X540(struct ixgbe_adapter *adapter)  in ixgbe_ptp_setup_sdp_X540()  argument
162 struct cyclecounter *cc = &adapter->hw_cc; in ixgbe_ptp_setup_sdp_X540()
163 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_setup_sdp_X540()
172 if (!(adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED)) in ixgbe_ptp_setup_sdp_X540()
198 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X540()
199 ns = timecounter_read(&adapter->hw_tc); in ixgbe_ptp_setup_sdp_X540()
200 clock_edge = adapter->hw_tc.cycle_last; in ixgbe_ptp_setup_sdp_X540()
201 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X540()
239 static void ixgbe_ptp_setup_sdp_X550(struct ixgbe_adapter *adapter) in ixgbe_ptp_setup_sdp_X550() argument
242 struct cyclecounter *cc = &adapter->hw_cc; in ixgbe_ptp_setup_sdp_X550()
243 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_setup_sdp_X550()
252 if (!(adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED)) in ixgbe_ptp_setup_sdp_X550()
281 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X550()
282 ns = timecounter_read(&adapter->hw_tc); in ixgbe_ptp_setup_sdp_X550()
283 clock_edge = adapter->hw_tc.cycle_last; in ixgbe_ptp_setup_sdp_X550()
284 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_setup_sdp_X550()
331 struct ixgbe_adapter *adapter = in ixgbe_ptp_read_X550() local
333 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_read_X550()
368 struct ixgbe_adapter *adapter = in ixgbe_ptp_read_82599() local
370 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_read_82599()
396 static void ixgbe_ptp_convert_to_hwtstamp(struct ixgbe_adapter *adapter, in ixgbe_ptp_convert_to_hwtstamp() argument
406 switch (adapter->hw.mac.type) { in ixgbe_ptp_convert_to_hwtstamp()
432 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_convert_to_hwtstamp()
433 ns = timecounter_cyc2time(&adapter->hw_tc, timestamp); in ixgbe_ptp_convert_to_hwtstamp()
434 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_convert_to_hwtstamp()
451 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjfine_82599() local
453 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_adjfine_82599()
457 incval = READ_ONCE(adapter->base_incval); in ixgbe_ptp_adjfine_82599()
492 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjfine_X550() local
494 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_adjfine_X550()
523 struct ixgbe_adapter *adapter = in ixgbe_ptp_adjtime() local
527 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_adjtime()
528 timecounter_adjtime(&adapter->hw_tc, delta); in ixgbe_ptp_adjtime()
529 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_adjtime()
531 if (adapter->ptp_setup_sdp) in ixgbe_ptp_adjtime()
532 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_adjtime()
550 struct ixgbe_adapter *adapter = in ixgbe_ptp_gettimex() local
552 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_gettimex()
556 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_gettimex()
558 switch (adapter->hw.mac.type) { in ixgbe_ptp_gettimex()
582 ns = timecounter_cyc2time(&adapter->hw_tc, stamp); in ixgbe_ptp_gettimex()
584 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_gettimex()
602 struct ixgbe_adapter *adapter = in ixgbe_ptp_settime() local
608 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_settime()
609 timecounter_init(&adapter->hw_tc, &adapter->hw_cc, ns); in ixgbe_ptp_settime()
610 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_settime()
612 if (adapter->ptp_setup_sdp) in ixgbe_ptp_settime()
613 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_settime()
629 struct ixgbe_adapter *adapter = in ixgbe_ptp_feature_enable() local
638 if (rq->type != PTP_CLK_REQ_PPS || !adapter->ptp_setup_sdp) in ixgbe_ptp_feature_enable()
642 adapter->flags2 |= IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_feature_enable()
644 adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_feature_enable()
646 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_feature_enable()
657 void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter) in ixgbe_ptp_check_pps_event() argument
659 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_check_pps_event()
668 if (!adapter->ptp_clock) in ixgbe_ptp_check_pps_event()
673 ptp_clock_event(adapter->ptp_clock, &event); in ixgbe_ptp_check_pps_event()
688 void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter) in ixgbe_ptp_overflow_check() argument
690 bool timeout = time_is_before_jiffies(adapter->last_overflow_check + in ixgbe_ptp_overflow_check()
696 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_overflow_check()
697 timecounter_read(&adapter->hw_tc); in ixgbe_ptp_overflow_check()
698 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_overflow_check()
700 adapter->last_overflow_check = jiffies; in ixgbe_ptp_overflow_check()
713 void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter) in ixgbe_ptp_rx_hang() argument
715 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_rx_hang()
725 adapter->last_rx_ptp_check = jiffies; in ixgbe_ptp_rx_hang()
730 rx_event = adapter->last_rx_ptp_check; in ixgbe_ptp_rx_hang()
731 for (n = 0; n < adapter->num_rx_queues; n++) { in ixgbe_ptp_rx_hang()
732 rx_ring = adapter->rx_ring[n]; in ixgbe_ptp_rx_hang()
740 adapter->last_rx_ptp_check = jiffies; in ixgbe_ptp_rx_hang()
742 adapter->rx_hwtstamp_cleared++; in ixgbe_ptp_rx_hang()
755 static void ixgbe_ptp_clear_tx_timestamp(struct ixgbe_adapter *adapter) in ixgbe_ptp_clear_tx_timestamp() argument
757 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_clear_tx_timestamp()
760 if (adapter->ptp_tx_skb) { in ixgbe_ptp_clear_tx_timestamp()
761 dev_kfree_skb_any(adapter->ptp_tx_skb); in ixgbe_ptp_clear_tx_timestamp()
762 adapter->ptp_tx_skb = NULL; in ixgbe_ptp_clear_tx_timestamp()
764 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_ptp_clear_tx_timestamp()
771 void ixgbe_ptp_tx_hang(struct ixgbe_adapter *adapter) in ixgbe_ptp_tx_hang() argument
773 bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + in ixgbe_ptp_tx_hang()
776 if (!adapter->ptp_tx_skb) in ixgbe_ptp_tx_hang()
779 if (!test_bit(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state)) in ixgbe_ptp_tx_hang()
787 cancel_work_sync(&adapter->ptp_tx_work); in ixgbe_ptp_tx_hang()
788 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_tx_hang()
789 adapter->tx_hwtstamp_timeouts++; in ixgbe_ptp_tx_hang()
802 static void ixgbe_ptp_tx_hwtstamp(struct ixgbe_adapter *adapter) in ixgbe_ptp_tx_hwtstamp() argument
804 struct sk_buff *skb = adapter->ptp_tx_skb; in ixgbe_ptp_tx_hwtstamp()
805 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_tx_hwtstamp()
811 ixgbe_ptp_convert_to_hwtstamp(adapter, &shhwtstamps, regval); in ixgbe_ptp_tx_hwtstamp()
818 adapter->ptp_tx_skb = NULL; in ixgbe_ptp_tx_hwtstamp()
819 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_ptp_tx_hwtstamp()
836 struct ixgbe_adapter *adapter = container_of(work, struct ixgbe_adapter, in ixgbe_ptp_tx_hwtstamp_work() local
838 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_tx_hwtstamp_work()
839 bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + in ixgbe_ptp_tx_hwtstamp_work()
844 if (!adapter->ptp_tx_skb) { in ixgbe_ptp_tx_hwtstamp_work()
845 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_tx_hwtstamp_work()
852 ixgbe_ptp_tx_hwtstamp(adapter); in ixgbe_ptp_tx_hwtstamp_work()
857 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_tx_hwtstamp_work()
858 adapter->tx_hwtstamp_timeouts++; in ixgbe_ptp_tx_hwtstamp_work()
862 schedule_work(&adapter->ptp_tx_work); in ixgbe_ptp_tx_hwtstamp_work()
891 ixgbe_ptp_convert_to_hwtstamp(q_vector->adapter, skb_hwtstamps(skb), in ixgbe_ptp_rx_pktstamp()
907 struct ixgbe_adapter *adapter; in ixgbe_ptp_rx_rgtstamp() local
913 if (!q_vector || !q_vector->adapter) in ixgbe_ptp_rx_rgtstamp()
916 adapter = q_vector->adapter; in ixgbe_ptp_rx_rgtstamp()
917 hw = &adapter->hw; in ixgbe_ptp_rx_rgtstamp()
930 ixgbe_ptp_convert_to_hwtstamp(adapter, skb_hwtstamps(skb), regval); in ixgbe_ptp_rx_rgtstamp()
942 int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) in ixgbe_ptp_get_ts_config() argument
944 struct hwtstamp_config *config = &adapter->tstamp_config; in ixgbe_ptp_get_ts_config()
975 static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter, in ixgbe_ptp_set_timestamp_mode() argument
978 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_set_timestamp_mode()
982 u32 aflags = adapter->flags; in ixgbe_ptp_set_timestamp_mode()
1055 adapter->flags &= ~(IXGBE_FLAG_RX_HWTSTAMP_ENABLED | in ixgbe_ptp_set_timestamp_mode()
1116 adapter->flags = aflags; in ixgbe_ptp_set_timestamp_mode()
1119 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_set_timestamp_mode()
1133 int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr) in ixgbe_ptp_set_ts_config() argument
1141 err = ixgbe_ptp_set_timestamp_mode(adapter, &config); in ixgbe_ptp_set_ts_config()
1146 memcpy(&adapter->tstamp_config, &config, in ixgbe_ptp_set_ts_config()
1147 sizeof(adapter->tstamp_config)); in ixgbe_ptp_set_ts_config()
1153 static void ixgbe_ptp_link_speed_adjust(struct ixgbe_adapter *adapter, in ixgbe_ptp_link_speed_adjust() argument
1170 switch (adapter->link_speed) { in ixgbe_ptp_link_speed_adjust()
1197 void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter) in ixgbe_ptp_start_cyclecounter() argument
1199 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_start_cyclecounter()
1241 ixgbe_ptp_link_speed_adjust(adapter, &cc.shift, &incval); in ixgbe_ptp_start_cyclecounter()
1247 ixgbe_ptp_link_speed_adjust(adapter, &cc.shift, &incval); in ixgbe_ptp_start_cyclecounter()
1259 WRITE_ONCE(adapter->base_incval, incval); in ixgbe_ptp_start_cyclecounter()
1263 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_start_cyclecounter()
1264 memcpy(&adapter->hw_cc, &cc, sizeof(adapter->hw_cc)); in ixgbe_ptp_start_cyclecounter()
1265 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_start_cyclecounter()
1274 static void ixgbe_ptp_init_systime(struct ixgbe_adapter *adapter) in ixgbe_ptp_init_systime() argument
1276 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_init_systime()
1324 void ixgbe_ptp_reset(struct ixgbe_adapter *adapter) in ixgbe_ptp_reset() argument
1326 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_ptp_reset()
1330 ixgbe_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config); in ixgbe_ptp_reset()
1336 ixgbe_ptp_start_cyclecounter(adapter); in ixgbe_ptp_reset()
1338 ixgbe_ptp_init_systime(adapter); in ixgbe_ptp_reset()
1340 spin_lock_irqsave(&adapter->tmreg_lock, flags); in ixgbe_ptp_reset()
1341 timecounter_init(&adapter->hw_tc, &adapter->hw_cc, in ixgbe_ptp_reset()
1343 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in ixgbe_ptp_reset()
1345 adapter->last_overflow_check = jiffies; in ixgbe_ptp_reset()
1350 if (adapter->ptp_setup_sdp) in ixgbe_ptp_reset()
1351 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_reset()
1364 static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter) in ixgbe_ptp_create_clock() argument
1366 struct net_device *netdev = adapter->netdev; in ixgbe_ptp_create_clock()
1370 if (!IS_ERR_OR_NULL(adapter->ptp_clock)) in ixgbe_ptp_create_clock()
1373 switch (adapter->hw.mac.type) { in ixgbe_ptp_create_clock()
1375 snprintf(adapter->ptp_caps.name, in ixgbe_ptp_create_clock()
1376 sizeof(adapter->ptp_caps.name), in ixgbe_ptp_create_clock()
1378 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
1379 adapter->ptp_caps.max_adj = 250000000; in ixgbe_ptp_create_clock()
1380 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
1381 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
1382 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
1383 adapter->ptp_caps.pps = 1; in ixgbe_ptp_create_clock()
1384 adapter->ptp_caps.adjfine = ixgbe_ptp_adjfine_82599; in ixgbe_ptp_create_clock()
1385 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
1386 adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex; in ixgbe_ptp_create_clock()
1387 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
1388 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
1389 adapter->ptp_setup_sdp = ixgbe_ptp_setup_sdp_X540; in ixgbe_ptp_create_clock()
1392 snprintf(adapter->ptp_caps.name, in ixgbe_ptp_create_clock()
1393 sizeof(adapter->ptp_caps.name), in ixgbe_ptp_create_clock()
1395 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
1396 adapter->ptp_caps.max_adj = 250000000; in ixgbe_ptp_create_clock()
1397 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
1398 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
1399 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
1400 adapter->ptp_caps.pps = 0; in ixgbe_ptp_create_clock()
1401 adapter->ptp_caps.adjfine = ixgbe_ptp_adjfine_82599; in ixgbe_ptp_create_clock()
1402 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
1403 adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex; in ixgbe_ptp_create_clock()
1404 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
1405 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
1410 snprintf(adapter->ptp_caps.name, 16, "%s", netdev->name); in ixgbe_ptp_create_clock()
1411 adapter->ptp_caps.owner = THIS_MODULE; in ixgbe_ptp_create_clock()
1412 adapter->ptp_caps.max_adj = 30000000; in ixgbe_ptp_create_clock()
1413 adapter->ptp_caps.n_alarm = 0; in ixgbe_ptp_create_clock()
1414 adapter->ptp_caps.n_ext_ts = 0; in ixgbe_ptp_create_clock()
1415 adapter->ptp_caps.n_per_out = 0; in ixgbe_ptp_create_clock()
1416 adapter->ptp_caps.pps = 1; in ixgbe_ptp_create_clock()
1417 adapter->ptp_caps.adjfine = ixgbe_ptp_adjfine_X550; in ixgbe_ptp_create_clock()
1418 adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; in ixgbe_ptp_create_clock()
1419 adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex; in ixgbe_ptp_create_clock()
1420 adapter->ptp_caps.settime64 = ixgbe_ptp_settime; in ixgbe_ptp_create_clock()
1421 adapter->ptp_caps.enable = ixgbe_ptp_feature_enable; in ixgbe_ptp_create_clock()
1422 adapter->ptp_setup_sdp = ixgbe_ptp_setup_sdp_X550; in ixgbe_ptp_create_clock()
1425 adapter->ptp_clock = NULL; in ixgbe_ptp_create_clock()
1426 adapter->ptp_setup_sdp = NULL; in ixgbe_ptp_create_clock()
1430 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, in ixgbe_ptp_create_clock()
1431 &adapter->pdev->dev); in ixgbe_ptp_create_clock()
1432 if (IS_ERR(adapter->ptp_clock)) { in ixgbe_ptp_create_clock()
1433 err = PTR_ERR(adapter->ptp_clock); in ixgbe_ptp_create_clock()
1434 adapter->ptp_clock = NULL; in ixgbe_ptp_create_clock()
1437 } else if (adapter->ptp_clock) in ixgbe_ptp_create_clock()
1444 adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; in ixgbe_ptp_create_clock()
1445 adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF; in ixgbe_ptp_create_clock()
1458 void ixgbe_ptp_init(struct ixgbe_adapter *adapter) in ixgbe_ptp_init() argument
1464 spin_lock_init(&adapter->tmreg_lock); in ixgbe_ptp_init()
1467 if (ixgbe_ptp_create_clock(adapter)) in ixgbe_ptp_init()
1471 INIT_WORK(&adapter->ptp_tx_work, ixgbe_ptp_tx_hwtstamp_work); in ixgbe_ptp_init()
1474 ixgbe_ptp_reset(adapter); in ixgbe_ptp_init()
1477 set_bit(__IXGBE_PTP_RUNNING, &adapter->state); in ixgbe_ptp_init()
1489 void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter) in ixgbe_ptp_suspend() argument
1492 if (!test_and_clear_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_ptp_suspend()
1495 adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED; in ixgbe_ptp_suspend()
1496 if (adapter->ptp_setup_sdp) in ixgbe_ptp_suspend()
1497 adapter->ptp_setup_sdp(adapter); in ixgbe_ptp_suspend()
1500 cancel_work_sync(&adapter->ptp_tx_work); in ixgbe_ptp_suspend()
1501 ixgbe_ptp_clear_tx_timestamp(adapter); in ixgbe_ptp_suspend()
1511 void ixgbe_ptp_stop(struct ixgbe_adapter *adapter) in ixgbe_ptp_stop() argument
1514 ixgbe_ptp_suspend(adapter); in ixgbe_ptp_stop()
1517 if (adapter->ptp_clock) { in ixgbe_ptp_stop()
1518 ptp_clock_unregister(adapter->ptp_clock); in ixgbe_ptp_stop()
1519 adapter->ptp_clock = NULL; in ixgbe_ptp_stop()
1521 adapter->netdev->name); in ixgbe_ptp_stop()