1 /* $OpenBSD: if_rtwn.c,v 1.6 2015/08/28 00:03:53 deraadt Exp $ */
4 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
5 * Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org>
6 * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <sys/cdefs.h>
22 __FBSDID("$FreeBSD$");
26 #include <sys/param.h>
28 #include <sys/mutex.h>
30 #include <sys/kernel.h>
31 #include <sys/socket.h>
32 #include <sys/systm.h>
33 #include <sys/malloc.h>
34 #include <sys/queue.h>
35 #include <sys/taskqueue.h>
37 #include <sys/endian.h>
38 #include <sys/linker.h>
40 #include <machine/bus.h>
41 #include <machine/resource.h>
45 #include <net/ethernet.h>
46 #include <net/if_media.h>
48 #include <net80211/ieee80211_var.h>
49 #include <net80211/ieee80211_radiotap.h>
51 #include <dev/rtwn/if_rtwnvar.h>
52 #include <dev/rtwn/if_rtwn_debug.h>
54 #include <dev/rtwn/pci/rtwn_pci_var.h>
56 #include <dev/rtwn/rtl8192c/pci/r92ce.h>
57 #include <dev/rtwn/rtl8192c/pci/r92ce_tx_desc.h>
61 r92ce_setup_tx_desc(struct rtwn_pci_softc *pc, void *desc,
62 uint32_t next_desc_addr)
64 struct r92ce_tx_desc *txd = desc;
67 txd->nextdescaddr = htole32(next_desc_addr);
71 r92ce_tx_postsetup(struct rtwn_pci_softc *pc, void *desc,
72 bus_dma_segment_t segs[])
74 struct r92ce_tx_desc *txd = desc;
76 txd->txbufaddr = htole32(segs[0].ds_addr);
77 txd->txbufsize = txd->pktlen;
78 bus_space_barrier(pc->pc_st, pc->pc_sh, 0, pc->pc_mapsize,
79 BUS_SPACE_BARRIER_WRITE);
83 r92ce_copy_tx_desc(void *dest, const void *src)
85 struct r92ce_tx_desc *txd = dest;
86 size_t len = sizeof(struct r92c_tx_desc) +
87 sizeof(txd->txbufsize) + sizeof(txd->pad);
90 memcpy(dest, src, len);
96 r92ce_dump_tx_desc(struct rtwn_softc *sc, const void *desc)
99 const struct r92ce_tx_desc *txd = desc;
101 RTWN_DPRINTF(sc, RTWN_DEBUG_XMIT_DESC,
102 "%s: len %d, off %d, flags0 %02X, dw: 1 %08X, 2 %08X, 3 %04X "
103 "(seq %04X), 4 %08X, 5 %08X, 6 %08X, size %04X, pad %04X, "
104 "addr: %08X (64: %08X), next: %08X (64: %08X), "
105 "rsvd: %08X %08X %08X %08X\n",
106 __func__, le16toh(txd->pktlen), txd->offset, txd->flags0,
107 le32toh(txd->txdw1), le32toh(txd->txdw2), le16toh(txd->txdw3),
108 le16toh(txd->txdseq), le32toh(txd->txdw4), le32toh(txd->txdw5),
109 le32toh(txd->txdw6), le16toh(txd->txbufsize), le16toh(txd->pad),
110 le32toh(txd->txbufaddr), le32toh(txd->txbufaddr64),
111 le32toh(txd->nextdescaddr), le32toh(txd->nextdescaddr64),
112 le32toh(txd->reserved[0]), le32toh(txd->reserved[1]),
113 le32toh(txd->reserved[2]), le32toh(txd->reserved[3]));