Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
7struct net_device;
8
9/* used to differentiate various protocols */
10enum hsr_version {
11 HSR_V0 = 0,
12 HSR_V1,
13 PRP_V1,
14};
15
16enum 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 */
33struct 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)
42extern bool is_hsr_master(struct net_device *dev);
43extern int hsr_get_version(struct net_device *dev, enum hsr_version *ver);
44struct net_device *hsr_get_port_ndev(struct net_device *ndev,
45 enum hsr_port_type pt);
46int hsr_get_port_type(struct net_device *hsr_dev, struct net_device *dev,
47 enum hsr_port_type *type);
48#else
49static inline bool is_hsr_master(struct net_device *dev)
50{
51 return false;
52}
53static inline int hsr_get_version(struct net_device *dev,
54 enum hsr_version *ver)
55{
56 return -EINVAL;
57}
58
59static inline struct net_device *hsr_get_port_ndev(struct net_device *ndev,
60 enum hsr_port_type pt)
61{
62 return ERR_PTR(-EINVAL);
63}
64
65static inline int hsr_get_port_type(struct net_device *hsr_dev,
66 struct net_device *dev,
67 enum hsr_port_type *type)
68{
69 return -EINVAL;
70}
71#endif /* CONFIG_HSR */
72
73#endif /*_LINUX_IF_HSR_H_*/