2 * net/tipc/bcast.h: Include file for TIPC broadcast code
4 * Copyright (c) 2003-2005, Ericsson Research Canada
5 * Copyright (c) 2005, Wind River Systems
6 * Copyright (c) 2005-2006, Ericsson AB
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
21 * Alternatively, this software may be distributed under the terms of the
22 * GNU General Public License ("GPL") version 2 as published by the Free
23 * Software Foundation.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
41 #define MAX_NODES 4096
45 * struct node_map - set of node identifiers
46 * @count: # of nodes in set
47 * @map: bitmap of node identifiers that are in the set
52 u32 map[MAX_NODES / WSIZE];
59 * struct port_list - set of node local destination ports
60 * @count: # of ports in set (only valid for first entry in list)
61 * @next: pointer to next entry in list
62 * @ports: array of port references
67 struct port_list *next;
74 extern char bc_link_name[];
78 * nmap_get - determine if node exists in a node map
81 static inline int nmap_get(struct node_map *nm_ptr, u32 node)
83 int n = tipc_node(node);
87 return nm_ptr->map[w] & (1 << b);
91 * nmap_add - add a node to a node map
94 static inline void nmap_add(struct node_map *nm_ptr, u32 node)
96 int n = tipc_node(node);
98 u32 mask = (1 << (n % WSIZE));
100 if ((nm_ptr->map[w] & mask) == 0) {
102 nm_ptr->map[w] |= mask;
107 * nmap_remove - remove a node from a node map
110 static inline void nmap_remove(struct node_map *nm_ptr, u32 node)
112 int n = tipc_node(node);
114 u32 mask = (1 << (n % WSIZE));
116 if ((nm_ptr->map[w] & mask) != 0) {
117 nm_ptr->map[w] &= ~mask;
123 * nmap_equal - test for equality of node maps
126 static inline int nmap_equal(struct node_map *nm_a, struct node_map *nm_b)
128 return !memcmp(nm_a, nm_b, sizeof(*nm_a));
132 * nmap_diff - find differences between node maps
133 * @nm_a: input node map A
134 * @nm_b: input node map B
135 * @nm_diff: output node map A-B (i.e. nodes of A that are not in B)
138 static inline void nmap_diff(struct node_map *nm_a, struct node_map *nm_b,
139 struct node_map *nm_diff)
141 int stop = sizeof(nm_a->map) / sizeof(u32);
146 memset(nm_diff, 0, sizeof(*nm_diff));
147 for (w = 0; w < stop; w++) {
148 map = nm_a->map[w] ^ (nm_a->map[w] & nm_b->map[w]);
149 nm_diff->map[w] = map;
151 for (b = 0 ; b < WSIZE; b++) {
160 * port_list_add - add a port to a port list, ensuring no duplicates
163 static inline void port_list_add(struct port_list *pl_ptr, u32 port)
165 struct port_list *item = pl_ptr;
167 int item_sz = PLSIZE;
168 int cnt = pl_ptr->count;
170 for (; ; cnt -= item_sz, item = item->next) {
173 for (i = 0; i < item_sz; i++)
174 if (item->ports[i] == port)
177 item->ports[i] = port;
182 item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
184 warn("Memory squeeze: multicast destination port list is incomplete\n");
187 item->next->next = NULL;
193 * port_list_free - free dynamically created entries in port_list chain
195 * Note: First item is on stack, so it doesn't need to be released
198 static inline void port_list_free(struct port_list *pl_ptr)
200 struct port_list *item;
201 struct port_list *next;
203 for (item = pl_ptr->next; item; item = next) {
210 int bclink_init(void);
211 void bclink_stop(void);
212 void bclink_acknowledge(struct node *n_ptr, u32 acked);
213 int bclink_send_msg(struct sk_buff *buf);
214 void bclink_recv_pkt(struct sk_buff *buf);
215 u32 bclink_get_last_sent(void);
216 u32 bclink_acks_missing(struct node *n_ptr);
217 void bclink_check_gap(struct node *n_ptr, u32 seqno);
218 int bclink_stats(char *stats_buf, const u32 buf_size);
219 int bclink_reset_stats(void);
220 int bclink_set_queue_limits(u32 limit);
221 void bcbearer_sort(void);
222 void bcbearer_push(void);