Tue Mar 3 09:34:40 2015 UTC ()
sc_fixed_ridx is initialised to 0 but tested as it it were initialised
to -1.  The result of this is tx frames were always sent out at fixed
rate 0 instead of ni_txrate.

Match the iwn behaviour and test ic_fixed_rate for -1 instead.

From OpenBSD rev.1.29.


(nonaka)
diff -r1.20 -r1.21 src/sys/dev/pci/if_iwm.c

cvs diff -r1.20 -r1.21 src/sys/dev/pci/if_iwm.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_iwm.c 2015/03/03 09:27:35 1.20
+++ src/sys/dev/pci/if_iwm.c 2015/03/03 09:34:40 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_iwm.c,v 1.20 2015/03/03 09:27:35 nonaka Exp $ */ 1/* $NetBSD: if_iwm.c,v 1.21 2015/03/03 09:34:40 nonaka Exp $ */
2/* OpenBSD: if_iwm.c,v 1.18 2015/02/11 01:12:42 brad Exp */ 2/* OpenBSD: if_iwm.c,v 1.18 2015/02/11 01:12:42 brad Exp */
3 3
4/* 4/*
5 * Copyright (c) 2014 genua mbh <info@genua.de> 5 * Copyright (c) 2014 genua mbh <info@genua.de>
6 * Copyright (c) 2014 Fixup Software Ltd. 6 * Copyright (c) 2014 Fixup Software Ltd.
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@@ -95,27 +95,27 @@ @@ -95,27 +95,27 @@
95 * purpose with or without fee is hereby granted, provided that the above 95 * purpose with or without fee is hereby granted, provided that the above
96 * copyright notice and this permission notice appear in all copies. 96 * copyright notice and this permission notice appear in all copies.
97 * 97 *
98 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 98 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 99 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
100 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 100 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
101 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 101 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
102 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 102 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
103 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 103 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
104 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 104 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
105 */ 105 */
106 106
107#include <sys/cdefs.h> 107#include <sys/cdefs.h>
108__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.20 2015/03/03 09:27:35 nonaka Exp $"); 108__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.21 2015/03/03 09:34:40 nonaka Exp $");
109 109
110#include <sys/param.h> 110#include <sys/param.h>
111#include <sys/conf.h> 111#include <sys/conf.h>
112#include <sys/kernel.h> 112#include <sys/kernel.h>
113#include <sys/kmem.h> 113#include <sys/kmem.h>
114#include <sys/mbuf.h> 114#include <sys/mbuf.h>
115#include <sys/mutex.h> 115#include <sys/mutex.h>
116#include <sys/proc.h> 116#include <sys/proc.h>
117#include <sys/socket.h> 117#include <sys/socket.h>
118#include <sys/sockio.h> 118#include <sys/sockio.h>
119#include <sys/systm.h> 119#include <sys/systm.h>
120 120
121#include <sys/cpu.h> 121#include <sys/cpu.h>
@@ -3807,27 +3807,27 @@ static const struct iwm_rate * @@ -3807,27 +3807,27 @@ static const struct iwm_rate *
3807iwm_tx_fill_cmd(struct iwm_softc *sc, struct iwm_node *in, 3807iwm_tx_fill_cmd(struct iwm_softc *sc, struct iwm_node *in,
3808 struct ieee80211_frame *wh, struct iwm_tx_cmd *tx) 3808 struct ieee80211_frame *wh, struct iwm_tx_cmd *tx)
3809{ 3809{
3810 const struct iwm_rate *rinfo; 3810 const struct iwm_rate *rinfo;
3811 int type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; 3811 int type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
3812 int ridx, rate_flags; 3812 int ridx, rate_flags;
3813 int nrates = in->in_ni.ni_rates.rs_nrates; 3813 int nrates = in->in_ni.ni_rates.rs_nrates;
3814 3814
3815 tx->rts_retry_limit = IWM_RTS_DFAULT_RETRY_LIMIT; 3815 tx->rts_retry_limit = IWM_RTS_DFAULT_RETRY_LIMIT;
3816 tx->data_retry_limit = IWM_DEFAULT_TX_RETRY; 3816 tx->data_retry_limit = IWM_DEFAULT_TX_RETRY;
3817 3817
3818 /* for data frames, use RS table */ 3818 /* for data frames, use RS table */
3819 if (type == IEEE80211_FC0_TYPE_DATA) { 3819 if (type == IEEE80211_FC0_TYPE_DATA) {
3820 if (sc->sc_fixed_ridx != -1) { 3820 if (sc->sc_ic.ic_fixed_rate != -1) {
3821 tx->initial_rate_index = sc->sc_fixed_ridx; 3821 tx->initial_rate_index = sc->sc_fixed_ridx;
3822 } else { 3822 } else {
3823 tx->initial_rate_index = (nrates-1) - in->in_ni.ni_txrate; 3823 tx->initial_rate_index = (nrates-1) - in->in_ni.ni_txrate;
3824 } 3824 }
3825 tx->tx_flags |= htole32(IWM_TX_CMD_FLG_STA_RATE); 3825 tx->tx_flags |= htole32(IWM_TX_CMD_FLG_STA_RATE);
3826 DPRINTFN(12, ("start with txrate %d\n", tx->initial_rate_index)); 3826 DPRINTFN(12, ("start with txrate %d\n", tx->initial_rate_index));
3827 return &iwm_rates[tx->initial_rate_index]; 3827 return &iwm_rates[tx->initial_rate_index];
3828 } 3828 }
3829 3829
3830 /* for non-data, use the lowest supported rate */ 3830 /* for non-data, use the lowest supported rate */
3831 ridx = in->in_ridx[0]; 3831 ridx = in->in_ridx[0];
3832 rinfo = &iwm_rates[ridx]; 3832 rinfo = &iwm_rates[ridx];
3833 3833