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