Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 May 2009 22:33:15 +0000 (UTC)
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r192495 - projects/mesh11s/sys/net80211
Message-ID:  <200905202233.n4KMXFmk046478@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rpaulo
Date: Wed May 20 22:33:14 2009
New Revision: 192495
URL: http://svn.freebsd.org/changeset/base/192495

Log:
  Use fixed point to calculate airtime link metric and rename the function to
  ieee80211_airtime_calc() so it can be used by the HWMP module.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/mesh11s/sys/net80211/ieee80211_mesh.c
  projects/mesh11s/sys/net80211/ieee80211_mesh.h

Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c	Wed May 20 22:32:25 2009	(r192494)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c	Wed May 20 22:33:14 2009	(r192495)
@@ -77,8 +77,6 @@ static int	mesh_verify_meshid(struct iee
 		    struct ieee80211_meshid_ie *);
 static int	mesh_verify_meshconf(struct ieee80211vap *,
 		    struct ieee80211_meshconf_ie *);
-static uint32_t	mesh_compute_airtime(struct ieee80211vap *,
-		    struct ieee80211_node *);
 
 /* timeout values in miliseconds */
 static const int ieee80211_mesh_retrytimeout = 40;
@@ -915,7 +913,7 @@ mesh_recv_action(struct ieee80211_node *
 		{
 			uint32_t metric;
 
-			metric = mesh_compute_airtime(vap, ni);
+			metric = ieee80211_airtime_calc(vap, ni);
 			vargs.ptrarg = &metric;
 			ieee80211_send_action(ni,
 			    IEEE80211_ACTION_CAT_MESHLINK,
@@ -1190,23 +1188,30 @@ ieee80211_add_meshprep(uint8_t *frm, str
 
 /*
  * Compute an Airtime Link Metric for the link with this node.
- * XXX needs work
+ *
+ * Based on D3.0.
  */
-static uint32_t
-mesh_compute_airtime(struct ieee80211vap *vap, struct ieee80211_node *ni)
+uint32_t
+ieee80211_airtime_calc(struct ieee80211vap *vap, struct ieee80211_node *ni)
 {
-	uint32_t res, overhead, rate, errrate;
-	const static int nbits = 8192;
+#define M_BITS 8
+#define S_FACTOR (2 * M_BITS)
+	uint64_t res;
+	uint32_t overhead, rate, errrate;
+	const static int nbits = 8192 << M_BITS;
 
 	/* Channel access overhead */
-	overhead = 123; /* XXX */
+	overhead = 123 << M_BITS; /* XXX */
 	/* In Mbps */
-	rate = 10;
+	rate = ni->ni_txrate;
 	/* In percentage */
-	errrate = 10;
-	res = (overhead + (nbits / rate)) * (100 / (100 - errrate));
-
-	return res;
+	errrate = (10 << M_BITS) / 100;
+	res = (overhead + (nbits / rate)) *
+	    ((1 << S_FACTOR) / ((1 << M_BITS) - errrate));
+
+	return (uint32_t) (res >> S_FACTOR);
+#undef M_BITS
+#undef S_FACTOR
 }
 
 /*

Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.h	Wed May 20 22:32:25 2009	(r192494)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.h	Wed May 20 22:33:14 2009	(r192495)
@@ -329,6 +329,8 @@ uint8_t *	ieee80211_add_meshpeer(uint8_t
 		    uint16_t);
 uint8_t *	ieee80211_add_meshprep(uint8_t *,
 		    struct ieee80211_meshprep_ie *);
+uint32_t	ieee80211_airtime_calc(struct ieee80211vap *,
+		    struct ieee80211_node *);
 uint8_t *	ieee80211_add_meshlink(uint8_t *, uint32_t);
 void		ieee80211_create_mbss(struct ieee80211vap *, struct
 		    ieee80211_channel *);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905202233.n4KMXFmk046478>