Skip to content

Commit

Permalink
net: dsa: sja1105: move ts_id from sja1105_tagger_data
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vladimir Oltean authored and David S. Miller committed Dec 12, 2021
1 parent bfcf142 commit 22ee9f8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions drivers/net/dsa/sja1105/sja1105.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/dsa/sja1105/sja1105_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3348,6 +3348,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) {
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/dsa/sja1105/sja1105_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion include/linux/dsa/sja1105.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 22ee9f8

Please sign in to comment.