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

[ATM] remove iovcnt from atm_skb

skbs has (and has had for a while) scatter/gather support
making the scatter gather in atm redundant.  the current iovcnt
schme really isnt being used anyway typically.   the atm
layer will need a little more work in the future to take
advantage of the skb scatter/gather support.  this patch
removes the iovcnt dependencies and gets the check for
non linear skbs right.
parent d5eb4faf
......@@ -1100,9 +1100,9 @@ static enum enq_res do_tx(struct sk_buff *skb)
dma_rd = eni_in(MID_DMA_RD_TX);
dma_size = 3; /* JK for descriptor and final fill, plus final size
mis-alignment fix */
DPRINTK("iovcnt = %d\n",ATM_SKB(skb)->iovcnt);
if (!ATM_SKB(skb)->iovcnt) dma_size += 5;
else dma_size += 5*ATM_SKB(skb)->iovcnt;
DPRINTK("iovcnt = %d\n",skb_shinfo(skb)->nr_frags);
if (!skb_shinfo(skb)->nr_frags) dma_size += 5;
else dma_size += 5*(skb_shinfo(skb)->nr_frags+1);
if (dma_size > TX_DMA_BUF) {
printk(KERN_CRIT DEV_LABEL "(itf %d): needs %d DMA entries "
"(got only %d)\n",vcc->dev->number,dma_size,TX_DMA_BUF);
......@@ -1123,15 +1123,20 @@ DPRINTK("iovcnt = %d\n",ATM_SKB(skb)->iovcnt);
MID_DMA_COUNT_SHIFT) | (tx->index << MID_DMA_CHAN_SHIFT) |
MID_DT_JK;
j++;
if (!ATM_SKB(skb)->iovcnt)
if (!skb_shinfo(skb)->nr_frags)
if (aal5) put_dma(tx->index,eni_dev->dma,&j,paddr,skb->len);
else put_dma(tx->index,eni_dev->dma,&j,paddr+4,skb->len-4);
else {
DPRINTK("doing direct send\n"); /* @@@ well, this doesn't work anyway */
for (i = 0; i < ATM_SKB(skb)->iovcnt; i++)
for (i = -1; i < skb_shinfo(skb)->nr_frags; i++)
if (i == -1)
put_dma(tx->index,eni_dev->dma,&j,(unsigned long)
((struct iovec *) skb->data)[i].iov_base,
((struct iovec *) skb->data)[i].iov_len);
skb->data,
skb->len - skb->data_len);
else
put_dma(tx->index,eni_dev->dma,&j,(unsigned long)
skb_shinfo(skb)->frags[i].page + skb_shinfo(skb)->frags[i].page_offset,
skb_shinfo(skb)->frags[i].size);
}
if (skb->len & 3)
put_dma(tx->index,eni_dev->dma,&j,zeroes,4-(skb->len & 3));
......
......@@ -1768,17 +1768,20 @@ static int hrz_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
{
unsigned int tx_len = skb->len;
unsigned int tx_iovcnt = ATM_SKB(skb)->iovcnt;
unsigned int tx_iovcnt = skb_shinfo(skb)->nr_frags;
// remember this so we can free it later
dev->tx_skb = skb;
if (tx_iovcnt) {
// scatter gather transfer
dev->tx_regions = tx_iovcnt;
dev->tx_iovec = (struct iovec *) skb->data;
dev->tx_iovec = 0; /* @@@ needs rewritten */
dev->tx_bytes = 0;
PRINTD (DBG_TX|DBG_BUS, "TX start scatter-gather transfer (iovec %p, len %d)",
skb->data, tx_len);
tx_release (dev);
hrz_kfree_skb (skb);
return -EIO;
} else {
// simple transfer
dev->tx_regions = 0;
......
......@@ -1986,7 +1986,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
return -EINVAL;
}
if (ATM_SKB(skb)->iovcnt != 0) {
if (skb_shinfo(skb)->nr_frags != 0) {
printk("%s: No scatter-gather yet.\n", card->name);
atomic_inc(&vcc->stats->tx_err);
dev_kfree_skb(skb);
......@@ -2024,7 +2024,6 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
return -ENOMEM;
}
atomic_add(skb->truesize, &vcc->sk->wmem_alloc);
ATM_SKB(skb)->iovcnt = 0;
memcpy(skb_put(skb, 52), cell, 52);
......
......@@ -1167,7 +1167,6 @@ static int rx_pkt(struct atm_dev *dev)
skb_put(skb,len);
// pwang_test
ATM_SKB(skb)->vcc = vcc;
ATM_SKB(skb)->iovcnt = 0;
ATM_DESC(skb) = desc;
skb_queue_tail(&iadev->rx_dma_q, skb);
......
......@@ -1606,9 +1606,9 @@ static void ns_close(struct atm_vcc *vcc)
card->index);
iovb = vc->rx_iov;
recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
ATM_SKB(iovb)->iovcnt);
ATM_SKB(iovb)->iovcnt = 0;
ATM_SKB(iovb)->vcc = NULL;
NS_SKB(iovb)->iovcnt);
NS_SKB(iovb)->iovcnt = 0;
NS_SKB(iovb)->vcc = NULL;
ns_grab_int_lock(card, flags);
recycle_iov_buf(card, iovb);
spin_unlock_irqrestore(&card->int_lock, flags);
......@@ -1806,7 +1806,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
return -EINVAL;
}
if (ATM_SKB(skb)->iovcnt != 0)
if (skb_shinfo(skb)->nr_frags != 0)
{
printk("nicstar%d: No scatter-gather yet.\n", card->index);
atomic_inc(&vcc->stats->tx_err);
......@@ -2231,30 +2231,30 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
}
}
vc->rx_iov = iovb;
ATM_SKB(iovb)->iovcnt = 0;
NS_SKB(iovb)->iovcnt = 0;
iovb->len = 0;
iovb->tail = iovb->data = iovb->head;
ATM_SKB(iovb)->vcc = vcc;
NS_SKB(iovb)->vcc = vcc;
/* IMPORTANT: a pointer to the sk_buff containing the small or large
buffer is stored as iovec base, NOT a pointer to the
small or large buffer itself. */
}
else if (ATM_SKB(iovb)->iovcnt >= NS_MAX_IOVECS)
else if (NS_SKB(iovb)->iovcnt >= NS_MAX_IOVECS)
{
printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
atomic_inc(&vcc->stats->rx_err);
recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data, NS_MAX_IOVECS);
ATM_SKB(iovb)->iovcnt = 0;
NS_SKB(iovb)->iovcnt = 0;
iovb->len = 0;
iovb->tail = iovb->data = iovb->head;
ATM_SKB(iovb)->vcc = vcc;
NS_SKB(iovb)->vcc = vcc;
}
iov = &((struct iovec *) iovb->data)[ATM_SKB(iovb)->iovcnt++];
iov = &((struct iovec *) iovb->data)[NS_SKB(iovb)->iovcnt++];
iov->iov_base = (void *) skb;
iov->iov_len = ns_rsqe_cellcount(rsqe) * 48;
iovb->len += iov->iov_len;
if (ATM_SKB(iovb)->iovcnt == 1)
if (NS_SKB(iovb)->iovcnt == 1)
{
if (skb->list != &card->sbpool.queue)
{
......@@ -2268,7 +2268,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
return;
}
}
else /* ATM_SKB(iovb)->iovcnt >= 2 */
else /* NS_SKB(iovb)->iovcnt >= 2 */
{
if (skb->list != &card->lbpool.queue)
{
......@@ -2277,7 +2277,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
which_list(card, skb);
atomic_inc(&vcc->stats->rx_err);
recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
ATM_SKB(iovb)->iovcnt);
NS_SKB(iovb)->iovcnt);
vc->rx_iov = NULL;
recycle_iov_buf(card, iovb);
return;
......@@ -2301,7 +2301,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
printk(".\n");
atomic_inc(&vcc->stats->rx_err);
recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
ATM_SKB(iovb)->iovcnt);
NS_SKB(iovb)->iovcnt);
vc->rx_iov = NULL;
recycle_iov_buf(card, iovb);
return;
......@@ -2309,7 +2309,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
/* By this point we (hopefully) have a complete SDU without errors. */
if (ATM_SKB(iovb)->iovcnt == 1) /* Just a small buffer */
if (NS_SKB(iovb)->iovcnt == 1) /* Just a small buffer */
{
/* skb points to a small buffer */
if (!atm_charge(vcc, skb->truesize))
......@@ -2331,7 +2331,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
atomic_inc(&vcc->stats->rx);
}
}
else if (ATM_SKB(iovb)->iovcnt == 2) /* One small plus one large buffer */
else if (NS_SKB(iovb)->iovcnt == 2) /* One small plus one large buffer */
{
struct sk_buff *sb;
......@@ -2408,7 +2408,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
printk("nicstar%d: Out of huge buffers.\n", card->index);
atomic_inc(&vcc->stats->rx_drop);
recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
ATM_SKB(iovb)->iovcnt);
NS_SKB(iovb)->iovcnt);
vc->rx_iov = NULL;
recycle_iov_buf(card, iovb);
return;
......@@ -2446,7 +2446,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
if (!atm_charge(vcc, hb->truesize))
{
recycle_iovec_rx_bufs(card, iov, ATM_SKB(iovb)->iovcnt);
recycle_iovec_rx_bufs(card, iov, NS_SKB(iovb)->iovcnt);
if (card->hbpool.count < card->hbnr.max)
{
skb_queue_tail(&card->hbpool.queue, hb);
......@@ -2469,7 +2469,7 @@ static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
0, 0);
/* Copy all large buffers to the huge buffer and free them */
for (j = 1; j < ATM_SKB(iovb)->iovcnt; j++)
for (j = 1; j < NS_SKB(iovb)->iovcnt; j++)
{
lb = (struct sk_buff *) iov->iov_base;
tocopy = MIN(remaining, iov->iov_len);
......
......@@ -750,6 +750,15 @@ typedef struct vc_map
} vc_map;
struct ns_skb_data
{
struct atm_vcc *vcc;
int iovcnt;
};
#define NS_SKB(skb) (((struct ns_skb_data *) (skb)->cb))
typedef struct ns_dev
{
int index; /* Card ID to the device driver */
......
......@@ -827,10 +827,10 @@ static int do_tx(struct sk_buff *skb)
vcc = ATM_SKB(skb)->vcc;
zatm_dev = ZATM_DEV(vcc->dev);
zatm_vcc = ZATM_VCC(vcc);
EVENT("iovcnt=%d\n",ATM_SKB(skb)->iovcnt,0);
EVENT("iovcnt=%d\n",skb_shinfo(skb)->nr_frags,0);
save_flags(flags);
cli();
if (!ATM_SKB(skb)->iovcnt) {
if (!skb_shinfo(skb)->nr_frags) {
if (zatm_vcc->txing == RING_ENTRIES-1) {
restore_flags(flags);
return RING_BUSY;
......
......@@ -385,7 +385,6 @@ struct atmphy_ops {
struct atm_skb_data {
struct atm_vcc *vcc; /* ATM VCC */
int iovcnt; /* 0 for "normal" operation */
unsigned long atm_options; /* ATM layer options */
};
......
......@@ -433,7 +433,6 @@ static int clip_start_xmit(struct sk_buff *skb,struct net_device *dev)
((u16 *) here)[3] = skb->protocol;
}
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;
DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n",skb,vcc,vcc->dev);
......
......@@ -391,27 +391,6 @@ int atm_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
(unsigned long) buff,eff_len);
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 */
int el, cnt;
struct iovec *iov = (struct iovec *)skb->data;
unsigned char *p = (unsigned char *)buff;
el = eff_len;
error = 0;
for (cnt = 0; (cnt < ATM_SKB(skb)->iovcnt) && el; cnt++) {
/*printk("s-g???: %p -> %p (%d)\n",iov->iov_base,p,iov->iov_len);*/
error = copy_to_user(p,iov->iov_base,
(iov->iov_len > el) ? el : iov->iov_len) ?
-EFAULT : 0;
if (error) break;
p += iov->iov_len;
el -= (iov->iov_len > el)?el:iov->iov_len;
iov++;
}
kfree_skb(skb);
return error ? error : eff_len;
}
error = copy_to_user(buff,skb->data,eff_len) ? -EFAULT : 0;
kfree_skb(skb);
return error ? error : eff_len;
......@@ -470,7 +449,6 @@ int atm_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
remove_wait_queue(&vcc->sleep,&wait);
if (error) return error;
skb->dev = NULL; /* for paths shared with net_device interfaces */
ATM_SKB(skb)->iovcnt = 0;
ATM_SKB(skb)->atm_options = vcc->atm_options;
if (copy_from_user(skb_put(skb,size),buff,size)) {
kfree_skb(skb);
......
......@@ -204,7 +204,6 @@ 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->sk->wmem_alloc);
ATM_SKB(skb)->vcc = vcc;
ATM_SKB(skb)->iovcnt = 0;
ATM_SKB(skb)->atm_options = vcc->atm_options;
priv->stats.tx_packets++;
priv->stats.tx_bytes += skb->len;
......
......@@ -523,7 +523,6 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc)
}
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);
entry->packets_fwded++;
......
......@@ -232,7 +232,6 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb)
return 1;
}
atomic_add(skb->truesize, &ATM_SKB(skb)->vcc->sk->wmem_alloc);
ATM_SKB(skb)->iovcnt = 0;
ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options;
DPRINTK("(unit %d): atm_skb(%p)->vcc(%p)->dev(%p)\n",
pvcc->chan.unit, skb, ATM_SKB(skb)->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