net: ravb: Break out Rx hardware timestamping
Prepare for moving away from device specific bit-fields to track how to do hardware Rx timestamping to using net common enums by breaking out the timestamping to a helper function. This is done to create cleaner code and prepare for easier changes improving the hardware timestapming. There is no functional change. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Link: https://patch.msgid.link/20251104222420.882731-7-niklas.soderlund+renesas@ragnatech.se Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
3614d249d1
commit
5ce97b8d61
@@ -946,6 +946,29 @@ refill:
|
||||
return rx_packets;
|
||||
}
|
||||
|
||||
static void ravb_rx_rcar_hwstamp(struct ravb_private *priv, int q,
|
||||
struct ravb_ex_rx_desc *desc,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
u32 get_ts = priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE;
|
||||
struct skb_shared_hwtstamps *shhwtstamps;
|
||||
struct timespec64 ts;
|
||||
|
||||
get_ts &= (q == RAVB_NC) ?
|
||||
RAVB_RXTSTAMP_TYPE_V2_L2_EVENT :
|
||||
~RAVB_RXTSTAMP_TYPE_V2_L2_EVENT;
|
||||
|
||||
if (!get_ts)
|
||||
return;
|
||||
|
||||
shhwtstamps = skb_hwtstamps(skb);
|
||||
memset(shhwtstamps, 0, sizeof(*shhwtstamps));
|
||||
ts.tv_sec = ((u64)le16_to_cpu(desc->ts_sh) << 32)
|
||||
| le32_to_cpu(desc->ts_sl);
|
||||
ts.tv_nsec = le32_to_cpu(desc->ts_n);
|
||||
shhwtstamps->hwtstamp = timespec64_to_ktime(ts);
|
||||
}
|
||||
|
||||
/* Packet receive function for Ethernet AVB */
|
||||
static int ravb_rx_rcar(struct net_device *ndev, int budget, int q)
|
||||
{
|
||||
@@ -955,7 +978,6 @@ static int ravb_rx_rcar(struct net_device *ndev, int budget, int q)
|
||||
struct ravb_ex_rx_desc *desc;
|
||||
unsigned int limit, i;
|
||||
struct sk_buff *skb;
|
||||
struct timespec64 ts;
|
||||
int rx_packets = 0;
|
||||
u8 desc_status;
|
||||
u16 pkt_len;
|
||||
@@ -992,7 +1014,6 @@ static int ravb_rx_rcar(struct net_device *ndev, int budget, int q)
|
||||
if (desc_status & MSC_CEEF)
|
||||
stats->rx_missed_errors++;
|
||||
} else {
|
||||
u32 get_ts = priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE;
|
||||
struct ravb_rx_buffer *rx_buff;
|
||||
void *rx_addr;
|
||||
|
||||
@@ -1010,19 +1031,8 @@ static int ravb_rx_rcar(struct net_device *ndev, int budget, int q)
|
||||
break;
|
||||
}
|
||||
skb_mark_for_recycle(skb);
|
||||
get_ts &= (q == RAVB_NC) ?
|
||||
RAVB_RXTSTAMP_TYPE_V2_L2_EVENT :
|
||||
~RAVB_RXTSTAMP_TYPE_V2_L2_EVENT;
|
||||
if (get_ts) {
|
||||
struct skb_shared_hwtstamps *shhwtstamps;
|
||||
|
||||
shhwtstamps = skb_hwtstamps(skb);
|
||||
memset(shhwtstamps, 0, sizeof(*shhwtstamps));
|
||||
ts.tv_sec = ((u64) le16_to_cpu(desc->ts_sh) <<
|
||||
32) | le32_to_cpu(desc->ts_sl);
|
||||
ts.tv_nsec = le32_to_cpu(desc->ts_n);
|
||||
shhwtstamps->hwtstamp = timespec64_to_ktime(ts);
|
||||
}
|
||||
ravb_rx_rcar_hwstamp(priv, q, desc, skb);
|
||||
|
||||
skb_put(skb, pkt_len);
|
||||
skb->protocol = eth_type_trans(skb, ndev);
|
||||
|
||||
Reference in New Issue
Block a user