[Madwifi-cvs] revision 3411 committed
Status: Beta
Brought to you by:
otaku
From: Matthew W. S. B. <svn...@ma...> - 2008-03-29 23:17:48
|
Project : madwifi Revision : 3411 Author : mentor (Matthew W. S. Bell) Date : 2008-03-30 00:17:39 +0100 (Sun, 30 Mar 2008) Log Message : Fiddling with r3404: * Formatting * Add some extra discards for otherwise unhandled action frames * Move _s() macros to compat.h Affected Files: * madwifi/branches/madwifi-dfs/ath/if_ath.c updated * madwifi/branches/madwifi-dfs/include/compat.h updated * madwifi/branches/madwifi-dfs/net80211/ieee80211.c updated * madwifi/branches/madwifi-dfs/net80211/ieee80211_beacon.c updated * madwifi/branches/madwifi-dfs/net80211/ieee80211_input.c updated * madwifi/branches/madwifi-dfs/net80211/ieee80211_output.c updated * madwifi/branches/madwifi-dfs/net80211/ieee80211_scan.c updated * madwifi/branches/madwifi-dfs/net80211/ieee80211_var.h updated * madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c updated Modified: madwifi/branches/madwifi-dfs/ath/if_ath.c =================================================================== --- madwifi/branches/madwifi-dfs/ath/if_ath.c 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/ath/if_ath.c 2008-03-29 23:17:39 UTC (rev 3411) @@ -1248,13 +1248,7 @@ struct ath_hal *ah = sc->sc_ah; u_int32_t now_tu, nexttbtt; - /* define a roundup() macro that is working both with positive and - * negative values */ - -#define roundup_s(x,y) ((x) >= 0 ? (((x)+(y)-1)/(y))*(y) : ((x)/(y))*(y)) - - /* we need the closest TBTT that is > now_tu */ - + /* Calculate the closest TBTT that is > now_tu. */ now_tu = ath_hal_gettsf64(ah) >> 10; nexttbtt = sc->sc_nexttbtt + roundup_s( (signed)(now_tu + 1 - sc->sc_nexttbtt), Modified: madwifi/branches/madwifi-dfs/include/compat.h =================================================================== --- madwifi/branches/madwifi-dfs/include/compat.h 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/include/compat.h 2008-03-29 23:17:39 UTC (rev 3411) @@ -87,6 +87,11 @@ #define howmany(x, y) (((x)+((y)-1))/(y)) +/* roundup() and howmany() macros that works both with positive and negative + * values. */ +#define roundup_s(x,y) ((x) >= 0 ? (((x)+((y)-1))/(y))*(y) : ((x)/(y))*(y)) +#define howmany_s(x, y) ((x) >= 0 ? (((x)+((y)-1))/(y)) : ((x)/(y))) + /* Bit map related macros. */ #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211.c =================================================================== --- madwifi/branches/madwifi-dfs/net80211/ieee80211.c 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/net80211/ieee80211.c 2008-03-29 23:17:39 UTC (rev 3411) @@ -347,7 +347,7 @@ ieee80211_expire_dfs_excl_timer; ic->ic_dfs_excl_timer.data = (unsigned long) ic; - /* initialize CSA related variables */ + /* Initialize CSA related variables. */ init_timer(&ic->ic_csa_timer); ic->ic_csa_timer.data = (unsigned long)ic; ic->ic_csa_timer.function = ieee80211_doth_switch_channel_tmr; @@ -1107,25 +1107,19 @@ ic->ic_curchan->ic_ieee, ic->ic_curchan->ic_freq); } else { - /* Change to a radar free 11a channel for dfstesttime - * seconds. */ - struct ieee80211vap *vap; - /* Start a channel switch on all available VAP */ + /* Change to a radar free 11a channel for dfstesttime + * seconds. + * Start a channel switch on all available VAPs. */ TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { - struct ieee80211_channel *c = ieee80211_doth_findchan( vap, IEEE80211_RADAR_TEST_MUTE_CHAN); - ieee80211_start_new_csa( - vap, - IEEE80211_CSA_CAN_STOP_TX, - c, - IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT, - 0); + ieee80211_start_new_csa(vap, IEEE80211_CSA_CAN_STOP_TX, + c, IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT, 0); } if_printf(dev, @@ -1151,22 +1145,16 @@ struct net_device *dev = ic->ic_dev; struct ieee80211vap *vap; - /* Return to the original channel we were on before the test mute */ + /* Return to the original channel we were on before the test mute. */ if_printf(dev, "Returning to channel %d\n", ieeeChan); printk(KERN_DEBUG "Returning to chan %d\n", ieeeChan); - /* Start a channel switch on all available VAP */ + /* Start a channel switch on all available VAP. */ TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { - struct ieee80211_channel *c = ieee80211_doth_findchan(vap, ieeeChan); - - ieee80211_start_new_csa( - vap, - IEEE80211_CSA_CAN_STOP_TX, - c, - IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT, - 0); + ieee80211_start_new_csa(vap, IEEE80211_CSA_CAN_STOP_TX, + c, IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT, 0); } } EXPORT_SYMBOL(ieee80211_dfs_test_return); Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_beacon.c =================================================================== --- madwifi/branches/madwifi-dfs/net80211/ieee80211_beacon.c 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/net80211/ieee80211_beacon.c 2008-03-29 23:17:39 UTC (rev 3411) @@ -285,6 +285,7 @@ struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; int len_changed = 0; + u_int8_t *frm; u_int16_t capinfo; IEEE80211_LOCK_IRQ(ic); @@ -294,14 +295,11 @@ if ((ic->ic_flags & IEEE80211_F_DOTH) && !(ic->ic_flags & IEEE80211_F_CHANSWITCH) && (vap->iv_flags & IEEE80211_F_CHANSWITCH)) { - - u_int8_t * frm; - - vap->iv_flags &= ~IEEE80211_F_CHANSWITCH; - IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, "%s: reinit beacon\n", __func__); + vap->iv_flags &= ~IEEE80211_F_CHANSWITCH; + skb_pull(skb, sizeof(struct ieee80211_frame)); skb_trim(skb, 0); frm = skb->data; @@ -459,8 +457,7 @@ * - ic_csa_chan = pointer to struct ieee80211_channel * - ic_csa_expires_tu = switch time in TU * - mod_timer(&ic_csa_timer, expires) = switch time in jiffies - * - ic_flags |= IEEE80211_F_CHANSWITCH - */ + * - ic_flags |= IEEE80211_F_CHANSWITCH */ if (IEEE80211_IS_MODE_BEACON(vap->iv_opmode)) { @@ -470,20 +467,20 @@ (struct ieee80211_ie_csa *)bo->bo_chanswitch; u_int32_t now_tu, nexttbtt; - if ((vap->iv_flags & IEEE80211_F_CHANSWITCH)==0) { + if (!(vap->iv_flags & IEEE80211_F_CHANSWITCH)) { vap->iv_flags |= IEEE80211_F_CHANSWITCH; - /* copy out trailer to open up a slot */ + /* Copy out trailer to open up a slot. */ memmove(bo->bo_chanswitch + sizeof(*csa_ie), bo->bo_chanswitch, bo->bo_chanswitch_trailerlen); - /* add ie in opened slot */ + /* Add ie in opened slot. */ csa_ie->csa_id = IEEE80211_ELEMID_CHANSWITCHANN; - /* fixed length */ + /* Fixed length. */ csa_ie->csa_len = sizeof(*csa_ie) - 2; - /* update the trailer lens */ + /* Update the trailer len's. */ bo->bo_chanswitch_trailerlen += sizeof(*csa_ie); bo->bo_tim_trailerlen += sizeof(*csa_ie); bo->bo_wme += sizeof(*csa_ie); @@ -491,8 +488,8 @@ bo->bo_ath_caps += sizeof(*csa_ie); bo->bo_xr += sizeof(*csa_ie); - /* indicate new beacon length so other layers - * may manage memory */ + /* Indicate new beacon length so other layers + * may manage memory. */ skb_put(skb, sizeof(*csa_ie)); len_changed = 1; } @@ -518,8 +515,7 @@ } /* Since beaconing is a shared process in IBSS mode, - * we send Action frames as well */ - + * we send Action frames as well. */ if (vap->iv_opmode == IEEE80211_M_IBSS) { ieee80211_send_csa_frame(vap, csa_ie->csa_mode, Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_input.c =================================================================== --- madwifi/branches/madwifi-dfs/net80211/ieee80211_input.c 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/net80211/ieee80211_input.c 2008-03-29 23:17:39 UTC (rev 3411) @@ -2750,13 +2750,11 @@ u_int32_t now_tu; TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { - now_tu = vap->iv_get_tsf(vap) >> 10; IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, "%s: Channel switch to %3d (%4d MHz) NOW! " - "(now_tu:%lu)\n", - __func__, + "(now_tu:%lu)\n", __func__, ic->ic_csa_chan->ic_ieee, ic->ic_csa_chan->ic_freq, now_tu); } @@ -2774,8 +2772,7 @@ } /* This function is called when we received an action frame or a beacon frame - * containing a CSA IE */ - + * containing a CSA IE. */ static int ieee80211_parse_csaie(struct ieee80211_node *ni, u_int8_t *frm, const struct ieee80211_frame *wh) @@ -4065,8 +4062,8 @@ break; } - case IEEE80211_FC0_SUBTYPE_ACTION: - + case IEEE80211_FC0_SUBTYPE_ACTION: { + unsigned char cat, act; /* we only parse Action frame from our BSSID */ if (!IEEE80211_ADDR_EQ(wh->i_addr3, vap->iv_bssid)) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, @@ -4077,20 +4074,30 @@ } /* parse the Category field */ - switch (*frm ++) { + switch (cat = *frm++) { case IEEE80211_ACTION_SPECTRUM_MANAGEMENT: - switch (*frm ++) { + switch (act = *frm++) { case IEEE80211_ACTION_S_CHANSWITCHANN: ieee80211_parse_csaie(ni, frm, wh); break; + default: + IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, wh, + "mgt", "action frame category 0x%x, " + "action 0x%x not handled", cat, act); + break; } break; + default: + IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, wh, "mgt", + "action frame category 0x%x not handled", cat); + break; } break; + } default: - IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, - wh, "mgt", "subtype 0x%x not handled", subtype); + IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, wh, "mgt", + "subtype 0x%x not handled", subtype); vap->iv_stats.is_rx_badsubtype++; break; } Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_output.c =================================================================== --- madwifi/branches/madwifi-dfs/net80211/ieee80211_output.c 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/net80211/ieee80211_output.c 2008-03-29 23:17:39 UTC (rev 3411) @@ -1758,9 +1758,7 @@ * in ic_flags * * is_beacon_frame : true if the csa_count comes from a beacon frame we just - * received. - */ - + * received. */ void ieee80211_start_new_csa(struct ieee80211vap *vap, u_int8_t csa_mode, @@ -1777,31 +1775,28 @@ * the switch will occur at any time after the frame containing the * element is transmitted. */ - now_tu = vap->iv_get_tsf(vap) >> 10; - now = jiffies; + now_tu = vap->iv_get_tsf(vap) >> 10; + now = jiffies; if (csa_count == 0) { - expires_tu = now_tu; - expires = now; + expires_tu = now_tu; + expires = now; IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, "%s: now:%d count:%d => expires:%d\n", __func__, now, csa_count, expires); } else { - /* csa_count includes the current frame if it is a beacon - * frame */ + * frame. */ if (is_beacon_frame) csa_count --; - /* compute the closest nexttbtt, next time a beacon for this - * VAP will be sent */ - + /* Compute the closest nexttbtt, next time a beacon for this + * VAP will be sent. */ nexttbtt = vap->iv_get_nexttbtt(vap); - /* compute ic_csa_expires_tu = nexttbtt + csa_count * - * ni_intval */ - + /* Compute ic_csa_expires_tu = nexttbtt + csa_count * + * ni_intval. */ expires_tu = nexttbtt + csa_count * vap->iv_bss->ni_intval; IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, @@ -1810,8 +1805,7 @@ __func__, now_tu, nexttbtt, expires_tu); - /* convert to jiffies, including a margin */ - + /* Convert to jiffies, including a margin. */ expires = now + IEEE80211_TU_TO_JIFFIES(expires_tu - now_tu - 10) - 1; @@ -1820,13 +1814,12 @@ __func__, now, csa_count, expires); } - /* if we have a CS in progress, we ignore this new CSA IE if the - * channel switch time is later than the current one */ + /* If we have a CS in progress, we ignore this new CSA IE if the + * channel switch time is later than the current one. */ if ((ic->ic_flags & IEEE80211_F_CHANSWITCH) && (expires_tu > ic->ic_csa_expires_tu)) { - - /* we do not ignore csa_mode if it says we must stop sending - * right now */ + /* We do not ignore csa_mode if it says we must stop sending + * right now. */ if (ic->ic_csa_mode == IEEE80211_CSA_CAN_STOP_TX && csa_mode == IEEE80211_CSA_MUST_STOP_TX) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, @@ -1848,8 +1841,7 @@ ic->ic_flags |= IEEE80211_F_CHANSWITCH; } -/* - * Send a broadcast CSA frame, announcing the new channel. References are from +/* Send a broadcast CSA frame, announcing the new channel. References are from * IEEE 802.11h-2003. CSA frame format is an "Action" frame (Type: 00, Subtype: * 1101, see 7.1.3.1.2) * @@ -1863,9 +1855,7 @@ * * csa_mode : IEEE80211_CSA_MANDATORY / IEEE80211_CSA_ADVISORY * csa_chan : new IEEE channel number - * csa_tbtt : TBTT until Channel Switch happens - */ - + * csa_tbtt : TBTT until Channel Switch happens */ void ieee80211_send_csa_frame(struct ieee80211vap *vap, u_int8_t csa_mode, @@ -1890,13 +1880,13 @@ return ; } - *frm ++ = IEEE80211_ACTION_SPECTRUM_MANAGEMENT; /* Category */ - *frm ++ = IEEE80211_ACTION_S_CHANSWITCHANN; /* Spectrum Management */ - *frm ++ = IEEE80211_ELEMID_CHANSWITCHANN; - *frm ++ = 3; - *frm ++ = csa_mode; - *frm ++ = csa_chan; - *frm ++ = csa_count; + *frm++ = IEEE80211_ACTION_SPECTRUM_MANAGEMENT; /* Category */ + *frm++ = IEEE80211_ACTION_S_CHANSWITCHANN; /* Spectrum Management */ + *frm++ = IEEE80211_ELEMID_CHANSWITCHANN; + *frm++ = 3; + *frm++ = csa_mode; + *frm++ = csa_chan; + *frm++ = csa_count; ieee80211_mgmt_output(ieee80211_ref_node(ni), skb, IEEE80211_FC0_SUBTYPE_ACTION, Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_scan.c =================================================================== --- madwifi/branches/madwifi-dfs/net80211/ieee80211_scan.c 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/net80211/ieee80211_scan.c 2008-03-29 23:17:39 UTC (rev 3411) @@ -1092,10 +1092,8 @@ new_channel->ic_freq); ieee80211_start_new_csa(vap, - IEEE80211_CSA_MUST_STOP_TX, - new_channel, - IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT, - 0); + IEEE80211_CSA_MUST_STOP_TX, new_channel, + IEEE80211_RADAR_CHANCHANGE_TBTT_COUNT, 0); } else { IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_var.h =================================================================== --- madwifi/branches/madwifi-dfs/net80211/ieee80211_var.h 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/net80211/ieee80211_var.h 2008-03-29 23:17:39 UTC (rev 3411) @@ -408,7 +408,7 @@ int ic_country_outdoor; struct ieee80211_ie_country ic_country_ie; /* country info element */ - /* current channel max power, used to compute Power Constraint IE. + /* Current channel max. power, used to compute Power Constraint IE. * * NB: local power constraint depends on the channel, but assuming it must * be detected dynamically, we cannot maintain a table (i.e., will not @@ -416,8 +416,8 @@ */ u_int8_t ic_curchanmaxpwr; - /* to handle Channel Switch Annoucements, only valid if ic_flags has - * IEEE80211_F_CHANSWITCH set */ + /* To handle Channel Switch Annoucements, only valid if ic_flags has + * IEEE80211_F_CHANSWITCH set. */ u_int8_t ic_csa_mode; struct ieee80211_channel * ic_csa_chan; u_int32_t ic_csa_expires_tu; Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c =================================================================== --- madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c 2008-03-29 21:45:53 UTC (rev 3410) +++ madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c 2008-03-29 23:17:39 UTC (rev 3411) @@ -757,10 +757,10 @@ ieee80211_setmode(ic, mode); } #endif - if ((vap->iv_opmode == IEEE80211_M_MONITOR || - vap->iv_opmode == IEEE80211_M_WDS)) { - if (vap->iv_des_chan != NULL && - vap->iv_des_chan != IEEE80211_CHAN_ANYC) { + if ((vap->iv_opmode == IEEE80211_M_MONITOR) || + (vap->iv_opmode == IEEE80211_M_WDS)) { + if ((vap->iv_des_chan != NULL) && + (vap->iv_des_chan != IEEE80211_CHAN_ANYC)) { /* Monitor and wds modes can switch directly. */ ic->ic_curchan = vap->iv_des_chan; if (vap->iv_state == IEEE80211_S_RUN) { @@ -769,16 +769,15 @@ } } else if (IEEE80211_IS_MODE_DFS_MASTER(vap->iv_opmode) && (ic->ic_flags & IEEE80211_F_DOTH)) { - if (vap->iv_des_chan != NULL && - vap->iv_des_chan != IEEE80211_CHAN_ANYC) { + if ((vap->iv_des_chan != NULL) && + (vap->iv_des_chan != IEEE80211_CHAN_ANYC)) { /* Need to use channel switch announcement on beacon * if we are up and running. We use ic_set_channel * directly * if we are "running" but not "up". * Otherwise, iv_des_chan * will take effect when we * are transitioned to RUN state * later. */ if (IS_UP(vap->iv_dev)) { - pre_announced_chanswitch(dev, - vap->iv_des_chan, + pre_announced_chanswitch(dev, vap->iv_des_chan, IEEE80211_DEFAULT_CHANCHANGE_TBTT_COUNT); } else if (vap->iv_state == IEEE80211_S_RUN) { ic->ic_curchan = vap->iv_des_chan; @@ -4477,13 +4476,11 @@ { struct ieee80211vap *vap = dev->priv; - ieee80211_send_csa_frame(vap, - IEEE80211_CSA_CAN_STOP_TX, + ieee80211_send_csa_frame(vap, IEEE80211_CSA_CAN_STOP_TX, channel->ic_ieee, csa_count); - /* now flag the beacon update to include the channel switch IE */ - ieee80211_start_new_csa(vap, - IEEE80211_CSA_CAN_STOP_TX, + /* Now flag the beacon update to include the channel switch IE. */ + ieee80211_start_new_csa(vap, IEEE80211_CSA_CAN_STOP_TX, channel, csa_count, 0); } @@ -4500,8 +4497,7 @@ return 0; c = ieee80211_doth_findchan(vap, param[0]); - if (c != NULL && - c != IEEE80211_CHAN_ANYC) { + if ((c != NULL) && (c != IEEE80211_CHAN_ANYC)) { pre_announced_chanswitch(dev, c, param[1]); } else { return -EINVAL; |