summaryrefslogtreecommitdiff
path: root/include/linux/dsa/sja1105.h
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2021-12-10 02:34:40 +0300
committerDavid S. Miller <davem@davemloft.net>2021-12-12 15:51:33 +0300
commitd38049bbe7601f38d598f5da5ff09980483b290a (patch)
tree426fd792105d44847bbe5175d99371ac37e37832 /include/linux/dsa/sja1105.h
parenta3d74295d7906ed793e1fd77603b38bb626a6bdb (diff)
downloadlinux-d38049bbe7601f38d598f5da5ff09980483b290a.tar.xz
net: dsa: sja1105: bring deferred xmit implementation in line with ocelot-8021q
When the ocelot-8021q driver was converted to deferred xmit as part of commit 8d5f7954b7c8 ("net: dsa: felix: break at first CPU port during init and teardown"), the deferred implementation was deliberately made subtly different from what sja1105 has. The implementation differences lied on the following observations: - There might be a race between these two lines in tag_sja1105.c: skb_queue_tail(&sp->xmit_queue, skb_get(skb)); kthread_queue_work(sp->xmit_worker, &sp->xmit_work); and the skb dequeue logic in sja1105_port_deferred_xmit(). For example, the xmit_work might be already queued, however the work item has just finished walking through the skb queue. Because we don't check the return code from kthread_queue_work, we don't do anything if the work item is already queued. However, nobody will take that skb and send it, at least until the next timestampable skb is sent. This creates additional (and avoidable) TX timestamping latency. To close that race, what the ocelot-8021q driver does is it doesn't keep a single work item per port, and a skb timestamping queue, but rather dynamically allocates a work item per packet. - It is also unnecessary to have more than one kthread that does the work. So delete the per-port kthread allocations and replace them with a single kthread which is global to the switch. This change brings the two implementations in line by applying those observations to the sja1105 driver as well. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/dsa/sja1105.h')
-rw-r--r--include/linux/dsa/sja1105.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/include/linux/dsa/sja1105.h b/include/linux/dsa/sja1105.h
index e6c78be40bde..acd9d2afccab 100644
--- a/include/linux/dsa/sja1105.h
+++ b/include/linux/dsa/sja1105.h
@@ -37,6 +37,12 @@
#define SJA1105_HWTS_RX_EN 0
+struct sja1105_deferred_xmit_work {
+ struct dsa_port *dp;
+ struct sk_buff *skb;
+ struct kthread_work work;
+};
+
/* Global tagger data: each struct sja1105_port has a reference to
* the structure defined in struct sja1105_private.
*/
@@ -52,6 +58,8 @@ struct sja1105_tagger_data {
* 2-step TX timestamps
*/
struct sk_buff_head skb_txtstamp_queue;
+ struct kthread_worker *xmit_worker;
+ void (*xmit_work_fn)(struct kthread_work *work);
};
struct sja1105_skb_cb {
@@ -65,9 +73,6 @@ struct sja1105_skb_cb {
((struct sja1105_skb_cb *)((skb)->cb))
struct sja1105_port {
- struct kthread_worker *xmit_worker;
- struct kthread_work xmit_work;
- struct sk_buff_head xmit_queue;
struct sja1105_tagger_data *data;
bool hwts_tx_en;
};