Lines Matching refs:ptp
40 struct qede_ptp *ptp = container_of(info, struct qede_ptp, clock_info); in qede_ptp_adjfreq() local
41 struct qede_dev *edev = ptp->edev; in qede_ptp_adjfreq()
46 spin_lock_bh(&ptp->lock); in qede_ptp_adjfreq()
47 rc = ptp->ops->adjfreq(edev->cdev, ppb); in qede_ptp_adjfreq()
48 spin_unlock_bh(&ptp->lock); in qede_ptp_adjfreq()
61 struct qede_ptp *ptp; in qede_ptp_adjtime() local
63 ptp = container_of(info, struct qede_ptp, clock_info); in qede_ptp_adjtime()
64 edev = ptp->edev; in qede_ptp_adjtime()
69 spin_lock_bh(&ptp->lock); in qede_ptp_adjtime()
70 timecounter_adjtime(&ptp->tc, delta); in qede_ptp_adjtime()
71 spin_unlock_bh(&ptp->lock); in qede_ptp_adjtime()
79 struct qede_ptp *ptp; in qede_ptp_gettime() local
82 ptp = container_of(info, struct qede_ptp, clock_info); in qede_ptp_gettime()
83 edev = ptp->edev; in qede_ptp_gettime()
85 spin_lock_bh(&ptp->lock); in qede_ptp_gettime()
86 ns = timecounter_read(&ptp->tc); in qede_ptp_gettime()
87 spin_unlock_bh(&ptp->lock); in qede_ptp_gettime()
100 struct qede_ptp *ptp; in qede_ptp_settime() local
103 ptp = container_of(info, struct qede_ptp, clock_info); in qede_ptp_settime()
104 edev = ptp->edev; in qede_ptp_settime()
111 spin_lock_bh(&ptp->lock); in qede_ptp_settime()
112 timecounter_init(&ptp->tc, &ptp->cc, ns); in qede_ptp_settime()
113 spin_unlock_bh(&ptp->lock); in qede_ptp_settime()
124 struct qede_ptp *ptp; in qede_ptp_ancillary_feature_enable() local
126 ptp = container_of(info, struct qede_ptp, clock_info); in qede_ptp_ancillary_feature_enable()
127 edev = ptp->edev; in qede_ptp_ancillary_feature_enable()
138 struct qede_ptp *ptp; in qede_ptp_task() local
143 ptp = container_of(work, struct qede_ptp, work); in qede_ptp_task()
144 edev = ptp->edev; in qede_ptp_task()
145 timedout = time_is_before_jiffies(ptp->ptp_tx_start + in qede_ptp_task()
149 spin_lock_bh(&ptp->lock); in qede_ptp_task()
150 rc = ptp->ops->read_tx_ts(edev->cdev, ×tamp); in qede_ptp_task()
151 spin_unlock_bh(&ptp->lock); in qede_ptp_task()
155 dev_kfree_skb_any(ptp->tx_skb); in qede_ptp_task()
156 ptp->tx_skb = NULL; in qede_ptp_task()
162 schedule_work(&ptp->work); in qede_ptp_task()
167 ns = timecounter_cyc2time(&ptp->tc, timestamp); in qede_ptp_task()
170 skb_tstamp_tx(ptp->tx_skb, &shhwtstamps); in qede_ptp_task()
171 dev_kfree_skb_any(ptp->tx_skb); in qede_ptp_task()
172 ptp->tx_skb = NULL; in qede_ptp_task()
184 struct qede_ptp *ptp; in qede_ptp_read_cc() local
188 ptp = container_of(cc, struct qede_ptp, cc); in qede_ptp_read_cc()
189 edev = ptp->edev; in qede_ptp_read_cc()
190 rc = ptp->ops->read_cc(edev->cdev, &phc_cycles); in qede_ptp_read_cc()
203 struct qede_ptp *ptp = edev->ptp; in qede_ptp_cfg_filters() local
205 if (!ptp) in qede_ptp_cfg_filters()
208 if (!ptp->hw_ts_ioctl_called) { in qede_ptp_cfg_filters()
213 switch (ptp->tx_type) { in qede_ptp_cfg_filters()
230 spin_lock_bh(&ptp->lock); in qede_ptp_cfg_filters()
231 switch (ptp->rx_filter) { in qede_ptp_cfg_filters()
238 ptp->rx_filter = HWTSTAMP_FILTER_NONE; in qede_ptp_cfg_filters()
242 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; in qede_ptp_cfg_filters()
247 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; in qede_ptp_cfg_filters()
252 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; in qede_ptp_cfg_filters()
257 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; in qede_ptp_cfg_filters()
262 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; in qede_ptp_cfg_filters()
267 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; in qede_ptp_cfg_filters()
272 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in qede_ptp_cfg_filters()
277 ptp->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in qede_ptp_cfg_filters()
283 ptp->ops->cfg_filters(edev->cdev, rx_filter, tx_type); in qede_ptp_cfg_filters()
285 spin_unlock_bh(&ptp->lock); in qede_ptp_cfg_filters()
293 struct qede_ptp *ptp; in qede_ptp_hw_ts() local
296 ptp = edev->ptp; in qede_ptp_hw_ts()
297 if (!ptp) in qede_ptp_hw_ts()
307 ptp->hw_ts_ioctl_called = 1; in qede_ptp_hw_ts()
308 ptp->tx_type = config.tx_type; in qede_ptp_hw_ts()
309 ptp->rx_filter = config.rx_filter; in qede_ptp_hw_ts()
315 config.rx_filter = ptp->rx_filter; in qede_ptp_hw_ts()
323 struct qede_ptp *ptp = edev->ptp; in qede_ptp_get_ts_info() local
325 if (!ptp) { in qede_ptp_get_ts_info()
341 if (ptp->clock) in qede_ptp_get_ts_info()
342 info->phc_index = ptp_clock_index(ptp->clock); in qede_ptp_get_ts_info()
367 struct qede_ptp *ptp; in qede_ptp_disable() local
369 ptp = edev->ptp; in qede_ptp_disable()
370 if (!ptp) in qede_ptp_disable()
373 if (ptp->clock) { in qede_ptp_disable()
374 ptp_clock_unregister(ptp->clock); in qede_ptp_disable()
375 ptp->clock = NULL; in qede_ptp_disable()
381 cancel_work_sync(&ptp->work); in qede_ptp_disable()
382 if (ptp->tx_skb) { in qede_ptp_disable()
383 dev_kfree_skb_any(ptp->tx_skb); in qede_ptp_disable()
384 ptp->tx_skb = NULL; in qede_ptp_disable()
389 spin_lock_bh(&ptp->lock); in qede_ptp_disable()
390 ptp->ops->disable(edev->cdev); in qede_ptp_disable()
391 spin_unlock_bh(&ptp->lock); in qede_ptp_disable()
393 kfree(ptp); in qede_ptp_disable()
394 edev->ptp = NULL; in qede_ptp_disable()
399 struct qede_ptp *ptp; in qede_ptp_init() local
402 ptp = edev->ptp; in qede_ptp_init()
403 if (!ptp) in qede_ptp_init()
406 spin_lock_init(&ptp->lock); in qede_ptp_init()
409 rc = ptp->ops->enable(edev->cdev); in qede_ptp_init()
416 INIT_WORK(&ptp->work, qede_ptp_task); in qede_ptp_init()
419 memset(&ptp->cc, 0, sizeof(ptp->cc)); in qede_ptp_init()
420 ptp->cc.read = qede_ptp_read_cc; in qede_ptp_init()
421 ptp->cc.mask = CYCLECOUNTER_MASK(64); in qede_ptp_init()
422 ptp->cc.shift = 0; in qede_ptp_init()
423 ptp->cc.mult = 1; in qede_ptp_init()
425 timecounter_init(&ptp->tc, &ptp->cc, ktime_to_ns(ktime_get_real())); in qede_ptp_init()
432 struct qede_ptp *ptp; in qede_ptp_enable() local
435 ptp = kzalloc(sizeof(*ptp), GFP_KERNEL); in qede_ptp_enable()
436 if (!ptp) { in qede_ptp_enable()
441 ptp->edev = edev; in qede_ptp_enable()
442 ptp->ops = edev->ops->ptp; in qede_ptp_enable()
443 if (!ptp->ops) { in qede_ptp_enable()
449 edev->ptp = ptp; in qede_ptp_enable()
458 ptp->clock_info.owner = THIS_MODULE; in qede_ptp_enable()
459 snprintf(ptp->clock_info.name, 16, "%s", edev->ndev->name); in qede_ptp_enable()
460 ptp->clock_info.max_adj = QED_MAX_PHC_DRIFT_PPB; in qede_ptp_enable()
461 ptp->clock_info.n_alarm = 0; in qede_ptp_enable()
462 ptp->clock_info.n_ext_ts = 0; in qede_ptp_enable()
463 ptp->clock_info.n_per_out = 0; in qede_ptp_enable()
464 ptp->clock_info.pps = 0; in qede_ptp_enable()
465 ptp->clock_info.adjfreq = qede_ptp_adjfreq; in qede_ptp_enable()
466 ptp->clock_info.adjtime = qede_ptp_adjtime; in qede_ptp_enable()
467 ptp->clock_info.gettime64 = qede_ptp_gettime; in qede_ptp_enable()
468 ptp->clock_info.settime64 = qede_ptp_settime; in qede_ptp_enable()
469 ptp->clock_info.enable = qede_ptp_ancillary_feature_enable; in qede_ptp_enable()
471 ptp->clock = ptp_clock_register(&ptp->clock_info, &edev->pdev->dev); in qede_ptp_enable()
472 if (IS_ERR(ptp->clock)) { in qede_ptp_enable()
482 kfree(ptp); in qede_ptp_enable()
484 edev->ptp = NULL; in qede_ptp_enable()
491 struct qede_ptp *ptp; in qede_ptp_tx_ts() local
493 ptp = edev->ptp; in qede_ptp_tx_ts()
494 if (!ptp) in qede_ptp_tx_ts()
509 } else if (unlikely(ptp->tx_skb)) { in qede_ptp_tx_ts()
517 ptp->tx_skb = skb_get(skb); in qede_ptp_tx_ts()
518 ptp->ptp_tx_start = jiffies; in qede_ptp_tx_ts()
519 schedule_work(&ptp->work); in qede_ptp_tx_ts()
525 struct qede_ptp *ptp; in qede_ptp_rx_ts() local
529 ptp = edev->ptp; in qede_ptp_rx_ts()
530 if (!ptp) in qede_ptp_rx_ts()
533 spin_lock_bh(&ptp->lock); in qede_ptp_rx_ts()
534 rc = ptp->ops->read_rx_ts(edev->cdev, ×tamp); in qede_ptp_rx_ts()
536 spin_unlock_bh(&ptp->lock); in qede_ptp_rx_ts()
541 ns = timecounter_cyc2time(&ptp->tc, timestamp); in qede_ptp_rx_ts()
542 spin_unlock_bh(&ptp->lock); in qede_ptp_rx_ts()