Google
 

Trailing-Edge - PDP-10 Archives - BB-R595B-SM_11-9-85 - mcb/xpt/xpefwd.bli
There is 1 other file named xpefwd.bli in the archive. Click here to see a list.
module XPEFWD	(
		IDENT = 'X01150'
		) =
begin

!
!                    COPYRIGHT (c) 1980, 1981, 1982
!                    DIGITAL EQUIPMENT CORPORATION
!                        Maynard, Massachusetts
!
!     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:	Transport
!
! ABSTRACT:
!
!	Transport forwarding module:  Forwards packets to other MCB
!	routines, and terminates packets which are not to be forwarded.
!
! ENVIRONMENT:	MCB
!
! AUTHOR: L. Webber , CREATION DATE: 23-Oct-79
!
! MODIFIED BY:
!
!	L. Webber, 23-Oct-79 : VERSION 1.00
!
! 1.01	L. Webber, 20-Dec-79
!	MCB interface modifications
!
! 1.02	L. Webber, 30-Jun-80
!	Modify to use MCBLIB macros
!
! 1.03	A. Peckham, 15-Oct-80
!	Take advantage of new function modifiers.
!
! 1.04  L. Webber, 17-Nov-80
!       Decrement ECL quota when queuing a message to ECL.
!
! 1.05	L. Webber, 11-Dec-80
!	Modify to support MCB 3.1
!
! 1.06	L. Webber, 10-Feb-81
!	Change from XPTFWD to XPEFWD; all entries are now CALL$
!	so they may be CALL$E'd.  All entries now have a "_"
!	in front of them, as: _TERMINATE.
!
! 1.07	L. Webber, 18-Feb-81
!	Fix maintenance of INPUTquota.
!	Add debugging code to maintain a count of DLL receive buffers
!	  outstanding to Transport.
!
! 1.08	L. Webber, 16-Mar-81
!	Fix _TERMINATE to call UNSPAWN to clean up a spawned CCB.
!
! 1.09	L. Webber, 4-Jun-81
!	Fix ECLFWD not to set C_LIN.
!
! 1.10	L. Webber, 25-Jun-81
!	Have FORWARDER check for negative as well as zero values of the
!	line quota (this is to accomodate some "high-priority" messages).
!
! 1.11	L. Webber, 26-Jun-81
!	Fix _TERMINATE to get rid of Transport's own (usually XCP) CCB.
!
! 1.12	L. Webber, 20-Jul-81
!	Modify _TERMINATE not to adjust input count when terminating a DC we
!	sent (it was already adjusted when the DC was sent).
!
! 1.13	A. Peckham, 19-Sep-81
!	Change CSBRT$ call to $MCB_RETURN_CCB_AND_BUFFER.
!
! 1.14	L. Webber, 23-Feb-82
!	Add DLLquota maintanance.
!
! 1.15	A. Peckham, 22-Apr-82
!       Eliminate GETLINE references.
!
!--
!
! INCLUDE FILES:
!

require 'XPTMAC';

!
! TABLE OF CONTENTS
!

forward routine
	_SNDBUF: CALL$ novalue,
	_FORWARDER: CALL$,
	DLL_Q: novalue,
	_ECLFWD: CALL$,
	_TERMINATE: CALL$ novalue;

!
! MACROS:
!

!
! EQUATED SYMBOLS:
!

!
! OWN STORAGE:
!

!
! EXTERNAL REFERENCES:
!

external routine
    UNSPAWN: novalue;
global
routine _SNDBUF (LINEb,CCB): CALL$ novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! This routine is called to unconditionally forward a packet to the
! Transport Line Interface Layer.  If the packet cannot be sent, it
! will be discarded.
!
! FORMAL PARAMETERS
!
!	LINEb	The data base of the output line on which it is
!		to be forwarded.
!	CCB	The CCB for the packet to be forwarded; the packet is assumed
!		to be an unpaired SDB which belongs to Transport.
!
! IMPLICIT INPUTS
!
!	LINEstate
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map CCB: ref block field (C_XPT_fields);
require 'XPTSYM';

!
!  Make sure the output line is up
!

if ((.CCB[C_XPT_TYPE] neq INITcode)!Buffer is not from Line Support
and (.LINEstate neq RU))		!  and line is not in "run" state:
    then $MCB_RETURN_CCB_AND_BUFFER(.CCB[C_XPT_ALLOCATION],.CCB) !  get rid of CCB/buffer

!
!  OK - now send out the packet
!

else DLL_Q(.CCB,.LINEb);
end;				!End of _SNDBUF
global
routine _FORWARDER (CCB,OLINE): CALL$ =

!++
! FUNCTIONAL DESCRIPTION:
!
! This routine is called to conditionally forward a packet to the
! Transport Line Interface Layer.  If the packet cannot be forwarded
! because of unreachability or congestion, the packet is returned
! to the caller with an error code.
!
! FORMAL PARAMETERS
!
!	CCB	Spawned CCB for packet to be forwarded.
!	OLINE	Channel number for output line.
!
! IMPLICIT INPUTS
!
!	LINEstate
!
! ROUTINE VALUE: "Success", "unreachable", or "congestion"
! COMPLETION CODES:
!
!	CS_SUC	Success: packet has been forwarded.
!	CE_DIS	Unreachable destination: packet is rejected.
!	CE_RTE	Congestion: packet is rejected.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map CCB: ref block field (C_XPT_fields);
local LINEb;
require 'XPTSYM';

!
!  Make sure the output line is up
!

LINEb = $XPT_GET_LINE_DB(.OLINE);       ! Address line data base entry
if .LINEstate neq RU then		!Output line is not in "run" state:
    return (CE_DIS)			!  reject the packet

!
!  Check the output quota
!

else if .LINEquota leq 0 then		!Quota exhausted:
    return (CE_RTE)			!  reject the packet

!
!  OK - send out the packet
!

else begin
    LINEquota = .LINEquota - 1;		!Decrement the quota
    CCB[C_XPT_TYPE] = FWDcode;          !Set buffer type
    DLL_Q (.CCB,.LINEb);		!Queue up the packet
    return (CS_SUC)			!Return "success"
    end
end;				!End of _FORWARDER
routine DLL_Q (CCB,LINEb): novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Queues a packet CCB to the Transport Line Interface Layer.
!
! FORMAL PARAMETERS
!
!	CCB	CCB to be queued
!	LINEb	Output line data base
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map CCB: ref block field (C_XPT_fields);
require 'XPTSYM';

CCB[C_HANDLE] = .TLIhandle;             ! Move in destination = TLI
CCB[C_FNC] = FC_XME;                    ! Function is "transmit enable"
CCB[C_MOD] = TM_DAT;                    !  with a side of "data"
$MCB_SCHEDULE_CCB(.CCB);                ! Send the buffer
end;				!End of DLL_Q
global
routine _ECLFWD (CCB,SOURCE,DEST,RTS): CALL$ =

!++
! FUNCTIONAL DESCRIPTION:
!
! This routine is called to conditionally forward a packet to a
! Transport user.  If the packet cannot be forwarded because of
! congestion, the packet is returned to the caller with an error
! code.
!
! FORMAL PARAMETERS
!
!	CCB	CCB for packet to be forwarded.
!	SOURCE	Source node address
!	DEST	Destination node address
!	RTS	"Return to sender" flag to be passed to user.
!
! IMPLICIT INPUTS
!
!	ECLquota
!
! ROUTINE VALUE: "Success" or "congestion"
! COMPLETION CODES:
!
!	CS_SUC	Success: packet has been forwarded to user.
!	CE_RTE	Congestion: packet is rejected.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map CCB: ref block field (C_XPT_fields);
require 'XPTSYM';
local CCB_P: ref block field(C_FIELDS);

!
!  Check the ECL quota
!

if .ECLquota eql 0 then			!Quota exhausted:
    return (CE_RTE)			!  return "congestion"
else ECLquota = .ECLquota - 1;          !Otherwise - decrement

!
!  OK - forward to user
!

CCB[C_FNC] = FC_RCP;			!Function is "receive complete"
CCB[C_MOD] = XM_DAT;			!Modifier is "data message"
CCB[C_XPT_SOURCE] = .SOURCE;		!  and source node address
CCB[C_XPT_DESTINATION] = .DEST;         !  and destination node address
CCB[C_STS] = (if .RTS then CE_DIS	!Status = "return to sender"
    else CS_SUC);			!  or "regular packet"
begin
local NODEb: ref NODEblock;
NODEb = $XPT_GET_NODE_DB(.DEST);
CCB[C_PIX] = .User;			!Move in destination PIX
end;
$MCB_SCHEDULE_CCB (.CCB);		!Queue to the destination process
return(CS_SUC)				!Return "success"
end;				!End of _ECLFWD
global
routine _TERMINATE (CCB,CODE): CALL$ novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! This routine is called to "terminate" a CCB or spawned/pass-through
! CCB pair.  "Termination" consists of releasing the spawned CCB and its
! SDB (if either exist) and returning the pass-through CCB to its owning
! process with a specified success or error code.
!
! FORMAL PARAMETERS
!
!	CCB	First or only CCB to terminate.
!	CODE	Success/failure code to return to the originating process.
!		This value is only used if the originating process is a
!		Transport user; if the terminated CCB is sent back to the
!		Data Link Layer, no status is returned.
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map CCB: ref block field (C_XPT_fields);
local LINEb;
require 'XPTSYM';
local ADJ;
local CCB_P: ref block field(C_XPT_fields);

!
!  Process spawned CCB if any
!

if ((.CCB[C_OWN] eql PD_XPT) and	!Parameter
(.CCB[C_STK] neq 0)) then begin		!  is a
    CCB_P = .CCB[C_STK];		!  spawned CCB:
    UNSPAWN(.CCB);			!  clean it up
    end
else CCB_P = .CCB;			!Parameter is pass-through CCB

!
!  Return pass-through CCB to a Transport user
!

if .CCB_P[C_FNC] eql FC_XME then begin
    INPUTquota = .INPUTquota + 1;	!Increase admission quota
    CCB_P[C_FNC] = FC_XCP;		!Function = "transmit complete"
    CCB_P[C_STS] = .CODE;		!Move in success/failure code
    LLCRS$ (.CCB_P);			!Return CCB to user
    end

!
!  Return pass-through CCB to the Transport Line Interface Layer
!

else if .CCB_P[C_FNC] eql FC_RCP then begin
    LINEb = $XPT_GET_LINE_DB(.CCB_P[C_LIX]);    ! Address line data base entry
    if .CCB[C_XPT_TYPE] neq NOcode then	
    begin					!Decrement receive
	INPUTcount = .INPUTcount - 1;		!  buffer count
	DLLquota = .DLLquota + 1;		!  and global quota
	end;
    CCB_P[C_FNC] = FC_RCE;			!Function = "receive enable"
    LLCRS$ (.CCB_P);				!Queue CCB back to DLL
    end

!
!  Return our own CCB to the pool
!

else if .CCB_P[C_OWN] eql PD_XPT
     then begin
          if .CCB_P[C_XPT_ALLOCATION] neq 0
          then begin
               MAP$(.CCB_P[C_BIAS]);
               $MCB_RETURN_BUFFER(.CCB_P[C_XPT_ALLOCATION],.CCB_P[C_ADDR]);
               end;
          $MCB_RETURN_CCB(.CCB_P);
          end

!  
!
!  How did we get here?
!

else BPT(XPT$_IFC,CCB_P[C_FNC]);

end;				!End of _TERMINATE
end				!End of Module XPEFWD
eludom