From: Jon M. <jon...@er...> - 2004-05-05 22:55:20
|
Hi, It looks ok at a quick glance. You will have to merge with some changes I just made and checked in, but I don't think there will be much overlap. I also worked to get rid of warnings, but mainly it was changes in the structure, like removing the linux-2.X subdirectories and removing placeholder code and #ifdefs. I also made changes in the makefile, so if you want to build as a standalone module you must run "make standalone" from now on. /Jon Mark Haverkamp wrote: >Jon, > >Attached are diffs for more list fixing up. I also got rid of a few >compiler warnings in this. > >Mark. > >cvs diff -u media.h bcast.h link.c sendbcast.c media.c link.h bcast.c manager.c >Index: media.h >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/media.h,v >retrieving revision 1.5 >diff -u -r1.5 media.h >--- media.h 11 Feb 2004 20:12:07 -0000 1.5 >+++ media.h 5 May 2004 22:36:56 -0000 >@@ -90,17 +90,19 @@ > struct bearer { > struct tipc_bearer publ; > struct media *media; >- struct link *cong_links; >+ struct list_head cong_links; > uint max_packet; /* Adjusted */ > uint priority; > uint bcast_interval; > uint identity; >- struct link *links; >+ struct list_head links; > uint continue_count; > int active; > char net_plane; > }; > >+struct link; >+ > uint bearer_get_media(char* raw,uint size); > void bearer_schedule(struct bearer *this, struct link *); > void bearer_stop(void); >@@ -132,7 +134,7 @@ > static inline int > bearer_congested(struct bearer *this, struct link * link) > { >- if (!this->cong_links) >+ if (list_empty(&this->cong_links)) > return 0; > return !bearer_resolve_congestion(this,link); > } >Index: bcast.h >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/bcast.h,v >retrieving revision 1.11 >diff -u -r1.11 bcast.h >--- bcast.h 5 May 2004 15:41:28 -0000 1.11 >+++ bcast.h 5 May 2004 22:36:56 -0000 >@@ -166,12 +166,14 @@ > void tipc_bcast_stop(void); > > void bnode_outqueue_release(int ackno); >+void blink_outqueue_release(struct link *ln, int ackno); > int in_list_node(struct list_head *list, tipc_net_addr_t destnode); > int in_list(struct list_head *list, uint destport, tipc_net_addr_t destnode); > > struct bcastlinkset* blink_select(int selector); > > >+ > extern struct broadcast_outqueue bcast_outqueue; > extern unsigned long int send_timer_ref; > extern struct bcastlinkset *linkset[MAX_BEARERS]; >Index: link.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/link.c,v >retrieving revision 1.20 >diff -u -r1.20 link.c >--- link.c 30 Apr 2004 21:23:17 -0000 1.20 >+++ link.c 5 May 2004 22:36:56 -0000 >@@ -210,7 +210,7 @@ > */ > > static void link_state_event(struct link *this, uint event); >-static void link_dump(struct link *); >+void link_dump(struct link *); > > > /* >@@ -554,17 +554,17 @@ > struct tipc_msg *msg; > this = (struct link*) k_malloc(sizeof(*this)); > memset(this,0,sizeof(*this)); >+ INIT_LIST_HEAD(&this->waiting_ports); >+ INIT_LIST_HEAD(&this->link_list); > this->addr = peer; > this->priority = b->priority; > link_set_queue_limits(this, b->media->window); > this->bearer = b; >- this->next_on_bearer = this->bearer->links; >- this->bearer->links = this; >+ list_add_tail(&this->link_list, &b->links); > this->checkpoint = 1; > this->state = RESET_UNKNOWN; > this->next_out_no = 1; > this->bcastlink = NULL; >- INIT_LIST_HEAD(&this->waiting_ports); > if (LINK_LOG_BUF_SIZE) { > char *buf = k_malloc(LINK_LOG_BUF_SIZE); > printbuf_init(&this->print_buf, buf, LINK_LOG_BUF_SIZE); >@@ -621,6 +621,7 @@ > } > #define DBG_OUTPUT 0 > >+#ifdef INTER_CLUSTER_COMM > static void > link_setup_timer(struct link *this) > { >@@ -634,6 +635,7 @@ > link_delete(this); > /* cfg_init_link_setup(addr); */ > } >+#endif > > void > link_start(struct link *this) >@@ -1126,7 +1128,7 @@ > int res = msg_data_sz(msg); > if (likely(!link_congested(this))) { > if (likely(msg_size(msg) <= link_max_pkt(this))) { >- if (likely(!this->bearer->cong_links)) { >+ if (likely(list_empty(&this->bearer->cong_links))) { > uint ack = mod(this->next_in_no - 1); > uint seqno = mod(this->next_out_no++); > msg_set_word(msg, 2, ((ack << 16) | seqno)); >@@ -1220,7 +1222,8 @@ > if (unlikely(res < 0)) > goto exit; > >- if (link_congested(this) || this->bearer->cong_links){ >+ if (link_congested(this) || >+ !list_empty(&this->bearer->cong_links)) { > res = link_schedule_port(this,sender->publ.ref,res); > goto exit; > } >@@ -2421,7 +2424,7 @@ > } > #define DBG_OUTPUT 0 > >-static void >+void > link_dump(struct link *this) > { > tipc_dump(&this->print_buf,"\n\nDumping link %s:\n",this->name); >Index: sendbcast.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/sendbcast.c,v >retrieving revision 1.13 >diff -u -r1.13 sendbcast.c >--- sendbcast.c 22 Apr 2004 07:06:59 -0000 1.13 >+++ sendbcast.c 5 May 2004 22:36:56 -0000 >@@ -236,7 +236,10 @@ > count = count_mc_member(&mc_head); > > >- #define REPLICA_NODES 0 >+#ifdef REPLICA_NODES >+#undef REPLICA_NODES >+#endif >+#define REPLICA_NODES 0 > if (count <= REPLICA_NODES){ > res = tipc_forward_buf2nameseq(ref,(struct tipc_name_seq*)seq, > b,&orig,res,17,&mc_head); >@@ -485,7 +488,7 @@ > int res = TIPC_OK; > if (likely(!link_congested(this))) { > if (likely(msg_size(msg) <= link_max_pkt(this))) { >- if (likely(!this->bearer->cong_links)) { >+ if (likely(list_empty(&this->bearer->cong_links))) { > msg_set_ack(msg,0); > blink_add_to_outqueue(this, buf); > if (this->first_out) >Index: media.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/media.c,v >retrieving revision 1.12 >diff -u -r1.12 media.c >--- media.c 16 Apr 2004 18:15:04 -0000 1.12 >+++ media.c 5 May 2004 22:36:56 -0000 >@@ -113,13 +113,7 @@ > */ > void bearer_detach_link(struct bearer* this,struct link* l) > { >- struct link **crs = &this->links; >- for (; (*crs); crs = &((*crs)->next)) { >- if ((*crs) == l) { >- *crs = l->next; >- break; >- } >- } >+ list_del_init(&l->link_list); > } > > /* >@@ -133,24 +127,19 @@ > bearer_push(struct bearer *this) > { > uint res = TIPC_OK; >+ struct link *ln, *tln; >+ > if (this->publ.blocked) > return 0; > >- while (this->cong_links && (res != PUSH_FAILED)) { >- struct link *link = this->cong_links; >- res = link_push_packet(this->cong_links); >- if (res == TIPC_OK) { >- this->cong_links = this->cong_links->next; >- continue; >- } else if (res == PUSH_FINISHED) { >- this->cong_links = >- (link != link->next) ? link->next : 0; >- link->next->prev = link->prev; >- link->prev->next = link->next; >- link->next = link->prev = 0; >- } >+ list_for_each_entry_safe(ln, tln, &this->cong_links, link_list) { >+ res = link_push_packet(ln); >+ if (res == PUSH_FAILED) >+ break; >+ if (res == PUSH_FINISHED) >+ list_move_tail(&ln->link_list, &this->links); > } >- return (this->cong_links == 0); >+ return list_empty(&this->cong_links); > } > > static int >@@ -175,7 +164,7 @@ > spin_lock_bh(&this->publ.lock); > this->continue_count++; > assert(this->publ.blocked); >- if (this->cong_links) >+ if (!list_empty(&this->cong_links)) > k_signal((Handler) bearer_lock_push, (void *) this); > this->publ.blocked = 0; > spin_unlock_bh(&this->publ.lock); >@@ -192,22 +181,7 @@ > static void > bearer_schedule_unlocked(struct bearer *this, struct link * link) > { >- if (link->next) >- return; >- assert(link->prev == 0); >- assert(this->cong_links != link); >- if (!this->cong_links) { >- this->cong_links = link; >- link->next = link; >- link->prev = link; >- } else { /* Link in last in list */ >- >- struct link *last = this->cong_links->prev; >- link->next = this->cong_links; >- link->prev = last; >- last->next = link; >- this->cong_links->prev = link; >- } >+ list_move_tail(&link->link_list, &this->cong_links); > } > > /* >@@ -221,8 +195,6 @@ > void > bearer_schedule(struct bearer *this, struct link * link) > { >- if (link->next) >- return; > spin_lock_bh(&this->publ.lock); > bearer_schedule_unlocked(this,link); > spin_unlock_bh(&this->publ.lock); >@@ -238,7 +210,7 @@ > bearer_resolve_congestion(struct bearer *this, struct link * link) > { > int res = 1; >- if (!this->cong_links) >+ if (list_empty(&this->cong_links)) > return 1; > spin_lock_bh(&this->publ.lock); > if (!bearer_push(this)) { >@@ -430,6 +402,8 @@ > this->media = media; > this->net_plane = bearer_id + 'A'; > this->active = 1; >+ INIT_LIST_HEAD(&this->cong_links); >+ INIT_LIST_HEAD(&this->links); > if (media->broadcast) { > cfg_init_link_req(bcast_domain,2,this, > &media->bcast_addr); >@@ -454,6 +428,8 @@ > { > uint i = 0; > struct bearer *this = 0; >+ struct link *ln, *tln; >+ > if (!bearer_name_valid(name)) > return TIPC_FAILURE; > write_lock_bh(&net_lock); >@@ -475,13 +451,11 @@ > write_lock_bh(&net_lock); > spin_lock_bh(&this->publ.lock); > } >- while (this->links) { >- struct link *next = this->links->next; >- struct node *owner = this->links->owner; >+ list_for_each_entry_safe(ln, tln, &this->links, link_list) { >+ struct node *owner = ln->owner; > spin_lock_bh(&owner->lock); >- link_delete(this->links); >+ link_delete(ln); > spin_unlock_bh(&owner->lock); >- this->links = next; > } > spin_unlock_bh(&this->publ.lock); > memset(this, 0, sizeof (struct bearer)); >Index: link.h >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/link.h,v >retrieving revision 1.11 >diff -u -r1.11 link.h >--- link.h 30 Apr 2004 21:23:17 -0000 1.11 >+++ link.h 5 May 2004 22:36:56 -0000 >@@ -117,9 +117,7 @@ > struct tipc_media_addr media_addr; > unsigned long int timer_ref; > struct node *owner; >- struct link *next; >- struct link *prev; >- struct link *next_on_bearer; >+ struct list_head link_list; > struct link *bcastlink; > > /* Management and link supervision data: */ >Index: bcast.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/bcast.c,v >retrieving revision 1.19 >diff -u -r1.19 bcast.c >--- bcast.c 22 Apr 2004 07:06:59 -0000 1.19 >+++ bcast.c 5 May 2004 22:36:57 -0000 >@@ -309,9 +309,7 @@ > > blink = (struct bcastlink*)k_malloc(sizeof(struct bcastlink)); > memcpy(&blink->link,this,sizeof(struct link)); >- blink->link.next = NULL; >- blink->link.prev = NULL; >- blink->link.next_on_bearer = NULL; >+ INIT_LIST_HEAD(&blink->link.link_list); > blink->link.out_queue_size = 0; > blink->link.first_out = NULL; > blink->link.last_out = NULL; >@@ -573,12 +571,11 @@ > > void free_mclist(struct list_head *list_head) > { >- struct list_head *tmp; >+ struct mc_identity *mci, *tmci; > >- while(!list_empty(list_head)) { >- tmp = list_head->next; >- list_del(tmp); >- kfree(list_entry(tmp, struct mc_identity, list)); >+ list_for_each_entry_safe(mci, tmci, list_head, list) { >+ list_del(&mci->list); >+ kfree(mci); > } > > } >Index: manager.c >=================================================================== >RCS file: /cvsroot/tipc/source/unstable/net/tipc/manager.c,v >retrieving revision 1.8 >diff -u -r1.8 manager.c >--- manager.c 16 Apr 2004 18:15:04 -0000 1.8 >+++ manager.c 5 May 2004 22:36:57 -0000 >@@ -110,25 +110,24 @@ > > int mng_enabled = 0; > >-struct subscr_data{ >+struct subscr_data { > void* usr_handle; > uint domain; > tipc_ref_t subscr_ref; > tipc_ref_t port_ref; > struct tipc_subscr sub; >- struct subscr_data* next; >- struct subscr_data* prev; >+ struct list_head subd_list; > }; > >-struct manager{ >+struct manager { > tipc_ref_t user_ref; > tipc_ref_t port_ref; > tipc_ref_t subscr_ref; > tipc_ref_t conn_port_ref; > uint name_subscriptions; >- struct subscr_data* subscribers; >+ struct list_head subscribers; > uint link_subscriptions; >- struct subscr_data* link_subscribers; >+ struct list_head link_subscribers; > }; > > static struct manager mng; >@@ -188,12 +187,7 @@ > tipc_disconnect(sd->port_ref); > tipc_deleteport(sd->port_ref); > tipc_unsubscribe(sd->subscr_ref); >- if (sd->prev) >- sd->prev->next = sd->next; >- else >- mng.subscribers = sd->next; >- if (sd->next) >- sd->next->prev = sd->prev; >+ list_del(&sd->subd_list); > kfree(sd); > mng.name_subscriptions--; > } >@@ -226,12 +220,13 @@ > void > mng_link_event(tipc_net_addr_t addr,char* name, int up) > { >- struct subscr_data* sub = mng.link_subscribers; >+ struct subscr_data* sub; > struct tipc_cmd_result_msg rmsg; > struct tipc_msg_section sct[3]; > struct tipc_link_info* l = &rmsg.result.links[0]; >- if (!sub) >+ if (list_empty(&mng.link_subscribers)) > return; >+ sub = list_entry(&mng.link_subscribers, struct subscr_data, subd_list); > mng_prepare_res_msg(TIPC_LINK_SUBSCRIBE, > sub->usr_handle, > TIPC_OK, >@@ -243,13 +238,12 @@ > l->up = up; > l->dest = htonl(addr); > rmsg.result_len = htonl(sct[1].size + sct[2].size); >- while (sub){ >+ list_for_each_entry(sub, &mng.link_subscribers, subd_list) { > if (in_scope(sub->domain,addr)){ >- memcpy(rmsg.usr_handle,sub->usr_handle, >+ memcpy(rmsg.usr_handle, sub->usr_handle, > sizeof(rmsg.usr_handle)); >- tipc_send(sub->port_ref,3u,sct); >+ tipc_send(sub->port_ref, 3u, sct); > } >- sub = sub->next; > } > } > >@@ -262,12 +256,7 @@ > if (connected) > tipc_disconnect(sub->port_ref); > tipc_deleteport(sub->port_ref); >- if (sub->prev) >- sub->prev->next = sub->next; >- else >- mng.link_subscribers = sub->next; >- if (sub->next) >- sub->next->prev = sub->prev; >+ list_del(&sub->subd_list); > kfree(sub); > mng.link_subscriptions--; > } >@@ -321,6 +310,7 @@ > memcpy(&sub->usr_handle,msg->usr_handle, > sizeof(sub->usr_handle)); > memcpy(&sub->sub,a,sizeof(*a)); >+ INIT_LIST_HEAD(&sub->subd_list); > > /* Create a port for subscription */ > tipc_createport(mng.user_ref, >@@ -353,10 +343,7 @@ > break; > } > >- sub->next = mng.subscribers; >- mng.subscribers = sub; >- if (sub->next) sub->next->prev = sub; >- sub->prev = 0; >+ list_add_tail(&sub->subd_list, &mng.subscribers); > > /* Establish connection */ > tipc_connect2port(sub->port_ref,orig); >@@ -370,6 +357,7 @@ > if (mng.link_subscriptions > 64) > break; > sub = (struct subscr_data*)k_malloc(sizeof(*sub)); >+ INIT_LIST_HEAD(&sub->subd_list); > tipc_createport(mng.user_ref, > (void*)sub, > TIPC_HIGH_IMPORTANCE, >@@ -384,11 +372,7 @@ > memcpy(&sub->usr_handle,msg->usr_handle, > sizeof(sub->usr_handle)); > sub->domain = msg->argv.domain; >- sub->prev = 0; >- sub->next = mng.link_subscribers; >- if (sub->next) >- sub->next->prev = sub; >- mng.link_subscribers = sub; >+ list_add_tail(&sub->subd_list, &mng.link_subscribers); > tipc_connect2port(sub->port_ref,orig); > rmsg.retval = TIPC_OK; > tipc_send(sub->port_ref, 2u, sct); >@@ -540,6 +524,8 @@ > { > struct tipc_name_seq seq; > memset(&mng, 0, sizeof (mng)); >+ INIT_LIST_HEAD(&mng.subscribers); >+ INIT_LIST_HEAD(&mng.link_subscribers); > tipc_attach(&mng.user_ref, 0, 0); > tipc_createport(mng.user_ref, > 0, > > > |