149268Sbostic /*- 249268Sbostic * Copyright (c) 1991 The Regents of the University of California. 349268Sbostic * All rights reserved. 449268Sbostic * 549268Sbostic * %sccs.include.redist.c% 649268Sbostic * 7*50975Ssklower * @(#)tp_param.h 7.9 (Berkeley) 09/03/91 849268Sbostic */ 949268Sbostic 1036407Ssklower /*********************************************************** 1136407Ssklower Copyright IBM Corporation 1987 1236407Ssklower 1336407Ssklower All Rights Reserved 1436407Ssklower 1536407Ssklower Permission to use, copy, modify, and distribute this software and its 1636407Ssklower documentation for any purpose and without fee is hereby granted, 1736407Ssklower provided that the above copyright notice appear in all copies and that 1836407Ssklower both that copyright notice and this permission notice appear in 1936407Ssklower supporting documentation, and that the name of IBM not be 2036407Ssklower used in advertising or publicity pertaining to distribution of the 2136407Ssklower software without specific, written prior permission. 2236407Ssklower 2336407Ssklower IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 2436407Ssklower ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 2536407Ssklower IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 2636407Ssklower ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 2736407Ssklower WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 2836407Ssklower ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 2936407Ssklower SOFTWARE. 3036407Ssklower 3136407Ssklower ******************************************************************/ 3236407Ssklower 3336407Ssklower /* 3436407Ssklower * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison 3536407Ssklower */ 3636407Ssklower /* 3736407Ssklower * ARGO TP 3836407Ssklower * 3936407Ssklower * $Header: tp_param.h,v 5.3 88/11/18 17:28:18 nhall Exp $ 4036407Ssklower * $Source: /usr/argo/sys/netiso/RCS/tp_param.h,v $ 4136407Ssklower * 4236407Ssklower */ 4336407Ssklower 4436407Ssklower #ifndef __TP_PARAM__ 4536407Ssklower #define __TP_PARAM__ 4636407Ssklower 4736407Ssklower 4836407Ssklower /****************************************************** 4936407Ssklower * compile time parameters that can be changed 5036407Ssklower *****************************************************/ 5136407Ssklower 5236407Ssklower #define TP_CLASSES_IMPLEMENTED 0x11 /* zero and 4 */ 5336407Ssklower 5436407Ssklower #define TP_DECBIT_CLEAR_COUNT 3 5536407Ssklower 5648750Ssklower /*#define N_TPREF 100 */ 5748750Ssklower #ifdef KERNEL 5848750Ssklower extern int N_TPREF; 5948750Ssklower #endif 6036407Ssklower 6137469Ssklower #define TP_SOCKBUFSIZE ((u_long)4096) 6237469Ssklower #define TP0_SOCKBUFSIZE ((u_long)512) 6336407Ssklower #define MAX_TSAP_SEL_LEN 64 6436407Ssklower 6536407Ssklower /* maximum tpdu size we'll accept: */ 6636407Ssklower #define TP_TPDUSIZE 0xc /* 4096 octets for classes 1-4*/ 6736407Ssklower #define TP0_TPDUSIZE 0xb /* 2048 octets for class 0 */ 6836407Ssklower #define TP_DFL_TPDUSIZE 0x7 /* 128 octets default */ 6936407Ssklower /* NOTE: don't ever negotiate 8192 because could get 7036407Ssklower * wraparound in checksumming 7136407Ssklower * (No mtu is likely to be larger than 4K anyway...) 7236407Ssklower */ 7348750Ssklower #define TP_NRETRANS 5 /* was 1; cray uses 6 */ 7436407Ssklower #define TP_MAXPORT 0xefff 7536407Ssklower 7636407Ssklower #define TP_RTT_NUM 0x7 7736407Ssklower /* ALPHA: to be used in the context: gain= 1/(2**alpha), or 7836407Ssklower * put another way, gaintimes(x) (x)>>alpha (forgetting the case alpha==0) 7936407Ssklower */ 8036407Ssklower #define TP_RTT_ALPHA 3 8136407Ssklower #define TP_RTV_ALPHA 2 8236407Ssklower 8336407Ssklower /* 8436407Ssklower * not sure how to treat data on disconnect 8536407Ssklower */ 8636407Ssklower #define T_CONN_DATA 0x1 8736407Ssklower #define T_DISCONNECT 0x2 8836407Ssklower #define T_DISC_DATA 0x4 8936407Ssklower #define T_XDATA 0x8 9036407Ssklower 9136407Ssklower #define ISO_CLNS 0 9236407Ssklower #define IN_CLNS 1 9336407Ssklower #define ISO_CONS 2 9436407Ssklower #define ISO_COSNS 3 9536407Ssklower #define TP_MAX_NETSERVICES 3 9636407Ssklower 9736407Ssklower /* Indices into tp stats ackreason[i] */ 9836407Ssklower #define _ACK_DONT_ 0 9936407Ssklower #define _ACK_STRAT_EACH_ 0x1 10036407Ssklower #define _ACK_STRAT_FULLWIN_ 0x2 10136407Ssklower #define _ACK_DUP_ 0x3 10236407Ssklower #define _ACK_EOT_ 0x4 10336407Ssklower #define _ACK_REORDER_ 0x5 10436407Ssklower #define _ACK_USRRCV_ 0x6 10536407Ssklower #define _ACK_FCC_ 0x7 10636407Ssklower #define _ACK_NUM_REASONS_ 0x8 10736407Ssklower 10836407Ssklower /* masks for use in tp_stash() */ 10936407Ssklower #define ACK_DONT 0 11036407Ssklower #define ACK_STRAT_EACH (1<< _ACK_STRAT_EACH_) 11136407Ssklower #define ACK_STRAT_FULLWIN (1<< _ACK_STRAT_FULLWIN_) 11236407Ssklower #define ACK_DUP (1<< _ACK_DUP_) 11336407Ssklower #define ACK_EOT (1<< _ACK_EOT_) 11436407Ssklower #define ACK_REORDER (1<< _ACK_REORDER_) 11536407Ssklower 11636407Ssklower /****************************************************** 11736407Ssklower * constants used in the protocol 11836407Ssklower *****************************************************/ 11936407Ssklower 12036407Ssklower #define TP_VERSION 0x1 12136407Ssklower 12236407Ssklower #define TP_MAX_HEADER_LEN 256 12336407Ssklower 12436407Ssklower #define TP_MIN_TPDUSIZE 0x7 /* 128 octets */ 12536407Ssklower #define TP_MAX_TPDUSIZE 0xd /* 8192 octets */ 12636407Ssklower 12736407Ssklower #define TP_MAX_XPD_DATA 0x10 /* 16 octets */ 12836407Ssklower #define TP_MAX_CC_DATA 0x20 /* 32 octets */ 12936407Ssklower #define TP_MAX_CR_DATA TP_MAX_CC_DATA 13036407Ssklower #define TP_MAX_DR_DATA 0x40 /* 64 octets */ 13136407Ssklower 13236407Ssklower #define TP_XTD_FMT_BIT 0x80000000 13336407Ssklower #define TP_XTD_FMT_MASK 0x7fffffff 13436407Ssklower #define TP_NML_FMT_BIT 0x80 13536407Ssklower #define TP_NML_FMT_MASK 0x7f 13636407Ssklower 13736407Ssklower /* 13836407Ssklower * values for the tpdu_type field, 2nd byte in a tpdu 13936407Ssklower */ 14036407Ssklower 14136407Ssklower #define TP_MIN_TPDUTYPE 0x1 14236407Ssklower 14336407Ssklower #define XPD_TPDU_type 0x1 14436407Ssklower #define XAK_TPDU_type 0x2 14536407Ssklower #define GR_TPDU_type 0x3 14636407Ssklower #define AK_TPDU_type 0x6 14736407Ssklower #define ER_TPDU_type 0x7 14836407Ssklower #define DR_TPDU_type 0x8 14936407Ssklower #define DC_TPDU_type 0xc 15036407Ssklower #define CC_TPDU_type 0xd 15136407Ssklower #define CR_TPDU_type 0xe 15236407Ssklower #define DT_TPDU_type 0xf 15336407Ssklower 15436407Ssklower #define TP_MAX_TPDUTYPE 0xf 15536407Ssklower 15636407Ssklower /* 15736407Ssklower * identifiers for the variable-length options in tpdus 15836407Ssklower */ 15936407Ssklower 16036407Ssklower #define TPP_acktime 0x85 16136407Ssklower #define TPP_residER 0x86 16236407Ssklower #define TPP_priority 0x87 16336407Ssklower #define TPP_transdelay 0x88 16436407Ssklower #define TPP_throughput 0x89 16536407Ssklower #define TPP_subseq 0x8a 16636407Ssklower #define TPP_flow_cntl_conf 0x8c /* not implemented */ 16736407Ssklower #define TPP_addl_info 0xe0 16836407Ssklower #define TPP_tpdu_size 0xc0 16936407Ssklower #define TPP_calling_sufx 0xc1 17036407Ssklower #define TPP_invalid_tpdu 0xc1 /* the bozos used a value twice */ 17136407Ssklower #define TPP_called_sufx 0xc2 17236407Ssklower #define TPP_checksum 0xc3 17336407Ssklower #define TPP_vers 0xc4 17436407Ssklower #define TPP_security 0xc5 17536407Ssklower #define TPP_addl_opt 0xc6 17636407Ssklower #define TPP_alt_class 0xc7 17736407Ssklower #define TPP_perf_meas 0xc8 /* local item : perf meas on, svp */ 17836407Ssklower 17936407Ssklower /****************************************************** 18036407Ssklower * Some fundamental data types 18136407Ssklower *****************************************************/ 18236407Ssklower #ifndef TRUE 18336407Ssklower #define TRUE 1 18436407Ssklower #endif TRUE 18536407Ssklower 18636407Ssklower #ifndef FALSE 18736407Ssklower #define FALSE 0 18836407Ssklower #endif FALSE 18936407Ssklower 19036407Ssklower #define TP_LOCAL 22 19136407Ssklower #define TP_FOREIGN 33 19236407Ssklower 19336407Ssklower #ifndef EOK 19436407Ssklower #define EOK 0 19536407Ssklower #endif EOK 19636407Ssklower 19736407Ssklower #define TP_CLASS_0 (1<<0) 19836407Ssklower #define TP_CLASS_1 (1<<1) 19936407Ssklower #define TP_CLASS_2 (1<<2) 20036407Ssklower #define TP_CLASS_3 (1<<3) 20136407Ssklower #define TP_CLASS_4 (1<<4) 20236407Ssklower 20336407Ssklower #define TP_FORCE 0x1 20436407Ssklower #define TP_STRICT 0x2 20536407Ssklower 20636407Ssklower #ifndef MNULL 20736407Ssklower #define MNULL (struct mbuf *)0 20836407Ssklower #endif MNULL 20937536Smckusick /* if ../sys/mbuf.h gets MT_types up to 0x40, these will 21036407Ssklower * have to be changed: 21136407Ssklower */ 21236407Ssklower #define MT_XPD 0x44 21336407Ssklower #define MT_EOT 0x40 21436407Ssklower 21536407Ssklower #define TP_ENOREF 0x80000000 21636407Ssklower 21736407Ssklower typedef unsigned int SeqNum; 21836407Ssklower typedef unsigned short RefNum; 21936407Ssklower typedef int ProtoHook; 22036407Ssklower 22136407Ssklower 22236407Ssklower /****************************************************** 22336407Ssklower * Some fundamental constants 22436407Ssklower *****************************************************/ 22536407Ssklower 22636407Ssklower #define TP_MIN_WIN 2048 22736407Ssklower #define TP_MAX_WIN 16384 22836407Ssklower #define TP_MAX_WIN_UNPRIV 8192 22936407Ssklower 23036407Ssklower /****************************************************** 23136407Ssklower * Macro used all over, for driver 23236407Ssklower *****************************************************/ 23336407Ssklower 23436407Ssklower #define DoEvent(x) \ 23536407Ssklower ((E.ev_number=(x)),(tp_driver(tpcb,&E))) 23636407Ssklower 23736407Ssklower /****************************************************** 23836407Ssklower * Some macros used all over, for timestamping 23936407Ssklower *****************************************************/ 24036407Ssklower 24136407Ssklower #define GET_CUR_TIME(tvalp) ((*tvalp) = time) 24236407Ssklower 24336407Ssklower #define GET_TIME_SINCE(oldtvalp, diffp) {\ 24436407Ssklower (diffp)->tv_sec = time.tv_sec - (oldtvalp)->tv_sec;\ 24536407Ssklower (diffp)->tv_usec = time.tv_usec - (oldtvalp)->tv_usec;\ 24636407Ssklower if( (diffp)->tv_usec <0 ) {\ 24736407Ssklower (diffp)->tv_sec --;\ 24836407Ssklower (diffp)->tv_usec = 1000000 - (diffp)->tv_usec;\ 24936407Ssklower }\ 25036407Ssklower } 25136407Ssklower 25236407Ssklower /****************************************************** 25336407Ssklower * Some macros used for address families 25436407Ssklower *****************************************************/ 25536407Ssklower 25636407Ssklower #define satosiso(ADDR) ((struct sockaddr_iso *)(ADDR)) 25736407Ssklower #define satosin(ADDR) ((struct sockaddr_in *)(ADDR)) 25836407Ssklower 25936407Ssklower /****************************************************** 26036407Ssklower * Macro used for changing types of mbufs 26136407Ssklower *****************************************************/ 26236407Ssklower 26336407Ssklower #define CHANGE_MTYPE(m, TYPE)\ 26436407Ssklower if((m)->m_type != TYPE) { \ 26536407Ssklower mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[TYPE]++; \ 26636407Ssklower (m)->m_type = TYPE; \ 26736407Ssklower } 26836407Ssklower 26936407Ssklower /****************************************************** 27036407Ssklower * Macros used for adding options to a tpdu header and for 27136407Ssklower * parsing the headers. 27236407Ssklower * Options are variable-length and must be bcopy-d because on the 27336407Ssklower * RT your assignments must be N-word aligned for objects of length 27436407Ssklower * N. Such a drag. 27536407Ssklower *****************************************************/ 27636407Ssklower 27736407Ssklower struct tp_vbp { 27836407Ssklower u_char tpv_code; 27936407Ssklower char tpv_len; 28036407Ssklower char tpv_val; 28136407Ssklower }; 28236407Ssklower #define vbptr(x) ((struct tp_vbp *)(x)) 28336407Ssklower #define vbval(x,type) (*((type *)&(((struct tp_vbp *)(x))->tpv_val))) 28436407Ssklower #define vbcode(x) (vbptr(x)->tpv_code) 28536407Ssklower #define vblen(x) (vbptr(x)->tpv_len) 28636407Ssklower 28736407Ssklower #define vb_putval(dst,type,src)\ 28836407Ssklower bcopy((caddr_t)&(src),(caddr_t)&(((struct tp_vbp *)(dst))->tpv_val),\ 28936407Ssklower sizeof(type)) 29036407Ssklower 29136407Ssklower #define vb_getval(src,type,dst)\ 29236407Ssklower bcopy((caddr_t)&(((struct tp_vbp *)(src))->tpv_val),(caddr_t)&(dst),sizeof(type)) 29336407Ssklower 29436407Ssklower #define ADDOPTION(type, DU, len, src)\ 29536407Ssklower { register caddr_t P;\ 29636407Ssklower P = (caddr_t)(DU) + (int)((DU)->tpdu_li);\ 29736407Ssklower vbptr(P)->tpv_code = type;\ 29836407Ssklower vbptr(P)->tpv_len = len;\ 29937469Ssklower bcopy((caddr_t)&src, (caddr_t)&(vbptr(P)->tpv_val), (unsigned)len);\ 30036407Ssklower DU->tpdu_li += len+2;/* 1 for code, 1 for length */\ 30136407Ssklower } 30236407Ssklower /****************************************************** 30336407Ssklower * Macro for the local credit: 30436407Ssklower * uses max transmission unit for the ll 30536407Ssklower * (as modified by the max TPDU size negotiated) 30636407Ssklower *****************************************************/ 30736407Ssklower 30836407Ssklower #if defined(ARGO_DEBUG)&&!defined(LOCAL_CREDIT_EXPAND) 30936407Ssklower #define LOCAL_CREDIT(tpcb) tp_local_credit(tpcb) 31036407Ssklower #else 311*50975Ssklower #define LOCAL_CREDIT(tpcb) {\ 31239920Ssklower register struct sockbuf *xxsb = &((tpcb)->tp_sock->so_rcv);\ 313*50975Ssklower register int xxi = sbspace(xxsb);\ 314*50975Ssklower xxi = (xxi<0) ? 0 : ((xxi) / (tpcb)->tp_l_tpdusize);\ 315*50975Ssklower xxi = min(xxi, (tpcb)->tp_maxlcredit); \ 31639920Ssklower if (!(tpcb->tp_cebit_off)) { \ 31739920Ssklower (tpcb)->tp_lcredit = ROUND((tpcb)->tp_win_recv); \ 31839920Ssklower if (xxi < (tpcb)->tp_lcredit) { \ 31939920Ssklower (tpcb)->tp_lcredit = xxi; \ 32039920Ssklower } \ 32139920Ssklower } \ 32239920Ssklower else { \ 32339920Ssklower (tpcb)->tp_lcredit = xxi; \ 32439920Ssklower } \ 32536407Ssklower } 32636407Ssklower #endif ARGO_DEBUG 32736407Ssklower 32836407Ssklower #ifdef KERNEL 329*50975Ssklower #ifdef ARGO_DEBUG 330*50975Ssklower #include "syslog.h" 331*50975Ssklower #define printf logpri(LOG_DEBUG),addlog 332*50975Ssklower #endif 33336407Ssklower 33436407Ssklower #ifndef tp_NSTATES 33536407Ssklower 33636407Ssklower #include "tp_states.h" 33736407Ssklower #include "tp_events.h" 33850236Ssklower #if defined(__STDC__) || defined(__cplusplus) 33950236Ssklower #undef ATTR 34050236Ssklower #define ATTR(X) ev_union.EV_ ## X 34150236Ssklower #endif /* defined(__STDC__) || defined(__cplusplus) */ 34236407Ssklower 34336407Ssklower #endif tp_NSTATES 34436407Ssklower #endif KERNEL 34536407Ssklower 34636407Ssklower #endif __TP_PARAM__ 347