Commit c70df568 authored by David S. Miller's avatar David S. Miller

[ATM]: Revert vcc global list changes, broke the build.

parent b9bf3d83
...@@ -153,9 +153,9 @@ static void atmtcp_v_close(struct atm_vcc *vcc) ...@@ -153,9 +153,9 @@ static void atmtcp_v_close(struct atm_vcc *vcc)
static int atmtcp_v_ioctl(struct atm_dev *dev,unsigned int cmd,void *arg) static int atmtcp_v_ioctl(struct atm_dev *dev,unsigned int cmd,void *arg)
{ {
unsigned long flags;
struct atm_cirange ci; struct atm_cirange ci;
struct atm_vcc *vcc; struct atm_vcc *vcc;
struct sock *s;
if (cmd != ATM_SETCIRANGE) return -ENOIOCTLCMD; if (cmd != ATM_SETCIRANGE) return -ENOIOCTLCMD;
if (copy_from_user(&ci,(void *) arg,sizeof(ci))) return -EFAULT; if (copy_from_user(&ci,(void *) arg,sizeof(ci))) return -EFAULT;
...@@ -163,18 +163,14 @@ static int atmtcp_v_ioctl(struct atm_dev *dev,unsigned int cmd,void *arg) ...@@ -163,18 +163,14 @@ static int atmtcp_v_ioctl(struct atm_dev *dev,unsigned int cmd,void *arg)
if (ci.vci_bits == ATM_CI_MAX) ci.vci_bits = MAX_VCI_BITS; if (ci.vci_bits == ATM_CI_MAX) ci.vci_bits = MAX_VCI_BITS;
if (ci.vpi_bits > MAX_VPI_BITS || ci.vpi_bits < 0 || if (ci.vpi_bits > MAX_VPI_BITS || ci.vpi_bits < 0 ||
ci.vci_bits > MAX_VCI_BITS || ci.vci_bits < 0) return -EINVAL; ci.vci_bits > MAX_VCI_BITS || ci.vci_bits < 0) return -EINVAL;
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&dev->lock, flags);
for (s = vcc_sklist; s; s = s->sk_next) { for (vcc = dev->vccs; vcc; vcc = vcc->next)
vcc = atm_sk(s);
if (vcc->dev != dev)
continue;
if ((vcc->vpi >> ci.vpi_bits) || if ((vcc->vpi >> ci.vpi_bits) ||
(vcc->vci >> ci.vci_bits)) { (vcc->vci >> ci.vci_bits)) {
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&dev->lock, flags);
return -EBUSY; return -EBUSY;
} }
} spin_unlock_irqrestore(&dev->lock, flags);
read_unlock(&vcc_sklist_lock);
dev->ci_range = ci; dev->ci_range = ci;
return 0; return 0;
} }
...@@ -237,9 +233,9 @@ static int atmtcp_v_proc(struct atm_dev *dev,loff_t *pos,char *page) ...@@ -237,9 +233,9 @@ static int atmtcp_v_proc(struct atm_dev *dev,loff_t *pos,char *page)
static void atmtcp_c_close(struct atm_vcc *vcc) static void atmtcp_c_close(struct atm_vcc *vcc)
{ {
unsigned long flags;
struct atm_dev *atmtcp_dev; struct atm_dev *atmtcp_dev;
struct atmtcp_dev_data *dev_data; struct atmtcp_dev_data *dev_data;
struct sock *s;
struct atm_vcc *walk; struct atm_vcc *walk;
atmtcp_dev = (struct atm_dev *) vcc->dev_data; atmtcp_dev = (struct atm_dev *) vcc->dev_data;
...@@ -250,23 +246,19 @@ static void atmtcp_c_close(struct atm_vcc *vcc) ...@@ -250,23 +246,19 @@ static void atmtcp_c_close(struct atm_vcc *vcc)
kfree(dev_data); kfree(dev_data);
shutdown_atm_dev(atmtcp_dev); shutdown_atm_dev(atmtcp_dev);
vcc->dev_data = NULL; vcc->dev_data = NULL;
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&atmtcp_dev->lock, flags);
for (s = vcc_sklist; s; s = s->sk_next) { for (walk = atmtcp_dev->vccs; walk; walk = walk->next)
walk = atm_sk(s);
if (walk->dev != atmtcp_dev)
continue;
wake_up(&walk->sleep); wake_up(&walk->sleep);
} spin_unlock_irqrestore(&atmtcp_dev->lock, flags);
read_unlock(&vcc_sklist_lock);
} }
static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb) static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
{ {
unsigned long flags;
struct atm_dev *dev; struct atm_dev *dev;
struct atmtcp_hdr *hdr; struct atmtcp_hdr *hdr;
struct sock *s; struct atm_vcc *out_vcc;
struct atm_vcc *out_vcc = NULL;
struct sk_buff *new_skb; struct sk_buff *new_skb;
int result = 0; int result = 0;
...@@ -278,17 +270,13 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb) ...@@ -278,17 +270,13 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
(struct atmtcp_control *) skb->data); (struct atmtcp_control *) skb->data);
goto done; goto done;
} }
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&dev->lock, flags);
for (s = vcc_sklist; s; s = s->sk_next) { for (out_vcc = dev->vccs; out_vcc; out_vcc = out_vcc->next)
out_vcc = atm_sk(s);
if (out_vcc->dev != dev)
continue;
if (out_vcc->vpi == ntohs(hdr->vpi) && if (out_vcc->vpi == ntohs(hdr->vpi) &&
out_vcc->vci == ntohs(hdr->vci) && out_vcc->vci == ntohs(hdr->vci) &&
out_vcc->qos.rxtp.traffic_class != ATM_NONE) out_vcc->qos.rxtp.traffic_class != ATM_NONE)
break; break;
} spin_unlock_irqrestore(&dev->lock, flags);
read_unlock(&vcc_sklist_lock);
if (!out_vcc) { if (!out_vcc) {
atomic_inc(&vcc->stats->tx_err); atomic_inc(&vcc->stats->tx_err);
goto done; goto done;
...@@ -378,7 +366,7 @@ int atmtcp_attach(struct atm_vcc *vcc,int itf) ...@@ -378,7 +366,7 @@ int atmtcp_attach(struct atm_vcc *vcc,int itf)
if (itf != -1) dev = atm_dev_lookup(itf); if (itf != -1) dev = atm_dev_lookup(itf);
if (dev) { if (dev) {
if (dev->ops != &atmtcp_v_dev_ops) { if (dev->ops != &atmtcp_v_dev_ops) {
atm_dev_put(dev); atm_dev_release(dev);
return -EMEDIUMTYPE; return -EMEDIUMTYPE;
} }
if (PRIV(dev)->vcc) return -EBUSY; if (PRIV(dev)->vcc) return -EBUSY;
...@@ -390,8 +378,7 @@ int atmtcp_attach(struct atm_vcc *vcc,int itf) ...@@ -390,8 +378,7 @@ int atmtcp_attach(struct atm_vcc *vcc,int itf)
if (error) return error; if (error) return error;
} }
PRIV(dev)->vcc = vcc; PRIV(dev)->vcc = vcc;
vcc->dev = &atmtcp_control_dev; bind_vcc(vcc,&atmtcp_control_dev);
vcc_insert_socket(vcc->sk);
set_bit(ATM_VF_META,&vcc->flags); set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags); set_bit(ATM_VF_READY,&vcc->flags);
vcc->dev_data = dev; vcc->dev_data = dev;
...@@ -415,7 +402,7 @@ int atmtcp_remove_persistent(int itf) ...@@ -415,7 +402,7 @@ int atmtcp_remove_persistent(int itf)
dev = atm_dev_lookup(itf); dev = atm_dev_lookup(itf);
if (!dev) return -ENODEV; if (!dev) return -ENODEV;
if (dev->ops != &atmtcp_v_dev_ops) { if (dev->ops != &atmtcp_v_dev_ops) {
atm_dev_put(dev); atm_dev_release(dev);
return -EMEDIUMTYPE; return -EMEDIUMTYPE;
} }
dev_data = PRIV(dev); dev_data = PRIV(dev);
...@@ -423,7 +410,7 @@ int atmtcp_remove_persistent(int itf) ...@@ -423,7 +410,7 @@ int atmtcp_remove_persistent(int itf)
dev_data->persist = 0; dev_data->persist = 0;
if (PRIV(dev)->vcc) return 0; if (PRIV(dev)->vcc) return 0;
kfree(dev_data); kfree(dev_data);
atm_dev_put(dev); atm_dev_release(dev);
shutdown_atm_dev(dev); shutdown_atm_dev(dev);
return 0; return 0;
} }
......
...@@ -1887,10 +1887,10 @@ static void eni_close(struct atm_vcc *vcc) ...@@ -1887,10 +1887,10 @@ static void eni_close(struct atm_vcc *vcc)
static int get_ci(struct atm_vcc *vcc,short *vpi,int *vci) static int get_ci(struct atm_vcc *vcc,short *vpi,int *vci)
{ {
struct sock *s; unsigned long flags;
struct atm_vcc *walk; struct atm_vcc *walk;
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&vcc->dev->lock, flags);
if (*vpi == ATM_VPI_ANY) *vpi = 0; if (*vpi == ATM_VPI_ANY) *vpi = 0;
if (*vci == ATM_VCI_ANY) { if (*vci == ATM_VCI_ANY) {
for (*vci = ATM_NOT_RSV_VCI; *vci < NR_VCI; (*vci)++) { for (*vci = ATM_NOT_RSV_VCI; *vci < NR_VCI; (*vci)++) {
...@@ -1898,47 +1898,40 @@ static int get_ci(struct atm_vcc *vcc,short *vpi,int *vci) ...@@ -1898,47 +1898,40 @@ static int get_ci(struct atm_vcc *vcc,short *vpi,int *vci)
ENI_DEV(vcc->dev)->rx_map[*vci]) ENI_DEV(vcc->dev)->rx_map[*vci])
continue; continue;
if (vcc->qos.txtp.traffic_class != ATM_NONE) { if (vcc->qos.txtp.traffic_class != ATM_NONE) {
for (s = vcc_sklist; s; s = s->sk_next) { for (walk = vcc->dev->vccs; walk;
walk = atm_sk(s); walk = walk->next)
if (walk->dev != vcc->dev)
continue;
if (test_bit(ATM_VF_ADDR,&walk->flags) if (test_bit(ATM_VF_ADDR,&walk->flags)
&& walk->vci == *vci && && walk->vci == *vci &&
walk->qos.txtp.traffic_class != walk->qos.txtp.traffic_class !=
ATM_NONE) ATM_NONE)
break; break;
} if (walk) continue;
if (s) continue;
} }
break; break;
} }
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return *vci == NR_VCI ? -EADDRINUSE : 0; return *vci == NR_VCI ? -EADDRINUSE : 0;
} }
if (*vci == ATM_VCI_UNSPEC) { if (*vci == ATM_VCI_UNSPEC) {
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return 0; return 0;
} }
if (vcc->qos.rxtp.traffic_class != ATM_NONE && if (vcc->qos.rxtp.traffic_class != ATM_NONE &&
ENI_DEV(vcc->dev)->rx_map[*vci]) { ENI_DEV(vcc->dev)->rx_map[*vci]) {
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return -EADDRINUSE; return -EADDRINUSE;
} }
if (vcc->qos.txtp.traffic_class == ATM_NONE) { if (vcc->qos.txtp.traffic_class == ATM_NONE) {
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return 0; return 0;
} }
for (s = vcc_sklist; s; s = s->sk_next) { for (walk = vcc->dev->vccs; walk; walk = walk->next)
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vci == *vci && if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vci == *vci &&
walk->qos.txtp.traffic_class != ATM_NONE) { walk->qos.txtp.traffic_class != ATM_NONE) {
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return -EADDRINUSE; return -EADDRINUSE;
} }
} spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return 0; return 0;
} }
...@@ -2146,7 +2139,7 @@ static unsigned char eni_phy_get(struct atm_dev *dev,unsigned long addr) ...@@ -2146,7 +2139,7 @@ static unsigned char eni_phy_get(struct atm_dev *dev,unsigned long addr)
static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page) static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page)
{ {
struct sock *s; unsigned long flags;
static const char *signal[] = { "LOST","unknown","okay" }; static const char *signal[] = { "LOST","unknown","okay" };
struct eni_dev *eni_dev = ENI_DEV(dev); struct eni_dev *eni_dev = ENI_DEV(dev);
struct atm_vcc *vcc; struct atm_vcc *vcc;
...@@ -2219,15 +2212,11 @@ static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page) ...@@ -2219,15 +2212,11 @@ static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page)
return sprintf(page,"%10sbacklog %u packets\n","", return sprintf(page,"%10sbacklog %u packets\n","",
skb_queue_len(&tx->backlog)); skb_queue_len(&tx->backlog));
} }
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&dev->lock, flags);
for (s = vcc_sklist; s; s = s->sk_next) { for (vcc = dev->vccs; vcc; vcc = vcc->next) {
struct eni_vcc *eni_vcc; struct eni_vcc *eni_vcc = ENI_VCC(vcc);
int length; int length;
vcc = atm_sk(s);
if (vcc->dev != dev)
continue;
eni_vcc = ENI_VCC(vcc);
if (--left) continue; if (--left) continue;
length = sprintf(page,"vcc %4d: ",vcc->vci); length = sprintf(page,"vcc %4d: ",vcc->vci);
if (eni_vcc->rx) { if (eni_vcc->rx) {
...@@ -2242,10 +2231,10 @@ static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page) ...@@ -2242,10 +2231,10 @@ static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page)
length += sprintf(page+length,"tx[%d], txing %d bytes", length += sprintf(page+length,"tx[%d], txing %d bytes",
eni_vcc->tx->index,eni_vcc->txing); eni_vcc->tx->index,eni_vcc->txing);
page[length] = '\n'; page[length] = '\n';
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&dev->lock, flags);
return length+1; return length+1;
} }
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&dev->lock, flags);
for (i = 0; i < eni_dev->free_len; i++) { for (i = 0; i < eni_dev->free_len; i++) {
struct eni_free *fe = eni_dev->free_list+i; struct eni_free *fe = eni_dev->free_list+i;
unsigned long offset; unsigned long offset;
......
...@@ -1069,22 +1069,18 @@ fore200e_supply(struct fore200e* fore200e) ...@@ -1069,22 +1069,18 @@ fore200e_supply(struct fore200e* fore200e)
static struct atm_vcc* static struct atm_vcc*
fore200e_find_vcc(struct fore200e* fore200e, struct rpd* rpd) fore200e_find_vcc(struct fore200e* fore200e, struct rpd* rpd)
{ {
struct sock *s; unsigned long flags;
struct atm_vcc* vcc; struct atm_vcc* vcc;
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&fore200e->atm_dev->lock, flags);
for(s = vcc_sklist; s; s = s->sk_next) { for (vcc = fore200e->atm_dev->vccs; vcc; vcc = vcc->next) {
vcc = atm_sk(s);
if (vcc->dev != fore200e->atm_dev)
continue;
if (vcc->vpi == rpd->atm_header.vpi && vcc->vci == rpd->atm_header.vci) {
read_unlock(&vcc_sklist_lock);
return vcc;
}
}
read_unlock(&vcc_sklist_lock);
return NULL; if (vcc->vpi == rpd->atm_header.vpi && vcc->vci == rpd->atm_header.vci)
break;
}
spin_unlock_irqrestore(&fore200e->atm_dev->lock, flags);
return vcc;
} }
...@@ -1354,23 +1350,20 @@ fore200e_activate_vcin(struct fore200e* fore200e, int activate, struct atm_vcc* ...@@ -1354,23 +1350,20 @@ fore200e_activate_vcin(struct fore200e* fore200e, int activate, struct atm_vcc*
static int static int
fore200e_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci) fore200e_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci)
{ {
unsigned long flags;
struct atm_vcc* walk; struct atm_vcc* walk;
struct sock *s;
/* find a free VPI */ /* find a free VPI */
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&vcc->dev->lock, flags);
if (*vpi == ATM_VPI_ANY) { if (*vpi == ATM_VPI_ANY) {
for (*vpi = 0, s = vcc_sklist; s; s = s->sk_next) { for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vci == *vci) && (walk->vpi == *vpi)) { if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
(*vpi)++; (*vpi)++;
s = vcc_sklist; walk = vcc->dev->vccs;
} }
} }
} }
...@@ -1378,19 +1371,16 @@ fore200e_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci) ...@@ -1378,19 +1371,16 @@ fore200e_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci)
/* find a free VCI */ /* find a free VCI */
if (*vci == ATM_VCI_ANY) { if (*vci == ATM_VCI_ANY) {
for (*vci = ATM_NOT_RSV_VCI, s = vcc_sklist; s; s = s->sk_next) { for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk; walk = walk->next) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vpi = *vpi) && (walk->vci == *vci)) { if ((walk->vpi = *vpi) && (walk->vci == *vci)) {
*vci = walk->vci + 1; *vci = walk->vci + 1;
s = vcc_sklist; walk = vcc->dev->vccs;
} }
} }
} }
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return 0; return 0;
} }
...@@ -2652,7 +2642,7 @@ fore200e_module_cleanup(void) ...@@ -2652,7 +2642,7 @@ fore200e_module_cleanup(void)
static int static int
fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page) fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page)
{ {
struct sock *s; unsigned long flags;
struct fore200e* fore200e = FORE200E_DEV(dev); struct fore200e* fore200e = FORE200E_DEV(dev);
int len, left = *pos; int len, left = *pos;
...@@ -2899,12 +2889,8 @@ fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page) ...@@ -2899,12 +2889,8 @@ fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page)
len = sprintf(page,"\n" len = sprintf(page,"\n"
" VCCs:\n address\tVPI.VCI:AAL\t(min/max tx PDU size) (min/max rx PDU size)\n"); " VCCs:\n address\tVPI.VCI:AAL\t(min/max tx PDU size) (min/max rx PDU size)\n");
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&fore200e->atm_dev->lock, flags);
for (s = vcc_sklist; s; s = s->sk_next) { for (vcc = fore200e->atm_dev->vccs; vcc; vcc = vcc->next) {
vcc = atm_sk(s);
if (vcc->dev != fore200e->atm_dev)
continue;
fore200e_vcc = FORE200E_VCC(vcc); fore200e_vcc = FORE200E_VCC(vcc);
...@@ -2918,7 +2904,7 @@ fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page) ...@@ -2918,7 +2904,7 @@ fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page)
fore200e_vcc->rx_max_pdu fore200e_vcc->rx_max_pdu
); );
} }
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&fore200e->atm_dev->lock, flags);
return len; return len;
} }
......
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
#include <linux/sonet.h> #include <linux/sonet.h>
#define USE_TASKLET #define USE_TASKLET
#define USE_HE_FIND_VCC
#undef USE_SCATTERGATHER #undef USE_SCATTERGATHER
#undef USE_CHECKSUM_HW /* still confused about this */ #undef USE_CHECKSUM_HW /* still confused about this */
#define USE_RBPS #define USE_RBPS
...@@ -327,24 +328,25 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags) ...@@ -327,24 +328,25 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 7) he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 7)
static __inline__ struct atm_vcc* static __inline__ struct atm_vcc*
__find_vcc(struct he_dev *he_dev, unsigned cid) he_find_vcc(struct he_dev *he_dev, unsigned cid)
{ {
unsigned long flags;
struct atm_vcc *vcc; struct atm_vcc *vcc;
struct sock *s;
short vpi; short vpi;
int vci; int vci;
vpi = cid >> he_dev->vcibits; vpi = cid >> he_dev->vcibits;
vci = cid & ((1 << he_dev->vcibits) - 1); vci = cid & ((1 << he_dev->vcibits) - 1);
for (s = vcc_sklist; s; s = s->sk_next) { spin_lock_irqsave(&he_dev->atm_dev->lock, flags);
vcc = atm_sk(s); for (vcc = he_dev->atm_dev->vccs; vcc; vcc = vcc->next)
if (vcc->dev == he_dev->atm_dev && if (vcc->vci == vci && vcc->vpi == vpi
vcc->vci == vci && vcc->vpi == vpi && && vcc->qos.rxtp.traffic_class != ATM_NONE) {
vcc->qos.rxtp.traffic_class != ATM_NONE) { spin_unlock_irqrestore(&he_dev->atm_dev->lock, flags);
return vcc; return vcc;
} }
}
spin_unlock_irqrestore(&he_dev->atm_dev->lock, flags);
return NULL; return NULL;
} }
...@@ -1564,6 +1566,17 @@ he_start(struct atm_dev *dev) ...@@ -1564,6 +1566,17 @@ he_start(struct atm_dev *dev)
reg |= RX_ENABLE; reg |= RX_ENABLE;
he_writel(he_dev, reg, RC_CONFIG); he_writel(he_dev, reg, RC_CONFIG);
#ifndef USE_HE_FIND_VCC
he_dev->he_vcc_table = kmalloc(sizeof(struct he_vcc_table) *
(1 << (he_dev->vcibits + he_dev->vpibits)), GFP_KERNEL);
if (he_dev->he_vcc_table == NULL) {
hprintk("failed to alloc he_vcc_table\n");
return -ENOMEM;
}
memset(he_dev->he_vcc_table, 0, sizeof(struct he_vcc_table) *
(1 << (he_dev->vcibits + he_dev->vpibits)));
#endif
for (i = 0; i < HE_NUM_CS_STPER; ++i) { for (i = 0; i < HE_NUM_CS_STPER; ++i) {
he_dev->cs_stper[i].inuse = 0; he_dev->cs_stper[i].inuse = 0;
he_dev->cs_stper[i].pcr = -1; he_dev->cs_stper[i].pcr = -1;
...@@ -1699,6 +1712,11 @@ he_stop(struct he_dev *he_dev) ...@@ -1699,6 +1712,11 @@ he_stop(struct he_dev *he_dev)
he_dev->tpd_base, he_dev->tpd_base_phys); he_dev->tpd_base, he_dev->tpd_base_phys);
#endif #endif
#ifndef USE_HE_FIND_VCC
if (he_dev->he_vcc_table)
kfree(he_dev->he_vcc_table);
#endif
if (he_dev->pci_dev) { if (he_dev->pci_dev) {
pci_read_config_word(he_dev->pci_dev, PCI_COMMAND, &command); pci_read_config_word(he_dev->pci_dev, PCI_COMMAND, &command);
command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
...@@ -1780,7 +1798,6 @@ he_service_rbrq(struct he_dev *he_dev, int group) ...@@ -1780,7 +1798,6 @@ he_service_rbrq(struct he_dev *he_dev, int group)
int pdus_assembled = 0; int pdus_assembled = 0;
int updated = 0; int updated = 0;
read_lock(&vcc_sklist_lock);
while (he_dev->rbrq_head != rbrq_tail) { while (he_dev->rbrq_head != rbrq_tail) {
++updated; ++updated;
...@@ -1806,10 +1823,13 @@ he_service_rbrq(struct he_dev *he_dev, int group) ...@@ -1806,10 +1823,13 @@ he_service_rbrq(struct he_dev *he_dev, int group)
buf_len = RBRQ_BUFLEN(he_dev->rbrq_head) * 4; buf_len = RBRQ_BUFLEN(he_dev->rbrq_head) * 4;
cid = RBRQ_CID(he_dev->rbrq_head); cid = RBRQ_CID(he_dev->rbrq_head);
#ifdef USE_HE_FIND_VCC
if (cid != lastcid) if (cid != lastcid)
vcc = __find_vcc(he_dev, cid); vcc = he_find_vcc(he_dev, cid);
lastcid = cid; lastcid = cid;
#else
vcc = HE_LOOKUP_VCC(he_dev, cid);
#endif
if (vcc == NULL) { if (vcc == NULL) {
hprintk("vcc == NULL (cid 0x%x)\n", cid); hprintk("vcc == NULL (cid 0x%x)\n", cid);
if (!RBRQ_HBUF_ERR(he_dev->rbrq_head)) if (!RBRQ_HBUF_ERR(he_dev->rbrq_head))
...@@ -1946,7 +1966,6 @@ he_service_rbrq(struct he_dev *he_dev, int group) ...@@ -1946,7 +1966,6 @@ he_service_rbrq(struct he_dev *he_dev, int group)
RBRQ_MASK(++he_dev->rbrq_head)); RBRQ_MASK(++he_dev->rbrq_head));
} }
read_unlock(&vcc_sklist_lock);
if (updated) { if (updated) {
if (updated > he_dev->rbrq_peak) if (updated > he_dev->rbrq_peak)
...@@ -2546,6 +2565,10 @@ he_open(struct atm_vcc *vcc, short vpi, int vci) ...@@ -2546,6 +2565,10 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
#endif #endif
spin_unlock_irqrestore(&he_dev->global_lock, flags); spin_unlock_irqrestore(&he_dev->global_lock, flags);
#ifndef USE_HE_FIND_VCC
HE_LOOKUP_VCC(he_dev, cid) = vcc;
#endif
} }
open_failed: open_failed:
...@@ -2611,6 +2634,9 @@ he_close(struct atm_vcc *vcc) ...@@ -2611,6 +2634,9 @@ he_close(struct atm_vcc *vcc)
if (timeout == 0) if (timeout == 0)
hprintk("close rx timeout cid 0x%x\n", cid); hprintk("close rx timeout cid 0x%x\n", cid);
#ifndef USE_HE_FIND_VCC
HE_LOOKUP_VCC(he_dev, cid) = NULL;
#endif
HPRINTK("close rx cid 0x%x complete\n", cid); HPRINTK("close rx cid 0x%x complete\n", cid);
} }
......
...@@ -2403,43 +2403,37 @@ idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc, ...@@ -2403,43 +2403,37 @@ idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc,
static int static int
idt77252_find_vcc(struct atm_vcc *vcc, short *vpi, int *vci) idt77252_find_vcc(struct atm_vcc *vcc, short *vpi, int *vci)
{ {
struct sock *s; unsigned long flags;
struct atm_vcc *walk; struct atm_vcc *walk;
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&vcc->dev->lock, flags);
if (*vpi == ATM_VPI_ANY) { if (*vpi == ATM_VPI_ANY) {
*vpi = 0; *vpi = 0;
s = vcc_sklist; walk = vcc->dev->vccs;
while (s) { while (walk) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vci == *vci) && (walk->vpi == *vpi)) { if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
(*vpi)++; (*vpi)++;
s = vcc_sklist; walk = vcc->dev->vccs;
continue; continue;
} }
s = s->sk_next; walk = walk->next;
} }
} }
if (*vci == ATM_VCI_ANY) { if (*vci == ATM_VCI_ANY) {
*vci = ATM_NOT_RSV_VCI; *vci = ATM_NOT_RSV_VCI;
s = vcc_sklist; walk = vcc->dev->vccs;
while (s) { while (walk) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vci == *vci) && (walk->vpi == *vpi)) { if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
(*vci)++; (*vci)++;
s = vcc_sklist; walk = vcc->dev->vccs;
continue; continue;
} }
s = s->sk_next; walk = walk->next;
} }
} }
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return 0; return 0;
} }
......
...@@ -293,6 +293,7 @@ struct atm_vcc { ...@@ -293,6 +293,7 @@ struct atm_vcc {
struct k_atm_aal_stats *stats; /* pointer to AAL stats group */ struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
wait_queue_head_t sleep; /* if socket is busy */ wait_queue_head_t sleep; /* if socket is busy */
struct sock *sk; /* socket backpointer */ struct sock *sk; /* socket backpointer */
struct atm_vcc *prev,*next;
/* SVC part --- may move later ------------------------------------- */ /* SVC part --- may move later ------------------------------------- */
short itf; /* interface number */ short itf; /* interface number */
struct sockaddr_atmsvc local; struct sockaddr_atmsvc local;
...@@ -319,6 +320,8 @@ struct atm_dev { ...@@ -319,6 +320,8 @@ struct atm_dev {
/* (NULL) */ /* (NULL) */
const char *type; /* device type name */ const char *type; /* device type name */
int number; /* device index */ int number; /* device index */
struct atm_vcc *vccs; /* VCC table (or NULL) */
struct atm_vcc *last; /* last VCC (or undefined) */
void *dev_data; /* per-device data */ void *dev_data; /* per-device data */
void *phy_data; /* private PHY date */ void *phy_data; /* private PHY date */
unsigned long flags; /* device flags (ATM_DF_*) */ unsigned long flags; /* device flags (ATM_DF_*) */
...@@ -387,9 +390,6 @@ struct atm_skb_data { ...@@ -387,9 +390,6 @@ struct atm_skb_data {
unsigned long atm_options; /* ATM layer options */ unsigned long atm_options; /* ATM layer options */
}; };
extern struct sock *vcc_sklist;
extern rwlock_t vcc_sklist_lock;
#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb)) #define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb))
struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops, struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
...@@ -397,8 +397,7 @@ struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops, ...@@ -397,8 +397,7 @@ struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
struct atm_dev *atm_dev_lookup(int number); struct atm_dev *atm_dev_lookup(int number);
void atm_dev_deregister(struct atm_dev *dev); void atm_dev_deregister(struct atm_dev *dev);
void shutdown_atm_dev(struct atm_dev *dev); void shutdown_atm_dev(struct atm_dev *dev);
void vcc_insert_socket(struct sock *sk); void bind_vcc(struct atm_vcc *vcc,struct atm_dev *dev);
void vcc_remove_socket(struct sock *sk);
/* /*
...@@ -437,7 +436,7 @@ static inline void atm_dev_hold(struct atm_dev *dev) ...@@ -437,7 +436,7 @@ static inline void atm_dev_hold(struct atm_dev *dev)
} }
static inline void atm_dev_put(struct atm_dev *dev) static inline void atm_dev_release(struct atm_dev *dev)
{ {
atomic_dec(&dev->refcnt); atomic_dec(&dev->refcnt);
......
...@@ -47,20 +47,15 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, ...@@ -47,20 +47,15 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
static int check_ci(struct atm_vcc *vcc,short vpi,int vci) static int check_ci(struct atm_vcc *vcc,short vpi,int vci)
{ {
struct sock *s;
struct atm_vcc *walk; struct atm_vcc *walk;
for (s = vcc_sklist; s; s = s->sk_next) { for (walk = vcc->dev->vccs; walk; walk = walk->next)
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vpi == vpi && if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vpi == vpi &&
walk->vci == vci && ((walk->qos.txtp.traffic_class != walk->vci == vci && ((walk->qos.txtp.traffic_class !=
ATM_NONE && vcc->qos.txtp.traffic_class != ATM_NONE) || ATM_NONE && vcc->qos.txtp.traffic_class != ATM_NONE) ||
(walk->qos.rxtp.traffic_class != ATM_NONE && (walk->qos.rxtp.traffic_class != ATM_NONE &&
vcc->qos.rxtp.traffic_class != ATM_NONE))) vcc->qos.rxtp.traffic_class != ATM_NONE)))
return -EADDRINUSE; return -EADDRINUSE;
}
/* allow VCCs with same VPI/VCI iff they don't collide on /* allow VCCs with same VPI/VCI iff they don't collide on
TX/RX (but we may refuse such sharing for other reasons, TX/RX (but we may refuse such sharing for other reasons,
e.g. if protocol requires to have both channels) */ e.g. if protocol requires to have both channels) */
...@@ -70,16 +65,17 @@ static int check_ci(struct atm_vcc *vcc,short vpi,int vci) ...@@ -70,16 +65,17 @@ static int check_ci(struct atm_vcc *vcc,short vpi,int vci)
int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci) int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci)
{ {
unsigned long flags;
static short p = 0; /* poor man's per-device cache */ static short p = 0; /* poor man's per-device cache */
static int c = 0; static int c = 0;
short old_p; short old_p;
int old_c; int old_c;
int err; int err;
read_lock(&vcc_sklist_lock); spin_lock_irqsave(&vcc->dev->lock, flags);
if (*vpi != ATM_VPI_ANY && *vci != ATM_VCI_ANY) { if (*vpi != ATM_VPI_ANY && *vci != ATM_VCI_ANY) {
err = check_ci(vcc,*vpi,*vci); err = check_ci(vcc,*vpi,*vci);
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return err; return err;
} }
/* last scan may have left values out of bounds for current device */ /* last scan may have left values out of bounds for current device */
...@@ -94,7 +90,7 @@ int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci) ...@@ -94,7 +90,7 @@ int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci)
if (!check_ci(vcc,p,c)) { if (!check_ci(vcc,p,c)) {
*vpi = p; *vpi = p;
*vci = c; *vci = c;
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return 0; return 0;
} }
if (*vci == ATM_VCI_ANY) { if (*vci == ATM_VCI_ANY) {
...@@ -109,7 +105,7 @@ int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci) ...@@ -109,7 +105,7 @@ int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci)
} }
} }
while (old_p != p || old_c != c); while (old_p != p || old_c != c);
read_unlock(&vcc_sklist_lock); spin_unlock_irqrestore(&vcc->dev->lock, flags);
return -EADDRINUSE; return -EADDRINUSE;
} }
......
...@@ -737,8 +737,7 @@ static int atm_init_atmarp(struct atm_vcc *vcc) ...@@ -737,8 +737,7 @@ static int atm_init_atmarp(struct atm_vcc *vcc)
set_bit(ATM_VF_META,&vcc->flags); set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags); set_bit(ATM_VF_READY,&vcc->flags);
/* allow replies and avoid getting closed if signaling dies */ /* allow replies and avoid getting closed if signaling dies */
vcc->dev = &atmarpd_dev; bind_vcc(vcc,&atmarpd_dev);
vcc_insert_socket(vcc->sk);
vcc->push = NULL; vcc->push = NULL;
vcc->pop = NULL; /* crash */ vcc->pop = NULL; /* crash */
vcc->push_oam = NULL; /* crash */ vcc->push_oam = NULL; /* crash */
......
...@@ -157,38 +157,6 @@ EXPORT_SYMBOL(br2684_ioctl_hook); ...@@ -157,38 +157,6 @@ EXPORT_SYMBOL(br2684_ioctl_hook);
#endif #endif
struct sock *vcc_sklist;
rwlock_t vcc_sklist_lock = RW_LOCK_UNLOCKED;
void __vcc_insert_socket(struct sock *sk)
{
sk->sk_next = vcc_sklist;
if (sk->sk_next)
vcc_sklist->sk_pprev = &sk->sk_next;
vcc_sklist = sk;
sk->sk_pprev = &vcc_sklist;
}
void vcc_insert_socket(struct sock *sk)
{
write_lock_irq(&vcc_sklist_lock);
__vcc_insert_socket(sk);
write_unlock_irq(&vcc_sklist_lock);
}
void vcc_remove_socket(struct sock *sk)
{
write_lock_irq(&vcc_sklist_lock);
if (sk->sk_pprev) {
if (sk->sk_next)
sk->sk_next->sk_pprev = sk->sk_pprev;
*sk->sk_pprev = sk->sk_next;
sk->sk_pprev = NULL;
}
write_unlock_irq(&vcc_sklist_lock);
}
static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size) static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -207,45 +175,16 @@ static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size) ...@@ -207,45 +175,16 @@ static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size)
} }
EXPORT_SYMBOL(vcc_sklist); int atm_create(struct socket *sock,int protocol,int family)
EXPORT_SYMBOL(vcc_sklist_lock);
EXPORT_SYMBOL(vcc_insert_socket);
EXPORT_SYMBOL(vcc_remove_socket);
static void vcc_sock_destruct(struct sock *sk)
{
struct atm_vcc *vcc = atm_sk(sk);
if (atomic_read(&vcc->sk->sk_rmem_alloc))
printk(KERN_DEBUG "vcc_sock_destruct: rmem leakage (%d bytes) detected.\n", atomic_read(&sk->sk_rmem_alloc));
if (atomic_read(&vcc->sk->sk_wmem_alloc))
printk(KERN_DEBUG "vcc_sock_destruct: wmem leakage (%d bytes) detected.\n", atomic_read(&sk->sk_wmem_alloc));
kfree(sk->sk_protinfo);
}
int vcc_create(struct socket *sock, int protocol, int family)
{ {
struct sock *sk; struct sock *sk;
struct atm_vcc *vcc; struct atm_vcc *vcc;
sock->sk = NULL; sock->sk = NULL;
if (sock->type == SOCK_STREAM) if (sock->type == SOCK_STREAM) return -EINVAL;
return -EINVAL; if (!(sk = alloc_atm_vcc_sk(family))) return -ENOMEM;
sk = sk_alloc(family, GFP_KERNEL, 1, NULL); vcc = atm_sk(sk);
if (!sk) memset(&vcc->flags,0,sizeof(vcc->flags));
return -ENOMEM;
sock_init_data(NULL, sk);
vcc = atm_sk(sk) = kmalloc(sizeof(*vcc), GFP_KERNEL);
if (!vcc) {
sk_free(sk);
return -ENOMEM;
}
memset(vcc, 0, sizeof(*vcc));
vcc->sk = sk;
vcc->dev = NULL; vcc->dev = NULL;
vcc->callback = NULL; vcc->callback = NULL;
memset(&vcc->local,0,sizeof(struct sockaddr_atmsvc)); memset(&vcc->local,0,sizeof(struct sockaddr_atmsvc));
...@@ -260,49 +199,42 @@ int vcc_create(struct socket *sock, int protocol, int family) ...@@ -260,49 +199,42 @@ int vcc_create(struct socket *sock, int protocol, int family)
vcc->atm_options = vcc->aal_options = 0; vcc->atm_options = vcc->aal_options = 0;
init_waitqueue_head(&vcc->sleep); init_waitqueue_head(&vcc->sleep);
sk->sk_sleep = &vcc->sleep; sk->sk_sleep = &vcc->sleep;
sk->sk_destruct = vcc_sock_destruct;
sock->sk = sk; sock->sk = sk;
return 0; return 0;
} }
static void vcc_destroy_socket(struct sock *sk) void atm_release_vcc_sk(struct sock *sk,int free_sk)
{ {
struct atm_vcc *vcc = atm_sk(sk); struct atm_vcc *vcc = atm_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
clear_bit(ATM_VF_READY, &vcc->flags); clear_bit(ATM_VF_READY,&vcc->flags);
if (vcc->dev) { if (vcc->dev) {
if (vcc->dev->ops->close) if (vcc->dev->ops->close) vcc->dev->ops->close(vcc);
vcc->dev->ops->close(vcc); if (vcc->push) vcc->push(vcc,NULL); /* atmarpd has no push */
if (vcc->push)
vcc->push(vcc, NULL); /* atmarpd has no push */
vcc_remove_socket(sk); /* no more receive */
while ((skb = skb_dequeue(&vcc->sk->sk_receive_queue))) { while ((skb = skb_dequeue(&vcc->sk->sk_receive_queue))) {
atm_return(vcc,skb->truesize); atm_return(vcc,skb->truesize);
kfree_skb(skb); kfree_skb(skb);
} }
module_put(vcc->dev->ops->owner); module_put(vcc->dev->ops->owner);
atm_dev_put(vcc->dev); atm_dev_release(vcc->dev);
if (atomic_read(&vcc->sk->sk_rmem_alloc))
printk(KERN_WARNING "atm_release_vcc: strange ... "
"rmem_alloc == %d after closing\n",
atomic_read(&vcc->sk->sk_rmem_alloc));
bind_vcc(vcc,NULL);
} }
if (free_sk) free_atm_vcc_sk(sk);
} }
int vcc_release(struct socket *sock) int atm_release(struct socket *sock)
{ {
struct sock *sk = sock->sk; if (sock->sk)
atm_release_vcc_sk(sock->sk,1);
if (sk) {
sock_orphan(sk);
lock_sock(sk);
vcc_destroy_socket(sock->sk);
release_sock(sk);
sock_put(sk);
}
return 0; return 0;
} }
...@@ -357,8 +289,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi, ...@@ -357,8 +289,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi,
if (vci > 0 && vci < ATM_NOT_RSV_VCI && !capable(CAP_NET_BIND_SERVICE)) if (vci > 0 && vci < ATM_NOT_RSV_VCI && !capable(CAP_NET_BIND_SERVICE))
return -EPERM; return -EPERM;
error = 0; error = 0;
vcc->dev = dev; bind_vcc(vcc,dev);
vcc_insert_socket(vcc->sk);
switch (vcc->qos.aal) { switch (vcc->qos.aal) {
case ATM_AAL0: case ATM_AAL0:
error = atm_init_aal0(vcc); error = atm_init_aal0(vcc);
...@@ -382,7 +313,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi, ...@@ -382,7 +313,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi,
if (!error) error = adjust_tp(&vcc->qos.txtp,vcc->qos.aal); if (!error) error = adjust_tp(&vcc->qos.txtp,vcc->qos.aal);
if (!error) error = adjust_tp(&vcc->qos.rxtp,vcc->qos.aal); if (!error) error = adjust_tp(&vcc->qos.rxtp,vcc->qos.aal);
if (error) { if (error) {
vcc_remove_socket(vcc->sk); bind_vcc(vcc,NULL);
return error; return error;
} }
DPRINTK("VCC %d.%d, AAL %d\n",vpi,vci,vcc->qos.aal); DPRINTK("VCC %d.%d, AAL %d\n",vpi,vci,vcc->qos.aal);
...@@ -396,7 +327,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi, ...@@ -396,7 +327,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi,
error = dev->ops->open(vcc,vpi,vci); error = dev->ops->open(vcc,vpi,vci);
if (error) { if (error) {
module_put(dev->ops->owner); module_put(dev->ops->owner);
vcc_remove_socket(vcc->sk); bind_vcc(vcc,NULL);
return error; return error;
} }
} }
...@@ -440,7 +371,7 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci) ...@@ -440,7 +371,7 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci)
dev = atm_dev_lookup(itf); dev = atm_dev_lookup(itf);
error = __vcc_connect(vcc, dev, vpi, vci); error = __vcc_connect(vcc, dev, vpi, vci);
if (error) { if (error) {
atm_dev_put(dev); atm_dev_release(dev);
return error; return error;
} }
} else { } else {
...@@ -454,7 +385,7 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci) ...@@ -454,7 +385,7 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci)
spin_unlock(&atm_dev_lock); spin_unlock(&atm_dev_lock);
if (!__vcc_connect(vcc, dev, vpi, vci)) if (!__vcc_connect(vcc, dev, vpi, vci))
break; break;
atm_dev_put(dev); atm_dev_release(dev);
dev = NULL; dev = NULL;
spin_lock(&atm_dev_lock); spin_lock(&atm_dev_lock);
} }
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <linux/poll.h> /* for poll_table */ #include <linux/poll.h> /* for poll_table */
int vcc_create(struct socket *sock, int protocol, int family); int atm_create(struct socket *sock,int protocol,int family);
int vcc_release(struct socket *sock); int atm_release(struct socket *sock);
int vcc_connect(struct socket *sock, int itf, short vpi, int vci); int vcc_connect(struct socket *sock, int itf, short vpi, int vci);
int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
int size, int flags); int size, int flags);
...@@ -24,6 +24,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, char *optval, ...@@ -24,6 +24,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname, char *optval,
int vcc_getsockopt(struct socket *sock, int level, int optname, char *optval, int vcc_getsockopt(struct socket *sock, int level, int optname, char *optval,
int *optlen); int *optlen);
void atm_release_vcc_sk(struct sock *sk,int free_sk);
void atm_shutdown_dev(struct atm_dev *dev); void atm_shutdown_dev(struct atm_dev *dev);
int atmpvc_init(void); int atmpvc_init(void);
......
...@@ -48,7 +48,7 @@ extern void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent); ...@@ -48,7 +48,7 @@ extern void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent);
#include "lec.h" #include "lec.h"
#include "lec_arpc.h" #include "lec_arpc.h"
#include "resources.h" #include "resources.h" /* for bind_vcc() */
#if 0 #if 0
#define DPRINTK printk #define DPRINTK printk
...@@ -810,8 +810,7 @@ lecd_attach(struct atm_vcc *vcc, int arg) ...@@ -810,8 +810,7 @@ lecd_attach(struct atm_vcc *vcc, int arg)
lec_arp_init(priv); lec_arp_init(priv);
priv->itfnum = i; /* LANE2 addition */ priv->itfnum = i; /* LANE2 addition */
priv->lecd = vcc; priv->lecd = vcc;
vcc->dev = &lecatm_dev; bind_vcc(vcc, &lecatm_dev);
vcc_insert_socket(vcc->sk);
vcc->proto_data = dev_lec[i]; vcc->proto_data = dev_lec[i];
set_bit(ATM_VF_META,&vcc->flags); set_bit(ATM_VF_META,&vcc->flags);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "lec.h" #include "lec.h"
#include "mpc.h" #include "mpc.h"
#include "resources.h" #include "resources.h" /* for bind_vcc() */
/* /*
* mpc.c: Implementation of MPOA client kernel part * mpc.c: Implementation of MPOA client kernel part
...@@ -789,8 +789,7 @@ int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) ...@@ -789,8 +789,7 @@ int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
} }
mpc->mpoad_vcc = vcc; mpc->mpoad_vcc = vcc;
vcc->dev = &mpc_dev; bind_vcc(vcc, &mpc_dev);
vcc_insert_socket(vcc->sk);
set_bit(ATM_VF_META,&vcc->flags); set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags); set_bit(ATM_VF_READY,&vcc->flags);
......
...@@ -334,7 +334,9 @@ static int atm_devices_info(loff_t pos,char *buf) ...@@ -334,7 +334,9 @@ static int atm_devices_info(loff_t pos,char *buf)
static int atm_pvc_info(loff_t pos,char *buf) static int atm_pvc_info(loff_t pos,char *buf)
{ {
struct sock *s; unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct atm_vcc *vcc; struct atm_vcc *vcc;
int left, clip_info = 0; int left, clip_info = 0;
...@@ -347,20 +349,25 @@ static int atm_pvc_info(loff_t pos,char *buf) ...@@ -347,20 +349,25 @@ static int atm_pvc_info(loff_t pos,char *buf)
if (try_atm_clip_ops()) if (try_atm_clip_ops())
clip_info = 1; clip_info = 1;
#endif #endif
read_lock(&vcc_sklist_lock); spin_lock(&atm_dev_lock);
for(s = vcc_sklist; s; s = s->sk_next) { list_for_each(p, &atm_devs) {
vcc = atm_sk(s); dev = list_entry(p, struct atm_dev, dev_list);
if (vcc->sk->sk_family == PF_ATMPVC && vcc->dev && !left--) { spin_lock_irqsave(&dev->lock, flags);
pvc_info(vcc,buf,clip_info); for (vcc = dev->vccs; vcc; vcc = vcc->next)
read_unlock(&vcc_sklist_lock); if (vcc->sk->sk_family == PF_ATMPVC &&
vcc->dev && !left--) {
pvc_info(vcc,buf,clip_info);
spin_unlock_irqrestore(&dev->lock, flags);
spin_unlock(&atm_dev_lock);
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
if (clip_info) if (clip_info)
module_put(atm_clip_ops->owner); module_put(atm_clip_ops->owner);
#endif #endif
return strlen(buf); return strlen(buf);
} }
spin_unlock_irqrestore(&dev->lock, flags);
} }
read_unlock(&vcc_sklist_lock); spin_unlock(&atm_dev_lock);
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
if (clip_info) if (clip_info)
module_put(atm_clip_ops->owner); module_put(atm_clip_ops->owner);
...@@ -371,8 +378,10 @@ static int atm_pvc_info(loff_t pos,char *buf) ...@@ -371,8 +378,10 @@ static int atm_pvc_info(loff_t pos,char *buf)
static int atm_vc_info(loff_t pos,char *buf) static int atm_vc_info(loff_t pos,char *buf)
{ {
unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct atm_vcc *vcc; struct atm_vcc *vcc;
struct sock *s;
int left; int left;
if (!pos) if (!pos)
...@@ -380,16 +389,20 @@ static int atm_vc_info(loff_t pos,char *buf) ...@@ -380,16 +389,20 @@ static int atm_vc_info(loff_t pos,char *buf)
"Address"," Itf VPI VCI Fam Flags Reply Send buffer" "Address"," Itf VPI VCI Fam Flags Reply Send buffer"
" Recv buffer\n"); " Recv buffer\n");
left = pos-1; left = pos-1;
read_lock(&vcc_sklist_lock); spin_lock(&atm_dev_lock);
for(s = vcc_sklist; s; s = s->sk_next) { list_for_each(p, &atm_devs) {
vcc = atm_sk(s); dev = list_entry(p, struct atm_dev, dev_list);
if (!left--) { spin_lock_irqsave(&dev->lock, flags);
vc_info(vcc,buf); for (vcc = dev->vccs; vcc; vcc = vcc->next)
read_unlock(&vcc_sklist_lock); if (!left--) {
return strlen(buf); vc_info(vcc,buf);
} spin_unlock_irqrestore(&dev->lock, flags);
spin_unlock(&atm_dev_lock);
return strlen(buf);
}
spin_unlock_irqrestore(&dev->lock, flags);
} }
read_unlock(&vcc_sklist_lock); spin_unlock(&atm_dev_lock);
return 0; return 0;
} }
...@@ -397,23 +410,29 @@ static int atm_vc_info(loff_t pos,char *buf) ...@@ -397,23 +410,29 @@ static int atm_vc_info(loff_t pos,char *buf)
static int atm_svc_info(loff_t pos,char *buf) static int atm_svc_info(loff_t pos,char *buf)
{ {
struct sock *s; unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct atm_vcc *vcc; struct atm_vcc *vcc;
int left; int left;
if (!pos) if (!pos)
return sprintf(buf,"Itf VPI VCI State Remote\n"); return sprintf(buf,"Itf VPI VCI State Remote\n");
left = pos-1; left = pos-1;
read_lock(&vcc_sklist_lock); spin_lock(&atm_dev_lock);
for(s = vcc_sklist; s; s = s->sk_next) { list_for_each(p, &atm_devs) {
vcc = atm_sk(s); dev = list_entry(p, struct atm_dev, dev_list);
if (vcc->sk->sk_family == PF_ATMSVC && !left--) { spin_lock_irqsave(&dev->lock, flags);
svc_info(vcc,buf); for (vcc = dev->vccs; vcc; vcc = vcc->next)
read_unlock(&vcc_sklist_lock); if (vcc->sk->sk_family == PF_ATMSVC && !left--) {
return strlen(buf); svc_info(vcc,buf);
} spin_unlock_irqrestore(&dev->lock, flags);
spin_unlock(&atm_dev_lock);
return strlen(buf);
}
spin_unlock_irqrestore(&dev->lock, flags);
} }
read_unlock(&vcc_sklist_lock); spin_unlock(&atm_dev_lock);
return 0; return 0;
} }
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include "resources.h" /* devs and vccs */ #include "resources.h" /* devs and vccs */
#include "common.h" /* common for PVCs and SVCs */ #include "common.h" /* common for PVCs and SVCs */
#ifndef NULL
#define NULL 0
#endif
static int pvc_shutdown(struct socket *sock,int how) static int pvc_shutdown(struct socket *sock,int how)
{ {
...@@ -105,7 +109,7 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr, ...@@ -105,7 +109,7 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr,
static struct proto_ops pvc_proto_ops = { static struct proto_ops pvc_proto_ops = {
.family = PF_ATMPVC, .family = PF_ATMPVC,
.release = vcc_release, .release = atm_release,
.bind = pvc_bind, .bind = pvc_bind,
.connect = pvc_connect, .connect = pvc_connect,
.socketpair = sock_no_socketpair, .socketpair = sock_no_socketpair,
...@@ -127,7 +131,7 @@ static struct proto_ops pvc_proto_ops = { ...@@ -127,7 +131,7 @@ static struct proto_ops pvc_proto_ops = {
static int pvc_create(struct socket *sock,int protocol) static int pvc_create(struct socket *sock,int protocol)
{ {
sock->ops = &pvc_proto_ops; sock->ops = &pvc_proto_ops;
return vcc_create(sock, protocol, PF_ATMPVC); return atm_create(sock,protocol,PF_ATMPVC);
} }
......
...@@ -23,6 +23,11 @@ ...@@ -23,6 +23,11 @@
#include "addr.h" #include "addr.h"
#ifndef NULL
#define NULL 0
#endif
LIST_HEAD(atm_devs); LIST_HEAD(atm_devs);
spinlock_t atm_dev_lock = SPIN_LOCK_UNLOCKED; spinlock_t atm_dev_lock = SPIN_LOCK_UNLOCKED;
...@@ -86,7 +91,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, ...@@ -86,7 +91,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
spin_lock(&atm_dev_lock); spin_lock(&atm_dev_lock);
if (number != -1) { if (number != -1) {
if ((inuse = __atm_dev_lookup(number))) { if ((inuse = __atm_dev_lookup(number))) {
atm_dev_put(inuse); atm_dev_release(inuse);
spin_unlock(&atm_dev_lock); spin_unlock(&atm_dev_lock);
__free_atm_dev(dev); __free_atm_dev(dev);
return NULL; return NULL;
...@@ -95,7 +100,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, ...@@ -95,7 +100,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
} else { } else {
dev->number = 0; dev->number = 0;
while ((inuse = __atm_dev_lookup(dev->number))) { while ((inuse = __atm_dev_lookup(dev->number))) {
atm_dev_put(inuse); atm_dev_release(inuse);
dev->number++; dev->number++;
} }
} }
...@@ -397,12 +402,78 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg) ...@@ -397,12 +402,78 @@ int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
else else
error = 0; error = 0;
done: done:
atm_dev_put(dev); atm_dev_release(dev);
return error; return error;
} }
struct sock *alloc_atm_vcc_sk(int family)
{
struct sock *sk;
struct atm_vcc *vcc;
sk = sk_alloc(family, GFP_KERNEL, 1, NULL);
if (!sk)
return NULL;
vcc = atm_sk(sk) = kmalloc(sizeof(*vcc), GFP_KERNEL);
if (!vcc) {
sk_free(sk);
return NULL;
}
sock_init_data(NULL, sk);
memset(vcc, 0, sizeof(*vcc));
vcc->sk = sk;
return sk;
}
static void unlink_vcc(struct atm_vcc *vcc)
{
unsigned long flags;
if (vcc->dev) {
spin_lock_irqsave(&vcc->dev->lock, flags);
if (vcc->prev)
vcc->prev->next = vcc->next;
else
vcc->dev->vccs = vcc->next;
if (vcc->next)
vcc->next->prev = vcc->prev;
else
vcc->dev->last = vcc->prev;
spin_unlock_irqrestore(&vcc->dev->lock, flags);
}
}
void free_atm_vcc_sk(struct sock *sk)
{
unlink_vcc(atm_sk(sk));
sk_free(sk);
}
void bind_vcc(struct atm_vcc *vcc,struct atm_dev *dev)
{
unsigned long flags;
unlink_vcc(vcc);
vcc->dev = dev;
if (dev) {
spin_lock_irqsave(&dev->lock, flags);
vcc->next = NULL;
vcc->prev = dev->last;
if (dev->vccs)
dev->last->next = vcc;
else
dev->vccs = vcc;
dev->last = vcc;
spin_unlock_irqrestore(&dev->lock, flags);
}
}
EXPORT_SYMBOL(atm_dev_register); EXPORT_SYMBOL(atm_dev_register);
EXPORT_SYMBOL(atm_dev_deregister); EXPORT_SYMBOL(atm_dev_deregister);
EXPORT_SYMBOL(atm_dev_lookup); EXPORT_SYMBOL(atm_dev_lookup);
EXPORT_SYMBOL(shutdown_atm_dev); EXPORT_SYMBOL(shutdown_atm_dev);
EXPORT_SYMBOL(bind_vcc);
...@@ -14,6 +14,8 @@ extern struct list_head atm_devs; ...@@ -14,6 +14,8 @@ extern struct list_head atm_devs;
extern spinlock_t atm_dev_lock; extern spinlock_t atm_dev_lock;
struct sock *alloc_atm_vcc_sk(int family);
void free_atm_vcc_sk(struct sock *sk);
int atm_dev_ioctl(unsigned int cmd, unsigned long arg); int atm_dev_ioctl(unsigned int cmd, unsigned long arg);
......
...@@ -200,21 +200,26 @@ void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type, ...@@ -200,21 +200,26 @@ void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type,
} }
static void purge_vcc(struct atm_vcc *vcc) static void purge_vccs(struct atm_vcc *vcc)
{ {
if (vcc->sk->sk_family == PF_ATMSVC && while (vcc) {
!test_bit(ATM_VF_META,&vcc->flags)) { if (vcc->sk->sk_family == PF_ATMSVC &&
set_bit(ATM_VF_RELEASED,&vcc->flags); !test_bit(ATM_VF_META,&vcc->flags)) {
vcc->reply = -EUNATCH; set_bit(ATM_VF_RELEASED,&vcc->flags);
vcc->sk->sk_err = EUNATCH; vcc->reply = -EUNATCH;
wake_up(&vcc->sleep); vcc->sk->sk_err = EUNATCH;
wake_up(&vcc->sleep);
}
vcc = vcc->next;
} }
} }
static void sigd_close(struct atm_vcc *vcc) static void sigd_close(struct atm_vcc *vcc)
{ {
struct sock *s; unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
DPRINTK("sigd_close\n"); DPRINTK("sigd_close\n");
sigd = NULL; sigd = NULL;
...@@ -222,14 +227,14 @@ static void sigd_close(struct atm_vcc *vcc) ...@@ -222,14 +227,14 @@ static void sigd_close(struct atm_vcc *vcc)
printk(KERN_ERR "sigd_close: closing with requests pending\n"); printk(KERN_ERR "sigd_close: closing with requests pending\n");
skb_queue_purge(&vcc->sk->sk_receive_queue); skb_queue_purge(&vcc->sk->sk_receive_queue);
read_lock(&vcc_sklist_lock); spin_lock(&atm_dev_lock);
for(s = vcc_sklist; s; s = s->sk_next) { list_for_each(p, &atm_devs) {
struct atm_vcc *vcc = atm_sk(s); dev = list_entry(p, struct atm_dev, dev_list);
spin_lock_irqsave(&dev->lock, flags);
if (vcc->dev) purge_vccs(dev->vccs);
purge_vcc(vcc); spin_unlock_irqrestore(&dev->lock, flags);
} }
read_unlock(&vcc_sklist_lock); spin_unlock(&atm_dev_lock);
} }
...@@ -252,8 +257,7 @@ int sigd_attach(struct atm_vcc *vcc) ...@@ -252,8 +257,7 @@ int sigd_attach(struct atm_vcc *vcc)
if (sigd) return -EADDRINUSE; if (sigd) return -EADDRINUSE;
DPRINTK("sigd_attach\n"); DPRINTK("sigd_attach\n");
sigd = vcc; sigd = vcc;
vcc->dev = &sigd_dev; bind_vcc(vcc,&sigd_dev);
vcc_insert_socket(vcc->sk);
set_bit(ATM_VF_META,&vcc->flags); set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags); set_bit(ATM_VF_READY,&vcc->flags);
wake_up(&sigd_sleep); wake_up(&sigd_sleep);
......
...@@ -88,21 +88,18 @@ static void svc_disconnect(struct atm_vcc *vcc) ...@@ -88,21 +88,18 @@ static void svc_disconnect(struct atm_vcc *vcc)
static int svc_release(struct socket *sock) static int svc_release(struct socket *sock)
{ {
struct sock *sk = sock->sk;
struct atm_vcc *vcc; struct atm_vcc *vcc;
if (sk) { if (!sock->sk) return 0;
vcc = ATM_SD(sock); vcc = ATM_SD(sock);
DPRINTK("svc_release %p\n", vcc); DPRINTK("svc_release %p\n",vcc);
clear_bit(ATM_VF_READY, &vcc->flags); clear_bit(ATM_VF_READY,&vcc->flags);
/* VCC pointer is used as a reference, so we must not free it atm_release_vcc_sk(sock->sk,0);
(thereby subjecting it to re-use) before all pending connections svc_disconnect(vcc);
are closed */ /* VCC pointer is used as a reference, so we must not free it
sock_hold(sk); (thereby subjecting it to re-use) before all pending connections
vcc_release(sock); are closed */
svc_disconnect(vcc); free_atm_vcc_sk(sock->sk);
sock_put(sk);
}
return 0; return 0;
} }
...@@ -545,7 +542,7 @@ static int svc_create(struct socket *sock,int protocol) ...@@ -545,7 +542,7 @@ static int svc_create(struct socket *sock,int protocol)
int error; int error;
sock->ops = &svc_proto_ops; sock->ops = &svc_proto_ops;
error = vcc_create(sock, protocol, AF_ATMSVC); error = atm_create(sock,protocol,AF_ATMSVC);
if (error) return error; if (error) return error;
ATM_SD(sock)->callback = svc_callback; ATM_SD(sock)->callback = svc_callback;
ATM_SD(sock)->local.sas_family = AF_ATMSVC; ATM_SD(sock)->local.sas_family = AF_ATMSVC;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment