aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bearer.c
diff options
context:
space:
mode:
authorAllan Stephens <Allan.Stephens@windriver.com>2011-01-07 13:00:11 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-02-23 18:05:05 -0500
commit2d627b92fd1e39d83c3ee0b9d410403f98cb3981 (patch)
tree38fc08bfe87ed28785c7dd464577e947397dfa7c /net/tipc/bearer.c
parent23dd4cce387124ec3ea06ca30d17854ae4d9b772 (diff)
tipc: Combine bearer structure with tipc_bearer structure
Combines two distinct structures containing information about a TIPC bearer into a single structure. The structures were previously kept separate so that public information about a bearer could be made available to plug-in media types using TIPC's native API, while the remaining information was kept private for use by TIPC itself. However, now that the native API has been removed there is no longer any need for this arrangement. Since one of the structures was already embedded within the other, the change largely involves replacing instances of "publ.foo" with "foo". The changes do not otherwise alter the operation of TIPC bearers. Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r--net/tipc/bearer.c98
1 files changed, 48 insertions, 50 deletions
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);