1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * net/tipc/bcast.h: Include file for TIPC broadcast code
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Copyright (c) 2003-2006, 2014-2015, Ericsson AB
5*4882a593Smuzhiyun * Copyright (c) 2005, 2010-2011, Wind River Systems
6*4882a593Smuzhiyun * All rights reserved.
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * Redistribution and use in source and binary forms, with or without
9*4882a593Smuzhiyun * modification, are permitted provided that the following conditions are met:
10*4882a593Smuzhiyun *
11*4882a593Smuzhiyun * 1. Redistributions of source code must retain the above copyright
12*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer.
13*4882a593Smuzhiyun * 2. Redistributions in binary form must reproduce the above copyright
14*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer in the
15*4882a593Smuzhiyun * documentation and/or other materials provided with the distribution.
16*4882a593Smuzhiyun * 3. Neither the names of the copyright holders nor the names of its
17*4882a593Smuzhiyun * contributors may be used to endorse or promote products derived from
18*4882a593Smuzhiyun * this software without specific prior written permission.
19*4882a593Smuzhiyun *
20*4882a593Smuzhiyun * Alternatively, this software may be distributed under the terms of the
21*4882a593Smuzhiyun * GNU General Public License ("GPL") version 2 as published by the Free
22*4882a593Smuzhiyun * Software Foundation.
23*4882a593Smuzhiyun *
24*4882a593Smuzhiyun * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25*4882a593Smuzhiyun * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26*4882a593Smuzhiyun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27*4882a593Smuzhiyun * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28*4882a593Smuzhiyun * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29*4882a593Smuzhiyun * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30*4882a593Smuzhiyun * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31*4882a593Smuzhiyun * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32*4882a593Smuzhiyun * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33*4882a593Smuzhiyun * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34*4882a593Smuzhiyun * POSSIBILITY OF SUCH DAMAGE.
35*4882a593Smuzhiyun */
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun #ifndef _TIPC_BCAST_H
38*4882a593Smuzhiyun #define _TIPC_BCAST_H
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #include "core.h"
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun struct tipc_node;
43*4882a593Smuzhiyun struct tipc_msg;
44*4882a593Smuzhiyun struct tipc_nl_msg;
45*4882a593Smuzhiyun struct tipc_nlist;
46*4882a593Smuzhiyun struct tipc_nitem;
47*4882a593Smuzhiyun extern const char tipc_bclink_name[];
48*4882a593Smuzhiyun extern unsigned long sysctl_tipc_bc_retruni;
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun #define TIPC_METHOD_EXPIRE msecs_to_jiffies(5000)
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun #define BCLINK_MODE_BCAST 0x1
53*4882a593Smuzhiyun #define BCLINK_MODE_RCAST 0x2
54*4882a593Smuzhiyun #define BCLINK_MODE_SEL 0x4
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun struct tipc_nlist {
57*4882a593Smuzhiyun struct list_head list;
58*4882a593Smuzhiyun u32 self;
59*4882a593Smuzhiyun u16 remote;
60*4882a593Smuzhiyun bool local;
61*4882a593Smuzhiyun };
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun void tipc_nlist_init(struct tipc_nlist *nl, u32 self);
64*4882a593Smuzhiyun void tipc_nlist_purge(struct tipc_nlist *nl);
65*4882a593Smuzhiyun void tipc_nlist_add(struct tipc_nlist *nl, u32 node);
66*4882a593Smuzhiyun void tipc_nlist_del(struct tipc_nlist *nl, u32 node);
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun /* Cookie to be used between socket and broadcast layer
69*4882a593Smuzhiyun * @rcast: replicast (instead of broadcast) was used at previous xmit
70*4882a593Smuzhiyun * @mandatory: broadcast/replicast indication was set by user
71*4882a593Smuzhiyun * @deferredq: defer queue to make message in order
72*4882a593Smuzhiyun * @expires: re-evaluate non-mandatory transmit method if we are past this
73*4882a593Smuzhiyun */
74*4882a593Smuzhiyun struct tipc_mc_method {
75*4882a593Smuzhiyun bool rcast;
76*4882a593Smuzhiyun bool mandatory;
77*4882a593Smuzhiyun struct sk_buff_head deferredq;
78*4882a593Smuzhiyun unsigned long expires;
79*4882a593Smuzhiyun };
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun int tipc_bcast_init(struct net *net);
82*4882a593Smuzhiyun void tipc_bcast_stop(struct net *net);
83*4882a593Smuzhiyun void tipc_bcast_add_peer(struct net *net, struct tipc_link *l,
84*4882a593Smuzhiyun struct sk_buff_head *xmitq);
85*4882a593Smuzhiyun void tipc_bcast_remove_peer(struct net *net, struct tipc_link *rcv_bcl);
86*4882a593Smuzhiyun void tipc_bcast_inc_bearer_dst_cnt(struct net *net, int bearer_id);
87*4882a593Smuzhiyun void tipc_bcast_dec_bearer_dst_cnt(struct net *net, int bearer_id);
88*4882a593Smuzhiyun int tipc_bcast_get_mtu(struct net *net);
89*4882a593Smuzhiyun void tipc_bcast_toggle_rcast(struct net *net, bool supp);
90*4882a593Smuzhiyun int tipc_mcast_xmit(struct net *net, struct sk_buff_head *pkts,
91*4882a593Smuzhiyun struct tipc_mc_method *method, struct tipc_nlist *dests,
92*4882a593Smuzhiyun u16 *cong_link_cnt);
93*4882a593Smuzhiyun int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,
94*4882a593Smuzhiyun u16 *cong_link_cnt);
95*4882a593Smuzhiyun int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb);
96*4882a593Smuzhiyun void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
97*4882a593Smuzhiyun struct tipc_msg *hdr);
98*4882a593Smuzhiyun int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
99*4882a593Smuzhiyun struct tipc_msg *hdr,
100*4882a593Smuzhiyun struct sk_buff_head *retrq);
101*4882a593Smuzhiyun int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg,
102*4882a593Smuzhiyun struct tipc_link *bcl);
103*4882a593Smuzhiyun int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
104*4882a593Smuzhiyun int tipc_bclink_reset_stats(struct net *net, struct tipc_link *l);
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun u32 tipc_bcast_get_mode(struct net *net);
107*4882a593Smuzhiyun u32 tipc_bcast_get_broadcast_ratio(struct net *net);
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun void tipc_mcast_filter_msg(struct net *net, struct sk_buff_head *defq,
110*4882a593Smuzhiyun struct sk_buff_head *inputq);
111*4882a593Smuzhiyun
tipc_bcast_lock(struct net * net)112*4882a593Smuzhiyun static inline void tipc_bcast_lock(struct net *net)
113*4882a593Smuzhiyun {
114*4882a593Smuzhiyun spin_lock_bh(&tipc_net(net)->bclock);
115*4882a593Smuzhiyun }
116*4882a593Smuzhiyun
tipc_bcast_unlock(struct net * net)117*4882a593Smuzhiyun static inline void tipc_bcast_unlock(struct net *net)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun spin_unlock_bh(&tipc_net(net)->bclock);
120*4882a593Smuzhiyun }
121*4882a593Smuzhiyun
tipc_bc_sndlink(struct net * net)122*4882a593Smuzhiyun static inline struct tipc_link *tipc_bc_sndlink(struct net *net)
123*4882a593Smuzhiyun {
124*4882a593Smuzhiyun return tipc_net(net)->bcl;
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun #endif
128