Linux 6.10-rc3
[linux-block.git] / net / hsr / hsr_framereg.h
CommitLineData
0e7623bd 1/* SPDX-License-Identifier: GPL-2.0 */
70ebe4a4 2/* Copyright 2011-2014 Autronica Fire and Security AS
f421436a
AB
3 *
4 * Author(s):
70ebe4a4 5 * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
8f4c0e01
MK
6 *
7 * include file for HSR and PRP.
f421436a
AB
8 */
9
70ebe4a4
AB
10#ifndef __HSR_FRAMEREG_H
11#define __HSR_FRAMEREG_H
f421436a
AB
12
13#include "hsr_main.h"
14
70ebe4a4 15struct hsr_node;
f421436a 16
451d8123
MK
17struct hsr_frame_info {
18 struct sk_buff *skb_std;
19 struct sk_buff *skb_hsr;
20 struct sk_buff *skb_prp;
21 struct hsr_port *port_rcv;
22 struct hsr_node *node_src;
23 u16 sequence_nr;
24 bool is_supervision;
25 bool is_vlan;
26 bool is_local_dest;
27 bool is_local_exclusive;
28 bool is_from_san;
29};
30
92a35678 31void hsr_del_self_node(struct hsr_priv *hsr);
e012764c
SAS
32void hsr_del_nodes(struct list_head *node_db);
33struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
451d8123
MK
34 struct sk_buff *skb, bool is_sup,
35 enum hsr_port_type rx_port);
36void hsr_handle_sup_frame(struct hsr_frame_info *frame);
f266a683
AB
37bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);
38
39void hsr_addr_subst_source(struct hsr_node *node, struct sk_buff *skb);
40void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,
c5a75911 41 struct hsr_port *port);
f421436a 42
f266a683
AB
43void hsr_register_frame_in(struct hsr_node *node, struct hsr_port *port,
44 u16 sequence_nr);
45int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
46 u16 sequence_nr);
f421436a 47
dda436b7 48void hsr_prune_nodes(struct timer_list *t);
5055cccf 49void hsr_prune_proxy_nodes(struct timer_list *t);
f421436a 50
92a35678 51int hsr_create_self_node(struct hsr_priv *hsr,
39c19fb9
JK
52 const unsigned char addr_a[ETH_ALEN],
53 const unsigned char addr_b[ETH_ALEN]);
f421436a 54
70ebe4a4 55void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
f421436a
AB
56 unsigned char addr[ETH_ALEN]);
57
70ebe4a4 58int hsr_get_node_data(struct hsr_priv *hsr,
f421436a
AB
59 const unsigned char *addr,
60 unsigned char addr_b[ETH_ALEN],
61 unsigned int *addr_b_ifindex,
62 int *if1_age,
63 u16 *if1_seq,
64 int *if2_age,
65 u16 *if2_seq);
66
451d8123
MK
67void prp_handle_san_frame(bool san, enum hsr_port_type port,
68 struct hsr_node *node);
69void prp_update_san_info(struct hsr_node *node, bool is_sup);
70
5055cccf
LM
71bool hsr_is_node_in_db(struct list_head *node_db,
72 const unsigned char addr[ETH_ALEN]);
73
fc4ecaee 74struct hsr_node {
e012764c 75 struct list_head mac_list;
5c7aa132
SAS
76 /* Protect R/W access to seq_out */
77 spinlock_t seq_out_lock;
fc4ecaee
MK
78 unsigned char macaddress_A[ETH_ALEN];
79 unsigned char macaddress_B[ETH_ALEN];
80 /* Local slave through which AddrB frames are received from this node */
81 enum hsr_port_type addr_B_port;
82 unsigned long time_in[HSR_PT_PORTS];
83 bool time_in_stale[HSR_PT_PORTS];
f1764114 84 unsigned long time_out[HSR_PT_PORTS];
451d8123
MK
85 /* if the node is a SAN */
86 bool san_a;
87 bool san_b;
fc4ecaee 88 u16 seq_out[HSR_PT_PORTS];
0c74d9f7 89 bool removed;
fc4ecaee
MK
90 struct rcu_head rcu_head;
91};
92
70ebe4a4 93#endif /* __HSR_FRAMEREG_H */