Lines Matching full:tx
10 * ice_set_tx_tstamp - Enable or disable Tx timestamping
24 /* Set the timestamp enable flag for all the Tx rings */ in ice_set_tx_tstamp()
31 /* Configure the Tx timestamp interrupt */ in ice_set_tx_tstamp()
312 * This algorithm works even if the PHC time was updated after a Tx timestamp
313 * was requested, but before the Tx timestamp event was reported from
322 * a second, and (b) discarding any Tx timestamp packet if it has waited for
359 * The Tx and Rx timestamps are 40 bits wide, including 32 bits of nominal
1124 * ice_ptp_tx_tstamp_work - Process Tx timestamps for a port
1149 * when we lock to clear the bit and then grab the SKB pointer. If a Tx thread
1151 * will notice it at the end when we re-queue the work item. If a Tx thread
1154 * the lock for the entire function is important in order to ensure that Tx
1160 struct ice_ptp_tx *tx; in ice_ptp_tx_tstamp_work() local
1165 tx = container_of(work, struct ice_ptp_tx, work); in ice_ptp_tx_tstamp_work()
1166 if (!tx->init) in ice_ptp_tx_tstamp_work()
1169 ptp_port = container_of(tx, struct ice_ptp_port, tx); in ice_ptp_tx_tstamp_work()
1173 for_each_set_bit(idx, tx->in_use, tx->len) { in ice_ptp_tx_tstamp_work()
1175 u8 phy_idx = idx + tx->quad_offset; in ice_ptp_tx_tstamp_work()
1180 err = ice_read_phy_tstamp(hw, tx->quad, phy_idx, in ice_ptp_tx_tstamp_work()
1192 ice_clear_phy_tstamp(hw, tx->quad, phy_idx); in ice_ptp_tx_tstamp_work()
1197 spin_lock(&tx->lock); in ice_ptp_tx_tstamp_work()
1198 clear_bit(idx, tx->in_use); in ice_ptp_tx_tstamp_work()
1199 skb = tx->tstamps[idx].skb; in ice_ptp_tx_tstamp_work()
1200 tx->tstamps[idx].skb = NULL; in ice_ptp_tx_tstamp_work()
1201 spin_unlock(&tx->lock); in ice_ptp_tx_tstamp_work()
1220 spin_lock(&tx->lock); in ice_ptp_tx_tstamp_work()
1221 if (!bitmap_empty(tx->in_use, tx->len)) in ice_ptp_tx_tstamp_work()
1222 kthread_queue_work(pf->ptp.kworker, &tx->work); in ice_ptp_tx_tstamp_work()
1223 spin_unlock(&tx->lock); in ice_ptp_tx_tstamp_work()
1227 * ice_ptp_request_ts - Request an available Tx timestamp index
1228 * @tx: the PTP Tx timestamp tracker to request from
1231 s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb) in ice_ptp_request_ts() argument
1236 if (!tx->init) in ice_ptp_request_ts()
1239 spin_lock(&tx->lock); in ice_ptp_request_ts()
1241 idx = find_first_zero_bit(tx->in_use, tx->len); in ice_ptp_request_ts()
1242 if (idx < tx->len) { in ice_ptp_request_ts()
1247 set_bit(idx, tx->in_use); in ice_ptp_request_ts()
1248 tx->tstamps[idx].start = jiffies; in ice_ptp_request_ts()
1249 tx->tstamps[idx].skb = skb_get(skb); in ice_ptp_request_ts()
1253 spin_unlock(&tx->lock); in ice_ptp_request_ts()
1258 if (idx >= tx->len) in ice_ptp_request_ts()
1261 return idx + tx->quad_offset; in ice_ptp_request_ts()
1268 * Queue work required to process the PTP Tx timestamps outside of interrupt
1273 if (pf->ptp.port.tx.init) in ice_ptp_process_ts()
1274 kthread_queue_work(pf->ptp.kworker, &pf->ptp.port.tx.work); in ice_ptp_process_ts()
1278 * ice_ptp_alloc_tx_tracker - Initialize tracking for Tx timestamps
1279 * @tx: Tx tracking structure to initialize
1285 ice_ptp_alloc_tx_tracker(struct ice_ptp_tx *tx) in ice_ptp_alloc_tx_tracker() argument
1287 tx->tstamps = kcalloc(tx->len, sizeof(*tx->tstamps), GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
1288 if (!tx->tstamps) in ice_ptp_alloc_tx_tracker()
1291 tx->in_use = bitmap_zalloc(tx->len, GFP_KERNEL); in ice_ptp_alloc_tx_tracker()
1292 if (!tx->in_use) { in ice_ptp_alloc_tx_tracker()
1293 kfree(tx->tstamps); in ice_ptp_alloc_tx_tracker()
1294 tx->tstamps = NULL; in ice_ptp_alloc_tx_tracker()
1298 spin_lock_init(&tx->lock); in ice_ptp_alloc_tx_tracker()
1299 kthread_init_work(&tx->work, ice_ptp_tx_tstamp_work); in ice_ptp_alloc_tx_tracker()
1301 tx->init = 1; in ice_ptp_alloc_tx_tracker()
1309 * @tx: the tracker to flush
1312 ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_flush_tx_tracker() argument
1316 for (idx = 0; idx < tx->len; idx++) { in ice_ptp_flush_tx_tracker()
1317 u8 phy_idx = idx + tx->quad_offset; in ice_ptp_flush_tx_tracker()
1319 spin_lock(&tx->lock); in ice_ptp_flush_tx_tracker()
1320 if (tx->tstamps[idx].skb) { in ice_ptp_flush_tx_tracker()
1321 dev_kfree_skb_any(tx->tstamps[idx].skb); in ice_ptp_flush_tx_tracker()
1322 tx->tstamps[idx].skb = NULL; in ice_ptp_flush_tx_tracker()
1324 clear_bit(idx, tx->in_use); in ice_ptp_flush_tx_tracker()
1325 spin_unlock(&tx->lock); in ice_ptp_flush_tx_tracker()
1329 ice_clear_phy_tstamp(&pf->hw, tx->quad, phy_idx); in ice_ptp_flush_tx_tracker()
1334 * ice_ptp_release_tx_tracker - Release allocated memory for Tx tracker
1336 * @tx: Tx tracking structure to release
1338 * Free memory associated with the Tx timestamp tracker.
1341 ice_ptp_release_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_release_tx_tracker() argument
1343 tx->init = 0; in ice_ptp_release_tx_tracker()
1345 kthread_cancel_work_sync(&tx->work); in ice_ptp_release_tx_tracker()
1347 ice_ptp_flush_tx_tracker(pf, tx); in ice_ptp_release_tx_tracker()
1349 kfree(tx->tstamps); in ice_ptp_release_tx_tracker()
1350 tx->tstamps = NULL; in ice_ptp_release_tx_tracker()
1352 kfree(tx->in_use); in ice_ptp_release_tx_tracker()
1353 tx->in_use = NULL; in ice_ptp_release_tx_tracker()
1355 tx->len = 0; in ice_ptp_release_tx_tracker()
1359 * ice_ptp_init_tx_e810 - Initialize tracking for Tx timestamps
1361 * @tx: the Tx tracking structure to initialize
1363 * Initialize the Tx timestamp tracker for this PF. For E810 devices, each
1367 ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) in ice_ptp_init_tx_e810() argument
1369 tx->quad = pf->hw.port_info->lport; in ice_ptp_init_tx_e810()
1370 tx->quad_offset = 0; in ice_ptp_init_tx_e810()
1371 tx->len = INDEX_PER_QUAD; in ice_ptp_init_tx_e810()
1373 return ice_ptp_alloc_tx_tracker(tx); in ice_ptp_init_tx_e810()
1378 * @tx: PTP Tx tracker to clean up
1380 * Loop through the Tx timestamp requests and see if any of them have been
1386 static void ice_ptp_tx_tstamp_cleanup(struct ice_ptp_tx *tx) in ice_ptp_tx_tstamp_cleanup() argument
1390 if (!tx->init) in ice_ptp_tx_tstamp_cleanup()
1393 for_each_set_bit(idx, tx->in_use, tx->len) { in ice_ptp_tx_tstamp_cleanup()
1397 if (time_is_after_jiffies(tx->tstamps[idx].start + 2 * HZ)) in ice_ptp_tx_tstamp_cleanup()
1400 spin_lock(&tx->lock); in ice_ptp_tx_tstamp_cleanup()
1401 skb = tx->tstamps[idx].skb; in ice_ptp_tx_tstamp_cleanup()
1402 tx->tstamps[idx].skb = NULL; in ice_ptp_tx_tstamp_cleanup()
1403 clear_bit(idx, tx->in_use); in ice_ptp_tx_tstamp_cleanup()
1404 spin_unlock(&tx->lock); in ice_ptp_tx_tstamp_cleanup()
1421 ice_ptp_tx_tstamp_cleanup(&pf->ptp.port.tx); in ice_ptp_periodic_work()
1528 /* Disable timestamping for both Tx and Rx */ in ice_ptp_init()
1531 /* Initialize the PTP port Tx timestamp tracker */ in ice_ptp_init()
1532 ice_ptp_init_tx_e810(pf, &pf->ptp.port.tx); in ice_ptp_init()
1577 /* Disable timestamping for both Tx and Rx */ in ice_ptp_release()
1580 ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); in ice_ptp_release()