summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2018-01-03 21:01:17 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2018-01-03 21:01:17 +0000
commit050dc7bf0f38acd812e081a11a1a0ba12e8a5dae (patch)
tree4329d03cdd13713e891fcafe4ad2cf0040b4989f /sys/dev/ic
parentf40c19909df2a3e78ff4a8cdd95f6250cc6d3789 (diff)
Since the PCI attachment code already uses mbufs for RX packets, we can
push the mbuf allocation down into the USB attachment code and now pass an mbuf to the bwfm(4) receive function.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/bwfm.c32
-rw-r--r--sys/dev/ic/bwfmvar.h4
2 files changed, 9 insertions, 27 deletions
diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c
index 1756315bced..c610fd5f8f1 100644
--- a/sys/dev/ic/bwfm.c
+++ b/sys/dev/ic/bwfm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwfm.c,v 1.23 2017/12/26 00:51:29 patrick Exp $ */
+/* $OpenBSD: bwfm.c,v 1.24 2018/01/03 21:01:16 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
@@ -118,7 +118,7 @@ void bwfm_set_key_cb(struct bwfm_softc *, void *);
void bwfm_delete_key_cb(struct bwfm_softc *, void *);
void bwfm_newstate_cb(struct bwfm_softc *, void *);
-void bwfm_rx(struct bwfm_softc *, char *, size_t);
+void bwfm_rx(struct bwfm_softc *, struct mbuf *);
void bwfm_rx_event(struct bwfm_softc *, char *, size_t);
void bwfm_scan_node(struct bwfm_softc *, struct bwfm_bss_info *, size_t);
@@ -1399,39 +1399,21 @@ bwfm_scan(struct bwfm_softc *sc)
}
void
-bwfm_rx(struct bwfm_softc *sc, char *buf, size_t len)
+bwfm_rx(struct bwfm_softc *sc, struct mbuf *m)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &ic->ic_if;
- struct bwfm_event *e = (void *)buf;
+ struct bwfm_event *e = mtod(m, struct bwfm_event *);
struct mbuf_list ml = MBUF_LIST_INITIALIZER();
- struct mbuf *m;
- char *mb;
- if (len >= sizeof(e->ehdr) &&
+ if (m->m_len >= sizeof(e->ehdr) &&
ntohs(e->ehdr.ether_type) == BWFM_ETHERTYPE_LINK_CTL &&
memcmp(BWFM_BRCM_OUI, e->hdr.oui, sizeof(e->hdr.oui)) == 0 &&
ntohs(e->hdr.usr_subtype) == BWFM_BRCM_SUBTYPE_EVENT)
- bwfm_rx_event(sc, buf, len);
-
- if (__predict_false(len > MCLBYTES))
- return;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (__predict_false(m == NULL))
- return;
- if (len > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if (!(m->m_flags & M_EXT)) {
- m_free(m);
- return;
- }
- }
- mb = mtod(m, char *);
- memcpy(mb, buf, len);
- m->m_pkthdr.len = m->m_len = len;
+ bwfm_rx_event(sc, mtod(m, char *), m->m_len);
if ((ic->ic_flags & IEEE80211_F_RSNON) &&
- len >= sizeof(e->ehdr) &&
+ m->m_len >= sizeof(e->ehdr) &&
ntohs(e->ehdr.ether_type) == ETHERTYPE_PAE) {
ifp->if_ipackets++;
#if NBPFILTER > 0
diff --git a/sys/dev/ic/bwfmvar.h b/sys/dev/ic/bwfmvar.h
index b2fd4126406..d924cab70ba 100644
--- a/sys/dev/ic/bwfmvar.h
+++ b/sys/dev/ic/bwfmvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwfmvar.h,v 1.5 2017/12/16 23:39:58 patrick Exp $ */
+/* $OpenBSD: bwfmvar.h,v 1.6 2018/01/03 21:01:16 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
@@ -160,4 +160,4 @@ int bwfm_chip_set_active(struct bwfm_softc *, uint32_t);
void bwfm_chip_set_passive(struct bwfm_softc *);
struct bwfm_core *bwfm_chip_get_core(struct bwfm_softc *, int);
struct bwfm_core *bwfm_chip_get_pmu(struct bwfm_softc *);
-void bwfm_rx(struct bwfm_softc *, char *, size_t);
+void bwfm_rx(struct bwfm_softc *, struct mbuf *);