patch-2.3.13 linux/drivers/net/shaper.c

Next file: linux/drivers/net/sk_g16.c
Previous file: linux/drivers/net/sdla.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.12/linux/drivers/net/shaper.c linux/drivers/net/shaper.c
@@ -51,14 +51,19 @@
  *		will render your machine defunct. Don't for now shape over
  *		PPP or SLIP therefore!
  *		This will be fixed in BETA4
- */
- 
-/*
- * bh_atomic() SMP races fixes and rewritten the locking code to be SMP safe
- * and irq-mask friendly. NOTE: we can't use start_bh_atomic() in kick_shaper()
- * because it's going to be recalled from an irq handler, and synchronize_bh()
- * is a nono if called from irq context.
+ *
+ * Update History :
+ *
+ *              bh_atomic() SMP races fixes and rewritten the locking code to
+ *              be SMP safe and irq-mask friendly.
+ *              NOTE: we can't use start_bh_atomic() in kick_shaper()
+ *              because it's going to be recalled from an irq handler,
+ *              and synchronize_bh() is a nono if called from irq context.
  *						1999  Andrea Arcangeli
+ *
+ *              Device statistics (tx_pakets, tx_bytes,
+ *              tx_drops: queue_over_time and collisions: max_queue_exceded)
+ *                               1999/06/18 Jordi Murgo <savage@apostols.org>
  */
  
 #include <linux/module.h>
@@ -228,18 +233,20 @@
 		/*
 		 *	Queue over time. Spill packet.
 		 */
-		if(skb->shapeclock-jiffies > SHAPER_LATENCY)
+		if(skb->shapeclock-jiffies > SHAPER_LATENCY) {
 			dev_kfree_skb(skb);
-		else
+			shaper->stats.tx_dropped++;
+		} else
 			skb_queue_tail(&shaper->sendq, skb);
 	}
 #endif 	
- 	if(sh_debug)
+	if(sh_debug)
  		printk("Frame queued.\n");
  	if(skb_queue_len(&shaper->sendq)>SHAPER_QLEN)
  	{
  		ptr=skb_dequeue(&shaper->sendq);
- 		dev_kfree_skb(ptr);
+                dev_kfree_skb(ptr);
+                shaper->stats.collisions++;
  	}
  	shaper_unlock(shaper);
  	return 0;
@@ -262,7 +269,11 @@
 			printk("Kick new frame to %s, %d\n",
 				shaper->dev->name,newskb->priority);
 		dev_queue_xmit(newskb);
-		if(sh_debug)
+
+                shaper->stats.tx_bytes+=newskb->len;
+		shaper->stats.tx_packets++;
+
+                if(sh_debug)
 			printk("Kicked new frame out.\n");
 		dev_kfree_skb(skb);
 	}
@@ -415,7 +426,8 @@
 
 static struct net_device_stats *shaper_get_stats(struct device *dev)
 {
-	return NULL;
+     	struct shaper *sh=dev->priv;
+	return &sh->stats;
 }
 
 static int shaper_header(struct sk_buff *skb, struct device *dev, 
@@ -590,7 +602,7 @@
  *	Add a shaper device to the system
  */
  
-__initfunc(int shaper_probe(struct device *dev))
+int __init shaper_probe(struct device *dev)
 {
 	/*
 	 *	Set up the shaper.
@@ -665,7 +677,9 @@
 
 void cleanup_module(void)
 {
-	/*
+        struct shaper *sh=dev_shape.priv;
+
+        /*
 	 *	No need to check MOD_IN_USE, as sys_delete_module() checks.
 	 *	To be unloadable we must be closed and detached so we don't
 	 *	need to flush things.
@@ -674,10 +688,9 @@
 	unregister_netdev(&dev_shape);
 
 	/*
-	 *	Free up the private structure, or leak memory :-) 
+	 *	Free up the private structure, or leak memory :-)
 	 */
-	 
-	kfree(dev_shape.priv);
+	kfree(sh);
 	dev_shape.priv = NULL;
 }
 

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