public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Martin Kaistra <martin.kaistra@linutronix.de>,
	Kurt Kanzenbach <kurt@linutronix.de>,
	Ansuel Smith <ansuelsmth@gmail.com>,
	Tobias Waldekranz <tobias@waldekranz.com>
Subject: [PATCH net-next 07/11] net: dsa: sja1105: move ts_id from sja1105_tagger_data
Date: Wed,  8 Dec 2021 22:05:00 +0200	[thread overview]
Message-ID: <20211208200504.3136642-8-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20211208200504.3136642-1-vladimir.oltean@nxp.com>

The TX timestamp ID is incremented by the SJA1110 PTP timestamping
callback (->port_tx_timestamp) for every packet, when cloning it.
It isn't used by the tagger at all, even though it sits inside the
struct sja1105_tagger_data.

Also, serialization to this structure is currently done through
tagger_data->meta_lock, which is a cheap hack because the meta_lock
isn't used for anything else on SJA1110 (sja1105_rcv_meta_state_machine
isn't called).

This change moves ts_id from sja1105_tagger_data to sja1105_private and
introduces a dedicated spinlock for it, also in sja1105_private.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/sja1105/sja1105.h      | 3 +++
 drivers/net/dsa/sja1105/sja1105_main.c | 1 +
 drivers/net/dsa/sja1105/sja1105_ptp.c  | 8 ++++----
 include/linux/dsa/sja1105.h            | 1 -
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h
index 6ef6fb4f30e6..850a7d3e69bb 100644
--- a/drivers/net/dsa/sja1105/sja1105.h
+++ b/drivers/net/dsa/sja1105/sja1105.h
@@ -261,6 +261,9 @@ struct sja1105_private {
 	 * the switch doesn't confuse them with one another.
 	 */
 	struct mutex mgmt_lock;
+	/* PTP two-step TX timestamp ID, and its serialization lock */
+	spinlock_t ts_id_lock;
+	u8 ts_id;
 	/* Serializes access to the dynamic config interface */
 	struct mutex dynamic_config_lock;
 	struct devlink_region **regions;
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 4f3350df7f4d..6468a8e963e8 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -3349,6 +3349,7 @@ static int sja1105_probe(struct spi_device *spi)
 	mutex_init(&priv->ptp_data.lock);
 	mutex_init(&priv->dynamic_config_lock);
 	mutex_init(&priv->mgmt_lock);
+	spin_lock_init(&priv->ts_id_lock);
 
 	rc = sja1105_parse_dt(priv);
 	if (rc < 0) {
diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
index 9077067328c2..0904ab10bd2f 100644
--- a/drivers/net/dsa/sja1105/sja1105_ptp.c
+++ b/drivers/net/dsa/sja1105/sja1105_ptp.c
@@ -468,15 +468,15 @@ void sja1110_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
 
 	skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
 
-	spin_lock(&tagger_data->meta_lock);
+	spin_lock(&priv->ts_id_lock);
 
-	ts_id = tagger_data->ts_id;
+	ts_id = priv->ts_id;
 	/* Deal automatically with 8-bit wraparound */
-	tagger_data->ts_id++;
+	priv->ts_id++;
 
 	SJA1105_SKB_CB(clone)->ts_id = ts_id;
 
-	spin_unlock(&tagger_data->meta_lock);
+	spin_unlock(&priv->ts_id_lock);
 
 	skb_queue_tail(&tagger_data->skb_txtstamp_queue, clone);
 }
diff --git a/include/linux/dsa/sja1105.h b/include/linux/dsa/sja1105.h
index 1dda9cce85d9..d8ee53085c09 100644
--- a/include/linux/dsa/sja1105.h
+++ b/include/linux/dsa/sja1105.h
@@ -51,7 +51,6 @@ struct sja1105_tagger_data {
 	 */
 	spinlock_t meta_lock;
 	unsigned long state;
-	u8 ts_id;
 	/* Used on SJA1110 where meta frames are generated only for
 	 * 2-step TX timestamps
 	 */
-- 
2.25.1


  parent reply	other threads:[~2021-12-08 20:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 20:04 [PATCH net-next 00/11] Replace DSA dp->priv with tagger-owned storage Vladimir Oltean
2021-12-08 20:04 ` [PATCH net-next 01/11] net: dsa: introduce tagger-owned storage for private and shared data Vladimir Oltean
2021-12-08 20:04 ` [PATCH net-next 02/11] net: dsa: tag_ocelot: convert to tagger-owned data Vladimir Oltean
2021-12-08 20:04 ` [PATCH net-next 03/11] net: dsa: sja1105: let deferred packets time out when sent to ports going down Vladimir Oltean
2021-12-08 20:04 ` [PATCH net-next 04/11] net: dsa: sja1105: bring in line deferred xmit implementation with ocelot-8021q Vladimir Oltean
2021-12-08 20:04 ` [PATCH net-next 05/11] net: dsa: sja1105: remove hwts_tx_en from tagger data Vladimir Oltean
2021-12-09  0:13   ` Jakub Kicinski
2021-12-09  0:14     ` Vladimir Oltean
2021-12-08 20:04 ` [PATCH net-next 06/11] net: dsa: sja1105: make dp->priv point directly to sja1105_tagger_data Vladimir Oltean
2021-12-08 20:05 ` Vladimir Oltean [this message]
2021-12-08 20:05 ` [PATCH net-next 08/11] net: dsa: tag_sja1105: convert to tagger-owned data Vladimir Oltean
2021-12-08 20:05 ` [PATCH net-next 09/11] Revert "net: dsa: move sja1110_process_meta_tstamp inside the tagging protocol driver" Vladimir Oltean
2021-12-08 20:05 ` [PATCH net-next 10/11] net: dsa: tag_sja1105: split sja1105_tagger_data into private and public sections Vladimir Oltean
2021-12-08 20:05 ` [PATCH net-next 11/11] net: dsa: remove dp->priv Vladimir Oltean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211208200504.3136642-8-vladimir.oltean@nxp.com \
    --to=vladimir.oltean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=martin.kaistra@linutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=tobias@waldekranz.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox