aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bcast.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/bcast.c')
-rw-r--r--net/tipc/bcast.c69
1 files changed, 30 insertions, 39 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 70ab5ef48766..fa68d1e9ff4b 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
@@ -44,13 +44,6 @@
44 44
45#define BCLINK_WIN_DEFAULT 20 /* bcast link window size (default) */ 45#define BCLINK_WIN_DEFAULT 20 /* bcast link window size (default) */
46 46
47/*
48 * Loss rate for incoming broadcast frames; used to test retransmission code.
49 * Set to N to cause every N'th frame to be discarded; 0 => don't discard any.
50 */
51
52#define TIPC_BCAST_LOSS_RATE 0
53
54/** 47/**
55 * struct bcbearer_pair - a pair of bearers used by broadcast link 48 * struct bcbearer_pair - a pair of bearers used by broadcast link
56 * @primary: pointer to primary bearer 49 * @primary: pointer to primary bearer
@@ -61,8 +54,8 @@
61 */ 54 */
62 55
63struct bcbearer_pair { 56struct bcbearer_pair {
64 struct bearer *primary; 57 struct tipc_bearer *primary;
65 struct bearer *secondary; 58 struct tipc_bearer *secondary;
66}; 59};
67 60
68/** 61/**
@@ -81,7 +74,7 @@ struct bcbearer_pair {
81 */ 74 */
82 75
83struct bcbearer { 76struct bcbearer {
84 struct bearer bearer; 77 struct tipc_bearer bearer;
85 struct media media; 78 struct media media;
86 struct bcbearer_pair bpairs[MAX_BEARERS]; 79 struct bcbearer_pair bpairs[MAX_BEARERS];
87 struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1]; 80 struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1];
@@ -93,6 +86,7 @@ struct bcbearer {
93 * struct bclink - link used for broadcast messages 86 * struct bclink - link used for broadcast messages
94 * @link: (non-standard) broadcast link structure 87 * @link: (non-standard) broadcast link structure
95 * @node: (non-standard) node structure representing b'cast link's peer node 88 * @node: (non-standard) node structure representing b'cast link's peer node
89 * @retransmit_to: node that most recently requested a retransmit
96 * 90 *
97 * Handles sequence numbering, fragmentation, bundling, etc. 91 * Handles sequence numbering, fragmentation, bundling, etc.
98 */ 92 */
@@ -100,6 +94,7 @@ struct bcbearer {
100struct bclink { 94struct bclink {
101 struct link link; 95 struct link link;
102 struct tipc_node node; 96 struct tipc_node node;
97 struct tipc_node *retransmit_to;
103}; 98};
104 99
105 100
@@ -184,6 +179,17 @@ static int bclink_ack_allowed(u32 n)
184 179
185 180
186/** 181/**
182 * tipc_bclink_retransmit_to - get most recent node to request retransmission
183 *
184 * Called with bc_lock locked
185 */
186
187struct tipc_node *tipc_bclink_retransmit_to(void)
188{
189 return bclink->retransmit_to;
190}
191
192/**
187 * bclink_retransmit_pkt - retransmit broadcast packets 193 * bclink_retransmit_pkt - retransmit broadcast packets
188 * @after: sequence number of last packet to *not* retransmit 194 * @after: sequence number of last packet to *not* retransmit
189 * @to: sequence number of last packet to retransmit 195 * @to: sequence number of last packet to retransmit
@@ -285,6 +291,7 @@ static void bclink_send_nack(struct tipc_node *n_ptr)
285 msg = buf_msg(buf); 291 msg = buf_msg(buf);
286 tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, 292 tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG,
287 INT_H_SIZE, n_ptr->addr); 293 INT_H_SIZE, n_ptr->addr);
294 msg_set_non_seq(msg, 1);
288 msg_set_mc_netid(msg, tipc_net_id); 295 msg_set_mc_netid(msg, tipc_net_id);
289 msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); 296 msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in));
290 msg_set_bcgap_after(msg, n_ptr->bclink.gap_after); 297 msg_set_bcgap_after(msg, n_ptr->bclink.gap_after);
@@ -400,13 +407,9 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
400 spin_lock_bh(&bc_lock); 407 spin_lock_bh(&bc_lock);
401 408
402 res = tipc_link_send_buf(bcl, buf); 409 res = tipc_link_send_buf(bcl, buf);
403 if (unlikely(res == -ELINKCONG)) 410 if (likely(res > 0))
404 buf_discard(buf);
405 else
406 bclink_set_last_sent(); 411 bclink_set_last_sent();
407 412
408 if (bcl->out_queue_size > bcl->stats.max_queue_sz)
409 bcl->stats.max_queue_sz = bcl->out_queue_size;
410 bcl->stats.queue_sz_counts++; 413 bcl->stats.queue_sz_counts++;
411 bcl->stats.accu_queue_sz += bcl->out_queue_size; 414 bcl->stats.accu_queue_sz += bcl->out_queue_size;
412 415
@@ -422,9 +425,6 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
422 425
423void tipc_bclink_recv_pkt(struct sk_buff *buf) 426void tipc_bclink_recv_pkt(struct sk_buff *buf)
424{ 427{
425#if (TIPC_BCAST_LOSS_RATE)
426 static int rx_count;
427#endif
428 struct tipc_msg *msg = buf_msg(buf); 428 struct tipc_msg *msg = buf_msg(buf);
429 struct tipc_node *node = tipc_node_find(msg_prevnode(msg)); 429 struct tipc_node *node = tipc_node_find(msg_prevnode(msg));
430 u32 next_in; 430 u32 next_in;
@@ -444,10 +444,9 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
444 tipc_node_unlock(node); 444 tipc_node_unlock(node);
445 spin_lock_bh(&bc_lock); 445 spin_lock_bh(&bc_lock);
446 bcl->stats.recv_nacks++; 446 bcl->stats.recv_nacks++;
447 bcl->owner->next = node; /* remember requestor */ 447 bclink->retransmit_to = node;
448 bclink_retransmit_pkt(msg_bcgap_after(msg), 448 bclink_retransmit_pkt(msg_bcgap_after(msg),
449 msg_bcgap_to(msg)); 449 msg_bcgap_to(msg));
450 bcl->owner->next = NULL;
451 spin_unlock_bh(&bc_lock); 450 spin_unlock_bh(&bc_lock);
452 } else { 451 } else {
453 tipc_bclink_peek_nack(msg_destnode(msg), 452 tipc_bclink_peek_nack(msg_destnode(msg),
@@ -459,14 +458,6 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
459 return; 458 return;
460 } 459 }
461 460
462#if (TIPC_BCAST_LOSS_RATE)
463 if (++rx_count == TIPC_BCAST_LOSS_RATE) {
464 rx_count = 0;
465 buf_discard(buf);
466 return;
467 }
468#endif
469
470 tipc_node_lock(node); 461 tipc_node_lock(node);
471receive: 462receive:
472 deferred = node->bclink.deferred_head; 463 deferred = node->bclink.deferred_head;
@@ -574,8 +565,8 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
574 bcbearer->remains = tipc_bcast_nmap; 565 bcbearer->remains = tipc_bcast_nmap;
575 566
576 for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) { 567 for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) {
577 struct bearer *p = bcbearer->bpairs[bp_index].primary; 568 struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;
578 struct bearer *s = bcbearer->bpairs[bp_index].secondary; 569 struct tipc_bearer *s = bcbearer->bpairs[bp_index].secondary;
579 570
580 if (!p) 571 if (!p)
581 break; /* no more bearers to try */ 572 break; /* no more bearers to try */
@@ -584,11 +575,11 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
584 if (bcbearer->remains_new.count == bcbearer->remains.count) 575 if (bcbearer->remains_new.count == bcbearer->remains.count)
585 continue; /* bearer pair doesn't add anything */ 576 continue; /* bearer pair doesn't add anything */
586 577
587 if (p->publ.blocked || 578 if (p->blocked ||
588 p->media->send_msg(buf, &p->publ, &p->media->bcast_addr)) { 579 p->media->send_msg(buf, p, &p->media->bcast_addr)) {
589 /* unable to send on primary bearer */ 580 /* unable to send on primary bearer */
590 if (!s || s->publ.blocked || 581 if (!s || s->blocked ||
591 s->media->send_msg(buf, &s->publ, 582 s->media->send_msg(buf, s,
592 &s->media->bcast_addr)) { 583 &s->media->bcast_addr)) {
593 /* unable to send on either bearer */ 584 /* unable to send on either bearer */
594 continue; 585 continue;
@@ -633,7 +624,7 @@ void tipc_bcbearer_sort(void)
633 memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp)); 624 memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp));
634 625
635 for (b_index = 0; b_index < MAX_BEARERS; b_index++) { 626 for (b_index = 0; b_index < MAX_BEARERS; b_index++) {
636 struct bearer *b = &tipc_bearers[b_index]; 627 struct tipc_bearer *b = &tipc_bearers[b_index];
637 628
638 if (!b->active || !b->nodes.count) 629 if (!b->active || !b->nodes.count)
639 continue; 630 continue;
@@ -682,12 +673,12 @@ void tipc_bcbearer_sort(void)
682 673
683void tipc_bcbearer_push(void) 674void tipc_bcbearer_push(void)
684{ 675{
685 struct bearer *b_ptr; 676 struct tipc_bearer *b_ptr;
686 677
687 spin_lock_bh(&bc_lock); 678 spin_lock_bh(&bc_lock);
688 b_ptr = &bcbearer->bearer; 679 b_ptr = &bcbearer->bearer;
689 if (b_ptr->publ.blocked) { 680 if (b_ptr->blocked) {
690 b_ptr->publ.blocked = 0; 681 b_ptr->blocked = 0;
691 tipc_bearer_lock_push(b_ptr); 682 tipc_bearer_lock_push(b_ptr);
692 } 683 }
693 spin_unlock_bh(&bc_lock); 684 spin_unlock_bh(&bc_lock);