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.
26 * @(#) $FreeBSD: src/sys/dev/hfa/fore_if.c,v 1.5 1999/08/28 00:41:49 peter Exp $
31 * FORE Systems 200-Series Adapter Support
32 * ---------------------------------------
34 * Network interface layer support
38 #include <dev/hfa/fore_include.h>
41 __RCSID("@(#) $FreeBSD: src/sys/dev/hfa/fore_if.c,v 1.5 1999/08/28 00:41:49 peter Exp $");
46 * Handle netatm core service interface ioctl requests
51 * code ioctl function (sub)code
52 * data data to/from ioctl
53 * arg optional code-specific argument
56 * 0 request processed successfully
57 * error request failed - reason code
60 fore_atm_ioctl(code, data, arg)
65 struct atminfreq *aip = (struct atminfreq *)data;
68 caddr_t buf = aip->air_buf_addr;
69 struct air_vinfo_rsp *avr;
70 int count, len, buf_len = aip->air_buf_len;
72 char ifname[2*IFNAMSIZ];
75 ATM_DEBUG2("fore_atm_ioctl: code=%d, opcode=%d\n",
76 code, aip->air_opcode);
78 switch ( aip->air_opcode ) {
82 * Get vendor statistics
84 pip = (struct atm_pif *)arg;
85 fup = (Fore_unit *)pip;
88 snprintf ( ifname, sizeof(ifname),
89 "%s%d", pip->pif_name, pip->pif_unit );
92 * Cast response structure onto user's buffer
94 avr = (struct air_vinfo_rsp *)buf;
97 * How large is the response structure?
99 len = sizeof(struct air_vinfo_rsp);
102 * Sanity check - enough room for response structure?
108 * Copy interface name into response structure
110 if ((err = copyout ( ifname, avr->avsp_intf, IFNAMSIZ)) != 0)
114 * Advance the buffer address and decrement the size
120 * Get the vendor stats from the hardware
123 if ( ( err = fore_get_stats ( fup ) ) == 0 )
126 * Stick as much of it as we have room for
129 count = min ( sizeof(Fore_stats), buf_len );
132 * Copy stats into user's buffer. Return value is
133 * amount of data copied.
135 if ((err = copyout((caddr_t)fup->fu_stats, buf, count)) != 0)
139 if ( count < sizeof(Fore_stats) )
144 * Record amount we're returning as vendor info...
146 if ((err = copyout(&count, &avr->avsp_len, sizeof(int))) != 0)
150 * Update the reply pointers and lengths
152 aip->air_buf_addr = buf;
153 aip->air_buf_len = buf_len;
157 err = ENOSYS; /* Operation not supported */
166 * Free Fore-specific device resources
168 * Frees all dynamically acquired resources for a device unit. Before
169 * this function is called, the CP will have been reset and our interrupt
173 * fup pointer to device unit structure
180 fore_interface_free(fup)
185 * Free up all of our allocated memory
193 * Clear device initialized
195 if (fup->fu_flags & CUF_INITED) {
196 fup->fu_flags &= ~CUF_INITED;
199 if (fup->fu_flags & FUF_STATCMD) {
200 DMA_FREE_ADDR(fup->fu_stats, fup->fu_statsd,
201 sizeof(Fore_cp_stats), 0);
202 fup->fu_flags &= ~FUF_STATCMD;