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/pk_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: pk_timer.c,v 1.10 2003/08/07 16:33:05 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  *      @(#)pk_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  *      @(#)pk_timer.c  8.1 (Berkeley) 6/10/93
   76  */
   77 
   78 #include <sys/cdefs.h>
   79 __KERNEL_RCSID(0, "$NetBSD: pk_timer.c,v 1.10 2003/08/07 16:33:05 agc Exp $");
   80 
   81 #include <sys/param.h>
   82 #include <sys/systm.h>
   83 #include <sys/mbuf.h>
   84 #include <sys/socket.h>
   85 #include <sys/protosw.h>
   86 #include <sys/socketvar.h>
   87 #include <sys/errno.h>
   88 
   89 #include <net/if.h>
   90 
   91 #include <netccitt/x25.h>
   92 #include <netccitt/pk.h>
   93 #include <netccitt/pk_var.h>
   94 #include <netccitt/pk_extern.h>
   95 
   96 /*
   97  * Various timer values.  They can be adjusted
   98  * by patching the binary with adb if necessary.
   99  */
  100 int             pk_t20 = 18 * PR_SLOWHZ;        /* restart timer */
  101 int             pk_t21 = 20 * PR_SLOWHZ;        /* call timer */
  102 /* XXX pk_t22 is never used */
  103 int             pk_t22 = 18 * PR_SLOWHZ;        /* reset timer */
  104 int             pk_t23 = 18 * PR_SLOWHZ;        /* clear timer */
  105 
  106 void
  107 pk_timer()
  108 {
  109         struct pkcb *pkp;
  110         struct pklcd *lcp, **pp;
  111         int    lcns_jammed, cant_restart;
  112 
  113         FOR_ALL_PKCBS(pkp) {
  114                 switch (pkp->pk_state) {
  115                 case DTE_SENT_RESTART:
  116                         lcp = pkp->pk_chan[0];
  117                         /*
  118                          * If restart failures are common, a link level
  119                          * reset should be initiated here.
  120                          */
  121                         if (lcp->lcd_timer && --lcp->lcd_timer == 0) {
  122                                 pk_message(0, pkp->pk_xcp,
  123                                            "packet level restart failed");
  124                                 pkp->pk_state = DTE_WAITING;
  125                         }
  126                         break;
  127 
  128                 case DTE_READY:
  129                         lcns_jammed = cant_restart = 0;
  130                         for (pp = &pkp->pk_chan[1]; pp <= &pkp->pk_chan[pkp->pk_maxlcn]; pp++) {
  131                                 if ((lcp = *pp) == 0)
  132                                         continue;
  133                                 switch (lcp->lcd_state) {
  134                                 case SENT_CALL:
  135                                         if (--lcp->lcd_timer == 0) {
  136                                                 if (lcp->lcd_so)
  137                                                         lcp->lcd_so->so_error = ETIMEDOUT;
  138                                                 pk_clear(lcp, 49, 1);
  139                                         }
  140                                         break;
  141 
  142                                 case SENT_CLEAR:
  143                                         if (lcp->lcd_retry >= 3)
  144                                                 lcns_jammed++;
  145                                         else if (--lcp->lcd_timer == 0)
  146                                                 pk_clear(lcp, 50, 1);
  147                                         break;
  148 
  149                                 case DATA_TRANSFER:     /* lcn active */
  150                                         cant_restart++;
  151                                         break;
  152 
  153                                 case LCN_ZOMBIE:        /* zombie state */
  154                                         pk_freelcd(lcp);
  155                                         break;
  156                                 }
  157                         }
  158                         if (lcns_jammed > pkp->pk_maxlcn / 2 && cant_restart == 0) {
  159                                 pk_message(0, pkp->pk_xcp, "%d lcns jammed: attempting restart", lcns_jammed);
  160                                 pk_restart(pkp, 0);
  161                         }
  162                 }
  163         }
  164 }

Cache object: a40502478df28a75b4750c98c8e44861


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