diff -ur --new-file old/linux/Documentation/Configure.help new/linux/Documentation/Configure.help
--- old/linux/Documentation/Configure.help	Thu Oct  1 23:49:55 1998
+++ new/linux/Documentation/Configure.help	Thu Oct  1 23:50:39 1998
@@ -3172,6 +3172,11 @@
   to actually make use of ATM. See http://lrcwww.epfl.ch/linux-atm/ for
   further details.
 
+Use "new" skb structure
+CONFIG_ATM_SKB
+  Store ATM-specific data in a "more compatible" way in socket buffers.
+  Use this options only with updated drivers.
+
 Enable single-copy
 CONFIG_MMU_HACKS
   Single-copy avoids intermediate buffering of AAL5 PDUs when using the
@@ -3224,6 +3229,58 @@
   using printks, but still has some impact on performance. Note that
   extended debugging may create certain race conditions itself. Enable
   this ONLY if you suspect problems with the driver.
+
+Fine-tune burst settings
+CONFIG_ATM_ENI_TUNE_BURST
+  In order to obtain good throughput, the ENI NIC can transfer multiple
+  words of data per PCI bus access cycle. Such a multi-word transfer is
+  called a burst.
+
+  The default settings for the burst sizes are suitable for most PCI
+  chipsets. However, in some cases, large bursts may overrun buffers in
+  the PCI chipset and cause data corruption. In such cases, large bursts
+  must be disabled and only (slower) small bursts can be used. The burst
+  sizes can be set independently in the send (TX) and receive (RX)
+  direction.
+
+  Note that enabling many different burst sizes in the same direction
+  may increase the cost of setting up a transfer such that the resulting
+  throughput is lower than when using only the largest available burst
+  size.
+
+Enable 8W TX bursts (recommended)
+CONFIG_ATM_ENI_BURST_TX_8W
+  Burst eight words at once in the send direction. This is the default
+  setting.
+
+Enable 4W TX bursts (optional)
+CONFIG_ATM_ENI_BURST_TX_4W
+  Burst four words at once in the send direction. You may want to try this
+  if you have disabled 8W bursts. Enabling 4W if 8W is also set may or may
+  not improve throughput.
+  
+Enable 2W TX bursts (optional)
+CONFIG_ATM_ENI_BURST_TX_2W
+  Burst two words at once in the send direction. You may want to try this
+  if you have disabled 4W and 8W bursts. Enabling 2W if 4W or 8W are also
+  set may or may not improve throughput.
+
+Enable 8W RX bursts (discouraged)
+CONFIG_ATM_ENI_BURST_RX_8W
+  Burst eight words at once in the receive direction. This may work with
+  recent PCI chipsets, but is known to fail with older chipsets, such as
+  the Intel Neptune series.
+
+Enable 4W RX bursts (recommended)
+CONFIG_ATM_ENI_BURST_RX_4W
+  Burst four words at once in the receive direction. This is the default
+  setting. Enabling 4W if 8W is also set may or may not improve throughput.
+
+Enable 2W RX bursts (optional)
+CONFIG_ATM_ENI_BURST_RX_2W
+  Burst two words at once in the receive direction. You may want to try
+  this if you have disabled 4W and 8W bursts. Enabling 2W if 4W or 8W are
+  also set may or may not improve throughput.
 
 ZeitNet ZN1221/ZN1225
 CONFIG_ATM_ZATM
diff -ur --new-file old/linux/drivers/atm/Config.in new/linux/drivers/atm/Config.in
--- old/linux/drivers/atm/Config.in	Thu Oct  1 23:49:55 1998
+++ new/linux/drivers/atm/Config.in	Thu Oct  1 23:50:40 1998
@@ -9,6 +9,15 @@
   tristate 'Efficient Networks ENI155P' CONFIG_ATM_ENI y
   if [ ! "$CONFIG_ATM_ENI" = "n" ]; then
     bool '  Enable extended debugging' CONFIG_ATM_ENI_DEBUG n
+    bool '  Fine-tune burst settings' CONFIG_ATM_ENI_TUNE_BURST n
+    if [ "$CONFIG_ATM_ENI_TUNE_BURST" = "y" ]; then
+      bool '    Enable 8W TX bursts (recommended)' CONFIG_ATM_ENI_BURST_TX_8W y
+      bool '    Enable 4W TX bursts (optional)' CONFIG_ATM_ENI_BURST_TX_4W n
+      bool '    Enable 2W TX bursts (optional)' CONFIG_ATM_ENI_BURST_TX_2W n
+      bool '    Enable 8W RX bursts (discouraged)' CONFIG_ATM_ENI_BURST_RX_8W n
+      bool '    Enable 4W RX bursts (recommended)' CONFIG_ATM_ENI_BURST_RX_4W y
+      bool '    Enable 2W RX bursts (optional)' CONFIG_ATM_ENI_BURST_RX_2W n
+    fi
   fi
   tristate 'ZeitNet ZN1221/ZN1225' CONFIG_ATM_ZATM y
   if [ ! "$CONFIG_ATM_ZATM" = "n" ]; then
diff -ur --new-file old/linux/drivers/atm/eni.c new/linux/drivers/atm/eni.c
--- old/linux/drivers/atm/eni.c	Thu Oct  1 23:49:55 1998
+++ new/linux/drivers/atm/eni.c	Thu Oct  1 23:50:40 1998
@@ -50,7 +50,6 @@
  * - buffer space allocation algorithm is stupid
  *   (RX: should be maxSDU+maxdelay*rate
  *    TX: should be maxSDU+min(maxSDU,maxdelay*rate) )
- * - ATM DD interface doesn't know about CLP
  * - doesn't support OAM cells
  * - eni_put_free may hang if not putting memory fragments that _complete_
  *   2^n block (never happens in real life, though)
@@ -64,6 +63,13 @@
 #define DPRINTK(format,args...)
 #endif
 
+
+#ifndef CONFIG_ATM_ENI_TUNE_BURST
+#define CONFIG_ATM_ENI_BURST_TX_8W
+#define CONFIG_ATM_ENI_BURST_RX_4W
+#endif
+
+
 #ifndef CONFIG_ATM_ENI_DEBUG
 
 
@@ -346,7 +352,7 @@
 			    vcc->vci,paddr);
 		ENI_PRV_SIZE(skb) = size+skip;
 		    /* PDU plus descriptor */
-		skb->atm.vcc = vcc;
+		ATM_SKB(skb)->vcc = vcc;
 	}
 	j = 0;
 	if ((eff && skip) || 1) { /* @@@ actually, skip is always == 1 ... */
@@ -377,23 +383,36 @@
 			paddr += init << 2;
 			words -= init;
 		}
+#ifdef CONFIG_ATM_ENI_BURST_RX_8W  /* works only with *some* PCI chipsets ... */
 		if (words & ~7) {
-#if 0 /* works with *some* PCI chipsets ... */
 			dma[j++] = MID_DT_8W | ((words >> 3) <<
 			    MID_DMA_COUNT_SHIFT) | (vcc->vci <<
 			    MID_DMA_VCI_SHIFT);
-			dma[j++] = virt_to_bus(paddr);
+			dma[j++] = virt_to_bus((void *) paddr);
 			paddr += (words & ~7) << 2;
 			words &= 7;
-#else
+		}
+#endif
+#ifdef CONFIG_ATM_ENI_BURST_RX_4W /* recommended */
+		if (words & ~3) {
 			dma[j++] = MID_DT_4W | ((words >> 2) <<
 			    MID_DMA_COUNT_SHIFT) | (vcc->vci <<
 			    MID_DMA_VCI_SHIFT);
 			dma[j++] = virt_to_bus((void *) paddr);
 			paddr += (words & ~3) << 2;
 			words &= 3;
+		}
 #endif
+#ifdef CONFIG_ATM_ENI_BURST_RX_2W /* probably useless if RX_4W or RX_8W */
+		if (words & ~1) {
+			dma[j++] = MID_DT_2W | ((words >> 1) <<
+			    MID_DMA_COUNT_SHIFT) | (vcc->vci <<
+			    MID_DMA_VCI_SHIFT);
+			dma[j++] = virt_to_bus((void *) paddr);
+			paddr += (words & ~1) << 2;
+			words &= 1;
 		}
+#endif
 		if (words) {
 			dma[j++] = MID_DT_WORD | (words << MID_DMA_COUNT_SHIFT)
 			    | (vcc->vci << MID_DMA_VCI_SHIFT);
@@ -707,7 +726,7 @@
 		EVENT("dequeued (size=%ld,pos=0x%lx)\n",ENI_PRV_SIZE(skb),
 		    ENI_PRV_POS(skb));
 rx_dequeued++;
-		vcc = skb->atm.vcc;
+		vcc = ATM_SKB(skb)->vcc;
 		eni_vcc = ENI_VCC(vcc);
 		first = 0;
 		vci_dsc = eni_dev->vci+(vcc->vci << 2);
@@ -907,6 +926,7 @@
 		paddr += init << 2;
 		words -= init;
 	}
+#ifdef CONFIG_ATM_ENI_BURST_TX_8W /* recommended */
 	if (words & ~7) {
 		DPRINTK("put_dma: %lx DMA: %d*8/%d words\n",paddr,words >> 3,
 		    words);
@@ -916,6 +936,29 @@
 		paddr += (words & ~7) << 2;
 		words &= 7;
 	}
+#endif
+#ifdef CONFIG_ATM_ENI_BURST_TX_4W /* probably useless if TX_8W */
+	if (words & ~3) {
+		DPRINTK("put_dma: %lx DMA: %d*4/%d words\n",paddr,words >> 2,
+		    words);
+		dma[(*j)++] = MID_DT_4W | ((words >> 2) << MID_DMA_COUNT_SHIFT)
+		    | (chan << MID_DMA_CHAN_SHIFT);
+		dma[(*j)++] = virt_to_bus((void *) paddr);
+		paddr += (words & ~3) << 2;
+		words &= 3;
+	}
+#endif
+#ifdef CONFIG_ATM_ENI_BURST_TX_2W /* probably useless if TX_4W or TX_8W */
+	if (words & ~1) {
+		DPRINTK("put_dma: %lx DMA: %d*2/%d words\n",paddr,words >> 1,
+		    words);
+		dma[(*j)++] = MID_DT_2W | ((words >> 1) << MID_DMA_COUNT_SHIFT)
+		    | (chan << MID_DMA_CHAN_SHIFT);
+		dma[(*j)++] = virt_to_bus((void *) paddr);
+		paddr += (words & ~1) << 2;
+		words &= 1;
+	}
+#endif
 	if (words) {
 		DPRINTK("put_dma: %lx DMA: %d words\n",paddr,words);
 		dma[(*j)++] = MID_DT_WORD | (words << MID_DMA_COUNT_SHIFT) |
@@ -945,7 +988,7 @@
 	DPRINTK(">do_tx\n");
 	NULLCHECK(skb);
 	EVENT("do_tx: skb=0x%lx, %ld bytes\n",(unsigned long) skb,skb->len);
-	vcc = skb->atm.vcc;
+	vcc = ATM_SKB(skb)->vcc;
 	NULLCHECK(vcc);
 	eni_dev = ENI_DEV(vcc->dev);
 	NULLCHECK(eni_dev);
@@ -1000,9 +1043,9 @@
 	dma_rd = readl(eni_dev->reg+MID_DMA_RD_TX);
 	dma_size = 3; /* JK for descriptor and final fill, plus final size
 			 mis-alignment fix */
-DPRINTK("iovcnt = %d\n",skb->atm.iovcnt);
-	if (!skb->atm.iovcnt) dma_size += 5;
-	else dma_size += 5*skb->atm.iovcnt;
+DPRINTK("iovcnt = %d\n",ATM_SKB(skb)->iovcnt);
+	if (!ATM_SKB(skb)->iovcnt) dma_size += 5;
+	else dma_size += 5*ATM_SKB(skb)->iovcnt;
 	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);
@@ -1020,7 +1063,7 @@
 	     MID_DMA_COUNT_SHIFT) | (tx->index << MID_DMA_CHAN_SHIFT) |
 	     MID_DT_JK;
 	j++;
-	if (!skb->atm.iovcnt)
+	if (!ATM_SKB(skb)->iovcnt)
 		if (aal5)
 			put_dma(tx->index,eni_dev->dma,&j,
 			    (unsigned long) skb->data,skb->len);
@@ -1028,7 +1071,7 @@
 			    (unsigned long) skb->data+4,skb->len-4);
 	else {
 DPRINTK("doing direct send\n");
-		for (i = 0; i < skb->atm.iovcnt; i++)
+		for (i = 0; i < ATM_SKB(skb)->iovcnt; i++)
 			put_dma(tx->index,eni_dev->dma,&j,(unsigned long)
 			    ((struct iovec *) skb->data)[i].iov_base,
 			    ((struct iovec *) skb->data)[i].iov_len);
@@ -1050,7 +1093,7 @@
 /*printk("dsc = 0x%08lx\n",tx->send[tx->tx_pos]);*/
 	tx->send[(tx->tx_pos+1) & (tx->words-1)] = (vcc->vci <<
 	    MID_SEG_VCI_SHIFT) | (aal5 ? 0 : (skb->data[3] & 0xf)) |
-	    (skb->atm.atm_options & ATM_ATMOPT_CLP ? MID_SEG_CLP : 0);
+	    (ATM_SKB(skb)->atm_options & ATM_ATMOPT_CLP ? MID_SEG_CLP : 0);
 	DPRINTK("size: %ld, len:%d\n",size,skb->len);
 	if (aal5)
 		tx->send[(tx->tx_pos+size-AAL5_TRAILER) & (tx->words-1)] =
@@ -1109,7 +1152,7 @@
 	eni_dev = ENI_DEV(dev);
 	NULLCHECK(eni_dev);
 	while ((skb = skb_dequeue(&eni_dev->tx_queue))) {
-		vcc = skb->atm.vcc;
+		vcc = ATM_SKB(skb)->vcc;
 		NULLCHECK(vcc);
 		tx = ENI_VCC(vcc)->tx;
 		NULLCHECK(ENI_VCC(vcc)->tx);
@@ -1873,7 +1916,7 @@
 	    (struct sk_buff *) &eni_dev->tx_queue; skb = skb->next) {
 		u32 *dsc;
 
-		if (skb->atm.vcc != vcc) continue;
+		if (ATM_SKB(skb)->vcc != vcc) continue;
 		dsc = tx->send+ENI_PRV_POS(skb);
 		*dsc = (*dsc & ~(MID_SEG_RATE | MID_SEG_PR)) |
 		    (tx->prescaler << MID_SEG_PR_SHIFT) |
@@ -1961,7 +2004,7 @@
 		*(u32 *) skb->data = htonl(*(u32 *) skb->data);
 	}
 submitted++;
-	skb->atm.vcc = vcc;
+	ATM_SKB(skb)->vcc = vcc;
 	save_flags(flags);
 	cli(); /* brute force */
 	if (skb_peek(&ENI_VCC(vcc)->tx->backlog) || do_tx(skb)) {
diff -ur --new-file old/linux/drivers/atm/eni.h new/linux/drivers/atm/eni.h
--- old/linux/drivers/atm/eni.h	Thu Oct  1 23:49:55 1998
+++ new/linux/drivers/atm/eni.h	Thu Oct  1 23:50:40 1998
@@ -21,8 +21,8 @@
 
 #define UBR_BUFFER	(128*1024)	/* UBR buffer size */
 
-#define RX_DMA_BUF	 5		/* burst and skip a few things */
-#define TX_DMA_BUF	60		/* should be enough for 64 kB */
+#define RX_DMA_BUF	  8		/* burst and skip a few things */
+#define TX_DMA_BUF	100		/* should be enough for 64 kB */
 
 
 struct eni_free {
@@ -104,6 +104,7 @@
 
 
 struct eni_skb_prv {
+	struct atm_skb_data _;		/* reserved */
 	unsigned long pos;		/* position of next descriptor */
 	int size;			/* PDU size in reassembly buffer */
 };
diff -ur --new-file old/linux/drivers/atm/nicstar.c new/linux/drivers/atm/nicstar.c
--- old/linux/drivers/atm/nicstar.c	Thu Oct  1 23:49:55 1998
+++ new/linux/drivers/atm/nicstar.c	Thu Oct  1 23:50:40 1998
@@ -966,7 +966,7 @@
       {
          if (scq->skb[i] != NULL)
 	 {
-            vcc = scq->skb[i]->atm.vcc;
+            vcc = ATM_SKB(scq->skb[i])->vcc;
             if (vcc->pop != NULL)
 	       vcc->pop(vcc, scq->skb[i]);
 	    else
@@ -1539,9 +1539,9 @@
 	        card->index);
          iovb = vc->rx_iov;
          recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
-	                       iovb->atm.iovcnt);
-         iovb->atm.iovcnt = 0;
-         iovb->atm.vcc = NULL;
+	                       ATM_SKB(iovb)->iovcnt);
+         ATM_SKB(iovb)->iovcnt = 0;
+         ATM_SKB(iovb)->vcc = NULL;
          save_flags(flags); cli();
          recycle_iov_buf(card, iovb);
          restore_flags(flags);
@@ -1740,7 +1740,7 @@
       return -EINVAL;
    }
    
-   if (skb->atm.iovcnt != 0)
+   if (ATM_SKB(skb)->iovcnt != 0)
    {
       printk("nicstar%d: No scatter-gather yet.\n", card->index);
       vcc->stats->tx_err++;
@@ -1748,7 +1748,7 @@
       return -EINVAL;
    }
    
-   skb->atm.vcc = vcc;
+   ATM_SKB(skb)->vcc = vcc;
 
    if (vcc->qos.aal == ATM_AAL5)
    {
@@ -1958,7 +1958,7 @@
               card->index, (u32) skb, i);
       if (skb != NULL)
       {
-         vcc = skb->atm.vcc;
+         vcc = ATM_SKB(skb)->vcc;
 	 if (vcc->pop != NULL)
 	    vcc->pop(vcc, skb);
 	 else
@@ -2065,7 +2065,7 @@
          skb_put(sb, NS_AAL0_HEADER);
          memcpy(sb->tail, cell, ATM_CELL_PAYLOAD);
          skb_put(sb, ATM_CELL_PAYLOAD);
-         sb->atm.vcc = vcc;
+         ATM_SKB(sb)->vcc = vcc;
          sb->stamp = xtime;
          vcc->push(vcc, sb);
          vcc->stats->rx++;
@@ -2103,30 +2103,30 @@
 	    }
 	 }
       vc->rx_iov = iovb;
-      iovb->atm.iovcnt = 0;
+      ATM_SKB(iovb)->iovcnt = 0;
       iovb->len = 0;
       iovb->tail = iovb->data = iovb->head;
-      iovb->atm.vcc = vcc;
+      ATM_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 (iovb->atm.iovcnt >= NS_MAX_IOVECS)
+   else if (ATM_SKB(iovb)->iovcnt >= NS_MAX_IOVECS)
    {
       printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
       vcc->stats->rx_err++;
       recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data, NS_MAX_IOVECS);
-      iovb->atm.iovcnt = 0;
+      ATM_SKB(iovb)->iovcnt = 0;
       iovb->len = 0;
       iovb->tail = iovb->data = iovb->head;
-      iovb->atm.vcc = vcc;
+      ATM_SKB(iovb)->vcc = vcc;
    }
-   iov = &((struct iovec *) iovb->data)[iovb->atm.iovcnt++];
+   iov = &((struct iovec *) iovb->data)[ATM_SKB(iovb)->iovcnt++];
    iov->iov_base = (void *) skb;
    iov->iov_len = ns_rsqe_cellcount(rsqe) * 48;
    iovb->len += iov->iov_len;
 
-   if (iovb->atm.iovcnt == 1)
+   if (ATM_SKB(iovb)->iovcnt == 1)
    {
       if (skb->list != &card->sbpool.queue)
       {
@@ -2140,7 +2140,7 @@
          return;
       }
    }
-   else /* iovb->atm.iovcnt >= 2 */
+   else /* ATM_SKB(iovb)->iovcnt >= 2 */
    {
       if (skb->list != &card->lbpool.queue)
       {
@@ -2149,7 +2149,7 @@
          which_list(card, skb);
          vcc->stats->rx_err++;
          recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
-	                       iovb->atm.iovcnt);
+	                       ATM_SKB(iovb)->iovcnt);
          vc->rx_iov = NULL;
          recycle_iov_buf(card, iovb);
 	 return;
@@ -2171,7 +2171,8 @@
          else
             printk("nicstar%d: AAL5 PDU size mismatch.\n", card->index);
          vcc->stats->rx_err++;
-         recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data, iovb->atm.iovcnt);
+         recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
+	   ATM_SKB(iovb)->iovcnt);
 	 vc->rx_iov = NULL;
          recycle_iov_buf(card, iovb);
 	 return;
@@ -2179,7 +2180,7 @@
 
       /* By this point we (hopefully) have a complete SDU without errors. */
 
-      if (iovb->atm.iovcnt == 1)	/* Just a small buffer */
+      if (ATM_SKB(iovb)->iovcnt == 1)	/* Just a small buffer */
       {
          /* skb points to a small buffer */
          if (!atm_charge(vcc, skb->truesize))
@@ -2194,13 +2195,13 @@
 #ifdef NS_USE_DESTRUCTORS
             skb->destructor = ns_sb_destructor;
 #endif /* NS_USE_DESTRUCTORS */
-            skb->atm.vcc = vcc;
+            ATM_SKB(skb)->vcc = vcc;
             skb->stamp = xtime;
             vcc->push(vcc, skb);
             vcc->stats->rx++;
          }
       }
-      else if (iovb->atm.iovcnt == 2)	/* One small plus one large buffer */
+      else if (ATM_SKB(iovb)->iovcnt == 2)	/* One small plus one large buffer */
       {
          struct sk_buff *sb;
 
@@ -2221,7 +2222,7 @@
 #ifdef NS_USE_DESTRUCTORS
                sb->destructor = ns_sb_destructor;
 #endif /* NS_USE_DESTRUCTORS */
-               sb->atm.vcc = vcc;
+               ATM_SKB(sb)->vcc = vcc;
                sb->stamp = xtime;
                vcc->push(vcc, sb);
                vcc->stats->rx++;
@@ -2247,7 +2248,7 @@
                skb_push(skb, NS_SMBUFSIZE);
                memcpy(skb->data, sb->data, NS_SMBUFSIZE);
                skb_put(skb, len - NS_SMBUFSIZE);
-               skb->atm.vcc = vcc;
+               ATM_SKB(skb)->vcc = vcc;
                skb->stamp = xtime;
                vcc->push(vcc, skb);
                vcc->stats->rx++;
@@ -2275,7 +2276,7 @@
                printk("nicstar%d: Out of huge buffers.\n", card->index);
                vcc->stats->rx_drop++;
                recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
-	                             iovb->atm.iovcnt);
+	                             ATM_SKB(iovb)->iovcnt);
                vc->rx_iov = NULL;
                recycle_iov_buf(card, iovb);
                return;
@@ -2313,7 +2314,7 @@
 
          if (!atm_charge(vcc, hb->truesize))
 	 {
-            recycle_iovec_rx_bufs(card, iov, iovb->atm.iovcnt);
+            recycle_iovec_rx_bufs(card, iov, ATM_SKB(iovb)->iovcnt);
             if (card->hbpool.count < card->hbnr.max)
             {
                skb_queue_tail(&card->hbpool.queue, hb);
@@ -2335,7 +2336,7 @@
                         0, 0);
 
             /* Copy all large buffers to the huge buffer and free them */
-            for (j = 1; j < iovb->atm.iovcnt; j++)
+            for (j = 1; j < ATM_SKB(iovb)->iovcnt; j++)
             {
                lb = (struct sk_buff *) iov->iov_base;
                tocopy = MIN(remaining, iov->iov_len);
@@ -2350,7 +2351,7 @@
             if (remaining != 0 || hb->len != len)
                printk("nicstar%d: Huge buffer len mismatch.\n", card->index);
 #endif /* EXTRA_DEBUG */
-            hb->atm.vcc = vcc;
+            ATM_SKB(hb)->vcc = vcc;
 #ifdef NS_USE_DESTRUCTORS
             hb->destructor = ns_hb_destructor;
 #endif /* NS_USE_DESTRUCTORS */
@@ -2375,7 +2376,7 @@
    ns_dev *card;
    u32 stat;
 
-   card = (ns_dev *) sb->atm.vcc->dev->dev_data;
+   card = (ns_dev *) ATM_SKB(sb)->vcc->dev->dev_data;
    stat = readl(card->membase + STAT);
    card->sbfqc = ns_stat_sfbqc_get(stat);   
    card->lbfqc = ns_stat_lfbqc_get(stat);
@@ -2398,7 +2399,7 @@
    ns_dev *card;
    u32 stat;
 
-   card = (ns_dev *) lb->atm.vcc->dev->dev_data;
+   card = (ns_dev *) ATM_SKB(lb)->vcc->dev->dev_data;
    stat = readl(card->membase + STAT);
    card->sbfqc = ns_stat_sfbqc_get(stat);   
    card->lbfqc = ns_stat_lfbqc_get(stat);
@@ -2420,7 +2421,7 @@
 {
    ns_dev *card;
 
-   card = (ns_dev *) hb->atm.vcc->dev->dev_data;
+   card = (ns_dev *) ATM_SKB(hb)->vcc->dev->dev_data;
 
    while (card->hbpool.count < card->hbnr.init)
    {
diff -ur --new-file old/linux/drivers/atm/nicstar.c.old_skb new/linux/drivers/atm/nicstar.c.old_skb
--- old/linux/drivers/atm/nicstar.c.old_skb	Thu Jan  1 01:00:00 1970
+++ new/linux/drivers/atm/nicstar.c.old_skb	Thu Oct  1 23:50:40 1998
@@ -0,0 +1,2883 @@
+/******************************************************************************
+ *
+ * nicstar.c
+ *
+ * Device driver supporting CBR for NICStAR based cards.
+ *
+ * IMPORTANT: The included file nicstarmac.c was NOT WRITTEN BY ME.
+ *            It was taken from the frle-0.22 device driver.
+ *            As the file doesn't have a copyright notice, in the file
+ *            nicstarmac.copyright I put the copyright notice from the
+ *            frle-0.22 device driver.
+ *            Some code is based on the nicstar driver by M. Welsh.
+ *
+ * Author: Rui Prior
+ *
+ * (C) INESC 1998
+ *
+ ******************************************************************************/
+
+
+/* Header files ***************************************************************/
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/skbuff.h>
+#include <linux/atmdev.h>
+#include <linux/atm.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include "nicstar.h"
+#include "nicstarmac.h"
+
+
+/* Additional code ************************************************************/
+
+#include "nicstarmac.c"
+
+
+/* Configurable parameters ****************************************************/
+
+#undef PHY_LOOPBACK
+#undef TX_DEBUG
+#undef RX_DEBUG
+#undef GENERAL_DEBUG
+#undef EXTRA_DEBUG
+
+#undef NS_USE_DESTRUCTORS /* For now keep this undefined unless you know
+                             you're going to use only raw ATM */
+
+
+/* Do not touch these *********************************************************/
+
+#ifdef TX_DEBUG
+#define TXPRINTK(args...) printk(args)
+#else
+#define TXPRINTK(args...)
+#endif /* TX_DEBUG */
+
+#ifdef RX_DEBUG
+#define RXPRINTK(args...) printk(args)
+#else
+#define RXPRINTK(args...)
+#endif /* RX_DEBUG */
+
+#ifdef GENERAL_DEBUG
+#define PRINTK(args...) printk(args)
+#else
+#define PRINTK(args...)
+#endif /* GENERAL_DEBUG */
+
+#ifdef EXTRA_DEBUG
+#define XPRINTK(args...) printk(args)
+#else
+#define XPRINTK(args...)
+#endif /* EXTRA_DEBUG */
+
+
+/* Macros *********************************************************************/
+
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+#define CMD_BUSY(card) (readl((card)->membase + STAT) & NS_STAT_CMDBZ)
+
+#define NS_DELAY mdelay(1)
+
+#define ALIGN_ADDRESS(addr, alignment) \
+        ((((u32) (addr)) + (((u32) (alignment)) - 1)) & ~(((u32) (alignment)) - 1))
+
+#undef CEIL(d)
+
+
+/* Version definition *********************************************************/
+/*
+#include <linux/version.h>
+char kernel_version[] = UTS_RELEASE;
+*/
+
+/* Function declarations ******************************************************/
+
+static u32 ns_read_sram(ns_dev *card, u32 sram_address);
+static void ns_write_sram(ns_dev *card, u32 sram_address, u32 *value, int count);
+static int ns_init_card(int i, struct pci_dev *pcidev);
+static void ns_init_card_error(ns_dev *card, int error);
+static scq_info *get_scq(int size, u32 scd);
+static void free_scq(scq_info *scq, struct atm_vcc *vcc);
+static void push_rxbufs(ns_dev *card, u32 type, u32 handle1, u32 addr1,
+                       u32 handle2, u32 addr2);
+static void ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
+static int ns_open(struct atm_vcc *vcc, short vpi, int vci);
+static void ns_close(struct atm_vcc *vcc);
+static void fill_tst(ns_dev *card, int n, vc_map *vc);
+static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb);
+static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
+                     struct sk_buff *skb);
+static void process_tsq(ns_dev *card);
+static void drain_scq(ns_dev *card, scq_info *scq, int pos);
+static void process_rsq(ns_dev *card);
+static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe);
+#ifdef NS_USE_DESTRUCTORS
+static void ns_sb_destructor(struct sk_buff *sb);
+static void ns_lb_destructor(struct sk_buff *lb);
+static void ns_hb_destructor(struct sk_buff *hb);
+#endif /* NS_USE_DESTRUCTORS */
+static void recycle_rx_buf(ns_dev *card, struct sk_buff *skb);
+static void recycle_iovec_rx_bufs(ns_dev *card, struct iovec *iov, int count);
+static void recycle_iov_buf(ns_dev *card, struct sk_buff *iovb);
+static void dequeue_sm_buf(ns_dev *card, struct sk_buff *sb);
+static void dequeue_lg_buf(ns_dev *card, struct sk_buff *lb);
+static int ns_proc_read(struct atm_dev *dev, loff_t *pos, char *page);
+static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void *arg);
+static void which_list(ns_dev *card, struct sk_buff *skb);
+static void ns_poll(unsigned long arg);
+
+
+/* Global variables ***********************************************************/
+
+static struct ns_dev *cards[NS_MAX_CARDS];
+static unsigned num_cards = 0;
+static struct atmdev_ops atm_ops =
+{
+   NULL,		/* dev_close */
+   ns_open,		/* open */
+   ns_close,		/* close */
+   ns_ioctl,		/* ioctl */
+   NULL,		/* getsockopt */
+   NULL,		/* setsockopt */
+   ns_send,		/* send */
+   NULL,		/* sg_send */
+   NULL,		/* send_oam */
+   NULL,		/* phy_put */
+   NULL,		/* phy_get */
+   NULL,		/* feedback */
+   NULL,		/* change_qos */
+   NULL,		/* free_rx_skb */
+   ns_proc_read		/* proc_read */
+};
+static struct timer_list ns_timer;
+
+
+/* Functions*******************************************************************/
+
+#ifdef MODULE
+
+int init_module(void)
+{
+   int i;
+   unsigned error = 0;	/* Initialized to remove compile warning */
+   struct pci_dev *pcidev;
+
+   XPRINTK("nicstar: init_module() called.\n");
+   if(!pci_present())
+   {
+      printk("nicstar: no PCI subsystem found.\n");
+      return -EIO;
+   }
+
+   for(i = 0; i < NS_MAX_CARDS; i++)
+      cards[i] = NULL;
+
+   pcidev = NULL;
+   for(i = 0; i < NS_MAX_CARDS; i++)
+   {
+      if ((pcidev = pci_find_device(PCI_VENDOR_ID_IDT,
+                                    PCI_DEVICE_ID_IDT_IDT77201,
+                                    pcidev)) == NULL)
+         break;
+
+      error = ns_init_card(i, pcidev);
+      if (error)
+         i--;		/* Try to find another card but don't increment index */
+   }
+
+   if (i == 0)
+   {
+      if (!error)
+      {
+         printk("nicstar: no cards found.\n");
+         return -ENXIO;
+      }
+      else
+         return -EIO;
+   }
+   TXPRINTK("nicstar: TX debug enabled.\n");
+   RXPRINTK("nicstar: RX debug enabled.\n");
+   PRINTK("nicstar: General debug enabled.\n");
+#ifdef PHY_LOOPBACK
+   printk("nicstar: using PHY loopback.\n");
+#endif /* PHY_LOOPBACK */
+   XPRINTK("nicstar: init_module() returned.\n");
+
+   ns_timer.next = NULL;
+   ns_timer.prev = NULL;
+   ns_timer.expires = jiffies + NS_POLL_PERIOD;
+   ns_timer.data = 0UL;
+   ns_timer.function = ns_poll;
+   add_timer(&ns_timer);
+   return 0;
+}
+
+
+
+void cleanup_module(void)
+{
+   int i, j;
+   unsigned short pci_command;
+   ns_dev *card;
+   struct sk_buff *hb;
+   struct sk_buff *iovb;
+   struct sk_buff *lb;
+   struct sk_buff *sb;
+   
+   XPRINTK("nicstar: cleanup_module() called.\n");
+
+   if (MOD_IN_USE)
+      printk("nicstar: module in use, remove delayed.\n");
+
+   del_timer(&ns_timer);
+
+   for (i = 0; i < NS_MAX_CARDS; i++)
+   {
+      if (cards[i] == NULL)
+         continue;
+
+      card = cards[i];
+
+      /* Stop everything */
+      writel(0x00000000, card->membase + CFG);
+
+      /* De-register device */
+      atm_dev_deregister(card->atmdev);
+
+      /* Disable memory mapping and busmastering */
+      if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command) != 0)
+      {
+         printk("nicstar%d: can't read PCI_COMMAND.\n", i);
+      }
+      pci_command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+      if (pci_write_config_word(card->pcidev, PCI_COMMAND, pci_command) != 0)
+      {
+         printk("nicstar%d: can't write PCI_COMMAND.\n", i);
+      }
+      
+      /* Free up resources */
+      j = 0;
+      PRINTK("nicstar%d: freeing %d huge buffers.\n", i, card->hbpool.count);
+      while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL)
+      {
+         kfree_skb(hb);
+	 j++;
+      }
+      PRINTK("nicstar%d: %d huge buffers freed.\n", i, j);
+      j = 0;
+      PRINTK("nicstar%d: freeing %d iovec buffers.\n", i, card->iovpool.count);
+      while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL)
+      {
+         kfree_skb(iovb);
+         j++;
+      }
+      PRINTK("nicstar%d: %d iovec buffers freed.\n", i, j);
+      while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL)
+         kfree_skb(lb);
+      while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL)
+         kfree_skb(sb);
+      free_scq(card->scq0, NULL);
+      for (j = 0; j < NS_FRSCD_NUM; j++)
+      {
+         if (card->scd2vc[j] != NULL)
+	    free_scq(card->scd2vc[j]->scq, card->scd2vc[j]->tx_vcc);
+      }
+      kfree(card->rsq.org);
+      kfree(card->tsq.org);
+      free_irq(card->pcidev->irq, card);
+      iounmap((void *) card->membase);
+      kfree(card);
+      
+   }
+   XPRINTK("nicstar: cleanup_module() returned.\n");
+}
+
+
+#else
+
+__initfunc(int nicstar_detect(void))
+{
+   int i;
+   unsigned error = 0;	/* Initialized to remove compile warning */
+   struct pci_dev *pcidev;
+
+   if(!pci_present())
+   {
+      printk("nicstar: no PCI subsystem found.\n");
+      return -EIO;
+   }
+
+   for(i = 0; i < NS_MAX_CARDS; i++)
+      cards[i] = NULL;
+
+   pcidev = NULL;
+   for(i = 0; i < NS_MAX_CARDS; i++)
+   {
+      if ((pcidev = pci_find_device(PCI_VENDOR_ID_IDT,
+                                    PCI_DEVICE_ID_IDT_IDT77201,
+                                    pcidev)) == NULL)
+         break;
+
+      error = ns_init_card(i, pcidev);
+      if (error)
+         i--;		/* Try to find another card but don't increment index */
+   }
+
+   if (i == 0 && error)
+      return -EIO;
+
+   TXPRINTK("nicstar: TX debug enabled.\n");
+   RXPRINTK("nicstar: RX debug enabled.\n");
+   PRINTK("nicstar: General debug enabled.\n");
+#ifdef PHY_LOOPBACK
+   printk("nicstar: using PHY loopback.\n");
+#endif /* PHY_LOOPBACK */
+   XPRINTK("nicstar: init_module() returned.\n");
+
+   return i;
+}
+
+
+#endif /* MODULE */
+
+
+static u32 ns_read_sram(ns_dev *card, u32 sram_address)
+{
+   unsigned long flags;
+   u32 data;
+   sram_address <<= 2;
+   sram_address &= 0x0007FFFC;	/* address must be dword aligned */
+   sram_address |= 0x50000000;	/* SRAM read command */
+   save_flags(flags); cli();
+   while (CMD_BUSY(card));
+   writel(sram_address, card->membase + CMD);
+   while (CMD_BUSY(card));
+   data = readl(card->membase + DR0);
+   restore_flags(flags);
+   return data;
+}
+
+
+   
+static void ns_write_sram(ns_dev *card, u32 sram_address, u32 *value, int count)
+{
+   unsigned long flags;
+   int i, c;
+   count--;	/* count range now is 0..3 instead of 1..4 */
+   c = count;
+   c <<= 2;	/* to use increments of 4 */
+   save_flags(flags); cli();
+   while (CMD_BUSY(card));
+   for (i = 0; i <= c; i += 4)
+      writel(*(value++), card->membase + i);
+   /* Note: DR# registers are the first 4 dwords in nicstar's memspace,
+            so card->membase + DR0 == card->membase */
+   sram_address <<= 2;
+   sram_address &= 0x0007FFFC;
+   sram_address |= (0x40000000 | count);
+   writel(sram_address, card->membase + CMD);
+   restore_flags(flags);
+}
+
+
+static int ns_init_card(int i, struct pci_dev *pcidev)
+{
+   int j;
+   struct ns_dev *card;
+   unsigned short pci_command;
+   unsigned char pci_latency;
+   unsigned error;
+   u32 data;
+   u32 u32d[4];
+   u32 ns_cfg_rctsize;
+   int bcount;
+
+   error = 0;
+
+   if ((card = kmalloc(sizeof(ns_dev), GFP_KERNEL)) == NULL)
+   {
+      printk("nicstar%d: can't allocate memory for device structure.\n", i);
+      error = 2;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   cards[i] = card;
+      
+   card->index = i;
+   card->pcidev = pcidev;
+   card->membase = (u32) (pcidev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK);
+   card->membase = (u32) ioremap(card->membase, NS_IOREMAP_SIZE);
+   if (card->membase == (u32) (NULL))
+   {
+      printk("nicstar%d: can't ioremap() membase.\n",i);
+      error = 3;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   PRINTK("nicstar%d: membase at 0x%x.\n", i, card->membase);
+
+   if (pci_read_config_word(pcidev, PCI_COMMAND, &pci_command) != 0)
+   {
+      printk("nicstar%d: can't read PCI_COMMAND.\n", i);
+      error = 4;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   pci_command |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+   if (pci_write_config_word(pcidev, PCI_COMMAND, pci_command) != 0)
+   {
+      printk("nicstar%d: can't write PCI_COMMAND.\n", i);
+      error = 5;
+      ns_init_card_error(card, error);
+      return error;
+   }
+
+   if (pci_read_config_byte(pcidev, PCI_LATENCY_TIMER, &pci_latency) != 0)
+   {
+      printk("nicstar%d: can't read PCI latency timer.\n", i);
+      error = 6;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   if (pci_latency < NS_PCI_LATENCY)
+   {
+      PRINTK("nicstar%d: setting PCI latency timer to %d.\n", i, NS_PCI_LATENCY);
+      for (j = 1; j < 4; j++)
+      {
+         if (pci_write_config_byte(pcidev, PCI_LATENCY_TIMER, NS_PCI_LATENCY) != 0);
+	    break;
+      }
+      if (j == 10)
+      {
+         printk("nicstar%d: can't set PCI latency timer to %d.\n", i, NS_PCI_LATENCY);
+         error = 7;
+         ns_init_card_error(card, error);
+	 return error;
+      }
+   }
+      
+   /* Clear timer overflow */
+   data = readl(card->membase + STAT);
+   if (data & NS_STAT_TMROF)
+      writel(NS_STAT_TMROF, card->membase + STAT);
+
+   /* Software reset */
+   writel(NS_CFG_SWRST, card->membase + CFG);
+   NS_DELAY;
+   writel(0x00000000, card->membase + CFG);
+
+   /* PHY reset */
+   writel(0x00000008, card->membase + GP);
+   NS_DELAY;
+   writel(0x00000001, card->membase + GP);
+   NS_DELAY;
+   while (CMD_BUSY(card));
+   writel(NS_CMD_WRITE_UTILITY | 0x00000100, card->membase + CMD);	/* Sync UTOPIA with SAR clock */
+   NS_DELAY;
+      
+   /* Detect PHY type */
+   while (CMD_BUSY(card));
+   writel(NS_CMD_READ_UTILITY | 0x00000200, card->membase + CMD);
+   while (CMD_BUSY(card));
+   data = readl(card->membase + DR0);
+   if (data == 0x00000009)
+   {
+      printk("nicstar%d: PHY seems to be 25 Mbps.\n", i);
+      card->max_pcr = IDT_25_PCR;
+      while(CMD_BUSY(card));
+      writel(0x00000008, card->membase + DR0);
+      writel(NS_CMD_WRITE_UTILITY | 0x00000200, card->membase + CMD);
+      /* Clear an eventual pending interrupt */
+      writel(NS_STAT_SFBQF, card->membase + STAT);
+#ifdef PHY_LOOPBACK
+      while(CMD_BUSY(card));
+      writel(0x00000022, card->membase + DR0);
+      writel(NS_CMD_WRITE_UTILITY | 0x00000202, card->membase + CMD);
+#endif /* PHY_LOOPBACK */
+   }
+   else if (data == 0x00000030)
+   {
+      printk("nicstar%d: PHY seems to be 155 Mbps.\n", i);
+      card->max_pcr = ATM_OC3_PCR;
+#ifdef PHY_LOOPBACK
+      while(CMD_BUSY(card));
+      writel(0x00000002, card->membase + DR0);
+      writel(NS_CMD_WRITE_UTILITY | 0x00000205, card->membase + CMD);
+#endif /* PHY_LOOPBACK */
+   }
+   else
+   {
+      printk("nicstar%d: can't determine PHY type.\n", i);
+      error = 8;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   writel(0x00000000, card->membase + GP);
+
+   /* Determine SRAM size */
+   data = 0x76543210;
+   ns_write_sram(card, 0x1C003, &data, 1);
+   data = 0x89ABCDEF;
+   ns_write_sram(card, 0x14003, &data, 1);
+   if (ns_read_sram(card, 0x14003) == 0x89ABCDEF &&
+       ns_read_sram(card, 0x1C003) == 0x76543210)
+       card->sram_size = 128;
+   else
+      card->sram_size = 32;
+   PRINTK("nicstar%d: %dK x 32bit SRAM size.\n", i, card->sram_size);
+
+   card->rct_size = NS_MAX_RCTSIZE;
+
+#if (NS_MAX_RCTSIZE == 4096)
+   if (card->sram_size == 128)
+      printk("nicstar%d: limiting maximum VCI. See NS_MAX_RCTSIZE in nicstar.h\n", i);
+#elif (NS_MAX_RCTSIZE == 16384)
+   if (card->sram_size == 32)
+   {
+      printk("nicstar%d: wasting memory. See NS_MAX_RCTSIZE in nicstar.h\n", i);
+      card->rct_size = 4096;
+   }
+#else
+#error NS_MAX_RCTSIZE must be either 4096 or 16384 in nicstar.c
+#endif
+
+   card->vpibits = NS_VPIBITS;
+   if (card->rct_size == 4096)
+      card->vcibits = 12 - NS_VPIBITS;
+   else /* card->rct_size == 16384 */
+      card->vcibits = 14 - NS_VPIBITS;
+
+#ifdef ESI_FROM_EPROM
+   /* Initialize the nicstar eeprom/eprom stuff, for the MAC addr */
+   nicstar_init_eprom(card->membase);
+#endif /* ESI_FROM_EPROM */
+
+   if (request_irq(pcidev->irq, &ns_irq_handler, SA_INTERRUPT, "nicstar", card) != 0)
+   {
+      printk("nicstar%d: can't allocate IRQ.\n", i);
+      error = 9;
+      ns_init_card_error(card, error);
+      return error;
+   }
+
+   /* Set the VPI/VCI MSb mask to zero so we can receive OAM cells */
+   writel(0x00000000, card->membase + VPM);
+      
+   /* Initialize TSQ */
+   card->tsq.org = kmalloc(NS_TSQSIZE + NS_TSQ_ALIGNMENT, GFP_KERNEL);
+   if (card->tsq.org == NULL)
+   {
+      printk("nicstar%d: can't allocate TSQ.\n", i);
+      error = 10;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   card->tsq.base = (ns_tsi *) ALIGN_ADDRESS(card->tsq.org, NS_TSQ_ALIGNMENT);
+   card->tsq.next = card->tsq.base;
+   card->tsq.last = card->tsq.base + (NS_TSQ_NUM_ENTRIES - 1);
+   for (j = 0; j < NS_TSQ_NUM_ENTRIES; j++)
+      ns_tsi_init(card->tsq.base + j);
+   writel(0x00000000, card->membase + TSQH);
+   writel((u32) virt_to_bus(card->tsq.base), card->membase + TSQB);
+   PRINTK("nicstar%d: TSQ base at 0x%x  0x%x  0x%x.\n", i, (u32) card->tsq.base,
+          (u32) virt_to_bus(card->tsq.base), readl(card->membase + TSQB));
+      
+   /* Initialize RSQ */
+   card->rsq.org = kmalloc(NS_RSQSIZE + NS_RSQ_ALIGNMENT, GFP_KERNEL);
+   if (card->rsq.org == NULL)
+   {
+      printk("nicstar%d: can't allocate RSQ.\n", i);
+      error = 11;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   card->rsq.base = (ns_rsqe *) ALIGN_ADDRESS(card->rsq.org, NS_RSQ_ALIGNMENT);
+   card->rsq.next = card->rsq.base;
+   card->rsq.last = card->rsq.base + (NS_RSQ_NUM_ENTRIES - 1);
+   for (j = 0; j < NS_RSQ_NUM_ENTRIES; j++)
+      ns_rsqe_init(card->rsq.base + j);
+   writel(0x00000000, card->membase + RSQH);
+   writel((u32) virt_to_bus(card->rsq.base), card->membase + RSQB);
+   PRINTK("nicstar%d: RSQ base at 0x%x.\n", i, (u32) card->rsq.base);
+      
+   /* Initialize SCQ0, the only VBR SCQ used */
+   card->scq1 = (scq_info *) NULL;
+   card->scq2 = (scq_info *) NULL;
+   card->scq0 = get_scq(VBR_SCQSIZE, NS_VRSCD0);
+   if (card->scq0 == (scq_info *) NULL)
+   {
+      printk("nicstar%d: can't get SCQ0.\n", i);
+      error = 12;
+      ns_init_card_error(card, error);
+      return error;
+   }
+   u32d[0] = (u32) virt_to_bus(card->scq0->base);
+   u32d[1] = (u32) 0x00000000;
+   u32d[2] = (u32) 0xffffffff;
+   u32d[3] = (u32) 0x00000000;
+   ns_write_sram(card, NS_VRSCD0, u32d, 4);
+   ns_write_sram(card, NS_VRSCD1, u32d, 4);	/* These last two won't be used */
+   ns_write_sram(card, NS_VRSCD2, u32d, 4);	/* but are initialized, just in case... */
+   card->scq0->scd = NS_VRSCD0;
+   PRINTK("nicstar%d: VBR-SCQ0 base at 0x%x.\n", i, (u32) card->scq0->base);
+
+   /* Initialize TSTs */
+   card->tst_addr = NS_TST0;
+   card->tst_free_entries = NS_TST_NUM_ENTRIES;
+   data = NS_TST_OPCODE_VARIABLE;
+   for (j = 0; j < NS_TST_NUM_ENTRIES; j++)
+      ns_write_sram(card, NS_TST0 + j, &data, 1);
+   data = ns_tste_make(NS_TST_OPCODE_END, NS_TST0);
+   ns_write_sram(card, NS_TST0 + NS_TST_NUM_ENTRIES, &data, 1);
+   for (j = 0; j < NS_TST_NUM_ENTRIES; j++)
+      ns_write_sram(card, NS_TST1 + j, &data, 1);
+   data = ns_tste_make(NS_TST_OPCODE_END, NS_TST1);
+   ns_write_sram(card, NS_TST1 + NS_TST_NUM_ENTRIES, &data, 1);
+   for (j = 0; j < NS_TST_NUM_ENTRIES; j++)
+      card->tste2vc[j] = NULL;
+   writel(NS_TST0 << 2, card->membase + TSTB);
+
+
+   /* Initialize RCT. AAL type is set on opening the VC. */
+#ifdef RCQ_SUPPORT
+   u32d[0] = NS_RCTE_RAWCELLINTEN;
+#else
+   u32d[0] = 0x00000000;
+#endif RCQ_SUPPORT
+   u32d[1] = 0x00000000;
+   u32d[2] = 0x00000000;
+   u32d[3] = 0xFFFFFFFF;
+   for (j = 0; j < card->rct_size; j++)
+      ns_write_sram(card, j * 4, u32d, 4);      
+      
+   memset(card->vcmap, 0, NS_MAX_RCTSIZE * sizeof(vc_map));
+      
+   for (j = 0; j < NS_FRSCD_NUM; j++)
+      card->scd2vc[j] = NULL;
+
+   /* Initialize buffer levels */
+   card->sbnr.min = MIN_SB;
+   card->sbnr.init = NUM_SB;
+   card->sbnr.max = MAX_SB;
+   card->lbnr.min = MIN_LB;
+   card->lbnr.init = NUM_LB;
+   card->lbnr.max = MAX_LB;
+   card->iovnr.min = MIN_IOVB;
+   card->iovnr.init = NUM_IOVB;
+   card->iovnr.max = MAX_IOVB;
+   card->hbnr.min = MIN_HB;
+   card->hbnr.init = NUM_HB;
+   card->hbnr.max = MAX_HB;
+   
+   card->sm_handle = 0x00000000;
+   card->sm_addr = 0x00000000;
+   card->lg_handle = 0x00000000;
+   card->lg_addr = 0x00000000;
+   
+   card->efbie = 1;	/* To prevent push_rxbufs from enabling the interrupt */
+
+   /* Allocate small buffers */
+   skb_queue_head_init(&card->sbpool.queue);
+   card->sbpool.count = 0;			/* Not used */
+   for (j = 0; j < NUM_SB; j++)
+   {
+      struct sk_buff *sb;
+      sb = alloc_skb(NS_SMSKBSIZE, GFP_KERNEL);
+      if (sb == NULL)
+      {
+         printk("nicstar%d: can't allocate %dth of %d small buffers.\n",
+                i, j, NUM_SB);
+         error = 13;
+         ns_init_card_error(card, error);
+	 return error;
+      }
+      skb_queue_tail(&card->sbpool.queue, sb);
+      skb_reserve(sb, NS_AAL0_HEADER);
+      push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data), 0, 0);
+   }
+   /* Test for strange behaviour which leads to crashes */
+   if ((bcount = ns_stat_sfbqc_get(readl(card->membase + STAT))) < card->sbnr.min)
+   {
+      printk("nicstar%d: Strange... Just allocated %d small buffers and sfbqc = %d.\n",
+             i, j, bcount);
+      error = 13;
+      ns_init_card_error(card, error);
+      return error;
+   }
+      
+
+   /* Allocate large buffers */
+   skb_queue_head_init(&card->lbpool.queue);
+   card->lbpool.count = 0;			/* Not used */
+   for (j = 0; j < NUM_LB; j++)
+   {
+      struct sk_buff *lb;
+      lb = alloc_skb(NS_LGSKBSIZE, GFP_KERNEL);
+      if (lb == NULL)
+      {
+         printk("nicstar%d: can't allocate %dth of %d large buffers.\n",
+                i, j, NUM_LB);
+         error = 14;
+         ns_init_card_error(card, error);
+	 return error;
+      }
+      skb_queue_tail(&card->lbpool.queue, lb);
+      skb_reserve(lb, NS_SMBUFSIZE);
+      push_rxbufs(card, BUF_LG, (u32) lb, (u32) virt_to_bus(lb->data), 0, 0);
+      /* Due to the implementation of push_rxbufs() this is 1, not 0 */
+      if (j == 1)
+      {
+         card->rcbuf = lb;
+         card->rawch = (u32) virt_to_bus(lb->data);
+      }
+   }
+   /* Test for strange behaviour which leads to crashes */
+   if ((bcount = ns_stat_lfbqc_get(readl(card->membase + STAT))) < card->lbnr.min)
+   {
+      printk("nicstar%d: Strange... Just allocated %d large buffers and lfbqc = %d.\n",
+             i, j, bcount);
+      error = 14;
+      ns_init_card_error(card, error);
+      return error;
+   }
+      
+
+   /* Allocate iovec buffers */
+   skb_queue_head_init(&card->iovpool.queue);
+   card->iovpool.count = 0;
+   for (j = 0; j < NUM_IOVB; j++)
+   {
+      struct sk_buff *iovb;
+      iovb = alloc_skb(NS_IOVBUFSIZE, GFP_KERNEL);
+      if (iovb == NULL)
+      {
+         printk("nicstar%d: can't allocate %dth of %d iovec buffers.\n",
+                i, j, NUM_IOVB);
+         error = 15;
+         ns_init_card_error(card, error);
+	 return error;
+      }
+      skb_queue_tail(&card->iovpool.queue, iovb);
+      card->iovpool.count++;
+   }
+
+
+   /* Pre-allocate some huge buffers */
+   skb_queue_head_init(&card->hbpool.queue);
+   card->hbpool.count = 0;
+   for (j = 0; j < NUM_HB; j++)
+   {
+      struct sk_buff *hb;
+      hb = alloc_skb(NS_HBUFSIZE, GFP_KERNEL);
+      if (hb == NULL)
+      {
+         printk("nicstar%d: can't allocate %dth of %d huge buffers.\n",
+                i, j, NUM_HB);
+         error = 16;
+         ns_init_card_error(card, error);
+	 return error;
+      }
+      skb_queue_tail(&card->hbpool.queue, hb);
+      card->hbpool.count++;
+   }
+
+   card->in_handler = 0;
+   card->in_poll = 0;
+   card->intcnt = 0;
+
+   /* Configure NICStAR */
+   if (card->rct_size == 4096)
+      ns_cfg_rctsize = NS_CFG_RCTSIZE_4096_ENTRIES;
+   else /* (card->rct_size == 16384) */
+      ns_cfg_rctsize = NS_CFG_RCTSIZE_16384_ENTRIES;
+
+   card->efbie = 1;
+   writel(NS_CFG_RXPATH |
+          NS_CFG_SMBUFSIZE |
+          NS_CFG_LGBUFSIZE |
+          NS_CFG_EFBIE |
+          NS_CFG_RSQSIZE |
+          NS_CFG_VPIBITS |
+          ns_cfg_rctsize |
+          NS_CFG_RXINT_NODELAY |
+          NS_CFG_RAWIE |		/* Only enabled if RCQ_SUPPORT */
+          NS_CFG_RSQAFIE |
+          NS_CFG_TXEN |
+          NS_CFG_TXIE |
+          NS_CFG_TSQFIE_OPT,		/* Only enabled if ENABLE_TSQFIE */ 
+          card->membase + CFG);
+
+   /* Register device */
+   card->atmdev = atm_dev_register("nicstar", &atm_ops, -1, 0UL);
+   if (card->atmdev == NULL)
+   {
+      printk("nicstar%d: can't register device.\n", i);
+      error = 17;
+      ns_init_card_error(card, error);
+      return error;
+   }
+      
+#ifdef ESI_FROM_EPROM
+   nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET,
+                      card->atmdev->esi, 6);
+   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[3], card->atmdev->esi[4], card->atmdev->esi[5]);
+#else
+   card->atmdev->esi[0] = NS_ESI0;
+   card->atmdev->esi[1] = NS_ESI1;
+   card->atmdev->esi[2] = NS_ESI2;
+   card->atmdev->esi[3] = NS_ESI3;
+   card->atmdev->esi[4] = NS_ESI4;
+   card->atmdev->esi[5] = NS_ESI5;
+#endif /* ESI_FROM_EPROM */
+
+   card->atmdev->dev_data = card;
+   card->atmdev->ci_range.vpi_bits = card->vpibits;
+   card->atmdev->ci_range.vci_bits = card->vcibits;
+
+   num_cards++;
+
+   return error;
+}
+
+
+
+static void ns_init_card_error(ns_dev *card, int error)
+{
+   if (error >= 17)
+   {
+      writel(0x00000000, card->membase + CFG);
+   }
+   if (error >= 16)
+   {
+      struct sk_buff *hb;
+      while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL)
+         kfree_skb(hb);
+   }
+   if (error >= 15)
+   {
+      struct sk_buff *iovb;
+      while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL)
+         kfree_skb(iovb);
+   }
+   if (error >= 14)
+   {
+      struct sk_buff *lb;
+      while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL)
+         kfree_skb(lb);
+   }
+   if (error >= 13)
+   {
+      struct sk_buff *sb;
+      while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL)
+         kfree_skb(sb);
+      free_scq(card->scq0, NULL);
+   }
+   if (error >= 12)
+   {
+      kfree(card->rsq.org);
+   }
+   if (error >= 11)
+   {
+      kfree(card->tsq.org);
+   }
+   if (error >= 10)
+   {
+      free_irq(card->pcidev->irq, card);
+   }
+   if (error >= 4)
+   {
+      iounmap((void *) card->membase);
+   }
+   if (error >= 3)
+   {
+      kfree(card);
+   }
+}
+
+
+
+static scq_info *get_scq(int size, u32 scd)
+{
+   scq_info *scq;
+   int i;
+
+   if (size != VBR_SCQSIZE && size != CBR_SCQSIZE)
+      return (scq_info *) NULL;
+
+   scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL);
+   if (scq == (scq_info *) NULL)
+      return (scq_info *) NULL;
+   scq->org = kmalloc(2 * size, GFP_KERNEL);
+   if (scq->org == NULL)
+   {
+      kfree(scq);
+      return (scq_info *) NULL;
+   }
+   scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) *
+                                          (size / NS_SCQE_SIZE), GFP_KERNEL);
+   if (scq->skb == (struct sk_buff **) NULL)
+   {
+      kfree(scq->org);
+      kfree(scq);
+      return (scq_info *) NULL;
+   }
+   scq->num_entries = size / NS_SCQE_SIZE;
+   scq->base = (ns_scqe *) ALIGN_ADDRESS(scq->org, size);
+   scq->next = scq->base;
+   scq->last = scq->base + (scq->num_entries - 1);
+   scq->tail = scq->last;
+   scq->scd = scd;
+   scq->num_entries = size / NS_SCQE_SIZE;
+   scq->tbd_count = 0;
+   scq->scqfull_waitq = NULL;
+   scq->full = 0;
+
+   for (i = 0; i < scq->num_entries; i++)
+      scq->skb[i] = NULL;
+
+   return scq;
+}
+
+
+
+/* For variable rate SCQ vcc must be NULL */
+static void free_scq(scq_info *scq, struct atm_vcc *vcc)
+{
+   int i;
+
+   if (scq->num_entries == VBR_SCQ_NUM_ENTRIES)
+      for (i = 0; i < scq->num_entries; i++)
+      {
+         if (scq->skb[i] != NULL)
+	 {
+            vcc = scq->skb[i]->atm.vcc;
+            if (vcc->pop != NULL)
+	       vcc->pop(vcc, scq->skb[i]);
+	    else
+               dev_kfree_skb(scq->skb[i]);
+         }
+      }
+   else /* vcc must be != NULL */
+   {
+      if (vcc == NULL)
+      {
+         printk("nicstar: free_scq() called with vcc == NULL for fixed rate scq.");
+         for (i = 0; i < scq->num_entries; i++)
+            dev_kfree_skb(scq->skb[i]);
+      }
+      else
+         for (i = 0; i < scq->num_entries; i++)
+         {
+            if (scq->skb[i] != NULL)
+            {
+               if (vcc->pop != NULL)
+                  vcc->pop(vcc, scq->skb[i]);
+               else
+                  dev_kfree_skb(scq->skb[i]);
+            }
+         }
+   }
+   kfree(scq->skb);
+   kfree(scq->org);
+   kfree(scq);
+}
+
+
+
+/* The handles passed must be pointers to the sk_buff containing the small
+   or large buffer(s) cast to u32. */
+static void push_rxbufs(ns_dev *card, u32 type, u32 handle1, u32 addr1,
+                       u32 handle2, u32 addr2)
+{
+   u32 stat;
+   unsigned long flags;
+   
+
+#ifdef GENERAL_DEBUG
+   if (!addr1)
+      printk("nicstar%d: push_rxbufs called with addr1 = 0.\n", card->index);
+#endif /* GENERAL_DEBUG */
+
+   stat = readl(card->membase + STAT);
+   card->sbfqc = ns_stat_sfbqc_get(stat);
+   card->lbfqc = ns_stat_lfbqc_get(stat);
+   if (type == BUF_SM)
+   {
+      if (!addr2)
+      {
+         if (card->sm_addr)
+	 {
+	    addr2 = card->sm_addr;
+	    handle2 = card->sm_handle;
+	    card->sm_addr = 0x00000000;
+	    card->sm_handle = 0x00000000;
+	 }
+	 else /* (!sm_addr) */
+	 {
+	    card->sm_addr = addr1;
+	    card->sm_handle = handle1;
+	 }
+      }      
+   }
+   else /* type == BUF_LG */
+   {
+      if (!addr2)
+      {
+         if (card->lg_addr)
+	 {
+	    addr2 = card->lg_addr;
+	    handle2 = card->lg_handle;
+	    card->lg_addr = 0x00000000;
+	    card->lg_handle = 0x00000000;
+	 }
+	 else /* (!lg_addr) */
+	 {
+	    card->lg_addr = addr1;
+	    card->lg_handle = handle1;
+	 }
+      }      
+   }
+
+   if (addr2)
+   {
+      if (type == BUF_SM)
+      {
+         if (card->sbfqc >= card->sbnr.max)
+         {
+            skb_unlink((struct sk_buff *) handle1);
+            kfree_skb((struct sk_buff *) handle1);
+            skb_unlink((struct sk_buff *) handle2);
+            kfree_skb((struct sk_buff *) handle2);
+            return;
+         }
+	 else
+            card->sbfqc += 2;
+      }
+      else /* (type == BUF_LG) */
+      {
+         if (card->lbfqc >= card->lbnr.max)
+         {
+            skb_unlink((struct sk_buff *) handle1);
+            kfree_skb((struct sk_buff *) handle1);
+            skb_unlink((struct sk_buff *) handle2);
+            kfree_skb((struct sk_buff *) handle2);
+            return;
+         }
+         else
+            card->lbfqc += 2;
+      }
+
+      save_flags(flags); cli();
+
+      while (CMD_BUSY(card));
+      writel(handle1, card->membase + DR0);
+      writel(addr1, card->membase + DR1);
+      writel(handle2, card->membase + DR2);
+      writel(addr2, card->membase + DR3);
+      writel(NS_CMD_WRITE_FREEBUFQ | (u32) type, card->membase + CMD);
+ 
+      restore_flags(flags);
+
+      XPRINTK("nicstar%d: Pushing %s buffers at 0x%x and 0x%x.\n", card->index,
+              (type == BUF_SM ? "small" : "large"), addr1, addr2);
+   }
+
+   if (!card->efbie && card->sbfqc >= card->sbnr.min &&
+       card->lbfqc >= card->lbnr.min)
+   {
+      card->efbie = 1;
+      writel((readl(card->membase + CFG) | NS_CFG_EFBIE), card->membase + CFG);
+   }
+
+   return;
+}
+
+
+
+static void ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+   u32 stat_r;
+   ns_dev *card;
+
+   card = (ns_dev *) dev_id;
+   card->intcnt++;
+
+   PRINTK("nicstar%d: NICStAR generated an interrupt\n", card->index);
+
+   if (card->in_handler)
+   {
+      printk("nicstar%d: Re-entering ns_irq_handler()???\n", card->index);
+      return;
+   }
+   card->in_handler = 1;
+   if (card->in_poll)
+   {
+      card->in_handler = 0;
+      printk("nicstar%d: Called irq handler while in ns_poll()!?\n",
+             card->index);
+      return;
+   }
+   
+   stat_r = readl(card->membase + STAT);
+
+   /* Transmit Status Indicator has been written to T. S. Queue */
+   if (stat_r & NS_STAT_TSIF)
+   {
+      TXPRINTK("nicstar%d: TSI interrupt\n", card->index);
+      process_tsq(card);
+      writel(NS_STAT_TSIF, card->membase + STAT);
+   }
+   
+   /* Incomplete CS-PDU has been transmitted */
+   if (stat_r & NS_STAT_TXICP)
+   {
+      writel(NS_STAT_TXICP, card->membase + STAT);
+      TXPRINTK("nicstar%d: Incomplete CS-PDU transmitted.\n",
+               card->index);
+   }
+   
+   /* Transmit Status Queue 7/8 full */
+   if (stat_r & NS_STAT_TSQF)
+   {
+      writel(NS_STAT_TSQF, card->membase + STAT);
+      PRINTK("nicstar%d: TSQ full.\n", card->index);
+      process_tsq(card);
+   }
+   
+   /* Timer overflow */
+   if (stat_r & NS_STAT_TMROF)
+   {
+      writel(NS_STAT_TMROF, card->membase + STAT);
+      PRINTK("nicstar%d: Timer overflow.\n", card->index);
+   }
+   
+   /* PHY device interrupt signal active */
+   if (stat_r & NS_STAT_PHYI)
+   {
+      writel(NS_STAT_PHYI, card->membase + STAT);
+      printk("nicstar%d: PHY interrupt.\n", card->index);
+   }
+
+   /* Small Buffer Queue is full */
+   if (stat_r & NS_STAT_SFBQF)
+   {
+      writel(NS_STAT_SFBQF, card->membase + STAT);
+      printk("nicstar%d: Small free buffer queue is full.\n", card->index);
+   }
+   
+   /* Large Buffer Queue is full */
+   if (stat_r & NS_STAT_LFBQF)
+   {
+      writel(NS_STAT_LFBQF, card->membase + STAT);
+      printk("nicstar%d: Large free buffer queue is full.\n", card->index);
+   }
+
+   /* Receive Status Queue is full */
+   if (stat_r & NS_STAT_RSQF)
+   {
+      writel(NS_STAT_RSQF, card->membase + STAT);
+      printk("nicstar%d: RSQ full.\n", card->index);
+      process_rsq(card);
+   }
+
+   /* Complete CS-PDU received */
+   if (stat_r & NS_STAT_EOPDU)
+   {
+      RXPRINTK("nicstar%d: End of CS-PDU received.\n", card->index);
+      process_rsq(card);
+      writel(NS_STAT_EOPDU, card->membase + STAT);
+   }
+
+   /* Raw cell received */
+   if (stat_r & NS_STAT_RAWCF)
+   {
+      writel(NS_STAT_RAWCF, card->membase + STAT);
+#ifndef RCQ_SUPPORT
+      printk("nicstar%d: Raw cell received and no support yet...\n",
+             card->index);
+#endif /* RCQ_SUPPORT */
+      /* NOTE: the following procedure may keep a raw cell pending untill the
+               next interrupt. As this preliminary support is only meant to
+               avoid buffer leakage, this is not an issue. */
+      while (readl(card->membase + RAWCT) != card->rawch)
+      {
+         ns_rcqe *rawcell;
+
+         rawcell = (ns_rcqe *) bus_to_virt(card->rawch);
+         if (ns_rcqe_islast(rawcell))
+         {
+            struct sk_buff *oldbuf;
+
+            oldbuf = card->rcbuf;
+            card->rcbuf = (struct sk_buff *) ns_rcqe_nextbufhandle(rawcell);
+            card->rawch = (u32) virt_to_bus(card->rcbuf->data);
+            recycle_rx_buf(card, oldbuf);
+         }
+         else
+            card->rawch += NS_RCQE_SIZE;
+      }
+   }
+
+   /* Small buffer queue is empty */
+   if (stat_r & NS_STAT_SFBQE)
+   {
+      int i;
+      struct sk_buff *sb;
+
+      writel(NS_STAT_SFBQE, card->membase + STAT);
+      printk("nicstar%d: Small free buffer queue empty.\n",
+             card->index);
+      for (i = 0; i < card->sbnr.min; i++)
+      {
+         sb = alloc_skb(NS_SMSKBSIZE, GFP_ATOMIC);
+         if (sb == NULL)
+         {
+            writel(readl(card->membase + CFG) & ~NS_CFG_EFBIE, card->membase + CFG);
+            card->efbie = 0;
+            break;
+         }
+         skb_queue_tail(&card->sbpool.queue, sb);
+         skb_reserve(sb, NS_AAL0_HEADER);
+         push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data), 0, 0);
+      }
+      card->sbfqc = i;
+      process_rsq(card);
+   }
+
+   /* Large buffer queue empty */
+   if (stat_r & NS_STAT_LFBQE)
+   {
+      int i;
+      struct sk_buff *lb;
+
+      writel(NS_STAT_LFBQE, card->membase + STAT);
+      printk("nicstar%d: Large free buffer queue empty.\n",
+             card->index);
+      for (i = 0; i < card->lbnr.min; i++)
+      {
+         lb = alloc_skb(NS_LGSKBSIZE, GFP_ATOMIC);
+         if (lb == NULL)
+         {
+            writel(readl(card->membase + CFG) & ~NS_CFG_EFBIE, card->membase + CFG);
+            card->efbie = 0;
+            break;
+         }
+         skb_queue_tail(&card->lbpool.queue, lb);
+         skb_reserve(lb, NS_SMBUFSIZE);
+         push_rxbufs(card, BUF_LG, (u32) lb, (u32) virt_to_bus(lb->data), 0, 0);
+      }
+      card->lbfqc = i;
+      process_rsq(card);
+   }
+
+   /* Receive Status Queue is 7/8 full */
+   if (stat_r & NS_STAT_RSQAF)
+   {
+      writel(NS_STAT_RSQAF, card->membase + STAT);
+      RXPRINTK("nicstar%d: RSQ almost full.\n", card->index);
+      process_rsq(card);
+   }
+   
+   card->in_handler = 0;
+   PRINTK("nicstar%d: end of interrupt service\n", card->index);
+}
+
+
+
+static int ns_open(struct atm_vcc *vcc, short vpi, int vci)
+{
+   ns_dev *card;
+   vc_map *vc;
+   int error;
+   double tmpd;
+   int tcr, tcra;	/* target cell rate, and absolute value */
+   int n = 0;		/* Number of entries in the TST. Initialized to remove
+                           the compiler warning. */
+   u32 u32d[4];
+   int frscdi = 0;	/* Index of the SCD. Initialized to remove the compiler
+                           warning. How I wish compilers were clever enough to
+			   tell which variables can truly be used
+			   uninitialized... */
+   int inuse;		/* tx or rx vc already in use by another vcc */
+
+   card = (ns_dev *) vcc->dev->dev_data;
+   PRINTK("nicstar%d: opening vpi.vci %d.%d \n", card->index, (int) vpi, vci);
+   if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0)
+   {
+      PRINTK("nicstar%d: unsupported AAL.\n", card->index);
+      return -EINVAL;
+   }
+
+   if ((error = atm_find_ci(vcc, &vpi, &vci)))
+   {
+      PRINTK("nicstar%d: error in atm_find_ci().\n", card->index);
+      return error;
+   }
+   vc = &(card->vcmap[vpi << card->vcibits | vci]);
+   vcc->vpi = vpi;
+   vcc->vci = vci;
+   vcc->dev_data = vc;
+
+   inuse = 0;
+   if (vcc->qos.txtp.traffic_class != ATM_NONE && vc->tx)
+      inuse = 1;
+   if (vcc->qos.rxtp.traffic_class != ATM_NONE && vc->rx)
+      inuse += 2;
+   if (inuse)
+   {
+      printk("nicstar%d: %s vci already in use.\n", card->index,
+             inuse == 1 ? "tx" : inuse == 2 ? "rx" : "tx and rx");
+      return -EINVAL;
+   }
+
+   vcc->flags |= ATM_VF_ADDR;
+
+   /* NOTE: You are not allowed to modify an open connection's QOS. To change
+      that, remove the ATM_VF_PARTIAL flag checking. There may be other changes
+      needed to do that. */
+   if (!(vcc->flags & ATM_VF_PARTIAL))
+   {
+      scq_info *scq;
+      
+      vcc->flags |= ATM_VF_PARTIAL;
+      if (vcc->qos.txtp.traffic_class == ATM_CBR)
+      {
+         /* Check requested cell rate and availability of SCD */
+         if (vcc->qos.txtp.max_pcr == 0 && vcc->qos.txtp.pcr == 0 &&
+             vcc->qos.txtp.min_pcr == 0)
+         {
+            PRINTK("nicstar%d: trying to open a CBR vc with cell rate = 0 \n",
+	           card->index);
+            vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+            return -EINVAL;
+         }
+
+         tcr = atm_pcr_goal(&(vcc->qos.txtp));
+         tcra = tcr >= 0 ? tcr : -tcr;
+      
+         PRINTK("nicstar%d: target cell rate = %d.\n", card->index,
+                vcc->qos.txtp.max_pcr);
+
+         tmpd = ((double) tcra) * ((double) NS_TST_NUM_ENTRIES) /
+                ((double) card->max_pcr);      
+
+         n = (int) tmpd;
+         if (tcr > 0)
+         {
+            if (tmpd > (double) n) n++;
+         }
+         else if (tcr < 0)
+         {
+            if (tmpd < (double) n) n--;
+         }
+         else /* tcr == 0 */
+         {
+            if ((n = (card->tst_free_entries - NS_TST_RESERVED)) <= 0)
+	    {
+               PRINTK("nicstar%d: no CBR bandwidth free.\n", card->index);
+	       vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+               return -EINVAL;
+            }
+         }
+
+         if (n == 0)
+         {
+            printk("nicstar%d: selected bandwidth < granularity.\n", card->index);
+            vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+            return -EINVAL;
+         }
+
+         if (vcc->qos.txtp.max_pcr > 0)
+         {
+            tmpd = (double) n * (double) card->max_pcr /
+	           (double) NS_TST_NUM_ENTRIES;
+            if (tmpd > PCR_TOLERANCE * (double) vcc->qos.txtp.max_pcr)
+            {
+               PRINTK("nicstar%d: target cell rate exceeded requested max_pcr.\n",
+                      card->index);
+            }
+         }
+
+         if (n > (card->tst_free_entries - NS_TST_RESERVED))
+         {
+            PRINTK("nicstar%d: not enough free CBR bandwidth.\n", card->index);
+	    vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+            return -EINVAL;
+         }
+         else
+            card->tst_free_entries -= n;
+
+         XPRINTK("nicstar%d: writing %d tst entries.\n", card->index, n);
+         for (frscdi = 0; frscdi < NS_FRSCD_NUM; frscdi++)
+         {
+            if (card->scd2vc[frscdi] == NULL)
+            {
+               card->scd2vc[frscdi] = vc;
+               break;
+	    }
+         }
+         if (frscdi == NS_FRSCD_NUM)
+         {
+            PRINTK("nicstar%d: no SCD available for CBR channel.\n", card->index);
+            card->tst_free_entries += n;
+            vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+	    return -EBUSY;
+         }
+
+         vc->cbr_scd = NS_FRSCD + frscdi * NS_FRSCD_SIZE;
+
+         scq = get_scq(CBR_SCQSIZE, vc->cbr_scd);
+         if (scq == (scq_info *) NULL)
+         {
+            PRINTK("nicstar%d: can't get fixed rate SCQ.\n", card->index);
+            card->scd2vc[frscdi] = NULL;
+            card->tst_free_entries += n;
+            vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+            return -ENOMEM;
+         }
+	 vc->scq = scq;
+         u32d[0] = (u32) virt_to_bus(scq->base);
+         u32d[1] = (u32) 0x00000000;
+         u32d[2] = (u32) 0xffffffff;
+         u32d[3] = (u32) 0x00000000;
+         ns_write_sram(card, vc->cbr_scd, u32d, 4);
+         
+	 fill_tst(card, n, vc);
+      }
+      else /* not CBR */
+      {
+         vc->cbr_scd = 0x00000000;
+	 vc->scq = card->scq0;
+      }
+      
+      if (vcc->qos.txtp.traffic_class != ATM_NONE)
+      {
+         vc->tx = 1;
+	 vc->tx_vcc = vcc;
+	 vc->tbd_count = 0;
+      }
+      if (vcc->qos.rxtp.traffic_class != ATM_NONE)
+      {
+         u32 status;
+      
+         vc->rx = 1;
+         vc->rx_vcc = vcc;
+         vc->rx_iov = NULL;
+
+	 /* Open the connection in hardware */
+	 if (vcc->qos.aal == ATM_AAL5)
+	    status = NS_RCTE_AAL5 | NS_RCTE_CONNECTOPEN;
+	 else /* vcc->qos.aal == ATM_AAL0 */
+	    status = NS_RCTE_AAL0 | NS_RCTE_CONNECTOPEN;
+#ifdef RCQ_SUPPORT
+         status |= NS_RCTE_RAWCELLINTEN;
+#endif /* RCQ_SUPPORT */
+         ns_write_sram(card, NS_RCT + (vpi << card->vcibits | vci) *
+	               NS_RCT_ENTRY_SIZE, &status, 1);
+      }
+      
+   }
+   
+   vcc->flags |= ATM_VF_READY;
+   return 0;
+}
+
+
+
+static void ns_close(struct atm_vcc *vcc)
+{
+   vc_map *vc;
+   ns_dev *card;
+   u32 data;
+   int i;
+   
+   vc = vcc->dev_data;
+   card = vcc->dev->dev_data;
+   PRINTK("nicstar%d: closing vpi.vci %d.%d \n", card->index,
+          (int) vcc->vpi, vcc->vci);
+
+   vcc->flags &= ~(ATM_VF_READY);
+   
+   if (vcc->qos.rxtp.traffic_class != ATM_NONE)
+   {
+      u32 addr;
+      unsigned long flags;
+      
+      addr = NS_RCT + (vcc->vpi << card->vcibits | vcc->vci) * NS_RCT_ENTRY_SIZE;
+      save_flags(flags); cli();
+      while(CMD_BUSY(card));
+      writel(NS_CMD_CLOSE_CONNECTION | addr << 2, card->membase + CMD);
+      restore_flags(flags);
+      
+      vc->rx = 0;
+      if (vc->rx_iov != NULL)
+      {
+	 struct sk_buff *iovb;
+	 u32 stat;
+   
+         stat = readl(card->membase + STAT);
+         card->sbfqc = ns_stat_sfbqc_get(stat);   
+         card->lbfqc = ns_stat_lfbqc_get(stat);
+
+         PRINTK("nicstar%d: closing a VC with pending rx buffers.\n",
+	        card->index);
+         iovb = vc->rx_iov;
+         recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
+	                       iovb->atm.iovcnt);
+         iovb->atm.iovcnt = 0;
+         iovb->atm.vcc = NULL;
+         save_flags(flags); cli();
+         recycle_iov_buf(card, iovb);
+         restore_flags(flags);
+         vc->rx_iov = NULL;
+      }
+   }
+
+   if (vcc->qos.txtp.traffic_class != ATM_NONE)
+   {
+      vc->tx = 0;
+   }
+
+   if (vcc->qos.txtp.traffic_class == ATM_CBR)
+   {
+      unsigned long flags;
+      ns_scqe *scqep;
+      scq_info *scq;
+
+      scq = vc->scq;
+
+      for (;;)
+      {
+         save_flags(flags); cli();
+         scqep = scq->next;
+         if (scqep == scq->base)
+            scqep = scq->last;
+         else
+            scqep--;
+         if (scqep == scq->tail)
+         {
+            restore_flags(flags);
+            break;
+         }
+         /* If the last entry is not a TSR, place one in the SCQ in order to
+            be able to completely drain it and then close. */
+         if (!ns_scqe_is_tsr(scqep) && scq->tail != scq->next)
+         {
+            ns_scqe tsr;
+            u32 scdi, scqi;
+            u32 data;
+            int index;
+
+            tsr.word_1 = ns_tsr_mkword_1(NS_TSR_INTENABLE);
+            scdi = (vc->cbr_scd - NS_FRSCD) / NS_FRSCD_SIZE;
+            scqi = scq->next - scq->base;
+            tsr.word_2 = ns_tsr_mkword_2(scdi, scqi);
+            tsr.word_3 = 0x00000000;
+            tsr.word_4 = 0x00000000;
+            *scq->next = tsr;
+            index = (int) scqi;
+            scq->skb[index] = NULL;
+            if (scq->next == scq->last)
+               scq->next = scq->base;
+            else
+               scq->next++;
+            data = (u32) virt_to_bus(scq->next);
+            ns_write_sram(card, scq->scd, &data, 1);
+         }
+         schedule();
+         restore_flags(flags);
+      }
+
+      /* Free all TST entries */
+      data = NS_TST_OPCODE_VARIABLE;
+      for (i = 0; i < NS_TST_NUM_ENTRIES; i++)
+      {
+         if (card->tste2vc[i] == vc)
+	 {
+            ns_write_sram(card, card->tst_addr + i, &data, 1);
+            card->tste2vc[i] = NULL;
+            card->tst_free_entries++;
+	 }
+      }
+      
+      card->scd2vc[(vc->cbr_scd - NS_FRSCD) / NS_FRSCD_SIZE] = NULL;
+      free_scq(vc->scq, vcc);
+   }
+
+   vcc->dev_data = NULL;
+   vcc->flags &= ~(ATM_VF_PARTIAL | ATM_VF_ADDR);
+
+#ifdef RX_DEBUG
+   {
+      u32 stat, cfg;
+      stat = readl(card->membase + STAT);
+      cfg = readl(card->membase + CFG);
+      printk("STAT = 0x%08X  CFG = 0x%08X  \n", stat, cfg);
+      printk("TSQ: base = 0x%08X  next = 0x%08X  last = 0x%08X  TSQT = 0x%08X \n",
+             (u32) card->tsq.base, (u32) card->tsq.next,(u32) card->tsq.last,
+	     readl(card->membase + TSQT));
+      printk("RSQ: base = 0x%08X  next = 0x%08X  last = 0x%08X  RSQT = 0x%08X \n",
+             (u32) card->rsq.base, (u32) card->rsq.next,(u32) card->rsq.last,
+	     readl(card->membase + RSQT));
+      printk("Empty free buffer queue interrupt %s \n",
+             card->efbie ? "enabled" : "disabled");
+      printk("SBCNT = %d  count = %d   LBCNT = %d count = %d \n",
+             ns_stat_sfbqc_get(stat), card->sbpool.count,
+	     ns_stat_lfbqc_get(stat), card->lbpool.count);
+      printk("hbpool.count = %d  iovpool.count = %d \n",
+             card->hbpool.count, card->iovpool.count);
+   }
+#endif /* RX_DEBUG */
+}
+
+
+
+static void fill_tst(ns_dev *card, int n, vc_map *vc)
+{
+   u32 new_tst;
+   double c, q;
+   int e, r;
+   u32 data;
+      
+   /* It would be very complicated to keep the two TSTs synchronized while
+      assuring that writes are only made to the inactive TST. So, for now I
+      will use only one TST. If problems occur, I will change this again */
+   
+   new_tst = card->tst_addr;
+
+   /* Fill procedure */
+
+   for (e = 0; e < NS_TST_NUM_ENTRIES; e++)
+   {
+      if (card->tste2vc[e] == NULL)
+         break;
+   }
+   if (e == NS_TST_NUM_ENTRIES)
+      printk("nicstar%d: No free TST entries found. \n", card->index);
+
+   r = n;
+   c = 1.0;
+   q = (double) n / (double) NS_TST_NUM_ENTRIES;
+
+   data = ns_tste_make(NS_TST_OPCODE_FIXED, vc->cbr_scd);
+      
+   while (e < NS_TST_NUM_ENTRIES)
+   {
+      if (c >= 1.0 && card->tste2vc[e] == NULL)
+      {
+         card->tste2vc[e] = vc;
+         ns_write_sram(card, new_tst + e, &data, 1);
+	 c -= 1.0;
+	 if (--r == 0)
+	    break;
+      }
+
+      e++;
+      c += q;
+   }
+   if (r != 0)
+      printk("nicstar%d: Not enough free TST entries. CBR lower than requested.\n",
+             card->index);
+   
+   /* End of fill procedure */
+   
+   data = ns_tste_make(NS_TST_OPCODE_END, new_tst);
+   ns_write_sram(card, new_tst + NS_TST_NUM_ENTRIES, &data, 1);
+   ns_write_sram(card, card->tst_addr + NS_TST_NUM_ENTRIES, &data, 1);
+   card->tst_addr = new_tst;
+}
+
+
+
+static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+   ns_dev *card;
+   vc_map *vc;
+   scq_info *scq;
+   unsigned long buflen;
+   ns_scqe scqe;
+   u32 flags;		/* TBD flags, not CPU flags */
+   
+   card = vcc->dev->dev_data;
+   TXPRINTK("nicstar%d: ns_send() called.\n", card->index);
+   if ((vc = (vc_map *) vcc->dev_data) == NULL)
+   {
+      printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n", card->index);
+      vcc->stats->tx_err++;
+      dev_kfree_skb(skb);
+      return -EINVAL;
+   }
+   
+   if (!vc->tx)
+   {
+      printk("nicstar%d: Trying to transmit on a non-tx VC.\n", card->index);
+      vcc->stats->tx_err++;
+      dev_kfree_skb(skb);
+      return -EINVAL;
+   }
+   
+   if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0)
+   {
+      printk("nicstar%d: Only AAL0 and AAL5 are supported.\n", card->index);
+      vcc->stats->tx_err++;
+      dev_kfree_skb(skb);
+      return -EINVAL;
+   }
+   
+   if (skb->atm.iovcnt != 0)
+   {
+      printk("nicstar%d: No scatter-gather yet.\n", card->index);
+      vcc->stats->tx_err++;
+      dev_kfree_skb(skb);
+      return -EINVAL;
+   }
+   
+   skb->atm.vcc = vcc;
+
+   if (vcc->qos.aal == ATM_AAL5)
+   {
+      buflen = (skb->len + 47 + 8) / 48 * 48;	/* Multiple of 48 */
+      flags = NS_TBD_AAL5;
+      scqe.word_2 = (u32) virt_to_bus(skb->data);
+      scqe.word_3 = (u32) skb->len;
+      scqe.word_4 = ((u32) vcc->vpi) << NS_TBD_VPI_SHIFT |
+                    ((u32) vcc->vci) << NS_TBD_VCI_SHIFT;
+      flags |= NS_TBD_EOPDU;
+   }
+   else /* (vcc->qos.aal == ATM_AAL0) */
+   {
+      buflen = ATM_CELL_PAYLOAD;	/* i.e., 48 bytes */
+      flags = NS_TBD_AAL0;
+      scqe.word_2 = (u32) virt_to_bus(skb->data) + NS_AAL0_HEADER;
+      scqe.word_3 = 0x00000000;
+      if (*skb->data & 0x02)	/* Payload type 1 - end of pdu */
+         flags |= NS_TBD_EOPDU;
+      scqe.word_4 = *((u32 *) skb->data) & ~NS_TBD_VC_MASK;
+      /* Force the VPI/VCI to be the same as in VCC struct */
+      scqe.word_4 |= (((u32) vcc->vpi) << NS_TBD_VPI_SHIFT |
+                      ((u32) vcc->vci) << NS_TBD_VCI_SHIFT) & NS_TBD_VC_MASK;
+   }
+
+   if (vcc->qos.txtp.traffic_class == ATM_CBR)
+   {
+      scqe.word_1 = ns_tbd_mkword_1_novbr(flags, (u32) buflen);
+      scq = ((vc_map *) vcc->dev_data)->scq;
+   }
+   else
+   {
+      scqe.word_1 = ns_tbd_mkword_1(flags, (u32) 1, (u32) 1, (u32) buflen);
+      scq = card->scq0;
+   }
+
+   if (push_scqe(card, vc, scq, &scqe, skb) != 0)	/* Timeout pushing the TBD */
+   {
+      printk("nicstar%d: Timeout pushing TBD.\n", card->index);
+      vcc->stats->tx_err++;
+      dev_kfree_skb(skb);
+      return -EIO;
+   }
+   vcc->stats->tx++;
+
+   return 0;
+}
+
+
+
+static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
+                     struct sk_buff *skb)
+{
+   unsigned long flags;
+   ns_scqe tsr;
+   u32 scdi, scqi;
+   int scq_is_vbr;
+   u32 data;
+   int index;
+   
+   if (scq->tail == scq->next)
+   {
+      save_flags(flags); cli();
+      scq->full = 1;
+      current->timeout = jiffies + SCQFULL_TIMEOUT;
+      interruptible_sleep_on(&scq->scqfull_waitq);
+      restore_flags(flags);
+
+      if (scq->full)
+         return 1;
+   }
+   *scq->next = *tbd;
+   index = (int) (scq->next - scq->base);
+   scq->skb[index] = skb;
+   XPRINTK("nicstar%d: sending skb at 0x%x (pos %d).\n",
+           card->index, (u32) skb, index);
+   XPRINTK("nicstar%d: TBD written:\n0x%x\n0x%x\n0x%x\n0x%x\n at 0x%x.\n",
+           card->index, tbd->word_1, tbd->word_2, tbd->word_3, tbd->word_4,
+           (u32) scq->next);
+   if (scq->next == scq->last)
+      scq->next = scq->base;
+   else
+      scq->next++;
+
+   vc->tbd_count++;
+   if (scq->num_entries == VBR_SCQ_NUM_ENTRIES)
+   {
+      scq->tbd_count++;
+      scq_is_vbr = 1;
+   }
+   else
+      scq_is_vbr = 0;
+
+   if (vc->tbd_count >= MAX_TBD_PER_VC || scq->tbd_count >= MAX_TBD_PER_SCQ)
+   {
+      if (scq->tail == scq->next)
+      {
+         save_flags(flags); cli();
+         scq->full = 1;
+         current->timeout = jiffies + SCQFULL_TIMEOUT;
+         interruptible_sleep_on(&scq->scqfull_waitq);
+         restore_flags(flags);
+      }
+
+      if (!scq->full)
+      {
+         tsr.word_1 = ns_tsr_mkword_1(NS_TSR_INTENABLE);
+         if (scq_is_vbr)
+            scdi = NS_TSR_SCDISVBR;
+         else
+            scdi = (vc->cbr_scd - NS_FRSCD) / NS_FRSCD_SIZE;
+         scqi = scq->next - scq->base;
+         tsr.word_2 = ns_tsr_mkword_2(scdi, scqi);
+         tsr.word_3 = 0x00000000;
+         tsr.word_4 = 0x00000000;
+
+         *scq->next = tsr;
+         index = (int) scqi;
+         scq->skb[index] = NULL;
+         XPRINTK("nicstar%d: TSR written:\n0x%x\n0x%x\n0x%x\n0x%x\n at 0x%x.\n",
+	         card->index, tsr.word_1, tsr.word_2, tsr.word_3, tsr.word_4,
+		 (u32) scq->next);
+         if (scq->next == scq->last)
+            scq->next = scq->base;
+         else
+            scq->next++;
+         vc->tbd_count = 0;
+         scq->tbd_count = 0;
+      }
+      else
+         PRINTK("nicstar%d: Could not write TSI.\n", card->index);
+   }
+   
+   data = (u32) virt_to_bus(scq->next);
+   ns_write_sram(card, scq->scd, &data, 1);
+   
+   return 0;
+}
+
+
+
+static void process_tsq(ns_dev *card)
+{
+   u32 scdi;
+   scq_info *scq;
+   ns_tsi *previous;
+   
+   if (ns_tsi_isempty(card->tsq.next))
+      return;
+   while (!ns_tsi_isempty(card->tsq.next))
+   {
+      if (!ns_tsi_tmrof(card->tsq.next))
+      {
+         scdi = ns_tsi_getscdindex(card->tsq.next);
+	 if (scdi == NS_TSI_SCDISVBR)
+	    scq = card->scq0;
+	 else
+	 {
+	    if (card->scd2vc[scdi] == NULL)
+	    {
+	       printk("nicstar%d: could not find VC from SCD index.\n",
+	              card->index);
+               ns_tsi_init(card->tsq.next);
+               return;
+            }
+	    scq = card->scd2vc[scdi]->scq;
+         }
+         drain_scq(card, scq, ns_tsi_getscqpos(card->tsq.next));
+         scq->full = 0;
+         wake_up_interruptible(&(scq->scqfull_waitq));
+      }
+
+      ns_tsi_init(card->tsq.next);
+      previous = card->tsq.next;
+      if (card->tsq.next == card->tsq.last)
+         card->tsq.next = card->tsq.base;
+      else
+         card->tsq.next++;
+   }
+   writel((((u32) previous) - ((u32) card->tsq.base)),
+          card->membase + TSQH);
+}
+
+
+
+static void drain_scq(ns_dev *card, scq_info *scq, int pos)
+{
+   struct atm_vcc *vcc;
+   struct sk_buff *skb;
+   int i;
+   
+   XPRINTK("nicstar%d: drain_scq() called, scq at 0x%x, pos %d.\n",
+           card->index, (u32) scq, pos);
+   if (pos >= scq->num_entries)
+   {
+      printk("nicstar%d: Bad index on drain_scq().\n", card->index);
+      return;
+   }
+
+   i = (int) (scq->tail - scq->base);
+   if (++i == scq->num_entries)
+      i = 0;
+   while (i != pos)
+   {
+      skb = scq->skb[i];
+      XPRINTK("nicstar%d: freeing skb at 0x%x (index %d).\n",
+              card->index, (u32) skb, i);
+      if (skb != NULL)
+      {
+         vcc = skb->atm.vcc;
+	 if (vcc->pop != NULL)
+	    vcc->pop(vcc, skb);
+	 else
+	    dev_kfree_skb(skb);
+	 scq->skb[i] = NULL;
+      }
+      if (++i == scq->num_entries)
+         i = 0;
+   }
+   scq->tail = scq->base + pos;
+}
+
+
+
+static void process_rsq(ns_dev *card)
+{
+   ns_rsqe *previous;
+
+   if (!ns_rsqe_valid(card->rsq.next))
+      return;
+   while (ns_rsqe_valid(card->rsq.next))
+   {
+      dequeue_rx(card, card->rsq.next);
+      ns_rsqe_init(card->rsq.next);
+      previous = card->rsq.next;
+      if (card->rsq.next == card->rsq.last)
+         card->rsq.next = card->rsq.base;
+      else
+         card->rsq.next++;
+   }
+   writel((((u32) previous) - ((u32) card->rsq.base)),
+          card->membase + RSQH);
+}
+
+
+
+static void dequeue_rx(ns_dev *card, ns_rsqe *rsqe)
+{
+   u32 vpi, vci;
+   vc_map *vc;
+   struct sk_buff *iovb;
+   struct iovec *iov;
+   struct atm_vcc *vcc;
+   struct sk_buff *skb;
+   unsigned short aal5_len;
+   int len;
+   u32 stat;
+
+   stat = readl(card->membase + STAT);
+   card->sbfqc = ns_stat_sfbqc_get(stat);   
+   card->lbfqc = ns_stat_lfbqc_get(stat);
+
+   skb = (struct sk_buff *) rsqe->buffer_handle;
+   vpi = ns_rsqe_vpi(rsqe);
+   vci = ns_rsqe_vci(rsqe);
+   if (vpi >= 1UL << card->vpibits || vci >= 1UL << card->vcibits)
+   {
+      printk("nicstar%d: SDU received for out-of-range vc %d.%d.\n",
+             card->index, vpi, vci);
+      recycle_rx_buf(card, skb);
+      return;
+   }
+   
+   vc = &(card->vcmap[vpi << card->vcibits | vci]);
+   if (!vc->rx)
+   {
+      RXPRINTK("nicstar%d: SDU received on non-rx vc %d.%d.\n",
+             card->index, vpi, vci);
+      recycle_rx_buf(card, skb);
+      return;
+   }
+
+   vcc = vc->rx_vcc;
+
+   if (vcc->qos.aal == ATM_AAL0)
+   {
+      struct sk_buff *sb;
+      unsigned char *cell;
+      int i;
+
+      cell = skb->data;
+      for (i = ns_rsqe_cellcount(rsqe); i; i--)
+      {
+         if ((sb = alloc_skb(NS_SMSKBSIZE, GFP_ATOMIC)) == NULL)
+         {
+            printk("nicstar%d: Can't allocate buffers for aal0.\n",
+                   card->index);
+            vcc->stats->rx_drop += i;
+            break;
+         }
+         if (!atm_charge(vcc, sb->truesize))
+         {
+            RXPRINTK("nicstar%d: atm_charge() dropped aal0 packets.\n",
+                     card->index);
+            vcc->stats->rx_drop += i - 1;	/* already increased by 1 */
+            kfree_skb(sb);
+            break;
+         }
+         /* Rebuild the header */
+         *((u32 *) sb->data) = rsqe->word_1 << 4 |
+                               (ns_rsqe_clp(rsqe) ? 0x00000001 : 0x00000000);
+         if (i == 1 && ns_rsqe_eopdu(rsqe))
+            *((u32 *) sb->data) |= 0x00000002;
+         skb_put(sb, NS_AAL0_HEADER);
+         memcpy(sb->tail, cell, ATM_CELL_PAYLOAD);
+         skb_put(sb, ATM_CELL_PAYLOAD);
+         sb->atm.vcc = vcc;
+         sb->stamp = xtime;
+         vcc->push(vcc, sb);
+         vcc->stats->rx++;
+         cell += ATM_CELL_PAYLOAD;
+      }
+
+      recycle_rx_buf(card, skb);
+      return;
+   }
+
+   /* To reach this point, the AAL layer can only be AAL5 */
+
+   if ((iovb = vc->rx_iov) == NULL)
+   {
+      iovb = skb_dequeue(&(card->iovpool.queue));
+      if (iovb == NULL)		/* No buffers in the queue */
+      {
+         iovb = alloc_skb(NS_IOVBUFSIZE, GFP_ATOMIC);
+	 if (iovb == NULL)
+	 {
+	    printk("nicstar%d: Out of iovec buffers.\n", card->index);
+            vcc->stats->rx_drop++;
+            recycle_rx_buf(card, skb);
+            return;
+	 }
+      }
+      else
+         if (--card->iovpool.count < card->iovnr.min)
+	 {
+	    struct sk_buff *new_iovb;
+	    if ((new_iovb = alloc_skb(NS_IOVBUFSIZE, GFP_ATOMIC)) != NULL)
+	    {
+               skb_queue_tail(&card->iovpool.queue, new_iovb);
+               card->iovpool.count++;
+	    }
+	 }
+      vc->rx_iov = iovb;
+      iovb->atm.iovcnt = 0;
+      iovb->len = 0;
+      iovb->tail = iovb->data = iovb->head;
+      iovb->atm.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 (iovb->atm.iovcnt >= NS_MAX_IOVECS)
+   {
+      printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
+      vcc->stats->rx_err++;
+      recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data, NS_MAX_IOVECS);
+      iovb->atm.iovcnt = 0;
+      iovb->len = 0;
+      iovb->tail = iovb->data = iovb->head;
+      iovb->atm.vcc = vcc;
+   }
+   iov = &((struct iovec *) iovb->data)[iovb->atm.iovcnt++];
+   iov->iov_base = (void *) skb;
+   iov->iov_len = ns_rsqe_cellcount(rsqe) * 48;
+   iovb->len += iov->iov_len;
+
+   if (iovb->atm.iovcnt == 1)
+   {
+      if (skb->list != &card->sbpool.queue)
+      {
+         printk("nicstar%d: Expected a small buffer, and this is not one.\n",
+	        card->index);
+         which_list(card, skb);
+         vcc->stats->rx_err++;
+         recycle_rx_buf(card, skb);
+         vc->rx_iov = NULL;
+         recycle_iov_buf(card, iovb);
+         return;
+      }
+   }
+   else /* iovb->atm.iovcnt >= 2 */
+   {
+      if (skb->list != &card->lbpool.queue)
+      {
+         printk("nicstar%d: Expected a large buffer, and this is not one.\n",
+	        card->index);
+         which_list(card, skb);
+         vcc->stats->rx_err++;
+         recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
+	                       iovb->atm.iovcnt);
+         vc->rx_iov = NULL;
+         recycle_iov_buf(card, iovb);
+	 return;
+      }
+   }
+
+   if (ns_rsqe_eopdu(rsqe))
+   {
+      aal5_len = *((unsigned short *) ((u32) skb->data + iov->iov_len - 6));
+      /* Swap byte order. Is it just me or the nicstar manual sais this should
+         already be in little endian format? */
+      aal5_len = ((aal5_len & 0x00ff) << 8 | (aal5_len & 0xff00) >> 8);
+      len = (aal5_len == 0x0000) ? 0x10000 : aal5_len;
+      if (ns_rsqe_crcerr(rsqe) ||
+          len + 8 > iovb->len || len + (47 + 8) < iovb->len)
+      {
+         if (ns_rsqe_crcerr(rsqe))
+	    printk("nicstar%d: AAL5 CRC error.\n", card->index);
+         else
+            printk("nicstar%d: AAL5 PDU size mismatch.\n", card->index);
+         vcc->stats->rx_err++;
+         recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data, iovb->atm.iovcnt);
+	 vc->rx_iov = NULL;
+         recycle_iov_buf(card, iovb);
+	 return;
+      }
+
+      /* By this point we (hopefully) have a complete SDU without errors. */
+
+      if (iovb->atm.iovcnt == 1)	/* Just a small buffer */
+      {
+         /* skb points to a small buffer */
+         if (!atm_charge(vcc, skb->truesize))
+         {
+            push_rxbufs(card, BUF_SM, (u32) skb, (u32) virt_to_bus(skb->data),
+                        0, 0);
+         }
+         else
+	 {
+            skb_put(skb, len);
+            dequeue_sm_buf(card, skb);
+#ifdef NS_USE_DESTRUCTORS
+            skb->destructor = ns_sb_destructor;
+#endif /* NS_USE_DESTRUCTORS */
+            skb->atm.vcc = vcc;
+            skb->stamp = xtime;
+            vcc->push(vcc, skb);
+            vcc->stats->rx++;
+         }
+      }
+      else if (iovb->atm.iovcnt == 2)	/* One small plus one large buffer */
+      {
+         struct sk_buff *sb;
+
+         sb = (struct sk_buff *) (iov - 1)->iov_base;
+         /* skb points to a large buffer */
+
+         if (len <= NS_SMBUFSIZE)
+	 {
+            if (!atm_charge(vcc, sb->truesize))
+            {
+               push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data),
+                           0, 0);
+            }
+            else
+	    {
+               skb_put(sb, len);
+               dequeue_sm_buf(card, sb);
+#ifdef NS_USE_DESTRUCTORS
+               sb->destructor = ns_sb_destructor;
+#endif /* NS_USE_DESTRUCTORS */
+               sb->atm.vcc = vcc;
+               sb->stamp = xtime;
+               vcc->push(vcc, sb);
+               vcc->stats->rx++;
+            }
+
+            push_rxbufs(card, BUF_LG, (u32) skb,
+	                   (u32) virt_to_bus(skb->data), 0, 0);
+
+	 }
+	 else			/* len > NS_SMBUFSIZE, the usual case */
+	 {
+            if (!atm_charge(vcc, skb->truesize))
+            {
+               push_rxbufs(card, BUF_LG, (u32) skb,
+                           (u32) virt_to_bus(skb->data), 0, 0);
+            }
+            else
+            {
+               dequeue_lg_buf(card, skb);
+#ifdef NS_USE_DESTRUCTORS
+               skb->destructor = ns_lb_destructor;
+#endif /* NS_USE_DESTRUCTORS */
+               skb_push(skb, NS_SMBUFSIZE);
+               memcpy(skb->data, sb->data, NS_SMBUFSIZE);
+               skb_put(skb, len - NS_SMBUFSIZE);
+               skb->atm.vcc = vcc;
+               skb->stamp = xtime;
+               vcc->push(vcc, skb);
+               vcc->stats->rx++;
+            }
+
+            push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data),
+                        0, 0);
+
+         }
+	 
+      }
+      else				/* Must push a huge buffer */
+      {
+         struct sk_buff *hb, *sb, *lb;
+	 int remaining, tocopy;
+         int j;
+
+         hb = skb_dequeue(&(card->hbpool.queue));
+         if (hb == NULL)		/* No buffers in the queue */
+         {
+
+            hb = alloc_skb(NS_HBUFSIZE, GFP_ATOMIC);
+            if (hb == NULL)
+            {
+               printk("nicstar%d: Out of huge buffers.\n", card->index);
+               vcc->stats->rx_drop++;
+               recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
+	                             iovb->atm.iovcnt);
+               vc->rx_iov = NULL;
+               recycle_iov_buf(card, iovb);
+               return;
+            }
+            else if (card->hbpool.count < card->hbnr.min)
+	    {
+               struct sk_buff *new_hb;
+               if ((new_hb = alloc_skb(NS_HBUFSIZE, GFP_ATOMIC)) != NULL)
+               {
+                  skb_queue_tail(&card->hbpool.queue, new_hb);
+                  card->hbpool.count++;
+               }
+            }
+	 }
+	 else
+         if (--card->hbpool.count < card->hbnr.min)
+         {
+            struct sk_buff *new_hb;
+            if ((new_hb = alloc_skb(NS_HBUFSIZE, GFP_ATOMIC)) != NULL)
+            {
+               skb_queue_tail(&card->hbpool.queue, new_hb);
+               card->hbpool.count++;
+            }
+            if (card->hbpool.count < card->hbnr.min)
+	    {
+               if ((new_hb = alloc_skb(NS_HBUFSIZE, GFP_ATOMIC)) != NULL)
+               {
+                  skb_queue_tail(&card->hbpool.queue, new_hb);
+                  card->hbpool.count++;
+               }
+            }
+         }
+
+         iov = (struct iovec *) iovb->data;
+
+         if (!atm_charge(vcc, hb->truesize))
+	 {
+            recycle_iovec_rx_bufs(card, iov, iovb->atm.iovcnt);
+            if (card->hbpool.count < card->hbnr.max)
+            {
+               skb_queue_tail(&card->hbpool.queue, hb);
+               card->hbpool.count++;
+            }
+	    else
+	       kfree_skb(hb);
+         }
+         else
+	 {
+            /* Copy the small buffer to the huge buffer */
+            sb = (struct sk_buff *) iov->iov_base;
+            memcpy(hb->data, sb->data, iov->iov_len);
+            skb_put(hb, iov->iov_len);
+            remaining = len - iov->iov_len;
+            iov++;
+            /* Free the small buffer */
+            push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data),
+                        0, 0);
+
+            /* Copy all large buffers to the huge buffer and free them */
+            for (j = 1; j < iovb->atm.iovcnt; j++)
+            {
+               lb = (struct sk_buff *) iov->iov_base;
+               tocopy = MIN(remaining, iov->iov_len);
+               memcpy(hb->tail, lb->data, tocopy);
+               skb_put(hb, tocopy);
+               iov++;
+               remaining -= tocopy;
+               push_rxbufs(card, BUF_LG, (u32) lb,
+                           (u32) virt_to_bus(lb->data), 0, 0);
+            }
+#ifdef EXTRA_DEBUG
+            if (remaining != 0 || hb->len != len)
+               printk("nicstar%d: Huge buffer len mismatch.\n", card->index);
+#endif /* EXTRA_DEBUG */
+            hb->atm.vcc = vcc;
+#ifdef NS_USE_DESTRUCTORS
+            hb->destructor = ns_hb_destructor;
+#endif /* NS_USE_DESTRUCTORS */
+            hb->stamp = xtime;
+            vcc->push(vcc, hb);
+            vcc->stats->rx++;
+         }
+      }
+
+      vc->rx_iov = NULL;
+      recycle_iov_buf(card, iovb);
+   }
+
+}
+
+
+
+#ifdef NS_USE_DESTRUCTORS
+
+static void ns_sb_destructor(struct sk_buff *sb)
+{
+   ns_dev *card;
+   u32 stat;
+
+   card = (ns_dev *) sb->atm.vcc->dev->dev_data;
+   stat = readl(card->membase + STAT);
+   card->sbfqc = ns_stat_sfbqc_get(stat);   
+   card->lbfqc = ns_stat_lfbqc_get(stat);
+
+   do
+   {
+      sb = alloc_skb(NS_SMSKBSIZE, GFP_KERNEL);
+      if (sb == NULL)
+         break;
+      skb_queue_tail(&card->sbpool.queue, sb);
+      skb_reserve(sb, NS_AAL0_HEADER);
+      push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data), 0, 0);
+   } while (card->sbfqc < card->sbnr.min);
+}
+
+
+
+static void ns_lb_destructor(struct sk_buff *lb)
+{
+   ns_dev *card;
+   u32 stat;
+
+   card = (ns_dev *) lb->atm.vcc->dev->dev_data;
+   stat = readl(card->membase + STAT);
+   card->sbfqc = ns_stat_sfbqc_get(stat);   
+   card->lbfqc = ns_stat_lfbqc_get(stat);
+
+   do
+   {
+      lb = alloc_skb(NS_LGSKBSIZE, GFP_KERNEL);
+      if (lb == NULL)
+         break;
+      skb_queue_tail(&card->lbpool.queue, lb);
+      skb_reserve(lb, NS_SMBUFSIZE);
+      push_rxbufs(card, BUF_LG, (u32) lb, (u32) virt_to_bus(lb->data), 0, 0);
+   } while (card->lbfqc < card->lbnr.min);
+}
+
+
+
+static void ns_hb_destructor(struct sk_buff *hb)
+{
+   ns_dev *card;
+
+   card = (ns_dev *) hb->atm.vcc->dev->dev_data;
+
+   while (card->hbpool.count < card->hbnr.init)
+   {
+      hb = alloc_skb(NS_HBUFSIZE, GFP_KERNEL);
+      if (hb == NULL)
+         break;
+      skb_queue_tail(&card->hbpool.queue, hb);
+      card->hbpool.count++;
+   }
+}
+
+#endif /* NS_USE_DESTRUCTORS */
+
+
+
+static void recycle_rx_buf(ns_dev *card, struct sk_buff *skb)
+{
+   if (skb->list == &card->sbpool.queue)
+      push_rxbufs(card, BUF_SM, (u32) skb, (u32) virt_to_bus(skb->data), 0, 0);
+   else if (skb->list == &card->lbpool.queue)
+      push_rxbufs(card, BUF_LG, (u32) skb, (u32) virt_to_bus(skb->data), 0, 0);
+   else
+   {
+      printk("nicstar%d: What kind of rx buffer is this?\n", card->index);
+      kfree_skb(skb);
+   }
+}
+
+
+
+static void recycle_iovec_rx_bufs(ns_dev *card, struct iovec *iov, int count)
+{
+   struct sk_buff *skb;
+
+   for (; count > 0; count--)
+   {
+      skb = (struct sk_buff *) (iov++)->iov_base;
+      if (skb->list == &card->sbpool.queue)
+         push_rxbufs(card, BUF_SM, (u32) skb, (u32) virt_to_bus(skb->data),
+	             0, 0);
+      else if (skb->list == &card->lbpool.queue)
+         push_rxbufs(card, BUF_LG, (u32) skb, (u32) virt_to_bus(skb->data),
+	             0, 0);
+      else
+      {
+         printk("nicstar%d: What kind of rx buffer is this?\n", card->index);
+         kfree_skb(skb);
+      }
+   }
+}
+
+
+
+static void recycle_iov_buf(ns_dev *card, struct sk_buff *iovb)
+{
+   if (card->iovpool.count < card->iovnr.max)
+   {
+      skb_queue_tail(&card->iovpool.queue, iovb);
+      card->iovpool.count++;
+   }
+   else
+      kfree_skb(iovb);
+}
+
+
+
+static void dequeue_sm_buf(ns_dev *card, struct sk_buff *sb)
+{
+   skb_unlink(sb);
+#ifdef NS_USE_DESTRUCTORS
+   if (card->sbfqc < card->sbnr.min)
+#else
+   if (card->sbfqc < card->sbnr.init)
+   {
+      struct sk_buff *new_sb;
+      if ((new_sb = alloc_skb(NS_SMSKBSIZE, GFP_ATOMIC)) != NULL)
+      {
+         skb_queue_tail(&card->sbpool.queue, new_sb);
+         skb_reserve(new_sb, NS_AAL0_HEADER);
+         push_rxbufs(card, BUF_SM, (u32) new_sb,
+                     (u32) virt_to_bus(new_sb->data), 0, 0);
+      }
+   }
+   if (card->sbfqc < card->sbnr.init)
+#endif /* NS_USE_DESTRUCTORS */
+   {
+      struct sk_buff *new_sb;
+      if ((new_sb = alloc_skb(NS_SMSKBSIZE, GFP_ATOMIC)) != NULL)
+      {
+         skb_queue_tail(&card->sbpool.queue, new_sb);
+         skb_reserve(new_sb, NS_AAL0_HEADER);
+         push_rxbufs(card, BUF_SM, (u32) new_sb,
+                     (u32) virt_to_bus(new_sb->data), 0, 0);
+      }
+   }
+}
+
+
+
+static void dequeue_lg_buf(ns_dev *card, struct sk_buff *lb)
+{
+   skb_unlink(lb);
+#ifdef NS_USE_DESTRUCTORS
+   if (card->lbfqc < card->lbnr.min)
+#else
+   if (card->lbfqc < card->lbnr.init)
+   {
+      struct sk_buff *new_lb;
+      if ((new_lb = alloc_skb(NS_LGSKBSIZE, GFP_ATOMIC)) != NULL)
+      {
+         skb_queue_tail(&card->lbpool.queue, new_lb);
+         skb_reserve(new_lb, NS_SMBUFSIZE);
+         push_rxbufs(card, BUF_LG, (u32) new_lb,
+                     (u32) virt_to_bus(new_lb->data), 0, 0);
+      }
+   }
+   if (card->lbfqc < card->lbnr.init)
+#endif /* NS_USE_DESTRUCTORS */
+   {
+      struct sk_buff *new_lb;
+      if ((new_lb = alloc_skb(NS_LGSKBSIZE, GFP_ATOMIC)) != NULL)
+      {
+         skb_queue_tail(&card->lbpool.queue, new_lb);
+         skb_reserve(new_lb, NS_SMBUFSIZE);
+         push_rxbufs(card, BUF_LG, (u32) new_lb,
+                     (u32) virt_to_bus(new_lb->data), 0, 0);
+      }
+   }
+}
+
+
+
+static int ns_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
+{
+   u32 stat;
+   ns_dev *card;
+   int left;
+
+   left = (int) *pos;
+   card = (ns_dev *) dev->dev_data;
+   stat = readl(card->membase + STAT);
+   if (!left--)
+      return sprintf(page, "Pool   count    min   init    max \n");
+   if (!left--)
+      return sprintf(page, "Small  %5d  %5d  %5d  %5d \n",
+                     ns_stat_sfbqc_get(stat), card->sbnr.min, card->sbnr.init,
+		     card->sbnr.max);
+   if (!left--)
+      return sprintf(page, "Large  %5d  %5d  %5d  %5d \n",
+                     ns_stat_lfbqc_get(stat), card->lbnr.min, card->lbnr.init,
+		     card->lbnr.max);
+   if (!left--)
+      return sprintf(page, "Huge   %5d  %5d  %5d  %5d \n", card->hbpool.count,
+                     card->hbnr.min, card->hbnr.init, card->hbnr.max);
+   if (!left--)
+      return sprintf(page, "Iovec  %5d  %5d  %5d  %5d \n", card->iovpool.count,
+                     card->iovnr.min, card->iovnr.init, card->iovnr.max);
+   if (!left--)
+   {
+      int retval;
+      retval = sprintf(page, "Interrupt counter: %u \n", card->intcnt);
+      card->intcnt = 0;
+      return retval;
+   }
+   /* Dump 25.6 Mbps PHY registers */
+   if (card->max_pcr == IDT_25_PCR && !left--)
+   {
+      u32 phy_regs[4];
+      u32 i;
+
+      for (i = 0; i < 4; i++)
+      {
+         while (CMD_BUSY(card));
+         writel(NS_CMD_READ_UTILITY | 0x00000200 | i, card->membase + CMD);
+         while (CMD_BUSY(card));
+         phy_regs[i] = readl(card->membase + DR0) & 0x000000FF;
+      }
+
+      return sprintf(page, "PHY regs: 0x%02X 0x%02X 0x%02X 0x%02X \n",
+                     phy_regs[0], phy_regs[1], phy_regs[2], phy_regs[3]);
+   }
+#if 0
+   /* Dump TST */
+   if (left-- < NS_TST_NUM_ENTRIES)
+   {
+      if (card->tste2vc[left + 1] == NULL)
+         return sprintf(page, "%5d - VBR/UBR \n", left + 1);
+      else
+         return sprintf(page, "%5d - %d %d \n", left + 1,
+                        card->tste2vc[left + 1]->tx_vcc->vpi,
+                        card->tste2vc[left + 1]->tx_vcc->vci);
+   }
+#endif /* 0 */
+   return 0;
+}
+
+
+
+static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void *arg)
+{
+   ns_dev *card;
+   pool_levels pl;
+   int btype;
+   unsigned long flags;
+
+   card = dev->dev_data;
+   switch (cmd)
+   {
+      case NS_GETPSTAT:
+         if (get_user(pl.buftype, &((pool_levels *) arg)->buftype))
+	    return -EFAULT;
+         switch (pl.buftype)
+	 {
+	    case NS_BUFTYPE_SMALL:
+	       pl.count = ns_stat_sfbqc_get(readl(card->membase + STAT));
+	       pl.level.min = card->sbnr.min;
+	       pl.level.init = card->sbnr.init;
+	       pl.level.max = card->sbnr.max;
+	       break;
+
+	    case NS_BUFTYPE_LARGE:
+	       pl.count = ns_stat_lfbqc_get(readl(card->membase + STAT));
+	       pl.level.min = card->lbnr.min;
+	       pl.level.init = card->lbnr.init;
+	       pl.level.max = card->lbnr.max;
+	       break;
+
+	    case NS_BUFTYPE_HUGE:
+	       pl.count = card->hbpool.count;
+	       pl.level.min = card->hbnr.min;
+	       pl.level.init = card->hbnr.init;
+	       pl.level.max = card->hbnr.max;
+	       break;
+
+	    case NS_BUFTYPE_IOVEC:
+	       pl.count = card->iovpool.count;
+	       pl.level.min = card->iovnr.min;
+	       pl.level.init = card->iovnr.init;
+	       pl.level.max = card->iovnr.max;
+	       break;
+
+            default:
+	       return -EINVAL;
+
+	 }
+         if (!copy_to_user((pool_levels *) arg, &pl, sizeof(pl)))
+	    return (sizeof(pl));
+	 else
+	    return -EFAULT;
+
+      case NS_SETBUFLEV:
+         if (!suser())
+	    return -EPERM;
+         if (copy_from_user(&pl, (pool_levels *) arg, sizeof(pl)))
+	    return -EFAULT;
+	 if (pl.level.min >= pl.level.init || pl.level.init >= pl.level.max)
+	    return -EINVAL;
+	 if (pl.level.min == 0)
+	    return -EINVAL;
+         switch (pl.buftype)
+	 {
+	    case NS_BUFTYPE_SMALL:
+               if (pl.level.max > TOP_SB)
+	          return -EINVAL;
+	       card->sbnr.min = pl.level.min;
+	       card->sbnr.init = pl.level.init;
+	       card->sbnr.max = pl.level.max;
+	       break;
+
+	    case NS_BUFTYPE_LARGE:
+               if (pl.level.max > TOP_LB)
+	          return -EINVAL;
+	       card->lbnr.min = pl.level.min;
+	       card->lbnr.init = pl.level.init;
+	       card->lbnr.max = pl.level.max;
+	       break;
+
+	    case NS_BUFTYPE_HUGE:
+               if (pl.level.max > TOP_HB)
+	          return -EINVAL;
+	       card->hbnr.min = pl.level.min;
+	       card->hbnr.init = pl.level.init;
+	       card->hbnr.max = pl.level.max;
+	       break;
+
+	    case NS_BUFTYPE_IOVEC:
+               if (pl.level.max > TOP_IOVB)
+	          return -EINVAL;
+	       card->iovnr.min = pl.level.min;
+	       card->iovnr.init = pl.level.init;
+	       card->iovnr.max = pl.level.max;
+	       break;
+
+            default:
+	       return -EINVAL;
+
+         }	 
+         return 0;
+
+      case NS_ADJBUFLEV:
+         if (!suser())
+	    return -EPERM;
+         btype = (int) arg;	/* an int is the same size as a pointer */
+         switch (btype)
+	 {
+	    case NS_BUFTYPE_SMALL:
+	       while (card->sbfqc < card->sbnr.init)
+	       {
+                  struct sk_buff *sb;
+
+                  sb = alloc_skb(NS_SMSKBSIZE, GFP_KERNEL);
+                  if (sb == NULL)
+                     return -ENOMEM;
+                  skb_queue_tail(&card->sbpool.queue, sb);
+                  skb_reserve(sb, NS_AAL0_HEADER);
+                  push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data), 0, 0);
+	       }
+	       break;
+
+            case NS_BUFTYPE_LARGE:
+	       while (card->lbfqc < card->lbnr.init)
+	       {
+                  struct sk_buff *lb;
+
+                  lb = alloc_skb(NS_LGSKBSIZE, GFP_KERNEL);
+                  if (lb == NULL)
+                     return -ENOMEM;
+                  skb_queue_tail(&card->lbpool.queue, lb);
+                  skb_reserve(lb, NS_SMBUFSIZE);
+                  push_rxbufs(card, BUF_LG, (u32) lb, (u32) virt_to_bus(lb->data), 0, 0);
+	       }
+	       break;
+
+            case NS_BUFTYPE_HUGE:
+               while (card->hbpool.count > card->hbnr.init)
+	       {
+                  struct sk_buff *hb;
+
+                  save_flags(flags); cli();
+		  hb = skb_dequeue(&card->hbpool.queue);
+		  card->hbpool.count--;
+		  restore_flags(flags);
+                  if (hb == NULL)
+		     printk("nicstar%d: huge buffer count inconsistent.\n",
+		            card->index);
+                  else
+		     kfree_skb(hb);
+		  
+	       }
+               while (card->hbpool.count < card->hbnr.init)
+               {
+                  struct sk_buff *hb;
+
+                  hb = alloc_skb(NS_HBUFSIZE, GFP_KERNEL);
+                  if (hb == NULL)
+                     return -ENOMEM;
+                  save_flags(flags); cli();
+                  skb_queue_tail(&card->hbpool.queue, hb);
+                  card->hbpool.count++;
+		  restore_flags(flags);
+               }
+	       break;
+
+            case NS_BUFTYPE_IOVEC:
+	       while (card->iovpool.count > card->iovnr.init)
+	       {
+	          struct sk_buff *iovb;
+
+                  save_flags(flags); cli();
+		  iovb = skb_dequeue(&card->iovpool.queue);
+		  card->iovpool.count--;
+		  restore_flags(flags);
+                  if (iovb == NULL)
+		     printk("nicstar%d: iovec buffer count inconsistent.\n",
+		            card->index);
+                  else
+		     kfree_skb(iovb);
+
+	       }
+               while (card->iovpool.count < card->iovnr.init)
+	       {
+	          struct sk_buff *iovb;
+
+                  iovb = alloc_skb(NS_IOVBUFSIZE, GFP_KERNEL);
+                  if (iovb == NULL)
+                     return -ENOMEM;
+                  save_flags(flags); cli();
+                  skb_queue_tail(&card->iovpool.queue, iovb);
+                  card->iovpool.count++;
+		  restore_flags(flags);
+	       }
+	       break;
+
+            default:
+	       return -EINVAL;
+
+	 }
+         return 0;
+
+      default:
+         if (dev->phy->ioctl == NULL) return -EINVAL;
+	 return dev->phy->ioctl(dev, cmd, arg);
+   }
+}
+
+
+
+static void which_list(ns_dev *card, struct sk_buff *skb)
+{
+   printk("It's a %s buffer.\n", skb->list == &card->sbpool.queue ?
+          "small" : skb->list == &card->lbpool.queue ? "large" :
+	  skb->list == &card->hbpool.queue ? "huge" :
+	  skb->list == &card->iovpool.queue ? "iovec" : "unknown");
+}
+
+
+
+static void ns_poll(unsigned long arg)
+{
+   int i;
+   ns_dev *card;
+   unsigned long flags;
+   u32 stat_r, stat_w;
+
+   PRINTK("nicstar: Entering ns_poll().\n");
+   for (i = 0; i < num_cards; i++)
+   {
+      card = cards[i];
+      save_flags(flags); cli();
+      if (card->in_poll)
+      {
+         printk("nicstar: Re-entering ns_poll()???\n");
+         continue;
+      }
+      card->in_poll = 1;
+      if (card->in_handler)
+      {
+         card->in_poll = 0;
+         printk("nicstar%d: ns_poll called while in interrupt handler!?\n",
+                card->index);
+         continue;
+      }
+
+      stat_w = 0;
+      stat_r = readl(card->membase + STAT);
+      if (stat_r & NS_STAT_TSIF)
+         stat_w |= NS_STAT_TSIF;
+      if (stat_r & NS_STAT_EOPDU)
+         stat_w |= NS_STAT_EOPDU;
+
+      process_tsq(card);
+      process_rsq(card);
+
+      writel(card->membase + STAT, stat_w);
+      card->in_poll = 0;
+      restore_flags(flags);
+   }
+   mod_timer(&ns_timer, jiffies + NS_POLL_PERIOD);
+   PRINTK("nicstar: Leaving ns_poll().\n");
+}
diff -ur --new-file old/linux/drivers/atm/zatm.c new/linux/drivers/atm/zatm.c
--- old/linux/drivers/atm/zatm.c	Thu Oct  1 23:49:55 1998
+++ new/linux/drivers/atm/zatm.c	Thu Oct  1 23:50:40 1998
@@ -644,8 +644,8 @@
 			continue;
 		}
 		skb->len = size;
-		skb->atm.vcc = vcc;
-		vcc->push(skb->atm.vcc,skb);
+		ATM_SKB(skb)->vcc = vcc;
+		vcc->push(vcc,skb);
 		vcc->stats->rx++;
 	}
 	zout(pos & 0xffff,MTA(mbx));
@@ -812,6 +812,7 @@
 
 static int do_tx(struct sk_buff *skb)
 {
+	struct atm_vcc *vcc;
 	struct zatm_dev *zatm_dev;
 	struct zatm_vcc *zatm_vcc;
 	u32 *dsc;
@@ -819,12 +820,13 @@
 
 	EVENT("do_tx\n",0,0);
 	DPRINTK("sending skb %p\n",skb);
-	zatm_dev = ZATM_DEV(skb->atm.vcc->dev);
-	zatm_vcc = ZATM_VCC(skb->atm.vcc);
-	EVENT("iovcnt=%d\n",skb->atm.iovcnt,0);
+	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);
 	save_flags(flags);
 	cli();
-	if (!skb->atm.iovcnt) {
+	if (!ATM_SKB(skb)->iovcnt) {
 		if (zatm_vcc->txing == RING_ENTRIES-1) {
 			restore_flags(flags);
 			return RING_BUSY;
@@ -838,8 +840,8 @@
 		dsc[3] = virt_to_bus(skb->data);
 		mb();
 		dsc[0] = uPD98401_TXPD_V | uPD98401_TXPD_DP | uPD98401_TXPD_SM
-		    | (skb->atm.vcc->qos.aal == ATM_AAL5 ? uPD98401_TXPD_AAL5 :
-		    0 | (skb->atm.atm_options & ATM_ATMOPT_CLP ?
+		    | (vcc->qos.aal == ATM_AAL5 ? uPD98401_TXPD_AAL5 : 0 |
+		    (ATM_SKB(skb)->atm_options & ATM_ATMOPT_CLP ?
 		    uPD98401_CLPM_1 : uPD98401_CLPM_0));
 		EVENT("dsc (0x%lx)\n",(unsigned long) dsc,0);
 	}
@@ -851,7 +853,7 @@
 		int i;
 
 		dsc = (u32 *) kmalloc(uPD98401_TXPD_SIZE*2+
-		    uPD98401_TXBD_SIZE*skb->atm.iovcnt,GFP_ATOMIC);
+		    uPD98401_TXBD_SIZE*ATM_SKB(skb)->iovcnt,GFP_ATOMIC);
 		if (!dsc) {
 			if (vcc->pop) vcc->pop(vcc,skb);
 			else dev_kfree_skb(skb);
@@ -860,13 +862,13 @@
 		/* @@@ should check alignment */
 		put = dsc+8;
 		dsc[0] = uPD98401_TXPD_V | uPD98401_TXPD_DP |
-		    (skb->atm.vcc->aal == ATM_AAL5 ? uPD98401_TXPD_AAL5 : 0 |
-		    (skb->atm.atm_options & ATM_ATMOPT_CLP ?  uPD98401_CLPM_1 :
-		    uPD98401_CLPM_0));
+		    (vcc->aal == ATM_AAL5 ? uPD98401_TXPD_AAL5 : 0 |
+		    (ATM_SKB(skb)->atm_options & ATM_ATMOPT_CLP ?
+		    uPD98401_CLPM_1 : uPD98401_CLPM_0));
 		dsc[1] = 0;
-		dsc[2] = skb->atm.iovcnt*uPD98401_TXBD_SIZE;
+		dsc[2] = ATM_SKB(skb)->iovcnt*uPD98401_TXBD_SIZE;
 		dsc[3] = virt_to_bus(put);
-		for (i = 0; i < skb->atm.iovcnt; i++) {
+		for (i = 0; i < ATM_SKB(skb)->iovcnt; i++) {
 			*put++ = ((struct iovec *) skb->data)[i].iov_len;
 			*put++ = virt_to_bus(((struct iovec *)
 			    skb->data)[i].iov_base);
@@ -1760,7 +1762,7 @@
 		else dev_kfree_skb(skb);
 		return -EINVAL;
 	}
-	skb->atm.vcc = vcc;
+	ATM_SKB(skb)->vcc = vcc;
 	error = do_tx(skb);
 	if (error != RING_BUSY) return error;
 	skb_queue_tail(&ZATM_VCC(vcc)->backlog,skb);
diff -ur --new-file old/linux/drivers/atm/zatm.h new/linux/drivers/atm/zatm.h
--- old/linux/drivers/atm/zatm.h	Thu Oct  1 23:49:55 1998
+++ new/linux/drivers/atm/zatm.h	Thu Oct  1 23:50:40 1998
@@ -128,6 +128,7 @@
 
 
 struct zatm_skb_prv {
+	struct atm_skb_data _;		/* reserved */
 	u32 *dsc;			/* pointer to skb's descriptor */
 };
 
diff -ur --new-file old/linux/include/linux/atmdev.h new/linux/include/linux/atmdev.h
--- old/linux/include/linux/atmdev.h	Thu Oct  1 23:49:55 1998
+++ new/linux/include/linux/atmdev.h	Thu Oct  1 23:50:40 1998
@@ -283,6 +283,19 @@
 };
 
 
+#ifdef CONFIG_ATM_SKB
+
+struct atm_skb_data {
+	struct atm_vcc	*vcc;		/* ATM VCC */
+	int		iovcnt;		/* 0 for "normal" operation */
+	unsigned long	atm_options;	/* ATM layer options */
+};
+
+#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb))
+
+#endif
+
+
 struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
     int number,unsigned long flags); /* number == -1: pick first available */
 struct atm_dev *atm_find_dev(int number);
diff -ur --new-file old/linux/include/linux/skbuff.h new/linux/include/linux/skbuff.h
--- old/linux/include/linux/skbuff.h	Thu Oct  1 23:49:55 1998
+++ new/linux/include/linux/skbuff.h	Thu Oct  1 23:50:40 1998
@@ -106,15 +106,23 @@
 	__u32		shapestamp;		/* Stamp for shaper    */
 	__u16		shapepend;		/* Pending */
 #endif
-#ifdef CONFIG_ATM
+#if defined(CONFIG_ATM) && !defined(CONFIG_ATM_SKB)
+
+/* ----- For updated drivers ----------------------------------------------- */
+
+#define ATM_SKB(skb) (&(skb)->atm)
+
+	struct atm_skb_data {
+	};
+
+/* ----- For not yet updated drivers --------------------------------------- */
+
 	struct {
 		struct atm_vcc	*vcc;		/* ATM VCC */
 		int		iovcnt;		/* 0 for "normal" operation */
 		unsigned long	atm_options;	/* ATM layer options */
-#ifdef CONFIG_AREQUIPA
-		int		generation;	/* generation number */
-#endif
 	} atm;
+
 #endif
 
 };
diff -ur --new-file old/linux/net/Config.in new/linux/net/Config.in
--- old/linux/net/Config.in	Thu Oct  1 23:49:55 1998
+++ new/linux/net/Config.in	Thu Oct  1 23:50:40 1998
@@ -26,6 +26,7 @@
 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
   bool 'Asynchronous Transfer Mode (ATM, EXPERIMENTAL)' CONFIG_ATM y
   if [ "$CONFIG_ATM" = "y" ]; then
+     bool '  Use "new" skb structure' CONFIG_ATM_SKB n
 #    bool '  Enable single-copy' CONFIG_MMU_HACKS n
 #    if [ "$CONFIG_MMU_HACKS" = "y" ]; then
 #      bool '    Extended debugging for single-copy' CONFIG_MMU_HACKS_DEBUG y
diff -ur --new-file old/linux/net/atm/clip.c new/linux/net/atm/clip.c
--- old/linux/net/atm/clip.c	Thu Oct  1 23:49:56 1998
+++ new/linux/net/atm/clip.c	Thu Oct  1 23:50:40 1998
@@ -1,4 +1,4 @@
-/* clip.c - RFC1577 Classical IP over ATM */
+/* net/atm/clip.c - RFC1577 Classical IP over ATM */
 
 /* Written 1995-1998 by Werner Almesberger, EPFL LRC/ICA */
 
@@ -166,14 +166,17 @@
 
 static int clip_arp_rcv(struct sk_buff *skb)
 {
+	struct atm_vcc *vcc;
+
 	DPRINTK("clip_arp_rcv\n");
-	if (!skb->atm.vcc || !atm_charge(skb->atm.vcc,skb->truesize)) {
+	vcc = ATM_SKB(skb)->vcc;
+	if (!vcc || !atm_charge(vcc,skb->truesize)) {
 		kfree_skb(skb);
 		return 0;
 	}
-	DPRINTK("pushing to %p\n",skb->atm.vcc);
-	DPRINTK("using %p\n",CLIP_VCC(skb->atm.vcc)->old_push);
-	CLIP_VCC(skb->atm.vcc)->old_push(skb->atm.vcc,skb);
+	DPRINTK("pushing to %p\n",vcc);
+	DPRINTK("using %p\n",CLIP_VCC(vcc)->old_push);
+	CLIP_VCC(vcc)->old_push(vcc,skb);
 	return 0;
 }
 
@@ -197,7 +200,7 @@
 		kfree_skb(skb);
 		return;
 	}
-	skb->atm.vcc = vcc;
+	ATM_SKB(skb)->vcc = vcc;
 	skb->mac.raw = skb->data;
 	if (!clip_vcc->encap || skb->len < RFC1483LLC_LEN || memcmp(skb->data,
 	    llc_oui,sizeof(llc_oui))) skb->protocol = htons(ETH_P_IP);
@@ -362,9 +365,9 @@
 		return 0;
 	}
 	DPRINTK("neigh %p, vccs %p\n",entry,entry->vccs);
-	skb->atm.vcc = entry->vccs->vcc;
+	ATM_SKB(skb)->vcc = entry->vccs->vcc;
 	DPRINTK("using neighbour %p, vcc %p\n",skb->dst->neighbour,
-	    skb->atm.vcc);
+	    ATM_SKB(skb)->vcc);
 	if (entry->vccs->encap) {
 		void *here;
 
@@ -372,13 +375,13 @@
 		memcpy(here,llc_oui,sizeof(llc_oui));
 		((u16 *) here)[3] = skb->protocol;
 	}
-	atomic_add(skb->truesize,&skb->atm.vcc->tx_inuse);
-	skb->atm.iovcnt = 0;
-	skb->atm.atm_options = skb->atm.vcc->atm_options;
+	atomic_add(skb->truesize,&ATM_SKB(skb)->vcc->tx_inuse);
+	ATM_SKB(skb)->iovcnt = 0;
+	ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options;
 	entry->vccs->last_use = jiffies;
-	DPRINTK("skb(%p)->atm.vcc(%p)->dev(%p)\n",skb,skb->atm.vcc,
-	    skb->atm.vcc->dev);
-	(void) skb->atm.vcc->dev->ops->send(skb->atm.vcc,skb);
+	DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n",skb,ATM_SKB(skb)->vcc,
+	    ATM_SKB(skb)->vcc->dev);
+	(void) ATM_SKB(skb)->vcc->dev->ops->send(ATM_SKB(skb)->vcc,skb);
 	PRIV(dev)->stats.tx_packets++;
 	return 0;
 }
diff -ur --new-file old/linux/net/atm/common.c new/linux/net/atm/common.c
--- old/linux/net/atm/common.c	Thu Oct  1 23:49:56 1998
+++ new/linux/net/atm/common.c	Thu Oct  1 23:50:41 1998
@@ -362,7 +362,7 @@
 		    (unsigned long) buff,eff_len);
 	DPRINTK("RcvM %d -= %d\n",atomic_read(&vcc->rx_inuse),skb->truesize);
 	atm_return(vcc,skb->truesize);
-	if (skb->atm.iovcnt) { /* @@@ hack */
+	if (ATM_SKB(skb)->iovcnt) { /* @@@ hack */
 		/* iovcnt set, use scatter-gather for receive */
 		int el, cnt;
 		struct iovec *iov = (struct iovec *)skb->data;
@@ -370,7 +370,7 @@
 
 		el = eff_len;
 		error = 0;
-		for (cnt = 0; (cnt < skb->atm.iovcnt) && el; cnt++) {
+		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) ?
@@ -447,7 +447,7 @@
 			DPRINTK("res is %d\n",res);
 			DPRINTK("Asnd %d += %d\n",vcc->tx_inuse,skb->truesize);
 			atomic_add(skb->truesize+ATM_PDU_OVHD,&vcc->tx_inuse);
-			skb->atm.iovcnt = res;
+			ATM_SKB(skb)->iovcnt = res;
 			error = vcc->dev->ops->send(vcc,skb);
 			/* FIXME: security: may send up to 3 "garbage" bytes */
 			return error ? error : size;
@@ -463,8 +463,8 @@
 			return vcc->reply;
 		if (!(vcc->flags & ATM_VF_READY)) return -EPIPE;
 	}
-	skb->atm.iovcnt = 0;
-	skb->atm.atm_options = vcc->atm_options;
+	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);
 		return -EFAULT;
diff -ur --new-file old/linux/net/atm/lec.c new/linux/net/atm/lec.c
--- old/linux/net/atm/lec.c	Thu Oct  1 23:49:56 1998
+++ new/linux/net/atm/lec.c	Thu Oct  1 23:50:41 1998
@@ -182,7 +182,7 @@
                         printk("%s:sending to vpi:%d vci:%d\n", dev->name,
                                 send_vcc->vpi, send_vcc->vci);
 #endif /* DUMP_PACKETS > 0 */
-                        skb->atm.vcc = send_vcc;
+                        ATM_SKB(skb)->vcc = send_vcc;
                         /* Minimum ethernet-frame size */
                         if (skb->len <62) {
                                 if (skb->truesize < 62) {
@@ -203,8 +203,8 @@
                                 }
                         }
                         atomic_add(skb->truesize, &send_vcc->tx_inuse);
-                        skb->atm.iovcnt = 0;
-			skb->atm.atm_options = send_vcc->atm_options;
+                        ATM_SKB(skb)->iovcnt = 0;
+			ATM_SKB(skb)->atm_options = send_vcc->atm_options;
                         send_vcc->dev->ops->send(send_vcc, skb);
                         priv->stats.tx_packets++;
                 }
diff -ur --new-file old/linux/net/atm/mpc.c new/linux/net/atm/mpc.c
--- old/linux/net/atm/mpc.c	Thu Oct  1 23:49:56 1998
+++ new/linux/net/atm/mpc.c	Thu Oct  1 23:50:41 1998
@@ -1,3 +1,5 @@
+/* mpc.c */
+
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/timer.h>
@@ -492,8 +494,8 @@
         }
 
         atomic_add(skb->truesize, &entry->shortcut->tx_inuse);
-	skb->atm.iovcnt = 0; /* just to be safe ... */
-	skb->atm.atm_options = entry->shortcut->atm_options;
+	ATM_SKB(skb)->iovcnt = 0; /* just to be safe ... */
+	ATM_SKB(skb)->atm_options = entry->shortcut->atm_options;
         entry->shortcut->dev->ops->send(entry->shortcut, skb);
 	entry->packets_fwded++;
 
diff -ur --new-file old/linux/net/atm/raw.c new/linux/net/atm/raw.c
--- old/linux/net/atm/raw.c	Thu Oct  1 23:49:56 1998
+++ new/linux/net/atm/raw.c	Thu Oct  1 23:50:41 1998
@@ -1,6 +1,6 @@
 /* net/atm/raw.c - Raw AAL0 and AAL5 transports */
 
-/* Written 1995-1997 by Werner Almesberger, EPFL LRC */
+/* Written 1995-1998 by Werner Almesberger, EPFL LRC */
 
 
 #include <linux/config.h>
@@ -43,8 +43,8 @@
 static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb)
 {
 #ifdef CONFIG_MMU_HACKS
-	if (skb->atm.iovcnt)
-		unlock_user(skb->atm.iovcnt,(struct iovec *) skb->data);
+	if (ATM_SKB(skb)->iovcnt)
+		unlock_user(ATM_SKB(skb)->iovcnt,(struct iovec *) skb->data);
 #endif
 	DPRINTK("APopR (%d) %d -= %d\n",vcc->vci,vcc->tx_inuse,skb->truesize);
 	atomic_sub(skb->truesize+ATM_PDU_OVHD,&vcc->tx_inuse);
diff -ur --new-file old/linux/net/core/skbuff.c new/linux/net/core/skbuff.c
--- old/linux/net/core/skbuff.c	Thu Oct  1 23:49:56 1998
+++ new/linux/net/core/skbuff.c	Thu Oct  1 23:50:41 1998
@@ -59,6 +59,10 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
+#if defined(CONFIG_ATM) && defined(CONFIG_ATM_SKB)
+#include <linux/atmdev.h>
+#endif
+
 /*
  * Skb list spinlock
  */
@@ -161,7 +165,11 @@
 	skb->cloned = 0;
 
 #ifdef CONFIG_ATM
+#ifdef CONFIG_ATM_SKB
+	ATM_SKB(skb)->iovcnt = 0;
+#else
 	skb->atm.iovcnt = 0;
+#endif
 #endif
 
 	atomic_set(&skb->users, 1); 
diff -ur --new-file old/linux/net/sched/sch_atm.c new/linux/net/sched/sch_atm.c
--- old/linux/net/sched/sch_atm.c	Thu Oct  1 23:49:56 1998
+++ new/linux/net/sched/sch_atm.c	Thu Oct  1 23:50:40 1998
@@ -345,7 +345,9 @@
 			}
 	if (!flow) flow = &p->link;
 	else {
-		if (flow->vcc) skb->atm.atm_options = flow->vcc->atm_options;
+		if (flow->vcc)
+			ATM_SKB(skb)->atm_options = flow->vcc->atm_options;
+			/*@@@ looks good ... but it's not supposed to work :-)*/
 #ifdef CONFIG_NET_CLS_POLICE
 		switch (result) {
 			case TC_POLICE_SHOT:
@@ -354,7 +356,8 @@
 			case TC_POLICE_RECLASSIFY:
 				if (flow->excess) flow = flow->excess;
 				else {
-					skb->atm.atm_options |= ATM_ATMOPT_CLP;
+					ATM_SKB(skb)->atm_options |=
+					    ATM_ATMOPT_CLP;
 					break;
 				}
 				/* fall through */
@@ -410,11 +413,11 @@
 			}
 			D2PRINTK("atm_tc_dequeue: ip %p, data %p\n",
 			    skb->nh.iph,skb->data);
-			skb->atm.vcc = flow->vcc;
+			ATM_SKB(skb)->vcc = flow->vcc;
 			memcpy(skb_push(skb,flow->hdr_len),flow->hdr,
 			    flow->hdr_len);
 			atomic_add(skb->truesize,&flow->vcc->tx_inuse);
-			skb->atm.iovcnt = 0;
+			ATM_SKB(skb)->iovcnt = 0;
 			/* atm.atm_options are already set by atm_tc_enqueue */
 			(void) flow->vcc->dev->ops->send(flow->vcc,skb);
 		}