1: /*      enetdefs.h	Stanford	25 April 1983 */
   2: 
   3: /* Notes:
   4:  *	- check maxwaiting, etc.
   5:  *	- Xdrops in enState may be meaningless
   6:  */
   7: 
   8: /*
   9:  *  Ethernet definitions NOT needed for user processes
  10:  *
  11:  **********************************************************************
  12:  * HISTORY
  13:  * 7 October 1985	Jeff Mogul	Stanford
  14:  *	Removed ENMAXOPENS limitation; available minors are now
  15:  *	dynamically allocated to interfaces.
  16:  *	Certain arrays in the enState structure are now indirected
  17:  *	via pointers.
  18:  * 17 October 1984	Jeff Mogul	Stanford
  19:  *	Added RecvCount filed to enOpenDescriptor struct to store count
  20:  *	of packets received on this filter.
  21:  *	Also, made some changes to encourage use of "high-priority"
  22:  *	devices:
  23:  *	- changed ENHIPRIDEV from 12 to 0; allows anyone to use
  24:  *		high priority
  25:  *	- changed ENHIPRI from 128 to 2; no point in having more than
  26:  *		one priority below ENHIPRI, since all would be equivalent.
  27:  *
  28:  * 2 October 1984	Jeff Mogul	Stanford
  29:  *	Added field to enOpenDescriptor struct to store pre-computed
  30:  *	address of short word AFTER last valid word in the filter;
  31:  *	this saves a few instructions in some very busy code.
  32:  *
  33:  * 10 November 1983	Jeffrey Mogul	Stanford
  34:  *	Minor changes to support EIOCDEVP ioctl,
  35:  *	removed references to enUnit[]
  36:  *
  37:  * 25-Apr-83	Jeffrey Mogul	Stanford
  38:  *	Began conversion to 4.2BSD.  This involves removing all
  39:  *	references to the actual hardware.
  40:  *	Most previous history comments removed.
  41:  *	Split off from definitions of interest to users.
  42:  *
  43:  * 10-Aug-82  Mike Accetta (mja) at Carnegie-Mellon University
  44:  *	Added EIOCMBIS and EIOCMBIC definitions, and new ENHOLDSIG mode
  45:  *	bit and ENPRIVMODES defintions (V3.05e). [Last change before
  46:  *	4.2BSD conversion starts.]
  47:  *
  48:  * 22-Feb-80  Rick Rashid (rfr) at Carnegie-Mellon University
  49:  *	Rewritten for multiple simultaneous opens with filters (V1.05).
  50:  *
  51:  * 18-Jan-80  Mike Accetta (mja) at Carnegie-Mellon University
  52:  *      Created (V1.00).
  53:  *
  54:  **********************************************************************
  55:  */
  56: 
  57: /* tunable constants */
  58: #define ENHIPRI     2       /* high priority priority */
  59:             /*
  60: 			 * setting ENHIPRI to 2 makes sense because all
  61: 			 * priorities below ENHIPRI are equivalent; therefore,
  62: 			 * we only need one of them.
  63: 			 */
  64: #define ENMAXPRI    255     /* maximum high priority priority */
  65: 
  66: #define ENUNIT(dev) (enUnitMap[minor(dev)]) /* macro */
  67:                     /* to extract ethernet unit number */
  68:                     /* from device number (used as the */
  69:                     /* index into the enState[] table); */
  70: #define ENINDEX(dev)    (minor(dev)) /* macro to extract logical */
  71:                     /* device index from device number */
  72:                     /* (used as the index into the */
  73:                     /* AllDescriptors table for the */
  74:                     /* unit) */
  75: 
  76: #define ENMAXWAITING    8       /* maximum number of packets */
  77:                     /* which can be queued at one time */
  78:                     /* for an open enet file (max 256) */
  79: #define ENDEFWAITING    2       /* default number of packets */
  80:                     /* which can be queued at one */
  81:                     /* time for an open enet file */
  82: #define ENPACKETS   50      /* number of preallocated packets */
  83:                     /* available for receiving (these
  84: 					/* should be allocated dynamically */
  85:                     /* once the system makes */
  86:                     /* this more feasible) */
  87: 
  88: #define ENMINSCAVENGE   4       /* minimum number of packets */
  89:                     /* guaranteed to be freed by */
  90:                     /* scavenging */
  91: 
  92: /*
  93:  * Privileged mode bits
  94:  */
  95: #define ENKERNEL    (0x8000)    /* flag bit to indicate kernel mode */
  96:                     /*  requests */
  97: 
  98: /*
  99:  *  The following definitions are meant to clean up
 100:  *  C language syntax a bit.
 101:  */
 102: 
 103: typedef enum {false, true}  boolean;
 104: #define TRUE    ((int)true)
 105: #define FALSE   ((int)false)
 106: 
 107: #define endcase break;
 108: 
 109: /*
 110:  * General purpose structure to define circular queues.
 111:  *  Both the queue header and the queue elements have this
 112:  *  structure.
 113:  */
 114: 
 115: struct Queue
 116: {
 117:     struct Queue * F;
 118:     struct Queue * B;
 119: };
 120: 
 121: #ifdef notdef
 122: /* Temporary used by queue macros. */
 123: struct Queue * q_tmp;
 124: 
 125: #define enqueue(head,elt) \
 126: { (elt)->F = (head);(elt)->B = (head)->B;(head)->B = (elt);((elt)->B)->F = (elt); };
 127: 
 128: #define remqueue(head,elt) \
 129:     { ((elt)->B)->F = (elt)->F; ((elt)->F)->B = (elt)->B; };
 130: 
 131: #define dequeue(head)             \
 132:     (((q_tmp = (head)->F) == (head)) ? NULL : \
 133:      (((q_tmp->B)->F = q_tmp->F),         \
 134:       ((q_tmp->F)->B = q_tmp->B),     \
 135:       (q_tmp)))
 136: 
 137: #define queueempty(head) \
 138:     ((head)->F == (head))
 139: 
 140: #define initqueue(head)  \
 141:     { (head)->F = (head); (head)->B = (head); };
 142: #endif notdef
 143: 
 144: /*
 145:  *  The ethernet packet structure.
 146:  *
 147:  */
 148: 
 149: struct enPacket
 150: {
 151:     struct Queue   enP_Link;        /* queue pointers */
 152:     u_short   *enP_Data;        /* pointer to start of packet */
 153:     short          enP_ByteCount;   /* # of bytes in Data */
 154:     u_short    enP_RefCount;    /* # of outstanding references to */
 155:                     /* this packet */
 156:     struct mbuf   *enP_mbuf;        /* first mbuf of packet */
 157: };
 158: #define enP_F   enP_Link.F
 159: #define enP_B   enP_Link.B
 160: 
 161: /*
 162:  *  Ethernet queue header
 163:  */
 164: struct enQueue
 165: {
 166:     struct Queue enQ_Head;  /* queue header and trailer pointers */
 167:     short    enQ_NumQueued; /* number of elements in queue */
 168: };
 169: #define enQ_F   enQ_Head.F
 170: #define enQ_B   enQ_Head.B
 171: 
 172: /*
 173:  *  Wait queue header
 174:  */
 175: struct enWaitQueue
 176: {
 177:     struct enPacket *enWQ_Packets[ENMAXWAITING];/* pointers to queued packets */
 178:     char         enWQ_Head;     /* index into Packets (for dequeue) */
 179:     char         enWQ_Tail;     /* index into Packets (for enqueue) */
 180:     u_char       enWQ_NumQueued;    /* current queue size */
 181:     u_char       enWQ_MaxWaiting;   /* threshold for additions */
 182: };
 183: #define enNextWaitQueueIndex(idx)                   \
 184:     if (++(idx) >= ENMAXWAITING) (idx) = 0
 185: #define enPrevWaitQueueIndex(idx)                   \
 186:     if (--(idx) < 0) (idx) = (ENMAXWAITING-1)
 187: 
 188: /*
 189:  *  States of receive side of open enet file.
 190:  */
 191: enum enStates {ENRECVIDLE, ENRECVTIMING, ENRECVTIMEDOUT};
 192: 
 193: struct enOpenDescriptor
 194: {
 195:     struct Queue       enOD_Link;   /* Linked list of OpenDescriptors */
 196:     struct enWaitQueue enOD_Waiting;    /* fixed Queue of waiting packets */
 197:     struct proc       *enOD_SigProc;    /* Process to signal (user mode) */
 198:     short          enOD_SigPid; /* Process ID of process to signal */
 199:     short              enOD_SigNumb;    /* Signal number for input packet */
 200:                     /* notification  */
 201:     long               enOD_Timeout;    /* Length of time to wait for packet */
 202:     struct enfilter    enOD_OpenFilter; /* Packet filter */
 203:     enum enStates      enOD_RecvState;  /* see enStates enumeration (above) */
 204:     short          enOD_Flag;   /* option bits */
 205: 
 206:     /* following are for enetselect() */
 207:     short          enOD_SelColl;    /* true if selects collide */
 208:     struct proc       *enOD_SelProc;    /* process that last selected us */
 209: 
 210:     unsigned long      enOD_RecvCount;  /* number of packets received */
 211: 
 212:     /* store precomputed address of end of filter */
 213:     unsigned short    *enOD_FiltEnd;    /* addr of short AFTER end of filt */
 214: };
 215: 
 216: /*
 217:  *  State descriptor for each enet device
 218:  */
 219: struct enState
 220: {
 221:     long    ens_Rcnt;       /* input packets queued since */
 222:                     /* system startup */
 223:     long    ens_Xcnt;       /* output packets sent since */
 224:                     /* system startup */
 225:     long    ens_Rdrops;     /* input packets dropped since */
 226:                     /* system startup */
 227:     long    ens_Xdrops;     /* output packets dropped since */
 228:                     /* system startup */
 229:     struct enQueue          /* queue of active open */
 230:         ens_Desq;       /* file descriptors */
 231:     struct endevp   ens_DevParams;  /* device parameters, see enet.h */
 232: };
 233: #define enRcnt      (enStatep->ens_Rcnt)
 234: #define enXcnt      (enStatep->ens_Xcnt)
 235: #define enRdrops    (enStatep->ens_Rdrops)
 236: #define enXdrops    (enStatep->ens_Xdrops)
 237: #define enDesq      (enStatep->ens_Desq)
 238: #define enCurOpens  (enStatep->ens_Desq.enQ_NumQueued)
 239: #define enDevParams (enStatep->ens_DevParams)

Defined variables

q_tmp defined in line 123; used 6 times

Defined struct's

Queue defined in line 115; used 40 times
enOpenDescriptor defined in line 193; used 34 times
enPacket defined in line 149; used 32 times
enQueue defined in line 164; used 8 times
enState defined in line 219; used 20 times
enWaitQueue defined in line 175; used 14 times

Defined enum's

enStates defined in line 191; used 2 times
  • in line 203(2)

Defined macros

ENDEFWAITING defined in line 79; used 2 times
ENHIPRI defined in line 58; used 1 times
ENINDEX defined in line 70; used 4 times
ENKERNEL defined in line 95; never used
ENMAXPRI defined in line 64; used 1 times
ENMAXWAITING defined in line 76; used 5 times
ENMINSCAVENGE defined in line 88; used 1 times
ENPACKETS defined in line 82; used 4 times
ENUNIT defined in line 66; used 3 times
FALSE defined in line 105; used 5 times
TRUE defined in line 104; used 2 times
dequeue defined in line 131; used 5 times
enCurOpens defined in line 238; used 2 times
enDesq defined in line 237; used 12 times
enDevParams defined in line 239; used 2 times
enNextWaitQueueIndex defined in line 183; used 2 times
enP_B defined in line 159; never used
enP_F defined in line 158; never used
enPrevWaitQueueIndex defined in line 185; used 1 times
enQ_B defined in line 170; used 3 times
enQ_F defined in line 169; used 7 times
enRcnt defined in line 233; used 1 times
enRdrops defined in line 235; used 2 times
enXcnt defined in line 234; used 1 times
enXdrops defined in line 236; never used
endcase defined in line 107; used 12 times
enqueue defined in line 125; used 3 times
initqueue defined in line 140; used 2 times
queueempty defined in line 137; never used
remqueue defined in line 128; never used

Usage of this include

Last modified: 1985-11-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1351
Valid CSS Valid XHTML 1.0 Strict