Skip to content

Commit 8f18655

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dsa: don't call ptp_classify_raw() if switch doesn't provide RX timestamping
ptp_classify_raw() is not exactly cheap, since it invokes a BPF program for every skb in the receive path. For switches which do not provide ds->ops->port_rxtstamp(), running ptp_classify_raw() provides precisely nothing, so check for the presence of the function pointer first, since that is much cheaper. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Kurt Kanzenbach <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent cd2aafa commit 8f18655

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/dsa/tag.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ static bool dsa_skb_defer_rx_timestamp(struct dsa_slave_priv *p,
3333
struct dsa_switch *ds = p->dp->ds;
3434
unsigned int type;
3535

36+
if (!ds->ops->port_rxtstamp)
37+
return false;
38+
3639
if (skb_headroom(skb) < ETH_HLEN)
3740
return false;
3841

@@ -45,10 +48,7 @@ static bool dsa_skb_defer_rx_timestamp(struct dsa_slave_priv *p,
4548
if (type == PTP_CLASS_NONE)
4649
return false;
4750

48-
if (likely(ds->ops->port_rxtstamp))
49-
return ds->ops->port_rxtstamp(ds, p->dp->index, skb, type);
50-
51-
return false;
51+
return ds->ops->port_rxtstamp(ds, p->dp->index, skb, type);
5252
}
5353

5454
static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,

0 commit comments

Comments
 (0)