?? scs.h
字號:
typedef struct _pccb { /* Port Command and Control Block */ union { /* PD dependent fields */ /* ( MUST BE FIRST IN PCCB !! ) */ struct _gvppccb gvp; /* Generic Vaxport specific fields */ struct _msipccb msi; /* MSI specific fields */ struct _uqpccb uq; /* UQ specific fields */ } pd; struct _pccbq *flink; /* System-wide local port database */ struct _pccbq *blink; /* queue pointers */ u_short size; /* Size of data structure */ u_char type; /* Structure type */ u_char : 8; struct _pdt *pdt; /* PDT pointer */ struct kschedblk forkb; /* Fork block */ struct lock_t pccb_lk; /* Lock structure */ union { /* PPD dependent fields */ struct _cippdpccb cippd; /* CI PPD specific fields */ } ppd; struct _lpib lpinfo; /* Local port information */} PCCB;typedef struct _pdt { /* Port Dispatch Table */ /* Mandatory PD Functions */ struct _scsh *( *alloc_dg )(); /* Allocate Datagram Buffer */ void ( *dealloc_dg )(); /* Deallocate Datagram Buffer */ void ( *add_dg )(); /* Add Datagram Buffer to Free Pool */ struct _scsh *( *remove_dg )(); /* Remove Dg Buffer from Free Pool */ struct _scsh *( *alloc_msg )(); /* Allocate Message Buffer */ void ( *dealloc_msg )(); /* Deallocate Message Buffer */ void ( *add_msg )(); /* Add Message Buffer to Free Pool */ struct _scsh *( *remove_msg )(); /* Remove Msg Buffer from Free Pool */ void ( *send_msg )(); /* Send Sequenced Message */ u_long ( *map_buf )(); /* Map Buffer */ void ( *unmap_buf )(); /* Unmap Buffer */ u_long ( *open_path )(); /* Transition Formative Path to Open */ void ( *crash_path )(); /* Crash Path */ struct _pb *( *get_pb )(); /* Retrieve Path Block */ void ( *remove_pb )(); /* Remove Path Block from Databases */ u_long ( *remote_reset )(); /* Reset Remote Port and System */ u_long ( *remote_start )(); /* Start Remote Port and System */ /* Optional PD Functions */ void ( *send_dg )(); /* Send Datagram */ u_long ( *send_data )(); /* Send Block Data */ u_long ( *request_data )(); /* Request Block Data */ void ( *crash_lport )(); /* Crash Local Port */ void ( *shutdown )(); /* Inform Systems of Local Shutdown */ /* Optional PD Functions for PPD */ u_long ( *opt1 )(); u_long ( *opt2 )(); u_long ( *opt3 )(); u_long ( *opt4 )(); u_long ( *opt5 )(); u_long ( *opt6 )(); u_long ( *opt7 )(); u_long ( *opt8 )(); u_long ( *opt9 )(); u_long ( *opt10 )(); u_long ( *opt11 )(); u_long ( *opt12 )();} PDT;typedef struct _tid { /* Transaction Identification Number */ u_long blockid; /* Block data transfer ID number */ struct _connid lconnid; /* Local connection ID number */} TID;/* SCS Sequenced Message Definitions. */ /* ACCEPT_REQ and CONN_REQ Sequenced */typedef struct { /* Messages */ u_short mtype; /* SCS message type */ short credit; /* Flow control credit */ struct _connid rconnid; /* Identification of receiving SYSAP */ /* MBZ for CONN_REQ */ struct _connid sconnid; /* Identification of sending SYSAP */ u_short min_credit; /* Minimum credit requirement */ u_short : 16; /* MBZ */ u_char rproc_name[ NAME_SIZE ];/* Receiving SYSAP name */ u_char sproc_name[ NAME_SIZE ];/* Sending SYSAP name */ u_char sproc_data[ DATA_SIZE ];/* Connect data from sending SYSAP */} ACCEPT_REQ, CONN_REQ; /* ACCEPT_RSP, CONN_RSP, DISCONN_REQ */typedef struct { /* and REJECT_REQ Sequenced Messages*/ u_short mtype; /* SCS message type */ u_short : 16; /* MBZ */ struct _connid rconnid; /* Identification of receiving SYSAP */ struct _connid sconnid; /* Identification of sending SYSAP */ u_short : 16; /* MBZ */ u_short reason; /* Reason */#define Req_status reason /* Request status */} ACCEPT_RSP, CONN_RSP, DISCONN_REQ, REJECT_REQ; /* CREDIT_REQ, CREDIT_RSP, */ /* DISCONN_RSP, and REJECT_RSP */typedef struct _scsh { /* Sequenced Messages and SCS Header*/ u_short mtype; /* SCS message type */ short credit; /* Flow control credit */ /* MBZ for DISCONN_RSP and REJECT_RSP*/ struct _connid rconnid; /* Identification of receiving SYSAP */ struct _connid sconnid; /* Identification of sending SYSAP */} CREDIT_REQ, CREDIT_RSP, DISCONN_RSP, REJECT_RSP, SCSH;/* Macros. */ /* CB Manipulation Macros *//* SMP: Both SCA database and CBVTE must be locked PRIOR to invocation. */#define Insert_cb( cb, pb ) { \ Insert_entry( cb->flink, pb->cbs ) \ ++pb->pinfo.nconns; \}/* SMP: Both SCA database and CBVTE must be locked PRIOR to invocation. */#define Remove_cb( cb, pb ) { \ Remove_entry( cb->flink ) \ --pb->pinfo.nconns; \ ( void )scs_dealloc_cb( cb ); \} /* Connection Manipulation Macros *//* SMP: The CBVTE is locked on successful invocation. */#define Check_connid( sourceid, cbvte, cb ) { \ if( sourceid.index <= ( lscs.max_conns - 1 )) { \ cbvte = Get_cbvte( sourceid ); \ Lock_cbvte( cbvte ) \ if( cbvte->connid.seq_num == sourceid.seq_num ) { \ cb = Get_cb( cbvte ); \ } else { \ Unlock_cbvte( cbvte ) \ return( RET_INVCONNID ); \ } \ } else { \ return( RET_INVCONNID ); \ } \}/* SMP: Both the SCA database and CBVTE are locked on successful invocation. */#define Check_connid2( sourceid, cbvte, cb ) { \ if( sourceid.index <= ( lscs.max_conns - 1 )) { \ cbvte = Get_cbvte( sourceid ); \ Lock_scadb() \ Lock_cbvte( cbvte ) \ if( cbvte->connid.seq_num == sourceid.seq_num ) { \ cb = Get_cb( cbvte ); \ } else { \ Unlock_cbvte( cbvte ) \ Unlock_scadb() \ return( RET_INVCONNID ); \ } \ } else { \ return( RET_INVCONNID ); \ } \}#define Get_cbvte( sourceid ) ( scs_cbvtdb->cbvt + sourceid.index )#define Get_cb( cbvte ) ( cbvte->ov1.cb )#define Comp_connid( c1, c2 ) ( U_long( c1 ) == U_long( c2 )) /* Counter Macros *//* SMP: The counter containing structure must be locked PRIOR to invocation. */#define Data_counter( counter, bytes ) { \ if( counter != -1 ) { \ if(( long )counter < 0 ) { \ if(( long )( counter += bytes ) > 0 ) { \ counter = -1; \ } \ } else { \ counter += bytes; \ } \ } \}/* SMP: The counter containing structure must be locked PRIOR to invocation. */#define Event_counter( counter ) { \ if( ++counter == 0 ) { \ --counter; \ } \} /* Positioning and Message Macros */#define Accept_req( bp ) (( ACCEPT_REQ * )bp )#define Accept_rsp( bp ) (( ACCEPT_RSP * )bp )#define Conn_req( bp ) (( CONN_REQ * )bp )#define Conn_rsp( bp ) (( CONN_RSP * )bp )#define Disconn_req( bp ) (( DISCONN_REQ * )bp )#define Reject_req( bp ) (( REJECT_REQ * )bp )#define Appl_to_scs( bp ) (( SCSH * )bp - 1 )#define Scs_to_appl( scsbp ) (( u_char * )( scsbp + 1 ))#define Cb_offset( ptr, offset ) \ (( u_char * )&(( CB * )ptr )->offset - ( u_char * )ptr )#define Pb_offset( ptr, offset ) \ (( u_char * )&(( PB * )ptr )->offset - ( u_char * )ptr )#define Pccb_offset( ptr, offset ) \ (( u_char * )&(( PCCB * )ptr )->offset - ( u_char * )ptr )#define Pos_to_cb( ptr, offset ) \ (( CB * )(( u_char * )ptr - Cb_offset( ptr, offset )))#define Pos_to_pb( ptr, offset ) \ (( PB * )(( u_char * )ptr - Pb_offset( ptr, offset )))#define Pos_to_pccb( ptr, offset ) \ (( PCCB * )(( u_char * )ptr - Pccb_offset( ptr, offset ))) /* Shorthand Notations */#define Cb (( CB * )cb )#define Lcb (( CB * )lcb )#define Sb (( SB * )sb )#define Pb (( PB * )pb )#define Alloc_dg pdt->alloc_dg#define Dealloc_dg pdt->dealloc_dg#define Add_dg pdt->add_dg#define Remove_dg pdt->remove_dg#define Alloc_msg pdt->alloc_msg#define Dealloc_msg pdt->dealloc_msg#define Add_msg pdt->add_msg#define Remove_msg pdt->remove_msg#define Send_msg pdt->send_msg#define Map_buf pdt->map_buf#define Unmap_buf pdt->unmap_buf#define Open_path pdt->open_path#define Crash_path pdt->crash_path#define Get_pb pdt->get_pb#define Remove_pb pdt->remove_pb#define Remote_reset pdt->remote_reset#define Remote_start pdt->remote_start#define Send_dg pdt->send_dg#define Send_data pdt->send_data#define Request_data pdt->request_data#define Crash_lport pdt->crash_lport#define Shutdown pdt->shutdown /* SCS Event Logging Macros */#define Elscscommon( elp ) ( &elp->el_body.elscs.scscommon )#define Elscsconn( p ) (( struct scs_conn * )p )#define Elscsrreason( p ) (( u_long * )p )#define Elscsldirid( p ) (( u_short * )p )#define Scs_clmaxcode( tab, event ) \ ( tab[ Eseverity( event )].max_code )#define Scs_clftab( tab, event ) \ ( tab[ Eseverity( event )].ftable + Ecode( event ) - 1 )#define Scs_cltabmsg( tab, event ) ( Scs_clftab( tab, event )->msg )#define Scs_cltabcode( tab, event ) ( Scs_clftab( tab, event )->fcode ) /* SCS SMP Locking Macros */#define Init_cbvte_lock( cbvte ) { \ lockinit(&(( cbvte )->cbvte_lk ), &lock_cbvte_d ); \}#define Init_pb_lock( pb ) { \ lockinit(&(( pb )->pb_lk ), &lock_pb_d ); \}#define Init_pccb_lock( pccb ) { \ lockinit(&(( pccb )->pccb_lk ), &lock_pccb_d ); \}#define Init_scadb_lock() { \ lockinit( &lk_scadb, &lock_scadb_d ); \}#define Lock_cbvte( cbvte ) { \ smp_lock(&(( cbvte )->cbvte_lk ), LK_RETRY ); \}#define Lock_pb( pb ) { \ smp_lock(&(( pb )->pb_lk ), LK_RETRY ); \}#define Lock_pccb( pccb ) { \ smp_lock(&(( pccb )->pccb_lk ), LK_RETRY ); \}#define Lock_scadb() { \ smp_lock( &lk_scadb, LK_RETRY ); \}#define Test_pb_lock( pb ) (( pb )->pb_lk.l_lock )#define Test_pccb_lock( pccb ) (( pccb )->pccb_lk.l_lock )#define Test_scadb_lock() ( lk_scadb.l_lock )#define Unlock_cbvte( cbvte ) { \ smp_unlock(&(( cbvte )->cbvte_lk )); \}#define Unlock_pb( pb ) { \ smp_unlock(&(( pb )->pb_lk )); \}#define Unlock_pccb( pccb ) { \ smp_unlock(&(( pccb )->pccb_lk )); \}#define Unlock_scadb() { \ smp_unlock( &lk_scadb ); \}/* CBVTE Semaphore Macros: CBVTEs are locked when their semaphores are tested * and incremented but not when they are decremented. This allows for * semaphores to be simultaneously tested and decremented in a SMP environment. * This is acceptable because SCS is interested in only whether semaphores are * zero or non-zero. Semaphores may test non-zero when actually zero but may * never test zero when non-zero. What is necessary to meet this semaphore * testing requirement is an atomic fetch of semaphore contents. This is * achieved by longword-aligning the word-size CBVTE semaphores. Once * atomically fetched the semaphore contents can be isolated and tested. * * This Decr_cbvte_sem should be an atomic operation, memory lock for * duration of operation such as adawi operation. * Unable to do so at this time, So lock and unlock the cbvte. */#define Decr_cbvte_sem( cbvte ) { \ Lock_cbvte( cbvte ) \ ++cbvte->cbip; \ Unlock_cbvte( cbvte ) \}#define Incr_cbvte_sem( cbvte ) { \ --cbvte->cbip; \}#define Test_cbvte_sem( cbvte ) ( U_long( cbvte->cbip ) & 0xffff ) /* Miscellaneous Macros *//* SMP: The CBVTE must be locked PRIOR to invocation. */#define Init_csb( csb, cb, scsbp, size ) { \ csb->connid = cb->cinfo.lconnid; \ csb->Aux = cb->aux; \ csb->size = size - sizeof( SCSH ); \ csb->buf = Scs_to_appl( scsbp ); \}#define Port_failure( reason ) \ (( reason == PF_POWER || \ reason == PF_PORTERROR || \ reason == PF_FATALERROR ) ? 1: 0 )/* SMP: The CBVTE must be locked PRIOR to invocation. */#define Remove_pb_waitq( cb ) { \ if( cb->cinfo.cbstate != CB_NOT_WAIT ) { \ Lock_pb( cb->pb ) \ Remove_entry( cb->scs_cb ) \ Unlock_pb( cb->pb ) \ cb->cinfo.cbstate = CB_NOT_WAIT; \ } \}/* SMP: Both the SCA database and PB must be locked PRIOR to invocation. */#define Remove_scs_timeoutq( pb ) { \ pb->pinfo.status.sanity = 0; \ pb->pinfo.duetime = 0; \ Remove_entry( pb->timeout ) \}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -