1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_IF_HSR_H_
3 #define _LINUX_IF_HSR_H_
4
5 #include <linux/types.h>
6
7 struct net_device;
8
9 /* used to differentiate various protocols */
10 enum hsr_version {
11 HSR_V0 = 0,
12 HSR_V1,
13 PRP_V1,
14 };
15
16 enum hsr_port_type {
17 HSR_PT_NONE = 0, /* Must be 0, used by framereg */
18 HSR_PT_SLAVE_A,
19 HSR_PT_SLAVE_B,
20 HSR_PT_INTERLINK,
21 HSR_PT_MASTER,
22 HSR_PT_PORTS, /* This must be the last item in the enum */
23 };
24
25 /* HSR Tag.
26 * As defined in IEC-62439-3:2010, the HSR tag is really { ethertype = 0x88FB,
27 * path, LSDU_size, sequence Nr }. But we let eth_header() create { h_dest,
28 * h_source, h_proto = 0x88FB }, and add { path, LSDU_size, sequence Nr,
29 * encapsulated protocol } instead.
30 *
31 * Field names as defined in the IEC:2010 standard for HSR.
32 */
33 struct hsr_tag {
34 __be16 path_and_LSDU_size;
35 __be16 sequence_nr;
36 __be16 encap_proto;
37 } __packed;
38
39 #define HSR_HLEN 6
40
41 #if IS_ENABLED(CONFIG_HSR)
42 extern bool is_hsr_master(struct net_device *dev);
43 extern int hsr_get_version(struct net_device *dev, enum hsr_version *ver);
44 struct net_device *hsr_get_port_ndev(struct net_device *ndev,
45 enum hsr_port_type pt);
46 #else
is_hsr_master(struct net_device * dev)47 static inline bool is_hsr_master(struct net_device *dev)
48 {
49 return false;
50 }
hsr_get_version(struct net_device * dev,enum hsr_version * ver)51 static inline int hsr_get_version(struct net_device *dev,
52 enum hsr_version *ver)
53 {
54 return -EINVAL;
55 }
56
hsr_get_port_ndev(struct net_device * ndev,enum hsr_port_type pt)57 static inline struct net_device *hsr_get_port_ndev(struct net_device *ndev,
58 enum hsr_port_type pt)
59 {
60 return ERR_PTR(-EINVAL);
61 }
62 #endif /* CONFIG_HSR */
63
64 #endif /*_LINUX_IF_HSR_H_*/
65