Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/net Pull up following revision(s) (requested by mrg i...



details:   https://anonhg.NetBSD.org/src/rev/717810312d89
branches:  netbsd-9
changeset: 963632:717810312d89
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Feb 25 18:40:43 2020 +0000

description:
Pull up following revision(s) (requested by mrg in ticket #717):

        sys/dev/fdt/dwcmmc_fdt.c                        1.11
        sys/dev/ic/bwfm.c                               1.15-1.18
        sys/dev/ic/bwfmreg.h                            1.4-1.6
        sys/dev/ic/bwfmvar.h                            1.4,1.5
        sys/dev/ic/dwc_mmc.c                            1.21,1.22
        sys/dev/ic/dwc_mmc_reg.h                        1.8,1.9,1.12,1.13
        sys/dev/pcmcia/pcmciareg.h                      1.11
        sys/dev/sdmmc/if_bwfm_sdio.c                    1.4,1.6-1.12
        sys/dev/sdmmc/if_bwfm_sdio.h                    1.1,1.2
        sys/dev/sdmmc/sdhc.c                            1.105,1.106
        sys/dev/sdmmc/sdmmc.c                           1.37,1.39
        sys/dev/sdmmc/sdmmc_cis.c                       1.6,1.8
        sys/dev/sdmmc/sdmmc_io.c                        1.15-1.19
        sys/dev/sdmmc/sdmmc_ioreg.h                     1.4,1.5
        sys/dev/sdmmc/sdmmc_mem.c                       1.69-1.71
        sys/dev/sdmmc/sdmmcdevs                         1.5-1.8
        sys/dev/sdmmc/sdmmcvar.h                        1.31,1.33,1.34
        sys/net/if_media.h                              1.66

Add Broadcom devices
 -
Fix typo
 -
add PCMCIA_CISTPL_SDIO definition.
 -
>From OpenBSD:
- move event handling to workqueue
- check for save/restore capability
 -
Tag work queue as MPsafe and increase length.
 -
Juse use bpf_mtap(), the 802.11 encapsulation is handled by firmware.
 -
>From OpenBSD:
- support block length per function
- add functions to read/write regions
 -
Decode (but not use) SDIO tuple in CIS.
 -
Fix locking.
 -
Add more SDIO defines (partially from version 3.0).
 -
>From OpenBSD:
- All the missing pieces (firmware load, chip setup, protocol handling)
TX queue and interrupt handling via sdmmc_task.
 -
Fix locking.
 -
Fix packet parsing.
 -
Add parser for original firmware config files.
 -
tagging work queue as MPSAFE was premature. Revert.
 -
SD_IO_RW_EXTENDED is a data transfer command, so set ADTC flag instead of AC
Use correct function to verify if a task has been queued. Avoids race
that can corrupt the task queue.
 -
More register definitions.
 -
Add IFM_IEEE80211_VHT subtype, IFM_IEEE80211_11AC operating mode, and missing descriptions
 -
If firmware is connected in HT or VHT mode, report it to SIOCGIFMEDIA
 -
white space police.

Skip setting power when the voltage doesn't change.
Also increase some timeouts.
 -
Add and use sdmmc_pause to avoid long-term busy waits.
 -
Add sdio abort function.
 -
Additional error messages.
 -
Print parameters for SDIO devices.
 -
Minor cosmetics.
 -
Simplyfy sdmmc_io_set_blocklen function signature by dropping the
extra softc pointer. Aligns with OpenBSD.
 -
Missing commit for sdio abort function.
 -
More code from OpenBSD
 -
no need to splnet() when enqueing packets
 -
explicit structure padding
 -
make internal functions static
 -
also prepare for GPIO interrupts.
 -
Avoid warnings for tautological shifts as sole conditional.
 -
Follow the Linux driver an use the FDT "compatible" property to build a
filename for the nvram config file, fall back to the standard filename.
E.g.
[Caching 123 nodes and 1093 properties]
compatible              73696e6f 766f6970 2c627069 2d6d322d   "sinovoip,bpi-m2-
            0010:       7a65726f 00...... ........ ........   zero"
            0015:       616c6c77 696e6e65 722c7375 6e38692d   "allwinner,sun8i-
            0025:       68322d70 6c757300 ........ ........   h2-plus"
interrupt-parent        00000001 ........ ........ ........   ....
model                   42616e61 6e612050 69204250 492d4d32   "Banana Pi BPI-M2
            0010:       2d5a6572 6f00.... ........ ........   -Zero"
name                    00...... ........ ........ ........   ""
serial-number           30326330 30303432 65636431 36376566   02c00042ecd167ef
            0010:       00...... ........ ........ ........   .
-rw-r--r--  1 root  wheel     875 Nov  2 12:06 brcmfmac43430-sdio.AP6212.txt
lrwxr-xr-x  1 root  wheel      29 Dec 30 16:19 brcmfmac43430-sdio.sinovoip,bpi-m2-zero.txt -> brcmfmac43430-sdio.AP6212.txt
-rw-r--r--  1 root  wheel     874 Jun 30  2019 brcmfmac43430-sdio.raspberrypi,3-model-b.txt
-rw-r--r--  1 root  wheel    1864 Jun 30  2019 brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt
lrwxr-xr-x  1 root  wheel      29 Dec 30 11:24 brcmfmac43455-sdio.raspberrypi,4-model-b-plus.txt -> brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt
 -
Add product ID for Broadcom BCM43455
 -
Use correct firmware for BCM43456
 -
size check was backwards.
 -
Be less noisy for some commands.
 -
Fix DWC_MMC_INT_SDIO_INT bit
 -
dwc_mmc fixes:
 - Rockchip uses a different SDIO int bit, so take this into consideration
 - Avoid unnecessary resets and always wait for resets to complete
 - kpause instead of delay while holding spinlock
 - Do not attempt autostop for SD_IO_RW_EXTENDED commands
 - Allow for sub-blklen byte counts for single block transfers
  -
More SDIO stability and performance fixes

diffstat:

 sys/dev/fdt/dwcmmc_fdt.c     |     7 +-
 sys/dev/ic/bwfm.c            |   270 ++++-
 sys/dev/ic/bwfmreg.h         |   151 +++-
 sys/dev/ic/bwfmvar.h         |    10 +-
 sys/dev/ic/dwc_mmc.c         |    99 +-
 sys/dev/ic/dwc_mmc_reg.h     |     8 +-
 sys/dev/ic/dwc_mmc_var.h     |     5 +-
 sys/dev/pcmcia/pcmciareg.h   |     3 +-
 sys/dev/sdmmc/if_bwfm_sdio.c |  1835 +++++++++++++++++++++++++++++++++++++++--
 sys/dev/sdmmc/if_bwfm_sdio.h |   209 ++++
 sys/dev/sdmmc/sdhc.c         |    60 +-
 sys/dev/sdmmc/sdmmc.c        |    27 +-
 sys/dev/sdmmc/sdmmc_cis.c    |    14 +-
 sys/dev/sdmmc/sdmmc_io.c     |   201 +++-
 sys/dev/sdmmc/sdmmc_ioreg.h  |    38 +-
 sys/dev/sdmmc/sdmmc_mem.c    |    12 +-
 sys/dev/sdmmc/sdmmcdevs      |    20 +-
 sys/dev/sdmmc/sdmmcvar.h     |     9 +-
 sys/net/if_media.h           |     7 +-
 19 files changed, 2702 insertions(+), 283 deletions(-)

diffs (truncated from 4336 to 300 lines):

diff -r c9947de56959 -r 717810312d89 sys/dev/fdt/dwcmmc_fdt.c
--- a/sys/dev/fdt/dwcmmc_fdt.c  Thu Feb 20 14:54:22 2020 +0000
+++ b/sys/dev/fdt/dwcmmc_fdt.c  Tue Feb 25 18:40:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwcmmc_fdt.c,v 1.8.2.1 2020/01/21 10:39:58 martin Exp $ */
+/* $NetBSD: dwcmmc_fdt.c,v 1.8.2.2 2020/02/25 18:40:43 martin Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.8.2.1 2020/01/21 10:39:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwcmmc_fdt.c,v 1.8.2.2 2020/02/25 18:40:43 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -56,12 +56,14 @@
 struct dwcmmc_fdt_config {
        u_int           ciu_div;
        u_int           flags;
+       uint32_t        intr_cardmask;
 };
 
 static const struct dwcmmc_fdt_config dwcmmc_rk3288_config = {
        .ciu_div = 2,
        .flags = DWC_MMC_F_USE_HOLD_REG |
                 DWC_MMC_F_DMA,
+       .intr_cardmask = __BIT(24),
 };
 
 static const struct of_compat_data compat_data[] = {
@@ -156,6 +158,7 @@
                sc->sc_bus_width = 4;
 
        sc->sc_fifo_depth = fifo_depth;
+       sc->sc_intr_cardmask = esc->sc_conf->intr_cardmask;
        sc->sc_ciu_div = esc->sc_conf->ciu_div;
        sc->sc_flags = esc->sc_conf->flags;
        sc->sc_pre_power_on = dwcmmc_fdt_pre_power_on;
diff -r c9947de56959 -r 717810312d89 sys/dev/ic/bwfm.c
--- a/sys/dev/ic/bwfm.c Thu Feb 20 14:54:22 2020 +0000
+++ b/sys/dev/ic/bwfm.c Tue Feb 25 18:40:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.14 2018/09/02 19:46:53 maya Exp $ */
+/* $NetBSD: bwfm.c,v 1.14.6.1 2020/02/25 18:40:43 martin Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -112,9 +112,11 @@
 struct ieee80211_channel *bwfm_bss2chan(struct bwfm_softc *, struct bwfm_bss_info *);
 void    bwfm_scan(struct bwfm_softc *);
 void    bwfm_connect(struct bwfm_softc *);
+void    bwfm_get_sta_info(struct bwfm_softc *, struct ifmediareq *);
 
 void    bwfm_rx(struct bwfm_softc *, struct mbuf *);
-void    bwfm_rx_event(struct bwfm_softc *, char *, size_t);
+void    bwfm_rx_event(struct bwfm_softc *, struct mbuf *);
+void    bwfm_rx_event_cb(struct bwfm_softc *, struct mbuf *);
 void    bwfm_scan_node(struct bwfm_softc *, struct bwfm_bss_info *, size_t);
 
 uint8_t bwfm_2ghz_channels[] = {
@@ -304,9 +306,6 @@
        /* TODO: return if no link? */
 
        for (;;) {
-               struct ieee80211_node *ni;
-               struct ether_header *eh;
-
                /* Discard management packets (fw handles this for us) */
                IF_DEQUEUE(&ic->ic_mgtq, m);
                if (m != NULL) {
@@ -323,36 +322,19 @@
                if (m == NULL)
                        break;
 
-               eh = mtod(m, struct ether_header *);
-               ni = ieee80211_find_txnode(ic, eh->ether_dhost);
-               if (ni == NULL) {
-                       ifp->if_oerrors++;
-                       m_freem(m);
-                       continue;
-               }
-
-               if (ieee80211_classify(ic, m, ni) != 0) {
-                       ifp->if_oerrors++;
-                       m_freem(m);
-                       ieee80211_free_node(ni);
-                       continue;
-               }
-
                error = sc->sc_bus_ops->bs_txdata(sc, &m);
                if (error == ENOBUFS) {
                        IF_PREPEND(&ifp->if_snd, m);
                        ifp->if_flags |= IFF_OACTIVE;
                        break;
                }
-
                if (error != 0) {
                        ifp->if_oerrors++;
                        m_freem(m);
-                       if (ni != NULL)
-                               ieee80211_free_node(ni);
-               } else {
-                       bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
+                       continue;
                }
+
+               bpf_mtap(ifp, m, BPF_D_OUT);
        }
 }
 
@@ -363,6 +345,7 @@
        struct ieee80211com *ic = &sc->sc_ic;
        uint8_t evmask[BWFM_EVENT_MASK_LEN];
        struct bwfm_join_pref_params join_pref[2];
+       int pm;
 
        if (bwfm_fwvar_var_set_int(sc, "mpc", 1)) {
                printf("%s: could not set mpc\n", DEVNAME(sc));
@@ -388,10 +371,31 @@
 
 #define        ENABLE_EVENT(e)         evmask[(e) / 8] |= 1 << ((e) % 8)
        /* Events used to drive the state machine */
-       ENABLE_EVENT(BWFM_E_ASSOC);
-       ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
-       ENABLE_EVENT(BWFM_E_SET_SSID);
-       ENABLE_EVENT(BWFM_E_LINK);
+       switch (ic->ic_opmode) {
+       case IEEE80211_M_STA:
+               ENABLE_EVENT(BWFM_E_IF);
+               ENABLE_EVENT(BWFM_E_LINK);
+               ENABLE_EVENT(BWFM_E_AUTH);
+               ENABLE_EVENT(BWFM_E_ASSOC);
+               ENABLE_EVENT(BWFM_E_DEAUTH);
+               ENABLE_EVENT(BWFM_E_DISASSOC);
+               ENABLE_EVENT(BWFM_E_SET_SSID);
+               ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
+               break;
+#ifndef IEEE80211_STA_ONLY
+       case IEEE80211_M_HOSTAP:
+               ENABLE_EVENT(BWFM_E_AUTH_IND);
+               ENABLE_EVENT(BWFM_E_ASSOC_IND);
+               ENABLE_EVENT(BWFM_E_REASSOC_IND);
+               ENABLE_EVENT(BWFM_E_DEAUTH_IND);
+               ENABLE_EVENT(BWFM_E_DISASSOC_IND);
+               ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
+               ENABLE_EVENT(BWFM_E_ESCAN_RESULT);
+               break;
+#endif
+       default:
+               break;
+       }
 #undef ENABLE_EVENT
 
 #ifdef BWFM_DEBUG
@@ -419,7 +423,16 @@
                return EIO;
        }
 
-       if (bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, 2)) {
+        /*
+         * Use CAM (constantly awake) when we are running as AP
+         * otherwise use fast power saving.
+         */
+       pm = BWFM_PM_FAST_PS;
+#ifndef IEEE80211_STA_ONLY
+       if (ic->ic_opmode == IEEE80211_M_HOSTAP)
+               pm = BWFM_PM_CAM;
+#endif
+       if (bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, pm)) {
                printf("%s: could not set power\n", DEVNAME(sc));
                return EIO;
        }
@@ -466,15 +479,25 @@
 {
        struct bwfm_softc *sc = ifp->if_softc;
        struct ieee80211com *ic = &sc->sc_ic;
+       struct bwfm_join_params join;
 
        sc->sc_tx_timer = 0;
        ifp->if_timer = 0;
        ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
 
+       memset(&join, 0, sizeof(join));
+       bwfm_fwvar_cmd_set_data(sc, BWFM_C_SET_SSID, &join, sizeof(join));
        bwfm_fwvar_cmd_set_int(sc, BWFM_C_DOWN, 1);
        bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, 0);
+       bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_AP, 0);
+       bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_INFRA, 0);
+       bwfm_fwvar_cmd_set_int(sc, BWFM_C_UP, 1);
+       bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, BWFM_PM_FAST_PS);
 
        ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
+
+       if (sc->sc_bus_ops->bs_stop)
+               sc->sc_bus_ops->bs_stop(sc);
 }
 
 void
@@ -531,6 +554,12 @@
                }
                break;
 
+       case SIOCGIFMEDIA:
+               error = ieee80211_ioctl(ic, cmd, data);
+               if (error == 0 && ic->ic_state == IEEE80211_S_RUN)
+                       bwfm_get_sta_info(sc, (struct ifmediareq *)data);
+               break;
+
        default:
                error = ieee80211_ioctl(ic, cmd, data);
        }
@@ -618,7 +647,7 @@
        wsec_key.len = htole32(wk->wk_keylen);
        memcpy(wsec_key.data, wk->wk_key, sizeof(wsec_key.data));
        if (!ext_key)
-               wsec_key.flags = htole32(BWFM_PRIMARY_KEY);
+               wsec_key.flags = htole32(BWFM_WSEC_PRIMARY_KEY);
 
        switch (wk->wk_cipher->ic_cipher) {
        case IEEE80211_CIPHER_WEP:
@@ -682,7 +711,7 @@
 
        memset(&wsec_key, 0, sizeof(wsec_key));
        wsec_key.index = htole32(wk->wk_keyix);
-       wsec_key.flags = htole32(BWFM_PRIMARY_KEY);
+       wsec_key.flags = htole32(BWFM_WSEC_PRIMARY_KEY);
 
        if (bwfm_fwvar_var_set_data(sc, "wsec_key", &wsec_key, sizeof(wsec_key)))
                return;
@@ -770,6 +799,9 @@
        case BWFM_TASK_KEY_DELETE:
                bwfm_key_delete_cb(sc, &t->t_key);
                break;
+       case BWFM_TASK_RX_EVENT:
+               bwfm_rx_event_cb(sc, t->t_mbuf);
+               break;
        default:
                panic("bwfm: unknown task command %d", t->t_cmd);
        }
@@ -1261,6 +1293,52 @@
        }
 }
 
+int
+bwfm_chip_sr_capable(struct bwfm_softc *sc)
+{
+       struct bwfm_core *core;
+       uint32_t reg;
+
+       if (sc->sc_chip.ch_pmurev < 17)
+               return 0;
+
+       switch (sc->sc_chip.ch_chip) {
+       case BRCM_CC_4345_CHIP_ID:
+       case BRCM_CC_4354_CHIP_ID:
+       case BRCM_CC_4356_CHIP_ID:
+               core = bwfm_chip_get_pmu(sc);
+               sc->sc_buscore_ops->bc_write(sc, core->co_base +
+                   BWFM_CHIP_REG_CHIPCONTROL_ADDR, 3);
+               reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+                   BWFM_CHIP_REG_CHIPCONTROL_DATA);
+               return (reg & (1 << 2)) != 0;
+       case BRCM_CC_43241_CHIP_ID:
+       case BRCM_CC_4335_CHIP_ID:
+       case BRCM_CC_4339_CHIP_ID:
+               core = bwfm_chip_get_pmu(sc);
+               sc->sc_buscore_ops->bc_write(sc, core->co_base +
+                   BWFM_CHIP_REG_CHIPCONTROL_ADDR, 3);
+               reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+                   BWFM_CHIP_REG_CHIPCONTROL_DATA);
+               return reg != 0;
+       case BRCM_CC_43430_CHIP_ID:
+               core = bwfm_chip_get_core(sc, BWFM_AGENT_CORE_CHIPCOMMON);
+               reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+                   BWFM_CHIP_REG_SR_CONTROL1);
+               return reg != 0;
+       default:
+               core = bwfm_chip_get_pmu(sc);
+               reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+                   BWFM_CHIP_REG_PMUCAPABILITIES_EXT);
+               if ((reg & BWFM_CHIP_REG_PMUCAPABILITIES_SR_SUPP) == 0)
+                       return 0;
+               reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+                   BWFM_CHIP_REG_RETENTION_CTL);
+               return (reg & (BWFM_CHIP_REG_RETENTION_CTL_MACPHY_DIS |
+                              BWFM_CHIP_REG_RETENTION_CTL_LOGIC_DIS)) == 0;
+       }
+}
+
 /* RAM size helpers */
 void
 bwfm_chip_socram_ramsize(struct bwfm_softc *sc, struct bwfm_core *core)
@@ -1415,10 +1493,10 @@
 {
        struct bwfm_proto_bcdc_dcmd *dcmd;
        size_t size = sizeof(dcmd->hdr) + *len;
-       static int reqid = 0;



Home | Main Index | Thread Index | Old Index