From owner-freebsd-wireless@FreeBSD.ORG Mon Sep 26 08:16:50 2011 Return-Path: Delivered-To: freebsd-wireless@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DC0A106566B for ; Mon, 26 Sep 2011 08:16:50 +0000 (UTC) (envelope-from himali.patel@sibridgetech.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id B7CE38FC14 for ; Mon, 26 Sep 2011 08:16:49 +0000 (UTC) Received: by yxk36 with SMTP id 36so5220214yxk.13 for ; Mon, 26 Sep 2011 01:16:49 -0700 (PDT) Received: by 10.68.55.100 with SMTP id r4mr28128732pbp.69.1317023549474; Mon, 26 Sep 2011 00:52:29 -0700 (PDT) Received: from himali.sibshivalik.com ([110.172.28.16]) by mx.google.com with ESMTPS id i2sm70778863pbt.3.2011.09.26.00.52.27 (version=SSLv3 cipher=OTHER); Mon, 26 Sep 2011 00:52:28 -0700 (PDT) Message-ID: <4E802FB5.7040604@sibridgetech.com> Date: Mon, 26 Sep 2011 13:24:29 +0530 From: Himali User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10 MIME-Version: 1.0 To: freebsd-wireless@freebsd.org Content-Type: multipart/mixed; boundary="------------090707080604010703040308" Subject: Quiet-IE implementation X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: himali.patel@sibridgetech.com List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Sep 2011 08:16:50 -0000 This is a multi-part message in MIME format. --------------090707080604010703040308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, We have implemented Quiet IE logic as per the 802.11h standard. Please find the attached 3 patches related to Quiet-IE implementation. Quiet IE :- As per 802.11h standard, Quiet IE is used to quiet other stations to reduce the interference for radar detection. We have implemented this for BSS only. In that AP will Send Quiet IE in its beacon and probe response packets. All the stations connected to this AP will quiet (i.e. stop transmission) for quiet duration when quiet count reaches zero. Configuration Parameters for Quiet-IE:- a) quiet - To enable/disable the Quiet Logic. b) quiet_period - To set quiet period parameter of Quiet-IE. c) quiet_count - To set quiet count parameter of Quiet-IE. d) quiet_offset - To set quiet offset parameter of Quiet-IE. e) quiet_duration - To set quiet duration parameter of Quiet-IE. Test Procedure:- a) On AP, configure the quiet parameters as - ifconfig wlan0 quiet ifconfig wlan0 quiet_period 1 ifconfig wlan0 quiet_count 100 ifconfig wlan0 quiet_offset 0 ifconfig wlan0 quiet_duration 50 (this should be less then configured beacon interval) b) Start ping utility on AP with ip-address of associated station and waiting time of 1ms ( -W 1), and check the results, Lots of packets will be received out of time (i.e. >1ms) c) we can verified this with other combinations also. Let us know in case of any queries regarding this. Regards, Himali --------------090707080604010703040308 Content-Type: text/x-patch; name="ath_quiet.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ath_quiet.patch" diff -Naur ath_org/ath_hal/ar5416/ar5416_misc.c ath/ath_hal/ar5416/ar5416_misc.c --- ath_org/ath_hal/ar5416/ar5416_misc.c 2011-09-16 14:10:44.798097426 +0530 +++ ath/ath_hal/ar5416/ar5416_misc.c 2011-09-19 11:27:09.048364069 +0530 @@ -298,6 +298,11 @@ } else { OS_REG_CLR_BIT(ah, AR_TIMER_MODE, AR_TIMER_MODE_QUIET); } + + /* Allow the quiet mechanism to do its work */ + OS_DELAY(200); + OS_REG_CLR_BIT(ah, AR_TIMER_MODE, AR_TIMER_MODE_QUIET); + return HAL_OK; } #undef TU_TO_USEC diff -Naur ath_org/if_ath.c ath/if_ath.c --- ath_org/if_ath.c 2011-09-16 14:10:44.793097635 +0530 +++ ath/if_ath.c 2011-09-19 11:19:07.875807211 +0530 @@ -187,6 +187,7 @@ static void ath_calibrate(void *); static int ath_newstate(struct ieee80211vap *, enum ieee80211_state, int); static void ath_setup_stationkey(struct ieee80211_node *); +static int ath_set_quiet(struct ieee80211_node *,u_int8_t *); static void ath_newassoc(struct ieee80211_node *, int); static int ath_setregdomain(struct ieee80211com *, struct ieee80211_regdomain *, int, @@ -719,6 +720,7 @@ ic->ic_vap_create = ath_vap_create; ic->ic_vap_delete = ath_vap_delete; ic->ic_raw_xmit = ath_raw_xmit; + ic->ic_set_quiet = ath_set_quiet; ic->ic_update_mcast = ath_update_mcast; ic->ic_update_promisc = ath_update_promisc; ic->ic_node_alloc = ath_node_alloc; @@ -865,6 +867,28 @@ return free; } + + static int +ath_set_quiet(struct ieee80211_node *ni, u_int8_t *quiet_elm) +{ + + struct ieee80211com *ic = ni->ni_ic; + struct ath_softc *sc = ic->ic_ifp->if_softc; + struct ath_hal *ah = sc->sc_ah; + + struct ieee80211_quiet_ie *quiet = (struct ieee80211_quiet_ie *)quiet_elm; + u_int16_t duration= le16toh(quiet->duration); + u_int16_t offset= le16toh(quiet->offset); + + return ath_hal_setQuiet(ah, + quiet->period, + duration, + offset + quiet->tbttcount*ni->ni_intval, + 1); +} + + + static struct ieee80211vap * ath_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, int opmode, int flags, diff -Naur ath_org/if_athvar.h ath/if_athvar.h --- ath_org/if_athvar.h 2011-09-16 14:10:44.794097594 +0530 +++ ath/if_athvar.h 2011-09-19 11:23:21.992010259 +0530 @@ -700,6 +700,11 @@ #define ath_hal_set11nburstduration(_ah, _ds, _dur) \ ((*(_ah)->ah_set11nBurstDuration)((_ah), (_ds), (_dur))) +#define ath_hal_setQuiet(_ah, _period, _duration, _nextStart,_enabled) \ + ((*(_ah)->ah_setQuiet)((_ah), (_period),(_duration), (_nextStart), (_enabled))) + + + /* * This is badly-named; you need to set the correct parameters * to begin to receive useful radar events; and even then --------------090707080604010703040308 Content-Type: text/x-patch; name="net80211_quiet.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="net80211_quiet.patch" diff -Naur net80211_org/ieee80211_dfs.c net80211/ieee80211_dfs.c --- net80211_org/ieee80211_dfs.c 2011-09-16 14:09:15.858786630 +0530 +++ net80211/ieee80211_dfs.c 2011-09-19 12:03:03.384069387 +0530 @@ -64,6 +64,12 @@ &ieee80211_cac_timeout, 0, "CAC timeout (secs)"); #define CAC_TIMEOUT msecs_to_ticks(ieee80211_cac_timeout*1000) +static int +null_set_quiet(struct ieee80211_node *ni, u_int8_t *quiet_elm) +{ + return ENOSYS; +} + void ieee80211_dfs_attach(struct ieee80211com *ic) { @@ -71,6 +77,8 @@ callout_init_mtx(&dfs->nol_timer, IEEE80211_LOCK_OBJ(ic), 0); callout_init_mtx(&dfs->cac_timer, IEEE80211_LOCK_OBJ(ic), 0); + + ic->ic_set_quiet = null_set_quiet; } void diff -Naur net80211_org/ieee80211.h net80211/ieee80211.h --- net80211_org/ieee80211.h 2011-09-16 14:09:15.857786672 +0530 +++ net80211/ieee80211.h 2011-09-19 11:44:01.536410831 +0530 @@ -759,6 +759,19 @@ /* * 802.11h Channel Switch Announcement (CSA). */ +struct ieee80211_quiet_ie { + uint8_t quiet_ie; /* IEEE80211_ELEMID_QUIET */ + uint8_t len; + uint8_t tbttcount; /* quiet start */ + uint8_t period; /* beacon intervals between quiets*/ + uint16_t duration; /* TUs of each quiet*/ + uint16_t offset; /* TUs of from TBTT of quiet start*/ + +} __packed; + +/* + * 802.11h Channel Switch Announcement (CSA). + */ struct ieee80211_csa_ie { uint8_t csa_ie; /* IEEE80211_ELEMID_CHANSWITCHANN */ uint8_t csa_len; diff -Naur net80211_org/ieee80211_input.c net80211/ieee80211_input.c --- net80211_org/ieee80211_input.c 2011-09-16 14:09:15.857786672 +0530 +++ net80211/ieee80211_input.c 2011-09-19 11:31:05.813307564 +0530 @@ -522,6 +522,9 @@ case IEEE80211_ELEMID_CSA: scan->csa = frm; break; + case IEEE80211_ELEMID_QUIET: + scan->quiet = frm; + break; case IEEE80211_ELEMID_FHPARMS: if (ic->ic_phytype == IEEE80211_T_FH) { scan->fhdwell = LE_READ_2(&frm[2]); diff -Naur net80211_org/ieee80211_ioctl.c net80211/ieee80211_ioctl.c --- net80211_org/ieee80211_ioctl.c 2011-09-16 14:09:15.857786672 +0530 +++ net80211/ieee80211_ioctl.c 2011-09-19 11:31:57.578109155 +0530 @@ -972,6 +972,21 @@ case IEEE80211_IOC_PUREG: ireq->i_val = (vap->iv_flags & IEEE80211_F_PUREG) != 0; break; + case IEEE80211_IOC_QUIET: + ireq->i_val = vap->iv_quiet; + break; + case IEEE80211_IOC_QUIET_COUNT: + ireq->i_val = vap->iv_quiet_count; + break; + case IEEE80211_IOC_QUIET_PERIOD: + ireq->i_val = vap->iv_quiet_period; + break; + case IEEE80211_IOC_QUIET_DUR: + ireq->i_val = vap->iv_quiet_duration; + break; + case IEEE80211_IOC_QUIET_OFFSET: + ireq->i_val = vap->iv_quiet_offset; + break; case IEEE80211_IOC_BGSCAN: ireq->i_val = (vap->iv_flags & IEEE80211_F_BGSCAN) != 0; break; @@ -2939,6 +2954,24 @@ if (isvap11g(vap)) error = ENETRESET; break; + case IEEE80211_IOC_QUIET: + vap->iv_quiet= ireq->i_val; + break; + case IEEE80211_IOC_QUIET_COUNT: + vap->iv_quiet_count=ireq->i_val; + break; + case IEEE80211_IOC_QUIET_PERIOD: + vap->iv_quiet_period=ireq->i_val; + break; + case IEEE80211_IOC_QUIET_OFFSET: + vap->iv_quiet_offset=ireq->i_val; + break; + case IEEE80211_IOC_QUIET_DUR: + if(ireq->i_val < vap->iv_bss->ni_intval) + vap->iv_quiet_duration=ireq->i_val; + else + error = EINVAL; + break; case IEEE80211_IOC_BGSCAN: if (ireq->i_val) { if ((vap->iv_caps & IEEE80211_C_BGSCAN) == 0) diff -Naur net80211_org/ieee80211_ioctl.h net80211/ieee80211_ioctl.h --- net80211_org/ieee80211_ioctl.h 2011-09-16 14:09:15.860786547 +0530 +++ net80211/ieee80211_ioctl.h 2011-09-19 11:33:28.046267274 +0530 @@ -715,6 +715,11 @@ #define IEEE80211_IOC_TDMA_SLOTLEN 203 /* TDMA: slot length (usecs) */ #define IEEE80211_IOC_TDMA_BINTERVAL 204 /* TDMA: beacon intvl (slots) */ +#define IEEE80211_IOC_QUIET 205 /* Quiet Enable/Disable*/ +#define IEEE80211_IOC_QUIET_PERIOD 206 /* Quiet Period*/ +#define IEEE80211_IOC_QUIET_OFFSET 207 /* Quiet Offset*/ +#define IEEE80211_IOC_QUIET_DUR 208 /* Quiet Duration*/ +#define IEEE80211_IOC_QUIET_COUNT 209 /* Quiet Count*/ /* * Parameters for controlling a scan requested with * IEEE80211_IOC_SCAN_REQ. diff -Naur net80211_org/ieee80211_output.c net80211/ieee80211_output.c --- net80211_org/ieee80211_output.c 2011-09-16 14:09:15.860786547 +0530 +++ net80211/ieee80211_output.c 2011-09-19 11:36:53.325550818 +0530 @@ -1661,6 +1661,32 @@ } /* + * Add an 11h Quiet time element to a frame. + */ + static uint8_t * +ieee80211_add_quiet(uint8_t *frm, struct ieee80211vap *vap) +{ + struct ieee80211_quiet_ie *quiet = (struct ieee80211_quiet_ie *) frm; + + quiet->quiet_ie = IEEE80211_ELEMID_QUIET; + quiet->len = 6; + if(vap->iv_quiet_count_value==1){ + vap->iv_quiet_count_value = vap->iv_quiet_count; + }else if(vap->iv_quiet_count_value>1){ + vap->iv_quiet_count_value--; + } + if(vap->iv_quiet_count_value==0){ + // value 0 is reserved as per 802.11h standerd + vap->iv_quiet_count_value=1; + } + quiet->tbttcount=vap->iv_quiet_count_value; + quiet->period = vap->iv_quiet_period; + quiet->duration = htole16(vap->iv_quiet_duration); + quiet->offset = htole16(vap->iv_quiet_offset); + return frm + sizeof(*quiet); +} + +/* * Add an 11h Channel Switch Announcement element to a frame. * Note that we use the per-vap CSA count to adjust the global * counter so we can use this routine to form probe response @@ -2253,6 +2279,7 @@ + IEEE80211_COUNTRY_MAX_SIZE + 3 + sizeof(struct ieee80211_csa_ie) + + sizeof(struct ieee80211_quiet_ie) + 3 + 2 + (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) + sizeof(struct ieee80211_ie_wpa) @@ -2319,6 +2346,14 @@ if (ic->ic_flags & IEEE80211_F_CSAPENDING) frm = ieee80211_add_csa(frm, vap); } + if (vap->iv_flags & IEEE80211_F_DOTH) { + if(IEEE80211_IS_CHAN_DFS(ic->ic_bsschan) && + (vap->iv_flags_ext & IEEE80211_FEXT_DFS)){ + if(vap->iv_quiet){ + frm=ieee80211_add_quiet(frm,vap); + } + } + } if (IEEE80211_IS_CHAN_ANYG(bss->ni_chan)) frm = ieee80211_add_erp(frm, ic); frm = ieee80211_add_xrates(frm, rs); @@ -2617,9 +2652,21 @@ frm = ieee80211_add_powerconstraint(frm, vap); bo->bo_csa = frm; if (ic->ic_flags & IEEE80211_F_CSAPENDING) - frm = ieee80211_add_csa(frm, vap); + frm = ieee80211_add_csa(frm, vap); } else bo->bo_csa = frm; + + if (vap->iv_flags & IEEE80211_F_DOTH) { + bo->bo_quiet = frm; + if(IEEE80211_IS_CHAN_DFS(ic->ic_bsschan) && + (vap->iv_flags_ext & IEEE80211_FEXT_DFS)){ + if(vap->iv_quiet) + frm=ieee80211_add_quiet(frm,vap); + } + }else{ + bo->bo_quiet= frm; + } + if (IEEE80211_IS_CHAN_ANYG(ni->ni_chan)) { bo->bo_erp = frm; frm = ieee80211_add_erp(frm, ic); @@ -2733,7 +2780,8 @@ + 2 + 4 + vap->iv_tim_len /* DTIM/IBSSPARMS */ + IEEE80211_COUNTRY_MAX_SIZE /* country */ + 2 + 1 /* power control */ - + sizeof(struct ieee80211_csa_ie) /* CSA */ + + sizeof(struct ieee80211_csa_ie) /* CSA */ + + sizeof(struct ieee80211_quiet_ie) /* Quiet */ + 2 + 1 /* ERP */ + 2 + (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) + (vap->iv_caps & IEEE80211_C_WPA ? /* WPA 1+2 */ @@ -2953,6 +3001,7 @@ bo->bo_appie += adjust; bo->bo_wme += adjust; bo->bo_csa += adjust; + bo->bo_quiet += adjust; bo->bo_tim_len = timlen; /* update information element */ @@ -3006,6 +3055,7 @@ #endif bo->bo_appie += sizeof(*csa); bo->bo_csa_trailer_len += sizeof(*csa); + bo->bo_quiet += sizeof(*csa); bo->bo_tim_trailer_len += sizeof(*csa); m->m_len += sizeof(*csa); m->m_pkthdr.len += sizeof(*csa); @@ -3016,6 +3066,11 @@ vap->iv_csa_count++; /* NB: don't clear IEEE80211_BEACON_CSA */ } + if(IEEE80211_IS_CHAN_DFS(ic->ic_bsschan) && + (vap->iv_flags_ext & IEEE80211_FEXT_DFS) ){ + if(vap->iv_quiet) + ieee80211_add_quiet(bo->bo_quiet,vap); + } if (isset(bo->bo_flags, IEEE80211_BEACON_ERP)) { /* * ERP element needs updating. diff -Naur net80211_org/ieee80211_proto.h net80211/ieee80211_proto.h --- net80211_org/ieee80211_proto.h 2011-09-16 14:09:15.856786714 +0530 +++ net80211/ieee80211_proto.h 2011-09-19 11:39:51.455999028 +0530 @@ -344,6 +344,7 @@ uint16_t bo_appie_len; /* AppIE length in bytes */ uint16_t bo_csa_trailer_len; uint8_t *bo_csa; /* start of CSA element */ + uint8_t *bo_quiet; /* start of Quiet element */ uint8_t *bo_meshconf; /* start of MESHCONF element */ uint8_t *bo_spare[3]; }; diff -Naur net80211_org/ieee80211_scan.h net80211/ieee80211_scan.h --- net80211_org/ieee80211_scan.h 2011-09-16 14:09:15.858786630 +0530 +++ net80211/ieee80211_scan.h 2011-09-19 11:40:14.946004468 +0530 @@ -213,6 +213,7 @@ uint8_t *ath; uint8_t *tdma; uint8_t *csa; + uint8_t *quiet; uint8_t *meshid; uint8_t *meshconf; uint8_t *spare[3]; diff -Naur net80211_org/ieee80211_sta.c net80211/ieee80211_sta.c --- net80211_org/ieee80211_sta.c 2011-09-16 14:09:15.857786672 +0530 +++ net80211/ieee80211_sta.c 2011-09-19 11:40:36.533090480 +0530 @@ -1345,6 +1345,9 @@ scan.htcap, scan.htinfo); /* XXX state changes? */ } + if (scan.quiet){ + ic->ic_set_quiet(ni, scan.quiet); + } if (scan.tim != NULL) { struct ieee80211_tim_ie *tim = (struct ieee80211_tim_ie *) scan.tim; diff -Naur net80211_org/ieee80211_var.h net80211/ieee80211_var.h --- net80211_org/ieee80211_var.h 2011-09-16 14:09:15.856786714 +0530 +++ net80211/ieee80211_var.h 2011-09-19 11:41:25.605012802 +0530 @@ -242,6 +242,9 @@ int (*ic_setregdomain)(struct ieee80211com *, struct ieee80211_regdomain *, int, struct ieee80211_channel []); + + int (*ic_set_quiet)(struct ieee80211_node *, u_int8_t *quiet_elm); + /* send/recv 802.11 management frame */ int (*ic_send_mgmt)(struct ieee80211_node *, int, int); @@ -403,6 +406,12 @@ uint8_t iv_dtim_period; /* DTIM period */ uint8_t iv_dtim_count; /* DTIM count from last bcn */ /* set/unset aid pwrsav state */ + uint8_t iv_quiet; /* Quiet Element */ + uint8_t iv_quiet_count; /* constant count for Quiet Element */ + uint8_t iv_quiet_count_value; /* variable count for Quiet Element */ + uint8_t iv_quiet_period; /* period for Quiet Element */ + uint16_t iv_quiet_duration; /* duration for Quiet Element */ + uint16_t iv_quiet_offset; /* offset for Quiet Element */ int iv_csa_count; /* count for doing CSA */ struct ieee80211_node *iv_bss; /* information for this node */ --------------090707080604010703040308 Content-Type: text/x-patch; name="ifconfig_quiet.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ifconfig_quiet.patch" diff -Naur ifconfig_org/ifieee80211.c ifconfig/ifieee80211.c --- ifconfig_org/ifieee80211.c 2011-07-20 11:29:28.000000000 +0530 +++ ifconfig/ifieee80211.c 2011-09-19 11:50:01.127186561 +0530 @@ -1337,6 +1337,39 @@ } static void +set80211quiet(const char *val, int d, int s, const struct afswtch *rafp) +{ + set80211(s, IEEE80211_IOC_QUIET, d, 0, NULL); +} + +static +DECL_CMD_FUNC(set80211quietperiod, val, d) +{ + set80211(s, IEEE80211_IOC_QUIET_PERIOD, atoi(val), 0, NULL); +} + + +static +DECL_CMD_FUNC(set80211quietcount, val, d) +{ + set80211(s, IEEE80211_IOC_QUIET_COUNT, atoi(val), 0, NULL); +} + + +static +DECL_CMD_FUNC(set80211quietduration, val, d) +{ + set80211(s, IEEE80211_IOC_QUIET_DUR, atoi(val), 0, NULL); +} + +static +DECL_CMD_FUNC(set80211quietoffset, val, d) +{ + set80211(s, IEEE80211_IOC_QUIET_OFFSET, atoi(val), 0, NULL); +} + + +static void set80211bgscan(const char *val, int d, int s, const struct afswtch *rafp) { set80211(s, IEEE80211_IOC_BGSCAN, d, 0, NULL); @@ -5161,6 +5194,12 @@ DEF_CMD_ARG("bgscanidle", set80211bgscanidle), DEF_CMD_ARG("bgscanintvl", set80211bgscanintvl), DEF_CMD_ARG("scanvalid", set80211scanvalid), + DEF_CMD("quiet", 1, set80211quiet), + DEF_CMD("-quiet", 0, set80211quiet), + DEF_CMD_ARG("quiet_count", set80211quietcount), + DEF_CMD_ARG("quiet_period", set80211quietperiod), + DEF_CMD_ARG("quiet_dur", set80211quietduration), + DEF_CMD_ARG("quiet_offset", set80211quietoffset), DEF_CMD_ARG("roam:rssi", set80211roamrssi), DEF_CMD_ARG("roam:rate", set80211roamrate), DEF_CMD_ARG("mcastrate", set80211mcastrate), --------------090707080604010703040308--