Lines Matching refs:ptp

350 static int efx_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta);
351 static int efx_phc_adjtime(struct ptp_clock_info *ptp, s64 delta);
352 static int efx_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts);
353 static int efx_phc_settime(struct ptp_clock_info *ptp,
355 static int efx_phc_enable(struct ptp_clock_info *ptp,
559 struct efx_ptp_data *ptp, in efx_ptp_mac_nic_to_ktime_correction() argument
603 kt = ptp->nic_to_kernel_time(nic_major, nic_minor, in efx_ptp_mac_nic_to_ktime_correction()
612 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_nic_to_kernel_time() local
616 kt = efx_ptp_mac_nic_to_ktime_correction(efx, ptp, in efx_ptp_nic_to_kernel_time()
619 ptp->ts_corrections.general_tx); in efx_ptp_nic_to_kernel_time()
621 kt = ptp->nic_to_kernel_time( in efx_ptp_nic_to_kernel_time()
624 ptp->ts_corrections.general_tx); in efx_ptp_nic_to_kernel_time()
633 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_get_attributes() local
661 ptp->ns_to_nic_time = efx_ptp_ns_to_s27; in efx_ptp_get_attributes()
662 ptp->nic_to_kernel_time = efx_ptp_s27_to_ktime_correction; in efx_ptp_get_attributes()
663 ptp->nic_time.minor_max = 1 << 27; in efx_ptp_get_attributes()
664 ptp->nic_time.sync_event_minor_shift = 19; in efx_ptp_get_attributes()
667 ptp->ns_to_nic_time = efx_ptp_ns_to_s_ns; in efx_ptp_get_attributes()
668 ptp->nic_to_kernel_time = efx_ptp_s_ns_to_ktime_correction; in efx_ptp_get_attributes()
669 ptp->nic_time.minor_max = 1000000000; in efx_ptp_get_attributes()
670 ptp->nic_time.sync_event_minor_shift = 22; in efx_ptp_get_attributes()
673 ptp->ns_to_nic_time = efx_ptp_ns_to_s_qns; in efx_ptp_get_attributes()
674 ptp->nic_to_kernel_time = efx_ptp_s_qns_to_ktime_correction; in efx_ptp_get_attributes()
675 ptp->nic_time.minor_max = 4000000000UL; in efx_ptp_get_attributes()
676 ptp->nic_time.sync_event_minor_shift = 24; in efx_ptp_get_attributes()
688 ptp->nic_time.sync_event_diff_min = ptp->nic_time.minor_max in efx_ptp_get_attributes()
689 - (ptp->nic_time.minor_max / 10); in efx_ptp_get_attributes()
690 ptp->nic_time.sync_event_diff_max = (ptp->nic_time.minor_max / 4) in efx_ptp_get_attributes()
691 + (ptp->nic_time.minor_max / 10); in efx_ptp_get_attributes()
702 ptp->min_synchronisation_ns = in efx_ptp_get_attributes()
706 ptp->min_synchronisation_ns = DEFAULT_MIN_SYNCHRONISATION_NS; in efx_ptp_get_attributes()
710 ptp->capabilities = MCDI_DWORD(outbuf, in efx_ptp_get_attributes()
713 ptp->capabilities = 0; in efx_ptp_get_attributes()
719 if (ptp->capabilities & (1 << MC_CMD_PTP_OUT_GET_ATTRIBUTES_FP44_FREQ_ADJ_LBN)) in efx_ptp_get_attributes()
720 ptp->adjfreq_ppb_shift = PPB_SHIFT_FP44; in efx_ptp_get_attributes()
722 ptp->adjfreq_ppb_shift = PPB_SHIFT_FP40; in efx_ptp_get_attributes()
861 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_send_times() local
862 int *mc_running = ptp->start.addr; in efx_ptp_send_times()
932 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_process_times() local
954 &ptp->timeset[i]); in efx_ptp_process_times()
957 ptp->nic_to_kernel_time(0, ptp->timeset[i].wait, 0)); in efx_ptp_process_times()
958 window = ptp->timeset[i].window; in efx_ptp_process_times()
971 ++ptp->invalid_sync_windows; in efx_ptp_process_times()
973 ++ptp->oversize_sync_windows; in efx_ptp_process_times()
974 } else if (corrected < ptp->min_synchronisation_ns) { in efx_ptp_process_times()
975 ++ptp->undersize_sync_windows; in efx_ptp_process_times()
994 start_sec = ptp->timeset[last_good].host_start >> MC_NANOSECOND_BITS; in efx_ptp_process_times()
1005 (ptp->timeset[last_good].host_start & MC_NANOSECOND_MASK); in efx_ptp_process_times()
1011 mc_time = ptp->nic_to_kernel_time(ptp->timeset[last_good].major, in efx_ptp_process_times()
1012 ptp->timeset[last_good].minor, 0); in efx_ptp_process_times()
1018 ptp->host_time_pps = *last_time; in efx_ptp_process_times()
1019 pps_sub_ts(&ptp->host_time_pps, delta); in efx_ptp_process_times()
1027 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_synchronize() local
1034 int *start = ptp->start.addr; in efx_ptp_synchronize()
1041 ptp->start.dma_addr); in efx_ptp_synchronize()
1057 ++ptp->fast_syncs; in efx_ptp_synchronize()
1059 ++ptp->sync_timeouts; in efx_ptp_synchronize()
1073 ++ptp->good_syncs; in efx_ptp_synchronize()
1075 ++ptp->no_time_syncs; in efx_ptp_synchronize()
1082 ++ptp->bad_syncs; in efx_ptp_synchronize()
1154 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_drop_time_expired_events() local
1158 if (ptp->rx_ts_inline) in efx_ptp_drop_time_expired_events()
1162 spin_lock_bh(&ptp->evt_lock); in efx_ptp_drop_time_expired_events()
1163 list_for_each_safe(cursor, next, &ptp->evt_list) { in efx_ptp_drop_time_expired_events()
1169 list_move(&evt->link, &ptp->evt_free_list); in efx_ptp_drop_time_expired_events()
1174 spin_unlock_bh(&ptp->evt_lock); in efx_ptp_drop_time_expired_events()
1180 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_match_rx() local
1187 WARN_ON_ONCE(ptp->rx_ts_inline); in efx_ptp_match_rx()
1189 spin_lock_bh(&ptp->evt_lock); in efx_ptp_match_rx()
1190 evts_waiting = !list_empty(&ptp->evt_list); in efx_ptp_match_rx()
1191 spin_unlock_bh(&ptp->evt_lock); in efx_ptp_match_rx()
1198 spin_lock_bh(&ptp->evt_lock); in efx_ptp_match_rx()
1199 list_for_each_safe(cursor, next, &ptp->evt_list) { in efx_ptp_match_rx()
1213 list_move(&evt->link, &ptp->evt_free_list); in efx_ptp_match_rx()
1217 spin_unlock_bh(&ptp->evt_lock); in efx_ptp_match_rx()
1228 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_process_events() local
1231 while ((skb = skb_dequeue(&ptp->rxq))) { in efx_ptp_process_events()
1242 ++ptp->rx_no_timestamp; in efx_ptp_process_events()
1246 skb_queue_head(&ptp->rxq, skb); in efx_ptp_process_events()
1262 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_remove_multicast_filters() local
1264 if (ptp->rxfilter_installed) { in efx_ptp_remove_multicast_filters()
1266 ptp->rxfilter_general); in efx_ptp_remove_multicast_filters()
1268 ptp->rxfilter_event); in efx_ptp_remove_multicast_filters()
1269 ptp->rxfilter_installed = false; in efx_ptp_remove_multicast_filters()
1275 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_insert_multicast_filters() local
1279 if (!ptp->channel || ptp->rxfilter_installed) in efx_ptp_insert_multicast_filters()
1287 efx_channel_get_rx_queue(ptp->channel))); in efx_ptp_insert_multicast_filters()
1297 ptp->rxfilter_event = rc; in efx_ptp_insert_multicast_filters()
1301 efx_channel_get_rx_queue(ptp->channel))); in efx_ptp_insert_multicast_filters()
1311 ptp->rxfilter_general = rc; in efx_ptp_insert_multicast_filters()
1313 ptp->rxfilter_installed = true; in efx_ptp_insert_multicast_filters()
1318 ptp->rxfilter_event); in efx_ptp_insert_multicast_filters()
1324 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_start() local
1327 ptp->reset_required = false; in efx_ptp_start()
1337 ptp->evt_frag_idx = 0; in efx_ptp_start()
1338 ptp->current_adjfreq = 0; in efx_ptp_start()
1349 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_stop() local
1354 if (ptp == NULL) in efx_ptp_stop()
1384 struct efx_ptp_data *ptp = in efx_ptp_pps_worker() local
1386 struct efx_nic *efx = ptp->efx; in efx_ptp_pps_worker()
1393 ptp_evt.pps_times = ptp->host_time_pps; in efx_ptp_pps_worker()
1394 ptp_clock_event(ptp->phc_clock, &ptp_evt); in efx_ptp_pps_worker()
1442 struct efx_ptp_data *ptp; in efx_ptp_probe() local
1446 ptp = kzalloc(sizeof(struct efx_ptp_data), GFP_KERNEL); in efx_ptp_probe()
1447 efx->ptp_data = ptp; in efx_ptp_probe()
1451 ptp->efx = efx; in efx_ptp_probe()
1452 ptp->channel = channel; in efx_ptp_probe()
1453 ptp->rx_ts_inline = efx_nic_rev(efx) >= EFX_REV_HUNT_A0; in efx_ptp_probe()
1455 rc = efx_nic_alloc_buffer(efx, &ptp->start, sizeof(int), GFP_KERNEL); in efx_ptp_probe()
1459 skb_queue_head_init(&ptp->rxq); in efx_ptp_probe()
1460 skb_queue_head_init(&ptp->txq); in efx_ptp_probe()
1461 ptp->workwq = create_singlethread_workqueue("sfc_ptp"); in efx_ptp_probe()
1462 if (!ptp->workwq) { in efx_ptp_probe()
1468 ptp->xmit_skb = efx_ptp_xmit_skb_queue; in efx_ptp_probe()
1472 ptp->xmit_skb = efx_ptp_xmit_skb_mc; in efx_ptp_probe()
1475 INIT_WORK(&ptp->work, efx_ptp_worker); in efx_ptp_probe()
1476 ptp->config.flags = 0; in efx_ptp_probe()
1477 ptp->config.tx_type = HWTSTAMP_TX_OFF; in efx_ptp_probe()
1478 ptp->config.rx_filter = HWTSTAMP_FILTER_NONE; in efx_ptp_probe()
1479 INIT_LIST_HEAD(&ptp->evt_list); in efx_ptp_probe()
1480 INIT_LIST_HEAD(&ptp->evt_free_list); in efx_ptp_probe()
1481 spin_lock_init(&ptp->evt_lock); in efx_ptp_probe()
1483 list_add(&ptp->rx_evts[pos].link, &ptp->evt_free_list); in efx_ptp_probe()
1497 ptp->phc_clock_info = efx_phc_clock_info; in efx_ptp_probe()
1498 ptp->phc_clock = ptp_clock_register(&ptp->phc_clock_info, in efx_ptp_probe()
1500 if (IS_ERR(ptp->phc_clock)) { in efx_ptp_probe()
1501 rc = PTR_ERR(ptp->phc_clock); in efx_ptp_probe()
1503 } else if (ptp->phc_clock) { in efx_ptp_probe()
1504 INIT_WORK(&ptp->pps_work, efx_ptp_pps_worker); in efx_ptp_probe()
1505 ptp->pps_workwq = create_singlethread_workqueue("sfc_pps"); in efx_ptp_probe()
1506 if (!ptp->pps_workwq) { in efx_ptp_probe()
1512 ptp->nic_ts_enabled = false; in efx_ptp_probe()
1522 efx_nic_free_buffer(efx, &ptp->start); in efx_ptp_probe()
1618 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_rx() local
1627 if (ptp->mode == MC_CMD_PTP_MODE_V1) { in efx_ptp_rx()
1660 if (ptp->mode == MC_CMD_PTP_MODE_V2) { in efx_ptp_rx()
1664 BUG_ON(ptp->mode != MC_CMD_PTP_MODE_V2_ENHANCED); in efx_ptp_rx()
1692 skb_queue_tail(&ptp->rxq, skb); in efx_ptp_rx()
1693 queue_work(ptp->workwq, &ptp->work); in efx_ptp_rx()
1704 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_tx() local
1706 skb_queue_tail(&ptp->txq, skb); in efx_ptp_tx()
1711 queue_work(ptp->workwq, &ptp->work); in efx_ptp_tx()
1785 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_get_ts_info() local
1790 if (!ptp) in efx_ptp_get_ts_info()
1811 ts_info->rx_filters = ptp->efx->type->hwtstamp_filters; in efx_ptp_get_ts_info()
1845 struct efx_ptp_data *ptp = efx->ptp_data; in ptp_event_failure() local
1849 ptp->evt_frag_idx, expected_frag_len); in ptp_event_failure()
1850 ptp->reset_required = true; in ptp_event_failure()
1851 queue_work(ptp->workwq, &ptp->work); in ptp_event_failure()
1858 static void ptp_event_rx(struct efx_nic *efx, struct efx_ptp_data *ptp) in ptp_event_rx() argument
1862 if (WARN_ON_ONCE(ptp->rx_ts_inline)) in ptp_event_rx()
1865 if (ptp->evt_frag_idx != 3) { in ptp_event_rx()
1870 spin_lock_bh(&ptp->evt_lock); in ptp_event_rx()
1871 if (!list_empty(&ptp->evt_free_list)) { in ptp_event_rx()
1872 evt = list_first_entry(&ptp->evt_free_list, in ptp_event_rx()
1876 evt->seq0 = EFX_QWORD_FIELD(ptp->evt_frags[2], MCDI_EVENT_DATA); in ptp_event_rx()
1877 evt->seq1 = (EFX_QWORD_FIELD(ptp->evt_frags[2], in ptp_event_rx()
1879 (EFX_QWORD_FIELD(ptp->evt_frags[1], in ptp_event_rx()
1881 (EFX_QWORD_FIELD(ptp->evt_frags[0], in ptp_event_rx()
1884 EFX_QWORD_FIELD(ptp->evt_frags[0], MCDI_EVENT_DATA), in ptp_event_rx()
1885 EFX_QWORD_FIELD(ptp->evt_frags[1], MCDI_EVENT_DATA), in ptp_event_rx()
1886 ptp->ts_corrections.ptp_rx); in ptp_event_rx()
1888 list_add_tail(&evt->link, &ptp->evt_list); in ptp_event_rx()
1890 queue_work(ptp->workwq, &ptp->work); in ptp_event_rx()
1895 spin_unlock_bh(&ptp->evt_lock); in ptp_event_rx()
1898 static void ptp_event_fault(struct efx_nic *efx, struct efx_ptp_data *ptp) in ptp_event_fault() argument
1900 int code = EFX_QWORD_FIELD(ptp->evt_frags[0], MCDI_EVENT_DATA); in ptp_event_fault()
1901 if (ptp->evt_frag_idx != 1) { in ptp_event_fault()
1909 static void ptp_event_pps(struct efx_nic *efx, struct efx_ptp_data *ptp) in ptp_event_pps() argument
1911 if (ptp->nic_ts_enabled) in ptp_event_pps()
1912 queue_work(ptp->pps_workwq, &ptp->pps_work); in ptp_event_pps()
1917 struct efx_ptp_data *ptp = efx->ptp_data; in efx_ptp_event() local
1920 if (!ptp) { in efx_ptp_event()
1929 if (!ptp->enabled) in efx_ptp_event()
1932 if (ptp->evt_frag_idx == 0) { in efx_ptp_event()
1933 ptp->evt_code = code; in efx_ptp_event()
1934 } else if (ptp->evt_code != code) { in efx_ptp_event()
1937 ptp->evt_frag_idx = 0; in efx_ptp_event()
1940 ptp->evt_frags[ptp->evt_frag_idx++] = *ev; in efx_ptp_event()
1945 ptp_event_rx(efx, ptp); in efx_ptp_event()
1948 ptp_event_fault(efx, ptp); in efx_ptp_event()
1951 ptp_event_pps(efx, ptp); in efx_ptp_event()
1958 ptp->evt_frag_idx = 0; in efx_ptp_event()
1959 } else if (MAX_EVENT_FRAGS == ptp->evt_frag_idx) { in efx_ptp_event()
1962 ptp->evt_frag_idx = 0; in efx_ptp_event()
1969 struct efx_ptp_data *ptp = efx->ptp_data; in efx_time_sync_event() local
1980 << ptp->nic_time.sync_event_minor_shift; in efx_time_sync_event()
2006 struct efx_ptp_data *ptp = efx->ptp_data; in __efx_rx_skb_attach_timestamp() local
2021 diff += ptp->nic_time.minor_max; in __efx_rx_skb_attach_timestamp()
2024 carry = (channel->sync_timestamp_minor >= ptp->nic_time.minor_max - diff) ? in __efx_rx_skb_attach_timestamp()
2027 if (diff <= ptp->nic_time.sync_event_diff_max) { in __efx_rx_skb_attach_timestamp()
2032 } else if (diff >= ptp->nic_time.sync_event_diff_min) { in __efx_rx_skb_attach_timestamp()
2054 ptp->nic_to_kernel_time(pkt_timestamp_major, in __efx_rx_skb_attach_timestamp()
2056 ptp->ts_corrections.general_rx); in __efx_rx_skb_attach_timestamp()
2059 static int efx_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta) in efx_phc_adjfreq() argument
2061 struct efx_ptp_data *ptp_data = container_of(ptp, in efx_phc_adjfreq()
2093 static int efx_phc_adjtime(struct ptp_clock_info *ptp, s64 delta) in efx_phc_adjtime() argument
2096 struct efx_ptp_data *ptp_data = container_of(ptp, in efx_phc_adjtime()
2113 static int efx_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) in efx_phc_gettime() argument
2115 struct efx_ptp_data *ptp_data = container_of(ptp, in efx_phc_gettime()
2139 static int efx_phc_settime(struct ptp_clock_info *ptp, in efx_phc_settime() argument
2150 rc = efx_phc_gettime(ptp, &time_now); in efx_phc_settime()
2156 rc = efx_phc_adjtime(ptp, timespec64_to_ns(&delta)); in efx_phc_settime()
2163 static int efx_phc_enable(struct ptp_clock_info *ptp, in efx_phc_enable() argument
2167 struct efx_ptp_data *ptp_data = container_of(ptp, in efx_phc_enable()