Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Merge more changes from FreeBSD/OpenBSD. My two ...



details:   https://anonhg.NetBSD.org/src/rev/8c3cf4340809
branches:  trunk
changeset: 460106:8c3cf4340809
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Tue Oct 08 07:30:58 2019 +0000

description:
Merge more changes from FreeBSD/OpenBSD. My two run(4) devices now work
again.

diffstat:

 sys/dev/usb/if_run.c    |  341 +++++++++++++++++++++++++++++++++++------------
 sys/dev/usb/if_runvar.h |    6 +-
 2 files changed, 252 insertions(+), 95 deletions(-)

diffs (truncated from 702 to 300 lines):

diff -r a4ecad1513f6 -r 8c3cf4340809 sys/dev/usb/if_run.c
--- a/sys/dev/usb/if_run.c      Tue Oct 08 07:16:25 2019 +0000
+++ b/sys/dev/usb/if_run.c      Tue Oct 08 07:30:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $        */
+/*     $NetBSD: if_run.c,v 1.33 2019/10/08 07:30:58 mlelstv Exp $      */
 /*     $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */
 
 /*-
@@ -18,12 +18,12 @@
  */
 
 /*-
- * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver.
+ * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver.
  * http://www.ralinktech.com/
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.33 2019/10/08 07:30:58 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -122,6 +122,8 @@
        USB_ID(ASUSTEK,         RT2870_5),
        USB_ID(ASUSTEK,         RT3070),
        USB_ID(ASUSTEK,         RT3070_1),
+       USB_ID(ASUSTEK,         USBN53),
+       USB_ID(ASUSTEK,         USBN66),
        USB_ID(ASUSTEK2,        USBN11),
        USB_ID(AZUREWAVE,       RT2870_1),
        USB_ID(AZUREWAVE,       RT2870_2),
@@ -138,6 +140,7 @@
        USB_ID(BELKIN,          F7D1101V2),
        USB_ID(BELKIN,          RT2870_1),
        USB_ID(BELKIN,          RT2870_2),
+       USB_ID(BELKIN,          RTL8192CU_2),
        USB_ID(BEWAN,           RT3070),
        USB_ID(CISCOLINKSYS,    AE1000),
        USB_ID(CISCOLINKSYS,    AM10),
@@ -162,6 +165,10 @@
        USB_ID(CYBERTAN,        RT2870),
        USB_ID(DLINK,           RT2870),
        USB_ID(DLINK,           RT3072),
+       USB_ID(DLINK,           DWA127),
+       USB_ID(DLINK,           DWA140B3),
+       USB_ID(DLINK,           DWA160B2),
+       USB_ID(DLINK,           DWA162),
        USB_ID(DLINK2,          DWA130),
        USB_ID(DLINK2,          RT2870_1),
        USB_ID(DLINK2,          RT2870_2),
@@ -203,6 +210,9 @@
        USB_ID(LINKSYS4,        WUSB600N),
        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),
@@ -257,6 +267,7 @@
        USB_ID(RALINK,          RT3072),
        USB_ID(RALINK,          RT3370),
        USB_ID(RALINK,          RT3572),
+       USB_ID(RALINK,          RT3573),
        USB_ID(RALINK,          RT5370),
        USB_ID(RALINK,          RT5572),
        USB_ID(RALINK,          RT8070),
@@ -276,9 +287,11 @@
        USB_ID(SITECOMEU,       RT2870_2),
        USB_ID(SITECOMEU,       RT2870_3),
        USB_ID(SITECOMEU,       RT3070_1),
+       USB_ID(SITECOMEU,       RT3070_3),
        USB_ID(SITECOMEU,       RT3072_3),
        USB_ID(SITECOMEU,       RT3072_4),
        USB_ID(SITECOMEU,       RT3072_5),
+       USB_ID(SITECOMEU,       RT3072_6),
        USB_ID(SITECOMEU,       WL302),
        USB_ID(SITECOMEU,       WL315),
        USB_ID(SITECOMEU,       WL321),
@@ -352,7 +365,7 @@
 static int             run_bbp_read(struct run_softc *, uint8_t, uint8_t *);
 static int             run_bbp_write(struct run_softc *, uint8_t, uint8_t);
 static int             run_mcu_cmd(struct run_softc *, uint8_t, uint16_t);
-static const char *    run_get_rf(int);
+static const char *    run_get_rf(uint16_t);
 static void            run_rt3593_get_txpower(struct run_softc *);
 static void            run_get_txpower(struct run_softc *);
 static int             run_read_eeprom(struct run_softc *);
@@ -850,6 +863,11 @@
 {
        struct run_tx_ring *txq = &sc->txq[qid];
        int i, error;
+       uint16_t txwisize;
+
+       txwisize = sizeof(struct rt2860_txwi);
+       if (sc->mac_ver == 0x5592)
+               txwisize += sizeof(uint32_t);
 
        txq->cur = txq->queued = 0;
 
@@ -870,8 +888,7 @@
 
                data->buf = usbd_get_buffer(data->xfer);
                /* zeroize the TXD + TXWI part */
-               memset(data->buf, 0, sizeof(struct rt2870_txd) +
-                   sizeof(struct rt2860_txwi));
+               memset(data->buf, 0, sizeof(struct rt2870_txd) + txwisize);
        }
        if (error != 0)
 fail:          run_free_tx_ring(sc, qid);
@@ -942,7 +959,9 @@
                return error;
 
        usbd_delay_ms(sc->sc_udev, 10);
+       run_write(sc, RT2860_H2M_BBPAGENT, 0);
        run_write(sc, RT2860_H2M_MAILBOX, 0);
+       run_write(sc, RT2860_H2M_INTSRC, 0);
        if ((error = run_mcu_cmd(sc, RT2860_MCU_CMD_RFRESET, 0)) != 0)
                return error;
 
@@ -1106,6 +1125,7 @@
        if ((error = run_read(sc, reg, &tmp)) != 0)
                return error;
 
+       tmp >>= (8 * (addr & 0x3));
        *val = (addr & 1) ? tmp >> 16 : tmp & 0xffff;
        return 0;
 }
@@ -1315,7 +1335,7 @@
 }
 
 static const char *
-run_get_rf(int rev)
+run_get_rf(uint16_t rev)
 {
        switch (rev) {
        case RT2860_RF_2820:    return "RT2820";
@@ -1487,34 +1507,45 @@
        ic->ic_myaddr[4] = val & 0xff;
        ic->ic_myaddr[5] = val >> 8;
 
-       /* read vendor BBP settings */
-       for (i = 0; i < 10; i++) {
-               run_srom_read(sc, RT2860_EEPROM_BBP_BASE + i, &val);
-               sc->bbp[i].val = val & 0xff;
-               sc->bbp[i].reg = val >> 8;
-               DPRINTF(("BBP%d=0x%02x\n", sc->bbp[i].reg, sc->bbp[i].val));
-       }
-
-       /* read vendor RF settings */
-       for (i = 0; i < 8; i++) {
-               run_srom_read(sc, RT3071_EEPROM_RF_BASE + i, &val);
-               sc->rf[i].val = val & 0xff;
-               sc->rf[i].reg = val >> 8;
-               DPRINTF(("RF%d=0x%02x\n", sc->rf[i].reg,
-                   sc->rf[i].val));
+       if (sc->mac_ver < 0x3593) {
+               /* read vendor BBP settings */
+               for (i = 0; i < 10; i++) {
+                       run_srom_read(sc, RT2860_EEPROM_BBP_BASE + i, &val);
+                       sc->bbp[i].val = val & 0xff;
+                       sc->bbp[i].reg = val >> 8;
+                       DPRINTF(("BBP%d=0x%02x\n", sc->bbp[i].reg,
+                           sc->bbp[i].val));
+               }
+
+               if (sc->mac_ver >= 0x3071) {
+                       /* read vendor RF settings */
+                       for (i = 0; i < 8; i++) {
+                               run_srom_read(sc, RT3071_EEPROM_RF_BASE + i,
+                                   &val);
+                               sc->rf[i].val = val & 0xff;
+                               sc->rf[i].reg = val >> 8;
+                               DPRINTF(("RF%d=0x%02x\n", sc->rf[i].reg,
+                                   sc->rf[i].val));
+                       }
+               }
        }
 
        /* read RF frequency offset from EEPROM */
-       run_srom_read(sc, RT2860_EEPROM_FREQ_LEDS, &val);
+       run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS :
+           RT3593_EEPROM_FREQ, &val);
        sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0;
        DPRINTF(("EEPROM freq offset %d\n", sc->freq & 0xff));
-
+       run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS :
+           RT3593_EEPROM_FREQ, &val);
        if ((val >> 8) != 0xff) {
                /* read LEDs operating mode */
                sc->leds = val >> 8;
-               run_srom_read(sc, RT2860_EEPROM_LED1, &sc->led[0]);
-               run_srom_read(sc, RT2860_EEPROM_LED2, &sc->led[1]);
-               run_srom_read(sc, RT2860_EEPROM_LED3, &sc->led[2]);
+               run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_LED1 :
+                   RT3593_EEPROM_LED1, &sc->led[0]);
+               run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_LED2 :
+                   RT3593_EEPROM_LED2, &sc->led[1]);
+               run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_LED3 :
+                   RT3593_EEPROM_LED3, &sc->led[2]);
        } else {
                /* broken EEPROM, use default settings */
                sc->leds = 0x01;
@@ -1526,7 +1557,10 @@
            sc->leds, sc->led[0], sc->led[1], sc->led[2]));
 
        /* read RF information */
-       run_srom_read(sc, RT2860_EEPROM_ANTENNA, &val);
+       if (sc->mac_ver == 0x5390 || sc->mac_ver == 0x5392)
+               run_srom_read(sc, 0x00, &val);
+       else
+               run_srom_read(sc, RT2860_EEPROM_ANTENNA, &val);
        if (val == 0xffff) {
                DPRINTF(("invalid EEPROM antenna info, using default\n"));
                if (sc->mac_ver == 0x3572) {
@@ -1546,11 +1580,15 @@
                        sc->nrxchains = 2;
                }
        } else {
-               sc->rf_rev = (val >> 8) & 0xf;
+               if (sc->mac_ver == 0x5390 || sc->mac_ver == 0x5392) {
+                       sc->rf_rev = val;
+                       run_srom_read(sc, RT2860_EEPROM_ANTENNA, &val);
+               } else
+                       sc->rf_rev = (val >> 8) & 0xf;
                sc->ntxchains = (val >> 4) & 0xf;
                sc->nrxchains = val & 0xf;
        }
-       DPRINTF(("EEPROM RF rev=0x%02x chains=%dT%dR\n",
+       DPRINTF(("EEPROM RF rev=0x%04x chains=%dT%dR\n",
            sc->rf_rev, sc->ntxchains, sc->nrxchains));
 
        run_srom_read(sc, RT2860_EEPROM_CONFIG, &val);
@@ -1607,11 +1645,14 @@
                    sc->txpow40mhz_2ghz[ridx], sc->txpow40mhz_5ghz[ridx]));
        }
 
+       DPRINTF(("mac_ver %hx\n", sc->mac_ver));
        /* read RSSI offsets and LNA gains from EEPROM */
-       run_srom_read(sc, RT2860_EEPROM_RSSI1_2GHZ, &val);
+       run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI1_2GHZ :
+           RT3593_EEPROM_RSSI1_2GHZ, &val);
        sc->rssi_2ghz[0] = val & 0xff;  /* Ant A */
        sc->rssi_2ghz[1] = val >> 8;    /* Ant B */
-       run_srom_read(sc, RT2860_EEPROM_RSSI2_2GHZ, &val);
+       run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI2_2GHZ :
+           RT3593_EEPROM_RSSI2_2GHZ, &val);
        if (sc->mac_ver >= 0x3070) {
                if (sc->mac_ver == 0x3593) {
                        sc->txmixgain_2ghz = 0;
@@ -1633,7 +1674,7 @@
        sc->lna[2] = val >> 8;          /* channel group 2 */
 
        run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI1_5GHZ :
-           RT3593_EEPROM_RSSI2_5GHZ, &val);
+           RT3593_EEPROM_RSSI1_5GHZ, &val);
        sc->rssi_5ghz[0] = val & 0xff;  /* Ant A */
        sc->rssi_5ghz[1] = val >> 8;    /* Ant B */
        run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI2_5GHZ :
@@ -2207,6 +2248,11 @@
 #endif
 
        rxwi = (struct rt2860_rxwi *)buf;
+       rxwisize = sizeof(struct rt2860_rxwi);
+       if (sc->mac_ver == 0x5592)
+               rxwisize += sizeof(uint64_t);
+       else if (sc->mac_ver == 0x3593)
+               rxwisize += sizeof(uint32_t);
        len = le16toh(rxwi->len) & 0xfff;
        if (__predict_false(len > dmalen)) {
                DPRINTF(("bad RXWI length %u > %u\n", len, dmalen));
@@ -2221,19 +2267,7 @@
                return;
        }
 
-       rxwisize = sizeof(struct rt2860_rxwi);
-       if (sc->mac_ver == 0x5592)
-               rxwisize += sizeof(uint64_t);
-       else if (sc->mac_ver == 0x3593)
-               rxwisize += sizeof(uint32_t);
-
-       wh = (struct ieee80211_frame *)(((uint8_t *)rxwi) + rxwisize);
-#ifdef RUN_HWCRYPTO
-       if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
-               wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
-               decrypted = 1;
-       }
-#endif
+       wh = (struct ieee80211_frame *)(buf + rxwisize);
 
        if (__predict_false((flags & RT2860_RX_MICERR))) {
                /* report MIC failures to net80211 for TKIP */
@@ -2241,13 +2275,20 @@
                ifp->if_ierrors++;
                return;
        }
-



Home | Main Index | Thread Index | Old Index