2 * ===================================
3 * HARP | Host ATM Research Platform
4 * ===================================
6 * This Host ATM Research Platform ("HARP") file (the "Software") is
7 * made available by Network Computing Services, Inc. ("NetworkCS")
8 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
12 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
14 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
15 * In no event shall NetworkCS be responsible for any damages, including
16 * but not limited to consequential damages, arising from or relating to
17 * any use of the Software or related support.
19 * Copyright 1994-1998 Network Computing Services, Inc.
21 * Copies of this Software may be made, however, the above copyright
22 * notice must be reproduced on all copies.
25 #include <sys/cdefs.h>
26 __FBSDID("$FreeBSD$");
29 * FORE Systems 200-Series Adapter Support
30 * ---------------------------------------
32 * Device statistics routines
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/socket.h>
39 #include <sys/socketvar.h>
43 #include <netatm/port.h>
44 #include <netatm/queue.h>
45 #include <netatm/atm.h>
46 #include <netatm/atm_sys.h>
47 #include <netatm/atm_sap.h>
48 #include <netatm/atm_cm.h>
49 #include <netatm/atm_if.h>
50 #include <netatm/atm_stack.h>
51 #include <netatm/atm_pcb.h>
52 #include <netatm/atm_var.h>
53 #include <dev/pci/pcivar.h>
54 #include <dev/hfa/fore.h>
55 #include <dev/hfa/fore_aali.h>
56 #include <dev/hfa/fore_slave.h>
57 #include <dev/hfa/fore_stats.h>
58 #include <dev/hfa/fore_var.h>
59 #include <dev/hfa/fore_include.h>
62 __RCSID("@(#) $FreeBSD$");
67 * Get device statistics from CP
69 * This function will issue a GET_STATS command to the CP in order to
70 * initiate the DMA transfer of the CP's statistics structure to the host.
71 * We will then sleep pending command completion. This must only be called
72 * from the ioctl system call handler.
77 * fup pointer to device unit structure
80 * 0 stats retrieval successful
81 * errno stats retrieval failed - reason indicated
92 ATM_DEBUG1("fore_get_stats: fup=%p\n", fup);
95 * Make sure device has been initialized
97 if ((fup->fu_flags & CUF_INITED) == 0) {
102 * If someone has already initiated a stats request, we'll
103 * just wait for that one to complete
106 if (fup->fu_flags & FUF_STATCMD) {
108 #if (defined(BSD) && (BSD >= 199103))
109 sst = tsleep((caddr_t)&fup->fu_stats, PWAIT|PCATCH, "fore", 0);
111 sst = sleep((caddr_t)&fup->fu_stats, PWAIT|PCATCH);
116 return (sst ? sst : fup->fu_stats_ret);
120 * Limit stats gathering to once a second or so
122 if (time_second == fup->fu_stats_time) {
126 fup->fu_stats_time = time_second;
129 * Queue command at end of command queue
131 hcp = fup->fu_cmd_tail;
132 if ((*hcp->hcq_status) & QSTAT_FREE) {
136 * Queue entry available, so set our view of things up
138 hcp->hcq_code = CMD_GET_STATS;
140 fup->fu_cmd_tail = hcp->hcq_next;
143 * Now set the CP-resident queue entry - the CP will grab
144 * the command when the op-code is set.
146 cqp = hcp->hcq_cpelem;
147 (*hcp->hcq_status) = QSTAT_PENDING;
149 dma = vtophys(fup->fu_stats);
151 fup->fu_stats->st_drv.drv_cm_nodma++;
155 fup->fu_statsd = dma;
156 cqp->cmdq_stats.stats_buffer = (CP_dma) CP_WRITE(dma);
158 fup->fu_flags |= FUF_STATCMD;
159 cqp->cmdq_stats.stats_cmd =
160 CP_WRITE(CMD_GET_STATS | CMD_INTR_REQ);
163 * Now wait for command to finish
165 #if (defined(BSD) && (BSD >= 199103))
166 sst = tsleep((caddr_t)&fup->fu_stats, PWAIT|PCATCH, "fore", 0);
168 sst = sleep((caddr_t)&fup->fu_stats, PWAIT|PCATCH);
173 return (sst ? sst : fup->fu_stats_ret);
179 fup->fu_stats->st_drv.drv_cm_full++;