Use pcidevs.h.
[dragonfly.git] / sys / net / iso88025.h
1 /*
2  * Copyright (c) 1998, Larry Lile
3  * All rights reserved.
4  *
5  * For latest sources and information on this driver, please
6  * go to http://anarchy.stdio.com.
7  *
8  * Questions, comments or suggestions should be directed to
9  * Larry Lile <lile@stdio.com>.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice unmodified, this list of conditions, and the following
16  *    disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * $FreeBSD: src/sys/net/iso88025.h,v 1.3.2.2 2002/06/18 00:15:31 kbyanc Exp $
34  * $DragonFly: src/sys/net/Attic/iso88025.h,v 1.6 2006/05/20 02:42:08 dillon Exp $
35  *
36  * Information gathered from tokenring@freebsd, /sys/net/ethernet.h and
37  * the Mach token ring driver.
38  */
39
40 /*
41  * Fundamental constants relating to iso 802.5
42  */
43
44 #ifndef _NET_ISO88025_H_
45 #define _NET_ISO88025_H_
46
47 #ifndef _SYS_TYPES_H_
48 #include <sys/types.h>
49 #endif
50
51 /*
52  * General ISO 802.5 definitions
53  */
54 #define ISO88025_ADDR_LEN       6
55 #define ISO88025_HDR_LEN        (ISO88025_CF_LEN + (ISO88025_ADDR_LEN * 2))
56 #define ISO88025_CF_LEN         2
57 #define RCF_LEN                 2
58 #define RIF_MAX_RD              14
59 #define RIF_MAX_LEN             16
60
61 #define TR_AC                   0x10
62 #define TR_LLC_FRAME            0x40
63
64 #define TR_4MBPS                4000000
65 #define TR_16MBPS               16000000
66 #define TR_100MBPS              100000000
67
68 /*
69  * Source routing 
70  */
71 #define TR_RII                  0x80
72 #define TR_RCF_BCST_MASK        0xe000
73 #define TR_RCF_LEN_MASK         0x1f00
74 #define TR_RCF_DIR              0x0080
75 #define TR_RCF_LF_MASK          0x0070
76
77 #define TR_RCF_RIFLEN(x)        ((ntohs(x) & TR_RCF_LEN_MASK) >> 8)
78
79 /*
80  * Minimum and maximum packet payload lengths.
81  */
82 #define ISO88025_MIN_LEN        0 
83 #define ISO88025_MAX_LEN        17960   
84
85 /*
86  * A macro to validate a length with
87  */
88 #define ISO88025_IS_VALID_LEN(foo)      \
89         ((foo) >= ISO88025_MIN_LEN && (foo) <= ISO88025_MAX_LEN)
90
91 /*
92  * ISO 802.5 physical header
93  */
94 struct iso88025_header {
95         u_char  ac;                                 /* access control field */
96         u_char  fc;                                 /* frame control field */
97         u_char  iso88025_dhost[ISO88025_ADDR_LEN];  /* destination address */
98         u_char  iso88025_shost[ISO88025_ADDR_LEN];  /* source address */
99         u_short rcf;                                /* route control field */
100         u_short rd[RIF_MAX_RD];                     /* routing designators */
101 };
102
103 struct iso88025_sockaddr_data {
104         u_char ether_dhost[ISO88025_ADDR_LEN];
105         u_char ether_shost[ISO88025_ADDR_LEN];
106         u_char ac;
107         u_char fc;
108 };
109
110 struct iso88025_sockaddr_dl_data {
111         u_short  trld_rcf;
112         u_short *trld_route[RIF_MAX_LEN];
113 };
114
115 #define ISO88025_MAX(a, b)      (((a)>(b))?(a):(b))
116 #define SDL_ISO88025(s)         ((struct iso88025_sockaddr_dl_data *)   \
117                                  ((s)->sdl_data + \
118                                   ISO88025_MAX((s)->sdl_nlen + (s)->sdl_alen + \
119                                                (s)->sdl_slen, 12)))
120
121 /*
122  * Structure of a 48-bit iso 802.5 address.
123  *  ( We could also add the 16 bit addresses as a union)
124  */
125 struct  iso88025_addr {
126         u_char octet[ISO88025_ADDR_LEN];
127 };
128
129 #define ISO88025_MAX_MTU        18000
130 #define ISO88025_DEFAULT_MTU    1500
131 #define senderr(e) { error = (e); goto bad;}
132
133 struct lwkt_serialize;
134 struct ifnet;
135
136 void    iso88025_ifattach (struct ifnet *, struct lwkt_serialize *);
137 int     iso88025_ioctl (struct ifnet *, int , caddr_t );
138
139 #endif