source: rtems-libbsd/freebsd/sys/dev/rtwn/rtl8192c/pci/r92ce_rx.c @ 0cbb715

55-freebsd-126-freebsd-12
Last change on this file since 0cbb715 was 0cbb715, checked in by Christian Mauderer <Christian.Mauderer@…>, on 11/22/16 at 09:41:47

rtwn: Import from FreeBSD.

  • Property mode set to 100644
File size: 3.7 KB
Line 
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_reg.h>
60
61
62int
63r92ce_classify_intr(struct rtwn_softc *sc, void *arg, int len __unused)
64{
65        uint32_t status;
66        int *rings = arg;
67        int ret;
68
69        *rings = 0;
70        status = rtwn_read_4(sc, R92C_HISR);
71        RTWN_DPRINTF(sc, RTWN_DEBUG_INTR, "%s: HISR %08X, HISRE %04X\n",
72            __func__, status, rtwn_read_2(sc, R92C_HISRE));
73        if (status == 0 || status == 0xffffffff)
74                return (0);
75
76        /* Disable interrupts. */
77        rtwn_write_4(sc, R92C_HIMR, 0);
78
79        /* Ack interrupts. */
80        rtwn_write_4(sc, R92C_HISR, status);
81
82        if (status & R92C_IMR_BDOK)
83                *rings |= (1 << RTWN_PCI_BEACON_QUEUE);
84        if (status & R92C_IMR_HIGHDOK)
85                *rings |= (1 << RTWN_PCI_HIGH_QUEUE);
86        if (status & R92C_IMR_MGNTDOK)
87                *rings |= (1 << RTWN_PCI_MGNT_QUEUE);
88        if (status & R92C_IMR_BKDOK)
89                *rings |= (1 << RTWN_PCI_BK_QUEUE);
90        if (status & R92C_IMR_BEDOK)
91                *rings |= (1 << RTWN_PCI_BE_QUEUE);
92        if (status & R92C_IMR_VIDOK)
93                *rings |= (1 << RTWN_PCI_VI_QUEUE);
94        if (status & R92C_IMR_VODOK)
95                *rings |= (1 << RTWN_PCI_VO_QUEUE);
96
97        ret = 0;
98        if (status & R92C_IMR_RXFOVW)
99                ret |= RTWN_PCI_INTR_RX_OVERFLOW;
100        if (status & R92C_IMR_RDU)
101                ret |= RTWN_PCI_INTR_RX_DESC_UNAVAIL;
102        if (status & R92C_IMR_ROK)
103                ret |= RTWN_PCI_INTR_RX_DONE;
104        if (status & R92C_IMR_TXFOVW)
105                ret |= RTWN_PCI_INTR_TX_OVERFLOW;
106        if (status & R92C_IMR_PSTIMEOUT)
107                ret |= RTWN_PCI_INTR_PS_TIMEOUT;
108
109        return (ret);
110}
111
112#define R92C_INT_ENABLE (R92C_IMR_ROK | R92C_IMR_VODOK | R92C_IMR_VIDOK | \
113                        R92C_IMR_BEDOK | R92C_IMR_BKDOK | R92C_IMR_MGNTDOK | \
114                        R92C_IMR_HIGHDOK | R92C_IMR_BDOK | R92C_IMR_RDU | \
115                        R92C_IMR_RXFOVW)
116void
117r92ce_enable_intr(struct rtwn_pci_softc *pc)
118{
119        struct rtwn_softc *sc = &pc->pc_sc;
120
121        /* Enable interrupts. */
122        rtwn_write_4(sc, R92C_HIMR, R92C_INT_ENABLE);
123}
124
125void
126r92ce_start_xfers(struct rtwn_softc *sc)
127{
128        /* Clear pending interrupts. */
129        rtwn_write_4(sc, R92C_HISR, 0xffffffff);
130
131        /* Enable interrupts. */
132        rtwn_write_4(sc, R92C_HIMR, R92C_INT_ENABLE);
133}
134#undef R92C_INT_ENABLE
Note: See TracBrowser for help on using the repository browser.