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
Defined struct's
Queue
defined in line
115; used 40 times
- in line 117-123(6),
151(2),
166(2),
195(2)
- in /usr/src/new/enet/net/enet.c line
308(2),
478(2),
703(2),
716(2),
743(2),
1024(2),
1350(2),
1578(2),
1584(4),
1598-1602(8)
enOpenDescriptor
defined in line
193; used 34 times
- in /usr/src/new/enet/net/enet.c line
238(2),
435(2),
728(2),
761(2),
846(2),
974(2),
1194(2),
1247(2),
1305-1309(4),
1344(2),
1380(2),
1536(2),
1571-1582(8)
enPacket
defined in line
149; used 32 times
- in line 177(2)
- in /usr/src/new/enet/net/enet.c line
233(2),
306-308(4),
340(2),
353-358(4),
378(2),
470-478(6),
706(2),
762(2),
1266(2),
1303(2),
1379(2)
Defined enum's
Defined macros
TRUE
defined in line
104; used 2 times
endcase
defined in line
107; used 12 times
- in /usr/src/new/enet/net/enet.c line
996,
1005,
1029,
1047,
1056,
1074,
1094,
1105,
1120,
1135,
1144,
1159
Usage of this include