^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright 2011-2014 Autronica Fire and Security AS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author(s):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * include file for HSR and PRP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef __HSR_FRAMEREG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define __HSR_FRAMEREG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "hsr_main.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct hsr_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct hsr_frame_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct sk_buff *skb_std;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct sk_buff *skb_hsr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct sk_buff *skb_prp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct hsr_port *port_rcv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct hsr_node *node_src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) u16 sequence_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) bool is_supervision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) bool is_vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) bool is_local_dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) bool is_local_exclusive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) bool is_from_san;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void hsr_del_self_node(struct hsr_priv *hsr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) void hsr_del_nodes(struct list_head *node_db);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct sk_buff *skb, bool is_sup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) enum hsr_port_type rx_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) void hsr_handle_sup_frame(struct hsr_frame_info *frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void hsr_addr_subst_source(struct hsr_node *node, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct hsr_port *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void hsr_register_frame_in(struct hsr_node *node, struct hsr_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) u16 sequence_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u16 sequence_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) void hsr_prune_nodes(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int hsr_create_self_node(struct hsr_priv *hsr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned char addr_a[ETH_ALEN],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned char addr_b[ETH_ALEN]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned char addr[ETH_ALEN]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int hsr_get_node_data(struct hsr_priv *hsr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) const unsigned char *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) unsigned char addr_b[ETH_ALEN],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) unsigned int *addr_b_ifindex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int *if1_age,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) u16 *if1_seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int *if2_age,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u16 *if2_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void prp_handle_san_frame(bool san, enum hsr_port_type port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct hsr_node *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) void prp_update_san_info(struct hsr_node *node, bool is_sup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct hsr_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct list_head mac_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) unsigned char macaddress_A[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned char macaddress_B[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* Local slave through which AddrB frames are received from this node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) enum hsr_port_type addr_B_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned long time_in[HSR_PT_PORTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) bool time_in_stale[HSR_PT_PORTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned long time_out[HSR_PT_PORTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* if the node is a SAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) bool san_a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) bool san_b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u16 seq_out[HSR_PT_PORTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct rcu_head rcu_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #endif /* __HSR_FRAMEREG_H */