From: Jon M. <jon...@er...> - 2004-04-21 14:22:15
|
Hi, To avoid code duplication, I suggest that you use the existing msg_print() in msg.c, instead og defining your own dump functions. Her you get almost everything you want already, but you may have to extend the function with a couple of switches. Then you will have a function that will dump the header correctly from anywhere within the code, without having to know the message type in advance. This also makes it possible to use the internal log, which is useful for long-time tests. If you only want to print to the console, and don't want to use my debug macros, just type e.g. msg_print(CONS,msg,"Your text"); otherwise the standard usage is #define DBG_OUTPUT CONS (at the beginning of the file, or just before the function you want to debug) ..... msg_dbg(msg,"Your text"); ..... #define DBG_OUTPUT 0 (if you want to shut off debugging for the rest of the file) Cheers /jon Guo, Min wrote: >the tipc retransmit patch for RM. > >Index: recvbcast.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/recvbcast.c,v >retrieving revision 1.11 >retrieving revision 1.14 >diff -u -r1.11 -r1.14 >--- recvbcast.c 16 Apr 2004 04:03:46 -0000 1.11 >+++ recvbcast.c 21 Apr 2004 02:34:41 -0000 1.14 >@@ -166,7 +179,7 @@ > * Input: ackno: the acked packet seqno > * Return: void > */ >-static void bnode_outqueue_release(int ackno) >+void bnode_outqueue_release(int ackno) > { > struct sk_buff *buf; > >@@ -295,34 +308,30 @@ > exp_seq = owner->last_in_bcast + 1; > defered_size = owner->deferred_inqueue_sz; > gap = owner->gap; >- dbg("-------recv bcast data seqno %d\n",msg_seqno(msg)); >- if(exp_seq != msg_seqno(msg)) { >- dbg("recv bcast data exp_seq is %d\n",exp_seq); >- dbg("recv bcast data seqno %d\n",msg_seqno(msg)); >- buf_safe_discard(buf); >- return; >- } >+ printk("-------recv bcast data seqno %d\n",msg_seqno(msg)); >+ printk("recv bcast data exp_seq is %d\n",exp_seq); >+ printk("recv bcast data seqno %d\n",msg_seqno(msg)); > > if (msg_seqno(msg) == exp_seq) { > spin_lock_bh(&owner->lock); > owner->last_in_bcast = exp_seq; > spin_unlock_bh(&owner->lock); >- exp_seq++; > if(gap != 0) { > recaculate_gap(this); > } > bcast_port_recv(buf); > >- //if (match_address_4(msg, tipc_own_addr)) >- request_retransmit(this, gap); >+ if (match_address_4(msg, tipc_own_addr)) >+ request_retransmit(this, gap); > > } >- /*else if(msg_seqno(msg) < exp_seq) { >+ else if(msg_seqno(msg) < exp_seq) { > dbg("discard duplicate message, seq:%d", >msg_seqno(msg)); > buf_discard(buf); > return; > > }else{ >+ return; > if(bcast_deferred_queue_add(this,buf)) { > recaculate_gap(this); > if(match_address_3(msg, tipc_own_addr) && >defered_size == 1 ) { >@@ -331,7 +340,7 @@ > request_retransmit(this, gap); > } > } >- }*/ >+ } > > } > /** >@@ -344,11 +353,15 @@ > static void recv_bcast_restransmit(struct link* this,struct sk_buff >*buf) > { > struct sk_buff *obuf; >+ struct tipc_msg *msg; > uint pos = INT_H_SIZE; > struct node* owner; >- >+ printk("recv_bcast_retransmit\n"); > owner = this->owner; > obuf = buf_extract(buf, pos); >+ printk("buf_extract"); >+ msg = buf_msg(obuf); >+ printk("the size is %d\n", msg_hdr_sz(msg)); > recv_bcast_data(this, obuf); > buf_safe_discard(buf); > } >@@ -370,7 +383,6 @@ > int ackno = msg_bcast_ack(buf_msg(buf)); > int gap; > dbg("---recv bcast state ack no= %d\n ",ackno); >-// bnode_outqueue_release(ackno); > this->owner->acked_bcast = ackno; > btlink = find_blink(this->bearer); > if (btlink) >@@ -450,7 +462,7 @@ > for (crs = &nodes;*crs;crs = &(*crs)->next) { > if (!in_own_cluster((*crs)->addr)) > continue; >-// dbg("the crs's acked number %d\n",(*crs) ->acked_bcast); >+ > if ( less((*crs) ->acked_bcast, min_acked_bcast)) > min_acked_bcast = (*crs) ->acked_bcast; > >@@ -490,8 +502,6 @@ > recv_bcast_restransmit(this,buf); > break; > case STATE_MSG: >- dbg("BCAST_MSG"); >- tipc_dump_head(msg); > recv_bcast_state(this,buf); > break; > default: >@@ -519,7 +529,7 @@ > if (false == nametbl_self_translate(&mc_head,msg_nametype(msg),\ > msg_namelower(msg),msg_nameupper(msg))) { > buf_safe_discard(buf); >- dbg("get TIPC_ERR_NO_PORT\n"); >+ printk("get TIPC_ERR_NO_PORT\n"); > > return TIPC_ERR_NO_PORT; > } > res = nameseq_deliver(buf,&mc_head); >Index: bcast.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/bcast.c,v >retrieving revision 1.14 >retrieving revision 1.18 >diff -u -r1.14 -r1.18 >--- bcast.c 16 Apr 2004 04:03:46 -0000 1.14 >+++ bcast.c 21 Apr 2004 02:34:41 -0000 1.18 >@@ -136,6 +152,9 @@ > > for (;i<MAX_BEARERS;i++) > linkset[i] = NULL; >+ for(i=0;i<MAX_NODES;i++) >+ retrans_nodes[i] = NULL; >+ > } > > >@@ -310,7 +329,7 @@ > blink->bitmap[i] = 0; > INIT_LIST_HEAD(&blink->list); > blink->mask = >(tipc_addr(tipc_zone(tipc_own_addr),tipc_cluster(tipc_own_addr),0)); >- memset(blink->bitmap, 0, MAX_NODES*sizeof(unsigned long)); >+ memset(blink->bitmap, 0, sizeof(blink->bitmap)); > list_add_tail(&(blink->list),&blink_head); > return blink; > >@@ -366,7 +385,7 @@ > buf_set_next(buf,tbuf); > node->deferred_in = buf; > node->deferred_inqueue_sz++; >- }else if(msg_seqno(buf_msg(tbuf)) == msg_seqno(buf_msg(buf))){ >+ }else if(msg_seqno(buf_msg(pbuf)) == msg_seqno(buf_msg(buf))){ > buf_safe_discard(buf); > return false; > }else{ >@@ -427,8 +446,8 @@ > int i = 0,prev_destnode; > struct mc_identity* mid; > >+ prev_destnode = 0; > list_for_each(pos,mc_head) { >- prev_destnode = 0; > mid = list_entry(pos,struct mc_identity,list); > if (mid != NULL && (prev_destnode != mid->node)){ > prev_destnode = mid->node; >@@ -795,7 +814,6 @@ > void > bcast_recv_timeout() > { >- return; > send_timer_ref = 0; > check_bcast_outqueue(); > timeout_retransmit(); >@@ -832,59 +850,59 @@ > > void datamsghead_dump(struct tipc_msg * p) > { >- dbg("Version:%d\n", msg_version(p)); >- dbg( "User:%d \n", msg_user(p)); >- dbg( "Headsize:%d\n", msg_hdr_sz(p)); >- dbg( "Message Size:%d\n", msg_size(p)); >- dbg( "Link level ack Seq no:%d\n", msg_ack(p)); >- dbg( "broadcast/link level seq no:%d\n", msg_bcast_ack(p)); >- dbg( "Send Seq:%d\n", msg_seqno(p)); >- dbg( "Previsous processor:%d\n", tipc_node(msg_prevnode(p))); >- dbg( "Orignate Port:%X\n", msg_origport(p)); >- dbg( "Desting Port:%X\n", msg_destport(p)); >+ printk("Version:%d\n", msg_version(p)); >+ printk( "User:%d \n", msg_user(p)); >+ printk( "Headsize:%d\n", msg_hdr_sz(p)); >+ printk( "Message Size:%d\n", msg_size(p)); >+ printk( "Link level ack Seq no:%d\n", msg_ack(p)); >+ printk( "broadcast/link level seq no:%d\n", msg_bcast_ack(p)); >+ printk( "Send Seq:%d\n", msg_seqno(p)); >+ printk( "Previsous processor:%d\n", tipc_node(msg_prevnode(p))); >+ printk( "Orignate Port:%X\n", msg_origport(p)); >+ printk( "Desting Port:%X\n", msg_destport(p)); > if (msg_hdr_sz(p) <= 24) > return; >- dbg( "Message Type:%d\n", msg_type(p)); >- dbg( "Error Code:%d\n", msg_errcode(p)); >- dbg( "Reroute Count:%d\n", msg_reroute_cnt(p)); >- dbg( "Orignate Processor:%d\n", tipc_node(msg_orignode(p))); >- dbg( "Destination Processor:%d\n", tipc_node(msg_destnode(p))); >+ printk( "Message Type:%d\n", msg_type(p)); >+ printk( "Error Code:%d\n", msg_errcode(p)); >+ printk( "Reroute Count:%d\n", msg_reroute_cnt(p)); >+ printk( "Orignate Processor:%d\n", tipc_node(msg_orignode(p))); >+ printk( "Destination Processor:%d\n", tipc_node(msg_destnode(p))); > if (msg_hdr_sz(p) <= 32) > return; >- dbg( "Port Name Type:%d\n", msg_nametype(p)); >- dbg( "Port Name Instance:%d\n", msg_namelower(p)); >+ printk( "Port Name Type:%d\n", msg_nametype(p)); >+ printk( "Port Name Instance:%d\n", msg_namelower(p)); > if (msg_hdr_sz(p) <= 40) > return; >- dbg( "Port Name Instance:%d\n", msg_nameupper(p)); >+ printk( "Port Name Instance:%d\n", msg_nameupper(p)); > } > > > void intermsghead_dump(struct tipc_msg* p) > { >- dbg( "Version:%d\n", msg_version(p)); >- dbg( "User:%d \n", msg_user(p)); >- dbg( "Headsize:%d\n", msg_hdr_sz(p)); >- dbg( "Broadcast ack no:%d\n", msg_bcast_ack(p)); >- dbg( "Message Size:%d\n", msg_size(p)); >- dbg( "Link Ack Seq:%d\n", msg_ack(p)); >- dbg( "Send Seq:%d\n", msg_seqno(p)); >- dbg( "Previsous processor:%d\n",tipc_node(msg_prevnode(p))); >- dbg( "importance :%d\n", msg_importance(p)); >- dbg( "Link selector :%d\n", msg_link_selector(p)); >- dbg( "Message Count :%d\n", msg_msgcnt(p)); >- dbg( "Probe:%d\n", msg_probe(p)); >- dbg( "Bearer identity:%d\n", msg_bearer_id(p)); >- dbg( "Link selector :%d\n", msg_link_selector(p)); >+ printk( "Version:%d\n", msg_version(p)); >+ printk( "User:%d \n", msg_user(p)); >+ printk( "Headsize:%d\n", msg_hdr_sz(p)); >+ printk( "Broadcast ack no:%d\n", msg_bcast_ack(p)); >+ printk( "Message Size:%d\n", msg_size(p)); >+ printk( "Link Ack Seq:%d\n", msg_ack(p)); >+ printk( "Send Seq:%d\n", msg_seqno(p)); >+ printk( "Previsous processor:%d\n",tipc_node(msg_prevnode(p))); >+ printk( "importance :%d\n", msg_importance(p)); >+ printk( "Link selector :%d\n", msg_link_selector(p)); >+ printk( "Message Count :%d\n", msg_msgcnt(p)); >+ printk( "Probe:%d\n", msg_probe(p)); >+ printk( "Bearer identity:%d\n", msg_bearer_id(p)); >+ printk( "Link selector :%d\n", msg_link_selector(p)); > if (msg_hdr_sz(p) < 20) > return; >- dbg( "Message Type:%d\n", msg_type(p)); >- dbg( "Sequence Gap:%d\n", msg_seq_gap(p)); >- dbg( "Next Send Packet:%d\n", msg_next_bcast(p)); >- dbg( "Next Send Packet:%d\n", msg_next_sent(p)); >+ printk( "Message Type:%d\n", msg_type(p)); >+ printk( "Sequence Gap:%d\n", msg_seq_gap(p)); >+ printk( "Next Send Packet:%d\n", msg_next_bcast(p)); >+ printk( "Next Send Packet:%d\n", msg_next_sent(p)); > if (msg_hdr_sz(p) <= 32 ) > return; >- dbg( "Orignate Processor:%d\n", tipc_node(msg_orignode(p))); >- dbg( "Destination Processor:%d\n", tipc_node(msg_destnode(p))); >+ printk( "Orignate Processor:%d\n", tipc_node(msg_orignode(p))); >+ printk( "Destination Processor:%d\n", tipc_node(msg_destnode(p))); > > } > void tipc_dump_head(struct tipc_msg *pmsg) >Index: sendbcast.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/sendbcast.c,v >retrieving revision 1.11 >retrieving revision 1.12 >diff -u -r1.11 -r1.12 >--- sendbcast.c 16 Apr 2004 04:03:46 -0000 1.11 >+++ sendbcast.c 20 Apr 2004 06:52:54 -0000 1.12 >@@ -296,15 +299,9 @@ > } > > for (i = 0; i < blinkset->linkcount ; i++) { >-// copybuf = buf_clone(buf); > res = blink_send_buf_fast(buf, >&(blinkset->blink[i]->link)); > >- >-// if (res<0) >-// buf_discard(copybuf); > } >-// buf_discard(buf); >- // res = tipc_bsend_buf_fast(buf, &(blinkset->blink[i]->link)); > return res; > } > >@@ -529,8 +526,8 @@ > if (!in_own_cluster((*crs)->addr)) > continue; > if ( less((*crs) ->acked_bcast,lastseq)){ >- count++; > retrans_nodes[count] = *crs; >+ count++; > } > > } >@@ -555,30 +552,49 @@ > struct tipc_msg *msg = buf_msg(buf); > > printk("==retransmit:%d\n", lastseq); >- return; > firstseq = msg_seqno(msg); > count = retrans_member_count(lastseq); >- if (count == 0) >- return; >- >- if(count > REPLICA_NODES){ >+ >+ if(count > 8){ > for(i = 0; i < MAX_BEARERS; i++) { > if (linkset[i] != NULL) > blinksets = linkset[i]; >- for( j = 0;j < blinksets->linkcount;j++) >- >broadcast_retransmit(&(blinksets->blink[j]->link), buf, lastseq); > > } >+ for( j = 0;j < blinksets->linkcount;j++) >+ >broadcast_retransmit(&(blinksets->blink[j]->link), buf, lastseq); > >+ > } > else { > for (i=0;i<count;i++){ >- pnode = retrans_nodes[i]; >+ pnode = retrans_nodes[i]; >+ if (!likely(pnode) ) >+ { >+ printk("pnode is null\n"); >+ continue; >+ } >+ else >+ printk("pnode is %d\n",pnode->addr); >+ >+ if (!likely(msg)){ >+ printk("bcast_send_retransmits >port=%d\n",msg_origport(msg)); >+ return; >+ } >+ else >+ printk("bcast_send_retransmits >port=%d\n",msg_origport(msg)); >+ read_lock_bh(&net_lock); > this = link_lock_select(pnode->addr, >msg_origport(msg)); >+ if (this) >+ spin_unlock_bh(&this->owner->lock); >+ read_unlock_bh(&net_lock); > if (unlikely(!this)) >+ { >+ printk("no link found\n"); > continue; >+ } > bcast_link_retransmit(this, buf, lastseq); > > } >- } >+ } > > } > >@@ -620,6 +636,50 @@ > this->retransm_queue_head = this->retransm_queue_size = 0; > } > >+void >+blink_tunnel(struct link *this, >+ struct tipc_msg *tunnel_hdr, >+ struct tipc_msg *msg) >+{ >+ struct link *tunnel; >+ struct sk_buff *buf; >+ uint length = msg_size(msg); >+ int res = 0; >+ >+ tunnel = this->owner->active_links[msg_link_selector(msg)]; >+ if (!likely(tunnel)){ >+ printk("the tunnel is null\n"); >+ return; >+ } >+ if (!link_is_up(this)) >+ return; >+ msg_set_size(tunnel_hdr, length + INT_H_SIZE); >+ buf = buf_acquire(length + INT_H_SIZE); >+ msg_set_seqno(tunnel_hdr, mod(tunnel->next_out_no++)); >+ msg_set_ack(tunnel_hdr, mod(tunnel->next_in_no - 1)); >+ msg_set_bcast_ack(tunnel_hdr,tunnel->owner->last_in_bcast); >+ msg_set_user(tunnel_hdr,BCAST_PROTOCOL); >+ buf_copy_append(buf,0, (unchar *) tunnel_hdr, INT_H_SIZE); >+ buf_copy_append(buf,INT_H_SIZE,(unchar*)msg, length); >+ >printk("%c->%c:",this->bearer->net_plane,tunnel->bearer->net_plane); >+ printk("the link name is :%s\n" , tunnel->name); >+ >+ printk( "the queue_size is %d\n", tunnel->out_queue_size); >+ printk("the queue limit is %d\n",tunnel->queue_limit[0]); >+ //assert(tunnel); >+ if (tunnel){ >+ if (bearer_send(tunnel->bearer, buf, >&tunnel->media_addr)) { >+ printk("bearer send\n"); >+ tunnel->stats.retransmitted++; >+ } else { >+ printk("bearer scheule\n"); >+ bearer_schedule(tunnel->bearer, this); >+ return; >+ } >+ } >+ printk("link tunnel--tunnel_hdr\n"); >+} >+ > /** > * Tunel the buffer in the broadcast packet and retransmit it > * Input parameters: this: link >@@ -633,18 +693,21 @@ > > int ackseq; > struct tipc_msg tunnel_hdr; >- >+ struct tipc_msg *msg = buf_msg(buf); >+ > ackseq = this->owner->last_in_bcast; > > msg_init(&tunnel_hdr,BCAST_PROTOCOL, > BCAST_MSG, TIPC_OK,INT_H_SIZE, this->addr); > >+ > spin_lock_bh(&bcast_outqueue.lock); > msg_set_msgcnt(&tunnel_hdr, 1); > for (; less_eq(msg_seqno(buf_msg(buf)), lastseq);buf = >buf->next) { > if(less_eq(msg_seqno(buf_msg(buf)), ackseq)) > continue; >+ blink_tunnel(this,&tunnel_hdr,buf_msg(buf)); > > link_tunnel(this, &tunnel_hdr, buf_msg(buf)); > /* The link may reset here, if extreme overload */ > if(likely(this->owner)) { > > |