Commit d5eb4faf authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: assorted atm patches

parent b4ad7122
This diff is collapsed.
...@@ -355,10 +355,18 @@ struct he_dev { ...@@ -355,10 +355,18 @@ struct he_dev {
struct he_dev *next; struct he_dev *next;
}; };
struct he_iovec
{
u32 iov_base;
u32 iov_len;
};
#define HE_MAXIOV 20
struct he_vcc struct he_vcc
{ {
struct iovec iov_head[32]; struct he_iovec iov_head[HE_MAXIOV];
struct iovec *iov_tail; struct he_iovec *iov_tail;
int pdu_len; int pdu_len;
int rc_index; int rc_index;
......
...@@ -2023,7 +2023,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags) ...@@ -2023,7 +2023,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
atomic_inc(&vcc->stats->tx_err); atomic_inc(&vcc->stats->tx_err);
return -ENOMEM; return -ENOMEM;
} }
atomic_add(skb->truesize + ATM_PDU_OVHD, &vcc->sk->wmem_alloc); atomic_add(skb->truesize, &vcc->sk->wmem_alloc);
ATM_SKB(skb)->iovcnt = 0; ATM_SKB(skb)->iovcnt = 0;
memcpy(skb_put(skb, 52), cell, 52); memcpy(skb_put(skb, 52), cell, 52);
......
...@@ -2846,7 +2846,6 @@ static const struct atmdev_ops ops = { ...@@ -2846,7 +2846,6 @@ static const struct atmdev_ops ops = {
.phy_get = NULL, .phy_get = NULL,
.feedback = NULL, .feedback = NULL,
.change_qos = lanai_change_qos, .change_qos = lanai_change_qos,
.free_rx_skb = NULL,
.proc_read = lanai_proc_read .proc_read = lanai_proc_read
}; };
......
...@@ -882,9 +882,14 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev) ...@@ -882,9 +882,14 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev)
return error; return error;
} }
if (ns_parse_mac(mac[i], card->atmdev->esi)) if (ns_parse_mac(mac[i], card->atmdev->esi)) {
nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET, nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET,
card->atmdev->esi, 6); card->atmdev->esi, 6);
if (memcmp(card->atmdev->esi, "\x00\x00\x00\x00\x00\x00", 6) == 0) {
nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT,
card->atmdev->esi, 6);
}
}
printk("nicstar%d: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n", i, printk("nicstar%d: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n", i,
card->atmdev->esi[0], card->atmdev->esi[1], card->atmdev->esi[2], card->atmdev->esi[0], card->atmdev->esi[1], card->atmdev->esi[2],
......
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
/* ESI stuff ******************************************************************/ /* ESI stuff ******************************************************************/
#define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C #define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C
#define NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT 0xF6
/* #defines *******************************************************************/ /* #defines *******************************************************************/
......
...@@ -30,9 +30,6 @@ ...@@ -30,9 +30,6 @@
#define ATM_DS3_PCR (8000*12) #define ATM_DS3_PCR (8000*12)
/* DS3: 12 cells in a 125 usec time slot */ /* DS3: 12 cells in a 125 usec time slot */
#define ATM_PDU_OVHD 0 /* number of bytes to charge against buffer
quota per PDU */
#define atm_sk(__sk) ((struct atm_vcc *)(__sk)->protinfo) #define atm_sk(__sk) ((struct atm_vcc *)(__sk)->protinfo)
#define ATM_SD(s) (atm_sk((s)->sk)) #define ATM_SD(s) (atm_sk((s)->sk))
...@@ -289,10 +286,6 @@ struct atm_vcc { ...@@ -289,10 +286,6 @@ struct atm_vcc {
struct atm_sap sap; /* SAP */ struct atm_sap sap; /* SAP */
void (*push)(struct atm_vcc *vcc,struct sk_buff *skb); void (*push)(struct atm_vcc *vcc,struct sk_buff *skb);
void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */ void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */
struct sk_buff *(*alloc_tx)(struct atm_vcc *vcc,unsigned int size);
/* TX allocation routine - can be */
/* modified by protocol or by driver.*/
/* NOTE: this interface will change */
int (*push_oam)(struct atm_vcc *vcc,void *cell); int (*push_oam)(struct atm_vcc *vcc,void *cell);
int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
void *dev_data; /* per-device data */ void *dev_data; /* per-device data */
...@@ -378,8 +371,6 @@ struct atmdev_ops { /* only send is required */ ...@@ -378,8 +371,6 @@ struct atmdev_ops { /* only send is required */
void (*feedback)(struct atm_vcc *vcc,struct sk_buff *skb, void (*feedback)(struct atm_vcc *vcc,struct sk_buff *skb,
unsigned long start,unsigned long dest,int len); unsigned long start,unsigned long dest,int len);
int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags); int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
void (*free_rx_skb)(struct atm_vcc *vcc, struct sk_buff *skb);
/* @@@ temporary hack */
int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page); int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
struct module *owner; struct module *owner;
}; };
...@@ -421,19 +412,19 @@ static __inline__ int atm_guess_pdu2truesize(int pdu_size) ...@@ -421,19 +412,19 @@ static __inline__ int atm_guess_pdu2truesize(int pdu_size)
static __inline__ void atm_force_charge(struct atm_vcc *vcc,int truesize) static __inline__ void atm_force_charge(struct atm_vcc *vcc,int truesize)
{ {
atomic_add(truesize+ATM_PDU_OVHD,&vcc->sk->rmem_alloc); atomic_add(truesize, &vcc->sk->rmem_alloc);
} }
static __inline__ void atm_return(struct atm_vcc *vcc,int truesize) static __inline__ void atm_return(struct atm_vcc *vcc,int truesize)
{ {
atomic_sub(truesize+ATM_PDU_OVHD,&vcc->sk->rmem_alloc); atomic_sub(truesize, &vcc->sk->rmem_alloc);
} }
static __inline__ int atm_may_send(struct atm_vcc *vcc,unsigned int size) static __inline__ int atm_may_send(struct atm_vcc *vcc,unsigned int size)
{ {
return size+atomic_read(&vcc->sk->wmem_alloc)+ATM_PDU_OVHD < vcc->sk->sndbuf; return (size + atomic_read(&vcc->sk->wmem_alloc)) < vcc->sk->sndbuf;
} }
......
...@@ -481,6 +481,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb) ...@@ -481,6 +481,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
} }
brdev->stats.rx_packets++; brdev->stats.rx_packets++;
brdev->stats.rx_bytes += skb->len; brdev->stats.rx_bytes += skb->len;
memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
netif_rx(skb); netif_rx(skb);
} }
......
...@@ -223,6 +223,7 @@ void clip_push(struct atm_vcc *vcc,struct sk_buff *skb) ...@@ -223,6 +223,7 @@ void clip_push(struct atm_vcc *vcc,struct sk_buff *skb)
clip_vcc->last_use = jiffies; clip_vcc->last_use = jiffies;
PRIV(skb->dev)->stats.rx_packets++; PRIV(skb->dev)->stats.rx_packets++;
PRIV(skb->dev)->stats.rx_bytes += skb->len; PRIV(skb->dev)->stats.rx_bytes += skb->len;
memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
netif_rx(skb); netif_rx(skb);
} }
......
...@@ -98,7 +98,7 @@ static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size) ...@@ -98,7 +98,7 @@ static struct sk_buff *alloc_tx(struct atm_vcc *vcc,unsigned int size)
} }
while (!(skb = alloc_skb(size,GFP_KERNEL))) schedule(); while (!(skb = alloc_skb(size,GFP_KERNEL))) schedule();
DPRINTK("AlTx %d += %d\n",atomic_read(&vcc->sk->wmem_alloc),skb->truesize); DPRINTK("AlTx %d += %d\n",atomic_read(&vcc->sk->wmem_alloc),skb->truesize);
atomic_add(skb->truesize+ATM_PDU_OVHD,&vcc->sk->wmem_alloc); atomic_add(skb->truesize, &vcc->sk->wmem_alloc);
return skb; return skb;
} }
...@@ -114,7 +114,6 @@ int atm_create(struct socket *sock,int protocol,int family) ...@@ -114,7 +114,6 @@ int atm_create(struct socket *sock,int protocol,int family)
vcc = atm_sk(sk); vcc = atm_sk(sk);
memset(&vcc->flags,0,sizeof(vcc->flags)); memset(&vcc->flags,0,sizeof(vcc->flags));
vcc->dev = NULL; vcc->dev = NULL;
vcc->alloc_tx = alloc_tx;
vcc->callback = NULL; vcc->callback = NULL;
memset(&vcc->local,0,sizeof(struct sockaddr_atmsvc)); memset(&vcc->local,0,sizeof(struct sockaddr_atmsvc));
memset(&vcc->remote,0,sizeof(struct sockaddr_atmsvc)); memset(&vcc->remote,0,sizeof(struct sockaddr_atmsvc));
...@@ -144,9 +143,7 @@ void atm_release_vcc_sk(struct sock *sk,int free_sk) ...@@ -144,9 +143,7 @@ void atm_release_vcc_sk(struct sock *sk,int free_sk)
if (vcc->push) vcc->push(vcc,NULL); /* atmarpd has no push */ if (vcc->push) vcc->push(vcc,NULL); /* atmarpd has no push */
while ((skb = skb_dequeue(&vcc->sk->receive_queue))) { while ((skb = skb_dequeue(&vcc->sk->receive_queue))) {
atm_return(vcc,skb->truesize); atm_return(vcc,skb->truesize);
if (vcc->dev->ops->free_rx_skb) kfree_skb(skb);
vcc->dev->ops->free_rx_skb(vcc,skb);
else kfree_skb(skb);
} }
spin_lock (&atm_dev_lock); spin_lock (&atm_dev_lock);
fops_put (vcc->dev->ops); fops_put (vcc->dev->ops);
...@@ -412,13 +409,11 @@ int atm_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, ...@@ -412,13 +409,11 @@ int atm_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
el -= (iov->iov_len > el)?el:iov->iov_len; el -= (iov->iov_len > el)?el:iov->iov_len;
iov++; iov++;
} }
if (!vcc->dev->ops->free_rx_skb) kfree_skb(skb); kfree_skb(skb);
else vcc->dev->ops->free_rx_skb(vcc, skb);
return error ? error : eff_len; return error ? error : eff_len;
} }
error = copy_to_user(buff,skb->data,eff_len) ? -EFAULT : 0; error = copy_to_user(buff,skb->data,eff_len) ? -EFAULT : 0;
if (!vcc->dev->ops->free_rx_skb) kfree_skb(skb); kfree_skb(skb);
else vcc->dev->ops->free_rx_skb(vcc, skb);
return error ? error : eff_len; return error ? error : eff_len;
} }
...@@ -450,7 +445,7 @@ int atm_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, ...@@ -450,7 +445,7 @@ int atm_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
add_wait_queue(&vcc->sleep,&wait); add_wait_queue(&vcc->sleep,&wait);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
error = 0; error = 0;
while (!(skb = vcc->alloc_tx(vcc,eff))) { while (!(skb = alloc_tx(vcc,eff))) {
if (m->msg_flags & MSG_DONTWAIT) { if (m->msg_flags & MSG_DONTWAIT) {
error = -EAGAIN; error = -EAGAIN;
break; break;
...@@ -502,8 +497,7 @@ unsigned int atm_poll(struct file *file,struct socket *sock,poll_table *wait) ...@@ -502,8 +497,7 @@ unsigned int atm_poll(struct file *file,struct socket *sock,poll_table *wait)
mask |= POLLHUP; mask |= POLLHUP;
if (sock->state != SS_CONNECTING) { if (sock->state != SS_CONNECTING) {
if (vcc->qos.txtp.traffic_class != ATM_NONE && if (vcc->qos.txtp.traffic_class != ATM_NONE &&
vcc->qos.txtp.max_sdu+atomic_read(&vcc->sk->wmem_alloc)+ vcc->qos.txtp.max_sdu+atomic_read(&vcc->sk->wmem_alloc) <= vcc->sk->sndbuf)
ATM_PDU_OVHD <= vcc->sk->sndbuf)
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
} }
else if (vcc->reply != WAITING) { else if (vcc->reply != WAITING) {
...@@ -570,7 +564,7 @@ int atm_ioctl(struct socket *sock,unsigned int cmd,unsigned long arg) ...@@ -570,7 +564,7 @@ int atm_ioctl(struct socket *sock,unsigned int cmd,unsigned long arg)
goto done; goto done;
} }
ret_val = put_user(vcc->sk->sndbuf- ret_val = put_user(vcc->sk->sndbuf-
atomic_read(&vcc->sk->wmem_alloc)-ATM_PDU_OVHD, atomic_read(&vcc->sk->wmem_alloc),
(int *) arg) ? -EFAULT : 0; (int *) arg) ? -EFAULT : 0;
goto done; goto done;
case SIOCINQ: case SIOCINQ:
......
...@@ -715,6 +715,7 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -715,6 +715,7 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
skb->protocol = eth_type_trans(skb, dev); skb->protocol = eth_type_trans(skb, dev);
priv->stats.rx_packets++; priv->stats.rx_packets++;
priv->stats.rx_bytes += skb->len; priv->stats.rx_bytes += skb->len;
memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
netif_rx(skb); netif_rx(skb);
} }
} }
......
...@@ -732,6 +732,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -732,6 +732,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)
eg->packets_rcvd++; eg->packets_rcvd++;
mpc->eg_ops->put(eg); mpc->eg_ops->put(eg);
memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
netif_rx(new_skb); netif_rx(new_skb);
return; return;
...@@ -863,7 +864,7 @@ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -863,7 +864,7 @@ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb)
struct mpoa_client *mpc = find_mpc_by_vcc(vcc); struct mpoa_client *mpc = find_mpc_by_vcc(vcc);
struct k_message *mesg = (struct k_message*)skb->data; struct k_message *mesg = (struct k_message*)skb->data;
atomic_sub(skb->truesize+ATM_PDU_OVHD, &vcc->sk->wmem_alloc); atomic_sub(skb->truesize, &vcc->sk->wmem_alloc);
if (mpc == NULL) { if (mpc == NULL) {
printk("mpoa: msg_from_mpoad: no mpc found\n"); printk("mpoa: msg_from_mpoad: no mpc found\n");
......
...@@ -37,7 +37,7 @@ void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb) ...@@ -37,7 +37,7 @@ void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb)
static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb) static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb)
{ {
DPRINTK("APopR (%d) %d -= %d\n",vcc->vci,vcc->sk->wmem_alloc,skb->truesize); 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); atomic_sub(skb->truesize, &vcc->sk->wmem_alloc);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
wake_up(&vcc->sleep); wake_up(&vcc->sleep);
} }
......
...@@ -98,7 +98,7 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb) ...@@ -98,7 +98,7 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb)
struct atm_vcc *session_vcc; struct atm_vcc *session_vcc;
msg = (struct atmsvc_msg *) skb->data; msg = (struct atmsvc_msg *) skb->data;
atomic_sub(skb->truesize+ATM_PDU_OVHD,&vcc->sk->wmem_alloc); atomic_sub(skb->truesize, &vcc->sk->wmem_alloc);
DPRINTK("sigd_send %d (0x%lx)\n",(int) msg->type, DPRINTK("sigd_send %d (0x%lx)\n",(int) msg->type,
(unsigned long) msg->vcc); (unsigned long) msg->vcc);
vcc = *(struct atm_vcc **) &msg->vcc; vcc = *(struct atm_vcc **) &msg->vcc;
......
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