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 <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de> Link: https://lore.kernel.org/r/20221209175840.390707-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
cd2aafa25b
commit
8f18655c49
@ -33,6 +33,9 @@ static bool dsa_skb_defer_rx_timestamp(struct dsa_slave_priv *p,
|
|||||||
struct dsa_switch *ds = p->dp->ds;
|
struct dsa_switch *ds = p->dp->ds;
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
|
|
||||||
|
if (!ds->ops->port_rxtstamp)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (skb_headroom(skb) < ETH_HLEN)
|
if (skb_headroom(skb) < ETH_HLEN)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -45,10 +48,7 @@ static bool dsa_skb_defer_rx_timestamp(struct dsa_slave_priv *p,
|
|||||||
if (type == PTP_CLASS_NONE)
|
if (type == PTP_CLASS_NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (likely(ds->ops->port_rxtstamp))
|
return ds->ops->port_rxtstamp(ds, p->dp->index, skb, type);
|
||||||
return ds->ops->port_rxtstamp(ds, p->dp->index, skb, type);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
|
static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user