Skip to content

Commit ea9b847

Browse files
jacob-kelleranguy11
authored andcommitted
ice: enable transmit timestamps for E810 devices
Add support for enabling Tx timestamp requests for outgoing packets on E810 devices. The ice hardware can support multiple outstanding Tx timestamp requests. When sending a descriptor to hardware, a Tx timestamp request is made by setting a request bit, and assigning an index that represents which Tx timestamp index to store the timestamp in. Hardware makes no effort to synchronize the index use, so it is up to software to ensure that Tx timestamp indexes are not re-used before the timestamp is reported back. To do this, introduce a Tx timestamp tracker which will keep track of currently in-use indexes. In the hot path, if a packet has a timestamp request, an index will be requested from the tracker. Unfortunately, this does require a lock as the indexes are shared across all queues on a PHY. There are not enough indexes to reliably assign only 1 to each queue. For the E810 devices, the timestamp indexes are not shared across PHYs, so each port can have its own tracking. Once hardware captures a timestamp, an interrupt is fired. In this interrupt, trigger a new work item that will figure out which timestamp was completed, and report the timestamp back to the stack. This function loops through the Tx timestamp indexes and checks whether there is now a valid timestamp. If so, it clears the PHY timestamp indication in the PHY memory, locks and removes the SKB and bit in the tracker, then reports the timestamp to the stack. It is possible in some cases that a timestamp request will be initiated but never completed. This might occur if the packet is dropped by software or hardware before it reaches the PHY. Add a task to the periodic work function that will check whether a timestamp request is more than a few seconds old. If so, the timestamp index is cleared in the PHY, and the SKB is released. Just as with Rx timestamps, the Tx timestamps are only 40 bits wide, and use the same overall logic for extending to 64 bits of nanoseconds. With this change, E810 devices should be able to perform basic PTP functionality. Future changes will extend the support to cover the E822-based devices. Signed-off-by: Jacob Keller <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 77a7811 commit ea9b847

File tree

9 files changed

+518
-4
lines changed

9 files changed

+518
-4
lines changed

drivers/net/ethernet/intel/ice/ice_base.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ ice_setup_tx_ctx(struct ice_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf_q)
287287
/* make sure the context is associated with the right VSI */
288288
tlan_ctx->src_vsi = ice_get_hw_vsi_num(hw, vsi->idx);
289289

290+
/* Restrict Tx timestamps to the PF VSI */
291+
switch (vsi->type) {
292+
case ICE_VSI_PF:
293+
tlan_ctx->tsyn_ena = 1;
294+
break;
295+
default:
296+
break;
297+
}
298+
290299
tlan_ctx->tso_ena = ICE_TX_LEGACY;
291300
tlan_ctx->tso_qnum = pf_q;
292301

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,14 +3204,16 @@ ice_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
32043204
if (!test_bit(ICE_FLAG_PTP, pf->flags))
32053205
return ethtool_op_get_ts_info(dev, info);
32063206

3207-
info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
3207+
info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
3208+
SOF_TIMESTAMPING_RX_SOFTWARE |
32083209
SOF_TIMESTAMPING_SOFTWARE |
3210+
SOF_TIMESTAMPING_TX_HARDWARE |
32093211
SOF_TIMESTAMPING_RX_HARDWARE |
32103212
SOF_TIMESTAMPING_RAW_HARDWARE;
32113213

32123214
info->phc_index = ice_get_ptp_clock_index(pf);
32133215

3214-
info->tx_types = BIT(HWTSTAMP_TX_OFF);
3216+
info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
32153217

32163218
info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
32173219

drivers/net/ethernet/intel/ice/ice_hw_autogen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
#define PFINT_MBX_CTL_ITR_INDX_M ICE_M(0x3, 11)
203203
#define PFINT_MBX_CTL_CAUSE_ENA_M BIT(30)
204204
#define PFINT_OICR 0x0016CA00
205+
#define PFINT_OICR_TSYN_TX_M BIT(11)
205206
#define PFINT_OICR_ECC_ERR_M BIT(16)
206207
#define PFINT_OICR_MAL_DETECT_M BIT(19)
207208
#define PFINT_OICR_GRST_M BIT(20)

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi)
12981298
ring->reg_idx = vsi->txq_map[i];
12991299
ring->ring_active = false;
13001300
ring->vsi = vsi;
1301+
ring->tx_tstamps = &pf->ptp.port.tx;
13011302
ring->dev = dev;
13021303
ring->count = vsi->num_tx_desc;
13031304
WRITE_ONCE(vsi->tx_rings[i], ring);

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,6 +2792,11 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
27922792
}
27932793
}
27942794

2795+
if (oicr & PFINT_OICR_TSYN_TX_M) {
2796+
ena_mask &= ~PFINT_OICR_TSYN_TX_M;
2797+
ice_ptp_process_ts(pf);
2798+
}
2799+
27952800
#define ICE_AUX_CRIT_ERR (PFINT_OICR_PE_CRITERR_M | PFINT_OICR_HMC_ERR_M | PFINT_OICR_PE_PUSH_M)
27962801
if (oicr & ICE_AUX_CRIT_ERR) {
27972802
struct iidc_event *event;

0 commit comments

Comments
 (0)