Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Wed, 5 Mar 2003 10:37:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Wed, 5 Mar 2003 10:37:46 -0500 Received: from locutus.cmf.nrl.navy.mil ([134.207.10.66]:21909 "EHLO locutus.cmf.nrl.navy.mil") by vger.kernel.org with ESMTP id ; Wed, 5 Mar 2003 10:37:29 -0500 Message-Id: <200303051547.h25FleGi006585@locutus.cmf.nrl.navy.mil> To: "David S. Miller" cc: linux-kernel@vger.kernel.org Subject: [PATCH][ATM] obselete some atm_vcc members X-url: http://www.nrl.navy.mil/CCS/people/chas/index.html X-mailer: nmh 1.0 Date: Wed, 05 Mar 2003 10:47:40 -0500 From: chas williams Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 26015 Lines: 793 it has been suggested that atm_vcc has redundant members with struct sock. this patch removes family, tx_inuse, rx_inuse, and recvq from atm_vcc in favor of sk->family, sk->wmem_alloc, sk->rmem_alloc, and sk->receive_queue (respectively). listenq and backlog_quota should be removed as well but i need to think about them for a bit. also, atm_dev now uses the list manipulation routines (converting the vccs lists is a bit more involved since some the atm drivers know too much) Index: linux/include/linux/atmdev.h =================================================================== RCS file: /home/chas/CVSROOT/linux/include/linux/atmdev.h,v retrieving revision 1.2 diff -u -r1.2 atmdev.h --- linux/include/linux/atmdev.h 20 Feb 2003 20:17:59 -0000 1.2 +++ linux/include/linux/atmdev.h 5 Mar 2003 00:05:46 -0000 @@ -277,7 +277,6 @@ struct atm_vcc { unsigned long flags; /* VCC flags (ATM_VF_*) */ - unsigned char family; /* address family; 0 if unused */ short vpi; /* VPI and VCI (types must be equal */ /* with sockaddr) */ int vci; @@ -286,7 +285,6 @@ struct atm_dev *dev; /* device back pointer */ struct atm_qos qos; /* QOS */ struct atm_sap sap; /* SAP */ - atomic_t tx_inuse,rx_inuse; /* buffer space in use */ void (*push)(struct atm_vcc *vcc,struct sk_buff *skb); void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */ struct sk_buff *(*alloc_tx)(struct atm_vcc *vcc,unsigned int size); @@ -297,7 +295,6 @@ int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); void *dev_data; /* per-device data */ void *proto_data; /* per-protocol data */ - struct sk_buff_head recvq; /* receive queue */ struct k_atm_aal_stats *stats; /* pointer to AAL stats group */ wait_queue_head_t sleep; /* if socket is busy */ struct sock *sk; /* socket backpointer */ @@ -346,7 +343,7 @@ struct proc_dir_entry *proc_entry; /* proc entry */ char *proc_name; /* proc entry name */ #endif - struct atm_dev *prev,*next; /* linkage */ + struct list_head dev_list; /* linkage */ }; @@ -425,19 +422,19 @@ static __inline__ void atm_force_charge(struct atm_vcc *vcc,int truesize) { - atomic_add(truesize+ATM_PDU_OVHD,&vcc->rx_inuse); + atomic_add(truesize+ATM_PDU_OVHD,&vcc->sk->rmem_alloc); } static __inline__ void atm_return(struct atm_vcc *vcc,int truesize) { - atomic_sub(truesize+ATM_PDU_OVHD,&vcc->rx_inuse); + atomic_sub(truesize+ATM_PDU_OVHD,&vcc->sk->rmem_alloc); } static __inline__ int atm_may_send(struct atm_vcc *vcc,unsigned int size) { - return size+atomic_read(&vcc->tx_inuse)+ATM_PDU_OVHD < vcc->sk->sndbuf; + return size+atomic_read(&vcc->sk->wmem_alloc)+ATM_PDU_OVHD < vcc->sk->sndbuf; } Index: linux/net/atm/atm_misc.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/atm_misc.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 atm_misc.c --- linux/net/atm/atm_misc.c 20 Feb 2003 13:46:30 -0000 1.1.1.1 +++ linux/net/atm/atm_misc.c 4 Mar 2003 23:29:50 -0000 @@ -16,7 +16,7 @@ int atm_charge(struct atm_vcc *vcc,int truesize) { atm_force_charge(vcc,truesize); - if (atomic_read(&vcc->rx_inuse) <= vcc->sk->rcvbuf) return 1; + if (atomic_read(&vcc->sk->rmem_alloc) <= vcc->sk->rcvbuf) return 1; atm_return(vcc,truesize); atomic_inc(&vcc->stats->rx_drop); return 0; @@ -29,11 +29,11 @@ int guess = atm_guess_pdu2truesize(pdu_size); atm_force_charge(vcc,guess); - if (atomic_read(&vcc->rx_inuse) <= vcc->sk->rcvbuf) { + if (atomic_read(&vcc->sk->rmem_alloc) <= vcc->sk->rcvbuf) { struct sk_buff *skb = alloc_skb(pdu_size,gfp_flags); if (skb) { - atomic_add(skb->truesize-guess,&vcc->rx_inuse); + atomic_add(skb->truesize-guess,&vcc->sk->rmem_alloc); return skb; } } Index: linux/net/atm/clip.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/clip.c,v retrieving revision 1.3 diff -u -r1.3 clip.c --- linux/net/atm/clip.c 4 Mar 2003 20:48:04 -0000 1.3 +++ linux/net/atm/clip.c 4 Mar 2003 23:45:45 -0000 @@ -63,7 +63,7 @@ ctrl->itf_num = itf; ctrl->ip = ip; atm_force_charge(atmarpd,skb->truesize); - skb_queue_tail(&atmarpd->recvq,skb); + skb_queue_tail(&atmarpd->sk->receive_queue,skb); wake_up(&atmarpd->sleep); return 0; } @@ -426,7 +426,7 @@ memcpy(here,llc_oui,sizeof(llc_oui)); ((u16 *) here)[3] = skb->protocol; } - atomic_add(skb->truesize,&vcc->tx_inuse); + atomic_add(skb->truesize,&vcc->sk->wmem_alloc); ATM_SKB(skb)->iovcnt = 0; ATM_SKB(skb)->atm_options = vcc->atm_options; entry->vccs->last_use = jiffies; @@ -485,7 +485,7 @@ vcc->push = clip_push; vcc->pop = clip_pop; skb_queue_head_init(©); - skb_migrate(&vcc->recvq,©); + skb_migrate(&vcc->sk->receive_queue,©); /* re-process everything received between connection setup and MKIP */ while ((skb = skb_dequeue(©))) if (!clip_devs) { @@ -691,10 +691,10 @@ barrier(); unregister_inetaddr_notifier(&clip_inet_notifier); unregister_netdevice_notifier(&clip_dev_notifier); - if (skb_peek(&vcc->recvq)) + if (skb_peek(&vcc->sk->receive_queue)) printk(KERN_ERR "atmarpd_close: closing with requests " "pending\n"); - skb_queue_purge(&vcc->recvq); + skb_queue_purge(&vcc->sk->receive_queue); DPRINTK("(done)\n"); module_put(THIS_MODULE); } Index: linux/net/atm/common.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/common.c,v retrieving revision 1.6 diff -u -r1.6 common.c --- linux/net/atm/common.c 3 Mar 2003 22:23:13 -0000 1.6 +++ linux/net/atm/common.c 5 Mar 2003 00:15:53 -0000 @@ -91,14 +91,14 @@ { struct sk_buff *skb; - if (atomic_read(&vcc->tx_inuse) && !atm_may_send(vcc,size)) { - DPRINTK("Sorry: tx_inuse = %d, size = %d, sndbuf = %d\n", - atomic_read(&vcc->tx_inuse),size,vcc->sk->sndbuf); + if (atomic_read(&vcc->sk->wmem_alloc) && !atm_may_send(vcc,size)) { + DPRINTK("Sorry: wmem_alloc = %d, size = %d, sndbuf = %d\n", + atomic_read(&vcc->sk->wmem_alloc),size,vcc->sk->sndbuf); return NULL; } while (!(skb = alloc_skb(size,GFP_KERNEL))) schedule(); - DPRINTK("AlTx %d += %d\n",atomic_read(&vcc->tx_inuse),skb->truesize); - atomic_add(skb->truesize+ATM_PDU_OVHD,&vcc->tx_inuse); + DPRINTK("AlTx %d += %d\n",atomic_read(&vcc->sk->wmem_alloc),skb->truesize); + atomic_add(skb->truesize+ATM_PDU_OVHD,&vcc->sk->wmem_alloc); return skb; } @@ -114,21 +114,19 @@ vcc = atm_sk(sk); memset(&vcc->flags,0,sizeof(vcc->flags)); vcc->dev = NULL; - vcc->family = sock->ops->family; vcc->alloc_tx = alloc_tx; vcc->callback = NULL; memset(&vcc->local,0,sizeof(struct sockaddr_atmsvc)); memset(&vcc->remote,0,sizeof(struct sockaddr_atmsvc)); vcc->qos.txtp.max_sdu = 1 << 16; /* for meta VCs */ - atomic_set(&vcc->tx_inuse,0); - atomic_set(&vcc->rx_inuse,0); + atomic_set(&vcc->sk->wmem_alloc,0); + atomic_set(&vcc->sk->rmem_alloc,0); vcc->push = NULL; vcc->pop = NULL; vcc->push_oam = NULL; vcc->vpi = vcc->vci = 0; /* no VCI/VPI yet */ vcc->atm_options = vcc->aal_options = 0; init_waitqueue_head(&vcc->sleep); - skb_queue_head_init(&vcc->recvq); skb_queue_head_init(&vcc->listenq); sk->sleep = &vcc->sleep; sock->sk = sk; @@ -145,7 +143,7 @@ if (vcc->dev) { if (vcc->dev->ops->close) vcc->dev->ops->close(vcc); if (vcc->push) vcc->push(vcc,NULL); /* atmarpd has no push */ - while ((skb = skb_dequeue(&vcc->recvq))) { + while ((skb = skb_dequeue(&vcc->sk->receive_queue))) { atm_return(vcc,skb->truesize); if (vcc->dev->ops->free_rx_skb) vcc->dev->ops->free_rx_skb(vcc,skb); @@ -153,10 +151,10 @@ } down(&atm_dev_sem); fops_put (vcc->dev->ops); - if (atomic_read(&vcc->rx_inuse)) + if (atomic_read(&vcc->sk->rmem_alloc)) printk(KERN_WARNING "atm_release_vcc: strange ... " - "rx_inuse == %d after closing\n", - atomic_read(&vcc->rx_inuse)); + "rmem_alloc == %d after closing\n", + atomic_read(&vcc->sk->rmem_alloc)); bind_vcc(vcc,NULL); } else down(&atm_dev_sem); @@ -311,11 +309,15 @@ if (error) return error; } else { - struct atm_dev *dev; + struct atm_dev *dev = NULL; + struct list_head *p; down(&atm_dev_sem); - for (dev = atm_devs; dev; dev = dev->next) + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); if (!atm_do_connect_dev(vcc,dev,vpi,vci)) break; + dev = NULL; + } up(&atm_dev_sem); if (!dev) return -ENODEV; } @@ -360,7 +362,7 @@ add_wait_queue(&vcc->sleep,&wait); set_current_state(TASK_INTERRUPTIBLE); error = 1; /* <= 0 is error */ - while (!(skb = skb_dequeue(&vcc->recvq))) { + while (!(skb = skb_dequeue(&vcc->sk->receive_queue))) { if (test_bit(ATM_VF_RELEASED,&vcc->flags) || test_bit(ATM_VF_CLOSE,&vcc->flags)) { error = vcc->reply; @@ -391,7 +393,7 @@ if (vcc->dev->ops->feedback) vcc->dev->ops->feedback(vcc,skb,(unsigned long) skb->data, (unsigned long) buff,eff_len); - DPRINTK("RcvM %d -= %d\n",atomic_read(&vcc->rx_inuse),skb->truesize); + DPRINTK("RcvM %d -= %d\n",atomic_read(&vcc->sk->rmem_alloc),skb->truesize); atm_return(vcc,skb->truesize); if (ATM_SKB(skb)->iovcnt) { /* @@@ hack */ /* iovcnt set, use scatter-gather for receive */ @@ -494,14 +496,14 @@ vcc = ATM_SD(sock); poll_wait(file,&vcc->sleep,wait); mask = 0; - if (skb_peek(&vcc->recvq) || skb_peek(&vcc->listenq)) + if (skb_peek(&vcc->sk->receive_queue) || skb_peek(&vcc->listenq)) mask |= POLLIN | POLLRDNORM; if (test_bit(ATM_VF_RELEASED,&vcc->flags) || test_bit(ATM_VF_CLOSE,&vcc->flags)) mask |= POLLHUP; if (sock->state != SS_CONNECTING) { if (vcc->qos.txtp.traffic_class != ATM_NONE && - vcc->qos.txtp.max_sdu+atomic_read(&vcc->tx_inuse)+ + vcc->qos.txtp.max_sdu+atomic_read(&vcc->sk->wmem_alloc)+ ATM_PDU_OVHD <= vcc->sk->sndbuf) mask |= POLLOUT | POLLWRNORM; } @@ -552,6 +554,7 @@ int atm_ioctl(struct socket *sock,unsigned int cmd,unsigned long arg) { struct atm_dev *dev; + struct list_head *p; struct atm_vcc *vcc; int *tmp_buf, *tmp_p; void *buf; @@ -568,7 +571,7 @@ goto done; } ret_val = put_user(vcc->sk->sndbuf- - atomic_read(&vcc->tx_inuse)-ATM_PDU_OVHD, + atomic_read(&vcc->sk->wmem_alloc)-ATM_PDU_OVHD, (int *) arg) ? -EFAULT : 0; goto done; case SIOCINQ: @@ -579,7 +582,7 @@ ret_val = -EINVAL; goto done; } - skb = skb_peek(&vcc->recvq); + skb = skb_peek(&vcc->sk->receive_queue); ret_val = put_user(skb ? skb->len : 0,(int *) arg) ? -EFAULT : 0; goto done; @@ -596,7 +599,7 @@ goto done; } size = 0; - for (dev = atm_devs; dev; dev = dev->next) + list_for_each(p, &atm_devs) size += sizeof(int); if (size > len) { ret_val = -E2BIG; @@ -608,8 +611,10 @@ goto done; } tmp_p = tmp_buf; - for (dev = atm_devs; dev; dev = dev->next) + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); *tmp_p++ = dev->number; + } ret_val = ((copy_to_user(buf, tmp_buf, size)) || put_user(size, &((struct atm_iobuf *) arg)->length) ) ? -EFAULT : 0; @@ -990,7 +995,7 @@ if (!error) error = adjust_tp(&qos->rxtp,qos->aal); if (error) return error; if (!vcc->dev->ops->change_qos) return -EOPNOTSUPP; - if (vcc->family == AF_ATMPVC) + if (vcc->sk->family == AF_ATMPVC) return vcc->dev->ops->change_qos(vcc,qos,ATM_MF_SET); return svc_change_qos(vcc,qos); } Index: linux/net/atm/lec.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/lec.c,v retrieving revision 1.14 diff -u -r1.14 lec.c --- linux/net/atm/lec.c 4 Mar 2003 20:48:28 -0000 1.14 +++ linux/net/atm/lec.c 4 Mar 2003 23:42:21 -0000 @@ -125,7 +125,7 @@ priv = (struct lec_priv *)dev->priv; atm_force_charge(priv->lecd, skb2->truesize); - skb_queue_tail(&priv->lecd->recvq, skb2); + skb_queue_tail(&priv->lecd->sk->receive_queue, skb2); wake_up(&priv->lecd->sleep); } @@ -202,7 +202,7 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv) { if (atm_may_send(vcc, skb->len)) { - atomic_add(skb->truesize, &vcc->tx_inuse); + atomic_add(skb->truesize, &vcc->sk->wmem_alloc); ATM_SKB(skb)->vcc = vcc; ATM_SKB(skb)->iovcnt = 0; ATM_SKB(skb)->atm_options = vcc->atm_options; @@ -399,7 +399,7 @@ int i; char *tmp; /* FIXME */ - atomic_sub(skb->truesize+ATM_PDU_OVHD, &vcc->tx_inuse); + atomic_sub(skb->truesize+ATM_PDU_OVHD, &vcc->sk->wmem_alloc); mesg = (struct atmlec_msg *)skb->data; tmp = skb->data; tmp += sizeof(struct atmlec_msg); @@ -505,7 +505,7 @@ skb2->len = sizeof(struct atmlec_msg); memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); atm_force_charge(priv->lecd, skb2->truesize); - skb_queue_tail(&priv->lecd->recvq, skb2); + skb_queue_tail(&priv->lecd->sk->receive_queue, skb2); wake_up(&priv->lecd->sleep); } if (f != NULL) br_fdb_put_hook(f); @@ -534,10 +534,10 @@ netif_stop_queue(dev); lec_arp_destroy(priv); - if (skb_peek(&vcc->recvq)) + if (skb_peek(&vcc->sk->receive_queue)) printk("%s lec_atm_close: closing with messages pending\n", dev->name); - while ((skb = skb_dequeue(&vcc->recvq))) { + while ((skb = skb_dequeue(&vcc->sk->receive_queue))) { atm_return(vcc, skb->truesize); dev_kfree_skb(skb); } @@ -595,13 +595,13 @@ memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); atm_force_charge(priv->lecd, skb->truesize); - skb_queue_tail(&priv->lecd->recvq, skb); + skb_queue_tail(&priv->lecd->sk->receive_queue, skb); wake_up(&priv->lecd->sleep); if (data != NULL) { DPRINTK("lec: about to send %d bytes of data\n", data->len); atm_force_charge(priv->lecd, data->truesize); - skb_queue_tail(&priv->lecd->recvq, data); + skb_queue_tail(&priv->lecd->sk->receive_queue, data); wake_up(&priv->lecd->sleep); } @@ -683,7 +683,7 @@ #endif /* DUMP_PACKETS > 0 */ if (memcmp(skb->data, lec_ctrl_magic, 4) ==0) { /* Control frame, to daemon*/ DPRINTK("%s: To daemon\n",dev->name); - skb_queue_tail(&vcc->recvq, skb); + skb_queue_tail(&vcc->sk->receive_queue, skb); wake_up(&vcc->sleep); } else { /* Data frame, queue to protocol handlers */ unsigned char *dst; Index: linux/net/atm/mpc.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/mpc.c,v retrieving revision 1.4 diff -u -r1.4 mpc.c --- linux/net/atm/mpc.c 3 Mar 2003 22:23:13 -0000 1.4 +++ linux/net/atm/mpc.c 4 Mar 2003 23:42:27 -0000 @@ -520,7 +520,7 @@ memcpy(skb->data, &llc_snap_mpoa_data, sizeof(struct llc_snap_hdr)); } - atomic_add(skb->truesize, &entry->shortcut->tx_inuse); + atomic_add(skb->truesize, &entry->shortcut->sk->wmem_alloc); ATM_SKB(skb)->iovcnt = 0; /* just to be safe ... */ ATM_SKB(skb)->atm_options = entry->shortcut->atm_options; entry->shortcut->send(entry->shortcut, skb); @@ -665,7 +665,7 @@ skb->dev = dev; if (memcmp(skb->data, &llc_snap_mpoa_ctrl, sizeof(struct llc_snap_hdr)) == 0) { dprintk("mpoa: (%s) mpc_push: control packet arrived\n", dev->name); - skb_queue_tail(&vcc->recvq, skb); /* Pass control packets to daemon */ + skb_queue_tail(&vcc->sk->receive_queue, skb); /* Pass control packets to daemon */ wake_up(&vcc->sleep); return; } @@ -840,7 +840,7 @@ mpc->in_ops->destroy_cache(mpc); mpc->eg_ops->destroy_cache(mpc); - while ( (skb = skb_dequeue(&vcc->recvq)) ){ + while ( (skb = skb_dequeue(&vcc->sk->receive_queue)) ){ atm_return(vcc, skb->truesize); kfree_skb(skb); } @@ -860,7 +860,7 @@ struct mpoa_client *mpc = find_mpc_by_vcc(vcc); struct k_message *mesg = (struct k_message*)skb->data; - atomic_sub(skb->truesize+ATM_PDU_OVHD, &vcc->tx_inuse); + atomic_sub(skb->truesize+ATM_PDU_OVHD, &vcc->sk->wmem_alloc); if (mpc == NULL) { printk("mpoa: msg_from_mpoad: no mpc found\n"); @@ -937,7 +937,7 @@ skb_put(skb, sizeof(struct k_message)); memcpy(skb->data, mesg, sizeof(struct k_message)); atm_force_charge(mpc->mpoad_vcc, skb->truesize); - skb_queue_tail(&mpc->mpoad_vcc->recvq, skb); + skb_queue_tail(&mpc->mpoad_vcc->sk->receive_queue, skb); wake_up(&mpc->mpoad_vcc->sleep); return 0; @@ -1214,7 +1214,7 @@ purge_msg->content.eg_info = entry->ctrl_info; atm_force_charge(vcc, skb->truesize); - skb_queue_tail(&vcc->recvq, skb); + skb_queue_tail(&vcc->sk->receive_queue, skb); wake_up(&vcc->sleep); dprintk("mpoa: purge_egress_shortcut: exiting:\n"); Index: linux/net/atm/proc.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/proc.c,v retrieving revision 1.3 diff -u -r1.3 proc.c --- linux/net/atm/proc.c 3 Mar 2003 22:23:13 -0000 1.3 +++ linux/net/atm/proc.c 5 Mar 2003 00:19:32 -0000 @@ -134,7 +134,7 @@ unsigned char *ip; int svc,off,ip_len; - svc = !clip_vcc || clip_vcc->vcc->family == AF_ATMSVC; + svc = !clip_vcc || clip_vcc->vcc->sk->family == AF_ATMSVC; off = sprintf(buf,"%-6s%-4s%-4s%5ld ",dev->name,svc ? "SVC" : "PVC", !clip_vcc || clip_vcc->encap ? "LLC" : "NULL", (jiffies-(clip_vcc ? clip_vcc->last_use : entry->neigh->used))/ @@ -209,7 +209,7 @@ if (!vcc->dev) here += sprintf(here,"Unassigned "); else here += sprintf(here,"%3d %3d %5d ",vcc->dev->number,vcc->vpi, vcc->vci); - switch (vcc->family) { + switch (vcc->sk->family) { case AF_ATMPVC: here += sprintf(here,"PVC"); break; @@ -217,12 +217,12 @@ here += sprintf(here,"SVC"); break; default: - here += sprintf(here,"%3d",vcc->family); + here += sprintf(here,"%3d",vcc->sk->family); } here += sprintf(here," %04lx %5d %7d/%7d %7d/%7d\n",vcc->flags, vcc->reply, - atomic_read(&vcc->tx_inuse),vcc->sk->sndbuf, - atomic_read(&vcc->rx_inuse),vcc->sk->rcvbuf); + atomic_read(&vcc->sk->wmem_alloc),vcc->sk->sndbuf, + atomic_read(&vcc->sk->rmem_alloc),vcc->sk->rcvbuf); } @@ -302,6 +302,7 @@ static int atm_devices_info(loff_t pos,char *buf) { struct atm_dev *dev; + struct list_head *p; int left; if (!pos) { @@ -309,10 +310,14 @@ "AAL(TX,err,RX,err,drop) ...\n"); } left = pos-1; - for (dev = atm_devs; dev && left; dev = dev->next) left--; - if (!dev) return 0; - dev_info(dev,buf); - return strlen(buf); + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); + if (left-- == 0) { + dev_info(dev,buf); + return strlen(buf); + } + } + return 0; } /* @@ -323,6 +328,7 @@ static int atm_pvc_info(loff_t pos,char *buf) { struct atm_dev *dev; + struct list_head *p; struct atm_vcc *vcc; int left; @@ -331,13 +337,15 @@ "TX(PCR,Class)\n"); } left = pos-1; - for (dev = atm_devs; dev; dev = dev->next) + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); for (vcc = dev->vccs; vcc; vcc = vcc->next) - if (vcc->family == PF_ATMPVC && + if (vcc->sk->family == PF_ATMPVC && vcc->dev && !left--) { pvc_info(vcc,buf); return strlen(buf); } + } return 0; } @@ -345,6 +353,7 @@ static int atm_vc_info(loff_t pos,char *buf) { struct atm_dev *dev; + struct list_head *p; struct atm_vcc *vcc; int left; @@ -353,12 +362,14 @@ "Address"," Itf VPI VCI Fam Flags Reply Send buffer" " Recv buffer\n"); left = pos-1; - for (dev = atm_devs; dev; dev = dev->next) + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); for (vcc = dev->vccs; vcc; vcc = vcc->next) if (!left--) { vc_info(vcc,buf); return strlen(buf); } + } for (vcc = nodev_vccs; vcc; vcc = vcc->next) if (!left--) { vc_info(vcc,buf); @@ -372,20 +383,23 @@ static int atm_svc_info(loff_t pos,char *buf) { struct atm_dev *dev; + struct list_head *p; struct atm_vcc *vcc; int left; if (!pos) return sprintf(buf,"Itf VPI VCI State Remote\n"); left = pos-1; - for (dev = atm_devs; dev; dev = dev->next) + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); for (vcc = dev->vccs; vcc; vcc = vcc->next) - if (vcc->family == PF_ATMSVC && !left--) { + if (vcc->sk->family == PF_ATMSVC && !left--) { svc_info(vcc,buf); return strlen(buf); } + } for (vcc = nodev_vccs; vcc; vcc = vcc->next) - if (vcc->family == PF_ATMSVC && !left--) { + if (vcc->sk->family == PF_ATMSVC && !left--) { svc_info(vcc,buf); return strlen(buf); } Index: linux/net/atm/raw.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/raw.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 raw.c --- linux/net/atm/raw.c 20 Feb 2003 13:46:30 -0000 1.1.1.1 +++ linux/net/atm/raw.c 4 Mar 2003 23:42:30 -0000 @@ -28,7 +28,7 @@ void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb) { if (skb) { - skb_queue_tail(&vcc->recvq,skb); + skb_queue_tail(&vcc->sk->receive_queue,skb); wake_up(&vcc->sleep); } } @@ -36,8 +36,8 @@ static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb) { - DPRINTK("APopR (%d) %d -= %d\n",vcc->vci,vcc->tx_inuse,skb->truesize); - atomic_sub(skb->truesize+ATM_PDU_OVHD,&vcc->tx_inuse); + DPRINTK("APopR (%d) %d -= %d\n",vcc->vci,vcc->sk->wmem_alloc,skb->truesize); + atomic_sub(skb->truesize+ATM_PDU_OVHD,&vcc->sk->wmem_alloc); dev_kfree_skb_any(skb); wake_up(&vcc->sleep); } Index: linux/net/atm/resources.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/resources.c,v retrieving revision 1.2 diff -u -r1.2 resources.c --- linux/net/atm/resources.c 25 Feb 2003 20:03:53 -0000 1.2 +++ linux/net/atm/resources.c 5 Mar 2003 00:10:01 -0000 @@ -26,8 +26,7 @@ #endif -struct atm_dev *atm_devs = NULL; -static struct atm_dev *last_dev = NULL; +LIST_HEAD(atm_devs); struct atm_vcc *nodev_vccs = NULL; extern struct semaphore atm_dev_sem; @@ -43,15 +42,7 @@ dev->type = type; dev->signal = ATM_PHY_SIG_UNKNOWN; dev->link_rate = ATM_OC3_PCR; - dev->next = NULL; - - dev->prev = last_dev; - - if (atm_devs) - last_dev->next = dev; - else - atm_devs = dev; - last_dev = dev; + list_add_tail(&dev->dev_list, &atm_devs); return dev; } @@ -59,14 +50,7 @@ /* Caller must hold atm_dev_sem. */ static void __free_atm_dev(struct atm_dev *dev) { - if (dev->prev) - dev->prev->next = dev->next; - else - atm_devs = dev->next; - if (dev->next) - dev->next->prev = dev->prev; - else - last_dev = dev->prev; + list_del(&dev->dev_list); kfree(dev); } @@ -74,10 +58,13 @@ struct atm_dev *atm_find_dev(int number) { struct atm_dev *dev; + struct list_head *p; - for (dev = atm_devs; dev; dev = dev->next) + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); if (dev->ops && dev->number == number) return dev; + } return NULL; } Index: linux/net/atm/resources.h =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/resources.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 resources.h --- linux/net/atm/resources.h 20 Feb 2003 13:46:30 -0000 1.1.1.1 +++ linux/net/atm/resources.h 5 Mar 2003 00:11:51 -0000 @@ -10,7 +10,7 @@ #include -extern struct atm_dev *atm_devs; +extern struct list_head atm_devs; extern struct atm_vcc *nodev_vccs; /* VCCs not linked to any device */ Index: linux/net/atm/signaling.c =================================================================== RCS file: /home/chas/CVSROOT/linux/net/atm/signaling.c,v retrieving revision 1.2 diff -u -r1.2 signaling.c --- linux/net/atm/signaling.c 25 Feb 2003 20:03:53 -0000 1.2 +++ linux/net/atm/signaling.c 5 Mar 2003 00:21:45 -0000 @@ -61,7 +61,7 @@ } #endif atm_force_charge(sigd,skb->truesize); - skb_queue_tail(&sigd->recvq,skb); + skb_queue_tail(&sigd->sk->receive_queue,skb); wake_up(&sigd->sleep); } @@ -98,7 +98,7 @@ struct atm_vcc *session_vcc; msg = (struct atmsvc_msg *) skb->data; - atomic_sub(skb->truesize+ATM_PDU_OVHD,&vcc->tx_inuse); + atomic_sub(skb->truesize+ATM_PDU_OVHD,&vcc->sk->wmem_alloc); DPRINTK("sigd_send %d (0x%lx)\n",(int) msg->type, (unsigned long) msg->vcc); vcc = *(struct atm_vcc **) &msg->vcc; @@ -198,7 +198,7 @@ static void purge_vccs(struct atm_vcc *vcc) { while (vcc) { - if (vcc->family == PF_ATMSVC && + if (vcc->sk->family == PF_ATMSVC && !test_bit(ATM_VF_META,&vcc->flags)) { set_bit(ATM_VF_RELEASED,&vcc->flags); vcc->reply = -EUNATCH; @@ -212,16 +212,20 @@ static void sigd_close(struct atm_vcc *vcc) { struct atm_dev *dev; + struct list_head *p; DPRINTK("sigd_close\n"); sigd = NULL; - if (skb_peek(&vcc->recvq)) + if (skb_peek(&vcc->sk->receive_queue)) printk(KERN_ERR "sigd_close: closing with requests pending\n"); - skb_queue_purge(&vcc->recvq); + skb_queue_purge(&vcc->sk->receive_queue); purge_vccs(nodev_vccs); down(&atm_dev_sem); - for (dev = atm_devs; dev; dev = dev->next) purge_vccs(dev->vccs); + list_for_each(p, &atm_devs) { + dev = list_entry(p, struct atm_dev, dev_list); + purge_vccs(dev->vccs); + } up(&atm_dev_sem); } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/