Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0
0002  * Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com>
0003  */
0004 
0005 /* Included by drivers/net/dsa/sja1105/sja1105.h and net/dsa/tag_sja1105.c */
0006 
0007 #ifndef _NET_DSA_SJA1105_H
0008 #define _NET_DSA_SJA1105_H
0009 
0010 #include <linux/skbuff.h>
0011 #include <linux/etherdevice.h>
0012 #include <linux/dsa/8021q.h>
0013 #include <net/dsa.h>
0014 
0015 #define ETH_P_SJA1105               ETH_P_DSA_8021Q
0016 #define ETH_P_SJA1105_META          0x0008
0017 #define ETH_P_SJA1110               0xdadc
0018 
0019 #define SJA1105_DEFAULT_VLAN            (VLAN_N_VID - 1)
0020 
0021 /* IEEE 802.3 Annex 57A: Slow Protocols PDUs (01:80:C2:xx:xx:xx) */
0022 #define SJA1105_LINKLOCAL_FILTER_A      0x0180C2000000ull
0023 #define SJA1105_LINKLOCAL_FILTER_A_MASK     0xFFFFFF000000ull
0024 /* IEEE 1588 Annex F: Transport of PTP over Ethernet (01:1B:19:xx:xx:xx) */
0025 #define SJA1105_LINKLOCAL_FILTER_B      0x011B19000000ull
0026 #define SJA1105_LINKLOCAL_FILTER_B_MASK     0xFFFFFF000000ull
0027 
0028 /* Source and Destination MAC of follow-up meta frames.
0029  * Whereas the choice of SMAC only affects the unique identification of the
0030  * switch as sender of meta frames, the DMAC must be an address that is present
0031  * in the DSA master port's multicast MAC filter.
0032  * 01-80-C2-00-00-0E is a good choice for this, as all profiles of IEEE 1588
0033  * over L2 use this address for some purpose already.
0034  */
0035 #define SJA1105_META_SMAC           0x222222222222ull
0036 #define SJA1105_META_DMAC           0x0180C200000Eull
0037 
0038 enum sja1110_meta_tstamp {
0039     SJA1110_META_TSTAMP_TX = 0,
0040     SJA1110_META_TSTAMP_RX = 1,
0041 };
0042 
0043 struct sja1105_deferred_xmit_work {
0044     struct dsa_port *dp;
0045     struct sk_buff *skb;
0046     struct kthread_work work;
0047 };
0048 
0049 /* Global tagger data */
0050 struct sja1105_tagger_data {
0051     /* Tagger to switch */
0052     void (*xmit_work_fn)(struct kthread_work *work);
0053     void (*meta_tstamp_handler)(struct dsa_switch *ds, int port, u8 ts_id,
0054                     enum sja1110_meta_tstamp dir, u64 tstamp);
0055     /* Switch to tagger */
0056     bool (*rxtstamp_get_state)(struct dsa_switch *ds);
0057     void (*rxtstamp_set_state)(struct dsa_switch *ds, bool on);
0058 };
0059 
0060 struct sja1105_skb_cb {
0061     struct sk_buff *clone;
0062     u64 tstamp;
0063     /* Only valid for packets cloned for 2-step TX timestamping */
0064     u8 ts_id;
0065 };
0066 
0067 #define SJA1105_SKB_CB(skb) \
0068     ((struct sja1105_skb_cb *)((skb)->cb))
0069 
0070 static inline struct sja1105_tagger_data *
0071 sja1105_tagger_data(struct dsa_switch *ds)
0072 {
0073     BUG_ON(ds->dst->tag_ops->proto != DSA_TAG_PROTO_SJA1105 &&
0074            ds->dst->tag_ops->proto != DSA_TAG_PROTO_SJA1110);
0075 
0076     return ds->tagger_data;
0077 }
0078 
0079 #endif /* _NET_DSA_SJA1105_H */