This patch-set is to support ocelot PTP Sync one-step timestamping.
Actually before that, this patch-set cleans up and optimizes the
DSA slave tx timestamp request handling process.
Yangbo Lu (3):
net: dsa: optimize tx timestamp request handling
net: mscc: ocelot: convert to ocelot_port_txtstamp_request()
net: mscc: ocelot: support PTP Sync one-step timestamping
Documentation/networking/timestamping.rst | 7 +-
.../net/dsa/hirschmann/hellcreek_hwtstamp.c | 20 +++--
.../net/dsa/hirschmann/hellcreek_hwtstamp.h | 2 +-
drivers/net/dsa/mv88e6xxx/hwtstamp.c | 21 +++--
drivers/net/dsa/mv88e6xxx/hwtstamp.h | 6 +-
drivers/net/dsa/ocelot/felix.c | 15 ++--
drivers/net/dsa/sja1105/sja1105_ptp.c | 6 +-
drivers/net/dsa/sja1105/sja1105_ptp.h | 2 +-
drivers/net/ethernet/mscc/ocelot.c | 81 ++++++++++++++++++-
drivers/net/ethernet/mscc/ocelot_net.c | 19 ++---
include/net/dsa.h | 2 +-
include/soc/mscc/ocelot.h | 6 +-
net/dsa/slave.c | 20 ++---
net/dsa/tag_ocelot.c | 25 +-----
net/dsa/tag_ocelot_8021q.c | 39 +++------
15 files changed, 158 insertions(+), 113 deletions(-)
base-commit: 392c36e5be1dee19ffce8c8ba8f07f90f5aa3f7c
--
2.25.1
Convert to a common ocelot_port_txtstamp_request() for TX timestamp
request handling.
Signed-off-by: Yangbo Lu <[email protected]>
---
drivers/net/dsa/ocelot/felix.c | 14 +++++---------
drivers/net/ethernet/mscc/ocelot.c | 24 +++++++++++++++++++++---
drivers/net/ethernet/mscc/ocelot_net.c | 18 +++++++-----------
include/soc/mscc/ocelot.h | 5 +++--
4 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index cdec2f5e271c..5f2cf0f31253 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1399,18 +1399,14 @@ static bool felix_txtstamp(struct dsa_switch *ds, int port,
struct sk_buff *skb, struct sk_buff **clone)
{
struct ocelot *ocelot = ds->priv;
- struct ocelot_port *ocelot_port = ocelot->ports[port];
- if (ocelot->ptp && ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
- *clone = skb_clone_sk(skb);
- if (!(*clone))
- return false;
+ if (!ocelot->ptp)
+ return false;
- ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
- return true;
- }
+ if (ocelot_port_txtstamp_request(ocelot, port, skb, clone))
+ return false;
- return false;
+ return true;
}
static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 8d06ffaf318a..541d3b4076be 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -530,8 +530,8 @@ void ocelot_port_disable(struct ocelot *ocelot, int port)
}
EXPORT_SYMBOL(ocelot_port_disable);
-void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
- struct sk_buff *clone)
+static void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
+ struct sk_buff *clone)
{
struct ocelot_port *ocelot_port = ocelot->ports[port];
@@ -545,7 +545,25 @@ void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
spin_unlock(&ocelot_port->ts_id_lock);
}
-EXPORT_SYMBOL(ocelot_port_add_txtstamp_skb);
+
+int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
+ struct sk_buff *skb,
+ struct sk_buff **clone)
+{
+ struct ocelot_port *ocelot_port = ocelot->ports[port];
+ u8 ptp_cmd = ocelot_port->ptp_cmd;
+
+ if (ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
+ *clone = skb_clone_sk(skb);
+ if (!(*clone))
+ return -ENOMEM;
+
+ ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(ocelot_port_txtstamp_request);
static void ocelot_get_hwtimestamp(struct ocelot *ocelot,
struct timespec64 *ts)
diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
index 36f32a4d9b0f..8293152a6dc1 100644
--- a/drivers/net/ethernet/mscc/ocelot_net.c
+++ b/drivers/net/ethernet/mscc/ocelot_net.c
@@ -507,19 +507,15 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
/* Check if timestamping is needed */
if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
- rew_op = ocelot_port->ptp_cmd;
+ struct sk_buff *clone;
- if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
- struct sk_buff *clone;
-
- clone = skb_clone_sk(skb);
- if (!clone) {
- kfree_skb(skb);
- return NETDEV_TX_OK;
- }
-
- ocelot_port_add_txtstamp_skb(ocelot, port, clone);
+ if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) {
+ kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
+ if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
+ rew_op = ocelot_port->ptp_cmd;
rew_op |= clone->cb[0] << 3;
}
}
diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
index 68cdc7ceaf4d..9cdaf1d9199f 100644
--- a/include/soc/mscc/ocelot.h
+++ b/include/soc/mscc/ocelot.h
@@ -820,8 +820,9 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);
int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
-void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
- struct sk_buff *clone);
+int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
+ struct sk_buff *skb,
+ struct sk_buff **clone);
void ocelot_get_txtstamp(struct ocelot *ocelot);
void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
int ocelot_get_max_mtu(struct ocelot *ocelot, int port);
--
2.25.1
On Fri, Apr 16, 2021 at 08:36:54PM +0800, Yangbo Lu wrote:
> Convert to a common ocelot_port_txtstamp_request() for TX timestamp
> request handling.
>
> Signed-off-by: Yangbo Lu <[email protected]>
> ---
> drivers/net/dsa/ocelot/felix.c | 14 +++++---------
> drivers/net/ethernet/mscc/ocelot.c | 24 +++++++++++++++++++++---
> drivers/net/ethernet/mscc/ocelot_net.c | 18 +++++++-----------
> include/soc/mscc/ocelot.h | 5 +++--
> 4 files changed, 36 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> index cdec2f5e271c..5f2cf0f31253 100644
> --- a/drivers/net/dsa/ocelot/felix.c
> +++ b/drivers/net/dsa/ocelot/felix.c
> @@ -1399,18 +1399,14 @@ static bool felix_txtstamp(struct dsa_switch *ds, int port,
> struct sk_buff *skb, struct sk_buff **clone)
> {
> struct ocelot *ocelot = ds->priv;
> - struct ocelot_port *ocelot_port = ocelot->ports[port];
>
> - if (ocelot->ptp && ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
> - *clone = skb_clone_sk(skb);
> - if (!(*clone))
> - return false;
> + if (!ocelot->ptp)
> + return false;
>
> - ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
> - return true;
> - }
> + if (ocelot_port_txtstamp_request(ocelot, port, skb, clone))
> + return false;
>
> - return false;
> + return true;
Considering the changes you'll have to make to patch 1 (changing the
return value and populating DSA_SKB_CB(skb)->clone at the end of this
function:
Reviewed-by: Vladimir Oltean <[email protected]>