Lines Matching refs:ptp
47 #include "nic.h" /* indirectly includes ptp.h */
348 static int efx_phc_adjfine(struct ptp_clock_info *ptp, long scaled_ppm);
349 static int efx_phc_adjtime(struct ptp_clock_info *ptp, s64 delta);
350 static int efx_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts);
351 static int efx_phc_settime(struct ptp_clock_info *ptp,
353 static int efx_phc_enable(struct ptp_clock_info *ptp,
546 struct efx_ptp_data *ptp,
590 kt = ptp->nic_to_kernel_time(nic_major, nic_minor,
599 struct efx_ptp_data *ptp = efx->ptp_data;
603 kt = efx_ptp_mac_nic_to_ktime_correction(efx, ptp,
606 ptp->ts_corrections.general_tx);
608 kt = ptp->nic_to_kernel_time(
611 ptp->ts_corrections.general_tx);
620 struct efx_ptp_data *ptp = efx->ptp_data;
648 ptp->ns_to_nic_time = efx_ptp_ns_to_s27;
649 ptp->nic_to_kernel_time = efx_ptp_s27_to_ktime_correction;
650 ptp->nic_time.minor_max = 1 << 27;
651 ptp->nic_time.sync_event_minor_shift = 19;
654 ptp->ns_to_nic_time = efx_ptp_ns_to_s_qns;
655 ptp->nic_to_kernel_time = efx_ptp_s_qns_to_ktime_correction;
656 ptp->nic_time.minor_max = 4000000000UL;
657 ptp->nic_time.sync_event_minor_shift = 24;
669 ptp->nic_time.sync_event_diff_min = ptp->nic_time.minor_max
670 - (ptp->nic_time.minor_max / 10);
671 ptp->nic_time.sync_event_diff_max = (ptp->nic_time.minor_max / 4)
672 + (ptp->nic_time.minor_max / 10);
683 ptp->min_synchronisation_ns =
687 ptp->min_synchronisation_ns = DEFAULT_MIN_SYNCHRONISATION_NS;
691 ptp->capabilities = MCDI_DWORD(outbuf,
694 ptp->capabilities = 0;
700 if (ptp->capabilities & (1 << MC_CMD_PTP_OUT_GET_ATTRIBUTES_FP44_FREQ_ADJ_LBN))
701 ptp->adjfreq_ppb_shift = PPB_SHIFT_FP44;
703 ptp->adjfreq_ppb_shift = PPB_SHIFT_FP40;
842 struct efx_ptp_data *ptp = efx->ptp_data;
843 int *mc_running = ptp->start.addr;
913 struct efx_ptp_data *ptp = efx->ptp_data;
935 &ptp->timeset[i]);
938 ptp->nic_to_kernel_time(0, ptp->timeset[i].wait, 0));
939 window = ptp->timeset[i].window;
952 ++ptp->invalid_sync_windows;
954 ++ptp->oversize_sync_windows;
955 } else if (corrected < ptp->min_synchronisation_ns) {
956 ++ptp->undersize_sync_windows;
975 start_sec = ptp->timeset[last_good].host_start >> MC_NANOSECOND_BITS;
986 (ptp->timeset[last_good].host_start & MC_NANOSECOND_MASK);
992 mc_time = ptp->nic_to_kernel_time(ptp->timeset[last_good].major,
993 ptp->timeset[last_good].minor, 0);
999 ptp->host_time_pps = *last_time;
1000 pps_sub_ts(&ptp->host_time_pps, delta);
1008 struct efx_ptp_data *ptp = efx->ptp_data;
1015 int *start = ptp->start.addr;
1022 ptp->start.dma_addr);
1038 ++ptp->fast_syncs;
1040 ++ptp->sync_timeouts;
1054 ++ptp->good_syncs;
1056 ++ptp->no_time_syncs;
1063 ++ptp->bad_syncs;
1173 struct efx_ptp_data *ptp = efx->ptp_data;
1176 while ((skb = skb_dequeue(&ptp->rxq))) {
1184 ++ptp->rx_no_timestamp;
1188 skb_queue_head(&ptp->rxq, skb);
1250 struct efx_ptp_data *ptp = efx->ptp_data;
1275 queue_delayed_work(ptp->workwq, &ptp->cleanup_work,
1311 struct efx_ptp_data *ptp = efx->ptp_data;
1319 return efx_ptp_insert_filter(efx, &ptp->rxfilters_mcast, &spec, 0);
1324 struct efx_ptp_data *ptp = efx->ptp_data;
1327 if (!ptp->channel || !list_empty(&ptp->rxfilters_mcast))
1333 rc = efx_ptp_insert_ipv4_filter(efx, &ptp->rxfilters_mcast,
1339 rc = efx_ptp_insert_ipv4_filter(efx, &ptp->rxfilters_mcast,
1351 rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_mcast,
1356 rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_mcast,
1371 efx_ptp_remove_filters(efx, &ptp->rxfilters_mcast);
1394 struct efx_ptp_data *ptp = efx->ptp_data;
1406 rc = efx_ptp_insert_ipv4_filter(efx, &ptp->rxfilters_ucast,
1411 rc = efx_ptp_insert_ipv4_filter(efx, &ptp->rxfilters_ucast,
1417 rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_ucast,
1422 rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_ucast,
1434 struct efx_ptp_data *ptp = efx->ptp_data;
1437 ptp->reset_required = false;
1447 ptp->evt_frag_idx = 0;
1448 ptp->current_adjfreq = 0;
1453 efx_ptp_remove_filters(efx, &ptp->rxfilters_mcast);
1459 struct efx_ptp_data *ptp = efx->ptp_data;
1462 if (ptp == NULL)
1467 efx_ptp_remove_filters(efx, &ptp->rxfilters_mcast);
1468 efx_ptp_remove_filters(efx, &ptp->rxfilters_ucast);
1486 struct efx_ptp_data *ptp =
1488 struct efx_nic *efx = ptp->efx;
1495 ptp_evt.pps_times = ptp->host_time_pps;
1496 ptp_clock_event(ptp->phc_clock, &ptp_evt);
1525 struct efx_ptp_data *ptp =
1529 list_for_each_entry_safe(rxfilter, tmp, &ptp->rxfilters_ucast, list) {
1531 efx_ptp_remove_one_filter(ptp->efx, rxfilter);
1534 if (!list_empty(&ptp->rxfilters_ucast)) {
1535 queue_delayed_work(ptp->workwq, &ptp->cleanup_work,
1559 struct efx_ptp_data *ptp;
1567 ptp = kzalloc(sizeof(struct efx_ptp_data), GFP_KERNEL);
1568 efx->ptp_data = ptp;
1572 ptp->efx = efx;
1573 ptp->channel = channel;
1575 rc = efx_nic_alloc_buffer(efx, &ptp->start, sizeof(int), GFP_KERNEL);
1579 skb_queue_head_init(&ptp->rxq);
1580 skb_queue_head_init(&ptp->txq);
1581 ptp->workwq = create_singlethread_workqueue("sfc_ptp");
1582 if (!ptp->workwq) {
1588 ptp->xmit_skb = efx_ptp_xmit_skb_queue;
1592 ptp->xmit_skb = efx_ptp_xmit_skb_mc;
1595 INIT_WORK(&ptp->work, efx_ptp_worker);
1596 INIT_DELAYED_WORK(&ptp->cleanup_work, efx_ptp_cleanup_worker);
1597 ptp->config.flags = 0;
1598 ptp->config.tx_type = HWTSTAMP_TX_OFF;
1599 ptp->config.rx_filter = HWTSTAMP_FILTER_NONE;
1600 INIT_LIST_HEAD(&ptp->rxfilters_mcast);
1601 INIT_LIST_HEAD(&ptp->rxfilters_ucast);
1615 ptp->phc_clock_info = efx_phc_clock_info;
1616 ptp->phc_clock = ptp_clock_register(&ptp->phc_clock_info,
1618 if (IS_ERR(ptp->phc_clock)) {
1619 rc = PTR_ERR(ptp->phc_clock);
1621 } else if (ptp->phc_clock) {
1622 INIT_WORK(&ptp->pps_work, efx_ptp_pps_worker);
1623 ptp->pps_workwq = create_singlethread_workqueue("sfc_pps");
1624 if (!ptp->pps_workwq) {
1630 ptp->nic_ts_enabled = false;
1640 efx_nic_free_buffer(efx, &ptp->start);
1652 * overlap with 'rxq0' because ptp.c doesn't use skb_record_rx_queue.
1709 snprintf(buf, len, "%s-ptp", channel->efx->name);
1737 struct efx_ptp_data *ptp = efx->ptp_data;
1745 if (ptp->mode == MC_CMD_PTP_MODE_V1) {
1778 skb_queue_tail(&ptp->rxq, skb);
1779 queue_work(ptp->workwq, &ptp->work);
1790 struct efx_ptp_data *ptp = efx->ptp_data;
1792 skb_queue_tail(&ptp->txq, skb);
1797 queue_work(ptp->workwq, &ptp->work);
1868 struct efx_ptp_data *ptp = efx->ptp_data;
1873 if (!ptp)
1894 ts_info->rx_filters = ptp->efx->type->hwtstamp_filters;
1928 struct efx_ptp_data *ptp = efx->ptp_data;
1932 ptp->evt_frag_idx, expected_frag_len);
1933 ptp->reset_required = true;
1934 queue_work(ptp->workwq, &ptp->work);
1937 static void ptp_event_fault(struct efx_nic *efx, struct efx_ptp_data *ptp)
1939 int code = EFX_QWORD_FIELD(ptp->evt_frags[0], MCDI_EVENT_DATA);
1940 if (ptp->evt_frag_idx != 1) {
1948 static void ptp_event_pps(struct efx_nic *efx, struct efx_ptp_data *ptp)
1950 if (ptp->nic_ts_enabled)
1951 queue_work(ptp->pps_workwq, &ptp->pps_work);
1956 struct efx_ptp_data *ptp = efx->ptp_data;
1959 if (!ptp) {
1968 if (!ptp->enabled)
1971 if (ptp->evt_frag_idx == 0) {
1972 ptp->evt_code = code;
1973 } else if (ptp->evt_code != code) {
1976 ptp->evt_frag_idx = 0;
1979 ptp->evt_frags[ptp->evt_frag_idx++] = *ev;
1984 ptp_event_fault(efx, ptp);
1987 ptp_event_pps(efx, ptp);
1994 ptp->evt_frag_idx = 0;
1995 } else if (MAX_EVENT_FRAGS == ptp->evt_frag_idx) {
1998 ptp->evt_frag_idx = 0;
2005 struct efx_ptp_data *ptp = efx->ptp_data;
2016 << ptp->nic_time.sync_event_minor_shift;
2042 struct efx_ptp_data *ptp = efx->ptp_data;
2057 diff += ptp->nic_time.minor_max;
2060 carry = (channel->sync_timestamp_minor >= ptp->nic_time.minor_max - diff) ?
2063 if (diff <= ptp->nic_time.sync_event_diff_max) {
2068 } else if (diff >= ptp->nic_time.sync_event_diff_min) {
2090 ptp->nic_to_kernel_time(pkt_timestamp_major,
2092 ptp->ts_corrections.general_rx);
2095 static int efx_phc_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
2097 struct efx_ptp_data *ptp_data = container_of(ptp,
2130 static int efx_phc_adjtime(struct ptp_clock_info *ptp, s64 delta)
2133 struct efx_ptp_data *ptp_data = container_of(ptp,
2150 static int efx_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
2152 struct efx_ptp_data *ptp_data = container_of(ptp,
2176 static int efx_phc_settime(struct ptp_clock_info *ptp,
2187 rc = efx_phc_gettime(ptp, &time_now);
2193 rc = efx_phc_adjtime(ptp, timespec64_to_ns(&delta));
2200 static int efx_phc_enable(struct ptp_clock_info *ptp,
2204 struct efx_ptp_data *ptp_data = container_of(ptp,