tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: run(4)



Hi,

2015-09-13 6:47 GMT+09:00 Robert Swindells <rjs%fdy2.co.uk@localhost>:

> I have put some diffs to run(4) on ftp.n.o that add support for some
> newer Ralink chipsets, they were derived from OpenBSD.

I teste your patch with some modified by me.
It works fine to me.

Tested devices
- Buffalo WLI-IC-AG300N
  MAC/BBP RT2872 (rev 0x0202), RF RT2850 (MIMO 2T2R)
- Logitec LAN-W450AN/U2
  MAC/BBP RT3593 (rev 0x0402), RF RT3053 (MIMO 3T3R)
- Logitec LAN-W300AU/U2
  MAC/BBP RT3572 (rev 0x0223), RF RT3052 (MIMO 2T2R)

Patch by me
- restore $NetBSD$
- add some device ID.
- restore non STA mode process.
- fix m_copydata destination address.
- TAB/whitespace fix.

Regards,
-- 
NONAKA Kimihiro
diff --git a/sys/dev/ic/rt2860reg.h b/sys/dev/ic/rt2860reg.h
index 1c58e80..c5eb093 100644
--- a/sys/dev/ic/rt2860reg.h
+++ b/sys/dev/ic/rt2860reg.h
@@ -1,3 +1,4 @@
+/*	$NetBSD: rt2860reg.h,v 1.1 2012/05/30 14:30:35 nonaka Exp $	*/
 /*	$OpenBSD: rt2860reg.h,v 1.32 2014/05/24 10:10:17 stsp Exp $	*/
 
 /*-
diff --git a/sys/dev/microcode/run/microcode.h b/sys/dev/microcode/run/microcode.h
index 1e6495c..87ce0d7 100644
--- a/sys/dev/microcode/run/microcode.h
+++ b/sys/dev/microcode/run/microcode.h
@@ -1,3 +1,4 @@
+/*	$NetBSD: microcode.h,v 1.1 2012/06/01 13:19:39 nonaka Exp $	*/
 /*	$OpenBSD: microcode.h,v 1.6 2014/05/19 05:38:51 stsp Exp $	*/
 
 /*-
diff --git a/sys/dev/usb/if_run.c b/sys/dev/usb/if_run.c
index 372f628..6c4bc92 100644
--- a/sys/dev/usb/if_run.c
+++ b/sys/dev/usb/if_run.c
@@ -206,6 +206,8 @@ static const struct usb_devno run_devs[] = {
 	USB_ID(LINKSYS4,	WUSB600NV2),
 	USB_ID(LOGITEC,		LANW300NU2),
 	USB_ID(LOGITEC,		LANW300NU2S),
+	USB_ID(LOGITEC,		LAN_W300ANU2),
+	USB_ID(LOGITEC,		LAN_W450ANU2E),
 	USB_ID(LOGITEC,		RT2870_1),
 	USB_ID(LOGITEC,		RT2870_2),
 	USB_ID(LOGITEC,		RT2870_3),
@@ -459,7 +461,7 @@ static const struct {
 	RT5592_DEF_BBP
 };
 
-/* 
+/*
  * Default values for BBP register R196 for RT5592.
  */
 static const uint8_t rt5592_bbp_r196[] = {
@@ -2610,6 +2612,15 @@ run_tx(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 		*(uint16_t *)wh->i_dur = htole16(dur);
 	}
 
+#ifndef IEEE80211_STA_ONLY
+	/* ask MAC to insert timestamp into probe responses */
+	if ((wh->i_fc[0] &
+	    (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) ==
+	    (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP))
+	    /* NOTE: beacons do not pass through tx_data() */
+		txwi->flags |= RT2860_TX_TS;
+#endif
+
 	if (__predict_false(sc->sc_drvbpf != NULL)) {
 		struct run_tx_radiotap_header *tap = &sc->sc_txtap;
 
@@ -2624,7 +2635,7 @@ run_tx(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 		bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m);
 	}
 
-	m_copydata(m, 0, m->m_pkthdr.len, (void *)(txwi + txwisize));
+	m_copydata(m, 0, m->m_pkthdr.len, (void *)(txwi + 1));
 	m_freem(m);
 
 	xferlen += sizeof (*txd) + 4;
@@ -2767,7 +2778,7 @@ run_ioctl(struct ifnet *ifp, u_long cmd, void *data)
 		}
 		break;
 
-#if 0		
+#if 0
 	case SIOCS80211CHANNEL:
 		/*
 		 * This allows for fast channel switching in monitor mode
@@ -3094,7 +3105,8 @@ run_rt3070_set_chan(struct run_softc *sc, u_int chan)
 	int i;
 
 	/* find the settings for this channel (we know it exists) */
-	for (i = 0; rt2860_rf2850[i].chan != chan; i++);
+	for (i = 0; rt2860_rf2850[i].chan != chan; i++)
+		continue;
 
 	/* use Tx power values from EEPROM */
 	txpow1 = sc->txpow1[i];
@@ -3367,7 +3379,7 @@ run_rt3593_set_chan(struct run_softc *sc, u_int chan)
 
 	run_rt3070_rf_write(sc, 31, (chan <= 14) ? 0xa0 : 0x80);
 
-	h20mhz = (sc->rf24_20mhz & 0x20) >> 5; 
+	h20mhz = (sc->rf24_20mhz & 0x20) >> 5;
 	run_rt3070_rf_read(sc, 30, &rf);
 	rf = (rf & ~0x06) | (h20mhz << 1) | (h20mhz << 2);
 	run_rt3070_rf_write(sc, 30, rf);
@@ -3394,7 +3406,7 @@ run_rt3593_set_chan(struct run_softc *sc, u_int chan)
 	else
 		rf |= 0x40;
 	run_rt3070_rf_write(sc, 6, rf);
-		
+
 	run_rt3070_rf_read(sc, 30, &rf);
 	rf = (rf & ~0x18) | 0x10;
 	run_rt3070_rf_write(sc, 30, rf);
@@ -3639,7 +3651,7 @@ run_rt5592_set_chan(struct run_softc *sc, u_int chan)
 
 		run_rt3070_rf_write(sc, 55, 0x43);
 
-		/* 
+		/*
 		 * RF R49/R50 Tx power ALC code.
 		 * G-band bit<7:6>=1:0, bit<5:0> range from 0x0 ~ 0x27.
 		 */
@@ -3659,7 +3671,7 @@ run_rt5592_set_chan(struct run_softc *sc, u_int chan)
 			}
 		}
 
-		/* 
+		/*
 		 * RF R49/R50 Tx power ALC code.
 		 * A-band bit<7:6>=1:1, bit<5:0> range from 0x0 ~ 0x2b.
 		 */
@@ -3806,8 +3818,27 @@ run_enable_tsf_sync(struct run_softc *sc)
 	tmp &= ~0x1fffff;
 	tmp |= ic->ic_bss->ni_intval * 16;
 	tmp |= RT2860_TSF_TIMER_EN | RT2860_TBTT_TIMER_EN;
-	/* local TSF is always updated with remote TSF on beacon reception */
-	tmp |= 1 << RT2860_TSF_SYNC_MODE_SHIFT;
+	if (ic->ic_opmode == IEEE80211_M_STA) {
+		/*
+		 * Local TSF is always updated with remote TSF on beacon
+		 * reception.
+		 */
+		tmp |= 1 << RT2860_TSF_SYNC_MODE_SHIFT;
+	}
+#ifndef IEEE80211_STA_ONLY
+	else if (ic->ic_opmode == IEEE80211_M_IBSS) {
+		tmp |= RT2860_BCN_TX_EN;
+		/*
+		 * Local TSF is updated with remote TSF on beacon reception
+		 * only if the remote TSF is greater than local TSF.
+		 */
+		tmp |= 2 << RT2860_TSF_SYNC_MODE_SHIFT;
+	} else if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
+		tmp |= RT2860_BCN_TX_EN;
+		/* SYNC with nobody */
+		tmp |= 3 << RT2860_TSF_SYNC_MODE_SHIFT;
+	}
+#endif
 	run_write(sc, RT2860_BCN_TIME_CFG, tmp);
 }
 
@@ -4068,7 +4099,7 @@ run_rt3070_rf_init(struct run_softc *sc)
 		}
 	}
 	if (sc->mac_ver == 0x3070 && sc->mac_rev < 0x0201) {
-		/* 
+		/*
 		 * Change voltage from 1.2V to 1.35V for RT3070.
 		 * The DAC issue (RT3070_LDO_CFG0) has been fixed
 		 * in RT3070(F).


Home | Main Index | Thread Index | Old Index