Lines Matching full:tx
111 /* SMA1 and UFL1 cannot be set to TX at the same time */ in ice_ptp_set_sma_config_e810t()
138 /* U.FL 1 TX will always enable SMA 1 RX */ in ice_ptp_set_sma_config_e810t()
139 dev_info(ice_hw_to_dev(hw), "SMA1 RX + U.FL1 TX"); in ice_ptp_set_sma_config_e810t()
142 dev_info(ice_hw_to_dev(hw), "SMA1 RX + U.FL1 TX"); in ice_ptp_set_sma_config_e810t()
145 dev_info(ice_hw_to_dev(hw), "SMA1 TX"); in ice_ptp_set_sma_config_e810t()
165 dev_info(ice_hw_to_dev(hw), "SMA2 TX"); in ice_ptp_set_sma_config_e810t()
170 dev_info(ice_hw_to_dev(hw), "SMA2 TX + U.FL2 RX"); in ice_ptp_set_sma_config_e810t()
257 * ice_ptp_cfg_tx_interrupt - Configure Tx timestamp interrupt for the device
260 * Program the device to respond appropriately to the Tx timestamp interrupt
286 /* Configure the Tx timestamp interrupt */ in ice_ptp_cfg_tx_interrupt()
425 * This algorithm works even if the PHC time was updated after a Tx timestamp
426 * was requested, but before the Tx timestamp event was reported from
435 * a second, and (b) discarding any Tx timestamp packet if it has waited for
472 * The Tx and Rx timestamps are 40 bits wide, including 32 bits of nominal
510 * ice_ptp_is_tx_tracker_up - Check if Tx tracker is ready for new timestamps
511 * @tx: the PTP Tx timestamp tracker to check
513 * Check that a given PTP Tx timestamp tracker is up, i.e. that it is ready
516 * Assumes the tx->lock spinlock is already held.
519 ice_ptp_is_tx_tracker_up(struct ice_ptp_tx *tx) in ice_ptp_is_tx_tracker_up() argument
521 lockdep_assert_held(&tx->lock); in ice_ptp_is_tx_tracker_up()
523 return tx->init && !tx->calibrating; in ice_ptp_is_tx_tracker_up()
527 * ice_ptp_req_tx_single_tstamp - Request Tx timestamp for a port from FW
528 * @tx: the PTP Tx timestamp tracker
531 void ice_ptp_req_tx_single_tstamp(struct ice_ptp_tx *tx, u8 idx) in ice_ptp_req_tx_single_tstamp() argument
537 if (!tx->init) in ice_ptp_req_tx_single_tstamp()
540 ptp_port = container_of(tx, struct ice_ptp_port, tx); in ice_ptp_req_tx_single_tstamp()
544 if (time_is_before_jiffies(tx->tstamps[idx].start + 2 * HZ)) { in ice_ptp_req_tx_single_tstamp()
545 /* Count the number of Tx timestamps that timed out */ in ice_ptp_req_tx_single_tstamp()
548 skb = tx->tstamps[idx].skb; in ice_ptp_req_tx_single_tstamp()
549 tx->tstamps[idx].skb = NULL; in ice_ptp_req_tx_single_tstamp()
550 clear_bit(idx, tx->in_use); in ice_ptp_req_tx_single_tstamp()
556 ice_trace(tx_tstamp_fw_req, tx->tstamps[idx].skb, idx); in ice_ptp_req_tx_single_tstamp()
562 tx->last_ll_ts_idx_read = idx; in ice_ptp_req_tx_single_tstamp()
566 * ice_ptp_complete_tx_single_tstamp - Complete Tx timestamp for a port
567 * @tx: the PTP Tx timestamp tracker
569 void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx) in ice_ptp_complete_tx_single_tstamp() argument
572 u8 idx = tx->last_ll_ts_idx_read; in ice_ptp_complete_tx_single_tstamp()
580 if (!tx->init || tx->last_ll_ts_idx_read < 0) in ice_ptp_complete_tx_single_tstamp()
583 ptp_port = container_of(tx, struct ice_ptp_port, tx); in ice_ptp_complete_tx_single_tstamp()
586 ice_trace(tx_tstamp_fw_done, tx->tstamps[idx].skb, idx); in ice_ptp_complete_tx_single_tstamp()
592 dev_err(ice_pf_to_dev(pf), "Failed to get the Tx tstamp - FW not ready"); in ice_ptp_complete_tx_single_tstamp()
606 if (raw_tstamp == tx->tstamps[idx].cached_tstamp) in ice_ptp_complete_tx_single_tstamp()
609 tx->tstamps[idx].cached_tstamp = raw_tstamp; in ice_ptp_complete_tx_single_tstamp()
610 clear_bit(idx, tx->in_use); in ice_ptp_complete_tx_single_tstamp()
611 skb = tx->tstamps[idx].skb; in ice_ptp_complete_tx_single_tstamp()
612 tx->tstamps[idx].skb = NULL; in ice_ptp_complete_tx_single_tstamp()
613 if (test_and_clear_bit(idx, tx->stale)) in ice_ptp_complete_tx_single_tstamp()
636 * ice_ptp_process_tx_tstamp - Process Tx timestamps for a port
637 * @tx: the PTP Tx timestamp tracker
652 * Note that we do not hold the tracking lock while reading the Tx timestamp.
659 * function, or during teardown when the Tx timestamp tracker is being
663 * If a Tx thread starts a new timestamp, we might not begin processing it
666 * If a Tx thread starts a new timestamp just after this function exits, the
672 * this case, software will set the stale bit for any outstanding Tx
676 * If a Tx packet has been waiting for more than 2 seconds, it is not possible
679 * we detect a Tx timestamp request that has waited for this long we assume
683 static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) in ice_ptp_process_tx_tstamp() argument
694 ptp_port = container_of(tx, struct ice_ptp_port, tx); in ice_ptp_process_tx_tstamp()
698 /* Read the Tx ready status first */ in ice_ptp_process_tx_tstamp()
699 if (tx->has_ready_bitmap) { in ice_ptp_process_tx_tstamp()
700 err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready); in ice_ptp_process_tx_tstamp()
708 for_each_set_bit(idx, tx->in_use, tx->len) { in ice_ptp_process_tx_tstamp()
710 u8 phy_idx = idx + tx->offset; in ice_ptp_process_tx_tstamp()
716 if (time_is_before_jiffies(tx->tstamps[idx].start + 2 * HZ)) { in ice_ptp_process_tx_tstamp()
719 /* Count the number of Tx timestamps that timed out */ in ice_ptp_process_tx_tstamp()
731 if (tx->has_ready_bitmap && in ice_ptp_process_tx_tstamp()
739 ice_trace(tx_tstamp_fw_req, tx->tstamps[idx].skb, idx); in ice_ptp_process_tx_tstamp()
741 err = ice_read_phy_tstamp(hw, tx->block, phy_idx, &raw_tstamp); in ice_ptp_process_tx_tstamp()
745 ice_trace(tx_tstamp_fw_done, tx->tstamps[idx].skb, idx); in ice_ptp_process_tx_tstamp()
752 if (!drop_ts && !tx->has_ready_bitmap && in ice_ptp_process_tx_tstamp()
753 raw_tstamp == tx->tstamps[idx].cached_tstamp) in ice_ptp_process_tx_tstamp()
761 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_process_tx_tstamp()
762 if (!tx->has_ready_bitmap && raw_tstamp) in ice_ptp_process_tx_tstamp()
763 tx->tstamps[idx].cached_tstamp = raw_tstamp; in ice_ptp_process_tx_tstamp()
764 clear_bit(idx, tx->in_use); in ice_ptp_process_tx_tstamp()
765 skb = tx->tstamps[idx].skb; in ice_ptp_process_tx_tstamp()
766 tx->tstamps[idx].skb = NULL; in ice_ptp_process_tx_tstamp()
767 if (test_and_clear_bit(idx, tx->stale)) in ice_ptp_process_tx_tstamp()
769 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_process_tx_tstamp()
795 * ice_ptp_tx_tstamp_owner - Process Tx timestamps for all ports on the device
805 struct ice_ptp_tx *tx = &port->tx; in ice_ptp_tx_tstamp_owner() local
807 if (!tx || !tx->init) in ice_ptp_tx_tstamp_owner()
810 ice_ptp_process_tx_tstamp(tx); in ice_ptp_tx_tstamp_owner()
818 /* Read the Tx ready status first */ in ice_ptp_tx_tstamp_owner()
830 * ice_ptp_tx_tstamp - Process Tx timestamps for this function.
831 * @tx: Tx tracking structure to initialize
834 * Tx timestamps, or ICE_TX_TSTAMP_WORK_DONE otherwise.
836 static enum ice_tx_tstamp_work ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) in ice_ptp_tx_tstamp() argument
841 if (!tx->init) in ice_ptp_tx_tstamp()
844 /* Process the Tx timestamp tracker */ in ice_ptp_tx_tstamp()
845 ice_ptp_process_tx_tstamp(tx); in ice_ptp_tx_tstamp()
847 /* Check if there are outstanding Tx timestamps */ in ice_ptp_tx_tstamp()
848 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_tx_tstamp()
849 more_timestamps = tx->init && !bitmap_empty(tx->in_use, tx->len); in ice_ptp_tx_tstamp()
850 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_tx_tstamp()
859 * ice_ptp_alloc_tx_tracker - Initialize tracking for Tx timestamps
860 * @tx: Tx tracking structure to initialize
866 ice_ptp_alloc_tx_tracker(struct ice_ptp_tx *tx) in ice_ptp_alloc_tx_tracker() argument
871 tstamps = kcalloc(tx->len, sizeof(*tstamps), GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
872 in_use = bitmap_zalloc(tx->len, GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
873 stale = bitmap_zalloc(tx->len, GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
883 tx->tstamps = tstamps; in ice_ptp_alloc_tx_tracker()
884 tx->in_use = in_use; in ice_ptp_alloc_tx_tracker()
885 tx->stale = stale; in ice_ptp_alloc_tx_tracker()
886 tx->init = 1; in ice_ptp_alloc_tx_tracker()
887 tx->last_ll_ts_idx_read = -1; in ice_ptp_alloc_tx_tracker()
889 spin_lock_init(&tx->lock); in ice_ptp_alloc_tx_tracker()
897 * @tx: the tracker to flush
899 * Called during teardown when a Tx tracker is being removed.
902 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
910 err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready); in ice_ptp_flush_tx_tracker()
912 dev_dbg(ice_pf_to_dev(pf), "Failed to get the Tx tstamp ready bitmap for block %u, err %d\n", in ice_ptp_flush_tx_tracker()
913 tx->block, err); in ice_ptp_flush_tx_tracker()
915 /* If we fail to read the Tx timestamp ready bitmap just in ice_ptp_flush_tx_tracker()
921 for_each_set_bit(idx, tx->in_use, tx->len) { in ice_ptp_flush_tx_tracker()
922 u8 phy_idx = idx + tx->offset; in ice_ptp_flush_tx_tracker()
927 ice_clear_phy_tstamp(hw, tx->block, phy_idx); in ice_ptp_flush_tx_tracker()
929 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_flush_tx_tracker()
930 skb = tx->tstamps[idx].skb; in ice_ptp_flush_tx_tracker()
931 tx->tstamps[idx].skb = NULL; in ice_ptp_flush_tx_tracker()
932 clear_bit(idx, tx->in_use); in ice_ptp_flush_tx_tracker()
933 clear_bit(idx, tx->stale); in ice_ptp_flush_tx_tracker()
934 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_flush_tx_tracker()
936 /* Count the number of Tx timestamps flushed */ in ice_ptp_flush_tx_tracker()
946 * @tx: the tracker to mark
948 * Mark currently outstanding Tx timestamps as stale. This prevents sending
956 ice_ptp_mark_tx_tracker_stale(struct ice_ptp_tx *tx) in ice_ptp_mark_tx_tracker_stale() argument
960 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_mark_tx_tracker_stale()
961 bitmap_or(tx->stale, tx->stale, tx->in_use, tx->len); in ice_ptp_mark_tx_tracker_stale()
962 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_mark_tx_tracker_stale()
969 * Called by the clock owner to flush all the Tx timestamp trackers associated
978 ice_ptp_flush_tx_tracker(ptp_port_to_pf(port), &port->tx); in ice_ptp_flush_all_tx_tracker()
982 * ice_ptp_release_tx_tracker - Release allocated memory for Tx tracker
984 * @tx: Tx tracking structure to release
986 * Free memory associated with the Tx timestamp tracker.
989 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
993 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_release_tx_tracker()
994 tx->init = 0; in ice_ptp_release_tx_tracker()
995 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_release_tx_tracker()
1000 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
1002 kfree(tx->tstamps); in ice_ptp_release_tx_tracker()
1003 tx->tstamps = NULL; in ice_ptp_release_tx_tracker()
1005 bitmap_free(tx->in_use); in ice_ptp_release_tx_tracker()
1006 tx->in_use = NULL; in ice_ptp_release_tx_tracker()
1008 bitmap_free(tx->stale); in ice_ptp_release_tx_tracker()
1009 tx->stale = NULL; in ice_ptp_release_tx_tracker()
1011 tx->len = 0; in ice_ptp_release_tx_tracker()
1015 * ice_ptp_init_tx_eth56g - Initialize tracking for Tx timestamps
1017 * @tx: the Tx tracking structure to initialize
1020 * Initialize the Tx timestamp tracker for this port. ETH56G PHYs
1023 * Return: 0 for success, -ENOMEM when failed to allocate Tx tracker
1025 static int ice_ptp_init_tx_eth56g(struct ice_pf *pf, struct ice_ptp_tx *tx, in ice_ptp_init_tx_eth56g() argument
1028 tx->block = port; in ice_ptp_init_tx_eth56g()
1029 tx->offset = 0; in ice_ptp_init_tx_eth56g()
1030 tx->len = INDEX_PER_PORT_ETH56G; in ice_ptp_init_tx_eth56g()
1031 tx->has_ready_bitmap = 1; in ice_ptp_init_tx_eth56g()
1033 return ice_ptp_alloc_tx_tracker(tx); in ice_ptp_init_tx_eth56g()
1037 * ice_ptp_init_tx_e82x - Initialize tracking for Tx timestamps
1039 * @tx: the Tx tracking structure to initialize
1042 * Initialize the Tx timestamp tracker for this port. For generic MAC devices,
1048 ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) in ice_ptp_init_tx_e82x() argument
1050 tx->block = ICE_GET_QUAD_NUM(port); in ice_ptp_init_tx_e82x()
1051 tx->offset = (port % ICE_PORTS_PER_QUAD) * INDEX_PER_PORT_E82X; in ice_ptp_init_tx_e82x()
1052 tx->len = INDEX_PER_PORT_E82X; in ice_ptp_init_tx_e82x()
1053 tx->has_ready_bitmap = 1; in ice_ptp_init_tx_e82x()
1055 return ice_ptp_alloc_tx_tracker(tx); in ice_ptp_init_tx_e82x()
1059 * ice_ptp_init_tx_e810 - Initialize tracking for Tx timestamps
1061 * @tx: the Tx tracking structure to initialize
1063 * Initialize the Tx timestamp tracker for this PF. For E810 devices, each
1067 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
1069 tx->block = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
1070 tx->offset = 0; in ice_ptp_init_tx_e810()
1071 tx->len = INDEX_PER_PORT_E810; in ice_ptp_init_tx_e810()
1076 tx->has_ready_bitmap = 0; in ice_ptp_init_tx_e810()
1078 return ice_ptp_alloc_tx_tracker(tx); in ice_ptp_init_tx_e810()
1151 * such as after a time adjustment. It marks any currently outstanding Tx
1186 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1242 * ice_ptp_check_tx_fifo - Check whether Tx FIFO is in an OK state
1243 * @port: PTP port for which Tx FIFO is checked
1269 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1291 "Port %d Tx FIFO still not empty; resetting quad %d\n", in ice_ptp_check_tx_fifo()
1302 * ice_ptp_wait_for_offsets - Check for valid Tx and Rx offsets
1305 * Check whether hardware has completed measuring the Tx and Rx offset values
1309 * registers with the calibrated offset values and enable timestamping. The Tx
1313 * This function reschedules itself until both Tx and Rx calibration have
1341 /* Tx and/or Rx offset not yet configured, try again later */ in ice_ptp_wait_for_offsets()
1420 /* temporarily disable Tx timestamps while calibrating in ice_ptp_port_phy_restart()
1423 spin_lock_irqsave(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
1424 ptp_port->tx.calibrating = true; in ice_ptp_port_phy_restart()
1425 spin_unlock_irqrestore(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
1433 /* Enable Tx timestamps right away */ in ice_ptp_port_phy_restart()
1434 spin_lock_irqsave(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
1435 ptp_port->tx.calibrating = false; in ice_ptp_port_phy_restart()
1436 spin_unlock_irqrestore(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
2613 * ice_ptp_request_ts - Request an available Tx timestamp index
2614 * @tx: the PTP Tx timestamp tracker to request from
2617 s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb) in ice_ptp_request_ts() argument
2622 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_request_ts()
2625 if (!ice_ptp_is_tx_tracker_up(tx)) { in ice_ptp_request_ts()
2626 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_request_ts()
2631 idx = find_next_zero_bit(tx->in_use, tx->len, in ice_ptp_request_ts()
2632 tx->last_ll_ts_idx_read + 1); in ice_ptp_request_ts()
2633 if (idx == tx->len) in ice_ptp_request_ts()
2634 idx = find_first_zero_bit(tx->in_use, tx->len); in ice_ptp_request_ts()
2636 if (idx < tx->len) { in ice_ptp_request_ts()
2641 set_bit(idx, tx->in_use); in ice_ptp_request_ts()
2642 clear_bit(idx, tx->stale); in ice_ptp_request_ts()
2643 tx->tstamps[idx].start = jiffies; in ice_ptp_request_ts()
2644 tx->tstamps[idx].skb = skb_get(skb); in ice_ptp_request_ts()
2649 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_request_ts()
2654 if (idx >= tx->len) in ice_ptp_request_ts()
2657 return idx + tx->offset; in ice_ptp_request_ts()
2661 * ice_ptp_process_ts - Process the PTP Tx timestamps
2664 * Returns: ICE_TX_TSTAMP_WORK_PENDING if there are any outstanding Tx
2675 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2680 WARN_ONCE(1, "Unexpected Tx timestamp interrupt mode %u\n", in ice_ptp_process_ts()
2687 * ice_ptp_maybe_trigger_tx_interrupt - Trigger Tx timstamp interrupt
2690 * The device PHY issues Tx timestamp interrupts to the driver for processing
2727 …dev_dbg(dev, "PTP periodic task detected waiting timestamps. Triggering Tx timestamp interrupt now… in ice_ptp_maybe_trigger_tx_interrupt()
2767 /* Disable timestamping for both Tx and Rx */ in ice_ptp_prepare_for_reset()
2775 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
3214 return ice_ptp_init_tx_eth56g(pf, &ptp_port->tx, in ice_ptp_init_port()
3217 return ice_ptp_init_tx_e810(pf, &ptp_port->tx); in ice_ptp_init_port()
3222 return ice_ptp_init_tx_e82x(pf, &ptp_port->tx, in ice_ptp_init_port()
3300 * ice_ptp_init_tx_interrupt_mode - Initialize device Tx interrupt mode
3303 * Initialize the Tx timestamp interrupt mode for this device. For most device
3321 /* other PHY types handle their own Tx interrupt */ in ice_ptp_init_tx_interrupt_mode()
3336 * items used for asynchronous work such as Tx timestamps and periodic work.
3370 /* Configure initial Tx interrupt settings */ in ice_ptp_init()
3410 /* Disable timestamping for both Tx and Rx */ in ice_ptp_release()
3415 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()