Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev More code from OpenBSD
details: https://anonhg.NetBSD.org/src/rev/6453b989522b
branches: trunk
changeset: 464885:6453b989522b
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Mon Oct 28 06:37:51 2019 +0000
description:
More code from OpenBSD
no need to splnet() when enqueing packets
explicit structure padding
make internal functions static
also prepare for GPIO interrupts.
diffstat:
sys/dev/ic/bwfm.c | 77 ++++-
sys/dev/ic/bwfmreg.h | 21 +-
sys/dev/ic/bwfmvar.h | 4 +-
sys/dev/sdmmc/if_bwfm_sdio.c | 496 ++++++++++++++++++++++++++++++------------
4 files changed, 430 insertions(+), 168 deletions(-)
diffs (truncated from 1377 to 300 lines):
diff -r d7d509f189b5 -r 6453b989522b sys/dev/ic/bwfm.c
--- a/sys/dev/ic/bwfm.c Mon Oct 28 06:32:10 2019 +0000
+++ b/sys/dev/ic/bwfm.c Mon Oct 28 06:37:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.17 2019/10/03 14:42:20 jmcneill Exp $ */
+/* $NetBSD: bwfm.c,v 1.18 2019/10/28 06:37:51 mlelstv Exp $ */
/* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
@@ -345,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));
@@ -370,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
@@ -401,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;
}
@@ -448,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
@@ -606,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:
@@ -670,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;
@@ -1452,10 +1493,10 @@
{
struct bwfm_proto_bcdc_dcmd *dcmd;
size_t size = sizeof(dcmd->hdr) + *len;
- static int reqid = 0;
+ int reqid;
int ret = 1;
- reqid++;
+ reqid = sc->sc_bcdc_reqid++;
dcmd = kmem_zalloc(sizeof(*dcmd), KM_SLEEP);
if (*len > sizeof(dcmd->buf))
@@ -1512,10 +1553,9 @@
{
struct bwfm_proto_bcdc_dcmd *dcmd;
size_t size = sizeof(dcmd->hdr) + len;
- int reqid = 0;
- int ret = 1;
+ int ret = 1, reqid;
- reqid++;
+ reqid = sc->sc_bcdc_reqid++;
dcmd = kmem_zalloc(sizeof(*dcmd), KM_SLEEP);
if (len > sizeof(dcmd->buf))
@@ -1845,7 +1885,6 @@
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = ic->ic_ifp;
struct bwfm_event *e = mtod(m, struct bwfm_event *);
- int s;
if (m->m_len >= sizeof(e->ehdr) &&
ntohs(e->ehdr.ether_type) == BWFM_ETHERTYPE_LINK_CTL &&
@@ -1856,14 +1895,8 @@
return;
}
- s = splnet();
-
- //if ((ifp->if_flags & IFF_RUNNING) != 0) {
- m_set_rcvif(m, ifp);
- if_percpuq_enqueue(ifp->if_percpuq, m);
- //}
-
- splx(s);
+ m_set_rcvif(m, ifp);
+ if_percpuq_enqueue(ifp->if_percpuq, m);
}
void
diff -r d7d509f189b5 -r 6453b989522b sys/dev/ic/bwfmreg.h
--- a/sys/dev/ic/bwfmreg.h Mon Oct 28 06:32:10 2019 +0000
+++ b/sys/dev/ic/bwfmreg.h Mon Oct 28 06:37:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfmreg.h,v 1.5 2019/10/03 14:42:20 jmcneill Exp $ */
+/* $NetBSD: bwfmreg.h,v 1.6 2019/10/28 06:37:51 mlelstv Exp $ */
/* $OpenBSD: bwfmreg.h,v 1.16 2018/02/07 21:44:09 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
@@ -372,21 +372,26 @@
uint16_t capability;
uint8_t ssid_len;
uint8_t ssid[BWFM_MAX_SSID_LEN];
+ uint8_t pad0;
uint32_t nrates;
uint8_t rates[16];
uint16_t chanspec;
uint16_t atim_window;
uint8_t dtim_period;
+ uint8_t pad1;
uint16_t rssi;
uint8_t phy_noise;
uint8_t n_cap;
+ uint16_t pad2;
uint32_t nbss_cap;
uint8_t ctl_ch;
+ uint8_t pad3[3];
uint32_t reserved32[1];
uint8_t flags;
uint8_t reserved[3];
uint8_t basic_mcs[BWFM_MCSSET_LEN];
uint16_t ie_offset;
+ uint16_t pad4;
uint32_t ie_length;
uint16_t snr;
};
@@ -572,6 +577,7 @@
struct bwfm_assoc_params {
uint8_t bssid[ETHER_ADDR_LEN];
+ uint16_t pad;
uint32_t chanspec_num;
uint16_t chanspec_list[];
};
@@ -599,6 +605,7 @@
struct bwfm_join_scan_params {
uint8_t scan_type;
+ uint8_t pad[3];
uint32_t nprobes;
uint32_t active_time;
uint32_t passive_time;
@@ -633,15 +640,18 @@
#define BWFM_CRYPTO_ALGO_AES_RESERVED1 5
#define BWFM_CRYPTO_ALGO_AES_RESERVED2 6
uint32_t flags;
-#define BWFM_PRIMARY_KEY (1 << 1)
+#define BWFM_WSEC_PRIMARY_KEY (1 << 1)
+#define BWFM_PRIMARY_KEY BWFM_WSEC_PRIMARY_KEY
uint32_t pad_2[3];
uint32_t iv_initialized;
uint32_t pad_3;
+ /* Rx IV */
struct {
uint32_t hi;
uint16_t lo;
+ uint16_t pad_4;
} rxiv;
- uint32_t pad_4[2];
+ uint32_t pad_5[2];
uint8_t ea[IEEE80211_ADDR_LEN];
};
@@ -753,7 +763,7 @@
#define BWFM_BRCM_OUI "\x00\x10\x18"
uint16_t usr_subtype;
#define BWFM_BRCM_SUBTYPE_EVENT 1
-};
+} __packed;
struct bwfm_event_msg {
uint16_t version;
@@ -767,7 +777,7 @@
char ifname[IFNAMSIZ];
uint8_t ifidx;
uint8_t bsscfgidx;
-};
+} __packed;
struct bwfm_event {
struct ether_header ehdr;
@@ -775,4 +785,3 @@
struct bwfm_ethhdr hdr;
struct bwfm_event_msg msg;
} __packed;
-
diff -r d7d509f189b5 -r 6453b989522b sys/dev/ic/bwfmvar.h
--- a/sys/dev/ic/bwfmvar.h Mon Oct 28 06:32:10 2019 +0000
+++ b/sys/dev/ic/bwfmvar.h Mon Oct 28 06:37:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfmvar.h,v 1.4 2019/09/01 05:40:39 mlelstv Exp $ */
+/* $NetBSD: bwfmvar.h,v 1.5 2019/10/28 06:37:51 mlelstv Exp $ */
/* $OpenBSD: bwfmvar.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
@@ -169,6 +169,8 @@
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
+
+ int sc_bcdc_reqid;
};
void bwfm_attach(struct bwfm_softc *);
diff -r d7d509f189b5 -r 6453b989522b sys/dev/sdmmc/if_bwfm_sdio.c
--- a/sys/dev/sdmmc/if_bwfm_sdio.c Mon Oct 28 06:32:10 2019 +0000
+++ b/sys/dev/sdmmc/if_bwfm_sdio.c Mon Oct 28 06:37:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.8 2019/10/28 06:20:01 mlelstv Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.9 2019/10/28 06:37:52 mlelstv Exp $ */
/* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
@@ -36,6 +36,9 @@
#include <netinet/in.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/fdt/fdtvar.h>
+
#include <dev/firmload.h>
#include <net80211/ieee80211_var.h>
@@ -80,6 +83,7 @@
Home |
Main Index |
Thread Index |
Old Index