aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/tipc/bearer.c63
-rw-r--r--net/tipc/bearer.h5
-rw-r--r--net/tipc/eth_media.c10
-rw-r--r--net/tipc/ib_media.c7
4 files changed, 23 insertions, 62 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index c2101c0bfd6d..826aa9fdf45f 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * net/tipc/bearer.c: TIPC bearer code 2 * net/tipc/bearer.c: TIPC bearer code
3 * 3 *
4 * Copyright (c) 1996-2006, Ericsson AB 4 * Copyright (c) 1996-2006, 2013, Ericsson AB
5 * Copyright (c) 2004-2006, 2010-2011, Wind River Systems 5 * Copyright (c) 2004-2006, 2010-2011, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -41,8 +41,13 @@
41 41
42#define MAX_ADDR_STR 60 42#define MAX_ADDR_STR 60
43 43
44static struct tipc_media *media_list[MAX_MEDIA]; 44static struct tipc_media * const media_list[] = {
45static u32 media_count; 45 &eth_media_info,
46#ifdef CONFIG_TIPC_MEDIA_IB
47 &ib_media_info,
48#endif
49 NULL
50};
46 51
47struct tipc_bearer tipc_bearers[MAX_BEARERS]; 52struct tipc_bearer tipc_bearers[MAX_BEARERS];
48 53
@@ -55,11 +60,11 @@ struct tipc_media *tipc_media_find(const char *name)
55{ 60{
56 u32 i; 61 u32 i;
57 62
58 for (i = 0; i < media_count; i++) { 63 for (i = 0; media_list[i] != NULL; i++) {
59 if (!strcmp(media_list[i]->name, name)) 64 if (!strcmp(media_list[i]->name, name))
60 return media_list[i]; 65 break;
61 } 66 }
62 return NULL; 67 return media_list[i];
63} 68}
64 69
65/** 70/**
@@ -69,44 +74,11 @@ static struct tipc_media *media_find_id(u8 type)
69{ 74{
70 u32 i; 75 u32 i;
71 76
72 for (i = 0; i < media_count; i++) { 77 for (i = 0; media_list[i] != NULL; i++) {
73 if (media_list[i]->type_id == type) 78 if (media_list[i]->type_id == type)
74 return media_list[i]; 79 break;
75 } 80 }
76 return NULL; 81 return media_list[i];
77}
78
79/**
80 * tipc_register_media - register a media type
81 *
82 * Bearers for this media type must be activated separately at a later stage.
83 */
84int tipc_register_media(struct tipc_media *m_ptr)
85{
86 int res = -EINVAL;
87
88 write_lock_bh(&tipc_net_lock);
89
90 if ((strlen(m_ptr->name) + 1) > TIPC_MAX_MEDIA_NAME)
91 goto exit;
92 if (m_ptr->priority > TIPC_MAX_LINK_PRI)
93 goto exit;
94 if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
95 (m_ptr->tolerance > TIPC_MAX_LINK_TOL))
96 goto exit;
97 if (media_count >= MAX_MEDIA)
98 goto exit;
99 if (tipc_media_find(m_ptr->name) || media_find_id(m_ptr->type_id))
100 goto exit;
101
102 media_list[media_count] = m_ptr;
103 media_count++;
104 res = 0;
105exit:
106 write_unlock_bh(&tipc_net_lock);
107 if (res)
108 pr_warn("Media <%s> registration error\n", m_ptr->name);
109 return res;
110} 82}
111 83
112/** 84/**
@@ -144,13 +116,11 @@ struct sk_buff *tipc_media_get_names(void)
144 if (!buf) 116 if (!buf)
145 return NULL; 117 return NULL;
146 118
147 read_lock_bh(&tipc_net_lock); 119 for (i = 0; media_list[i] != NULL; i++) {
148 for (i = 0; i < media_count; i++) {
149 tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, 120 tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME,
150 media_list[i]->name, 121 media_list[i]->name,
151 strlen(media_list[i]->name) + 1); 122 strlen(media_list[i]->name) + 1);
152 } 123 }
153 read_unlock_bh(&tipc_net_lock);
154 return buf; 124 return buf;
155} 125}
156 126
@@ -247,7 +217,7 @@ struct sk_buff *tipc_bearer_get_names(void)
247 return NULL; 217 return NULL;
248 218
249 read_lock_bh(&tipc_net_lock); 219 read_lock_bh(&tipc_net_lock);
250 for (i = 0; i < media_count; i++) { 220 for (i = 0; media_list[i] != NULL; i++) {
251 for (j = 0; j < MAX_BEARERS; j++) { 221 for (j = 0; j < MAX_BEARERS; j++) {
252 b_ptr = &tipc_bearers[j]; 222 b_ptr = &tipc_bearers[j];
253 if (b_ptr->active && (b_ptr->media == media_list[i])) { 223 if (b_ptr->active && (b_ptr->media == media_list[i])) {
@@ -472,5 +442,4 @@ void tipc_bearer_stop(void)
472 if (tipc_bearers[i].active) 442 if (tipc_bearers[i].active)
473 bearer_disable(&tipc_bearers[i]); 443 bearer_disable(&tipc_bearers[i]);
474 } 444 }
475 media_count = 0;
476} 445}
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index cc780bbedbb9..516af8c0577d 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * net/tipc/bearer.h: Include file for TIPC bearer code 2 * net/tipc/bearer.h: Include file for TIPC bearer code
3 * 3 *
4 * Copyright (c) 1996-2006, Ericsson AB 4 * Copyright (c) 1996-2006, 2013, Ericsson AB
5 * Copyright (c) 2005, 2010-2011, Wind River Systems 5 * Copyright (c) 2005, 2010-2011, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -157,7 +157,6 @@ extern struct tipc_bearer tipc_bearers[];
157/* 157/*
158 * TIPC routines available to supported media types 158 * TIPC routines available to supported media types
159 */ 159 */
160int tipc_register_media(struct tipc_media *m_ptr);
161 160
162void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); 161void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
163 162
@@ -171,10 +170,12 @@ int tipc_disable_bearer(const char *name);
171 */ 170 */
172int tipc_eth_media_start(void); 171int tipc_eth_media_start(void);
173void tipc_eth_media_stop(void); 172void tipc_eth_media_stop(void);
173extern struct tipc_media eth_media_info;
174 174
175#ifdef CONFIG_TIPC_MEDIA_IB 175#ifdef CONFIG_TIPC_MEDIA_IB
176int tipc_ib_media_start(void); 176int tipc_ib_media_start(void);
177void tipc_ib_media_stop(void); 177void tipc_ib_media_stop(void);
178extern struct tipc_media ib_media_info;
178#else 179#else
179static inline int tipc_ib_media_start(void) { return 0; } 180static inline int tipc_ib_media_start(void) { return 0; }
180static inline void tipc_ib_media_stop(void) { return; } 181static inline void tipc_ib_media_stop(void) { return; }
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index 1e3c33250db3..37fb145476ec 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * net/tipc/eth_media.c: Ethernet bearer support for TIPC 2 * net/tipc/eth_media.c: Ethernet bearer support for TIPC
3 * 3 *
4 * Copyright (c) 2001-2007, Ericsson AB 4 * Copyright (c) 2001-2007, 2013, Ericsson AB
5 * Copyright (c) 2005-2008, 2011-2013, Wind River Systems 5 * Copyright (c) 2005-2008, 2011-2013, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -57,7 +57,7 @@ struct eth_media {
57 struct work_struct cleanup; 57 struct work_struct cleanup;
58}; 58};
59 59
60static struct tipc_media eth_media_info; 60
61static struct eth_media eth_media_array[MAX_ETH_MEDIA]; 61static struct eth_media eth_media_array[MAX_ETH_MEDIA];
62static int eth_started; 62static int eth_started;
63 63
@@ -315,7 +315,7 @@ static int eth_msg2addr(const struct tipc_bearer *tb_ptr,
315/* 315/*
316 * Ethernet media registration info 316 * Ethernet media registration info
317 */ 317 */
318static struct tipc_media eth_media_info = { 318struct tipc_media eth_media_info = {
319 .send_msg = send_msg, 319 .send_msg = send_msg,
320 .enable_media = enable_media, 320 .enable_media = enable_media,
321 .disable_media = disable_media, 321 .disable_media = disable_media,
@@ -342,10 +342,6 @@ int tipc_eth_media_start(void)
342 if (eth_started) 342 if (eth_started)
343 return -EINVAL; 343 return -EINVAL;
344 344
345 res = tipc_register_media(&eth_media_info);
346 if (res)
347 return res;
348
349 res = register_netdevice_notifier(&notifier); 345 res = register_netdevice_notifier(&notifier);
350 if (!res) 346 if (!res)
351 eth_started = 1; 347 eth_started = 1;
diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c
index cbe7fe15cc7c..48e1c07842e6 100644
--- a/net/tipc/ib_media.c
+++ b/net/tipc/ib_media.c
@@ -60,7 +60,6 @@ struct ib_media {
60 struct work_struct cleanup; 60 struct work_struct cleanup;
61}; 61};
62 62
63static struct tipc_media ib_media_info;
64static struct ib_media ib_media_array[MAX_IB_MEDIA]; 63static struct ib_media ib_media_array[MAX_IB_MEDIA];
65static int ib_started; 64static int ib_started;
66 65
@@ -311,7 +310,7 @@ static int ib_msg2addr(const struct tipc_bearer *tb_ptr,
311/* 310/*
312 * InfiniBand media registration info 311 * InfiniBand media registration info
313 */ 312 */
314static struct tipc_media ib_media_info = { 313struct tipc_media ib_media_info = {
315 .send_msg = send_msg, 314 .send_msg = send_msg,
316 .enable_media = enable_media, 315 .enable_media = enable_media,
317 .disable_media = disable_media, 316 .disable_media = disable_media,
@@ -338,10 +337,6 @@ int tipc_ib_media_start(void)
338 if (ib_started) 337 if (ib_started)
339 return -EINVAL; 338 return -EINVAL;
340 339
341 res = tipc_register_media(&ib_media_info);
342 if (res)
343 return res;
344
345 res = register_netdevice_notifier(&notifier); 340 res = register_netdevice_notifier(&notifier);
346 if (!res) 341 if (!res)
347 ib_started = 1; 342 ib_started = 1;