aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/core.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/tipc/core.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'net/tipc/core.c')
-rw-r--r--net/tipc/core.c151
1 files changed, 32 insertions, 119 deletions
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 696468117985..943b6af84265 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -2,7 +2,7 @@
2 * net/tipc/core.c: TIPC module code 2 * net/tipc/core.c: TIPC module code
3 * 3 *
4 * Copyright (c) 2003-2006, Ericsson AB 4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005-2006, Wind River Systems 5 * Copyright (c) 2005-2006, 2010-2011, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -34,37 +34,13 @@
34 * POSSIBILITY OF SUCH DAMAGE. 34 * POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37#include <linux/init.h>
38#include <linux/module.h>
39#include <linux/kernel.h>
40#include <linux/random.h>
41
42#include "core.h" 37#include "core.h"
43#include "dbg.h"
44#include "ref.h" 38#include "ref.h"
45#include "net.h"
46#include "user_reg.h"
47#include "name_table.h" 39#include "name_table.h"
48#include "subscr.h" 40#include "subscr.h"
49#include "config.h" 41#include "config.h"
50 42
51 43
52#ifndef CONFIG_TIPC_ZONES
53#define CONFIG_TIPC_ZONES 3
54#endif
55
56#ifndef CONFIG_TIPC_CLUSTERS
57#define CONFIG_TIPC_CLUSTERS 1
58#endif
59
60#ifndef CONFIG_TIPC_NODES
61#define CONFIG_TIPC_NODES 255
62#endif
63
64#ifndef CONFIG_TIPC_SLAVE_NODES
65#define CONFIG_TIPC_SLAVE_NODES 0
66#endif
67
68#ifndef CONFIG_TIPC_PORTS 44#ifndef CONFIG_TIPC_PORTS
69#define CONFIG_TIPC_PORTS 8191 45#define CONFIG_TIPC_PORTS 8191
70#endif 46#endif
@@ -77,7 +53,6 @@
77 53
78int tipc_mode = TIPC_NOT_RUNNING; 54int tipc_mode = TIPC_NOT_RUNNING;
79int tipc_random; 55int tipc_random;
80atomic_t tipc_user_count = ATOMIC_INIT(0);
81 56
82const char tipc_alphabet[] = 57const char tipc_alphabet[] =
83 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."; 58 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.";
@@ -85,10 +60,6 @@ const char tipc_alphabet[] =
85/* configurable TIPC parameters */ 60/* configurable TIPC parameters */
86 61
87u32 tipc_own_addr; 62u32 tipc_own_addr;
88int tipc_max_zones;
89int tipc_max_clusters;
90int tipc_max_nodes;
91int tipc_max_slaves;
92int tipc_max_ports; 63int tipc_max_ports;
93int tipc_max_subscriptions; 64int tipc_max_subscriptions;
94int tipc_max_publications; 65int tipc_max_publications;
@@ -96,13 +67,8 @@ int tipc_net_id;
96int tipc_remote_management; 67int tipc_remote_management;
97 68
98 69
99int tipc_get_mode(void)
100{
101 return tipc_mode;
102}
103
104/** 70/**
105 * buf_acquire - creates a TIPC message buffer 71 * tipc_buf_acquire - creates a TIPC message buffer
106 * @size: message size (including TIPC header) 72 * @size: message size (including TIPC header)
107 * 73 *
108 * Returns a new buffer with data pointers set to the specified size. 74 * Returns a new buffer with data pointers set to the specified size.
@@ -111,7 +77,7 @@ int tipc_get_mode(void)
111 * There may also be unrequested tailroom present at the buffer's end. 77 * There may also be unrequested tailroom present at the buffer's end.
112 */ 78 */
113 79
114struct sk_buff *buf_acquire(u32 size) 80struct sk_buff *tipc_buf_acquire(u32 size)
115{ 81{
116 struct sk_buff *skb; 82 struct sk_buff *skb;
117 unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u; 83 unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
@@ -129,7 +95,7 @@ struct sk_buff *buf_acquire(u32 size)
129 * tipc_core_stop_net - shut down TIPC networking sub-systems 95 * tipc_core_stop_net - shut down TIPC networking sub-systems
130 */ 96 */
131 97
132void tipc_core_stop_net(void) 98static void tipc_core_stop_net(void)
133{ 99{
134 tipc_eth_media_stop(); 100 tipc_eth_media_stop();
135 tipc_net_stop(); 101 tipc_net_stop();
@@ -143,10 +109,11 @@ int tipc_core_start_net(unsigned long addr)
143{ 109{
144 int res; 110 int res;
145 111
146 if ((res = tipc_net_start(addr)) || 112 res = tipc_net_start(addr);
147 (res = tipc_eth_media_start())) { 113 if (!res)
114 res = tipc_eth_media_start();
115 if (res)
148 tipc_core_stop_net(); 116 tipc_core_stop_net();
149 }
150 return res; 117 return res;
151} 118}
152 119
@@ -154,7 +121,7 @@ int tipc_core_start_net(unsigned long addr)
154 * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode 121 * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode
155 */ 122 */
156 123
157void tipc_core_stop(void) 124static void tipc_core_stop(void)
158{ 125{
159 if (tipc_mode != TIPC_NODE_MODE) 126 if (tipc_mode != TIPC_NODE_MODE)
160 return; 127 return;
@@ -165,17 +132,17 @@ void tipc_core_stop(void)
165 tipc_handler_stop(); 132 tipc_handler_stop();
166 tipc_cfg_stop(); 133 tipc_cfg_stop();
167 tipc_subscr_stop(); 134 tipc_subscr_stop();
168 tipc_reg_stop();
169 tipc_nametbl_stop(); 135 tipc_nametbl_stop();
170 tipc_ref_table_stop(); 136 tipc_ref_table_stop();
171 tipc_socket_stop(); 137 tipc_socket_stop();
138 tipc_log_resize(0);
172} 139}
173 140
174/** 141/**
175 * tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode 142 * tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode
176 */ 143 */
177 144
178int tipc_core_start(void) 145static int tipc_core_start(void)
179{ 146{
180 int res; 147 int res;
181 148
@@ -185,16 +152,22 @@ int tipc_core_start(void)
185 get_random_bytes(&tipc_random, sizeof(tipc_random)); 152 get_random_bytes(&tipc_random, sizeof(tipc_random));
186 tipc_mode = TIPC_NODE_MODE; 153 tipc_mode = TIPC_NODE_MODE;
187 154
188 if ((res = tipc_handler_start()) || 155 res = tipc_handler_start();
189 (res = tipc_ref_table_init(tipc_max_ports, tipc_random)) || 156 if (!res)
190 (res = tipc_reg_start()) || 157 res = tipc_ref_table_init(tipc_max_ports, tipc_random);
191 (res = tipc_nametbl_init()) || 158 if (!res)
192 (res = tipc_k_signal((Handler)tipc_subscr_start, 0)) || 159 res = tipc_nametbl_init();
193 (res = tipc_k_signal((Handler)tipc_cfg_init, 0)) || 160 if (!res)
194 (res = tipc_netlink_start()) || 161 res = tipc_k_signal((Handler)tipc_subscr_start, 0);
195 (res = tipc_socket_init())) { 162 if (!res)
163 res = tipc_k_signal((Handler)tipc_cfg_init, 0);
164 if (!res)
165 res = tipc_netlink_start();
166 if (!res)
167 res = tipc_socket_init();
168 if (res)
196 tipc_core_stop(); 169 tipc_core_stop();
197 } 170
198 return res; 171 return res;
199} 172}
200 173
@@ -203,22 +176,20 @@ static int __init tipc_init(void)
203{ 176{
204 int res; 177 int res;
205 178
206 tipc_log_resize(CONFIG_TIPC_LOG); 179 if (tipc_log_resize(CONFIG_TIPC_LOG) != 0)
207 info("Activated (version " TIPC_MOD_VER 180 warn("Unable to create log buffer\n");
208 " compiled " __DATE__ " " __TIME__ ")\n"); 181
182 info("Activated (version " TIPC_MOD_VER ")\n");
209 183
210 tipc_own_addr = 0; 184 tipc_own_addr = 0;
211 tipc_remote_management = 1; 185 tipc_remote_management = 1;
212 tipc_max_publications = 10000; 186 tipc_max_publications = 10000;
213 tipc_max_subscriptions = 2000; 187 tipc_max_subscriptions = 2000;
214 tipc_max_ports = CONFIG_TIPC_PORTS; 188 tipc_max_ports = CONFIG_TIPC_PORTS;
215 tipc_max_zones = CONFIG_TIPC_ZONES;
216 tipc_max_clusters = CONFIG_TIPC_CLUSTERS;
217 tipc_max_nodes = CONFIG_TIPC_NODES;
218 tipc_max_slaves = CONFIG_TIPC_SLAVE_NODES;
219 tipc_net_id = 4711; 189 tipc_net_id = 4711;
220 190
221 if ((res = tipc_core_start())) 191 res = tipc_core_start();
192 if (res)
222 err("Unable to start in single node mode\n"); 193 err("Unable to start in single node mode\n");
223 else 194 else
224 info("Started in single node mode\n"); 195 info("Started in single node mode\n");
@@ -230,7 +201,6 @@ static void __exit tipc_exit(void)
230 tipc_core_stop_net(); 201 tipc_core_stop_net();
231 tipc_core_stop(); 202 tipc_core_stop();
232 info("Deactivated\n"); 203 info("Deactivated\n");
233 tipc_log_resize(0);
234} 204}
235 205
236module_init(tipc_init); 206module_init(tipc_init);
@@ -239,60 +209,3 @@ module_exit(tipc_exit);
239MODULE_DESCRIPTION("TIPC: Transparent Inter Process Communication"); 209MODULE_DESCRIPTION("TIPC: Transparent Inter Process Communication");
240MODULE_LICENSE("Dual BSD/GPL"); 210MODULE_LICENSE("Dual BSD/GPL");
241MODULE_VERSION(TIPC_MOD_VER); 211MODULE_VERSION(TIPC_MOD_VER);
242
243/* Native TIPC API for kernel-space applications (see tipc.h) */
244
245EXPORT_SYMBOL(tipc_attach);
246EXPORT_SYMBOL(tipc_detach);
247EXPORT_SYMBOL(tipc_get_addr);
248EXPORT_SYMBOL(tipc_get_mode);
249EXPORT_SYMBOL(tipc_createport);
250EXPORT_SYMBOL(tipc_deleteport);
251EXPORT_SYMBOL(tipc_ownidentity);
252EXPORT_SYMBOL(tipc_portimportance);
253EXPORT_SYMBOL(tipc_set_portimportance);
254EXPORT_SYMBOL(tipc_portunreliable);
255EXPORT_SYMBOL(tipc_set_portunreliable);
256EXPORT_SYMBOL(tipc_portunreturnable);
257EXPORT_SYMBOL(tipc_set_portunreturnable);
258EXPORT_SYMBOL(tipc_publish);
259EXPORT_SYMBOL(tipc_withdraw);
260EXPORT_SYMBOL(tipc_connect2port);
261EXPORT_SYMBOL(tipc_disconnect);
262EXPORT_SYMBOL(tipc_shutdown);
263EXPORT_SYMBOL(tipc_isconnected);
264EXPORT_SYMBOL(tipc_peer);
265EXPORT_SYMBOL(tipc_ref_valid);
266EXPORT_SYMBOL(tipc_send);
267EXPORT_SYMBOL(tipc_send_buf);
268EXPORT_SYMBOL(tipc_send2name);
269EXPORT_SYMBOL(tipc_forward2name);
270EXPORT_SYMBOL(tipc_send_buf2name);
271EXPORT_SYMBOL(tipc_forward_buf2name);
272EXPORT_SYMBOL(tipc_send2port);
273EXPORT_SYMBOL(tipc_forward2port);
274EXPORT_SYMBOL(tipc_send_buf2port);
275EXPORT_SYMBOL(tipc_forward_buf2port);
276EXPORT_SYMBOL(tipc_multicast);
277/* EXPORT_SYMBOL(tipc_multicast_buf); not available yet */
278EXPORT_SYMBOL(tipc_ispublished);
279EXPORT_SYMBOL(tipc_available_nodes);
280
281/* TIPC API for external bearers (see tipc_bearer.h) */
282
283EXPORT_SYMBOL(tipc_block_bearer);
284EXPORT_SYMBOL(tipc_continue);
285EXPORT_SYMBOL(tipc_disable_bearer);
286EXPORT_SYMBOL(tipc_enable_bearer);
287EXPORT_SYMBOL(tipc_recv_msg);
288EXPORT_SYMBOL(tipc_register_media);
289
290/* TIPC API for external APIs (see tipc_port.h) */
291
292EXPORT_SYMBOL(tipc_createport_raw);
293EXPORT_SYMBOL(tipc_reject_msg);
294EXPORT_SYMBOL(tipc_send_buf_fast);
295EXPORT_SYMBOL(tipc_acknowledge);
296EXPORT_SYMBOL(tipc_get_port);
297EXPORT_SYMBOL(tipc_get_handle);
298