aboutsummaryrefslogtreecommitdiffstats
path: root/net/hsr/hsr_main.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/hsr/hsr_main.h')
-rw-r--r--net/hsr/hsr_main.h61
1 files changed, 39 insertions, 22 deletions
diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h
index 56fe060c0ab1..5a9c69962ded 100644
--- a/net/hsr/hsr_main.h
+++ b/net/hsr/hsr_main.h
@@ -1,4 +1,4 @@
1/* Copyright 2011-2013 Autronica Fire and Security AS 1/* Copyright 2011-2014 Autronica Fire and Security AS
2 * 2 *
3 * This program is free software; you can redistribute it and/or modify it 3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free 4 * under the terms of the GNU General Public License as published by the Free
@@ -6,11 +6,11 @@
6 * any later version. 6 * any later version.
7 * 7 *
8 * Author(s): 8 * Author(s):
9 * 2011-2013 Arvid Brodin, arvid.brodin@xdin.com 9 * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
10 */ 10 */
11 11
12#ifndef _HSR_PRIVATE_H 12#ifndef __HSR_PRIVATE_H
13#define _HSR_PRIVATE_H 13#define __HSR_PRIVATE_H
14 14
15#include <linux/netdevice.h> 15#include <linux/netdevice.h>
16#include <linux/list.h> 16#include <linux/list.h>
@@ -29,6 +29,7 @@
29 * each node differ before we notify of communication problem? 29 * each node differ before we notify of communication problem?
30 */ 30 */
31#define MAX_SLAVE_DIFF 3000 /* ms */ 31#define MAX_SLAVE_DIFF 3000 /* ms */
32#define HSR_SEQNR_START (USHRT_MAX - 1024)
32 33
33 34
34/* How often shall we check for broken ring and remove node entries older than 35/* How often shall we check for broken ring and remove node entries older than
@@ -46,16 +47,16 @@
46 * path, LSDU_size, sequence Nr }. But we let eth_header() create { h_dest, 47 * path, LSDU_size, sequence Nr }. But we let eth_header() create { h_dest,
47 * h_source, h_proto = 0x88FB }, and add { path, LSDU_size, sequence Nr, 48 * h_source, h_proto = 0x88FB }, and add { path, LSDU_size, sequence Nr,
48 * encapsulated protocol } instead. 49 * encapsulated protocol } instead.
50 *
51 * Field names as defined in the IEC:2010 standard for HSR.
49 */ 52 */
50#define HSR_TAGLEN 6
51
52/* Field names below as defined in the IEC:2010 standard for HSR. */
53struct hsr_tag { 53struct hsr_tag {
54 __be16 path_and_LSDU_size; 54 __be16 path_and_LSDU_size;
55 __be16 sequence_nr; 55 __be16 sequence_nr;
56 __be16 encap_proto; 56 __be16 encap_proto;
57} __packed; 57} __packed;
58 58
59#define HSR_HLEN 6
59 60
60/* The helper functions below assumes that 'path' occupies the 4 most 61/* The helper functions below assumes that 'path' occupies the 4 most
61 * significant bits of the 16-bit field shared by 'path' and 'LSDU_size' (or 62 * significant bits of the 16-bit field shared by 'path' and 'LSDU_size' (or
@@ -136,31 +137,47 @@ struct hsr_ethhdr_sp {
136} __packed; 137} __packed;
137 138
138 139
139enum hsr_dev_idx { 140enum hsr_port_type {
140 HSR_DEV_NONE = -1, 141 HSR_PT_NONE = 0, /* Must be 0, used by framereg */
141 HSR_DEV_SLAVE_A = 0, 142 HSR_PT_SLAVE_A,
142 HSR_DEV_SLAVE_B, 143 HSR_PT_SLAVE_B,
143 HSR_DEV_MASTER, 144 HSR_PT_INTERLINK,
145 HSR_PT_MASTER,
146 HSR_PT_PORTS, /* This must be the last item in the enum */
147};
148
149struct hsr_port {
150 struct list_head port_list;
151 struct net_device *dev;
152 struct hsr_priv *hsr;
153 enum hsr_port_type type;
144}; 154};
145#define HSR_MAX_SLAVE (HSR_DEV_SLAVE_B + 1)
146#define HSR_MAX_DEV (HSR_DEV_MASTER + 1)
147 155
148struct hsr_priv { 156struct hsr_priv {
149 struct list_head hsr_list; /* List of hsr devices */
150 struct rcu_head rcu_head; 157 struct rcu_head rcu_head;
151 struct net_device *dev; 158 struct list_head ports;
152 struct net_device *slave[HSR_MAX_SLAVE]; 159 struct list_head node_db; /* Known HSR nodes */
153 struct list_head node_db; /* Other HSR nodes */
154 struct list_head self_node_db; /* MACs of slaves */ 160 struct list_head self_node_db; /* MACs of slaves */
155 struct timer_list announce_timer; /* Supervision frame dispatch */ 161 struct timer_list announce_timer; /* Supervision frame dispatch */
162 struct timer_list prune_timer;
156 int announce_count; 163 int announce_count;
157 u16 sequence_nr; 164 u16 sequence_nr;
158 spinlock_t seqnr_lock; /* locking for sequence_nr */ 165 spinlock_t seqnr_lock; /* locking for sequence_nr */
159 unsigned char sup_multicast_addr[ETH_ALEN]; 166 unsigned char sup_multicast_addr[ETH_ALEN];
160}; 167};
161 168
162void register_hsr_master(struct hsr_priv *hsr_priv); 169#define hsr_for_each_port(hsr, port) \
163void unregister_hsr_master(struct hsr_priv *hsr_priv); 170 list_for_each_entry_rcu((port), &(hsr)->ports, port_list)
164bool is_hsr_slave(struct net_device *dev); 171
172struct hsr_port *hsr_port_get_hsr(struct hsr_priv *hsr, enum hsr_port_type pt);
173
174/* Caller must ensure skb is a valid HSR frame */
175static inline u16 hsr_get_skb_sequence_nr(struct sk_buff *skb)
176{
177 struct hsr_ethhdr *hsr_ethhdr;
178
179 hsr_ethhdr = (struct hsr_ethhdr *) skb_mac_header(skb);
180 return ntohs(hsr_ethhdr->hsr_tag.sequence_nr);
181}
165 182
166#endif /* _HSR_PRIVATE_H */ 183#endif /* __HSR_PRIVATE_H */