From owner-p4-projects@FreeBSD.ORG Fri Sep 5 23:20:58 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1F9741065677; Fri, 5 Sep 2008 23:20:58 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8E611065675 for ; Fri, 5 Sep 2008 23:20:57 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C17508FC1C for ; Fri, 5 Sep 2008 23:20:57 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m85NKv5V048086 for ; Fri, 5 Sep 2008 23:20:57 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m85NKvil048072 for perforce@freebsd.org; Fri, 5 Sep 2008 23:20:57 GMT (envelope-from sam@freebsd.org) Date: Fri, 5 Sep 2008 23:20:57 GMT Message-Id: <200809052320.m85NKvil048072@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 149294 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Sep 2008 23:20:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=149294 Change 149294 by sam@sam_ebb on 2008/09/05 23:20:52 Fix tx parameters for mgt frames so drivers don't need to deal with this; this also eliminates the hack M_LINK0 use to force wep encryption for the shared key auth handshake (which is important 'cuz we're out of flags and will shortly re-use it for something else). This is a bit ugly and may need some cleanup. Affected files ... .. //depot/projects/vap/sys/net80211/ieee80211_ht.c#44 edit .. //depot/projects/vap/sys/net80211/ieee80211_output.c#54 edit .. //depot/projects/vap/sys/net80211/ieee80211_proto.h#25 edit Differences ... ==== //depot/projects/vap/sys/net80211/ieee80211_ht.c#44 (text+ko) ==== @@ -1945,6 +1945,7 @@ } while (0) struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; + struct ieee80211_bpf_params params; struct mbuf *m; uint8_t *frm; uint16_t baparamset; @@ -2048,7 +2049,14 @@ } m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); - return ieee80211_mgmt_output(ni, m, IEEE80211_FC0_SUBTYPE_ACTION); + memset(¶ms, 0, sizeof(params)); + params.ibp_pri = WME_AC_VO; + params.ibp_rate0 = ni->ni_txparms->mgmtrate; + /* NB: we know all frames are unicast */ + params.ibp_try0 = ni->ni_txparms->maxretry; + params.ibp_power = ni->ni_txpower; + return ieee80211_mgmt_output(ni, m, IEEE80211_FC0_SUBTYPE_ACTION, + ¶ms); bad: ieee80211_free_node(ni); if (m != NULL) ==== //depot/projects/vap/sys/net80211/ieee80211_output.c#54 (text+ko) ==== @@ -479,7 +479,8 @@ * otherwise deal with reclaiming any reference (on error). */ int -ieee80211_mgmt_output(struct ieee80211_node *ni, struct mbuf *m, int type) +ieee80211_mgmt_output(struct ieee80211_node *ni, struct mbuf *m, int type, + struct ieee80211_bpf_params *params) { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; @@ -509,17 +510,15 @@ ieee80211_send_setup(ni, wh, IEEE80211_FC0_TYPE_MGT | type, vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); - if ((m->m_flags & M_LINK0) != 0 && ni->ni_challenge != NULL) { - m->m_flags &= ~M_LINK0; + if (params->ibp_flags & IEEE80211_BPF_CRYPTO) { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr1, "encrypting frame (%s)", __func__); wh->i_fc[1] |= IEEE80211_FC1_WEP; } - if (type != IEEE80211_FC0_SUBTYPE_PROBE_RESP) { - /* NB: force non-ProbeResp frames to the highest queue */ - M_WME_SETAC(m, WME_AC_VO); - } else - M_WME_SETAC(m, WME_AC_BE); + + KASSERT(type != IEEE80211_FC0_SUBTYPE_PROBE_RESP, ("probe response?")); + M_WME_SETAC(m, params->ibp_pri); + #ifdef IEEE80211_DEBUG /* avoid printing too many frames */ if ((ieee80211_msg_debug(vap) && doprint(vap, type)) || @@ -534,7 +533,7 @@ #endif IEEE80211_NODE_STAT(ni, tx_mgmt); - return ic->ic_raw_xmit(ni, m, NULL); + return ic->ic_raw_xmit(ni, m, params); } /* @@ -554,6 +553,8 @@ struct ieee80211com *ic = ni->ni_ic; struct mbuf *m; struct ieee80211_frame *wh; + int hdrlen; + uint8_t *frm; if (vap->iv_state == IEEE80211_S_CAC) { IEEE80211_NOTE(vap, IEEE80211_MSG_OUTPUT | IEEE80211_MSG_DOTH, @@ -563,16 +564,27 @@ return EIO; /* XXX */ } - m = m_gethdr(M_NOWAIT, MT_HEADER); + if (vap->iv_opmode == IEEE80211_M_WDS) + hdrlen = sizeof(struct ieee80211_frame_addr4); + else + hdrlen = sizeof(struct ieee80211_frame); + m = ieee80211_getmgtframe(&frm, ic->ic_headroom + hdrlen, 0); if (m == NULL) { /* XXX debug msg */ ieee80211_unref_node(&ni); vap->iv_stats.is_tx_nobuf++; return ENOMEM; } - MH_ALIGN(m, sizeof(struct ieee80211_frame)); + KASSERT(M_LEADINGSPACE(m) >= hdrlen, + ("leading space %d", M_LEADINGSPACE(m))); + M_PREPEND(m, hdrlen, M_DONTWAIT); + if (m == NULL) { + /* NB: cannot happen */ + ieee80211_free_node(ni); + return ENOMEM; + } - wh = mtod(m, struct ieee80211_frame *); + wh = mtod(m, struct ieee80211_frame *); /* NB: a little lie */ ieee80211_send_setup(ni, wh, IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA, vap->iv_myaddr, ni->ni_macaddr, ni->ni_bssid); @@ -582,11 +594,8 @@ vap->iv_opmode != IEEE80211_M_HOSTAP) wh->i_fc[1] |= IEEE80211_FC1_PWR_MGT; m->m_len = m->m_pkthdr.len = sizeof(struct ieee80211_frame); - } else { - /* NB: 4-address frame */ - m->m_len = m->m_pkthdr.len = - sizeof(struct ieee80211_frame_addr4); } + m->m_len = m->m_pkthdr.len = hdrlen; M_WME_SETAC(m, WME_AC_BE); IEEE80211_NODE_STAT(ni, tx_data); @@ -1654,6 +1663,8 @@ { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; + const struct ieee80211_txparam *tp; + struct ieee80211_bpf_params params; struct ieee80211_frame *wh; const struct ieee80211_rateset *rs; struct mbuf *m; @@ -1721,6 +1732,8 @@ frm = add_appie(frm, vap->iv_appie_probereq); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); + KASSERT(M_LEADINGSPACE(m) >= sizeof(struct ieee80211_frame), + ("leading space %d", M_LEADINGSPACE(m))); M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT); if (m == NULL) return ENOMEM; @@ -1741,7 +1754,17 @@ ieee80211_chan2ieee(ic, ic->ic_curchan), ether_sprintf(bssid), ssidlen, ssid); - return ic->ic_raw_xmit(ni, m, NULL); + memset(¶ms, 0, sizeof(params)); + params.ibp_pri = M_WME_GETAC(m); + tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; + params.ibp_rate0 = tp->mgmtrate; + if (IEEE80211_IS_MULTICAST(da)) { + params.ibp_flags |= IEEE80211_BPF_NOACK; + params.ibp_try0 = 1; + } else + params.ibp_try0 = tp->maxretry; + params.ibp_power = ni->ni_txpower; + return ic->ic_raw_xmit(ni, m, ¶ms); } /* @@ -1786,6 +1809,7 @@ struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; struct ieee80211_node *bss = vap->iv_bss; + struct ieee80211_bpf_params params; struct mbuf *m; uint8_t *frm; uint16_t capinfo; @@ -1805,6 +1829,7 @@ ieee80211_node_refcnt(ni)+1); ieee80211_ref_node(ni); + memset(¶ms, 0, sizeof(params)); switch (type) { case IEEE80211_FC0_SUBTYPE_AUTH: @@ -1827,7 +1852,7 @@ bss->ni_authmode == IEEE80211_AUTH_SHARED); m = ieee80211_getmgtframe(&frm, - ic->ic_headroom + sizeof(struct ieee80211_frame), + ic->ic_headroom + sizeof(struct ieee80211_frame), 3 * sizeof(uint16_t) + (has_challenge && status == IEEE80211_STATUS_SUCCESS ? sizeof(uint16_t)+IEEE80211_CHALLENGE_LEN : 0) @@ -1852,7 +1877,8 @@ if (arg == IEEE80211_AUTH_SHARED_RESPONSE) { IEEE80211_NOTE(vap, IEEE80211_MSG_AUTH, ni, "request encrypt frame (%s)", __func__); - m->m_flags |= M_LINK0; /* WEP-encrypt, please */ + /* mark frame for encryption */ + params.ibp_flags |= IEEE80211_BPF_CRYPTO; } } else m->m_pkthdr.len = m->m_len = 3 * sizeof(uint16_t); @@ -2093,7 +2119,13 @@ /* NOTREACHED */ } - return ieee80211_mgmt_output(ni, m, type); + /* NB: force non-ProbeResp frames to the highest queue */ + params.ibp_pri = WME_AC_VO; + params.ibp_rate0 = ni->ni_txparms->mgmtrate; + /* NB: we know all frames are unicast */ + params.ibp_try0 = ni->ni_txparms->maxretry; + params.ibp_power = ni->ni_txpower; + return ieee80211_mgmt_output(ni, m, type, ¶ms); bad: ieee80211_free_node(ni); return ret; ==== //depot/projects/vap/sys/net80211/ieee80211_proto.h#25 (text+ko) ==== @@ -64,8 +64,9 @@ ((ni)->ni_vap->iv_input(ni, m, rssi, noise, rstamp)) int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int, uint32_t); -int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int); struct ieee80211_bpf_params; +int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int, + struct ieee80211_bpf_params *); int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); int ieee80211_output(struct ifnet *, struct mbuf *,