svn commit: r192495 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Wed May 20 22:33:15 UTC 2009
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 *);
More information about the svn-src-projects
mailing list