xref: /csrg-svn/sys/netiso/tp_pcb.h (revision 37536)
136409Ssklower /***********************************************************
236409Ssklower 		Copyright IBM Corporation 1987
336409Ssklower 
436409Ssklower                       All Rights Reserved
536409Ssklower 
636409Ssklower Permission to use, copy, modify, and distribute this software and its
736409Ssklower documentation for any purpose and without fee is hereby granted,
836409Ssklower provided that the above copyright notice appear in all copies and that
936409Ssklower both that copyright notice and this permission notice appear in
1036409Ssklower supporting documentation, and that the name of IBM not be
1136409Ssklower used in advertising or publicity pertaining to distribution of the
1236409Ssklower software without specific, written prior permission.
1336409Ssklower 
1436409Ssklower IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
1536409Ssklower ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
1636409Ssklower IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
1736409Ssklower ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
1836409Ssklower WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
1936409Ssklower ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2036409Ssklower SOFTWARE.
2136409Ssklower 
2236409Ssklower ******************************************************************/
2336409Ssklower 
2436409Ssklower /*
2536409Ssklower  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
2636409Ssklower  */
2736409Ssklower /*
2836409Ssklower  * ARGO TP
2936409Ssklower  *
3036409Ssklower  * $Header: tp_pcb.h,v 5.2 88/11/18 17:09:32 nhall Exp $
3136409Ssklower  * $Source: /usr/argo/sys/netiso/RCS/tp_pcb.h,v $
3236409Ssklower  *
3336409Ssklower  *
3436409Ssklower  * This file defines the transport protocol control block (tpcb).
3536409Ssklower  * and a bunch of #define values that are used in the tpcb.
3636409Ssklower  */
3736409Ssklower 
3836409Ssklower #ifndef  __TP_PCB__
3936409Ssklower #define  __TP_PCB__
4036409Ssklower 
4136409Ssklower #include "../netiso/tp_param.h"
4236409Ssklower #include "../netiso/tp_timer.h"
4336409Ssklower #include "../netiso/tp_user.h"
4436409Ssklower #ifndef sblock
45*37536Smckusick #include "socketvar.h"
4636409Ssklower #endif sblock
4736409Ssklower 
4836409Ssklower /* NOTE: the code depends on REF_CLOSED > REF_OPEN > the rest, and
4936409Ssklower  * on REF_FREE being zero
5036409Ssklower  *
5136409Ssklower  * Possible improvement:
5236409Ssklower  * think about merging the tp_ref w/ the tpcb and doing a search
5336409Ssklower  * through the tpcb list, from tpb. This would slow down lookup
5436409Ssklower  * during data transfer
5536409Ssklower  * It would be a little nicer also to have something based on the
5636409Ssklower  * clock (like top n bits of the reference is part of the clock, to
5736409Ssklower  * minimize the likelihood  of reuse after a crash)
5836409Ssklower  * also, need to keep the timer servicing part to a minimum (although
5936409Ssklower  * the cost of this is probably independent of whether the timers are
6036409Ssklower  * in the pcb or in an array..
6136409Ssklower  * Last, would have to make the number of timers a function of the amount of
6236409Ssklower  * mbufs available, plus some for the frozen references.
6336409Ssklower  *
6436409Ssklower  * Possible improvement:
6536409Ssklower  * Might not need the ref_state stuff either...
6636409Ssklower  * REF_FREE could correspond to tp_state == CLOSED or nonexistend tpcb,
6736409Ssklower  * REF_OPEN to tp_state anywhere from AK_WAIT or CR_SENT to CLOSING
6836409Ssklower  * REF_OPENING could correspond to LISTENING, because that's the
6936409Ssklower  * way it's used, not because the correspondence is exact.
7036409Ssklower  * REF_CLOSED could correspond to REFWAIT
7136409Ssklower  */
7236409Ssklower #define REF_FROZEN 3	/* has ref timer only */
7336409Ssklower #define REF_OPEN 2		/* has timers, possibly active */
7436409Ssklower #define REF_OPENING 1	/* in use (has a pcb) but no timers */
7536409Ssklower #define REF_FREE 0		/* free to reallocate */
7636409Ssklower 
7736409Ssklower #define N_CTIMERS 		4
7836409Ssklower #define N_ETIMERS 		2
7936409Ssklower 
8036409Ssklower struct tp_ref {
8136409Ssklower 	u_char	 			tpr_state; /* values REF_FROZEN, etc. above */
8236409Ssklower 	struct Ccallout 	tpr_callout[N_CTIMERS]; /* C timers */
8336409Ssklower 	struct Ecallout		tpr_calltodo;			/* list of active E timers */
8436409Ssklower 	struct tp_pcb 		*tpr_pcb;	/* back ptr to PCB */
8536409Ssklower };
8636409Ssklower 
8736409Ssklower struct tp_param {
8836409Ssklower 	/* PER system stuff (one static structure instead of a bunch of names) */
8936409Ssklower 	unsigned 	tpp_configed:1;			/* Has TP been initialized? */
9036409Ssklower };
9136409Ssklower 
9236409Ssklower 
9336409Ssklower /*
9436409Ssklower  * retransmission control and performance measurement
9536409Ssklower  */
9636409Ssklower struct tp_rtc {
9736409Ssklower 	struct tp_rtc	*tprt_next; /* ptr to next rtc structure in the list */
9836409Ssklower 	SeqNum 			tprt_seq;	/* seq # of this TPDU */
9936409Ssklower 	int				tprt_eot;	/* Will this TPDU have the eot bit set? */
10036409Ssklower 	int				tprt_octets;/* # octets in this TPDU */
10136409Ssklower 	struct mbuf		*tprt_data; /* ptr to the octets of data */
10236409Ssklower };
10336409Ssklower 
10436409Ssklower extern
10536409Ssklower struct nl_protosw {
10636409Ssklower 	int		nlp_afamily;			/* address family */
10736409Ssklower 	int		(*nlp_putnetaddr)();	/* puts addresses in nl pcb */
10836409Ssklower 	int		(*nlp_getnetaddr)();	/* gets addresses from nl pcb */
10936409Ssklower 	int		(*nlp_putsufx)();		/* puts transport suffixes in nl pcb */
11036409Ssklower 	int		(*nlp_getsufx)();		/* gets transport suffixes from nl pcb */
11136409Ssklower 	int		(*nlp_recycle_suffix)();/* clears suffix from nl pcb */
11236409Ssklower 	int		(*nlp_mtu)();			/* figures out mtu based on nl used */
11336409Ssklower 	int		(*nlp_pcbbind)();		/* bind to pcb for net level */
11436409Ssklower 	int		(*nlp_pcbconn)();		/* connect for net level */
11536409Ssklower 	int		(*nlp_pcbdisc)();		/* disconnect net level */
11636409Ssklower 	int		(*nlp_pcbdetach)();		/* detach net level pcb */
11736409Ssklower 	int		(*nlp_pcballoc)();		/* allocate a net level pcb */
11836409Ssklower 	int		(*nlp_output)();		/* prepare a packet to give to nl */
11936409Ssklower 	int		(*nlp_dgoutput)();		/* prepare a packet to give to nl */
12036409Ssklower 	int		(*nlp_ctloutput)();		/* hook for network set/get options */
12136409Ssklower 	caddr_t	nlp_pcblist;			/* list of xx_pcb's for connections */
12236409Ssklower } nl_protosw[];
12336409Ssklower 
12436409Ssklower 
12536409Ssklower struct tp_pcb {
12636409Ssklower 	u_short 			tp_state;		/* state of fsm */
12736409Ssklower 	short 				tp_retrans;		/* # times can still retrans */
12836409Ssklower 	struct tp_ref 		*tp_refp;		/* rest of pcb	*/
12936409Ssklower 	caddr_t				tp_npcb;		/* to lower layer pcb */
13036409Ssklower 	struct nl_protosw	*tp_nlproto;	/* lower-layer dependent routines */
13136409Ssklower 	struct socket 		*tp_sock;		/* back ptr */
13236409Ssklower 
13336409Ssklower 
13436409Ssklower 	RefNum				tp_lref;	 	/* local reference */
13536409Ssklower 	RefNum 				tp_fref;		/* foreign reference */
13636409Ssklower 
13736409Ssklower 	u_int				tp_seqmask;		/* mask for seq space */
13836409Ssklower 	u_int				tp_seqbit;		/* bit for seq number wraparound */
13936409Ssklower 	u_int				tp_seqhalf;		/* half the seq space */
14036409Ssklower 
14136409Ssklower 	/* credit & sequencing info for SENDING */
14236409Ssklower 	u_short 			tp_fcredit;		/* current remote credit in # packets */
14336409Ssklower 
14436409Ssklower 	u_short				tp_cong_win;	/* congestion window : set to 1 on
14536409Ssklower 										 * source quench
14636409Ssklower 										 * Minimizes the amount of retrans-
14736409Ssklower 										 * missions (independently of the
14836409Ssklower 										 * retrans strategy).  Increased
14936409Ssklower 										 * by one for each good ack received.
15036409Ssklower 										 * Minimizes the amount sent in a
15136409Ssklower 										 * regular tp_send() also.
15236409Ssklower 										 */
15336409Ssklower 	SeqNum				tp_snduna;		/* seq # of lowest unacked DT */
15436409Ssklower 	struct tp_rtc		*tp_snduna_rtc;	/* lowest unacked stuff sent so far */
15536409Ssklower 	SeqNum				tp_sndhiwat;	/* highest seq # sent so far */
15636409Ssklower 	struct tp_rtc		*tp_sndhiwat_rtc;	/* last stuff sent so far */
15736409Ssklower 	int					tp_Nwindow;		/* for perf. measurement */
15837469Ssklower 	struct mbuf			*tp_ucddata;	/* user connect/disconnect data */
15936409Ssklower 
16036409Ssklower 	/* credit & sequencing info for RECEIVING */
16136409Ssklower 	SeqNum	 			tp_sent_lcdt;	/* cdt according to last ack sent */
16236409Ssklower 	SeqNum	 			tp_sent_uwe;	/* uwe according to last ack sent */
16336409Ssklower 	SeqNum	 			tp_sent_rcvnxt;	/* rcvnxt according to last ack sent
16436409Ssklower 										 * needed for perf measurements only
16536409Ssklower 										 */
16636409Ssklower 	u_short				tp_lcredit;		/* current local credit in # packets */
16736409Ssklower 	SeqNum				tp_rcvnxt;		/* next DT seq # expect to recv */
16836409Ssklower 	struct tp_rtc		*tp_rcvnxt_rtc;	/* unacked stuff recvd out of order */
16936409Ssklower 
17036409Ssklower 	/* parameters per-connection controllable by user */
17136409Ssklower 	struct tp_conn_param _tp_param;
17236409Ssklower 
17336409Ssklower #define	tp_Nretrans _tp_param.p_Nretrans
17436409Ssklower #define	tp_dr_ticks _tp_param.p_dr_ticks
17536409Ssklower #define	tp_cc_ticks _tp_param.p_cc_ticks
17636409Ssklower #define	tp_dt_ticks _tp_param.p_dt_ticks
17736409Ssklower #define	tp_xpd_ticks _tp_param.p_x_ticks
17836409Ssklower #define	tp_cr_ticks _tp_param.p_cr_ticks
17936409Ssklower #define	tp_keepalive_ticks _tp_param.p_keepalive_ticks
18036409Ssklower #define	tp_sendack_ticks _tp_param.p_sendack_ticks
18136409Ssklower #define	tp_refer_ticks _tp_param.p_ref_ticks
18236409Ssklower #define	tp_inact_ticks _tp_param.p_inact_ticks
18336409Ssklower #define	tp_xtd_format _tp_param.p_xtd_format
18436409Ssklower #define	tp_xpd_service _tp_param.p_xpd_service
18536409Ssklower #define	tp_ack_strat _tp_param.p_ack_strat
18636409Ssklower #define	tp_rx_strat _tp_param.p_rx_strat
18736409Ssklower #define	tp_use_checksum _tp_param.p_use_checksum
18836409Ssklower #define	tp_use_efc _tp_param.p_use_efc
18936409Ssklower #define	tp_use_nxpd _tp_param.p_use_nxpd
19036409Ssklower #define	tp_use_rcc _tp_param.p_use_rcc
19136409Ssklower #define	tp_tpdusize _tp_param.p_tpdusize
19236409Ssklower #define	tp_class _tp_param.p_class
19336409Ssklower #define	tp_winsize _tp_param.p_winsize
19436409Ssklower #define	tp_no_disc_indications _tp_param.p_no_disc_indications
19536409Ssklower #define	tp_dont_change_params _tp_param.p_dont_change_params
19636409Ssklower #define	tp_netservice _tp_param.p_netservice
19736409Ssklower 
19836409Ssklower 	int tp_l_tpdusize;
19936409Ssklower 		/* whereas tp_tpdusize is log2(the negotiated max size)
20036409Ssklower 		 * l_tpdusize is the size we'll use when sending, in # chars
20136409Ssklower 		 */
20236409Ssklower 
20336409Ssklower 	struct timeval	tp_rtv;					/* max round-trip time variance */
20436409Ssklower 	struct timeval	tp_rtt; 					/* smoothed round-trip time */
20536409Ssklower 	struct timeval 	tp_rttemit[ TP_RTT_NUM + 1 ];
20636409Ssklower 					/* times that the last TP_RTT_NUM DT_TPDUs were emitted */
20736409Ssklower 	unsigned
20836409Ssklower 		tp_sendfcc:1,			/* shall next ack include FCC parameter? */
20936409Ssklower 		tp_trace:1,				/* is this pcb being traced? (not used yet) */
21036409Ssklower 		tp_perf_on:1,			/* 0/1 -> performance measuring on  */
21136409Ssklower 		tp_reneged:1,			/* have we reneged on cdt since last ack? */
21236409Ssklower 		tp_decbit:4,			/* dec bit was set, we're in reneg mode  */
21336409Ssklower 		tp_flags:8,				/* values: */
21436409Ssklower #define TPF_CONN_DATA_OUT	TPFLAG_CONN_DATA_OUT
21536409Ssklower #define TPF_CONN_DATA_IN	TPFLAG_CONN_DATA_IN
21636409Ssklower #define TPF_DISC_DATA_IN	TPFLAG_DISC_DATA_IN
21736409Ssklower #define TPF_DISC_DATA_OUT	TPFLAG_DISC_DATA_OUT
21836409Ssklower #define TPF_XPD_PRESENT 	TPFLAG_XPD_PRESENT
21936409Ssklower #define TPF_NLQOS_PDN	 	TPFLAG_NLQOS_PDN
22036409Ssklower #define TPF_PEER_ON_SAMENET	TPFLAG_PEER_ON_SAMENET
22136409Ssklower 
22236409Ssklower #define PEER_IS_LOCAL(t) \
22336409Ssklower 			(((t)->tp_flags & TPF_PEER_ON_SAME_NET)==TPF_PEER_ON_SAME_NET)
22436409Ssklower #define USES_PDN(t)	\
22536409Ssklower 			(((t)->tp_flags & TPF_NLQOS_PDN)==TPF_NLQOS_PDN)
22636409Ssklower 
22736409Ssklower 		tp_unused:16;
22836409Ssklower 
22936409Ssklower 
23036409Ssklower #ifdef TP_PERF_MEAS
23136409Ssklower 	/* performance stats - see tp_stat.h */
23237469Ssklower 	struct tp_pmeas		*tp_p_meas;
23337469Ssklower 	struct mbuf			*tp_p_mbuf;
23436409Ssklower #endif TP_PERF_MEAS
23537469Ssklower 	/* addressing */
23637469Ssklower 	u_short				tp_domain;		/* domain (INET, ISO) */
23737469Ssklower 	/* for compatibility with the *old* way and with INET, be sure that
23837469Ssklower 	 * that lsuffix and fsuffix are aligned to a short addr.
23937469Ssklower 	 * having them follow the u_short *suffixlen should suffice (choke)
24037469Ssklower 	 */
24137469Ssklower 	u_short				tp_fsuffixlen;	/* foreign suffix */
24237469Ssklower 	char				tp_fsuffix[MAX_TSAP_SEL_LEN];
24337469Ssklower 	u_short				tp_lsuffixlen;	/* local suffix */
24437469Ssklower 	char				tp_lsuffix[MAX_TSAP_SEL_LEN];
24537469Ssklower #define SHORT_LSUFXP(tpcb) ((short *)((tpcb)->tp_lsuffix))
24637469Ssklower #define SHORT_FSUFXP(tpcb) ((short *)((tpcb)->tp_fsuffix))
24737469Ssklower 
24837469Ssklower 	u_char 				tp_vers;		/* protocol version */
24937469Ssklower 	u_char 				tp_peer_acktime; /* used to compute DT retrans time */
25037469Ssklower 
25137469Ssklower 	struct sockbuf		tp_Xsnd;		/* for expedited data */
25237469Ssklower /*	struct sockbuf		tp_Xrcv;		/* for expedited data */
25337469Ssklower #define tp_Xrcv tp_sock->so_rcv
25437469Ssklower 	SeqNum				tp_Xsndnxt;	/* next XPD seq # to send */
25537469Ssklower 	SeqNum				tp_Xuna;		/* seq # of unacked XPD */
25637469Ssklower 	SeqNum				tp_Xrcvnxt;	/* next XPD seq # expect to recv */
25737469Ssklower 
25837469Ssklower 	/* AK subsequencing */
25937469Ssklower 	u_short				tp_s_subseq;	/* next subseq to send */
26037469Ssklower 	u_short				tp_r_subseq;	/* highest recv subseq */
26137469Ssklower 
26236409Ssklower };
26336409Ssklower 
26436409Ssklower extern struct timeval 	time;
26536409Ssklower extern struct tp_ref 	tp_ref[];
26636409Ssklower extern struct tp_param	tp_param;
26736409Ssklower 
26836409Ssklower #define	sototpcb(so) 	((struct tp_pcb *)(so->so_tpcb))
26936409Ssklower #define	sototpref(so)	((struct tp_ref *)((so)->so_tpcb->tp_ref))
27036409Ssklower #define	tpcbtoso(tp)	((struct socket *)((tp)->tp_sock))
27136409Ssklower #define	tpcbtoref(tp)	((struct tp_ref *)((tp)->tp_ref))
27236409Ssklower 
27336409Ssklower #endif  __TP_PCB__
274