No functional change, this is in preparation for later patches. Introduce i40e_ptp_rx_hwtstamp_raw() that doesn't depend on skb pointer as input. Keep i40e_ptp_rx_hwtstamp with same semantics as before. Signed-off-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx> --- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 36 +++++++++++++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index d86b6d349ea9..859e11f4e884 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -1262,6 +1262,7 @@ void i40e_ptp_rx_hang(struct i40e_pf *pf); void i40e_ptp_tx_hang(struct i40e_pf *pf); void i40e_ptp_tx_hwtstamp(struct i40e_pf *pf); void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index); +u64 i40e_ptp_rx_hwtstamp_raw(struct i40e_pf *pf, u8 index); void i40e_ptp_set_increment(struct i40e_pf *pf); int i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr); int i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr); diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c index 2d3533f38d7b..ec33d783f6ee 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c @@ -808,18 +808,16 @@ void i40e_ptp_tx_hwtstamp(struct i40e_pf *pf) } /** - * i40e_ptp_rx_hwtstamp - Utility function which checks for an Rx timestamp + * i40e_ptp_rx_hwtstamp_raw - Utility function which checks for an Rx timestamp * @pf: Board private structure - * @skb: Particular skb to send timestamp with * @index: Index into the receive timestamp registers for the timestamp * * The XL710 receives a notification in the receive descriptor with an offset - * into the set of RXTIME registers where the timestamp is for that skb. This + * into the set of RXTIME registers where the timestamp is for that pkt. This * function goes and fetches the receive timestamp from that offset, if a valid - * one exists. The RXTIME registers are in ns, so we must convert the result - * first. + * one exists, else zero is returned. **/ -void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index) +u64 i40e_ptp_rx_hwtstamp_raw(struct i40e_pf *pf, u8 index) { u32 prttsyn_stat, hi, lo; struct i40e_hw *hw; @@ -829,7 +827,7 @@ void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index) * doing Tx timestamping, check if Rx timestamping is configured. */ if (!(pf->flags & I40E_FLAG_PTP) || !pf->ptp_rx) - return; + return 0; hw = &pf->hw; @@ -841,7 +839,7 @@ void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index) /* TODO: Should we warn about missing Rx timestamp event? */ if (!(prttsyn_stat & BIT(index))) { spin_unlock_bh(&pf->ptp_rx_lock); - return; + return 0; } /* Clear the latched event since we're about to read its register */ @@ -854,7 +852,27 @@ void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index) ns = (((u64)hi) << 32) | lo; - i40e_ptp_convert_to_hwtstamp(skb_hwtstamps(skb), ns); + return ns; +} + +/** + * i40e_ptp_rx_hwtstamp - Utility function which checks for an Rx timestamp + * @pf: Board private structure + * @skb: Particular skb to send timestamp with + * @index: Index into the receive timestamp registers for the timestamp + * + * The XL710 receives a notification in the receive descriptor with an offset + * into the set of RXTIME registers where the timestamp is for that skb. This + * function goes and fetches the receive timestamp from that offset, if a valid + * one exists. The RXTIME registers are in ns, so we must convert the result + * first. + **/ +void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index) +{ + u64 ns = i40e_ptp_rx_hwtstamp_raw(pf, index); + + if (ns) + i40e_ptp_convert_to_hwtstamp(skb_hwtstamps(skb), ns); } /**