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/llc_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: llc_timer.c,v 1.8 2003/08/07 16:33:03 agc Exp $        */
    2 
    3 /* 
    4  * Copyright (c) 1992, 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  * Dirk Husemann and the Computer Science Department (IV) of
    9  * the University of Erlangen-Nuremberg, Germany.
   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  *      @(#)llc_timer.c 8.1 (Berkeley) 6/10/93
   36  */
   37 
   38 /* 
   39  * Copyright (c) 1990, 1991, 1992
   40  *              Dirk Husemann, Computer Science Department IV, 
   41  *              University of Erlangen-Nuremberg, Germany.
   42  * 
   43  * This code is derived from software contributed to Berkeley by
   44  * Dirk Husemann and the Computer Science Department (IV) of
   45  * the University of Erlangen-Nuremberg, Germany.
   46  *
   47  * Redistribution and use in source and binary forms, with or without
   48  * modification, are permitted provided that the following conditions
   49  * are met:
   50  * 1. Redistributions of source code must retain the above copyright
   51  *    notice, this list of conditions and the following disclaimer.
   52  * 2. Redistributions in binary form must reproduce the above copyright
   53  *    notice, this list of conditions and the following disclaimer in the
   54  *    documentation and/or other materials provided with the distribution.
   55  * 3. All advertising materials mentioning features or use of this software
   56  *    must display the following acknowledgement:
   57  *      This product includes software developed by the University of
   58  *      California, Berkeley and its contributors.
   59  * 4. Neither the name of the University nor the names of its contributors
   60  *    may be used to endorse or promote products derived from this software
   61  *    without specific prior written permission.
   62  *
   63  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   64  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   65  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   66  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   67  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   68  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   69  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   70  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   71  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   72  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   73  * SUCH DAMAGE.
   74  *
   75  *      @(#)llc_timer.c 8.1 (Berkeley) 6/10/93
   76  */
   77 
   78 #include <sys/cdefs.h>
   79 __KERNEL_RCSID(0, "$NetBSD: llc_timer.c,v 1.8 2003/08/07 16:33:03 agc Exp $");
   80 
   81 #include <sys/param.h>
   82 #include <sys/systm.h>
   83 #include <sys/mbuf.h>
   84 #include <sys/domain.h>
   85 #include <sys/socket.h>
   86 #include <sys/protosw.h>
   87 #include <sys/errno.h>
   88 #include <sys/time.h>
   89 #include <sys/kernel.h>
   90 
   91 #include <net/if.h>
   92 #include <net/if_dl.h>
   93 #include <net/if_llc.h>
   94 
   95 #include <netccitt/dll.h>
   96 #include <netccitt/llc_var.h>
   97 
   98 
   99 /*
  100  * Various timer values.  They can be adjusted
  101  * by patching the binary with adb if necessary.
  102  */
  103 /* ISO 8802-2 timers */
  104 int     llc_n2                  = LLC_N2_VALUE;
  105 int     llc_ACK_timer           = LLC_ACK_TIMER;
  106 int     llc_P_timer             = LLC_P_TIMER;
  107 int     llc_BUSY_timer          = LLC_BUSY_TIMER;
  108 int     llc_REJ_timer           = LLC_REJ_TIMER;
  109 /* Implementation specific timers */
  110 int     llc_AGE_timer           = LLC_AGE_TIMER;
  111 int     llc_DACTION_timer       = LLC_DACTION_TIMER;
  112 
  113 /*
  114  * The timer routine. We are called every 500ms by the kernel.
  115  * Handle the various virtual timers.
  116  */
  117 
  118 void
  119 llc_timer()
  120 {
  121         struct llc_linkcb *linkp;
  122         struct llc_linkcb *nlinkp;
  123         int timer;
  124         int action;
  125         int s = splnet();
  126 
  127         /*
  128          * All links are accessible over the doubly linked list llccb_q
  129          */
  130         if (!LQEMPTY) {
  131                 /*
  132                  * A for-loop is not that great an idea as the linkp
  133                  * might get deleted if the age timer has expired ...
  134                  */
  135                 linkp = LQFIRST;
  136                 while (LQVALID(linkp)) {
  137                         nlinkp = LQNEXT(linkp);
  138                         /*
  139                          * Check implementation specific timers first
  140                          */
  141                         /* The delayed action/acknowledge idle timer */
  142                         switch (LLC_TIMERXPIRED(linkp,DACTION)) {
  143                         case LLC_TIMER_RUNNING:
  144                                 LLC_AGETIMER(linkp,DACTION);
  145                                 break;
  146                         case LLC_TIMER_EXPIRED: {
  147                                 int cmdrsp;
  148                                 int pollfinal;
  149 
  150                                 switch (LLC_GETFLAG(linkp,DACTION)) {
  151                                 case LLC_DACKCMD:
  152                                         cmdrsp = LLC_CMD, pollfinal = 0;
  153                                         break;
  154                                 case LLC_DACKCMDPOLL:
  155                                         cmdrsp = LLC_CMD, pollfinal = 1;
  156                                         break;
  157                                 case LLC_DACKRSP:
  158                                         cmdrsp = LLC_RSP, pollfinal = 0;
  159                                         break;
  160                                 case LLC_DACKRSPFINAL:
  161                                         cmdrsp = LLC_RSP, pollfinal = 1;
  162                                         break;
  163                                 default:
  164                                         panic("Unexpected LLC_GETFLAG");
  165                                         return;
  166                                 }
  167                                 llc_send(linkp, LLCFT_RR, cmdrsp, pollfinal);
  168                                 LLC_STOPTIMER(linkp,DACTION);
  169                                 break;
  170                         }
  171                         }
  172                         /* The link idle timer */
  173                         switch (LLC_TIMERXPIRED(linkp,AGE)) {
  174                         case LLC_TIMER_RUNNING:
  175                                 LLC_AGETIMER(linkp,AGE);
  176                                 break;
  177                         case LLC_TIMER_EXPIRED:
  178                                 /*
  179                                  * Only crunch the link when really no
  180                                  * timers are running any more.
  181                                  */
  182                                 if (llc_anytimersup(linkp) == 0) {
  183                                         llc_dellink(linkp);
  184                                         LLC_STOPTIMER(linkp,AGE);
  185                                         goto gone;
  186                                 } else {
  187                                         LLC_STARTTIMER(linkp,AGE);
  188                                 }
  189                                 break;
  190                         }
  191                         /* 
  192                          * Now, check all the ISO 8802-2 timers 
  193                          */
  194                         FOR_ALL_LLC_TIMERS(timer) {
  195                                 action = 0;
  196                                 if ((linkp->llcl_timerflags & (1<<timer)) &&
  197                                     (linkp->llcl_timers[timer] == 0)) {
  198                                         switch (timer) {
  199                                         case LLC_ACK_SHIFT:
  200                                                 action = LLC_ACK_TIMER_EXPIRED;
  201                                                 break;
  202                                         case LLC_P_SHIFT:
  203                                                 action = LLC_P_TIMER_EXPIRED;
  204                                                 break;
  205                                         case LLC_BUSY_SHIFT:
  206                                                 action = LLC_BUSY_TIMER_EXPIRED;
  207                                                 break;
  208                                         case LLC_REJ_SHIFT:
  209                                                 action = LLC_REJ_TIMER_EXPIRED;
  210                                                 break;
  211                                         }
  212                                         linkp->llcl_timerflags &= ~(1<<timer);
  213                                         (void)llc_statehandler(linkp, (struct llc *)0, action, 0, 1);
  214                                 } else if (linkp->llcl_timers[timer] > 0)
  215                                         linkp->llcl_timers[timer]--;
  216                         }
  217                         
  218 gone:                   linkp = nlinkp;
  219                 }
  220         }
  221         splx (s);
  222 }

Cache object: 89ef92ad669426cc7e27053b66d1e529


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