ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/include/ether_defs.h
Revision: 1.1.1.1 (vendor branch)
Committed: 2002-02-04T16:58:13Z (22 years, 4 months ago) by cebix
Content type: text/plain
Branch: cebix
CVS Tags: start
Changes since 1.1: +0 -0 lines
Log Message:
Imported sources

File Contents

# Content
1 /*
2 * ether_defs.h - Definitions for DLPI Ethernet Driver
3 *
4 * SheepShaver (C) 1997-2002 Marc Hellwig and Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef ETHER_DEFS_H
22 #define ETHER_DEFS_H
23
24
25 #if __BEOS__ && __POWERPC__
26 #define PRAGMA_ALIGN_SUPPORTED 1
27 #define PACKED__
28 #else
29 #define PACKED__ __attribute__ ((packed))
30 #endif
31
32
33 /*
34 * Macros
35 */
36
37 // Get pointer to the read queue, assumes 'q' is a write queue ptr
38 #define RD(q) (&q[-1])
39
40 // Get pointer to the write queue, assumes 'q' is a read queue ptr
41 #define WR(q) (&q[1])
42
43 #define OTCompare48BitAddresses(p1, p2) \
44 (*(const uint32*)((const uint8*)(p1)) == *(const uint32*)((const uint8*)(p2)) && \
45 *(const uint16*)(((const uint8*)(p1))+4) == *(const uint16*)(((const uint8*)(p2))+4) )
46
47 #define OTCopy48BitAddress(p1, p2) \
48 (*(uint32*)((uint8*)(p2)) = *(const uint32*)((const uint8*)(p1)), \
49 *(uint16*)(((uint8*)(p2))+4) = *(const uint16*)(((const uint8*)(p1))+4) )
50
51 #define OTClear48BitAddress(p1) \
52 (*(uint32*)((uint8*)(p1)) = 0, \
53 *(uint16*)(((uint8*)(p1))+4) = 0 )
54
55 #define OTCompare8022SNAP(p1, p2) \
56 (*(const uint32*)((const uint8*)(p1)) == *(const uint32*)((const uint8*)(p2)) && \
57 *(((const uint8*)(p1))+4) == *(((const uint8*)(p2))+4) )
58
59 #define OTCopy8022SNAP(p1, p2) \
60 (*(uint32*)((uint8*)(p2)) = *(const uint32*)((const uint8*)(p1)), \
61 *(((uint8*)(p2))+4) = *(((const uint8*)(p1))+4) )
62
63 #define OTIs48BitBroadcastAddress(p1) \
64 (*(uint32*)((uint8*)(p1)) == 0xffffffff && \
65 *(uint16*)(((uint8*)(p1))+4) == 0xffff )
66
67 #define OTSet48BitBroadcastAddress(p1) \
68 (*(uint32*)((uint8*)(p1)) = 0xffffffff, \
69 *(uint16*)(((uint8*)(p1))+4) = 0xffff )
70
71 #define OTIs48BitZeroAddress(p1) \
72 (*(uint32*)((uint8*)(p1)) == 0 && \
73 *(uint16*)(((uint8*)(p1))+4) == 0 )
74
75
76 /*
77 * Constants
78 */
79
80 enum {
81 // Address and packet lengths
82 kEnetPhysicalAddressLength = 6,
83 k8022SAPLength = 1,
84 k8022DLSAPLength = 2,
85 k8022SNAPLength = 5,
86 kMaxBoundAddrLength = 6 + 2 + 5, // addr/SAP/SNAP
87 kEnetAndSAPAddressLength = kEnetPhysicalAddressLength + k8022DLSAPLength,
88 kEnetPacketHeaderLength = (2 * kEnetPhysicalAddressLength) + k8022DLSAPLength,
89 k8022BasicHeaderLength = 3, // SSAP/DSAP/Control
90 k8022SNAPHeaderLength = k8022SNAPLength + k8022BasicHeaderLength,
91 kMinDIXSAP = 1501,
92 kEnetTSDU = 1514,
93
94 // Special addresses
95 kSNAPSAP = 0xaa,
96 kMax8022SAP = 0xfe,
97 k8022GlobalSAP = 0xff,
98 kIPXSAP = 0xff,
99
100 // DLPI interface states
101 DL_UNBOUND = 0,
102
103 // Message types
104 M_DATA = 0,
105 M_PROTO = 1,
106 M_IOCTL = 14,
107 M_IOCACK = 129,
108 M_IOCNAK = 130,
109 M_PCPROTO = 131, // priority message
110 M_FLUSH = 134,
111 FLUSHDATA = 0,
112 FLUSHALL = 1,
113 FLUSHR = 1,
114 FLUSHW = 2,
115 FLUSHRW = 3,
116
117 // DLPI primitives
118 DL_INFO_REQ = 0,
119 DL_BIND_REQ = 1,
120 DL_PEER_BIND = 1,
121 DL_HIERARCHICAL_BIND = 2,
122 DL_UNBIND_REQ = 2,
123 DL_INFO_ACK = 3,
124 DL_BIND_ACK = 4,
125 DL_ERROR_ACK = 5,
126 DL_OK_ACK = 6,
127 DL_UNITDATA_REQ = 7,
128 DL_UNITDATA_IND = 8,
129 DL_UDERROR_IND = 9,
130 DL_SUBS_UNBIND_REQ = 21,
131 DL_SUBS_BIND_REQ = 27,
132 DL_SUBS_BIND_ACK = 28,
133 DL_ENABMULTI_REQ = 29,
134 DL_DISABMULTI_REQ = 30,
135 DL_PHYS_ADDR_REQ = 49,
136 DL_PHYS_ADDR_ACK = 50,
137 DL_FACT_PHYS_ADDR = 1,
138 DL_CURR_PHYS_ADDR = 2,
139
140 // DLPI states
141 DL_IDLE = 3,
142
143 // DLPI error codes
144 DL_BADADDR = 1, // improper address format
145 DL_OUTSTATE = 3, // improper state
146 DL_SYSERR = 4, // UNIX system error
147 DL_UNSUPPORTED = 7, // service unsupported
148 DL_BADPRIM = 9, // primitive unknown
149 DL_NOTSUPPORTED = 18, // primitive not implemented
150 DL_TOOMANY = 19, // limit exceeded
151
152 // errnos
153 MAC_ENXIO = 6,
154 MAC_ENOMEM = 12,
155 MAC_EINVAL = 22,
156
157 // Various DLPI constants
158 DL_CLDLS = 2, // connectionless data link service
159 DL_STYLE1 = 0x500,
160 DL_VERSION_2 = 2,
161 DL_CSMACD = 0,
162 DL_ETHER = 4,
163 DL_UNKNOWN = -1,
164
165 // ioctl() codes
166 I_OTSetFramingType = (('O' << 8) | 2),
167 kOTGetFramingValue = -1,
168 kOTFramingEthernet = 1,
169 kOTFramingEthernetIPX = 2,
170 kOTFramingEthernet8023 = 4,
171 kOTFraming8022 = 8,
172 I_OTSetRawMode = (('O' << 8) | 3),
173 DL_IOC_HDR_INFO = (('l' << 8) | 10),
174
175 // Buffer allocation priority
176 BPRI_LO = 1,
177 BPRI_HI = 3,
178
179 // Misc constants
180 kEnetModuleID = 7101
181 };
182
183 enum EAddrType {
184 keaStandardAddress = 0,
185 keaMulticast,
186 keaBroadcast,
187 keaBadAddress
188 };
189
190
191 /*
192 * Structures
193 */
194
195 // Data block
196 struct datab {
197 datab *db_freep;
198 uint8 *db_base;
199 uint8 *db_lim;
200 uint8 db_ref;
201 uint8 db_type;
202 // ...
203 };
204
205 // Message block
206 struct msgb {
207 msgb *b_next;
208 msgb *b_prev;
209 msgb *b_cont;
210 uint8 *b_rptr;
211 uint8 *b_wptr;
212 datab *b_datap;
213 // ...
214 };
215
216 // Queue (full structure required because of size)
217 struct queue {
218 void *q_qinfo;
219 msgb *q_first;
220 msgb *q_last;
221 queue *q_next;
222 queue *q_link;
223 void *q_ptr;
224 uint32 q_count;
225 int32 q_minpsz;
226 int32 q_maxpsz;
227 uint32 q_hiwat;
228 uint32 q_lowat;
229 void *q_bandp;
230 uint16 q_flag;
231 uint8 q_nband;
232 uint8 q_pad1[1];
233 void *q_osx;
234 queue *q_ffcp;
235 queue *q_bfcp;
236 };
237 typedef struct queue queue_t;
238
239 // M_IOCTL parameters
240 struct iocblk {
241 int32 ioc_cmd;
242 void *ioc_cr;
243 uint32 ioc_id;
244 uint32 ioc_count;
245 int32 ioc_error;
246 int32 ioc_rval;
247 int32 ioc_filler[4];
248 };
249
250 // Priority specification
251 struct dl_priority_t {
252 int32 dl_min, dl_max;
253 };
254
255 // DPLI primitives
256 struct dl_info_req_t {
257 uint32 dl_primitive; // DL_INFO_REQ
258 };
259
260 struct dl_info_ack_t {
261 uint32 dl_primitive; // DL_INFO_ACK
262 uint32 dl_max_sdu;
263 uint32 dl_min_sdu;
264 uint32 dl_addr_length;
265 uint32 dl_mac_type;
266 uint32 dl_reserved;
267 uint32 dl_current_state;
268 int32 dl_sap_length;
269 uint32 dl_service_mode;
270 uint32 dl_qos_length;
271 uint32 dl_qos_offset;
272 uint32 dl_qos_range_length;
273 uint32 dl_qos_range_offset;
274 uint32 dl_provider_style;
275 uint32 dl_addr_offset;
276 uint32 dl_version;
277 uint32 dl_brdcst_addr_length;
278 uint32 dl_brdcst_addr_offset;
279 uint32 dl_growth;
280 };
281
282 struct dl_bind_req_t {
283 uint32 dl_primitive; // DL_BIND_REQ
284 uint32 dl_sap;
285 uint32 dl_max_conind;
286 uint16 dl_service_mode;
287 uint16 dl_conn_mgmt;
288 uint32 dl_xidtest_flg;
289 };
290
291 struct dl_bind_ack_t {
292 uint32 dl_primitive; // DL_BIND_ACK
293 uint32 dl_sap;
294 uint32 dl_addr_length;
295 uint32 dl_addr_offset;
296 uint32 dl_max_conind;
297 uint32 dl_xidtest_flg;
298 };
299
300 struct dl_error_ack_t {
301 uint32 dl_primitive; // DL_ERROR_ACK
302 uint32 dl_error_primitive;
303 uint32 dl_errno;
304 uint32 dl_unix_errno;
305 };
306
307 struct dl_ok_ack_t {
308 uint32 dl_primitive; // DL_ERROR_ACK
309 uint32 dl_correct_primitive;
310 };
311
312 struct dl_unitdata_req_t {
313 uint32 dl_primitive; // DL_UNITDATA_REQ
314 uint32 dl_dest_addr_length;
315 uint32 dl_dest_addr_offset;
316 dl_priority_t dl_priority;
317 };
318
319 struct dl_unitdata_ind_t {
320 uint32 dl_primitive; // DL_UNITDATA_IND
321 uint32 dl_dest_addr_length;
322 uint32 dl_dest_addr_offset;
323 uint32 dl_src_addr_length;
324 uint32 dl_src_addr_offset;
325 uint32 dl_group_address;
326 };
327
328 struct dl_uderror_ind_t {
329 uint32 dl_primitive; // DL_UDERROR_IND
330 uint32 dl_dest_addr_length;
331 uint32 dl_dest_addr_offset;
332 uint32 dl_unix_errno;
333 uint32 dl_errno;
334 };
335
336 struct dl_subs_bind_req_t {
337 uint32 dl_primitive; // DL_SUBS_BIND_REQ
338 uint32 dl_subs_sap_offset;
339 uint32 dl_subs_sap_length;
340 uint32 dl_subs_bind_class;
341 };
342
343 struct dl_subs_bind_ack_t {
344 uint32 dl_primitive; // DL_SUBS_BIND_ACK
345 uint32 dl_subs_sap_offset;
346 uint32 dl_subs_sap_length;
347 };
348
349 struct dl_subs_unbind_req_t {
350 uint32 dl_primitive; // DL_SUBS_UNBIND_REQ
351 uint32 dl_subs_sap_offset;
352 uint32 dl_subs_sap_length;
353 };
354
355 struct dl_enabmulti_req_t {
356 uint32 dl_primitive; // DL_ENABMULTI_REQ
357 uint32 dl_addr_length;
358 uint32 dl_addr_offset;
359 };
360
361 struct dl_disabmulti_req_t {
362 uint32 dl_primitive; // DL_DISABMULTI_REQ
363 uint32 dl_addr_length;
364 uint32 dl_addr_offset;
365 };
366
367 struct dl_phys_addr_req_t {
368 uint32 dl_primitive; // DL_PHYS_ADDR_REQ
369 uint32 dl_addr_type;
370 };
371
372 struct dl_phys_addr_ack_t {
373 uint32 dl_primitive; // DL_PHYS_ADDR_ACK
374 uint32 dl_addr_length;
375 uint32 dl_addr_offset;
376 };
377
378 // Parameters for I_OTSetRawMode/kOTSetRecvMode ioctl()
379 struct dl_recv_control_t {
380 uint32 dl_primitive;
381 uint32 dl_flags;
382 uint32 dl_truncation_length;
383 };
384
385 union DL_primitives {
386 uint32 dl_primitive;
387 dl_info_req_t info_req;
388 dl_info_ack_t info_ack;
389 dl_bind_req_t bind_req;
390 dl_bind_ack_t bind_ack;
391 dl_error_ack_t error_ack;
392 dl_ok_ack_t ok_ack;
393 dl_unitdata_req_t unitdata_req;
394 dl_unitdata_ind_t unitdata_ind;
395 dl_uderror_ind_t uderror_ind;
396 dl_subs_bind_req_t subs_bind_req;
397 dl_subs_bind_ack_t subs_bind_ack;
398 dl_subs_unbind_req_t subs_unbind_req;
399 dl_enabmulti_req_t enabmulti_req;
400 dl_disabmulti_req_t disabmulti_req;
401 dl_phys_addr_req_t phys_addr_req;
402 dl_phys_addr_ack_t phys_addr_ack;
403 };
404
405 #ifdef PRAGMA_ALIGN_SUPPORTED
406 #pragma options align=mac68k
407 #endif
408
409 // Packet headers
410 struct EnetPacketHeader {
411 uint8 fDestAddr[6];
412 uint8 fSourceAddr[6];
413 uint16 fProto;
414 } PACKED__;
415
416 struct T8022Header {
417 uint8 fDSAP;
418 uint8 fSSAP;
419 uint8 fCtrl;
420 } PACKED__;
421
422 struct T8022SNAPHeader {
423 uint8 fDSAP;
424 uint8 fSSAP;
425 uint8 fCtrl;
426 uint8 fSNAP[k8022SNAPLength];
427 } PACKED__;
428
429 struct T8022FullPacketHeader {
430 EnetPacketHeader fEnetPart;
431 T8022SNAPHeader f8022Part;
432 } PACKED__;
433
434 struct T8022AddressStruct {
435 uint8 fHWAddr[6];
436 uint16 fSAP;
437 uint8 fSNAP[k8022SNAPLength];
438 } PACKED__;
439
440 #ifdef PRAGMA_ALIGN_SUPPORTED
441 #pragma options align=reset
442 #endif
443
444 #endif