aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/tipc/bcast.c28
-rw-r--r--net/tipc/bearer.c98
-rw-r--r--net/tipc/bearer.h67
-rw-r--r--net/tipc/discover.c26
-rw-r--r--net/tipc/discover.h6
-rw-r--r--net/tipc/link.c13
-rw-r--r--net/tipc/link.h4
-rw-r--r--net/tipc/node.c4
8 files changed, 119 insertions, 127 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 70ab5ef48766..b4d659df465f 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (c) 2004-2006, Ericsson AB 4 * Copyright (c) 2004-2006, Ericsson AB
5 * Copyright (c) 2004, Intel Corporation. 5 * Copyright (c) 2004, Intel Corporation.
6 * Copyright (c) 2005, Wind River Systems 6 * Copyright (c) 2005, 2010-2011, Wind River Systems
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
@@ -61,8 +61,8 @@
61 */ 61 */
62 62
63struct bcbearer_pair { 63struct bcbearer_pair {
64 struct bearer *primary; 64 struct tipc_bearer *primary;
65 struct bearer *secondary; 65 struct tipc_bearer *secondary;
66}; 66};
67 67
68/** 68/**
@@ -81,7 +81,7 @@ struct bcbearer_pair {
81 */ 81 */
82 82
83struct bcbearer { 83struct bcbearer {
84 struct bearer bearer; 84 struct tipc_bearer bearer;
85 struct media media; 85 struct media media;
86 struct bcbearer_pair bpairs[MAX_BEARERS]; 86 struct bcbearer_pair bpairs[MAX_BEARERS];
87 struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1]; 87 struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1];
@@ -574,8 +574,8 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
574 bcbearer->remains = tipc_bcast_nmap; 574 bcbearer->remains = tipc_bcast_nmap;
575 575
576 for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) { 576 for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) {
577 struct bearer *p = bcbearer->bpairs[bp_index].primary; 577 struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;
578 struct bearer *s = bcbearer->bpairs[bp_index].secondary; 578 struct tipc_bearer *s = bcbearer->bpairs[bp_index].secondary;
579 579
580 if (!p) 580 if (!p)
581 break; /* no more bearers to try */ 581 break; /* no more bearers to try */
@@ -584,11 +584,11 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
584 if (bcbearer->remains_new.count == bcbearer->remains.count) 584 if (bcbearer->remains_new.count == bcbearer->remains.count)
585 continue; /* bearer pair doesn't add anything */ 585 continue; /* bearer pair doesn't add anything */
586 586
587 if (p->publ.blocked || 587 if (p->blocked ||
588 p->media->send_msg(buf, &p->publ, &p->media->bcast_addr)) { 588 p->media->send_msg(buf, p, &p->media->bcast_addr)) {
589 /* unable to send on primary bearer */ 589 /* unable to send on primary bearer */
590 if (!s || s->publ.blocked || 590 if (!s || s->blocked ||
591 s->media->send_msg(buf, &s->publ, 591 s->media->send_msg(buf, s,
592 &s->media->bcast_addr)) { 592 &s->media->bcast_addr)) {
593 /* unable to send on either bearer */ 593 /* unable to send on either bearer */
594 continue; 594 continue;
@@ -633,7 +633,7 @@ void tipc_bcbearer_sort(void)
633 memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp)); 633 memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp));
634 634
635 for (b_index = 0; b_index < MAX_BEARERS; b_index++) { 635 for (b_index = 0; b_index < MAX_BEARERS; b_index++) {
636 struct bearer *b = &tipc_bearers[b_index]; 636 struct tipc_bearer *b = &tipc_bearers[b_index];
637 637
638 if (!b->active || !b->nodes.count) 638 if (!b->active || !b->nodes.count)
639 continue; 639 continue;
@@ -682,12 +682,12 @@ void tipc_bcbearer_sort(void)
682 682
683void tipc_bcbearer_push(void) 683void tipc_bcbearer_push(void)
684{ 684{
685 struct bearer *b_ptr; 685 struct tipc_bearer *b_ptr;
686 686
687 spin_lock_bh(&bc_lock); 687 spin_lock_bh(&bc_lock);
688 b_ptr = &bcbearer->bearer; 688 b_ptr = &bcbearer->bearer;
689 if (b_ptr->publ.blocked) { 689 if (b_ptr->blocked) {
690 b_ptr->publ.blocked = 0; 690 b_ptr->blocked = 0;
691 tipc_bearer_lock_push(b_ptr); 691 tipc_bearer_lock_push(b_ptr);
692 } 692 }
693 spin_unlock_bh(&bc_lock); 693 spin_unlock_bh(&bc_lock);
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 837b7a467885..9e2ff0ed017b 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -2,7 +2,7 @@
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, Ericsson AB
5 * Copyright (c) 2004-2006, Wind River Systems 5 * Copyright (c) 2004-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
@@ -44,7 +44,7 @@
44static struct media media_list[MAX_MEDIA]; 44static struct media media_list[MAX_MEDIA];
45static u32 media_count; 45static u32 media_count;
46 46
47struct bearer tipc_bearers[MAX_BEARERS]; 47struct tipc_bearer tipc_bearers[MAX_BEARERS];
48 48
49/** 49/**
50 * media_name_valid - validate media name 50 * media_name_valid - validate media name
@@ -278,13 +278,13 @@ static int bearer_name_validate(const char *name,
278 * bearer_find - locates bearer object with matching bearer name 278 * bearer_find - locates bearer object with matching bearer name
279 */ 279 */
280 280
281static struct bearer *bearer_find(const char *name) 281static struct tipc_bearer *bearer_find(const char *name)
282{ 282{
283 struct bearer *b_ptr; 283 struct tipc_bearer *b_ptr;
284 u32 i; 284 u32 i;
285 285
286 for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { 286 for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) {
287 if (b_ptr->active && (!strcmp(b_ptr->publ.name, name))) 287 if (b_ptr->active && (!strcmp(b_ptr->name, name)))
288 return b_ptr; 288 return b_ptr;
289 } 289 }
290 return NULL; 290 return NULL;
@@ -294,16 +294,16 @@ static struct bearer *bearer_find(const char *name)
294 * tipc_bearer_find_interface - locates bearer object with matching interface name 294 * tipc_bearer_find_interface - locates bearer object with matching interface name
295 */ 295 */
296 296
297struct bearer *tipc_bearer_find_interface(const char *if_name) 297struct tipc_bearer *tipc_bearer_find_interface(const char *if_name)
298{ 298{
299 struct bearer *b_ptr; 299 struct tipc_bearer *b_ptr;
300 char *b_if_name; 300 char *b_if_name;
301 u32 i; 301 u32 i;
302 302
303 for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { 303 for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) {
304 if (!b_ptr->active) 304 if (!b_ptr->active)
305 continue; 305 continue;
306 b_if_name = strchr(b_ptr->publ.name, ':') + 1; 306 b_if_name = strchr(b_ptr->name, ':') + 1;
307 if (!strcmp(b_if_name, if_name)) 307 if (!strcmp(b_if_name, if_name))
308 return b_ptr; 308 return b_ptr;
309 } 309 }
@@ -318,7 +318,7 @@ struct sk_buff *tipc_bearer_get_names(void)
318{ 318{
319 struct sk_buff *buf; 319 struct sk_buff *buf;
320 struct media *m_ptr; 320 struct media *m_ptr;
321 struct bearer *b_ptr; 321 struct tipc_bearer *b_ptr;
322 int i, j; 322 int i, j;
323 323
324 buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME)); 324 buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME));
@@ -331,8 +331,8 @@ struct sk_buff *tipc_bearer_get_names(void)
331 b_ptr = &tipc_bearers[j]; 331 b_ptr = &tipc_bearers[j];
332 if (b_ptr->active && (b_ptr->media == m_ptr)) { 332 if (b_ptr->active && (b_ptr->media == m_ptr)) {
333 tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, 333 tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME,
334 b_ptr->publ.name, 334 b_ptr->name,
335 strlen(b_ptr->publ.name) + 1); 335 strlen(b_ptr->name) + 1);
336 } 336 }
337 } 337 }
338 } 338 }
@@ -340,14 +340,14 @@ struct sk_buff *tipc_bearer_get_names(void)
340 return buf; 340 return buf;
341} 341}
342 342
343void tipc_bearer_add_dest(struct bearer *b_ptr, u32 dest) 343void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest)
344{ 344{
345 tipc_nmap_add(&b_ptr->nodes, dest); 345 tipc_nmap_add(&b_ptr->nodes, dest);
346 tipc_disc_update_link_req(b_ptr->link_req); 346 tipc_disc_update_link_req(b_ptr->link_req);
347 tipc_bcbearer_sort(); 347 tipc_bcbearer_sort();
348} 348}
349 349
350void tipc_bearer_remove_dest(struct bearer *b_ptr, u32 dest) 350void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest)
351{ 351{
352 tipc_nmap_remove(&b_ptr->nodes, dest); 352 tipc_nmap_remove(&b_ptr->nodes, dest);
353 tipc_disc_update_link_req(b_ptr->link_req); 353 tipc_disc_update_link_req(b_ptr->link_req);
@@ -362,12 +362,12 @@ void tipc_bearer_remove_dest(struct bearer *b_ptr, u32 dest)
362 * bearer.lock must be taken before calling 362 * bearer.lock must be taken before calling
363 * Returns binary true(1) ore false(0) 363 * Returns binary true(1) ore false(0)
364 */ 364 */
365static int bearer_push(struct bearer *b_ptr) 365static int bearer_push(struct tipc_bearer *b_ptr)
366{ 366{
367 u32 res = 0; 367 u32 res = 0;
368 struct link *ln, *tln; 368 struct link *ln, *tln;
369 369
370 if (b_ptr->publ.blocked) 370 if (b_ptr->blocked)
371 return 0; 371 return 0;
372 372
373 while (!list_empty(&b_ptr->cong_links) && (res != PUSH_FAILED)) { 373 while (!list_empty(&b_ptr->cong_links) && (res != PUSH_FAILED)) {
@@ -382,13 +382,13 @@ static int bearer_push(struct bearer *b_ptr)
382 return list_empty(&b_ptr->cong_links); 382 return list_empty(&b_ptr->cong_links);
383} 383}
384 384
385void tipc_bearer_lock_push(struct bearer *b_ptr) 385void tipc_bearer_lock_push(struct tipc_bearer *b_ptr)
386{ 386{
387 int res; 387 int res;
388 388
389 spin_lock_bh(&b_ptr->publ.lock); 389 spin_lock_bh(&b_ptr->lock);
390 res = bearer_push(b_ptr); 390 res = bearer_push(b_ptr);
391 spin_unlock_bh(&b_ptr->publ.lock); 391 spin_unlock_bh(&b_ptr->lock);
392 if (res) 392 if (res)
393 tipc_bcbearer_push(); 393 tipc_bcbearer_push();
394} 394}
@@ -398,16 +398,14 @@ void tipc_bearer_lock_push(struct bearer *b_ptr)
398 * Interrupt enabling new requests after bearer congestion or blocking: 398 * Interrupt enabling new requests after bearer congestion or blocking:
399 * See bearer_send(). 399 * See bearer_send().
400 */ 400 */
401void tipc_continue(struct tipc_bearer *tb_ptr) 401void tipc_continue(struct tipc_bearer *b_ptr)
402{ 402{
403 struct bearer *b_ptr = (struct bearer *)tb_ptr; 403 spin_lock_bh(&b_ptr->lock);
404
405 spin_lock_bh(&b_ptr->publ.lock);
406 b_ptr->continue_count++; 404 b_ptr->continue_count++;
407 if (!list_empty(&b_ptr->cong_links)) 405 if (!list_empty(&b_ptr->cong_links))
408 tipc_k_signal((Handler)tipc_bearer_lock_push, (unsigned long)b_ptr); 406 tipc_k_signal((Handler)tipc_bearer_lock_push, (unsigned long)b_ptr);
409 b_ptr->publ.blocked = 0; 407 b_ptr->blocked = 0;
410 spin_unlock_bh(&b_ptr->publ.lock); 408 spin_unlock_bh(&b_ptr->lock);
411} 409}
412 410
413/* 411/*
@@ -418,7 +416,7 @@ void tipc_continue(struct tipc_bearer *tb_ptr)
418 * bearer.lock is busy 416 * bearer.lock is busy
419 */ 417 */
420 418
421static void tipc_bearer_schedule_unlocked(struct bearer *b_ptr, struct link *l_ptr) 419static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr, struct link *l_ptr)
422{ 420{
423 list_move_tail(&l_ptr->link_list, &b_ptr->cong_links); 421 list_move_tail(&l_ptr->link_list, &b_ptr->cong_links);
424} 422}
@@ -431,11 +429,11 @@ static void tipc_bearer_schedule_unlocked(struct bearer *b_ptr, struct link *l_p
431 * bearer.lock is free 429 * bearer.lock is free
432 */ 430 */
433 431
434void tipc_bearer_schedule(struct bearer *b_ptr, struct link *l_ptr) 432void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr)
435{ 433{
436 spin_lock_bh(&b_ptr->publ.lock); 434 spin_lock_bh(&b_ptr->lock);
437 tipc_bearer_schedule_unlocked(b_ptr, l_ptr); 435 tipc_bearer_schedule_unlocked(b_ptr, l_ptr);
438 spin_unlock_bh(&b_ptr->publ.lock); 436 spin_unlock_bh(&b_ptr->lock);
439} 437}
440 438
441 439
@@ -444,18 +442,18 @@ void tipc_bearer_schedule(struct bearer *b_ptr, struct link *l_ptr)
444 * and if there is, try to resolve it before returning. 442 * and if there is, try to resolve it before returning.
445 * 'tipc_net_lock' is read_locked when this function is called 443 * 'tipc_net_lock' is read_locked when this function is called
446 */ 444 */
447int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr) 445int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr)
448{ 446{
449 int res = 1; 447 int res = 1;
450 448
451 if (list_empty(&b_ptr->cong_links)) 449 if (list_empty(&b_ptr->cong_links))
452 return 1; 450 return 1;
453 spin_lock_bh(&b_ptr->publ.lock); 451 spin_lock_bh(&b_ptr->lock);
454 if (!bearer_push(b_ptr)) { 452 if (!bearer_push(b_ptr)) {
455 tipc_bearer_schedule_unlocked(b_ptr, l_ptr); 453 tipc_bearer_schedule_unlocked(b_ptr, l_ptr);
456 res = 0; 454 res = 0;
457 } 455 }
458 spin_unlock_bh(&b_ptr->publ.lock); 456 spin_unlock_bh(&b_ptr->lock);
459 return res; 457 return res;
460} 458}
461 459
@@ -463,9 +461,9 @@ int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr)
463 * tipc_bearer_congested - determines if bearer is currently congested 461 * tipc_bearer_congested - determines if bearer is currently congested
464 */ 462 */
465 463
466int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr) 464int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr)
467{ 465{
468 if (unlikely(b_ptr->publ.blocked)) 466 if (unlikely(b_ptr->blocked))
469 return 1; 467 return 1;
470 if (likely(list_empty(&b_ptr->cong_links))) 468 if (likely(list_empty(&b_ptr->cong_links)))
471 return 0; 469 return 0;
@@ -478,7 +476,7 @@ int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr)
478 476
479int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority) 477int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
480{ 478{
481 struct bearer *b_ptr; 479 struct tipc_bearer *b_ptr;
482 struct media *m_ptr; 480 struct media *m_ptr;
483 struct bearer_name b_name; 481 struct bearer_name b_name;
484 char addr_string[16]; 482 char addr_string[16];
@@ -528,7 +526,7 @@ restart:
528 bearer_id = i; 526 bearer_id = i;
529 continue; 527 continue;
530 } 528 }
531 if (!strcmp(name, tipc_bearers[i].publ.name)) { 529 if (!strcmp(name, tipc_bearers[i].name)) {
532 warn("Bearer <%s> rejected, already enabled\n", name); 530 warn("Bearer <%s> rejected, already enabled\n", name);
533 goto failed; 531 goto failed;
534 } 532 }
@@ -551,8 +549,8 @@ restart:
551 } 549 }
552 550
553 b_ptr = &tipc_bearers[bearer_id]; 551 b_ptr = &tipc_bearers[bearer_id];
554 strcpy(b_ptr->publ.name, name); 552 strcpy(b_ptr->name, name);
555 res = m_ptr->enable_bearer(&b_ptr->publ); 553 res = m_ptr->enable_bearer(b_ptr);
556 if (res) { 554 if (res) {
557 warn("Bearer <%s> rejected, enable failure (%d)\n", name, -res); 555 warn("Bearer <%s> rejected, enable failure (%d)\n", name, -res);
558 goto failed; 556 goto failed;
@@ -570,7 +568,7 @@ restart:
570 b_ptr->link_req = tipc_disc_init_link_req(b_ptr, &m_ptr->bcast_addr, 568 b_ptr->link_req = tipc_disc_init_link_req(b_ptr, &m_ptr->bcast_addr,
571 bcast_scope, 2); 569 bcast_scope, 2);
572 } 570 }
573 spin_lock_init(&b_ptr->publ.lock); 571 spin_lock_init(&b_ptr->lock);
574 write_unlock_bh(&tipc_net_lock); 572 write_unlock_bh(&tipc_net_lock);
575 info("Enabled bearer <%s>, discovery domain %s, priority %u\n", 573 info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
576 name, tipc_addr_string_fill(addr_string, bcast_scope), priority); 574 name, tipc_addr_string_fill(addr_string, bcast_scope), priority);
@@ -587,7 +585,7 @@ failed:
587 585
588int tipc_block_bearer(const char *name) 586int tipc_block_bearer(const char *name)
589{ 587{
590 struct bearer *b_ptr = NULL; 588 struct tipc_bearer *b_ptr = NULL;
591 struct link *l_ptr; 589 struct link *l_ptr;
592 struct link *temp_l_ptr; 590 struct link *temp_l_ptr;
593 591
@@ -600,8 +598,8 @@ int tipc_block_bearer(const char *name)
600 } 598 }
601 599
602 info("Blocking bearer <%s>\n", name); 600 info("Blocking bearer <%s>\n", name);
603 spin_lock_bh(&b_ptr->publ.lock); 601 spin_lock_bh(&b_ptr->lock);
604 b_ptr->publ.blocked = 1; 602 b_ptr->blocked = 1;
605 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { 603 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
606 struct tipc_node *n_ptr = l_ptr->owner; 604 struct tipc_node *n_ptr = l_ptr->owner;
607 605
@@ -609,7 +607,7 @@ int tipc_block_bearer(const char *name)
609 tipc_link_reset(l_ptr); 607 tipc_link_reset(l_ptr);
610 spin_unlock_bh(&n_ptr->lock); 608 spin_unlock_bh(&n_ptr->lock);
611 } 609 }
612 spin_unlock_bh(&b_ptr->publ.lock); 610 spin_unlock_bh(&b_ptr->lock);
613 read_unlock_bh(&tipc_net_lock); 611 read_unlock_bh(&tipc_net_lock);
614 return 0; 612 return 0;
615} 613}
@@ -620,27 +618,27 @@ int tipc_block_bearer(const char *name)
620 * Note: This routine assumes caller holds tipc_net_lock. 618 * Note: This routine assumes caller holds tipc_net_lock.
621 */ 619 */
622 620
623static void bearer_disable(struct bearer *b_ptr) 621static void bearer_disable(struct tipc_bearer *b_ptr)
624{ 622{
625 struct link *l_ptr; 623 struct link *l_ptr;
626 struct link *temp_l_ptr; 624 struct link *temp_l_ptr;
627 625
628 info("Disabling bearer <%s>\n", b_ptr->publ.name); 626 info("Disabling bearer <%s>\n", b_ptr->name);
629 tipc_disc_stop_link_req(b_ptr->link_req); 627 tipc_disc_stop_link_req(b_ptr->link_req);
630 spin_lock_bh(&b_ptr->publ.lock); 628 spin_lock_bh(&b_ptr->lock);
631 b_ptr->link_req = NULL; 629 b_ptr->link_req = NULL;
632 b_ptr->publ.blocked = 1; 630 b_ptr->blocked = 1;
633 b_ptr->media->disable_bearer(&b_ptr->publ); 631 b_ptr->media->disable_bearer(b_ptr);
634 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { 632 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
635 tipc_link_delete(l_ptr); 633 tipc_link_delete(l_ptr);
636 } 634 }
637 spin_unlock_bh(&b_ptr->publ.lock); 635 spin_unlock_bh(&b_ptr->lock);
638 memset(b_ptr, 0, sizeof(struct bearer)); 636 memset(b_ptr, 0, sizeof(struct tipc_bearer));
639} 637}
640 638
641int tipc_disable_bearer(const char *name) 639int tipc_disable_bearer(const char *name)
642{ 640{
643 struct bearer *b_ptr; 641 struct tipc_bearer *b_ptr;
644 int res; 642 int res;
645 643
646 write_lock_bh(&tipc_net_lock); 644 write_lock_bh(&tipc_net_lock);
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index 85f451d5aacf..255dea64f7bd 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -2,7 +2,7 @@
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, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005, 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
@@ -61,26 +61,7 @@ struct tipc_media_addr {
61 } dev_addr; 61 } dev_addr;
62}; 62};
63 63
64/** 64struct tipc_bearer;
65 * struct tipc_bearer - TIPC bearer info available to media code
66 * @usr_handle: pointer to additional media-specific information about bearer
67 * @mtu: max packet size bearer can support
68 * @blocked: non-zero if bearer is blocked
69 * @lock: spinlock for controlling access to bearer
70 * @addr: media-specific address associated with bearer
71 * @name: bearer name (format = media:interface)
72 *
73 * Note: TIPC initializes "name" and "lock" fields; media code is responsible
74 * for initialization all other fields when a bearer is enabled.
75 */
76struct tipc_bearer {
77 void *usr_handle;
78 u32 mtu;
79 int blocked;
80 spinlock_t lock;
81 struct tipc_media_addr addr;
82 char name[TIPC_MAX_BEARER_NAME];
83};
84 65
85/** 66/**
86 * struct media - TIPC media information available to internal users 67 * struct media - TIPC media information available to internal users
@@ -115,8 +96,13 @@ struct media {
115}; 96};
116 97
117/** 98/**
118 * struct bearer - TIPC bearer information available to internal users 99 * struct tipc_bearer - TIPC bearer structure
119 * @publ: bearer information available to privileged users 100 * @usr_handle: pointer to additional media-specific information about bearer
101 * @mtu: max packet size bearer can support
102 * @blocked: non-zero if bearer is blocked
103 * @lock: spinlock for controlling access to bearer
104 * @addr: media-specific address associated with bearer
105 * @name: bearer name (format = media:interface)
120 * @media: ptr to media structure associated with bearer 106 * @media: ptr to media structure associated with bearer
121 * @priority: default link priority for bearer 107 * @priority: default link priority for bearer
122 * @detect_scope: network address mask used during automatic link creation 108 * @detect_scope: network address mask used during automatic link creation
@@ -128,10 +114,18 @@ struct media {
128 * @active: non-zero if bearer structure is represents a bearer 114 * @active: non-zero if bearer structure is represents a bearer
129 * @net_plane: network plane ('A' through 'H') currently associated with bearer 115 * @net_plane: network plane ('A' through 'H') currently associated with bearer
130 * @nodes: indicates which nodes in cluster can be reached through bearer 116 * @nodes: indicates which nodes in cluster can be reached through bearer
117 *
118 * Note: media-specific code is responsible for initialization of the fields
119 * indicated below when a bearer is enabled; TIPC's generic bearer code takes
120 * care of initializing all other fields.
131 */ 121 */
132 122struct tipc_bearer {
133struct bearer { 123 void *usr_handle; /* initalized by media */
134 struct tipc_bearer publ; 124 u32 mtu; /* initalized by media */
125 int blocked; /* initalized by media */
126 struct tipc_media_addr addr; /* initalized by media */
127 char name[TIPC_MAX_BEARER_NAME];
128 spinlock_t lock;
135 struct media *media; 129 struct media *media;
136 u32 priority; 130 u32 priority;
137 u32 detect_scope; 131 u32 detect_scope;
@@ -152,7 +146,7 @@ struct bearer_name {
152 146
153struct link; 147struct link;
154 148
155extern struct bearer tipc_bearers[]; 149extern struct tipc_bearer tipc_bearers[];
156 150
157/* 151/*
158 * TIPC routines available to supported media types 152 * TIPC routines available to supported media types
@@ -186,14 +180,14 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a);
186struct sk_buff *tipc_media_get_names(void); 180struct sk_buff *tipc_media_get_names(void);
187 181
188struct sk_buff *tipc_bearer_get_names(void); 182struct sk_buff *tipc_bearer_get_names(void);
189void tipc_bearer_add_dest(struct bearer *b_ptr, u32 dest); 183void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest);
190void tipc_bearer_remove_dest(struct bearer *b_ptr, u32 dest); 184void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest);
191void tipc_bearer_schedule(struct bearer *b_ptr, struct link *l_ptr); 185void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr);
192struct bearer *tipc_bearer_find_interface(const char *if_name); 186struct tipc_bearer *tipc_bearer_find_interface(const char *if_name);
193int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr); 187int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr);
194int tipc_bearer_congested(struct bearer *b_ptr, struct link *l_ptr); 188int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr);
195void tipc_bearer_stop(void); 189void tipc_bearer_stop(void);
196void tipc_bearer_lock_push(struct bearer *b_ptr); 190void tipc_bearer_lock_push(struct tipc_bearer *b_ptr);
197 191
198 192
199/** 193/**
@@ -214,10 +208,11 @@ void tipc_bearer_lock_push(struct bearer *b_ptr);
214 * and let TIPC's link code deal with the undelivered message. 208 * and let TIPC's link code deal with the undelivered message.
215 */ 209 */
216 210
217static inline int tipc_bearer_send(struct bearer *b_ptr, struct sk_buff *buf, 211static inline int tipc_bearer_send(struct tipc_bearer *b_ptr,
212 struct sk_buff *buf,
218 struct tipc_media_addr *dest) 213 struct tipc_media_addr *dest)
219{ 214{
220 return !b_ptr->media->send_msg(buf, &b_ptr->publ, dest); 215 return !b_ptr->media->send_msg(buf, b_ptr, dest);
221} 216}
222 217
223#endif /* _TIPC_BEARER_H */ 218#endif /* _TIPC_BEARER_H */
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index fa026bd91a68..59a86fc5b6d0 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -2,7 +2,7 @@
2 * net/tipc/discover.c 2 * net/tipc/discover.c
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
@@ -57,7 +57,7 @@
57 * @timer_intv: current interval between requests (in ms) 57 * @timer_intv: current interval between requests (in ms)
58 */ 58 */
59struct link_req { 59struct link_req {
60 struct bearer *bearer; 60 struct tipc_bearer *bearer;
61 struct tipc_media_addr dest; 61 struct tipc_media_addr dest;
62 struct sk_buff *buf; 62 struct sk_buff *buf;
63 struct timer_list timer; 63 struct timer_list timer;
@@ -75,7 +75,7 @@ struct link_req {
75static struct sk_buff *tipc_disc_init_msg(u32 type, 75static struct sk_buff *tipc_disc_init_msg(u32 type,
76 u32 req_links, 76 u32 req_links,
77 u32 dest_domain, 77 u32 dest_domain,
78 struct bearer *b_ptr) 78 struct tipc_bearer *b_ptr)
79{ 79{
80 struct sk_buff *buf = tipc_buf_acquire(DSC_H_SIZE); 80 struct sk_buff *buf = tipc_buf_acquire(DSC_H_SIZE);
81 struct tipc_msg *msg; 81 struct tipc_msg *msg;
@@ -87,7 +87,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
87 msg_set_req_links(msg, req_links); 87 msg_set_req_links(msg, req_links);
88 msg_set_dest_domain(msg, dest_domain); 88 msg_set_dest_domain(msg, dest_domain);
89 msg_set_bc_netid(msg, tipc_net_id); 89 msg_set_bc_netid(msg, tipc_net_id);
90 msg_set_media_addr(msg, &b_ptr->publ.addr); 90 msg_set_media_addr(msg, &b_ptr->addr);
91 } 91 }
92 return buf; 92 return buf;
93} 93}
@@ -99,7 +99,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
99 * @media_addr: media address advertised by duplicated node 99 * @media_addr: media address advertised by duplicated node
100 */ 100 */
101 101
102static void disc_dupl_alert(struct bearer *b_ptr, u32 node_addr, 102static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
103 struct tipc_media_addr *media_addr) 103 struct tipc_media_addr *media_addr)
104{ 104{
105 char node_addr_str[16]; 105 char node_addr_str[16];
@@ -111,7 +111,7 @@ static void disc_dupl_alert(struct bearer *b_ptr, u32 node_addr,
111 tipc_media_addr_printf(&pb, media_addr); 111 tipc_media_addr_printf(&pb, media_addr);
112 tipc_printbuf_validate(&pb); 112 tipc_printbuf_validate(&pb);
113 warn("Duplicate %s using %s seen on <%s>\n", 113 warn("Duplicate %s using %s seen on <%s>\n",
114 node_addr_str, media_addr_str, b_ptr->publ.name); 114 node_addr_str, media_addr_str, b_ptr->name);
115} 115}
116 116
117/** 117/**
@@ -120,7 +120,7 @@ static void disc_dupl_alert(struct bearer *b_ptr, u32 node_addr,
120 * @b_ptr: bearer that message arrived on 120 * @b_ptr: bearer that message arrived on
121 */ 121 */
122 122
123void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr) 123void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
124{ 124{
125 struct link *link; 125 struct link *link;
126 struct tipc_media_addr media_addr; 126 struct tipc_media_addr media_addr;
@@ -140,7 +140,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr)
140 if (!tipc_addr_node_valid(orig)) 140 if (!tipc_addr_node_valid(orig))
141 return; 141 return;
142 if (orig == tipc_own_addr) { 142 if (orig == tipc_own_addr) {
143 if (memcmp(&media_addr, &b_ptr->publ.addr, sizeof(media_addr))) 143 if (memcmp(&media_addr, &b_ptr->addr, sizeof(media_addr)))
144 disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr); 144 disc_dupl_alert(b_ptr, tipc_own_addr, &media_addr);
145 return; 145 return;
146 } 146 }
@@ -193,7 +193,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr)
193 return; 193 return;
194 rbuf = tipc_disc_init_msg(DSC_RESP_MSG, 1, orig, b_ptr); 194 rbuf = tipc_disc_init_msg(DSC_RESP_MSG, 1, orig, b_ptr);
195 if (rbuf != NULL) { 195 if (rbuf != NULL) {
196 b_ptr->media->send_msg(rbuf, &b_ptr->publ, &media_addr); 196 b_ptr->media->send_msg(rbuf, b_ptr, &media_addr);
197 buf_discard(rbuf); 197 buf_discard(rbuf);
198 } 198 }
199 } 199 }
@@ -249,9 +249,9 @@ void tipc_disc_update_link_req(struct link_req *req)
249 249
250static void disc_timeout(struct link_req *req) 250static void disc_timeout(struct link_req *req)
251{ 251{
252 spin_lock_bh(&req->bearer->publ.lock); 252 spin_lock_bh(&req->bearer->lock);
253 253
254 req->bearer->media->send_msg(req->buf, &req->bearer->publ, &req->dest); 254 req->bearer->media->send_msg(req->buf, req->bearer, &req->dest);
255 255
256 if ((req->timer_intv == TIPC_LINK_REQ_SLOW) || 256 if ((req->timer_intv == TIPC_LINK_REQ_SLOW) ||
257 (req->timer_intv == TIPC_LINK_REQ_FAST)) { 257 (req->timer_intv == TIPC_LINK_REQ_FAST)) {
@@ -266,7 +266,7 @@ static void disc_timeout(struct link_req *req)
266 } 266 }
267 k_start_timer(&req->timer, req->timer_intv); 267 k_start_timer(&req->timer, req->timer_intv);
268 268
269 spin_unlock_bh(&req->bearer->publ.lock); 269 spin_unlock_bh(&req->bearer->lock);
270} 270}
271 271
272/** 272/**
@@ -279,7 +279,7 @@ static void disc_timeout(struct link_req *req)
279 * Returns pointer to link request structure, or NULL if unable to create. 279 * Returns pointer to link request structure, or NULL if unable to create.
280 */ 280 */
281 281
282struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr, 282struct link_req *tipc_disc_init_link_req(struct tipc_bearer *b_ptr,
283 const struct tipc_media_addr *dest, 283 const struct tipc_media_addr *dest,
284 u32 dest_domain, 284 u32 dest_domain,
285 u32 req_links) 285 u32 req_links)
diff --git a/net/tipc/discover.h b/net/tipc/discover.h
index d2c3cffb79fc..4046d7743f07 100644
--- a/net/tipc/discover.h
+++ b/net/tipc/discover.h
@@ -2,7 +2,7 @@
2 * net/tipc/discover.h 2 * net/tipc/discover.h
3 * 3 *
4 * Copyright (c) 2003-2006, Ericsson AB 4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005, 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
@@ -39,13 +39,13 @@
39 39
40struct link_req; 40struct link_req;
41 41
42struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr, 42struct link_req *tipc_disc_init_link_req(struct tipc_bearer *b_ptr,
43 const struct tipc_media_addr *dest, 43 const struct tipc_media_addr *dest,
44 u32 dest_domain, 44 u32 dest_domain,
45 u32 req_links); 45 u32 req_links);
46void tipc_disc_update_link_req(struct link_req *req); 46void tipc_disc_update_link_req(struct link_req *req);
47void tipc_disc_stop_link_req(struct link_req *req); 47void tipc_disc_stop_link_req(struct link_req *req);
48 48
49void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr); 49void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr);
50 50
51#endif 51#endif
diff --git a/net/tipc/link.c b/net/tipc/link.c
index e30770d007f5..1c5c53a81531 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -113,7 +113,7 @@ static void link_init_max_pkt(struct link *l_ptr)
113{ 113{
114 u32 max_pkt; 114 u32 max_pkt;
115 115
116 max_pkt = (l_ptr->b_ptr->publ.mtu & ~3); 116 max_pkt = (l_ptr->b_ptr->mtu & ~3);
117 if (max_pkt > MAX_MSG_SIZE) 117 if (max_pkt > MAX_MSG_SIZE)
118 max_pkt = MAX_MSG_SIZE; 118 max_pkt = MAX_MSG_SIZE;
119 119
@@ -303,7 +303,7 @@ static void link_set_timer(struct link *l_ptr, u32 time)
303 * Returns pointer to link. 303 * Returns pointer to link.
304 */ 304 */
305 305
306struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, 306struct link *tipc_link_create(struct tipc_bearer *b_ptr, const u32 peer,
307 const struct tipc_media_addr *media_addr) 307 const struct tipc_media_addr *media_addr)
308{ 308{
309 struct link *l_ptr; 309 struct link *l_ptr;
@@ -317,7 +317,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
317 } 317 }
318 318
319 l_ptr->addr = peer; 319 l_ptr->addr = peer;
320 if_name = strchr(b_ptr->publ.name, ':') + 1; 320 if_name = strchr(b_ptr->name, ':') + 1;
321 sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:", 321 sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:",
322 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), 322 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
323 tipc_node(tipc_own_addr), 323 tipc_node(tipc_own_addr),
@@ -1595,11 +1595,10 @@ static int link_recv_buf_validate(struct sk_buff *buf)
1595 * structure (i.e. cannot be NULL), but bearer can be inactive. 1595 * structure (i.e. cannot be NULL), but bearer can be inactive.
1596 */ 1596 */
1597 1597
1598void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) 1598void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1599{ 1599{
1600 read_lock_bh(&tipc_net_lock); 1600 read_lock_bh(&tipc_net_lock);
1601 while (head) { 1601 while (head) {
1602 struct bearer *b_ptr = (struct bearer *)tb_ptr;
1603 struct tipc_node *n_ptr; 1602 struct tipc_node *n_ptr;
1604 struct link *l_ptr; 1603 struct link *l_ptr;
1605 struct sk_buff *crs; 1604 struct sk_buff *crs;
@@ -2658,7 +2657,7 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window)
2658static struct link *link_find_link(const char *name, struct tipc_node **node) 2657static struct link *link_find_link(const char *name, struct tipc_node **node)
2659{ 2658{
2660 struct link_name link_name_parts; 2659 struct link_name link_name_parts;
2661 struct bearer *b_ptr; 2660 struct tipc_bearer *b_ptr;
2662 struct link *l_ptr; 2661 struct link *l_ptr;
2663 2662
2664 if (!link_name_validate(name, &link_name_parts)) 2663 if (!link_name_validate(name, &link_name_parts))
@@ -2961,7 +2960,7 @@ static void link_print(struct link *l_ptr, const char *str)
2961 2960
2962 tipc_printf(buf, str); 2961 tipc_printf(buf, str);
2963 tipc_printf(buf, "Link %x<%s>:", 2962 tipc_printf(buf, "Link %x<%s>:",
2964 l_ptr->addr, l_ptr->b_ptr->publ.name); 2963 l_ptr->addr, l_ptr->b_ptr->name);
2965 2964
2966#ifdef CONFIG_TIPC_DEBUG 2965#ifdef CONFIG_TIPC_DEBUG
2967 if (link_reset_reset(l_ptr) || link_reset_unknown(l_ptr)) 2966 if (link_reset_reset(l_ptr) || link_reset_unknown(l_ptr))
diff --git a/net/tipc/link.h b/net/tipc/link.h
index 85fd3bcb5ed9..bdb0fa263d20 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -122,7 +122,7 @@ struct link {
122 u32 checkpoint; 122 u32 checkpoint;
123 u32 peer_session; 123 u32 peer_session;
124 u32 peer_bearer_id; 124 u32 peer_bearer_id;
125 struct bearer *b_ptr; 125 struct tipc_bearer *b_ptr;
126 u32 tolerance; 126 u32 tolerance;
127 u32 continuity_interval; 127 u32 continuity_interval;
128 u32 abort_limit; 128 u32 abort_limit;
@@ -213,7 +213,7 @@ struct link {
213 213
214struct tipc_port; 214struct tipc_port;
215 215
216struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, 216struct link *tipc_link_create(struct tipc_bearer *b_ptr, const u32 peer,
217 const struct tipc_media_addr *media_addr); 217 const struct tipc_media_addr *media_addr);
218void tipc_link_delete(struct link *l_ptr); 218void tipc_link_delete(struct link *l_ptr);
219void tipc_link_changeover(struct link *l_ptr); 219void tipc_link_changeover(struct link *l_ptr);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 3af53e327f49..e4dba1dfb6ea 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -2,7 +2,7 @@
2 * net/tipc/node.c: TIPC node management routines 2 * net/tipc/node.c: TIPC node management routines
3 * 3 *
4 * Copyright (c) 2000-2006, Ericsson AB 4 * Copyright (c) 2000-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
@@ -238,7 +238,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
238 return n_ptr; 238 return n_ptr;
239 } 239 }
240 err("Attempt to establish second link on <%s> to %s\n", 240 err("Attempt to establish second link on <%s> to %s\n",
241 l_ptr->b_ptr->publ.name, 241 l_ptr->b_ptr->name,
242 tipc_addr_string_fill(addr_string, l_ptr->addr)); 242 tipc_addr_string_fill(addr_string, l_ptr->addr));
243 } 243 }
244 return NULL; 244 return NULL;