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 $
27 * @(#) $DragonFly: src/sys/dev/atm/hfa/fore_if.c,v 1.3 2003/08/07 21:16:49 dillon Exp $
31 * FORE Systems 200-Series Adapter Support
32 * ---------------------------------------
34 * Network interface layer support
38 #include "fore_include.h"
41 * Handle netatm core service interface ioctl requests
46 * code ioctl function (sub)code
47 * data data to/from ioctl
48 * arg optional code-specific argument
51 * 0 request processed successfully
52 * error request failed - reason code
55 fore_atm_ioctl(code, data, arg)
60 struct atminfreq *aip = (struct atminfreq *)data;
63 caddr_t buf = aip->air_buf_addr;
64 struct air_vinfo_rsp *avr;
65 int count, len, buf_len = aip->air_buf_len;
67 char ifname[2*IFNAMSIZ];
70 ATM_DEBUG2("fore_atm_ioctl: code=%d, opcode=%d\n",
71 code, aip->air_opcode);
73 switch ( aip->air_opcode ) {
77 * Get vendor statistics
79 pip = (struct atm_pif *)arg;
80 fup = (Fore_unit *)pip;
83 snprintf ( ifname, sizeof(ifname),
84 "%s%d", pip->pif_name, pip->pif_unit );
87 * Cast response structure onto user's buffer
89 avr = (struct air_vinfo_rsp *)buf;
92 * How large is the response structure?
94 len = sizeof(struct air_vinfo_rsp);
97 * Sanity check - enough room for response structure?
103 * Copy interface name into response structure
105 if ((err = copyout ( ifname, avr->avsp_intf, IFNAMSIZ)) != 0)
109 * Advance the buffer address and decrement the size
115 * Get the vendor stats from the hardware
118 if ( ( err = fore_get_stats ( fup ) ) == 0 )
121 * Stick as much of it as we have room for
124 count = min ( sizeof(Fore_stats), buf_len );
127 * Copy stats into user's buffer. Return value is
128 * amount of data copied.
130 if ((err = copyout((caddr_t)fup->fu_stats, buf, count)) != 0)
134 if ( count < sizeof(Fore_stats) )
139 * Record amount we're returning as vendor info...
141 if ((err = copyout(&count, &avr->avsp_len, sizeof(int))) != 0)
145 * Update the reply pointers and lengths
147 aip->air_buf_addr = buf;
148 aip->air_buf_len = buf_len;
152 err = ENOSYS; /* Operation not supported */
161 * Free Fore-specific device resources
163 * Frees all dynamically acquired resources for a device unit. Before
164 * this function is called, the CP will have been reset and our interrupt
168 * fup pointer to device unit structure
175 fore_interface_free(fup)
180 * Free up all of our allocated memory
188 * Clear device initialized
190 if (fup->fu_flags & CUF_INITED) {
191 fup->fu_flags &= ~CUF_INITED;
194 if (fup->fu_flags & FUF_STATCMD) {
195 DMA_FREE_ADDR(fup->fu_stats, fup->fu_statsd,
196 sizeof(Fore_cp_stats), 0);
197 fup->fu_flags &= ~FUF_STATCMD;