blob: d9628e7a5f051ab8e0d6718b7d8ee3ff8e4877a2 [file] [log] [blame]
Murali Karicheri0e7623b2019-04-05 13:31:34 -04001/* SPDX-License-Identifier: GPL-2.0 */
Arvid Brodin70ebe4a2014-07-04 23:34:38 +02002/* Copyright 2011-2014 Autronica Fire and Security AS
Arvid Brodinf4214362013-10-30 21:10:47 +01003 *
Arvid Brodinf4214362013-10-30 21:10:47 +01004 * Author(s):
Arvid Brodin70ebe4a2014-07-04 23:34:38 +02005 * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
Murali Karicheri8f4c0e02020-07-22 10:40:16 -04006 *
7 * include file for HSR and PRP.
Arvid Brodinf4214362013-10-30 21:10:47 +01008 */
9
Arvid Brodin70ebe4a2014-07-04 23:34:38 +020010#ifndef __HSR_FRAMEREG_H
11#define __HSR_FRAMEREG_H
Arvid Brodinf4214362013-10-30 21:10:47 +010012
13#include "hsr_main.h"
14
Arvid Brodin70ebe4a2014-07-04 23:34:38 +020015struct hsr_node;
Arvid Brodinf4214362013-10-30 21:10:47 +010016
Murali Karicheri451d8122020-07-22 10:40:21 -040017struct 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 Yoo92a35672019-12-22 11:26:54 +000031void hsr_del_self_node(struct hsr_priv *hsr);
Cong Wangb9a1e622019-07-03 17:21:13 -070032void hsr_del_nodes(struct list_head *node_db);
Murali Karicheri451d8122020-07-22 10:40:21 -040033struct 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);
36void hsr_handle_sup_frame(struct hsr_frame_info *frame);
Arvid Brodinf266a682014-07-04 23:41:03 +020037bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);
Arvid Brodinf4214362013-10-30 21:10:47 +010038
Arvid Brodinf266a682014-07-04 23:41:03 +020039void 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,
Arvid Brodinc5a75912014-07-04 23:38:05 +020041 struct hsr_port *port);
Arvid Brodinf4214362013-10-30 21:10:47 +010042
Arvid Brodinf266a682014-07-04 23:41:03 +020043void 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);
Arvid Brodinf4214362013-10-30 21:10:47 +010047
Kees Cookdda436b2017-10-24 01:46:16 -070048void hsr_prune_nodes(struct timer_list *t);
Arvid Brodinf4214362013-10-30 21:10:47 +010049
Taehee Yoo92a35672019-12-22 11:26:54 +000050int hsr_create_self_node(struct hsr_priv *hsr,
Arvid Brodinf4214362013-10-30 21:10:47 +010051 unsigned char addr_a[ETH_ALEN],
52 unsigned char addr_b[ETH_ALEN]);
53
Arvid Brodin70ebe4a2014-07-04 23:34:38 +020054void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
Arvid Brodinf4214362013-10-30 21:10:47 +010055 unsigned char addr[ETH_ALEN]);
56
Arvid Brodin70ebe4a2014-07-04 23:34:38 +020057int hsr_get_node_data(struct hsr_priv *hsr,
Arvid Brodinf4214362013-10-30 21:10:47 +010058 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 Karicheri451d8122020-07-22 10:40:21 -040066void prp_handle_san_frame(bool san, enum hsr_port_type port,
67 struct hsr_node *node);
68void prp_update_san_info(struct hsr_node *node, bool is_sup);
69
Murali Karicherifc4ecae2019-04-05 13:31:35 -040070struct 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 Wenzeldaea7722021-02-24 10:46:49 +010078 unsigned long time_out[HSR_PT_PORTS];
Murali Karicheri451d8122020-07-22 10:40:21 -040079 /* if the node is a SAN */
80 bool san_a;
81 bool san_b;
Murali Karicherifc4ecae2019-04-05 13:31:35 -040082 u16 seq_out[HSR_PT_PORTS];
83 struct rcu_head rcu_head;
84};
85
Arvid Brodin70ebe4a2014-07-04 23:34:38 +020086#endif /* __HSR_FRAMEREG_H */