svn commit: r195813 - head/sys/net80211

Sam Leffler sam at FreeBSD.org
Tue Jul 21 19:38:23 UTC 2009


Author: sam
Date: Tue Jul 21 19:38:22 2009
New Revision: 195813
URL: http://svn.freebsd.org/changeset/base/195813

Log:
  store mesh timers as ticks and sysctls for changing the defaults
  
  Reviewed by:	rpaulo
  Approved by:	re (kib)

Modified:
  head/sys/net80211/ieee80211_hwmp.c
  head/sys/net80211/ieee80211_mesh.c
  head/sys/net80211/ieee80211_mesh.h

Modified: head/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- head/sys/net80211/ieee80211_hwmp.c	Tue Jul 21 19:36:32 2009	(r195812)
+++ head/sys/net80211/ieee80211_hwmp.c	Tue Jul 21 19:38:22 2009	(r195813)
@@ -116,24 +116,8 @@ static struct ieee80211_node *
 		    const uint8_t [IEEE80211_ADDR_LEN], struct mbuf *);
 static void	hwmp_peerdown(struct ieee80211_node *);
 
-static int	ieee80211_hwmp_targetonly = 0;
-static int	ieee80211_hwmp_replyforward = 1;
-static const int ieee80211_hwmp_maxprepretries = 3;
-static const struct timeval ieee80211_hwmp_maxhopstime = { 0, 500000 };
-static const struct timeval ieee80211_hwmp_preqminint = { 0, 100000 };
-static const struct timeval ieee80211_hwmp_perrminint = { 0, 100000 };
-static const struct timeval ieee80211_hwmp_roottimeout = { 5, 0 };
-static const struct timeval ieee80211_hwmp_pathtimeout = { 5, 0 };
-static const struct timeval ieee80211_hwmp_pathtoroottimeout = { 5, 0 };
-static const struct timeval ieee80211_hwmp_rootint = { 2, 0 };
-static const struct timeval ieee80211_hwmp_rannint = { 1, 0 };
-static const struct timeval ieee80211_hwmp_pathmaintenanceint = { 2, 0 };
-static const struct timeval ieee80211_hwmp_confirmint = { 2, 0 };
-
-#define	timeval2msecs(tv)	(tv.tv_sec * 1000 + tv.tv_usec / 1000)
-
-#define	HWMP_ROOTMODEINT msecs_to_ticks(timeval2msecs(ieee80211_hwmp_rootint))
-#define	HWMP_RANNMODEINT msecs_to_ticks(timeval2msecs(ieee80211_hwmp_rannint))
+static struct timeval ieee80211_hwmp_preqminint = { 0, 100000 };
+static struct timeval ieee80211_hwmp_perrminint = { 0, 100000 };
 
 /* unalligned little endian access */
 #define LE_WRITE_2(p, v) do {				\
@@ -176,10 +160,28 @@ struct ieee80211_hwmp_state {
 
 SYSCTL_NODE(_net_wlan, OID_AUTO, hwmp, CTLFLAG_RD, 0,
     "IEEE 802.11s HWMP parameters");
+static int	ieee80211_hwmp_targetonly = 0;
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, targetonly, CTLTYPE_INT | CTLFLAG_RW,
     &ieee80211_hwmp_targetonly, 0, "Set TO bit on generated PREQs");
+static int	ieee80211_hwmp_replyforward = 1;
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, replyforward, CTLTYPE_INT | CTLFLAG_RW,
     &ieee80211_hwmp_replyforward, 0, "Set RF bit on generated PREQs");
+static int	ieee80211_hwmp_pathtimeout = -1;
+SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, pathlifetime, CTLTYPE_INT | CTLFLAG_RW,
+    &ieee80211_hwmp_pathtimeout, 0, ieee80211_sysctl_msecs_ticks, "I",
+    "path entry lifetime (ms)");
+static int	ieee80211_hwmp_roottimeout = -1;
+SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, roottimeout, CTLTYPE_INT | CTLFLAG_RW,
+    &ieee80211_hwmp_roottimeout, 0, ieee80211_sysctl_msecs_ticks, "I",
+    "root PREQ timeout (ms)");
+static int	ieee80211_hwmp_rootint = -1;
+SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, rootint, CTLTYPE_INT | CTLFLAG_RW,
+    &ieee80211_hwmp_rootint, 0, ieee80211_sysctl_msecs_ticks, "I",
+    "root interval (ms)");
+static int	ieee80211_hwmp_rannint = -1;
+SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, rannint, CTLTYPE_INT | CTLFLAG_RW,
+    &ieee80211_hwmp_rannint, 0, ieee80211_sysctl_msecs_ticks, "I",
+    "root announcement interval (ms)");
 
 #define	IEEE80211_HWMP_DEFAULT_MAXHOPS	31
 
@@ -188,7 +190,7 @@ static	ieee80211_recv_action_func hwmp_r
 static	ieee80211_recv_action_func hwmp_recv_action_meshpath_perr;
 static	ieee80211_recv_action_func hwmp_recv_action_meshpath_rann;
 
-static const struct ieee80211_mesh_proto_path mesh_proto_hwmp = {
+static struct ieee80211_mesh_proto_path mesh_proto_hwmp = {
 	.mpp_descr	= "HWMP",
 	.mpp_ie		= IEEE80211_MESHCONF_HWMP,
 	.mpp_discover	= hwmp_discover,
@@ -197,14 +199,20 @@ static const struct ieee80211_mesh_proto
 	.mpp_vdetach	= hwmp_vdetach,
 	.mpp_newstate	= hwmp_newstate,
 	.mpp_privlen	= sizeof(struct ieee80211_hwmp_route),
-	/* ieee80211_hwmp_pathtimeout */
-	.mpp_inact	= { 5, 0 },
 };
+SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, inact, CTLTYPE_INT | CTLFLAG_RW,
+	&mesh_proto_hwmp.mpp_inact, 0, ieee80211_sysctl_msecs_ticks, "I",
+	"mesh route inactivity timeout (ms)");
 
 
 static void
 ieee80211_hwmp_init(void)
 {
+	ieee80211_hwmp_pathtimeout = msecs_to_ticks(5*1000);
+	ieee80211_hwmp_roottimeout = msecs_to_ticks(5*1000);
+	ieee80211_hwmp_rootint = msecs_to_ticks(2*1000);
+	ieee80211_hwmp_rannint = msecs_to_ticks(1*1000);
+
 	/*
 	 * Register action frame handlers.
 	 */
@@ -217,6 +225,9 @@ ieee80211_hwmp_init(void)
 	ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESHPATH,
 	    IEEE80211_ACTION_MESHPATH_RANN, hwmp_recv_action_meshpath_rann);
 
+	/* NB: default is 5 secs per spec */
+	mesh_proto_hwmp.mpp_inact = msecs_to_ticks(5*1000);
+
 	/*
 	 * Register HWMP.
 	 */
@@ -617,11 +628,11 @@ hwmp_rootmode_setup(struct ieee80211vap 
 		break;
 	case IEEE80211_HWMP_ROOTMODE_NORMAL:
 	case IEEE80211_HWMP_ROOTMODE_PROACTIVE:
-		callout_reset(&hs->hs_roottimer, HWMP_ROOTMODEINT,
+		callout_reset(&hs->hs_roottimer, ieee80211_hwmp_rootint,
 		    hwmp_rootmode_cb, vap);
 		break;
 	case IEEE80211_HWMP_ROOTMODE_RANN:
-		callout_reset(&hs->hs_roottimer, HWMP_RANNMODEINT,
+		callout_reset(&hs->hs_roottimer, ieee80211_hwmp_rannint,
 		    hwmp_rootmode_rann_cb, vap);
 		break;
 	}
@@ -654,7 +665,7 @@ hwmp_rootmode_cb(void *arg)
 	preq.preq_id = ++hs->hs_preqid;
 	IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr);
 	preq.preq_origseq = ++hs->hs_seq;
-	preq.preq_lifetime = timeval2msecs(ieee80211_hwmp_roottimeout);
+	preq.preq_lifetime = ticks_to_msecs(ieee80211_hwmp_roottimeout);
 	preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
 	preq.preq_tcount = 1;
 	IEEE80211_ADDR_COPY(PREQ_TADDR(0), broadcastaddr);
@@ -1297,7 +1308,7 @@ hwmp_discover(struct ieee80211vap *vap,
 			}
 			rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
 			rt->rt_lifetime =
-			    timeval2msecs(ieee80211_hwmp_pathtimeout);
+			    ticks_to_msecs(ieee80211_hwmp_pathtimeout);
 			/* XXX check preq retries */
 			sendpreq = 1;
 			IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest,

Modified: head/sys/net80211/ieee80211_mesh.c
==============================================================================
--- head/sys/net80211/ieee80211_mesh.c	Tue Jul 21 19:36:32 2009	(r195812)
+++ head/sys/net80211/ieee80211_mesh.c	Tue Jul 21 19:38:22 2009	(r195813)
@@ -180,7 +180,7 @@ mesh_rt_add_locked(struct ieee80211_mesh
 	if (rt != NULL) {
 		IEEE80211_ADDR_COPY(rt->rt_dest, dest);
 		rt->rt_priv = (void *)ALIGN(&rt[1]);
-		getmicrouptime(&rt->rt_crtime);
+		rt->rt_crtime = ticks;
 		TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next);
 	}
 	return rt;
@@ -310,17 +310,13 @@ mesh_rt_flush_invalid(struct ieee80211va
 {
 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
 	struct ieee80211_mesh_route *rt, *next;
-	struct timeval tv, delta;
 
 	if (ms == NULL)
 		return;
-	getmicrouptime(&tv);
 	MESH_RT_LOCK(ms);
 	TAILQ_FOREACH_SAFE(rt, &ms->ms_routes, rt_next, next) {
-		delta = tv;
-		timevalsub(&delta, &rt->rt_crtime);
 		if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 &&
-		    timevalcmp(&delta, &ms->ms_ppath->mpp_inact, >=))
+		    ticks - rt->rt_crtime >= ms->ms_ppath->mpp_inact)
 			mesh_rt_del(ms, rt);
 	}
 	MESH_RT_UNLOCK(ms);
@@ -676,9 +672,7 @@ mesh_newstate(struct ieee80211vap *vap, 
 			break;
 		}
 		ieee80211_node_authorize(vap->iv_bss);
-		callout_reset(&ms->ms_cleantimer,
-		    msecs_to_ticks(ms->ms_ppath->mpp_inact.tv_sec * 1000 +
-		        ms->ms_ppath->mpp_inact.tv_usec / 1000),
+		callout_reset(&ms->ms_cleantimer, ms->ms_ppath->mpp_inact,
                     mesh_rt_cleanup_cb, vap);
 		break;
 	default:
@@ -696,9 +690,7 @@ mesh_rt_cleanup_cb(void *arg)
 	struct ieee80211_mesh_state *ms = vap->iv_mesh;
 
 	mesh_rt_flush_invalid(vap);
-	callout_reset(&ms->ms_cleantimer,
-	    msecs_to_ticks(ms->ms_ppath->mpp_inact.tv_sec * 1000 +
-	        ms->ms_ppath->mpp_inact.tv_usec / 1000),
+	callout_reset(&ms->ms_cleantimer, ms->ms_ppath->mpp_inact,
 	    mesh_rt_cleanup_cb, vap);
 }
 

Modified: head/sys/net80211/ieee80211_mesh.h
==============================================================================
--- head/sys/net80211/ieee80211_mesh.h	Tue Jul 21 19:36:32 2009	(r195812)
+++ head/sys/net80211/ieee80211_mesh.h	Tue Jul 21 19:38:22 2009	(r195813)
@@ -376,7 +376,7 @@ struct ieee80211_meshcntl_ae11 {
 MALLOC_DECLARE(M_80211_MESH_RT);
 struct ieee80211_mesh_route {
 	TAILQ_ENTRY(ieee80211_mesh_route)	rt_next;
-	struct timeval		rt_crtime;	/* creation time */
+	int			rt_crtime;	/* creation time */
 	uint8_t			rt_dest[IEEE80211_ADDR_LEN];
 	uint8_t			rt_nexthop[IEEE80211_ADDR_LEN];
 	uint32_t		rt_metric;	/* path metric */
@@ -409,7 +409,8 @@ struct ieee80211_mesh_proto_path {
 			    enum ieee80211_state, int);
 	const size_t	mpp_privlen;	/* size required in the routing table
 					   for private data */
-	const struct timeval mpp_inact;	/* inact. timeout for invalid routes */
+	int		mpp_inact;	/* inact. timeout for invalid routes
+					   (ticks) */
 };
 
 /*


More information about the svn-src-all mailing list