3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
31 * FORE Systems 200-Series Adapter Support
32 * ---------------------------------------
34 * Network interface layer support
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/socket.h>
41 #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_ioctl.h>
51 #include <netatm/atm_stack.h>
52 #include <netatm/atm_pcb.h>
53 #include <netatm/atm_var.h>
54 #include <dev/pci/pcivar.h>
55 #include <dev/hfa/fore.h>
56 #include <dev/hfa/fore_aali.h>
57 #include <dev/hfa/fore_slave.h>
58 #include <dev/hfa/fore_stats.h>
59 #include <dev/hfa/fore_var.h>
60 #include <dev/hfa/fore_include.h>
63 __RCSID("@(#) $FreeBSD$");
68 * Handle netatm core service interface ioctl requests
73 * code ioctl function (sub)code
74 * data data to/from ioctl
75 * arg optional code-specific argument
78 * 0 request processed successfully
79 * error request failed - reason code
82 fore_atm_ioctl(code, data, arg)
87 struct atminfreq *aip = (struct atminfreq *)data;
90 caddr_t buf = aip->air_buf_addr;
91 struct air_vinfo_rsp *avr;
94 size_t buf_len = aip->air_buf_len;
96 char ifname[2*IFNAMSIZ];
99 ATM_DEBUG2("fore_atm_ioctl: code=%d, opcode=%d\n",
100 code, aip->air_opcode);
102 switch ( aip->air_opcode ) {
106 * Get vendor statistics
108 pip = (struct atm_pif *)arg;
109 fup = (Fore_unit *)pip;
112 snprintf ( ifname, sizeof(ifname),
113 "%s%d", pip->pif_name, pip->pif_unit );
116 * Cast response structure onto user's buffer
118 avr = (struct air_vinfo_rsp *)buf;
121 * How large is the response structure?
123 len = sizeof(struct air_vinfo_rsp);
126 * Sanity check - enough room for response structure?
132 * Copy interface name into response structure
134 if ((err = copyout ( ifname, avr->avsp_intf, IFNAMSIZ)) != 0)
138 * Advance the buffer address and decrement the size
144 * Get the vendor stats from the hardware
147 if ( ( err = fore_get_stats ( fup ) ) == 0 )
150 * Stick as much of it as we have room for
153 count = min ( sizeof(Fore_stats), buf_len );
156 * Copy stats into user's buffer. Return value is
157 * amount of data copied.
159 if ((err = copyout((caddr_t)fup->fu_stats, buf, count)) != 0)
163 if ( count < sizeof(Fore_stats) )
168 * Record amount we're returning as vendor info...
170 if ((err = copyout(&count, &avr->avsp_len, sizeof(count))) != 0)
174 * Update the reply pointers and lengths
176 aip->air_buf_addr = buf;
177 aip->air_buf_len = buf_len;
181 err = ENOSYS; /* Operation not supported */
190 * Free Fore-specific device resources
192 * Frees all dynamically acquired resources for a device unit. Before
193 * this function is called, the CP will have been reset and our interrupt
197 * fup pointer to device unit structure
204 fore_interface_free(fup)
209 * Free up all of our allocated memory
217 * Clear device initialized
219 if (fup->fu_flags & CUF_INITED) {
220 fup->fu_flags &= ~CUF_INITED;
223 if (fup->fu_flags & FUF_STATCMD) {
224 fup->fu_flags &= ~FUF_STATCMD;