svn commit: r331041 - head/sys/dev/usb/wlan

Andriy Voskoboinyk avos at FreeBSD.org
Fri Mar 16 00:09:16 UTC 2018


Author: avos
Date: Fri Mar 16 00:09:16 2018
New Revision: 331041
URL: https://svnweb.freebsd.org/changeset/base/331041

Log:
  urtw(4): provide names for some commonly used rate indices + drop
  now-unused urtw_rate2rtl()

Modified:
  head/sys/dev/usb/wlan/if_urtw.c

Modified: head/sys/dev/usb/wlan/if_urtw.c
==============================================================================
--- head/sys/dev/usb/wlan/if_urtw.c	Thu Mar 15 23:32:29 2018	(r331040)
+++ head/sys/dev/usb/wlan/if_urtw.c	Fri Mar 16 00:09:16 2018	(r331041)
@@ -65,6 +65,12 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb/wlan/if_urtwreg.h>
 #include <dev/usb/wlan/if_urtwvar.h>
 
+/* copy some rate indices from if_rtwn_ridx.h */
+#define	URTW_RIDX_CCK5		2
+#define	URTW_RIDX_CCK11		3
+#define	URTW_RIDX_OFDM6		4
+#define	URTW_RIDX_OFDM24	8
+
 static SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L");
 #ifdef URTW_DEBUG
 int urtw_debug = 0;
@@ -682,7 +688,6 @@ static void		urtw_ledtask(void *, int);
 static void		urtw_watchdog(void *);
 static void		urtw_set_multi(void *);
 static int		urtw_isbmode(uint16_t);
-static uint16_t		urtw_rate2rtl(uint32_t);
 static uint16_t		urtw_rtl2rate(uint32_t);
 static usb_error_t	urtw_set_rate(struct urtw_softc *);
 static usb_error_t	urtw_update_msr(struct urtw_softc *);
@@ -866,7 +871,7 @@ urtw_attach(device_t dev)
 
 	sc->sc_rts_retry = URTW_DEFAULT_RTS_RETRY;
 	sc->sc_tx_retry = URTW_DEFAULT_TX_RETRY;
-	sc->sc_currate = 3;
+	sc->sc_currate = URTW_RIDX_CCK11;
 	sc->sc_preamble_mode = urtw_preamble_mode;
 
 	ic->ic_softc = sc;
@@ -1766,8 +1771,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_
 			flags |= URTW_TX_FLAG_CTS;
 		if (rtsenable) {
 			flags |= URTW_TX_FLAG_RTS;
-			flags |= (urtw_rate2rtl(11) & 0xf) <<
-			    URTW_TX_FLAG_RTSRATE_SHIFT;
+			flags |= URTW_RIDX_CCK5 << URTW_TX_FLAG_RTSRATE_SHIFT;
 			tx->rtsdur = rtsdur;
 		}
 		tx->flag = htole32(flags);
@@ -1788,7 +1792,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_
 			flags |= URTW_TX_FLAG_RTS;
 			tx->rtsdur = rtsdur;
 		}
-		flags |= (urtw_rate2rtl(11) & 0xf) << URTW_TX_FLAG_RTSRATE_SHIFT;
+		flags |= URTW_RIDX_CCK5 << URTW_TX_FLAG_RTSRATE_SHIFT;
 		tx->flag = htole32(flags);
 		tx->retry = 3;		/* CW minimum  */
 		tx->retry |= 7 << 4;	/* CW maximum  */
@@ -1908,9 +1912,9 @@ urtw_set_rate(struct urtw_softc *sc)
 	uint16_t data;
 	usb_error_t error;
 
-	basic_rate = urtw_rate2rtl(48);
-	min_rr_rate = urtw_rate2rtl(12);
-	max_rr_rate = urtw_rate2rtl(48);
+	basic_rate = URTW_RIDX_OFDM24;
+	min_rr_rate = URTW_RIDX_OFDM6;
+	max_rr_rate = URTW_RIDX_OFDM24;
 
 	urtw_write8_m(sc, URTW_RESP_RATE,
 	    max_rr_rate << URTW_RESP_MAX_RATE_SHIFT |
@@ -1925,19 +1929,6 @@ urtw_set_rate(struct urtw_softc *sc)
 	urtw_write16_m(sc, URTW_BRSR, data);
 fail:
 	return (error);
-}
-
-static uint16_t
-urtw_rate2rtl(uint32_t rate)
-{
-	unsigned int i;
-
-	for (i = 0; i < nitems(urtw_ratetable); i++) {
-		if (rate == urtw_ratetable[i].reg)
-			return urtw_ratetable[i].val;
-	}
-
-	return (3);
 }
 
 static uint16_t


More information about the svn-src-head mailing list