Murali Karicheri | 0e7623b | 2019-04-05 13:31:34 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Arvid Brodin | 70ebe4a | 2014-07-04 23:34:38 +0200 | [diff] [blame] | 2 | /* Copyright 2011-2014 Autronica Fire and Security AS |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 3 | * |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 4 | * Author(s): |
Arvid Brodin | 70ebe4a | 2014-07-04 23:34:38 +0200 | [diff] [blame] | 5 | * 2011-2014 Arvid Brodin, arvid.brodin@alten.se |
Murali Karicheri | 8f4c0e0 | 2020-07-22 10:40:16 -0400 | [diff] [blame] | 6 | * |
| 7 | * include file for HSR and PRP. |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
Arvid Brodin | 70ebe4a | 2014-07-04 23:34:38 +0200 | [diff] [blame] | 10 | #ifndef __HSR_FRAMEREG_H |
| 11 | #define __HSR_FRAMEREG_H |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 12 | |
| 13 | #include "hsr_main.h" |
| 14 | |
Arvid Brodin | 70ebe4a | 2014-07-04 23:34:38 +0200 | [diff] [blame] | 15 | struct hsr_node; |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 16 | |
Murali Karicheri | 451d812 | 2020-07-22 10:40:21 -0400 | [diff] [blame] | 17 | struct 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 | |
Taehee Yoo | 92a3567 | 2019-12-22 11:26:54 +0000 | [diff] [blame] | 31 | void hsr_del_self_node(struct hsr_priv *hsr); |
Cong Wang | b9a1e62 | 2019-07-03 17:21:13 -0700 | [diff] [blame] | 32 | void hsr_del_nodes(struct list_head *node_db); |
Murali Karicheri | 451d812 | 2020-07-22 10:40:21 -0400 | [diff] [blame] | 33 | struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db, |
| 34 | struct sk_buff *skb, bool is_sup, |
| 35 | enum hsr_port_type rx_port); |
| 36 | void hsr_handle_sup_frame(struct hsr_frame_info *frame); |
Arvid Brodin | f266a68 | 2014-07-04 23:41:03 +0200 | [diff] [blame] | 37 | bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr); |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 38 | |
Arvid Brodin | f266a68 | 2014-07-04 23:41:03 +0200 | [diff] [blame] | 39 | void hsr_addr_subst_source(struct hsr_node *node, struct sk_buff *skb); |
| 40 | void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb, |
Arvid Brodin | c5a7591 | 2014-07-04 23:38:05 +0200 | [diff] [blame] | 41 | struct hsr_port *port); |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 42 | |
Arvid Brodin | f266a68 | 2014-07-04 23:41:03 +0200 | [diff] [blame] | 43 | void hsr_register_frame_in(struct hsr_node *node, struct hsr_port *port, |
| 44 | u16 sequence_nr); |
| 45 | int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node, |
| 46 | u16 sequence_nr); |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 47 | |
Kees Cook | dda436b | 2017-10-24 01:46:16 -0700 | [diff] [blame] | 48 | void hsr_prune_nodes(struct timer_list *t); |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 49 | |
Taehee Yoo | 92a3567 | 2019-12-22 11:26:54 +0000 | [diff] [blame] | 50 | int hsr_create_self_node(struct hsr_priv *hsr, |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 51 | unsigned char addr_a[ETH_ALEN], |
| 52 | unsigned char addr_b[ETH_ALEN]); |
| 53 | |
Arvid Brodin | 70ebe4a | 2014-07-04 23:34:38 +0200 | [diff] [blame] | 54 | void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos, |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 55 | unsigned char addr[ETH_ALEN]); |
| 56 | |
Arvid Brodin | 70ebe4a | 2014-07-04 23:34:38 +0200 | [diff] [blame] | 57 | int hsr_get_node_data(struct hsr_priv *hsr, |
Arvid Brodin | f421436 | 2013-10-30 21:10:47 +0100 | [diff] [blame] | 58 | const unsigned char *addr, |
| 59 | unsigned char addr_b[ETH_ALEN], |
| 60 | unsigned int *addr_b_ifindex, |
| 61 | int *if1_age, |
| 62 | u16 *if1_seq, |
| 63 | int *if2_age, |
| 64 | u16 *if2_seq); |
| 65 | |
Murali Karicheri | 451d812 | 2020-07-22 10:40:21 -0400 | [diff] [blame] | 66 | void prp_handle_san_frame(bool san, enum hsr_port_type port, |
| 67 | struct hsr_node *node); |
| 68 | void prp_update_san_info(struct hsr_node *node, bool is_sup); |
| 69 | |
Murali Karicheri | fc4ecae | 2019-04-05 13:31:35 -0400 | [diff] [blame] | 70 | struct hsr_node { |
| 71 | struct list_head mac_list; |
| 72 | unsigned char macaddress_A[ETH_ALEN]; |
| 73 | unsigned char macaddress_B[ETH_ALEN]; |
| 74 | /* Local slave through which AddrB frames are received from this node */ |
| 75 | enum hsr_port_type addr_B_port; |
| 76 | unsigned long time_in[HSR_PT_PORTS]; |
| 77 | bool time_in_stale[HSR_PT_PORTS]; |
Marco Wenzel | daea772 | 2021-02-24 10:46:49 +0100 | [diff] [blame] | 78 | unsigned long time_out[HSR_PT_PORTS]; |
Murali Karicheri | 451d812 | 2020-07-22 10:40:21 -0400 | [diff] [blame] | 79 | /* if the node is a SAN */ |
| 80 | bool san_a; |
| 81 | bool san_b; |
Murali Karicheri | fc4ecae | 2019-04-05 13:31:35 -0400 | [diff] [blame] | 82 | u16 seq_out[HSR_PT_PORTS]; |
| 83 | struct rcu_head rcu_head; |
| 84 | }; |
| 85 | |
Arvid Brodin | 70ebe4a | 2014-07-04 23:34:38 +0200 | [diff] [blame] | 86 | #endif /* __HSR_FRAMEREG_H */ |