xref: /openbmc/linux/net/tipc/bcast.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1b97bf3fdSPer Liden /*
2b97bf3fdSPer Liden  * net/tipc/bcast.h: Include file for TIPC broadcast code
3b97bf3fdSPer Liden  *
43c724acdSJon Paul Maloy  * Copyright (c) 2003-2006, 2014-2015, Ericsson AB
501d83eddSAllan Stephens  * Copyright (c) 2005, 2010-2011, Wind River Systems
6b97bf3fdSPer Liden  * All rights reserved.
7b97bf3fdSPer Liden  *
8b97bf3fdSPer Liden  * Redistribution and use in source and binary forms, with or without
9b97bf3fdSPer Liden  * modification, are permitted provided that the following conditions are met:
10b97bf3fdSPer Liden  *
119ea1fd3cSPer Liden  * 1. Redistributions of source code must retain the above copyright
129ea1fd3cSPer Liden  *    notice, this list of conditions and the following disclaimer.
139ea1fd3cSPer Liden  * 2. Redistributions in binary form must reproduce the above copyright
149ea1fd3cSPer Liden  *    notice, this list of conditions and the following disclaimer in the
159ea1fd3cSPer Liden  *    documentation and/or other materials provided with the distribution.
169ea1fd3cSPer Liden  * 3. Neither the names of the copyright holders nor the names of its
179ea1fd3cSPer Liden  *    contributors may be used to endorse or promote products derived from
189ea1fd3cSPer Liden  *    this software without specific prior written permission.
199ea1fd3cSPer Liden  *
209ea1fd3cSPer Liden  * Alternatively, this software may be distributed under the terms of the
219ea1fd3cSPer Liden  * GNU General Public License ("GPL") version 2 as published by the Free
229ea1fd3cSPer Liden  * Software Foundation.
23b97bf3fdSPer Liden  *
24b97bf3fdSPer Liden  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25b97bf3fdSPer Liden  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26b97bf3fdSPer Liden  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27b97bf3fdSPer Liden  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28b97bf3fdSPer Liden  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29b97bf3fdSPer Liden  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30b97bf3fdSPer Liden  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31b97bf3fdSPer Liden  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32b97bf3fdSPer Liden  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33b97bf3fdSPer Liden  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34b97bf3fdSPer Liden  * POSSIBILITY OF SUCH DAMAGE.
35b97bf3fdSPer Liden  */
36b97bf3fdSPer Liden 
37b97bf3fdSPer Liden #ifndef _TIPC_BCAST_H
38b97bf3fdSPer Liden #define _TIPC_BCAST_H
39b97bf3fdSPer Liden 
406beb19a6SJon Paul Maloy #include "core.h"
41b97bf3fdSPer Liden 
426c00055aSDavid S. Miller struct tipc_node;
436beb19a6SJon Paul Maloy struct tipc_msg;
446beb19a6SJon Paul Maloy struct tipc_nl_msg;
452ae0b8afSJon Paul Maloy struct tipc_nlist;
462ae0b8afSJon Paul Maloy struct tipc_nitem;
475be9c086SJon Paul Maloy extern const char tipc_bclink_name[];
48a91d55d1STuong Lien extern unsigned long sysctl_tipc_bc_retruni;
496beb19a6SJon Paul Maloy 
5001fd12bbSJon Paul Maloy #define TIPC_METHOD_EXPIRE msecs_to_jiffies(5000)
5101fd12bbSJon Paul Maloy 
5202ec6cafSHoang Le #define BCLINK_MODE_BCAST  0x1
5302ec6cafSHoang Le #define BCLINK_MODE_RCAST  0x2
5402ec6cafSHoang Le #define BCLINK_MODE_SEL    0x4
5502ec6cafSHoang Le 
562ae0b8afSJon Paul Maloy struct tipc_nlist {
572ae0b8afSJon Paul Maloy 	struct list_head list;
582ae0b8afSJon Paul Maloy 	u32 self;
592ae0b8afSJon Paul Maloy 	u16 remote;
602ae0b8afSJon Paul Maloy 	bool local;
612ae0b8afSJon Paul Maloy };
622ae0b8afSJon Paul Maloy 
632ae0b8afSJon Paul Maloy void tipc_nlist_init(struct tipc_nlist *nl, u32 self);
642ae0b8afSJon Paul Maloy void tipc_nlist_purge(struct tipc_nlist *nl);
652ae0b8afSJon Paul Maloy void tipc_nlist_add(struct tipc_nlist *nl, u32 node);
662ae0b8afSJon Paul Maloy void tipc_nlist_del(struct tipc_nlist *nl, u32 node);
672ae0b8afSJon Paul Maloy 
6801fd12bbSJon Paul Maloy /* Cookie to be used between socket and broadcast layer
6901fd12bbSJon Paul Maloy  * @rcast: replicast (instead of broadcast) was used at previous xmit
7001fd12bbSJon Paul Maloy  * @mandatory: broadcast/replicast indication was set by user
71c55c8edaSHoang Le  * @deferredq: defer queue to make message in order
7201fd12bbSJon Paul Maloy  * @expires: re-evaluate non-mandatory transmit method if we are past this
7301fd12bbSJon Paul Maloy  */
7401fd12bbSJon Paul Maloy struct tipc_mc_method {
7501fd12bbSJon Paul Maloy 	bool rcast;
7601fd12bbSJon Paul Maloy 	bool mandatory;
77c55c8edaSHoang Le 	struct sk_buff_head deferredq;
7801fd12bbSJon Paul Maloy 	unsigned long expires;
7901fd12bbSJon Paul Maloy };
8001fd12bbSJon Paul Maloy 
816beb19a6SJon Paul Maloy int tipc_bcast_init(struct net *net);
826beb19a6SJon Paul Maloy void tipc_bcast_stop(struct net *net);
83b06b281eSJon Paul Maloy void tipc_bcast_add_peer(struct net *net, struct tipc_link *l,
8452666986SJon Paul Maloy 			 struct sk_buff_head *xmitq);
85b06b281eSJon Paul Maloy void tipc_bcast_remove_peer(struct net *net, struct tipc_link *rcv_bcl);
86b06b281eSJon Paul Maloy void tipc_bcast_inc_bearer_dst_cnt(struct net *net, int bearer_id);
87b06b281eSJon Paul Maloy void tipc_bcast_dec_bearer_dst_cnt(struct net *net, int bearer_id);
88959e1781SJon Paul Maloy int  tipc_bcast_get_mtu(struct net *net);
89ba5f6a86SHoang Le void tipc_bcast_toggle_rcast(struct net *net, bool supp);
90a853e4c6SJon Paul Maloy int tipc_mcast_xmit(struct net *net, struct sk_buff_head *pkts,
9101fd12bbSJon Paul Maloy 		    struct tipc_mc_method *method, struct tipc_nlist *dests,
9201fd12bbSJon Paul Maloy 		    u16 *cong_link_cnt);
93*cad2929dSHoang Huu Le int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,
94*cad2929dSHoang Huu Le 		    u16 *cong_link_cnt);
9552666986SJon Paul Maloy int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb);
9606bd2b1eSJon Paul Maloy void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
9706bd2b1eSJon Paul Maloy 			struct tipc_msg *hdr);
9802d11ca2SJon Paul Maloy int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
99a91d55d1STuong Lien 			struct tipc_msg *hdr,
100a91d55d1STuong Lien 			struct sk_buff_head *retrq);
10103b6fefdSTuong Lien int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg,
10203b6fefdSTuong Lien 			struct tipc_link *bcl);
103670f4f88SRichard Alpe int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
10403b6fefdSTuong Lien int tipc_bclink_reset_stats(struct net *net, struct tipc_link *l);
1057be57fc6SRichard Alpe 
106*cad2929dSHoang Huu Le u32 tipc_bcast_get_mode(struct net *net);
10702ec6cafSHoang Le u32 tipc_bcast_get_broadcast_ratio(struct net *net);
10802ec6cafSHoang Le 
10908e046c8SHoang Le void tipc_mcast_filter_msg(struct net *net, struct sk_buff_head *defq,
110c55c8edaSHoang Le 			   struct sk_buff_head *inputq);
111c55c8edaSHoang Le 
tipc_bcast_lock(struct net * net)1120043550bSJon Paul Maloy static inline void tipc_bcast_lock(struct net *net)
1130043550bSJon Paul Maloy {
1140043550bSJon Paul Maloy 	spin_lock_bh(&tipc_net(net)->bclock);
1150043550bSJon Paul Maloy }
1160043550bSJon Paul Maloy 
tipc_bcast_unlock(struct net * net)1170043550bSJon Paul Maloy static inline void tipc_bcast_unlock(struct net *net)
1180043550bSJon Paul Maloy {
1190043550bSJon Paul Maloy 	spin_unlock_bh(&tipc_net(net)->bclock);
1200043550bSJon Paul Maloy }
1210043550bSJon Paul Maloy 
tipc_bc_sndlink(struct net * net)12252666986SJon Paul Maloy static inline struct tipc_link *tipc_bc_sndlink(struct net *net)
12352666986SJon Paul Maloy {
12452666986SJon Paul Maloy 	return tipc_net(net)->bcl;
12552666986SJon Paul Maloy }
12652666986SJon Paul Maloy 
127b97bf3fdSPer Liden #endif
128