From owner-svn-src-projects@FreeBSD.ORG Fri May 15 09:47:11 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 696E5106566B; Fri, 15 May 2009 09:47:11 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 574D48FC0A; Fri, 15 May 2009 09:47:11 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4F9lBod018546; Fri, 15 May 2009 09:47:11 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4F9lBWb018542; Fri, 15 May 2009 09:47:11 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200905150947.n4F9lBWb018542@svn.freebsd.org> From: Rui Paulo Date: Fri, 15 May 2009 09:47:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192137 - projects/mesh11s/sys/net80211 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 09:47:11 -0000 Author: rpaulo Date: Fri May 15 09:47:10 2009 New Revision: 192137 URL: http://svn.freebsd.org/changeset/base/192137 Log: * move code to create mesh prep IEs to the mesh C file * add some comments * initial work on airtime link metric report. Sponsored by: The FreeBSD Foundation Modified: projects/mesh11s/sys/net80211/ieee80211_input.c projects/mesh11s/sys/net80211/ieee80211_mesh.c projects/mesh11s/sys/net80211/ieee80211_mesh.h projects/mesh11s/sys/net80211/ieee80211_output.c Modified: projects/mesh11s/sys/net80211/ieee80211_input.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_input.c Fri May 15 04:53:55 2009 (r192136) +++ projects/mesh11s/sys/net80211/ieee80211_input.c Fri May 15 09:47:10 2009 (r192137) @@ -807,9 +807,14 @@ ieee80211_recv_action(struct ieee80211_n break; } break; + case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_MESHLINK: + case IEEE80211_ACTION_CAT_MESHPATH: + /* handled by ieee80211_mesh.c */ + break; default: IEEE80211_NOTE(vap, - IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni, + IEEE80211_MSG_ACTION, ni, "%s: category %d not implemented", __func__, ia->ia_category); vap->iv_stats.is_rx_mgtdiscard++; Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.c Fri May 15 04:53:55 2009 (r192136) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Fri May 15 09:47:10 2009 (r192137) @@ -77,6 +77,8 @@ 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; @@ -884,6 +886,33 @@ mesh_recv_action(struct ieee80211_node * break; } break; + /* + * Airtime link metric handling. + */ + case IEEE80211_ACTION_CAT_MESHLINK: + switch (ia->ia_action) { + case IEEE80211_ACTION_MESHLINK_REQ: + { + uint32_t metric; + + metric = mesh_compute_airtime(vap, ni); + vargs.ptrarg = &metric; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_MESHLINK, + IEEE80211_ACTION_MESHLINK_REP, + vargs); + } + break; + case IEEE80211_ACTION_MESHLINK_REP: + break; + default: + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "mesh link using reserved action %d", + ia->ia_action); + vap->iv_stats.is_rx_mgtdiscard++; + } + break; default: IEEE80211_DISCARD(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, @@ -1020,8 +1049,20 @@ mesh_verify_meshconf(struct ieee80211vap return 0; } +#define ADDSHORT(frm, v) do { \ + frm[0] = (v) & 0xff; \ + frm[1] = (v) >> 8; \ + frm += 2; \ +} while (0) +#define ADDWORD(frm, v) do { \ + frm[0] = (v) & 0xff; \ + frm[1] = ((v) >> 8) & 0xff; \ + frm[2] = ((v) >> 16) & 0xff; \ + frm[3] = ((v) >> 24) & 0xff; \ + frm += 4; \ +} while (0) /* - * Add a MESH ID element to a frame. + * Add a Mesh ID IE to a frame. */ uint8_t * ieee80211_add_meshid(uint8_t *frm, struct ieee80211vap *vap) @@ -1037,7 +1078,7 @@ ieee80211_add_meshid(uint8_t *frm, struc } /* - * Add a Mesh Configuration element to a frame. + * Add a Mesh Configuration IE to a frame. * For now just use HWMP routing, Airtime link metric, Null Congestion * Signaling, Null Sync Protocol and Null Authentication. */ @@ -1063,15 +1104,14 @@ ieee80211_add_meshconf(uint8_t *frm, str return frm + sizeof(ie); } +/* + * Add a Mesh Peer Management IE to a frame. + */ uint8_t * ieee80211_add_meshpeer(uint8_t *frm, uint8_t subtype, uint16_t localid, uint16_t peerid, uint16_t reason) { -#define ADDSHORT(frm, v) do { \ - frm[0] = (v) & 0xff; \ - frm[1] = (v) >> 8; \ - frm += 2; \ -} while (0) + *frm++ = IEEE80211_ELEMID_MESHPEER; switch (subtype) { case IEEE80211_MESH_PEER_LINK_OPEN: @@ -1097,10 +1137,70 @@ ieee80211_add_meshpeer(uint8_t *frm, uin ADDSHORT(frm, reason); break; } + return frm; -#undef ADDSHORT } +/* + * Add a Mesh Path Reply IE to a frame. + */ +uint8_t * +ieee80211_add_meshprep(uint8_t *frm, struct ieee80211_meshprep_ie *prep) +{ + + *frm++ = IEEE80211_ELEMID_MESHPREP; + *frm++ = sizeof(struct ieee80211_meshprep_ie) - 2; + *frm++ = prep->prep_flags; + *frm++ = prep->prep_hopcount; + *frm++ = prep->prep_ttl; + IEEE80211_ADDR_COPY(frm, prep->prep_targetaddr); + frm += 6; + ADDWORD(frm, prep->prep_targetseq); + ADDWORD(frm, prep->prep_lifetime); + ADDWORD(frm, prep->prep_metric); + IEEE80211_ADDR_COPY(frm, prep->prep_origaddr); + frm += 6; + ADDWORD(frm, prep->prep_origseq); + + return frm; +} + +/* + * Compute an Airtime Link Metric for the link with this node. + * XXX needs work + */ +static uint32_t +mesh_compute_airtime(struct ieee80211vap *vap, struct ieee80211_node *ni) +{ + uint32_t res, overhead, rate, errrate; + const static int nbits = 8192; + + /* Channel access overhead */ + overhead = 123; /* XXX */ + /* In Mbps */ + rate = 10; + /* In percentage */ + errrate = 10; + res = (overhead + (nbits / rate)) * (100 / (100 - errrate)); + + return res; +} + +/* + * Add a Mesh Link Metric report IE to a frame. + */ +uint8_t * +ieee80211_add_meshlink(uint8_t *frm, uint32_t metric) +{ + + *frm++ = IEEE80211_ELEMID_MESHLINK; + *frm++ = 4; + ADDWORD(frm, metric); + + return frm; +} +#undef ADDSHORT +#undef ADDWORD void ieee80211_create_mbss(struct ieee80211vap *vap, struct ieee80211_channel *chan) Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.h Fri May 15 04:53:55 2009 (r192136) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.h Fri May 15 09:47:10 2009 (r192137) @@ -290,6 +290,7 @@ enum { IEEE80211_ACTION_MESHPEERING_OPEN = 0, IEEE80211_ACTION_MESHPEERING_CONFIRM = 1, IEEE80211_ACTION_MESHPEERING_CLOSE = 2, + /* 3-255 reserved */ }; /* @@ -299,6 +300,16 @@ enum { IEEE80211_ACTION_MESHPATH_REQ = 0, IEEE80211_ACTION_MESHPATH_REP = 1, IEEE80211_ACTION_MESHPATH_ERR = 2, + /* 3-255 reserved */ +}; + +/* + * Mesh Link Metric Action codes. + */ +enum { + IEEE80211_ACTION_MESHLINK_REQ = 0, /* Link Metric Request */ + IEEE80211_ACTION_MESHLINK_REP = 1, /* Link Metric Report */ + /* 2-255 reserved */ }; struct ieee80211_meshcntl { @@ -315,6 +326,9 @@ uint8_t * ieee80211_add_meshid(uint8_t * uint8_t * ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *); uint8_t * ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t, uint16_t); +uint8_t * ieee80211_add_meshprep(uint8_t *, + struct ieee80211_meshprep_ie *); +uint8_t * ieee80211_add_meshlink(uint8_t *, uint32_t); void ieee80211_create_mbss(struct ieee80211vap *, struct ieee80211_channel *); uint32_t ieee80211_mesh_getseq(void); Modified: projects/mesh11s/sys/net80211/ieee80211_output.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_output.c Fri May 15 04:53:55 2009 (r192136) +++ projects/mesh11s/sys/net80211/ieee80211_output.c Fri May 15 09:47:10 2009 (r192137) @@ -546,13 +546,6 @@ ieee80211_send_action(struct ieee80211_n frm[1] = (v) >> 8; \ frm += 2; \ } while (0) -#define ADDWORD(frm, v) do { \ - frm[0] = (v) & 0xff; \ - frm[1] = ((v) >> 8) & 0xff; \ - frm[2] = ((v) >> 16) & 0xff; \ - frm[3] = ((v) >> 24) & 0xff; \ - frm += 4; \ -} while (0) #define MS(_v, _f) (((_v) & _f) >> _f##_S) #define SM(_v, _f) (((_v) << _f##_S) & _f) struct ieee80211vap *vap = ni->ni_vap; @@ -794,19 +787,7 @@ ieee80211_send_action(struct ieee80211_n "seq 0x%x, lifetime 0x%x", prep->prep_flags, prep->prep_hopcount, prep->prep_ttl, prep->prep_targetseq, prep->prep_lifetime); - *frm++ = IEEE80211_ELEMID_MESHPREP; - *frm++ = sizeof(struct ieee80211_meshprep_ie) - 2; - *frm++ = prep->prep_flags; - *frm++ = prep->prep_hopcount; - *frm++ = prep->prep_ttl; - IEEE80211_ADDR_COPY(frm, prep->prep_targetaddr); - frm += 6; - ADDWORD(frm, prep->prep_targetseq); - ADDWORD(frm, prep->prep_lifetime); - ADDWORD(frm, prep->prep_metric); - IEEE80211_ADDR_COPY(frm, prep->prep_origaddr); - frm += 6; - ADDWORD(frm, prep->prep_origseq); + frm = ieee80211_add_meshprep(frm, prep); break; } }