[commits] r1637 - trunk/batman-adv-kernelland

postmaster at open-mesh.net postmaster at open-mesh.net
Mon Apr 19 22:14:08 CEST 2010


Author: simon
Date: 2010-04-19 22:13:31 +0200 (Mon, 19 Apr 2010)
New Revision: 1637

Modified:
   trunk/batman-adv-kernelland/aggregation.c
   trunk/batman-adv-kernelland/bat_sysfs.c
   trunk/batman-adv-kernelland/main.c
   trunk/batman-adv-kernelland/main.h
   trunk/batman-adv-kernelland/send.c
   trunk/batman-adv-kernelland/types.h
Log:
batman-adv: move queue counters into bat_priv

to support multiple mesh devices later, we need to move global variables
like the queues into corresponding private structs bat_priv of the soft
devices.

Note that this patch still has a lot of FIXMEs and depends on the global
soft_device variable. This should be resolved later, e.g. by referencing
the parent soft device in batman_if.

Signed-off-by: Simon Wunderlich <siwu at hrz.tu-chemnitz.de>


Modified: trunk/batman-adv-kernelland/aggregation.c
===================================================================
--- trunk/batman-adv-kernelland/aggregation.c	2010-04-15 08:37:15 UTC (rev 1636)
+++ trunk/batman-adv-kernelland/aggregation.c	2010-04-19 20:13:31 UTC (rev 1637)
@@ -106,10 +106,12 @@
 {
 	struct forw_packet *forw_packet_aggr;
 	unsigned long flags;
+	/* FIXME: each batman_if will be attached to a softif */
+	struct bat_priv *bat_priv = netdev_priv(soft_device);
 
 	/* own packet should always be scheduled */
 	if (!own_packet) {
-		if (!atomic_dec_not_zero(&batman_queue_left)) {
+		if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
 			bat_dbg(DBG_BATMAN, "batman packet queue full\n");
 			return;
 		}
@@ -118,7 +120,7 @@
 	forw_packet_aggr = kmalloc(sizeof(struct forw_packet), GFP_ATOMIC);
 	if (!forw_packet_aggr) {
 		if (!own_packet)
-			atomic_inc(&batman_queue_left);
+			atomic_inc(&bat_priv->batman_queue_left);
 		return;
 	}
 
@@ -126,7 +128,7 @@
 						GFP_ATOMIC);
 	if (!forw_packet_aggr->packet_buff) {
 		if (!own_packet)
-			atomic_inc(&batman_queue_left);
+			atomic_inc(&bat_priv->batman_queue_left);
 		kfree(forw_packet_aggr);
 		return;
 	}

Modified: trunk/batman-adv-kernelland/bat_sysfs.c
===================================================================
--- trunk/batman-adv-kernelland/bat_sysfs.c	2010-04-15 08:37:15 UTC (rev 1636)
+++ trunk/batman-adv-kernelland/bat_sysfs.c	2010-04-19 20:13:31 UTC (rev 1637)
@@ -408,6 +408,9 @@
 	atomic_set(&bat_priv->gw_mode, GW_MODE_OFF);
 	atomic_set(&bat_priv->gw_class, 0);
 	atomic_set(&bat_priv->orig_interval, 1000);
+	atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN);
+	atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN);
+
 	bat_priv->primary_if = NULL;
 	bat_priv->num_ifaces = 0;
 

Modified: trunk/batman-adv-kernelland/main.c
===================================================================
--- trunk/batman-adv-kernelland/main.c	2010-04-15 08:37:15 UTC (rev 1636)
+++ trunk/batman-adv-kernelland/main.c	2010-04-19 20:13:31 UTC (rev 1637)
@@ -44,8 +44,6 @@
 DEFINE_SPINLOCK(forw_bcast_list_lock);
 
 atomic_t vis_interval;
-atomic_t bcast_queue_left;
-atomic_t batman_queue_left;
 
 int16_t num_hna;
 
@@ -84,8 +82,6 @@
 
 	atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only
 					 * for debugging now. */
-	atomic_set(&bcast_queue_left, BCAST_QUEUE_LEN);
-	atomic_set(&batman_queue_left, BATMAN_QUEUE_LEN);
 
 	/* the name should not be longer than 10 chars - see
 	 * http://lwn.net/Articles/23634/ */

Modified: trunk/batman-adv-kernelland/main.h
===================================================================
--- trunk/batman-adv-kernelland/main.h	2010-04-15 08:37:15 UTC (rev 1636)
+++ trunk/batman-adv-kernelland/main.h	2010-04-19 20:13:31 UTC (rev 1637)
@@ -138,8 +138,6 @@
 extern spinlock_t forw_bcast_list_lock;
 
 extern atomic_t vis_interval;
-extern atomic_t bcast_queue_left;
-extern atomic_t batman_queue_left;
 extern int16_t num_hna;
 
 extern struct net_device *soft_device;

Modified: trunk/batman-adv-kernelland/send.c
===================================================================
--- trunk/batman-adv-kernelland/send.c	2010-04-15 08:37:15 UTC (rev 1636)
+++ trunk/batman-adv-kernelland/send.c	2010-04-19 20:13:31 UTC (rev 1637)
@@ -397,8 +397,10 @@
 int add_bcast_packet_to_list(struct sk_buff *skb)
 {
 	struct forw_packet *forw_packet;
+	/* FIXME: each batman_if will be attached to a softif */
+	struct bat_priv *bat_priv = netdev_priv(soft_device);
 
-	if (!atomic_dec_not_zero(&bcast_queue_left)) {
+	if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
 		bat_dbg(DBG_BATMAN, "bcast packet queue full\n");
 		goto out;
 	}
@@ -426,7 +428,7 @@
 packet_free:
 	kfree(forw_packet);
 out_and_inc:
-	atomic_inc(&bcast_queue_left);
+	atomic_inc(&bat_priv->bcast_queue_left);
 out:
 	return NETDEV_TX_BUSY;
 }
@@ -440,6 +442,8 @@
 		container_of(delayed_work, struct forw_packet, delayed_work);
 	unsigned long flags;
 	struct sk_buff *skb1;
+	/* FIXME: each batman_if will be attached to a softif */
+	struct bat_priv *bat_priv = netdev_priv(soft_device);
 
 	spin_lock_irqsave(&forw_bcast_list_lock, flags);
 	hlist_del(&forw_packet->list);
@@ -465,7 +469,7 @@
 		_add_bcast_packet_to_list(forw_packet, ((5 * HZ) / 1000));
 	else {
 		forw_packet_free(forw_packet);
-		atomic_inc(&bcast_queue_left);
+		atomic_inc(&bat_priv->bcast_queue_left);
 	}
 }
 
@@ -476,6 +480,8 @@
 	struct forw_packet *forw_packet =
 		container_of(delayed_work, struct forw_packet, delayed_work);
 	unsigned long flags;
+	/* FIXME: each batman_if will be attached to a softif */
+	struct bat_priv *bat_priv = netdev_priv(soft_device);
 
 	spin_lock_irqsave(&forw_bat_list_lock, flags);
 	hlist_del(&forw_packet->list);
@@ -494,7 +500,7 @@
 
 	/* don't count own packet */
 	if (!forw_packet->own)
-		atomic_inc(&batman_queue_left);
+		atomic_inc(&bat_priv->batman_queue_left);
 
 	forw_packet_free(forw_packet);
 }

Modified: trunk/batman-adv-kernelland/types.h
===================================================================
--- trunk/batman-adv-kernelland/types.h	2010-04-15 08:37:15 UTC (rev 1636)
+++ trunk/batman-adv-kernelland/types.h	2010-04-19 20:13:31 UTC (rev 1637)
@@ -104,6 +104,8 @@
 	atomic_t gw_mode;
 	atomic_t gw_class;
 	atomic_t orig_interval;
+	atomic_t bcast_queue_left;
+	atomic_t batman_queue_left;
 	char num_ifaces;
 	struct batman_if *primary_if;
 	struct kobject *mesh_obj;



More information about the commits mailing list