b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@ascom.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@ascom.ch>
Subject: [B.A.T.M.A.N.] [PATCH 09/11] batman-adv: Use local tq values determined by NDP on OGMs
Date: Fri, 14 Jan 2011 01:59:52 +0100	[thread overview]
Message-ID: <1294966794-17780-10-git-send-email-linus.luessing@ascom.ch> (raw)
In-Reply-To: <1294966794-17780-1-git-send-email-linus.luessing@ascom.ch>

With this commit not the local transmit quality values determined
by the OGMs themselves are applied on received OGMs, but the local
transmit quality detemined by NDP instead. Usually the link quality
measurements of NDP are more up-to-date than the one of the OGMs, as NDP
is using a more frequent interval because NDP's packets are not being
flooded through the whole mesh.

Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
 routing.c |   62 ++++++++++++++++++++++++++++--------------------------------
 1 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/batman-adv/routing.c b/batman-adv/routing.c
index 947592f..8a3acfa 100644
--- a/batman-adv/routing.c
+++ b/batman-adv/routing.c
@@ -152,7 +152,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
 	struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
 	struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
 	struct hlist_node *node;
-	unsigned char total_count;
+	uint8_t local_tq = 0, local_rq = 0;
 
 	if (orig_node == orig_neigh_node) {
 		rcu_read_lock();
@@ -199,25 +199,23 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
 			return 0;
 	}
 
-	orig_node->last_valid = jiffies;
+	/* note, bottom halves are already deactivated outside in
+	 * recv_bat_packet() */
+	spin_lock(&if_incoming->neigh_list_lock);
+	hlist_for_each_entry(neigh_node, node, &if_incoming->neigh_list,
+								list) {
+		if (!compare_orig(neigh_node->addr, orig_neigh_node->orig))
+			continue;
 
-	/* pay attention to not get a value bigger than 100 % */
-	total_count = (orig_neigh_node->bcast_own_sum[if_incoming->if_num] >
-		       neigh_node->real_packet_count ?
-		       neigh_node->real_packet_count :
-		       orig_neigh_node->bcast_own_sum[if_incoming->if_num]);
+		orig_node->last_valid = jiffies;
+		local_tq = neigh_node->tq_avg;
+		local_rq = neigh_node->rq;
+		break;
+	}
+	spin_unlock(&if_incoming->neigh_list_lock);
 
-	/* if we have too few packets (too less data) we set tq_own to zero */
-	/* if we receive too few packets it is not considered bidirectional */
-	if ((total_count < TQ_LOCAL_BIDRECT_SEND_MINIMUM) ||
-	    (neigh_node->real_packet_count < TQ_LOCAL_BIDRECT_RECV_MINIMUM))
-		orig_neigh_node->tq_own = 0;
-	else
-		/* neigh_node->real_packet_count is never zero as we
-		 * only purge old information when getting new
-		 * information */
-		orig_neigh_node->tq_own = (TQ_MAX_VALUE * total_count) /
-			neigh_node->real_packet_count;
+	if (local_tq == 0)
+		return 0;
 
 	/*
 	 * 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does
@@ -228,25 +226,22 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
 	orig_neigh_node->tq_asym_penalty =
 		TQ_MAX_VALUE -
 		(TQ_MAX_VALUE *
-		 (TQ_LOCAL_WINDOW_SIZE - neigh_node->real_packet_count) *
-		 (TQ_LOCAL_WINDOW_SIZE - neigh_node->real_packet_count) *
-		 (TQ_LOCAL_WINDOW_SIZE - neigh_node->real_packet_count)) /
-		(TQ_LOCAL_WINDOW_SIZE *
-		 TQ_LOCAL_WINDOW_SIZE *
-		 TQ_LOCAL_WINDOW_SIZE);
+		 (TQ_MAX_VALUE - local_rq) *
+		 (TQ_MAX_VALUE - local_rq) *
+		 (TQ_MAX_VALUE - local_rq)) /
+		(TQ_MAX_VALUE *
+		 TQ_MAX_VALUE *
+		 TQ_MAX_VALUE);
 
-	ogm_packet->tq = ((ogm_packet->tq *
-			      orig_neigh_node->tq_own *
-			      orig_neigh_node->tq_asym_penalty) /
-			     (TQ_MAX_VALUE * TQ_MAX_VALUE));
+	ogm_packet->tq = ((ogm_packet->tq * local_tq *
+			   orig_neigh_node->tq_asym_penalty) /
+			   (TQ_MAX_VALUE * TQ_MAX_VALUE));
 
 	bat_dbg(DBG_BATMAN, bat_priv,
 		"bidirectional: "
-		"orig = %-15pM neigh = %-15pM => own_bcast = %2i, "
-		"real recv = %2i, local tq: %3i, asym_penalty: %3i, "
-		"total tq: %3i\n",
-		orig_node->orig, orig_neigh_node->orig, total_count,
-		neigh_node->real_packet_count, orig_neigh_node->tq_own,
+		"orig = %-15pM neigh = %-15pM => local tq = %3i, "
+		"local rq: %3i, asym_penalty: %3i, total tq: %3i\n",
+		orig_node->orig, orig_neigh_node->orig, local_tq, local_rq,
 		orig_neigh_node->tq_asym_penalty, ogm_packet->tq);
 
 	/* if link has the minimum required transmission quality
@@ -859,6 +854,7 @@ int recv_bat_packet(struct sk_buff *skb,
 
 	ethhdr = (struct ethhdr *)skb_mac_header(skb);
 
+	/* note, is_bidirectional_neigh() relies on deactivated bottom halves */
 	spin_lock_bh(&bat_priv->orig_hash_lock);
 	receive_aggr_bat_packet(ethhdr,
 				skb->data,
-- 
1.7.1


  parent reply	other threads:[~2011-01-14  0:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-14  0:59 [B.A.T.M.A.N.] NDP patches v5 Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 01/11] batman-adv: Rename packet type / structure / functions for OGMs Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 02/11] batman-adv: Adding workqueue for new ndp packets Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 03/11] batman-adv: Send neighbor discovery packets Linus Lüssing
2011-01-15 13:53   ` Andrew Lunn
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 04/11] batman-adv: Creating neighbor structures, updating LQs Linus Lüssing
2011-01-15 14:14   ` Andrew Lunn
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 05/11] batman-adv: Purge outdated ndp neighbours Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 06/11] batman-adv: Adding ndp debugfs output Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 07/11] batman-adv: Adding batman_if specific sysfs wrapper macros for UINT Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 08/11] batman-adv: Adding sysfs parameter for ndp interval Linus Lüssing
2011-01-14  0:59 ` Linus Lüssing [this message]
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 10/11] batman-adv: Use rcu locking + ref-counting for neigh_list Linus Lüssing
2011-01-14  0:59 ` [B.A.T.M.A.N.] [PATCH 11/11] batman-adv: Adding sysfs ABI documentation for ndp_interval Linus Lüssing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1294966794-17780-10-git-send-email-linus.luessing@ascom.ch \
    --to=linus.luessing@ascom.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).