📄 scs_event.c
字号:
#ifndef lintstatic char *sccsid = "@(#)scs_event.c 4.1 (ULTRIX) 7/2/90";#endif lint/************************************************************************ * * * Copyright (c) 1988 - 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 * Systems Communication Services * * Abstract: This module contains Systems Communication Services( SCS ) * event notification routines. It includes routines invoked * by port drivers to notify SCS. * * Creator: Todd M. Katz Creation Date: July 7, 1985 * * Function/Routines: * * scs_data_done Block Data Transfer Completed * scs_dg_rec Application Datagram Received * scs_msg_rec Sequenced Message Received * scs_msg_snt Application Sequenced Message Sent * scs_new_path New Path to System Discovered * scs_path_crash Path to System Crashed * * Modification History: * * 18-Apr-1989 Pete Keilty * Added smp_lock.h, and extern struct lock_t lk_scadb. * * 21-Feb-1989 Todd M. Katz TMK0005 * Fix a bug introduced by TMK0004. Modify scs_path_crash() to insure * that the local variable "event" is zeroed prior to the processing of * each Connection Block associated with the failed path. * * 11-Feb-1989 Todd M. Katz TMK0004 * 1. Add support for SCS event logging. Log abortions of connection * establishment and terminations of fully established SCS connections * due to path failure. * 2. Include header file ../vaxmsi/msisysap.h. * * 20-Aug-1988 Todd M. Katz TMK0003 * SCA event codes have been completed revised. All former SCS path crash * codes are now defined as either error events or severe error events. * The path crash attribute is only applied by the individual port driver * routines responsible for crashing paths and only when the crashed path * is currently open. * * 09-Jul-1988 Todd M. Katz TMK0002 * Update comments. * * 02-Jun-1988 Ricky S. Palmer * Removed inclusion of header file ../vaxmsi/msisysap.h * * 08-Jan-1988 Todd M. Katz TMK0001 * Formated module, revised comments, increased robustness, restructured * code paths, and added SMP support. *//* Libraries and Include Files. */#include "../h/types.h"#include "../h/time.h"#include "../h/param.h"#include "../h/ksched.h"#include "../h/errlog.h"#include "../h/smp_lock.h"#ifdef mips#include "../h/systm.h"#include "../h/vmmac.h"#endif mips#include "../io/scs/sca.h"#include "../io/scs/scaparam.h"#include "../io/ci/cippdsysap.h"#include "../io/ci/cisysap.h"#include "../io/msi/msisysap.h"#include "../io/bi/bvpsysap.h"#include "../io/gvp/gvpsysap.h"#include "../io/uba/uqsysap.h"#include "../io/sysap/sysap.h"#include "../io/ci/cippdscs.h"#include "../io/ci/ciscs.h"#include "../io/msi/msiscs.h"#include "../io/bi/bvpscs.h"#include "../io/gvp/gvpscs.h"#include "../io/uba/uqscs.h"#include "../io/scs/scs.h"/* External Variables and Routines. */extern SCSIB lscs;extern struct lock_t lk_scadb;extern CBVTDB *scs_cbvtdb;extern pbq scs_timeoutq;extern cbq scs_listeners;extern struct timezone tz;extern void scs_dispose_msg(), scs_init_cmsb(), scs_log_event(), unksched();/* Name: scs_data_done - Block Data Transfer Completed * * Abstract: This SCS event notification routine is asynchronously invoked * following PD completion of a specific block data transfer. The * PD should not have notified SCS of the failure of the path over * which the block data transfer occurred although in a SMP * environment this may prove unavoidable. * * The transfer initiating SYSAP is notified of transfer * completion through asynchronous invocation of the connection's * control event routine and the send credit temporarily withdrawn * during block data transfer is returned. The latter may trigger * notification of the appropriate SYSAP of the availability of * send credits on the connection through asynchronous invocation * of the connection's control event routine. * * Inputs: * * IPL_SCS - Interrupt processor level * lscs - Local system permanent information * pccb - Port Command and Control Block pointer * lk_scadb - SCA database lock structure * scs_cbvtdb - CB vector table database pointer * scsbp - Address of SCS header in buffer * ( READ ONLY ) * tid - Transaction identification pointer * * Outputs: * * IPL_SCS - Interrupt processor level * cb - Connection Block pointer * cinfo.ntransfers - Number of block data transfers in progress * cinfo.snd_credit - Number of send credits * cinfo.status.cwait - 0 * * SMP: The SCA database is locked for PB retrieval. It also prevents * premature PB deletion as required by PD routines which crash * paths. * * The CB is locked to synchronize access and to prevent deletion. * It is indirectly locked through its CBVTE. Locking the CB also * prevents premature PB deletion as required by scs_init_cmsb(). * * The CBVTE semaphore is incremented prior to any SYSAP * notification to prevent any changes in connection state while * both potential SYSAP notifications are in progress. The * semaphore is decremented following completion of all SYSAP * notifications. * * PCCB addresses are always valid allowing access to static * fields because PCCBs are never deleted once SCS becomes aware * of their existence. * * NO EXTERNAL locks may be held when this routine is invoked. */voidscs_data_done( pccb, scsbp, tid ) PCCB *pccb; SCSH *scsbp; register TID *tid;{ register PB *pb; register CB *cb; u_long event; register CBVTE *cbvte; register u_long credit; register void ( *control )(); CMSB data_cmsb, credit_cmsb; /* Block data transfer completion notifications are processed as follows: * * 1. Lock and retrieve the CB targeted by the transaction identification * number. * 2. Validate the connection. * 3. Decrement the number of transfers currently in progress on the * connection. * 4. Return the send credit temporarily withdrawn during the block data * transfer. * 5. Increment the CBVTE semaphore. * 6. Unlock the CB. * 7. Notify the SYSAP of send credit availability on the connection if it * was waiting for them to become available. * 8. Notify the SYSAP of the completion of its block data transfer. * 9. Decrement the CBVTE semaphore. * * Incrementing the appropriate CBVTE semaphore protects the connection * against all changes in state for the duration of both SYSAP * notifications and while any call backs on the connection are in * progress. * * The path on which the block data transfer completed is crashed under any * of the following circumstances: * * 1. The CB can not be retrieved. * 2. A connection identification number mismatch exists. * 3. The connection is in an inappropriate state. * 4. The connection does not have any block data transfers in progress. * * None of these circumstances are ever expected in a single processor * environment. This explains the drastic actions taken when they occur. * However, the occurrence of any of these circumstances can be expected in * a SMP environment, albeit with an extremely low frequency, whenever a * path fails. This is because no mechanisms exist to coordinate PD event * notifications of SCS as there are mechanisms to coordinate SCS * notifications of SYSAPs. This allows PD notifications of block transfer * completion to actually occur after PD notifications of path failure * even though PDs initiate the former notifications first. The actions * taken remain the same as in the single processor case even though they * are drastic and may well result in double crashing of the path. There * is no other alternative. * * The buffer provided to this routine is READ ONLY and is only provided * for PB retrieval if it becomes necessary to crash the path. */ if( tid->lconnid.index > ( lscs.max_conns - 1 )) { cbvte = NULL; event = SE_BADCONNID; } else { cbvte = Get_cbvte( tid->lconnid ); Lock_cbvte( cbvte ) cb = Get_cb( cbvte ); if( tid->lconnid.seq_num != cbvte->connid.seq_num ) { event = SE_BADCONNID; } else if( cb->cinfo.cstate != CS_OPEN && cb->cinfo.cstate != CS_DISCONN_REC ) { event = SE_BADCSTATE; } else if( cb->cinfo.ntransfers-- > 0 ) { control = cb->control; ++cb->cinfo.snd_credit; if( cb->cinfo.status.cwait && cb->cinfo.cstate == CS_OPEN ) { cb->cinfo.status.cwait = 0; credit = 1; ( void )scs_init_cmsb( CRE_CREDIT_AVAIL, ADR_SUCCESS, &credit_cmsb, cb, cb->pb, 0 ); } else { credit = 0; } ( void )scs_init_cmsb( CRE_BLOCK_DONE, ADR_SUCCESS, &data_cmsb, cb, cb->pb, tid->blockid ); Incr_cbvte_sem( cbvte ) Unlock_cbvte( cbvte ) if( credit ) { ( void )( *control )( CRE_CREDIT_AVAIL, &credit_cmsb ); } ( void )( *control )( CRE_BLOCK_DONE, &data_cmsb ); Decr_cbvte_sem( cbvte ) return; } else { cb->cinfo.ntransfers = 0; event = SE_NOTRANSFERS; } } if( cbvte ) { Unlock_cbvte( cbvte ) } Lock_scadb() pb = ( *pccb->Get_pb )( pccb, scsbp, BUF ); ( void )( *pccb->Crash_path )( pccb, pb, event, 0, NULL ); Unlock_scadb()}/* Name: scs_dg_rec - Application Datagram Received * * Abstract: This SCS event notification routine is asynchronously invoked * whenever a PD receives an application datagram. SCS disposes * of the received application datagram in one of two ways: * * 1. The application datagram is handed off to the appropriate * SYSAP through asynchronous invocation of the connection's * datagram event routine. * 2. The application datagram buffer is added to the appropriate * port's free datagram buffer pool. * * NOTE: It is possible for SCS to have been previously notified * of the failure of the path over which the application * datagram was received. This is because datagrams may be * both sent and received over failed paths. In such cases * the datagram is just returned to the appropriate port's * free datagram buffer pool. * * Inputs: * * IPL_SCS - Interrupt processor level * lscs - Local system permanent information * pccb - Port Command and Control Block pointer * lk_scadb - SCA database lock structure * scsbp - Address of SCS header in datagram buffer * scs_cbvtdb - CB vector table database pointer * size - Size of application data + SCS header * * Outputs: * * IPL_SCS - Interrupt processor level * cb - Connection Block pointer * cinfo.dg_credit - Number of local datagram credits * cinfo_dgs_discard - Number of datagrams discarded * cinfo_dgs_rec - Number of datagrams received * * SMP: The SCA database is locked for PB retrieval. It also prevents * premature PB deletion as required by PD routines which crash * paths. * * The CB is locked to synchronize access and to prevent deletion. * It is indirectly locked through its CBVTE. Locking the CB also * prevents premature PB deletion as required by scs_init_cmsb(). * * The CBVTE semaphore is incremented prior to SYSAP reception of * the received application datagram to prevent any changes in * connection state while SYSAP reception is in progress. The * semaphore is decremented after SYSAP reception of the * application datagram completes. * * PCCB addresses are always valid allowing access to static * fields because PCCBs are never deleted once SCS becomes aware * of their existence. * * NO EXTERNAL locks may be held when this routine is invoked. */voidscs_dg_rec( pccb, scsbp, size ) PCCB *pccb; register SCSH *scsbp; u_long size;{ CSB dg_csb; register CB *cb; register CBVTE *cbvte; register u_long event; register void ( *notify )(); /* Application datagram reception notifications are processed as follows: * * 1. Lock and retrieve the CB targeted by the received application * datagram. * 2. Validate the connection. * 3. Determine whether suitable conditions exist for reception and * disposal of the application datagram on the connection by the * corresponding SYSAP. * 4. Perform connection bookkeeping * 5. Increment the CBVTE semaphore. * 6. Unlock the CB. * 7. Invoke the connection's datagram event routine to allow the * corresponding SYSAP to receive and dispose of the the application * datagram provided suitable conditions exist. * 8. Decrement the CBVTE semaphore. * * Incrementing the appropriate CBVTE semaphore protects the connection * against all changes in state for the duration of SYSAP reception of the * application datagram and while any call backs on the connection are in * progress. * * Failure to validate the connection( Step 2 ) is normally a result of * connection termination due to path failure. Failure to find suitable * conditions for SYSAP disposal of the application datagram( Step 3 ) may * be due to: * * 1. Inappropriate connection state. * 2. Absence of a datagram event routine associated with the connection. * 3. Current lack of receive datagram credits on the connection. * * Either failure aborts handing off the application datagram to the SYSAP * for disposal. Instead, the datagram buffer is returned to the * appropriate port's free datagram pool and the number of datagrams * discarded on the connection is incremented( provided the connection is * in an acceptable state ). * * The path on which the datagram was received is crashed under any of the * following circumstances:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -