xref: /OK3568_Linux_fs/kernel/include/linux/dsa/sja1105.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun  * Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com>
3*4882a593Smuzhiyun  */
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun /* Included by drivers/net/dsa/sja1105/sja1105.h and net/dsa/tag_sja1105.c */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef _NET_DSA_SJA1105_H
8*4882a593Smuzhiyun #define _NET_DSA_SJA1105_H
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/skbuff.h>
11*4882a593Smuzhiyun #include <linux/etherdevice.h>
12*4882a593Smuzhiyun #include <linux/dsa/8021q.h>
13*4882a593Smuzhiyun #include <net/dsa.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #define ETH_P_SJA1105				ETH_P_DSA_8021Q
16*4882a593Smuzhiyun #define ETH_P_SJA1105_META			0x0008
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /* IEEE 802.3 Annex 57A: Slow Protocols PDUs (01:80:C2:xx:xx:xx) */
19*4882a593Smuzhiyun #define SJA1105_LINKLOCAL_FILTER_A		0x0180C2000000ull
20*4882a593Smuzhiyun #define SJA1105_LINKLOCAL_FILTER_A_MASK		0xFFFFFF000000ull
21*4882a593Smuzhiyun /* IEEE 1588 Annex F: Transport of PTP over Ethernet (01:1B:19:xx:xx:xx) */
22*4882a593Smuzhiyun #define SJA1105_LINKLOCAL_FILTER_B		0x011B19000000ull
23*4882a593Smuzhiyun #define SJA1105_LINKLOCAL_FILTER_B_MASK		0xFFFFFF000000ull
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /* Source and Destination MAC of follow-up meta frames.
26*4882a593Smuzhiyun  * Whereas the choice of SMAC only affects the unique identification of the
27*4882a593Smuzhiyun  * switch as sender of meta frames, the DMAC must be an address that is present
28*4882a593Smuzhiyun  * in the DSA master port's multicast MAC filter.
29*4882a593Smuzhiyun  * 01-80-C2-00-00-0E is a good choice for this, as all profiles of IEEE 1588
30*4882a593Smuzhiyun  * over L2 use this address for some purpose already.
31*4882a593Smuzhiyun  */
32*4882a593Smuzhiyun #define SJA1105_META_SMAC			0x222222222222ull
33*4882a593Smuzhiyun #define SJA1105_META_DMAC			0x0180C200000Eull
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define SJA1105_HWTS_RX_EN			0
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun /* Global tagger data: each struct sja1105_port has a reference to
38*4882a593Smuzhiyun  * the structure defined in struct sja1105_private.
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun struct sja1105_tagger_data {
41*4882a593Smuzhiyun 	struct sk_buff *stampable_skb;
42*4882a593Smuzhiyun 	/* Protects concurrent access to the meta state machine
43*4882a593Smuzhiyun 	 * from taggers running on multiple ports on SMP systems
44*4882a593Smuzhiyun 	 */
45*4882a593Smuzhiyun 	spinlock_t meta_lock;
46*4882a593Smuzhiyun 	unsigned long state;
47*4882a593Smuzhiyun };
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun struct sja1105_skb_cb {
50*4882a593Smuzhiyun 	u32 meta_tstamp;
51*4882a593Smuzhiyun };
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun #define SJA1105_SKB_CB(skb) \
54*4882a593Smuzhiyun 	((struct sja1105_skb_cb *)DSA_SKB_CB_PRIV(skb))
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun struct sja1105_port {
57*4882a593Smuzhiyun 	u16 subvlan_map[DSA_8021Q_N_SUBVLAN];
58*4882a593Smuzhiyun 	struct kthread_worker *xmit_worker;
59*4882a593Smuzhiyun 	struct kthread_work xmit_work;
60*4882a593Smuzhiyun 	struct sk_buff_head xmit_queue;
61*4882a593Smuzhiyun 	struct sja1105_tagger_data *data;
62*4882a593Smuzhiyun 	struct dsa_port *dp;
63*4882a593Smuzhiyun 	bool hwts_tx_en;
64*4882a593Smuzhiyun 	u16 xmit_tpid;
65*4882a593Smuzhiyun };
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #endif /* _NET_DSA_SJA1105_H */
68