2 * net/tipc/bearer.h: Include file for TIPC bearer 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.
38 #ifndef _TIPC_BEARER_H
39 #define _TIPC_BEARER_H
41 #include <net/tipc/tipc_bearer.h>
49 * struct media - TIPC media information available to internal users
50 * @send_msg: routine which handles buffer transmission
51 * @enable_bearer: routine which enables a bearer
52 * @disable_bearer: routine which disables a bearer
53 * @addr2str: routine which converts bearer's address to string form
54 * @bcast_addr: media address used in broadcasting
55 * @bcast: non-zero if media supports broadcasting [currently mandatory]
56 * @priority: default link (and bearer) priority
57 * @tolerance: default time (in ms) before declaring link failure
58 * @window: default window (in packets) before declaring link congestion
59 * @type_id: TIPC media identifier [defined in tipc_bearer.h]
64 int (*send_msg)(struct sk_buff *buf,
65 struct tipc_bearer *b_ptr,
66 struct tipc_media_addr *dest);
67 int (*enable_bearer)(struct tipc_bearer *b_ptr);
68 void (*disable_bearer)(struct tipc_bearer *b_ptr);
69 char *(*addr2str)(struct tipc_media_addr *a,
70 char *str_buf, int str_size);
71 struct tipc_media_addr bcast_addr;
77 char name[TIPC_MAX_MEDIA_NAME];
81 * struct bearer - TIPC bearer information available to internal users
82 * @publ: bearer information available to privileged users
83 * @media: ptr to media structure associated with bearer
84 * @priority: default link priority for bearer
85 * @detect_scope: network address mask used during automatic link creation
86 * @identity: array index of this bearer within TIPC bearer array
87 * @link_req: ptr to (optional) structure making periodic link setup requests
88 * @links: list of non-congested links associated with bearer
89 * @cong_links: list of congested links associated with bearer
90 * @continue_count: # of times bearer has resumed after congestion or blocking
91 * @active: non-zero if bearer structure is represents a bearer
92 * @net_plane: network plane ('A' through 'H') currently associated with bearer
93 * @nodes: indicates which nodes in cluster can be reached through bearer
97 struct tipc_bearer publ;
102 struct link_req *link_req;
103 struct list_head links;
104 struct list_head cong_links;
108 struct node_map nodes;
112 char media_name[TIPC_MAX_MEDIA_NAME];
113 char if_name[TIPC_MAX_IF_NAME];
118 extern struct bearer *bearers;
120 void media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a);
121 struct sk_buff *media_get_names(void);
123 struct sk_buff *bearer_get_names(void);
124 void bearer_add_dest(struct bearer *b_ptr, u32 dest);
125 void bearer_remove_dest(struct bearer *b_ptr, u32 dest);
126 void bearer_schedule(struct bearer *b_ptr, struct link *l_ptr);
127 struct bearer *bearer_find_interface(const char *if_name);
128 int bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr);
129 int bearer_init(void);
130 void bearer_stop(void);
131 int bearer_broadcast(struct sk_buff *buf, struct tipc_bearer *b_ptr,
132 struct tipc_media_addr *dest);
133 void bearer_lock_push(struct bearer *b_ptr);
137 * bearer_send- sends buffer to destination over bearer
139 * Returns true (1) if successful, or false (0) if unable to send
142 * The media send routine must not alter the buffer being passed in
143 * as it may be needed for later retransmission!
145 * If the media send routine returns a non-zero value (indicating that
146 * it was unable to send the buffer), it must:
147 * 1) mark the bearer as blocked,
148 * 2) call tipc_continue() once the bearer is able to send again.
149 * Media types that are unable to meet these two critera must ensure their
150 * send routine always returns success -- even if the buffer was not sent --
151 * and let TIPC's link code deal with the undelivered message.
154 static inline int bearer_send(struct bearer *b_ptr, struct sk_buff *buf,
155 struct tipc_media_addr *dest)
157 return !b_ptr->media->send_msg(buf, &b_ptr->publ, dest);
161 * bearer_congested - determines if bearer is currently congested
164 static inline int bearer_congested(struct bearer *b_ptr, struct link *l_ptr)
166 if (unlikely(b_ptr->publ.blocked))
168 if (likely(list_empty(&b_ptr->cong_links)))
170 return !bearer_resolve_congestion(b_ptr, l_ptr);