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 * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
37 #define MAX_NODES 4096
41 * struct node_map - set of node identifiers
42 * @count: # of nodes in set
43 * @map: bitmap of node identifiers that are in the set
48 u32 map
[MAX_NODES
/ WSIZE
];
55 * struct port_list - set of node local destination ports
56 * @count: # of ports in set (only valid for first entry in list)
57 * @next: pointer to next entry in list
58 * @ports: array of port references
63 struct port_list
*next
;
70 extern char bc_link_name
[];
74 * nmap_get - determine if node exists in a node map
77 static inline int nmap_get(struct node_map
*nm_ptr
, u32 node
)
79 int n
= tipc_node(node
);
83 return nm_ptr
->map
[w
] & (1 << b
);
87 * nmap_add - add a node to a node map
90 static inline void nmap_add(struct node_map
*nm_ptr
, u32 node
)
92 int n
= tipc_node(node
);
94 u32 mask
= (1 << (n
% WSIZE
));
96 if ((nm_ptr
->map
[w
] & mask
) == 0) {
98 nm_ptr
->map
[w
] |= mask
;
103 * nmap_remove - remove a node from a node map
106 static inline void nmap_remove(struct node_map
*nm_ptr
, u32 node
)
108 int n
= tipc_node(node
);
110 u32 mask
= (1 << (n
% WSIZE
));
112 if ((nm_ptr
->map
[w
] & mask
) != 0) {
113 nm_ptr
->map
[w
] &= ~mask
;
119 * nmap_equal - test for equality of node maps
122 static inline int nmap_equal(struct node_map
*nm_a
, struct node_map
*nm_b
)
124 return !memcmp(nm_a
, nm_b
, sizeof(*nm_a
));
128 * nmap_diff - find differences between node maps
129 * @nm_a: input node map A
130 * @nm_b: input node map B
131 * @nm_diff: output node map A-B (i.e. nodes of A that are not in B)
134 static inline void nmap_diff(struct node_map
*nm_a
, struct node_map
*nm_b
,
135 struct node_map
*nm_diff
)
137 int stop
= sizeof(nm_a
->map
) / sizeof(u32
);
142 memset(nm_diff
, 0, sizeof(*nm_diff
));
143 for (w
= 0; w
< stop
; w
++) {
144 map
= nm_a
->map
[w
] ^ (nm_a
->map
[w
] & nm_b
->map
[w
]);
145 nm_diff
->map
[w
] = map
;
147 for (b
= 0 ; b
< WSIZE
; b
++) {
156 * port_list_add - add a port to a port list, ensuring no duplicates
159 static inline void port_list_add(struct port_list
*pl_ptr
, u32 port
)
161 struct port_list
*item
= pl_ptr
;
163 int item_sz
= PLSIZE
;
164 int cnt
= pl_ptr
->count
;
166 for (; ; cnt
-= item_sz
, item
= item
->next
) {
169 for (i
= 0; i
< item_sz
; i
++)
170 if (item
->ports
[i
] == port
)
173 item
->ports
[i
] = port
;
178 item
->next
= kmalloc(sizeof(*item
), GFP_ATOMIC
);
180 warn("Memory squeeze: multicast destination port list is incomplete\n");
183 item
->next
->next
= NULL
;
189 * port_list_free - free dynamically created entries in port_list chain
191 * Note: First item is on stack, so it doesn't need to be released
194 static inline void port_list_free(struct port_list
*pl_ptr
)
196 struct port_list
*item
;
197 struct port_list
*next
;
199 for (item
= pl_ptr
->next
; item
; item
= next
) {
206 int bclink_init(void);
207 void bclink_stop(void);
208 void bclink_acknowledge(struct node
*n_ptr
, u32 acked
);
209 int bclink_send_msg(struct sk_buff
*buf
);
210 void bclink_recv_pkt(struct sk_buff
*buf
);
211 u32
bclink_get_last_sent(void);
212 u32
bclink_acks_missing(struct node
*n_ptr
);
213 void bclink_check_gap(struct node
*n_ptr
, u32 seqno
);
214 int bclink_stats(char *stats_buf
, const u32 buf_size
);
215 int bclink_reset_stats(void);
216 int bclink_set_queue_limits(u32 limit
);
217 void bcbearer_sort(void);
218 void bcbearer_push(void);