1 /* 2 * Copyright (c) University of British Columbia, 1984 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Laboratory for Computation Vision and the Computer Science Department 8 * of the University of British Columbia. 9 * 10 * %sccs.include.redist.c% 11 * 12 * @(#)pk_timer.c 7.2 (Berkeley) 05/11/90 13 */ 14 15 #include "../h/param.h" 16 #include "../h/systm.h" 17 #include "../h/mbuf.h" 18 #include "../h/socket.h" 19 #include "../h/protosw.h" 20 #include "../h/socketvar.h" 21 #include "../h/errno.h" 22 23 #include "../net/if.h" 24 25 #include "../netccitt/pk.h" 26 #include "../netccitt/pk_var.h" 27 28 /* 29 * Various timer values. They can be adjusted 30 * by patching the binary with adb if necessary. 31 */ 32 int pk_t20 = 18 * PR_SLOWHZ; /* restart timer */ 33 int pk_t21 = 20 * PR_SLOWHZ; /* call timer */ 34 /* XXX pk_t22 is never used */ 35 int pk_t22 = 18 * PR_SLOWHZ; /* reset timer */ 36 int pk_t23 = 18 * PR_SLOWHZ; /* clear timer */ 37 38 pk_timer () 39 { 40 register struct pkcb *pkp; 41 register struct pklcd *lcp, **pp; 42 register int lcns_jammed, cant_restart; 43 44 for (pkp = pkcbhead; pkp; pkp = pkp->pk_next) { 45 switch (pkp -> pk_state) { 46 case DTE_SENT_RESTART: 47 lcp = pkp -> pk_chan[0]; 48 /* 49 * If restart failures are common, a link level 50 * reset should be initiated here. 51 */ 52 if (lcp -> lcd_timer && --lcp -> lcd_timer == 0) 53 pk_message (0, pkp -> pk_xcp, 54 "packet level restart failed"); 55 break; 56 57 case DTE_READY: 58 lcns_jammed = cant_restart = 0; 59 for (pp = &pkp -> pk_chan[1]; pp <= &pkp -> pk_chan[pkp -> pk_maxlcn]; pp++) { 60 if ((lcp = *pp) == 0) 61 continue; 62 switch (lcp -> lcd_state) { 63 case SENT_CALL: 64 if (--lcp -> lcd_timer == 0) { 65 lcp -> lcd_so -> so_error = ETIMEDOUT; 66 pk_clear (lcp); 67 } 68 break; 69 70 case SENT_CLEAR: 71 if (lcp -> lcd_retry >= 3) 72 lcns_jammed++; 73 else 74 if (--lcp -> lcd_timer == 0) 75 pk_clear (lcp); 76 break; 77 78 case DATA_TRANSFER: /* lcn active */ 79 cant_restart++; 80 break; 81 } 82 } 83 if (lcns_jammed > pkp -> pk_maxlcn / 2 && cant_restart == 0) { 84 pk_message (0, pkp -> pk_xcp, "%d lcns jammed: attempting restart", lcns_jammed); 85 pk_restart (pkp, 0); 86 } 87 } 88 } 89 } 90