Commit c4b364ce authored by Yangbo Lu's avatar Yangbo Lu Committed by David S. Miller
Browse files

net: dsa: free skb->cb usage in core driver



Free skb->cb usage in core driver and let device drivers decide to
use or not. The reason having a DSA_SKB_CB(skb)->clone was because
dsa_skb_tx_timestamp() which may set the clone pointer was called
before p->xmit() which would use the clone if any, and the device
driver has no way to initialize the clone pointer.

This patch just put memset(skb->cb, 0, sizeof(skb->cb)) at beginning
of dsa_slave_xmit(). Some new features in the future, like one-step
timestamp may need more bytes of skb->cb to use in
dsa_skb_tx_timestamp(), and p->xmit().

Signed-off-by: default avatarYangbo Lu <yangbo.lu@nxp.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c5416f5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1408,7 +1408,7 @@ static void felix_txtstamp(struct dsa_switch *ds, int port,
			return;

		ocelot_port_add_txtstamp_skb(ocelot, port, clone);
		DSA_SKB_CB(skb)->clone = clone;
		OCELOT_SKB_CB(skb)->clone = clone;
	}
}

+1 −1
Original line number Diff line number Diff line
@@ -3137,7 +3137,7 @@ static void sja1105_port_deferred_xmit(struct kthread_work *work)
	struct sk_buff *skb;

	while ((skb = skb_dequeue(&sp->xmit_queue)) != NULL) {
		struct sk_buff *clone = DSA_SKB_CB(skb)->clone;
		struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone;

		mutex_lock(&priv->mgmt_lock);

+2 −2
Original line number Diff line number Diff line
@@ -432,7 +432,7 @@ bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port,
}

/* Called from dsa_skb_tx_timestamp. This callback is just to clone
 * the skb and have it available in DSA_SKB_CB in the .port_deferred_xmit
 * the skb and have it available in SJA1105_SKB_CB in the .port_deferred_xmit
 * callback, where we will timestamp it synchronously.
 */
void sja1105_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
@@ -448,7 +448,7 @@ void sja1105_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
	if (!clone)
		return;

	DSA_SKB_CB(skb)->clone = clone;
	SJA1105_SKB_CB(skb)->clone = clone;
}

static int sja1105_ptp_reset(struct dsa_switch *ds)
+3 −3
Original line number Diff line number Diff line
@@ -538,8 +538,8 @@ void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
	spin_lock(&ocelot_port->ts_id_lock);

	skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS;
	/* Store timestamp ID in cb[0] of sk_buff */
	clone->cb[0] = ocelot_port->ts_id;
	/* Store timestamp ID in OCELOT_SKB_CB(clone)->ts_id */
	OCELOT_SKB_CB(clone)->ts_id = ocelot_port->ts_id;
	ocelot_port->ts_id = (ocelot_port->ts_id + 1) % 4;
	skb_queue_tail(&ocelot_port->tx_skbs, clone);

@@ -604,7 +604,7 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
		spin_lock_irqsave(&port->tx_skbs.lock, flags);

		skb_queue_walk_safe(&port->tx_skbs, skb, skb_tmp) {
			if (skb->cb[0] != id)
			if (OCELOT_SKB_CB(skb)->ts_id != id)
				continue;
			__skb_unlink(skb, &port->tx_skbs);
			skb_match = skb;
+1 −1
Original line number Diff line number Diff line
@@ -520,7 +520,7 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)

			ocelot_port_add_txtstamp_skb(ocelot, port, clone);

			rew_op |= clone->cb[0] << 3;
			rew_op |= OCELOT_SKB_CB(clone)->ts_id << 3;
		}
	}

Loading