Lines Matching full:tx

115 			state1 = "SMA1 Tx U.FL1 disabled";  in ice_ptp_update_sma_data()
122 /* U.FL1 Tx will always enable SMA1 Rx */ in ice_ptp_update_sma_data()
123 state1 = "SMA1 Rx, U.FL1 Tx"; in ice_ptp_update_sma_data()
131 state2 = "SMA2 Tx, U.FL2 disabled"; in ice_ptp_update_sma_data()
142 state2 = "SMA2 Tx, U.FL2 Rx"; in ice_ptp_update_sma_data()
191 * ice_ptp_cfg_tx_interrupt - Configure Tx timestamp interrupt for the device
194 * Program the device to respond appropriately to the Tx timestamp interrupt
220 /* Configure the Tx timestamp interrupt */ in ice_ptp_cfg_tx_interrupt()
359 * This algorithm works even if the PHC time was updated after a Tx timestamp
360 * was requested, but before the Tx timestamp event was reported from
369 * a second, and (b) discarding any Tx timestamp packet if it has waited for
406 * The Tx and Rx timestamps are 40 bits wide, including 32 bits of nominal
444 * ice_ptp_is_tx_tracker_up - Check if Tx tracker is ready for new timestamps
445 * @tx: the PTP Tx timestamp tracker to check
447 * Check that a given PTP Tx timestamp tracker is up, i.e. that it is ready
450 * Assumes the tx->lock spinlock is already held.
453 ice_ptp_is_tx_tracker_up(struct ice_ptp_tx *tx) in ice_ptp_is_tx_tracker_up() argument
455 lockdep_assert_held(&tx->lock); in ice_ptp_is_tx_tracker_up()
457 return tx->init && !tx->calibrating; in ice_ptp_is_tx_tracker_up()
461 * ice_ptp_req_tx_single_tstamp - Request Tx timestamp for a port from FW
462 * @tx: the PTP Tx timestamp tracker
465 void ice_ptp_req_tx_single_tstamp(struct ice_ptp_tx *tx, u8 idx) in ice_ptp_req_tx_single_tstamp() argument
471 if (!tx->init) in ice_ptp_req_tx_single_tstamp()
474 ptp_port = container_of(tx, struct ice_ptp_port, tx); in ice_ptp_req_tx_single_tstamp()
478 if (time_is_before_jiffies(tx->tstamps[idx].start + 2 * HZ)) { in ice_ptp_req_tx_single_tstamp()
479 /* Count the number of Tx timestamps that timed out */ in ice_ptp_req_tx_single_tstamp()
482 skb = tx->tstamps[idx].skb; in ice_ptp_req_tx_single_tstamp()
483 tx->tstamps[idx].skb = NULL; in ice_ptp_req_tx_single_tstamp()
484 clear_bit(idx, tx->in_use); in ice_ptp_req_tx_single_tstamp()
490 ice_trace(tx_tstamp_fw_req, tx->tstamps[idx].skb, idx); in ice_ptp_req_tx_single_tstamp()
496 tx->last_ll_ts_idx_read = idx; in ice_ptp_req_tx_single_tstamp()
500 * ice_ptp_complete_tx_single_tstamp - Complete Tx timestamp for a port
501 * @tx: the PTP Tx timestamp tracker
503 void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx) in ice_ptp_complete_tx_single_tstamp() argument
506 u8 idx = tx->last_ll_ts_idx_read; in ice_ptp_complete_tx_single_tstamp()
514 if (!tx->init || tx->last_ll_ts_idx_read < 0) in ice_ptp_complete_tx_single_tstamp()
517 ptp_port = container_of(tx, struct ice_ptp_port, tx); in ice_ptp_complete_tx_single_tstamp()
520 ice_trace(tx_tstamp_fw_done, tx->tstamps[idx].skb, idx); in ice_ptp_complete_tx_single_tstamp()
526 dev_err(ice_pf_to_dev(pf), "Failed to get the Tx tstamp - FW not ready"); in ice_ptp_complete_tx_single_tstamp()
540 if (raw_tstamp == tx->tstamps[idx].cached_tstamp) in ice_ptp_complete_tx_single_tstamp()
543 tx->tstamps[idx].cached_tstamp = raw_tstamp; in ice_ptp_complete_tx_single_tstamp()
544 clear_bit(idx, tx->in_use); in ice_ptp_complete_tx_single_tstamp()
545 skb = tx->tstamps[idx].skb; in ice_ptp_complete_tx_single_tstamp()
546 tx->tstamps[idx].skb = NULL; in ice_ptp_complete_tx_single_tstamp()
547 if (test_and_clear_bit(idx, tx->stale)) in ice_ptp_complete_tx_single_tstamp()
570 * ice_ptp_process_tx_tstamp - Process Tx timestamps for a port
571 * @tx: the PTP Tx timestamp tracker
586 * Note that we do not hold the tracking lock while reading the Tx timestamp.
593 * function, or during teardown when the Tx timestamp tracker is being
597 * If a Tx thread starts a new timestamp, we might not begin processing it
600 * If a Tx thread starts a new timestamp just after this function exits, the
606 * this case, software will set the stale bit for any outstanding Tx
610 * If a Tx packet has been waiting for more than 2 seconds, it is not possible
613 * we detect a Tx timestamp request that has waited for this long we assume
617 static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) in ice_ptp_process_tx_tstamp() argument
628 ptp_port = container_of(tx, struct ice_ptp_port, tx); in ice_ptp_process_tx_tstamp()
632 /* Read the Tx ready status first */ in ice_ptp_process_tx_tstamp()
633 if (tx->has_ready_bitmap) { in ice_ptp_process_tx_tstamp()
634 err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready); in ice_ptp_process_tx_tstamp()
642 for_each_set_bit(idx, tx->in_use, tx->len) { in ice_ptp_process_tx_tstamp()
644 u8 phy_idx = idx + tx->offset; in ice_ptp_process_tx_tstamp()
650 if (time_is_before_jiffies(tx->tstamps[idx].start + 2 * HZ)) { in ice_ptp_process_tx_tstamp()
653 /* Count the number of Tx timestamps that timed out */ in ice_ptp_process_tx_tstamp()
665 if (tx->has_ready_bitmap && in ice_ptp_process_tx_tstamp()
673 ice_trace(tx_tstamp_fw_req, tx->tstamps[idx].skb, idx); in ice_ptp_process_tx_tstamp()
675 err = ice_read_phy_tstamp(hw, tx->block, phy_idx, &raw_tstamp); in ice_ptp_process_tx_tstamp()
679 ice_trace(tx_tstamp_fw_done, tx->tstamps[idx].skb, idx); in ice_ptp_process_tx_tstamp()
686 if (!drop_ts && !tx->has_ready_bitmap && in ice_ptp_process_tx_tstamp()
687 raw_tstamp == tx->tstamps[idx].cached_tstamp) in ice_ptp_process_tx_tstamp()
695 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_process_tx_tstamp()
696 if (!tx->has_ready_bitmap && raw_tstamp) in ice_ptp_process_tx_tstamp()
697 tx->tstamps[idx].cached_tstamp = raw_tstamp; in ice_ptp_process_tx_tstamp()
698 clear_bit(idx, tx->in_use); in ice_ptp_process_tx_tstamp()
699 skb = tx->tstamps[idx].skb; in ice_ptp_process_tx_tstamp()
700 tx->tstamps[idx].skb = NULL; in ice_ptp_process_tx_tstamp()
701 if (test_and_clear_bit(idx, tx->stale)) in ice_ptp_process_tx_tstamp()
703 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_process_tx_tstamp()
729 * ice_ptp_tx_tstamp_owner - Process Tx timestamps for all ports on the device
739 struct ice_ptp_tx *tx = &port->tx; in ice_ptp_tx_tstamp_owner() local
741 if (!tx || !tx->init) in ice_ptp_tx_tstamp_owner()
744 ice_ptp_process_tx_tstamp(tx); in ice_ptp_tx_tstamp_owner()
752 /* Read the Tx ready status first */ in ice_ptp_tx_tstamp_owner()
764 * ice_ptp_tx_tstamp - Process Tx timestamps for this function.
765 * @tx: Tx tracking structure to initialize
768 * Tx timestamps, or ICE_TX_TSTAMP_WORK_DONE otherwise.
770 static enum ice_tx_tstamp_work ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) in ice_ptp_tx_tstamp() argument
775 if (!tx->init) in ice_ptp_tx_tstamp()
778 /* Process the Tx timestamp tracker */ in ice_ptp_tx_tstamp()
779 ice_ptp_process_tx_tstamp(tx); in ice_ptp_tx_tstamp()
781 /* Check if there are outstanding Tx timestamps */ in ice_ptp_tx_tstamp()
782 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_tx_tstamp()
783 more_timestamps = tx->init && !bitmap_empty(tx->in_use, tx->len); in ice_ptp_tx_tstamp()
784 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_tx_tstamp()
793 * ice_ptp_alloc_tx_tracker - Initialize tracking for Tx timestamps
794 * @tx: Tx tracking structure to initialize
800 ice_ptp_alloc_tx_tracker(struct ice_ptp_tx *tx) in ice_ptp_alloc_tx_tracker() argument
805 tstamps = kcalloc(tx->len, sizeof(*tstamps), GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
806 in_use = bitmap_zalloc(tx->len, GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
807 stale = bitmap_zalloc(tx->len, GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
817 tx->tstamps = tstamps; in ice_ptp_alloc_tx_tracker()
818 tx->in_use = in_use; in ice_ptp_alloc_tx_tracker()
819 tx->stale = stale; in ice_ptp_alloc_tx_tracker()
820 tx->init = 1; in ice_ptp_alloc_tx_tracker()
821 tx->last_ll_ts_idx_read = -1; in ice_ptp_alloc_tx_tracker()
823 spin_lock_init(&tx->lock); in ice_ptp_alloc_tx_tracker()
831 * @tx: the tracker to flush
833 * Called during teardown when a Tx tracker is being removed.
836 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
844 err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready); in ice_ptp_flush_tx_tracker()
846 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()
847 tx->block, err); in ice_ptp_flush_tx_tracker()
849 /* If we fail to read the Tx timestamp ready bitmap just in ice_ptp_flush_tx_tracker()
855 for_each_set_bit(idx, tx->in_use, tx->len) { in ice_ptp_flush_tx_tracker()
856 u8 phy_idx = idx + tx->offset; in ice_ptp_flush_tx_tracker()
861 ice_clear_phy_tstamp(hw, tx->block, phy_idx); in ice_ptp_flush_tx_tracker()
863 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_flush_tx_tracker()
864 skb = tx->tstamps[idx].skb; in ice_ptp_flush_tx_tracker()
865 tx->tstamps[idx].skb = NULL; in ice_ptp_flush_tx_tracker()
866 clear_bit(idx, tx->in_use); in ice_ptp_flush_tx_tracker()
867 clear_bit(idx, tx->stale); in ice_ptp_flush_tx_tracker()
868 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_flush_tx_tracker()
870 /* Count the number of Tx timestamps flushed */ in ice_ptp_flush_tx_tracker()
880 * @tx: the tracker to mark
882 * Mark currently outstanding Tx timestamps as stale. This prevents sending
890 ice_ptp_mark_tx_tracker_stale(struct ice_ptp_tx *tx) in ice_ptp_mark_tx_tracker_stale() argument
894 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_mark_tx_tracker_stale()
895 bitmap_or(tx->stale, tx->stale, tx->in_use, tx->len); in ice_ptp_mark_tx_tracker_stale()
896 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_mark_tx_tracker_stale()
903 * Called by the clock owner to flush all the Tx timestamp trackers associated
912 ice_ptp_flush_tx_tracker(ptp_port_to_pf(port), &port->tx); in ice_ptp_flush_all_tx_tracker()
916 * ice_ptp_release_tx_tracker - Release allocated memory for Tx tracker
918 * @tx: Tx tracking structure to release
920 * Free memory associated with the Tx timestamp tracker.
923 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
927 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_release_tx_tracker()
928 tx->init = 0; in ice_ptp_release_tx_tracker()
929 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_release_tx_tracker()
934 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
936 kfree(tx->tstamps); in ice_ptp_release_tx_tracker()
937 tx->tstamps = NULL; in ice_ptp_release_tx_tracker()
939 bitmap_free(tx->in_use); in ice_ptp_release_tx_tracker()
940 tx->in_use = NULL; in ice_ptp_release_tx_tracker()
942 bitmap_free(tx->stale); in ice_ptp_release_tx_tracker()
943 tx->stale = NULL; in ice_ptp_release_tx_tracker()
945 tx->len = 0; in ice_ptp_release_tx_tracker()
949 * ice_ptp_init_tx_eth56g - Initialize tracking for Tx timestamps
951 * @tx: the Tx tracking structure to initialize
954 * Initialize the Tx timestamp tracker for this port. ETH56G PHYs
957 * Return: 0 for success, -ENOMEM when failed to allocate Tx tracker
959 static int ice_ptp_init_tx_eth56g(struct ice_pf *pf, struct ice_ptp_tx *tx, in ice_ptp_init_tx_eth56g() argument
962 tx->block = port; in ice_ptp_init_tx_eth56g()
963 tx->offset = 0; in ice_ptp_init_tx_eth56g()
964 tx->len = INDEX_PER_PORT_ETH56G; in ice_ptp_init_tx_eth56g()
965 tx->has_ready_bitmap = 1; in ice_ptp_init_tx_eth56g()
967 return ice_ptp_alloc_tx_tracker(tx); in ice_ptp_init_tx_eth56g()
971 * ice_ptp_init_tx_e82x - Initialize tracking for Tx timestamps
973 * @tx: the Tx tracking structure to initialize
976 * Initialize the Tx timestamp tracker for this port. For generic MAC devices,
982 ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) in ice_ptp_init_tx_e82x() argument
984 tx->block = ICE_GET_QUAD_NUM(port); in ice_ptp_init_tx_e82x()
985 tx->offset = (port % ICE_PORTS_PER_QUAD) * INDEX_PER_PORT_E82X; in ice_ptp_init_tx_e82x()
986 tx->len = INDEX_PER_PORT_E82X; in ice_ptp_init_tx_e82x()
987 tx->has_ready_bitmap = 1; in ice_ptp_init_tx_e82x()
989 return ice_ptp_alloc_tx_tracker(tx); in ice_ptp_init_tx_e82x()
993 * ice_ptp_init_tx_e810 - Initialize tracking for Tx timestamps
995 * @tx: the Tx tracking structure to initialize
997 * Initialize the Tx timestamp tracker for this PF. For E810 devices, each
1001 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
1003 tx->block = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
1004 tx->offset = 0; in ice_ptp_init_tx_e810()
1005 tx->len = INDEX_PER_PORT_E810; in ice_ptp_init_tx_e810()
1010 tx->has_ready_bitmap = 0; in ice_ptp_init_tx_e810()
1012 return ice_ptp_alloc_tx_tracker(tx); in ice_ptp_init_tx_e810()
1085 * such as after a time adjustment. It marks any currently outstanding Tx
1120 ice_ptp_mark_tx_tracker_stale(&pf->ptp.port.tx); in ice_ptp_reset_cached_phctime()
1176 * ice_ptp_check_tx_fifo - Check whether Tx FIFO is in an OK state
1177 * @port: PTP port for which Tx FIFO is checked
1203 dev_err(ice_pf_to_dev(pf), "PTP failed to check port %d Tx FIFO, err %d\n", in ice_ptp_check_tx_fifo()
1225 "Port %d Tx FIFO still not empty; resetting quad %d\n", in ice_ptp_check_tx_fifo()
1236 * ice_ptp_wait_for_offsets - Check for valid Tx and Rx offsets
1239 * Check whether hardware has completed measuring the Tx and Rx offset values
1243 * registers with the calibrated offset values and enable timestamping. The Tx
1247 * This function reschedules itself until both Tx and Rx calibration have
1275 /* Tx and/or Rx offset not yet configured, try again later */ in ice_ptp_wait_for_offsets()
1354 /* temporarily disable Tx timestamps while calibrating in ice_ptp_port_phy_restart()
1357 spin_lock_irqsave(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
1358 ptp_port->tx.calibrating = true; in ice_ptp_port_phy_restart()
1359 spin_unlock_irqrestore(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
1367 /* Enable Tx timestamps right away */ in ice_ptp_port_phy_restart()
1368 spin_lock_irqsave(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
1369 ptp_port->tx.calibrating = false; in ice_ptp_port_phy_restart()
1370 spin_unlock_irqrestore(&ptp_port->tx.lock, flags); in ice_ptp_port_phy_restart()
2657 * ice_ptp_request_ts - Request an available Tx timestamp index
2658 * @tx: the PTP Tx timestamp tracker to request from
2661 s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb) in ice_ptp_request_ts() argument
2666 spin_lock_irqsave(&tx->lock, flags); in ice_ptp_request_ts()
2669 if (!ice_ptp_is_tx_tracker_up(tx)) { in ice_ptp_request_ts()
2670 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_request_ts()
2675 idx = find_next_zero_bit(tx->in_use, tx->len, in ice_ptp_request_ts()
2676 tx->last_ll_ts_idx_read + 1); in ice_ptp_request_ts()
2677 if (idx == tx->len) in ice_ptp_request_ts()
2678 idx = find_first_zero_bit(tx->in_use, tx->len); in ice_ptp_request_ts()
2680 if (idx < tx->len) { in ice_ptp_request_ts()
2685 set_bit(idx, tx->in_use); in ice_ptp_request_ts()
2686 clear_bit(idx, tx->stale); in ice_ptp_request_ts()
2687 tx->tstamps[idx].start = jiffies; in ice_ptp_request_ts()
2688 tx->tstamps[idx].skb = skb_get(skb); in ice_ptp_request_ts()
2693 spin_unlock_irqrestore(&tx->lock, flags); in ice_ptp_request_ts()
2698 if (idx >= tx->len) in ice_ptp_request_ts()
2701 return idx + tx->offset; in ice_ptp_request_ts()
2705 * ice_ptp_process_ts - Process the PTP Tx timestamps
2708 * Returns: ICE_TX_TSTAMP_WORK_PENDING if there are any outstanding Tx
2719 return ice_ptp_tx_tstamp(&pf->ptp.port.tx); in ice_ptp_process_ts()
2724 WARN_ONCE(1, "Unexpected Tx timestamp interrupt mode %u\n", in ice_ptp_process_ts()
2731 * ice_ptp_maybe_trigger_tx_interrupt - Trigger Tx timstamp interrupt
2734 * The device PHY issues Tx timestamp interrupts to the driver for processing
2771 …dev_dbg(dev, "PTP periodic task detected waiting timestamps. Triggering Tx timestamp interrupt now… in ice_ptp_maybe_trigger_tx_interrupt()
2811 /* Disable timestamping for both Tx and Rx */ in ice_ptp_prepare_for_reset()
2819 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_prepare_for_reset()
3109 return ice_ptp_init_tx_eth56g(pf, &ptp_port->tx, in ice_ptp_init_port()
3112 return ice_ptp_init_tx_e810(pf, &ptp_port->tx); in ice_ptp_init_port()
3117 return ice_ptp_init_tx_e82x(pf, &ptp_port->tx, in ice_ptp_init_port()
3125 * ice_ptp_init_tx_interrupt_mode - Initialize device Tx interrupt mode
3128 * Initialize the Tx timestamp interrupt mode for this device. For most device
3146 /* other PHY types handle their own Tx interrupt */ in ice_ptp_init_tx_interrupt_mode()
3161 * items used for asynchronous work such as Tx timestamps and periodic work.
3202 /* Configure initial Tx interrupt settings */ in ice_ptp_init()
3238 /* Disable timestamping for both Tx and Rx */ in ice_ptp_release()
3243 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()