From owner-svn-src-head@freebsd.org Wed Sep 21 20:56:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E84BBE4805; Wed, 21 Sep 2016 20:56:11 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C8B8906; Wed, 21 Sep 2016 20:56:11 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8LKuACc041661; Wed, 21 Sep 2016 20:56:10 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8LKuAMk041660; Wed, 21 Sep 2016 20:56:10 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201609212056.u8LKuAMk041660@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Wed, 21 Sep 2016 20:56:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306142 - head/sys/dev/iwm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2016 20:56:11 -0000 Author: adrian Date: Wed Sep 21 20:56:10 2016 New Revision: 306142 URL: https://svnweb.freebsd.org/changeset/base/306142 Log: [iwm] use rate control info from the node txrates; use mgmtrate for EAPOL frames This changes the transmit rate control code to do a few things: * use fixed rates (mcast, ucast, mgmt) where required. * Don't use a hard-coded 11a or 11bg rate for non-data frames - use what net80211 says we should use. * use mgmtrate for EAPOL frames. Reviewed by: avos Differential Revision: https://reviews.freebsd.org/D7994 Modified: head/sys/dev/iwm/if_iwm.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Wed Sep 21 19:53:51 2016 (r306141) +++ head/sys/dev/iwm/if_iwm.c Wed Sep 21 20:56:10 2016 (r306142) @@ -324,7 +324,7 @@ static void iwm_update_sched(struct iwm_ #endif static const struct iwm_rate * iwm_tx_fill_cmd(struct iwm_softc *, struct iwm_node *, - struct ieee80211_frame *, struct iwm_tx_cmd *); + struct mbuf *, struct iwm_tx_cmd *); static int iwm_tx(struct iwm_softc *, struct mbuf *, struct ieee80211_node *, int); static int iwm_raw_xmit(struct ieee80211_node *, struct mbuf *, @@ -3197,24 +3197,36 @@ iwm_tx_rateidx_lookup(struct iwm_softc * */ static const struct iwm_rate * iwm_tx_fill_cmd(struct iwm_softc *sc, struct iwm_node *in, - struct ieee80211_frame *wh, struct iwm_tx_cmd *tx) + struct mbuf *m, struct iwm_tx_cmd *tx) { - struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni = &in->in_ni; + struct ieee80211_frame *wh; + const struct ieee80211_txparam *tp = ni->ni_txparms; const struct iwm_rate *rinfo; - int type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; - int ridx, rate_flags; + int type; + int ridx, rate_flags, i; + + wh = mtod(m, struct ieee80211_frame *); + type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; tx->rts_retry_limit = IWM_RTS_DFAULT_RETRY_LIMIT; tx->data_retry_limit = IWM_DEFAULT_TX_RETRY; - /* - * XXX TODO: everything about the rate selection here is terrible! - */ - - if (type == IEEE80211_FC0_TYPE_DATA) { - int i; + if (type == IEEE80211_FC0_TYPE_MGT) { + i = iwm_tx_rateidx_lookup(sc, in, tp->mgmtrate); + ridx = in->in_ridx[i]; + } else if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { + i = iwm_tx_rateidx_lookup(sc, in, tp->mcastrate); + ridx = in->in_ridx[i]; + } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { + i = iwm_tx_rateidx_lookup(sc, in, tp->ucastrate); + ridx = in->in_ridx[i]; + } else if (m->m_flags & M_EAPOL) { + i = iwm_tx_rateidx_lookup(sc, in, tp->mgmtrate); + ridx = in->in_ridx[i]; + } else { /* for data frames, use RS table */ + /* XXX pass pktlen */ (void) ieee80211_ratectl_rate(ni, NULL, 0); i = iwm_tx_rateidx_lookup(sc, in, ni->ni_txrate); ridx = in->in_ridx[i]; @@ -3225,28 +3237,6 @@ iwm_tx_fill_cmd(struct iwm_softc *sc, st IWM_DPRINTF(sc, IWM_DEBUG_XMIT | IWM_DEBUG_TXRATE, "%s: start with i=%d, txrate %d\n", __func__, i, iwm_rates[ridx].rate); - } else { - /* - * For non-data, use the lowest supported rate for the given - * operational mode. - * - * Note: there may not be any rate control information available. - * This driver currently assumes if we're transmitting data - * frames, use the rate control table. Grr. - * - * XXX TODO: use the configured rate for the traffic type! - * XXX TODO: this should be per-vap, not curmode; as we later - * on we'll want to handle off-channel stuff (eg TDLS). - */ - if (ic->ic_curmode == IEEE80211_MODE_11A) { - /* - * XXX this assumes the mode is either 11a or not 11a; - * definitely won't work for 11n. - */ - ridx = IWM_RIDX_OFDM; - } else { - ridx = IWM_RIDX_CCK; - } } rinfo = &iwm_rates[ridx]; @@ -3308,7 +3298,7 @@ iwm_tx(struct iwm_softc *sc, struct mbuf tx = (void *)cmd->data; memset(tx, 0, sizeof(*tx)); - rinfo = iwm_tx_fill_cmd(sc, in, wh, tx); + rinfo = iwm_tx_fill_cmd(sc, in, m, tx); /* Encrypt the frame if need be. */ if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {