diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2011-10-06 15:28:44 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-12-27 11:13:05 -0500 |
commit | 706767da1bd0726d8fbc62e4818cb29193676a74 (patch) | |
tree | f2df46f9850bfb984e64f44ec6c8fca0bf249922 /net/tipc/eth_media.c | |
parent | 2060a5774452e35b4a1dc4371abbb5ffd691355f (diff) |
tipc: Register new media using pre-compiled structure
Speeds up the registration of TIPC media types by passing in a structure
containing the required information, rather than by passing in the various
fields describing the media type individually.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/eth_media.c')
-rw-r--r-- | net/tipc/eth_media.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index e728d4ce2a1b..15c685b868db 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -38,9 +38,6 @@ | |||
38 | #include "bearer.h" | 38 | #include "bearer.h" |
39 | 39 | ||
40 | #define MAX_ETH_BEARERS MAX_BEARERS | 40 | #define MAX_ETH_BEARERS MAX_BEARERS |
41 | #define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI | ||
42 | #define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL | ||
43 | #define ETH_LINK_WINDOW TIPC_DEF_LINK_WIN | ||
44 | 41 | ||
45 | /** | 42 | /** |
46 | * struct eth_bearer - Ethernet bearer data structure | 43 | * struct eth_bearer - Ethernet bearer data structure |
@@ -257,6 +254,24 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size | |||
257 | return str_buf; | 254 | return str_buf; |
258 | } | 255 | } |
259 | 256 | ||
257 | /* | ||
258 | * Ethernet media registration info | ||
259 | */ | ||
260 | |||
261 | static struct media eth_media_info = { | ||
262 | .send_msg = send_msg, | ||
263 | .enable_bearer = enable_bearer, | ||
264 | .disable_bearer = disable_bearer, | ||
265 | .addr2str = eth_addr2str, | ||
266 | .bcast_addr = { htonl(TIPC_MEDIA_TYPE_ETH), | ||
267 | { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} } }, | ||
268 | .priority = TIPC_DEF_LINK_PRI, | ||
269 | .tolerance = TIPC_DEF_LINK_TOL, | ||
270 | .window = TIPC_DEF_LINK_WIN, | ||
271 | .type_id = TIPC_MEDIA_TYPE_ETH, | ||
272 | .name = "eth" | ||
273 | }; | ||
274 | |||
260 | /** | 275 | /** |
261 | * tipc_eth_media_start - activate Ethernet bearer support | 276 | * tipc_eth_media_start - activate Ethernet bearer support |
262 | * | 277 | * |
@@ -266,21 +281,14 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size | |||
266 | 281 | ||
267 | int tipc_eth_media_start(void) | 282 | int tipc_eth_media_start(void) |
268 | { | 283 | { |
269 | struct tipc_media_addr bcast_addr; | ||
270 | int res; | 284 | int res; |
271 | 285 | ||
272 | if (eth_started) | 286 | if (eth_started) |
273 | return -EINVAL; | 287 | return -EINVAL; |
274 | 288 | ||
275 | bcast_addr.type = htonl(TIPC_MEDIA_TYPE_ETH); | ||
276 | memset(&bcast_addr.dev_addr, 0xff, ETH_ALEN); | ||
277 | |||
278 | memset(eth_bearers, 0, sizeof(eth_bearers)); | 289 | memset(eth_bearers, 0, sizeof(eth_bearers)); |
279 | 290 | ||
280 | res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth", | 291 | res = tipc_register_media(ð_media_info); |
281 | enable_bearer, disable_bearer, send_msg, | ||
282 | eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY, | ||
283 | ETH_LINK_TOLERANCE, ETH_LINK_WINDOW); | ||
284 | if (res) | 292 | if (res) |
285 | return res; | 293 | return res; |
286 | 294 | ||