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/netccitt/hd_timer.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 /*      $NetBSD: hd_timer.c,v 1.12 2005/02/26 22:45:10 perry Exp $      */
    2 
    3 /*
    4  * Copyright (c) 1990, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * This code is derived from software contributed to Berkeley by
    8  * the Laboratory for Computation Vision and the Computer Science Department
    9  * of the University of British Columbia.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. Neither the name of the University nor the names of its contributors
   20  *    may be used to endorse or promote products derived from this software
   21  *    without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  *
   35  *      @(#)hd_timer.c  8.1 (Berkeley) 6/10/93
   36  */
   37 
   38 /*
   39  * Copyright (c) 1984 University of British Columbia.
   40  *
   41  * This code is derived from software contributed to Berkeley by
   42  * the Laboratory for Computation Vision and the Computer Science Department
   43  * of the University of British Columbia.
   44  *
   45  * Redistribution and use in source and binary forms, with or without
   46  * modification, are permitted provided that the following conditions
   47  * are met:
   48  * 1. Redistributions of source code must retain the above copyright
   49  *    notice, this list of conditions and the following disclaimer.
   50  * 2. Redistributions in binary form must reproduce the above copyright
   51  *    notice, this list of conditions and the following disclaimer in the
   52  *    documentation and/or other materials provided with the distribution.
   53  * 3. All advertising materials mentioning features or use of this software
   54  *    must display the following acknowledgement:
   55  *      This product includes software developed by the University of
   56  *      California, Berkeley and its contributors.
   57  * 4. Neither the name of the University nor the names of its contributors
   58  *    may be used to endorse or promote products derived from this software
   59  *    without specific prior written permission.
   60  *
   61  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   62  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   63  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   64  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   65  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   66  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   67  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   68  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   69  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   70  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   71  * SUCH DAMAGE.
   72  *
   73  *      @(#)hd_timer.c  8.1 (Berkeley) 6/10/93
   74  */
   75 
   76 #include <sys/cdefs.h>
   77 __KERNEL_RCSID(0, "$NetBSD: hd_timer.c,v 1.12 2005/02/26 22:45:10 perry Exp $");
   78 
   79 #include <sys/param.h>
   80 #include <sys/systm.h>
   81 #include <sys/mbuf.h>
   82 #include <sys/domain.h>
   83 #include <sys/socket.h>
   84 #include <sys/protosw.h>
   85 #include <sys/errno.h>
   86 #include <sys/time.h>
   87 #include <sys/kernel.h>
   88 
   89 #include <net/if.h>
   90 
   91 #include <netccitt/hdlc.h>
   92 #include <netccitt/hd_var.h>
   93 #include <netccitt/x25.h>
   94 #include <netccitt/pk_extern.h>
   95 
   96 /*
   97  * these can be patched with adb if the
   98  * default values are inappropriate
   99  */
  100 
  101 int             hd_t1 = T1;
  102 int             hd_t3 = T3;
  103 int             hd_n2 = N2;
  104 
  105 /*
  106  *  HDLC TIMER
  107  *
  108  *  This routine is called every 500ms by the kernel. Decrement timer by this
  109  *  amount - if expired then process the event.
  110  */
  111 
  112 void
  113 hd_timer()
  114 {
  115         struct hdcb *hdp;
  116         int    s = splnet();
  117 
  118         for (hdp = hdcbhead; hdp; hdp = hdp->hd_next) {
  119                 if (hdp->hd_rrtimer && (--hdp->hd_rrtimer == 0)) {
  120                         if (hdp->hd_lasttxnr != hdp->hd_vr)
  121                                 hd_writeinternal(hdp, RR, POLLOFF);
  122                 }
  123                 if (!(hdp->hd_timer && --hdp->hd_timer == 0))
  124                         continue;
  125 
  126                 switch (hdp->hd_state) {
  127                 case INIT:
  128                 case DISC_SENT:
  129                         hd_writeinternal(hdp, DISC, POLLON);
  130                         break;
  131 
  132                 case ABM:
  133                         if (hdp->hd_lastrxnr != hdp->hd_vs) {   /* XXX */
  134                                 hdp->hd_timeouts++;
  135                                 hd_resend_iframe(hdp);
  136                         }
  137                         break;
  138 
  139                 case WAIT_SABM:
  140                         hd_writeinternal(hdp, FRMR, POLLOFF);
  141                         if (++hdp->hd_retxcnt == hd_n2) {
  142                                 hdp->hd_retxcnt = 0;
  143                                 hd_writeinternal(hdp, SABM, POLLOFF);
  144                                 hdp->hd_state = WAIT_UA;
  145                         }
  146                         break;
  147 
  148                 case DM_SENT:
  149                         if (++hdp->hd_retxcnt == hd_n2) {
  150                                 /* Notify the packet level. */
  151                                 (void) pk_ctlinput(PRC_LINKDOWN,
  152                                        (struct sockaddr *) hdp->hd_pkp, NULL);
  153                                 hdp->hd_retxcnt = 0;
  154                                 hdp->hd_state = SABM_SENT;
  155                                 hd_writeinternal(hdp, SABM, POLLOFF);
  156                         } else
  157                                 hd_writeinternal(hdp, DM, POLLOFF);
  158                         break;
  159 
  160                 case WAIT_UA:
  161                         if (++hdp->hd_retxcnt == hd_n2) {
  162                                 hdp->hd_retxcnt = 0;
  163                                 hd_writeinternal(hdp, DM, POLLOFF);
  164                                 hdp->hd_state = DM_SENT;
  165                         } else
  166                                 hd_writeinternal(hdp, SABM, POLLOFF);
  167                         break;
  168 
  169                 case SABM_SENT:
  170                         /* Do this indefinitely. */
  171                         hd_writeinternal(hdp, SABM, POLLON);
  172                         break;
  173 
  174                 case DISCONNECTED:
  175                         /*
  176                          * Poll the interface driver flags waiting
  177                          * for the IFF_UP bit to come on.
  178                          */
  179                         if (hdp->hd_ifp->if_flags & IFF_UP)
  180                                 hdp->hd_state = INIT;
  181 
  182                 }
  183                 SET_TIMER(hdp);
  184         }
  185 
  186         splx(s);
  187 }

Cache object: 78c75549dd447dbca6a11ff10d477fb9


[ 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.