The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/hfa/fore_if.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  *
    3  * ===================================
    4  * HARP  |  Host ATM Research Platform
    5  * ===================================
    6  *
    7  *
    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.
   12  *
   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.
   20  *
   21  * Copyright 1994-1998 Network Computing Services, Inc.
   22  *
   23  * Copies of this Software may be made, however, the above copyright
   24  * notice must be reproduced on all copies.
   25  *
   26  *      @(#) $FreeBSD$
   27  *
   28  */
   29 
   30 /*
   31  * FORE Systems 200-Series Adapter Support
   32  * ---------------------------------------
   33  *
   34  * Network interface layer support
   35  *
   36  */
   37 
   38 #include <sys/param.h>
   39 #include <sys/systm.h>
   40 #include <sys/socket.h>
   41 #include <sys/socketvar.h>
   42 #include <net/if.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>
   61 
   62 #ifndef lint
   63 __RCSID("@(#) $FreeBSD$");
   64 #endif
   65 
   66 
   67 /*
   68  * Handle netatm core service interface ioctl requests 
   69  *
   70  * Called at splnet.
   71  *
   72  * Arguments:
   73  *      code            ioctl function (sub)code
   74  *      data            data to/from ioctl
   75  *      arg             optional code-specific argument
   76  *
   77  * Returns:
   78  *      0               request processed successfully
   79  *      error           request failed - reason code
   80  */
   81 int
   82 fore_atm_ioctl(code, data, arg)
   83         int     code;
   84         caddr_t data;
   85         caddr_t arg;
   86 {
   87         struct atminfreq        *aip = (struct atminfreq *)data;
   88         struct atm_pif          *pip;
   89         Fore_unit               *fup;
   90         caddr_t                 buf = aip->air_buf_addr;
   91         struct air_vinfo_rsp    *avr;
   92         size_t count;
   93         size_t len;
   94         size_t buf_len = aip->air_buf_len;
   95         int                     err = 0;
   96         char                    ifname[2*IFNAMSIZ];
   97  
   98 
   99         ATM_DEBUG2("fore_atm_ioctl: code=%d, opcode=%d\n", 
  100                 code, aip->air_opcode);
  101 
  102         switch ( aip->air_opcode ) {
  103 
  104         case AIOCS_INF_VST:
  105                 /*
  106                  * Get vendor statistics
  107                  */
  108                 pip = (struct atm_pif *)arg;
  109                 fup = (Fore_unit *)pip;
  110                 if ( pip == NULL )
  111                         return ( ENXIO );
  112                 snprintf ( ifname, sizeof(ifname),
  113                     "%s%d", pip->pif_name, pip->pif_unit );
  114 
  115                 /*
  116                  * Cast response structure onto user's buffer
  117                  */
  118                 avr = (struct air_vinfo_rsp *)buf;
  119 
  120                 /*
  121                  * How large is the response structure?
  122                  */
  123                 len = sizeof(struct air_vinfo_rsp);
  124 
  125                 /*
  126                  * Sanity check - enough room for response structure?
  127                  */
  128                 if ( buf_len < len )
  129                         return ( ENOSPC );
  130 
  131                 /*
  132                  * Copy interface name into response structure
  133                  */
  134                 if ((err = copyout ( ifname, avr->avsp_intf, IFNAMSIZ)) != 0)
  135                         break;
  136 
  137                 /*
  138                  * Advance the buffer address and decrement the size
  139                  */
  140                 buf += len;
  141                 buf_len -= len;
  142 
  143                 /*
  144                  * Get the vendor stats from the hardware
  145                  */
  146                 count = 0;
  147                 if ( ( err = fore_get_stats ( fup ) ) == 0 )
  148                 {
  149                         /*
  150                          * Stick as much of it as we have room for 
  151                          * into the response
  152                          */
  153                         count = min ( sizeof(Fore_stats), buf_len );
  154 
  155                         /*
  156                          * Copy stats into user's buffer. Return value is
  157                          * amount of data copied.
  158                          */
  159                         if ((err = copyout((caddr_t)fup->fu_stats, buf, count)) != 0)
  160                                 break;
  161                         buf += count;
  162                         buf_len -= count;
  163                         if ( count < sizeof(Fore_stats) )
  164                                 err = ENOSPC;
  165                 }
  166 
  167                 /*
  168                  * Record amount we're returning as vendor info...
  169                  */
  170                 if ((err = copyout(&count, &avr->avsp_len, sizeof(count))) != 0)
  171                         break;
  172 
  173                 /*
  174                  * Update the reply pointers and lengths
  175                  */
  176                 aip->air_buf_addr = buf;
  177                 aip->air_buf_len = buf_len;
  178                 break;
  179 
  180         default:
  181                 err = ENOSYS;           /* Operation not supported */
  182                 break;
  183         }
  184 
  185         return (err);
  186 }
  187 
  188 
  189 /*
  190  * Free Fore-specific device resources
  191  * 
  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
  194  * vectors removed.
  195  *
  196  * Arguments:
  197  *      fup     pointer to device unit structure
  198  *
  199  * Returns:
  200  *      none
  201  *
  202  */
  203 void
  204 fore_interface_free(fup)
  205         Fore_unit       *fup;
  206 {
  207 
  208         /*
  209          * Free up all of our allocated memory
  210          */
  211         fore_xmit_free(fup);
  212         fore_recv_free(fup);
  213         fore_buf_free(fup);
  214         fore_cmd_free(fup);
  215 
  216         /*
  217          * Clear device initialized
  218          */
  219         if (fup->fu_flags & CUF_INITED) {
  220                 fup->fu_flags &= ~CUF_INITED;
  221         }
  222 
  223         if (fup->fu_flags & FUF_STATCMD) {
  224                 fup->fu_flags &= ~FUF_STATCMD;
  225         }
  226         return;
  227 }
  228 

Cache object: b88d77b5fe7760e7bcd1870c8c3158fa


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.