function so it can be shared with the SDIO attachment driver.
-/* $OpenBSD: bwfm.c,v 1.37 2018/02/07 21:36:34 patrick Exp $ */
+/* $OpenBSD: bwfm.c,v 1.38 2018/02/07 22:01:04 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
int, char *, size_t *);
int bwfm_proto_bcdc_set_dcmd(struct bwfm_softc *, int,
int, char *, size_t);
+void bwfm_proto_bcdc_rx(struct bwfm_softc *, struct mbuf *);
int bwfm_fwvar_cmd_get_data(struct bwfm_softc *, int, void *, size_t);
int bwfm_fwvar_cmd_set_data(struct bwfm_softc *, int, void *, size_t);
struct bwfm_proto_ops bwfm_proto_bcdc_ops = {
.proto_query_dcmd = bwfm_proto_bcdc_query_dcmd,
.proto_set_dcmd = bwfm_proto_bcdc_set_dcmd,
+ .proto_rx = bwfm_proto_bcdc_rx,
};
struct cfdriver bwfm_cd = {
return ret;
}
+void
+bwfm_proto_bcdc_rx(struct bwfm_softc *sc, struct mbuf *m)
+{
+ struct bwfm_proto_bcdc_hdr *hdr;
+
+ hdr = mtod(m, struct bwfm_proto_bcdc_hdr *);
+ if (m->m_len < sizeof(*hdr)) {
+ m_freem(m);
+ return;
+ }
+ if (m->m_len < sizeof(*hdr) + (hdr->data_offset << 2)) {
+ m_freem(m);
+ return;
+ }
+ m_adj(m, sizeof(*hdr) + (hdr->data_offset << 2));
+ bwfm_rx(sc, m);
+}
+
/* FW Variable code */
int
bwfm_fwvar_cmd_get_data(struct bwfm_softc *sc, int cmd, void *data, size_t len)
-/* $OpenBSD: bwfmvar.h,v 1.10 2018/02/07 21:36:34 patrick Exp $ */
+/* $OpenBSD: bwfmvar.h,v 1.11 2018/02/07 22:01:04 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
char *, size_t *);
int (*proto_set_dcmd)(struct bwfm_softc *, int, int,
char *, size_t);
+ void (*proto_rx)(struct bwfm_softc *, struct mbuf *);
};
extern struct bwfm_proto_ops bwfm_proto_bcdc_ops;
-/* $OpenBSD: if_bwfm_usb.c,v 1.8 2018/01/24 13:10:20 patrick Exp $ */
+/* $OpenBSD: if_bwfm_usb.c,v 1.9 2018/02/07 22:01:04 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
{
struct bwfm_usb_rx_data *data = priv;
struct bwfm_usb_softc *sc = data->sc;
- struct bwfm_proto_bcdc_hdr *hdr;
usbd_status error;
- uint32_t len, off;
struct mbuf *m;
+ uint32_t len;
DPRINTFN(2, ("%s: %s status %s\n", DEVNAME(sc), __func__,
usbd_errstr(status)));
}
usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
- hdr = (void *)data->buf;
- if (len < sizeof(*hdr))
- goto resubmit;
- len -= sizeof(*hdr);
- off += sizeof(*hdr);
- if (len < hdr->data_offset << 2)
- goto resubmit;
- len -= hdr->data_offset << 2;
- off += hdr->data_offset << 2;
-
m = bwfm_usb_newbuf();
if (m == NULL)
goto resubmit;
- memcpy(mtod(m, char *), data->buf + off, len);
+ memcpy(mtod(m, char *), data->buf, len);
m->m_len = m->m_pkthdr.len = len;
- bwfm_rx(&sc->sc_sc, m);
+ sc->sc_sc.sc_proto_ops->proto_rx(&sc->sc_sc, m);
resubmit:
usbd_setup_xfer(data->xfer, sc->sc_rx_pipeh, data, data->buf,