📄 mscp_conpol.c
字号:
#ifndef lintstatic char *sccsid = "@(#)mscp_conpol.c 4.3 (ULTRIX) 12/6/90";#endif lint/************************************************************************ * * * Copyright (c) 1987 - 1989 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************ * * * Facility: Systems Communication Architecture * Disk Class Driver * * Abstract: This module contains all the routines associated with * connection management. * * Author: David E. Eiche Creation Date: September 30, 1985 * * History: * * 04-Dec-1990 Pete Keilty * Modified mscp_system_poll() added Splscs synchronization * because it is called from timeout routine now also. * Modified mscp_consetretry() to set polling for adapter * fail over. * Modified mscp_consubr() to set lport_name, rport_addr & sysid * from the connection block. * * 03-July-1990 Matthew Sacks * Modified the below change to special case the KDB50. This is * because they have an init process which is both very slow and * which blocks out the other KDB50's. The goal is to prevent one * KDB50's init from causing host access timeouts to another KDB50. * * 28-Dec-1989 David E. Eiche DEE0081 * Change mscp_constconem() to identify controllers that support * dual porting and to adjust the host timeout interval to prevent * spurious host timeouts caused by timer processing delays. Change * mscp_constrstcon() to use the processing overhead factor in * computing a default controller timeout. * * 17-Mar-1989 Tim Burke * Changed queue manipulations to use the following macros: * insque ..... Insert_entry * remque ..... Remove_entry * remqck ..... Remove_entry and check to see if any elements on queue. * * 12-Feb-1989 Todd M. Katz TMK0003 * 1. Modify TMK0002 to use the shorthand notation Lproc_name when * refering to the corresponding MSB field. * 2. Include header file ../vaxmsi/msisysap.h. * 3. Use the ../machine link to refer to machine specific header files. * * 17-Oct-1988 Pete Keilty * Fix concleanup save off wrp->flink for later use, wrp insque to * restart queue. * * 28-Sep-1988 David E. Eiche DEE0058 * Fix host timeout logic so that controllers that are initialized * to have host timeout disabled retain that characteristic after * connection recovery. * * 28-Sep-1988 David E. Eiche DEE0057 * Fix panic message formats to make them consistent. * * 14-Sep-1988 Todd M. Katz TMK0002 * Pass the local SYSAP name in the MSB to SCS when crashing a path. * * 09-Sep-1988 David E. Eiche DEE0056 * Move initialization of request state from mscp_conqrestart * to mscp_restart_next in mscp_subr.c. This fixes a bug in * which the connection management request block was having * its state erroneously initialized. * * 06-Sep-1988 David E. Eiche DEE0054 * Fix code which caused disks to hang when a second loss of * connection occurred while recovering from the first. * * 06-Sep-1988 David E. Eiche DEE0053 * Change host/controller timeout code to provide a default * controller timeout period if the controller returns a zero * controller timeout. This is done in conjunction with a * change to the host timeout values in the controller model * table. * * 17-Aug-1988 David E. Eiche DEE0051 * Change state definitions to use ST_CMN_INITIAL so that recovery * can rely on the initial state in any state table to be the same. * Also modify mscp_polinit to set and mscp_polgtuntem to clear the * upoll_busy flag in the connection block. * * 17-July-1988 David E. Eiche DEE0047 * Change parameters used to call mscp_get_unitb, so that it * can be called from attention message processing. Move the * calls to mscp_find_controller and mscp_find_device for the * same reason. * * 17-July-1988 David E. Eiche DEE0046 * Change parameters used in calling mscp_get_connb, so that it * can be called from the new path section of the control routine. * This allows the new system event to be processed directly rather * than by invocation of system polling. * * 17-July-1988 David E. Eiche DEE0045 * Change references to the model table to conform to the new * format and to use the connection block fields where appropriate. * * 29-June-1988 David E. Eiche DEE0044 * Change mscp_conresynch to always call scs_crash_path so that * all SYSAPs connected to a server are quickly notified of path * failure. This change is intended to prevent multiple resynch's * of a controller as the result of a single failure. * * 29-June-1988 David E. Eiche DEE0043 * Change mscp_condisccmplt to dispatch EV_ERRECOV instead of * EV_INITIAL. Change mscp_concleanup to clarify the event * redispatch logic and improve the code style. * * 27-June-1988 David E. Eiche DEE0042 * Add code to mscp_constrstcon to supply a default maximum transfer * length value if the controller does not supply the field. This * change is in accordance with the MSCP specification and is required * by the mscp_ioctl routine to implement the bad block scan ioctl. * * 16-June-1988 Larry Cohen * Add global variable mscp_polls that is incremented for each * connection attempt and decremented for each connection completion. * The system waits in init_main for mscp_polls to go to zero so that * autoconfigure output can be delayed until the disks/tapes have * been sized. * * 02-Jun-1988 Ricky S. Palmer * Removed inclusion of header file ../vaxmsi/msisysap.h * * 20-May-1988 David E. Eiche DEE0038 * Remove mscp_conreturn routine. All references to mscp_conreturn * had previously been changed to use mscp_noaction. * * 15-May-1988 David E. Eiche DEE0034 * Change mscp_conresynch to correctly bracket if's. * Add routine mscp_condealmsg to deallocate a connection * management service message that arrives after the connection * is restarted. * * 15-Jan-1988 Todd M. Katz TMK0001 * Include new header file ../vaxmsi/msisysap.h. * * 25-Jan-1988 Ricky S. Palmer * Added some "node_name" based code to determine whether a dssc or an hsc * is involved. This needs to be done using the hardware port type. * *//**//* Libraries and Include Files. */#include "../h/types.h"#include "../h/time.h"#include "../h/kernel.h"#include "../h/param.h"#include "../h/kmalloc.h"#include "../h/buf.h"#include "../h/errno.h"#include "../h/ioctl.h"#include "../h/devio.h"#include "../h/file.h"#include "../fs/ufs/fs.h"#include "../h/errlog.h"#include "../machine/pte.h"#ifdef mips#include "../h/systm.h"#include "../h/vmmac.h"#endif mips#include "../io/scs/sca.h"#include "../io/ci/cippdsysap.h"#include "../io/ci/cisysap.h"#include "../io/bi/bvpsysap.h"#include "../io/gvp/gvpsysap.h"#include "../io/msi/msisysap.h"#include "../io/uba/uqsysap.h"#include "../io/sysap/sysap.h"#include "../io/uba/ubavar.h"#include "../io/sysap/mscp_msg.h"#include "../io/sysap/mscp_defs.h"/**//* External variables and routines. */extern struct uba_ctlr ubminit[];extern struct uba_device ubdinit[];extern struct uba_driver mscpdriver;extern struct timeval boottime;extern int dkn;extern int mscp_polls;extern u_long scs_connect();extern u_long scs_crsh_path();extern u_long scs_info_system();extern u_long scs_reset();extern u_long scs_restart();extern void scs_unix_to_vms();extern void mscp_bbr_init();extern void mscp_conqrestart();extern void mscp_dealloc_all();extern void mscp_dispatch();extern void mscp_find_controller();extern void mscp_find_device();extern void mscp_find_model();extern void mscp_recycle_rspid();extern void mscp_reserve_credit();extern void mscp_restart_next();extern u_long mscp_send_msg();extern UNITB *mscp_unit_tbl[];extern STATE mscp_con_states[];extern STATE mscp_pol_states[];extern STATE mscp_rec_states[];extern LISTHD mscp_rspid_wait_lh;/* Forward routine references. */void mscp_consubr();void mscp_confmtstcon();void mscp_constrstcon();CONNB * mscp_get_connb();UNITB * mscp_get_unitb();/**//* * * Name: mscp_system_poll - Find and connect to known (sub-)systems. * * Abstract: Find all systems currently known by SCS and attempt to * initiate a connection to each of them. * * Inputs: * * Outputs: * * * Return NONE * Values: */voidmscp_system_poll( clp ) register CLASSB *clp;{ register CONNB *cp; ISB isb; SIB sib; CMSB cmsb; int saved_ipl; saved_ipl = Splscs(); clp->flags.need_poll = 0; /* Poll SCS for each system that it knows about, and attempt to * establish connections to all known systems. If an SCS service * returns any error status or if sufficient memory is not available * to allocate a connection block, abort the current polling cycle * and reschedule polling. */ Zero_scaaddr( isb.next_sysid ); do { cp = NULL; if( scs_info_system( &isb, &sib ) == RET_SUCCESS ) { isb.next_lport_name = 0; if( scs_info_path( &isb, NULL ) == RET_SUCCESS ) { cp = mscp_get_connb( clp, &isb.sysid, &isb.rport_addr, isb.lport_name ); } } if( cp == NULL ) { clp->flags.need_poll = 1; break; } } while ( !Test_scaaddr( isb.next_sysid )); /* If the polling cycle completed successfully and the listening * connection has not yet been established, issue a listen request * to SCS. If the listen does not succeed, reschedule polling, * as it is then the only way to find out about new systems. */ if(( clp->flags.need_poll == 0 ) && ( clp->flags.listen == 0 )) { cmsb = clp->cmsb; cmsb.aux = ( u_char * )clp; if( scs_listen( &cmsb ) == RET_SUCCESS ) { clp->flags.listen = 1; } else { clp->flags.need_poll = 1; } } splx( saved_ipl ); return;}/**//* * * Name: mscp_coninit - Connect to the target system. * * Abstract: * * Inputs: * * Outputs: * * * Return NONE * Values: */u_longmscp_coninit( event, rp ) u_long event; REQB *rp;{ CONNB *cp = rp->connb; CLASSB *clp = rp->classb; cp->retry_count = CONNECT_RETRIES; mscp_consubr( rp ); return( EV_NULL );}/**//* * * Name: mscp_concomplete - Process a connection completed response. * * Abstract: * * Inputs: * * Outputs: * * * Return NONE * Values: */u_longmscp_concomplete( event, rp ) u_long event; register REQB *rp;{ register CONNB *cp = rp->connb; register CMSB *cmsp; CLASSB *clp = rp->classb; u_long status = EV_NULL; /* Turn off the connection timeout. */ cp->cmdtmo_intvl = 0; /* A connect complete event was received. Analyze the completion status. */ if( event == EV_CONCOMPLETE ) { cmsp = ( CMSB * )rp->aux; switch( cmsp->status ) { /* The connection succeeded. Store the connection ID and * redispatch. */ case ADR_SUCCESS: Move_connid( cmsp->connid, cp->connid ); status = EV_CONACTIVE; break; /* The server does not support the requested service. * Vaporize the connection block and go away. */ case ADR_NOSUPPORT: case ADR_NOLISTENER: Remove_entry( cp->flink ); KM_FREE( cp, KM_SCA ); mscp_polls--; break; /* A retryable error occurred. If retries remain, reissue * the connect. */ case ADR_DISCONN: case ADR_NOCREDIT: case ADR_PATH_FAILURE: case ADR_NORESOURCE: if( cp->retry_count-- ) mscp_consubr( rp ); else status = EV_EXRETRY; break; /* These errors should not occur. If they do, panic. */ case ADR_BUSY: panic( "mscp_concomplete: connect to an active server\n" ); default: panic( "mscp_concomplete: unrecognized completion status\n" ); } /* The connect timed out. If retries remain, reissue the connect. */ } else { if( cp->retry_count-- ) mscp_consubr( rp ); else status = EV_EXRETRY; } return( status );}/**//* * * Name: mscp_constconcm - Send an MSCP STCON command message. * * Abstract: * * Inputs: * * Outputs: * * * Return NONE * Values: */u_longmscp_constconcm( event, rp ) u_long event; REQB *rp;{ /* Format a set controller characteristics message, and attempt * to send it out on the connection. Note that the host timeout * field in this message is zero, which means no host timeout is * desired for this controller (for the moment). */ mscp_confmtstcon( rp, 0 ); /* The send message has been queued successfully. Exit to wait for * the end message to come back. */ return( mscp_send_msg( rp ) );}/**/u_short mscp_htmo_overhead = HTMO_OVERHEAD;u_short mscp_htmo_overhead_kdb50 = HTMO_OVERHEAD_KDB50;/* * * Name: mscp_constconem - Process an MSCP STCON end message. * * Abstract: * * Inputs: * * Outputs: * * * Return NONE * Values: */u_longmscp_constconem( event, rp ) u_long event; register REQB *rp;{ register CONNB *cp = rp->connb; u_long state = rp->state; /* Store the controller characteristics and recycle the RSPID. * Note also that the end message buffer address has been stored * in the REQB so that it can be used to send the next connection * management command. Then look up the controller model information * and store a pointer to the model table entry in the CONNB. */ mscp_constrstcon( rp ); mscp_recycle_rspid( rp ); /* If the connection state is STCON1 and the controller supports * dual port operation, the host timeout is calculated as the larger * of the compiled-in host dual port timeout and the controller * timeout that was returned in the STCON end message plus a * processing overhead factor. A message will be sent to the * controller at least once per controller timeout period, so no * host timeout should occur while the host is operational. * * For controllers that do not support dual port operation, the host * timeout is disabled by setting it to zero. Since zero was sent in * the first STCON command, it is not necessary to send a second command. */ if( state == ST_CN_STCON1 ) { mscp_find_model( cp ); mscp_reserve_credit( rp ); if(( cp->cnt_flgs & MSCP_CF_MLTHS ) || ( cp->cnt_id.model == MSCP_CM_UDA50 ) || ( cp->cnt_id.model == MSCP_CM_UDA50A ) || ( cp->cnt_id.model == MSCP_CM_KDA50 ) || ( cp->cnt_id.model == MSCP_CM_KDB50 ) || ( cp->cnt_id.model == MSCP_CM_KDM70 )) { cp->hst_tmo = HTMO_DUALPORT; if ((cp->cnt_tmo + mscp_htmo_overhead) > cp->hst_tmo ) { if (cp->cnt_id.model == MSCP_CM_KDB50) cp->hst_tmo = cp->cnt_tmo + mscp_htmo_overhead_kdb50;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -