]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: dsa: no longer identify PTP packet in core driver
authorYangbo Lu <yangbo.lu@nxp.com>
Tue, 27 Apr 2021 04:21:58 +0000 (12:21 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Apr 2021 21:10:15 +0000 (14:10 -0700)
Move ptp_classify_raw out of dsa core driver for handling tx
timestamp request. Let device drivers do this if they want.
Not all drivers want to limit tx timestamping for only PTP
packet.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Tested-by: Kurt Kanzenbach <kurt@linutronix.de>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c
drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h
drivers/net/dsa/mv88e6xxx/hwtstamp.c
drivers/net/dsa/mv88e6xxx/hwtstamp.h
drivers/net/dsa/ocelot/felix.c
drivers/net/dsa/sja1105/sja1105_ptp.c
drivers/net/dsa/sja1105/sja1105_ptp.h
include/net/dsa.h
net/dsa/slave.c

index 6ba5e23330667f1c5dc87c63be81f723b005eea3..5b2e023468fe9908a54647cdeb092c671a9ede06 100644 (file)
@@ -374,14 +374,19 @@ long hellcreek_hwtstamp_work(struct ptp_clock_info *ptp)
 }
 
 bool hellcreek_port_txtstamp(struct dsa_switch *ds, int port,
-                            struct sk_buff *clone, unsigned int type)
+                            struct sk_buff *clone)
 {
        struct hellcreek *hellcreek = ds->priv;
        struct hellcreek_port_hwtstamp *ps;
        struct ptp_header *hdr;
+       unsigned int type;
 
        ps = &hellcreek->ports[port].port_hwtstamp;
 
+       type = ptp_classify_raw(clone);
+       if (type == PTP_CLASS_NONE)
+               return false;
+
        /* Make sure the message is a PTP message that needs to be timestamped
         * and the interaction with the HW timestamping is enabled. If not, stop
         * here
index c0745ffa1ebbd8a96a47001cc7ca311254999e61..728cd5dc650f03c66e452127d890ebf6683d641f 100644 (file)
@@ -45,7 +45,7 @@ int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port,
 bool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port,
                             struct sk_buff *clone, unsigned int type);
 bool hellcreek_port_txtstamp(struct dsa_switch *ds, int port,
-                            struct sk_buff *clone, unsigned int type);
+                            struct sk_buff *clone);
 
 int hellcreek_get_ts_info(struct dsa_switch *ds, int port,
                          struct ethtool_ts_info *info);
index 05ca1d3c6498a19ed156f8641e95a929c8018f2e..79514a54d9030514a3cae05849f25b532113a514 100644 (file)
@@ -469,11 +469,16 @@ long mv88e6xxx_hwtstamp_work(struct ptp_clock_info *ptp)
 }
 
 bool mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port,
-                            struct sk_buff *clone, unsigned int type)
+                            struct sk_buff *clone)
 {
        struct mv88e6xxx_chip *chip = ds->priv;
        struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
        struct ptp_header *hdr;
+       unsigned int type;
+
+       type = ptp_classify_raw(clone);
+       if (type == PTP_CLASS_NONE)
+               return false;
 
        hdr = mv88e6xxx_should_tstamp(chip, port, clone, type);
        if (!hdr)
index 9da9f197ba02fe8ea7069dc5aa1b22206d67c2ce..91fbc7838fc87fc14cb811307bb6e48069b13500 100644 (file)
@@ -118,7 +118,7 @@ int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, int port,
 bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,
                             struct sk_buff *clone, unsigned int type);
 bool mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port,
-                            struct sk_buff *clone, unsigned int type);
+                            struct sk_buff *clone);
 
 int mv88e6xxx_get_ts_info(struct dsa_switch *ds, int port,
                          struct ethtool_ts_info *info);
@@ -152,8 +152,7 @@ static inline bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,
 }
 
 static inline bool mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port,
-                                          struct sk_buff *clone,
-                                          unsigned int type)
+                                          struct sk_buff *clone)
 {
        return false;
 }
index 1379f86d71eceb00fbe854c20ceda5847d3195d6..d679f023dc0019bd1af646a14723590a87edaa8d 100644 (file)
@@ -1396,7 +1396,7 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port,
 }
 
 static bool felix_txtstamp(struct dsa_switch *ds, int port,
-                          struct sk_buff *clone, unsigned int type)
+                          struct sk_buff *clone)
 {
        struct ocelot *ocelot = ds->priv;
        struct ocelot_port *ocelot_port = ocelot->ports[port];
index 1b90570b257b5041d67579d3b47fa037aca17fad..72d052de82d8986e7bcb163e82ae7e5f46bda5d5 100644 (file)
@@ -435,8 +435,7 @@ bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port,
  * the skb and have it available in DSA_SKB_CB in the .port_deferred_xmit
  * callback, where we will timestamp it synchronously.
  */
-bool sja1105_port_txtstamp(struct dsa_switch *ds, int port,
-                          struct sk_buff *skb, unsigned int type)
+bool sja1105_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
 {
        struct sja1105_private *priv = ds->priv;
        struct sja1105_port *sp = &priv->ports[port];
index 3daa33e98e77bcf613203dc7d42c187e02ca237f..c70c4729a06d73b2076684c4e718919ac82442b8 100644 (file)
@@ -105,7 +105,7 @@ bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port,
                           struct sk_buff *skb, unsigned int type);
 
 bool sja1105_port_txtstamp(struct dsa_switch *ds, int port,
-                          struct sk_buff *skb, unsigned int type);
+                          struct sk_buff *skb);
 
 int sja1105_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr);
 
index 507082959aa4f055cecc0636f2a30c641d90a820..905066055b08d97e21772dd0b3ee4402c2fd2d6e 100644 (file)
@@ -741,7 +741,7 @@ struct dsa_switch_ops {
        int     (*port_hwtstamp_set)(struct dsa_switch *ds, int port,
                                     struct ifreq *ifr);
        bool    (*port_txtstamp)(struct dsa_switch *ds, int port,
-                                struct sk_buff *clone, unsigned int type);
+                                struct sk_buff *clone);
        bool    (*port_rxtstamp)(struct dsa_switch *ds, int port,
                                 struct sk_buff *skb, unsigned int type);
 
index b2a802e9330e84e9506853c7d1d646fb7948d39e..acaa52e60d7f09d5287795dca5b966a5fbcb8f99 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/if_bridge.h>
 #include <linux/if_hsr.h>
 #include <linux/netpoll.h>
-#include <linux/ptp_classify.h>
 
 #include "dsa_priv.h"
 
@@ -557,15 +556,10 @@ static void dsa_skb_tx_timestamp(struct dsa_slave_priv *p,
 {
        struct dsa_switch *ds = p->dp->ds;
        struct sk_buff *clone;
-       unsigned int type;
 
        if (!(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))
                return;
 
-       type = ptp_classify_raw(skb);
-       if (type == PTP_CLASS_NONE)
-               return;
-
        if (!ds->ops->port_txtstamp)
                return;
 
@@ -573,7 +567,7 @@ static void dsa_skb_tx_timestamp(struct dsa_slave_priv *p,
        if (!clone)
                return;
 
-       if (ds->ops->port_txtstamp(ds, p->dp->index, clone, type)) {
+       if (ds->ops->port_txtstamp(ds, p->dp->index, clone)) {
                DSA_SKB_CB(skb)->clone = clone;
                return;
        }
@@ -632,9 +626,7 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
 
        DSA_SKB_CB(skb)->clone = NULL;
 
-       /* Identify PTP protocol packets, clone them, and pass them to the
-        * switch driver
-        */
+       /* Handle tx timestamp if any */
        dsa_skb_tx_timestamp(p, skb);
 
        if (dsa_realloc_skb(skb, dev)) {