From owner-svn-src-projects@FreeBSD.ORG Mon Jun 29 16:34:59 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 C093E1065670; Mon, 29 Jun 2009 16:34:59 +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 950C68FC0C; Mon, 29 Jun 2009 16:34:59 +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 n5TGYxNY049631; Mon, 29 Jun 2009 16:34:59 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5TGYxvB049629; Mon, 29 Jun 2009 16:34:59 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200906291634.n5TGYxvB049629@svn.freebsd.org> From: Rui Paulo Date: Mon, 29 Jun 2009 16:34:59 +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: r195161 - 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: Mon, 29 Jun 2009 16:35:00 -0000 Author: rpaulo Date: Mon Jun 29 16:34:59 2009 New Revision: 195161 URL: http://svn.freebsd.org/changeset/base/195161 Log: Finish the airtime link calculation algorithm now that I know how do it. Sponsored by: The FreeBSD Foundation Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.c Mon Jun 29 16:15:26 2009 (r195160) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Mon Jun 29 16:34:59 2009 (r195161) @@ -1567,25 +1567,42 @@ ieee80211_add_meshpeer(uint8_t *frm, uin * * Based on D3.0. */ +/* + * Max 802.11s overhead. + */ +#define IEEE80211_MESH_MAXOVERHEAD \ + (sizeof(struct ieee80211_qosframe_addr4) \ + + sizeof(struct ieee80211_meshcntl_ae11) \ + + sizeof(struct llc) \ + + IEEE80211_ADDR_LEN \ + + IEEE80211_WEP_IVLEN \ + + IEEE80211_WEP_KIDLEN \ + + IEEE80211_WEP_CRCLEN \ + + IEEE80211_WEP_MICLEN \ + + IEEE80211_CRC_LEN) uint32_t ieee80211_airtime_calc(struct ieee80211_node *ni) { #define M_BITS 8 #define S_FACTOR (2 * M_BITS) - uint64_t res; - uint32_t overhead, rate, errrate; + struct ieee80211com *ic = ni->ni_ic; + struct ifnet *ifp = ni->ni_vap->iv_ifp; const static int nbits = 8192 << M_BITS; + uint32_t overhead, rate, errrate; + uint64_t res; - /* Channel access overhead */ - overhead = 123 << M_BITS; /* XXX */ - /* In Mbps */ + /* Time to transmit a frame */ rate = ni->ni_txrate; - /* In percentage */ - errrate = (10 << M_BITS) / 100; + overhead = ieee80211_compute_duration(ic->ic_rt, + ifp->if_mtu + IEEE80211_MESH_MAXOVERHEAD, rate, 0) << M_BITS; + /* Error rate in percentage */ + /* XXX assuming small failures are ok */ + errrate = (((ifp->if_oerrors + + ifp->if_ierrors) / 100) << M_BITS) / 100; res = (overhead + (nbits / rate)) * ((1 << S_FACTOR) / ((1 << M_BITS) - errrate)); - return (uint32_t) (res >> S_FACTOR); + return (uint32_t)(res >> S_FACTOR); #undef M_BITS #undef S_FACTOR }