patch-2.3.99-pre3 linux/drivers/atm/nicstar.c

Next file: linux/drivers/atm/nicstar.h
Previous file: linux/drivers/atm/iphase.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre2/linux/drivers/atm/nicstar.c linux/drivers/atm/nicstar.c
@@ -37,8 +37,10 @@
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/interrupt.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
+#include <asm/atomic.h>
 #include "nicstar.h"
 #include "nicstarmac.h"
 #ifdef CONFIG_ATM_NICSTAR_USE_SUNI
@@ -284,7 +286,7 @@
       card = cards[i];
 
 #ifdef CONFIG_ATM_NICSTAR_USE_IDT77105
-      if (card->max_pcr == IDT_25_PCR) {
+      if (card->max_pcr == ATM_25_PCR) {
         idt77105_stop(card->atmdev);
       }
 #endif /* CONFIG_ATM_NICSTAR_USE_IDT77105 */
@@ -311,7 +313,7 @@
       PRINTK("nicstar%d: freeing %d huge buffers.\n", i, card->hbpool.count);
       while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL)
       {
-         kfree_skb(hb);
+         dev_kfree_skb_any(hb);
 	 j++;
       }
       PRINTK("nicstar%d: %d huge buffers freed.\n", i, j);
@@ -319,14 +321,14 @@
       PRINTK("nicstar%d: freeing %d iovec buffers.\n", i, card->iovpool.count);
       while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL)
       {
-         kfree_skb(iovb);
+         dev_kfree_skb_any(iovb);
          j++;
       }
       PRINTK("nicstar%d: %d iovec buffers freed.\n", i, j);
       while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL)
-         kfree_skb(lb);
+         dev_kfree_skb_any(lb);
       while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL)
-         kfree_skb(sb);
+         dev_kfree_skb_any(sb);
       free_scq(card->scq0, NULL);
       for (j = 0; j < NS_FRSCD_NUM; j++)
       {
@@ -547,7 +549,7 @@
    switch(data) {
       case 0x00000009:
          printk("nicstar%d: PHY seems to be 25 Mbps.\n", i);
-         card->max_pcr = IDT_25_PCR;
+         card->max_pcr = ATM_25_PCR;
          while(CMD_BUSY(card));
          writel(0x00000008, card->membase + DR0);
          writel(NS_CMD_WRITE_UTILITY | 0x00000200, card->membase + CMD);
@@ -857,7 +859,7 @@
    card->efbie = 1;
 
    /* Register device */
-   card->atmdev = atm_dev_register("nicstar", &atm_ops, -1, 0UL);
+   card->atmdev = atm_dev_register("nicstar", &atm_ops, -1, NULL);
    if (card->atmdev == NULL)
    {
       printk("nicstar%d: can't register device.\n", i);
@@ -891,7 +893,7 @@
 #endif /* CONFIG_ATM_NICSTAR_USE_SUNI */
 
 #ifdef CONFIG_ATM_NICSTAR_USE_IDT77105
-   if (card->max_pcr == IDT_25_PCR) {
+   if (card->max_pcr == ATM_25_PCR) {
       idt77105_init(card->atmdev);
       /* Note that for the IDT77105 PHY we don't need the awful
        * module count hack that the SUNI needs because we can
@@ -936,26 +938,26 @@
    {
       struct sk_buff *iovb;
       while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL)
-         kfree_skb(iovb);
+         dev_kfree_skb_any(iovb);
    }
    if (error >= 15)
    {
       struct sk_buff *sb;
       while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL)
-         kfree_skb(sb);
+         dev_kfree_skb_any(sb);
       free_scq(card->scq0, NULL);
    }
    if (error >= 14)
    {
       struct sk_buff *lb;
       while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL)
-         kfree_skb(lb);
+         dev_kfree_skb_any(lb);
    }
    if (error >= 13)
    {
       struct sk_buff *hb;
       while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL)
-         kfree_skb(hb);
+         dev_kfree_skb_any(hb);
    }
    if (error >= 12)
    {
@@ -1039,7 +1041,7 @@
             if (vcc->pop != NULL)
 	       vcc->pop(vcc, scq->skb[i]);
 	    else
-               dev_kfree_skb(scq->skb[i]);
+               dev_kfree_skb_any(scq->skb[i]);
          }
       }
    else /* vcc must be != NULL */
@@ -1048,7 +1050,7 @@
       {
          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]);
+            dev_kfree_skb_any(scq->skb[i]);
       }
       else
          for (i = 0; i < scq->num_entries; i++)
@@ -1058,7 +1060,7 @@
                if (vcc->pop != NULL)
                   vcc->pop(vcc, scq->skb[i]);
                else
-                  dev_kfree_skb(scq->skb[i]);
+                  dev_kfree_skb_any(scq->skb[i]);
             }
          }
    }
@@ -1130,9 +1132,9 @@
          if (card->sbfqc >= card->sbnr.max)
          {
             skb_unlink((struct sk_buff *) handle1);
-            kfree_skb((struct sk_buff *) handle1);
+            dev_kfree_skb_any((struct sk_buff *) handle1);
             skb_unlink((struct sk_buff *) handle2);
-            kfree_skb((struct sk_buff *) handle2);
+            dev_kfree_skb_any((struct sk_buff *) handle2);
             return;
          }
 	 else
@@ -1143,9 +1145,9 @@
          if (card->lbfqc >= card->lbnr.max)
          {
             skb_unlink((struct sk_buff *) handle1);
-            kfree_skb((struct sk_buff *) handle1);
+            dev_kfree_skb_any((struct sk_buff *) handle1);
             skb_unlink((struct sk_buff *) handle2);
-            kfree_skb((struct sk_buff *) handle2);
+            dev_kfree_skb_any((struct sk_buff *) handle2);
             return;
          }
          else
@@ -1420,16 +1422,16 @@
       return -EINVAL;
    }
 
-   vcc->flags |= ATM_VF_ADDR;
+   set_bit(ATM_VF_ADDR,&vcc->flags);
 
    /* 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))
+   if (!test_bit(ATM_VF_PARTIAL,&vcc->flags))
    {
       scq_info *scq;
       
-      vcc->flags |= ATM_VF_PARTIAL;
+      set_bit(ATM_VF_PARTIAL,&vcc->flags);
       if (vcc->qos.txtp.traffic_class == ATM_CBR)
       {
          /* Check requested cell rate and availability of SCD */
@@ -1438,7 +1440,8 @@
          {
             PRINTK("nicstar%d: trying to open a CBR vc with cell rate = 0 \n",
 	           card->index);
-            vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+	    clear_bit(ATM_VF_PARTIAL,&vcc->flags);
+	    clear_bit(ATM_VF_ADDR,&vcc->flags);
             return -EINVAL;
          }
 
@@ -1461,7 +1464,8 @@
             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);
+	       clear_bit(ATM_VF_PARTIAL,&vcc->flags);
+	       clear_bit(ATM_VF_ADDR,&vcc->flags);
                return -EINVAL;
             }
          }
@@ -1469,14 +1473,16 @@
          if (n == 0)
          {
             printk("nicstar%d: selected bandwidth < granularity.\n", card->index);
-            vcc->flags &= ~(ATM_VF_ADDR | ATM_VF_PARTIAL);
+	    clear_bit(ATM_VF_PARTIAL,&vcc->flags);
+	    clear_bit(ATM_VF_ADDR,&vcc->flags);
             return -EINVAL;
          }
 
          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);
+	    clear_bit(ATM_VF_PARTIAL,&vcc->flags);
+	    clear_bit(ATM_VF_ADDR,&vcc->flags);
             return -EINVAL;
          }
          else
@@ -1495,7 +1501,8 @@
          {
             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);
+	    clear_bit(ATM_VF_PARTIAL,&vcc->flags);
+	    clear_bit(ATM_VF_ADDR,&vcc->flags);
 	    return -EBUSY;
          }
 
@@ -1507,7 +1514,8 @@
             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);
+	    clear_bit(ATM_VF_PARTIAL,&vcc->flags);
+	    clear_bit(ATM_VF_ADDR,&vcc->flags);
             return -ENOMEM;
          }
 	 vc->scq = scq;
@@ -1553,7 +1561,7 @@
       
    }
    
-   vcc->flags |= ATM_VF_READY;
+   set_bit(ATM_VF_READY,&vcc->flags);
    MOD_INC_USE_COUNT;
    return 0;
 }
@@ -1572,7 +1580,7 @@
    PRINTK("nicstar%d: closing vpi.vci %d.%d \n", card->index,
           (int) vcc->vpi, vcc->vci);
 
-   vcc->flags &= ~(ATM_VF_READY);
+   clear_bit(ATM_VF_READY,&vcc->flags);
    
    if (vcc->qos.rxtp.traffic_class != ATM_NONE)
    {
@@ -1681,7 +1689,8 @@
    }
 
    vcc->dev_data = NULL;
-   vcc->flags &= ~(ATM_VF_PARTIAL | ATM_VF_ADDR);
+   clear_bit(ATM_VF_PARTIAL,&vcc->flags);
+   clear_bit(ATM_VF_ADDR,&vcc->flags);
    MOD_DEC_USE_COUNT;
 
 #ifdef RX_DEBUG
@@ -1778,32 +1787,32 @@
    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);
+      atomic_inc(&vcc->stats->tx_err);
+      dev_kfree_skb_any(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);
+      atomic_inc(&vcc->stats->tx_err);
+      dev_kfree_skb_any(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);
+      atomic_inc(&vcc->stats->tx_err);
+      dev_kfree_skb_any(skb);
       return -EINVAL;
    }
    
    if (ATM_SKB(skb)->iovcnt != 0)
    {
       printk("nicstar%d: No scatter-gather yet.\n", card->index);
-      vcc->stats->tx_err++;
-      dev_kfree_skb(skb);
+      atomic_inc(&vcc->stats->tx_err);
+      dev_kfree_skb_any(skb);
       return -EINVAL;
    }
    
@@ -1847,11 +1856,11 @@
 
    if (push_scqe(card, vc, scq, &scqe, skb) != 0)
    {
-      vcc->stats->tx_err++;
-      dev_kfree_skb(skb);
+      atomic_inc(&vcc->stats->tx_err);
+      dev_kfree_skb_any(skb);
       return -EIO;
    }
-   vcc->stats->tx++;
+   atomic_inc(&vcc->stats->tx);
 
    return 0;
 }
@@ -2071,7 +2080,7 @@
 	 if (vcc->pop != NULL)
 	    vcc->pop(vcc, skb);
 	 else
-	    dev_kfree_skb(skb);
+	    dev_kfree_skb_any(skb);
 	 scq->skb[i] = NULL;
       }
       if (++i == scq->num_entries)
@@ -2155,15 +2164,15 @@
          {
             printk("nicstar%d: Can't allocate buffers for aal0.\n",
                    card->index);
-            vcc->stats->rx_drop += i;
+            atomic_add(i,&vcc->stats->rx_drop);
             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);
+            atomic_add(i-1,&vcc->stats->rx_drop); /* already increased by 1 */
+            dev_kfree_skb_any(sb);
             break;
          }
          /* Rebuild the header */
@@ -2177,7 +2186,7 @@
          ATM_SKB(sb)->vcc = vcc;
          sb->stamp = xtime;
          vcc->push(vcc, sb);
-         vcc->stats->rx++;
+         atomic_inc(&vcc->stats->rx);
          cell += ATM_CELL_PAYLOAD;
       }
 
@@ -2196,7 +2205,7 @@
 	 if (iovb == NULL)
 	 {
 	    printk("nicstar%d: Out of iovec buffers.\n", card->index);
-            vcc->stats->rx_drop++;
+            atomic_inc(&vcc->stats->rx_drop);
             recycle_rx_buf(card, skb);
             return;
 	 }
@@ -2223,7 +2232,7 @@
    else if (ATM_SKB(iovb)->iovcnt >= NS_MAX_IOVECS)
    {
       printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
-      vcc->stats->rx_err++;
+      atomic_inc(&vcc->stats->rx_err);
       recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data, NS_MAX_IOVECS);
       ATM_SKB(iovb)->iovcnt = 0;
       iovb->len = 0;
@@ -2242,7 +2251,7 @@
          printk("nicstar%d: Expected a small buffer, and this is not one.\n",
 	        card->index);
          which_list(card, skb);
-         vcc->stats->rx_err++;
+         atomic_inc(&vcc->stats->rx_err);
          recycle_rx_buf(card, skb);
          vc->rx_iov = NULL;
          recycle_iov_buf(card, iovb);
@@ -2256,7 +2265,7 @@
          printk("nicstar%d: Expected a large buffer, and this is not one.\n",
 	        card->index);
          which_list(card, skb);
-         vcc->stats->rx_err++;
+         atomic_inc(&vcc->stats->rx_err);
          recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
 	                       ATM_SKB(iovb)->iovcnt);
          vc->rx_iov = NULL;
@@ -2280,7 +2289,7 @@
             printk(" - PDU size mismatch.\n");
          else
             printk(".\n");
-         vcc->stats->rx_err++;
+         atomic_inc(&vcc->stats->rx_err);
          recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
 	   ATM_SKB(iovb)->iovcnt);
 	 vc->rx_iov = NULL;
@@ -2308,7 +2317,7 @@
             ATM_SKB(skb)->vcc = vcc;
             skb->stamp = xtime;
             vcc->push(vcc, skb);
-            vcc->stats->rx++;
+            atomic_inc(&vcc->stats->rx);
          }
       }
       else if (ATM_SKB(iovb)->iovcnt == 2)	/* One small plus one large buffer */
@@ -2335,7 +2344,7 @@
                ATM_SKB(sb)->vcc = vcc;
                sb->stamp = xtime;
                vcc->push(vcc, sb);
-               vcc->stats->rx++;
+               atomic_inc(&vcc->stats->rx);
             }
 
             push_rxbufs(card, BUF_LG, (u32) skb,
@@ -2361,7 +2370,7 @@
                ATM_SKB(skb)->vcc = vcc;
                skb->stamp = xtime;
                vcc->push(vcc, skb);
-               vcc->stats->rx++;
+               atomic_inc(&vcc->stats->rx);
             }
 
             push_rxbufs(card, BUF_SM, (u32) sb, (u32) virt_to_bus(sb->data),
@@ -2384,7 +2393,7 @@
             if (hb == NULL)
             {
                printk("nicstar%d: Out of huge buffers.\n", card->index);
-               vcc->stats->rx_drop++;
+               atomic_inc(&vcc->stats->rx_drop);
                recycle_iovec_rx_bufs(card, (struct iovec *) iovb->data,
 	                             ATM_SKB(iovb)->iovcnt);
                vc->rx_iov = NULL;
@@ -2431,7 +2440,7 @@
                card->hbpool.count++;
             }
 	    else
-	       kfree_skb(hb);
+	       dev_kfree_skb_any(hb);
          }
          else
 	 {
@@ -2467,7 +2476,7 @@
 #endif /* NS_USE_DESTRUCTORS */
             hb->stamp = xtime;
             vcc->push(vcc, hb);
-            vcc->stats->rx++;
+            atomic_inc(&vcc->stats->rx);
          }
       }
 
@@ -2556,7 +2565,7 @@
    else
    {
       printk("nicstar%d: What kind of rx buffer is this?\n", card->index);
-      kfree_skb(skb);
+      dev_kfree_skb_any(skb);
    }
 }
 
@@ -2578,7 +2587,7 @@
       else
       {
          printk("nicstar%d: What kind of rx buffer is this?\n", card->index);
-         kfree_skb(skb);
+         dev_kfree_skb_any(skb);
       }
    }
 }
@@ -2593,7 +2602,7 @@
       card->iovpool.count++;
    }
    else
-      kfree_skb(iovb);
+      dev_kfree_skb_any(iovb);
 }
 
 
@@ -2700,7 +2709,7 @@
    /* Dump 25.6 Mbps PHY registers */
    /* Now there's a 25.6 Mbps PHY driver this code isn't needed. I left it
       here just in case it's needed for debugging. */
-   if (card->max_pcr == IDT_25_PCR && !left--)
+   if (card->max_pcr == ATM_25_PCR && !left--)
    {
       u32 phy_regs[4];
       u32 i;
@@ -2787,7 +2796,7 @@
 	    return -EFAULT;
 
       case NS_SETBUFLEV:
-         if (!suser())
+         if (!capable(CAP_NET_ADMIN))
 	    return -EPERM;
          if (copy_from_user(&pl, (pool_levels *) arg, sizeof(pl)))
 	    return -EFAULT;
@@ -2836,7 +2845,7 @@
          return 0;
 
       case NS_ADJBUFLEV:
-         if (!suser())
+         if (!capable(CAP_NET_ADMIN))
 	    return -EPERM;
          btype = (int) arg;	/* an int is the same size as a pointer */
          switch (btype)
@@ -2882,7 +2891,7 @@
 		     printk("nicstar%d: huge buffer count inconsistent.\n",
 		            card->index);
                   else
-		     kfree_skb(hb);
+		     dev_kfree_skb_any(hb);
 		  
 	       }
                while (card->hbpool.count < card->hbnr.init)
@@ -2912,7 +2921,7 @@
 		     printk("nicstar%d: iovec buffer count inconsistent.\n",
 		            card->index);
                   else
-		     kfree_skb(iovb);
+		     dev_kfree_skb_any(iovb);
 
 	       }
                while (card->iovpool.count < card->iovnr.init)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)