2019-05-02 23:23:30 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
* Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com>
|
|
|
|
*/
|
|
|
|
|
2019-05-05 13:19:27 +03:00
|
|
|
/* Included by drivers/net/dsa/sja1105/sja1105.h and net/dsa/tag_sja1105.c */
|
2019-05-02 23:23:30 +03:00
|
|
|
|
|
|
|
#ifndef _NET_DSA_SJA1105_H
|
|
|
|
#define _NET_DSA_SJA1105_H
|
|
|
|
|
2019-05-05 13:19:27 +03:00
|
|
|
#include <linux/skbuff.h>
|
2019-05-02 23:23:34 +03:00
|
|
|
#include <linux/etherdevice.h>
|
2020-05-12 20:20:34 +03:00
|
|
|
#include <linux/dsa/8021q.h>
|
2019-05-05 13:19:27 +03:00
|
|
|
#include <net/dsa.h>
|
2019-05-02 23:23:34 +03:00
|
|
|
|
|
|
|
#define ETH_P_SJA1105 ETH_P_DSA_8021Q
|
2019-06-08 15:04:36 +03:00
|
|
|
#define ETH_P_SJA1105_META 0x0008
|
2019-05-02 23:23:34 +03:00
|
|
|
|
2019-05-05 13:19:27 +03:00
|
|
|
/* IEEE 802.3 Annex 57A: Slow Protocols PDUs (01:80:C2:xx:xx:xx) */
|
|
|
|
#define SJA1105_LINKLOCAL_FILTER_A 0x0180C2000000ull
|
|
|
|
#define SJA1105_LINKLOCAL_FILTER_A_MASK 0xFFFFFF000000ull
|
|
|
|
/* IEEE 1588 Annex F: Transport of PTP over Ethernet (01:1B:19:xx:xx:xx) */
|
|
|
|
#define SJA1105_LINKLOCAL_FILTER_B 0x011B19000000ull
|
|
|
|
#define SJA1105_LINKLOCAL_FILTER_B_MASK 0xFFFFFF000000ull
|
|
|
|
|
2019-06-08 15:04:36 +03:00
|
|
|
/* Source and Destination MAC of follow-up meta frames.
|
|
|
|
* Whereas the choice of SMAC only affects the unique identification of the
|
|
|
|
* switch as sender of meta frames, the DMAC must be an address that is present
|
|
|
|
* in the DSA master port's multicast MAC filter.
|
|
|
|
* 01-80-C2-00-00-0E is a good choice for this, as all profiles of IEEE 1588
|
|
|
|
* over L2 use this address for some purpose already.
|
|
|
|
*/
|
|
|
|
#define SJA1105_META_SMAC 0x222222222222ull
|
|
|
|
#define SJA1105_META_DMAC 0x0180C200000Eull
|
|
|
|
|
2019-10-01 21:58:19 +03:00
|
|
|
#define SJA1105_HWTS_RX_EN 0
|
|
|
|
|
2019-06-08 15:04:40 +03:00
|
|
|
/* Global tagger data: each struct sja1105_port has a reference to
|
|
|
|
* the structure defined in struct sja1105_private.
|
|
|
|
*/
|
|
|
|
struct sja1105_tagger_data {
|
|
|
|
struct sk_buff *stampable_skb;
|
|
|
|
/* Protects concurrent access to the meta state machine
|
|
|
|
* from taggers running on multiple ports on SMP systems
|
|
|
|
*/
|
|
|
|
spinlock_t meta_lock;
|
2019-10-01 21:58:19 +03:00
|
|
|
unsigned long state;
|
2019-06-08 15:04:40 +03:00
|
|
|
};
|
|
|
|
|
2019-06-08 15:04:42 +03:00
|
|
|
struct sja1105_skb_cb {
|
|
|
|
u32 meta_tstamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SJA1105_SKB_CB(skb) \
|
|
|
|
((struct sja1105_skb_cb *)DSA_SKB_CB_PRIV(skb))
|
|
|
|
|
2019-05-05 13:19:27 +03:00
|
|
|
struct sja1105_port {
|
2020-05-12 20:20:34 +03:00
|
|
|
u16 subvlan_map[DSA_8021Q_N_SUBVLAN];
|
net: dsa: Make deferred_xmit private to sja1105
There are 3 things that are wrong with the DSA deferred xmit mechanism:
1. Its introduction has made the DSA hotpath ever so slightly more
inefficient for everybody, since DSA_SKB_CB(skb)->deferred_xmit needs
to be initialized to false for every transmitted frame, in order to
figure out whether the driver requested deferral or not (a very rare
occasion, rare even for the only driver that does use this mechanism:
sja1105). That was necessary to avoid kfree_skb from freeing the skb.
2. Because L2 PTP is a link-local protocol like STP, it requires
management routes and deferred xmit with this switch. But as opposed
to STP, the deferred work mechanism needs to schedule the packet
rather quickly for the TX timstamp to be collected in time and sent
to user space. But there is no provision for controlling the
scheduling priority of this deferred xmit workqueue. Too bad this is
a rather specific requirement for a feature that nobody else uses
(more below).
3. Perhaps most importantly, it makes the DSA core adhere a bit too
much to the NXP company-wide policy "Innovate Where It Doesn't
Matter". The sja1105 is probably the only DSA switch that requires
some frames sent from the CPU to be routed to the slave port via an
out-of-band configuration (register write) rather than in-band (DSA
tag). And there are indeed very good reasons to not want to do that:
if that out-of-band register is at the other end of a slow bus such
as SPI, then you limit that Ethernet flow's throughput to effectively
the throughput of the SPI bus. So hardware vendors should definitely
not be encouraged to design this way. We do _not_ want more
widespread use of this mechanism.
Luckily we have a solution for each of the 3 issues:
For 1, we can just remove that variable in the skb->cb and counteract
the effect of kfree_skb with skb_get, much to the same effect. The
advantage, of course, being that anybody who doesn't use deferred xmit
doesn't need to do any extra operation in the hotpath.
For 2, we can create a kernel thread for each port's deferred xmit work.
If the user switch ports are named swp0, swp1, swp2, the kernel threads
will be named swp0_xmit, swp1_xmit, swp2_xmit (there appears to be a 15
character length limit on kernel thread names). With this, the user can
change the scheduling priority with chrt $(pidof swp2_xmit).
For 3, we can actually move the entire implementation to the sja1105
driver.
So this patch deletes the generic implementation from the DSA core and
adds a new one, more adequate to the requirements of PTP TX
timestamping, in sja1105_main.c.
Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-01-04 03:37:10 +03:00
|
|
|
struct kthread_worker *xmit_worker;
|
|
|
|
struct kthread_work xmit_work;
|
|
|
|
struct sk_buff_head xmit_queue;
|
2019-06-08 15:04:40 +03:00
|
|
|
struct sja1105_tagger_data *data;
|
2019-05-05 13:19:27 +03:00
|
|
|
struct dsa_port *dp;
|
2019-06-08 15:04:35 +03:00
|
|
|
bool hwts_tx_en;
|
2020-05-12 20:20:32 +03:00
|
|
|
u16 xmit_tpid;
|
2019-05-05 13:19:27 +03:00
|
|
|
};
|
2019-05-02 23:23:30 +03:00
|
|
|
|
|
|
|
#endif /* _NET_DSA_SJA1105_H */
|