f57d346b37c8d5ce09fcf9556dacde53d1a43197
[dragonfly.git] / sys / netproto / atm / atm_if.h
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/sys/netatm/atm_if.h,v 1.2 1999/08/28 00:48:36 peter Exp $
27  *      @(#) $DragonFly: src/sys/netproto/atm/atm_if.h,v 1.6 2005/02/01 00:51:50 joerg Exp $
28  *
29  */
30
31 /*
32  * Core ATM Services
33  * -----------------
34  *
35  * ATM Physical and Network Interface definitions 
36  *
37  */
38
39 #ifndef _NETATM_ATM_IF_H
40 #define _NETATM_ATM_IF_H
41
42 /*
43  * Handy constants
44  */
45 #define ATM_NIF_MTU     9180            /* Default network interface MTU */
46
47 #define ATM_PCR_TAXI100 227273          /* Peak Cell Rate for 100 Mbs TAXI */
48 #define ATM_PCR_TAXI140 318181          /* Peak Cell Rate for 140 Mbs TAXI */
49 #define ATM_PCR_OC3C    353207          /* Peak Cell Rate for OC3c */
50 #define ATM_PCR_OC12C   1416905         /* Peak Cell Rate for OC12c */
51
52
53 /*
54  * Media Access Control (MAC) address
55  */
56 struct mac_addr {
57         u_char          ma_data[6];     /* MAC address */
58 };
59 typedef struct mac_addr Mac_addr;
60
61
62 /*
63  * Adapter vendor identifiers
64  */
65 enum atm_vendor {
66         VENDOR_UNKNOWN,                 /* Unknown vendor */
67         VENDOR_FORE,                    /* FORE Systems, Inc. */
68         VENDOR_ENI                      /* Efficient Networks, Inc. */
69 };
70 typedef enum atm_vendor Atm_vendor;
71
72
73 /*
74  * Adapter vendor interface identifiers
75  */
76 enum atm_vendapi {
77         VENDAPI_UNKNOWN,                /* Unknown interface */
78         VENDAPI_FORE_1,                 /* FORE - 200 Series */
79         VENDAPI_ENI_1                   /* ENI - Midway */
80 };
81 typedef enum atm_vendapi        Atm_vendapi;
82
83
84 /*
85  * Adapter device model identifiers
86  */
87 enum atm_device {
88         DEV_UNKNOWN,                    /* Unknown device */
89         DEV_FORE_SBA200E,               /* FORE SBA-200E */
90         DEV_FORE_SBA200,                /* FORE SBA-200 */
91         DEV_FORE_PCA200E,               /* FORE PCA-200E */
92         DEV_ENI_155P                    /* ENI-155p */
93 };
94 typedef enum atm_device Atm_device;
95
96
97 /*
98  * Adapter media identifiers
99  */
100 enum atm_media {
101         MEDIA_UNKNOWN,                  /* Unknown media type */
102         MEDIA_TAXI_100,                 /* TAXI - 100 Mbps */
103         MEDIA_TAXI_140,                 /* TAXI - 140 Mbps */
104         MEDIA_OC3C,                     /* OC-3C */
105         MEDIA_OC12C,                    /* OC-12C */
106         MEDIA_UTP155                    /* UTP-155 */
107 };
108 typedef enum atm_media  Atm_media;
109
110
111 /*
112  * Bus type identifiers
113  */
114 enum atm_bus {
115         BUS_UNKNOWN,                    /* Unknown bus type */
116         BUS_SBUS_B16,                   /* SBus: 16 byte (4 word) max burst */
117         BUS_SBUS_B32,                   /* SBus: 32 byte (8 word) max burst */
118         BUS_PCI                         /* PCI */
119 };
120 typedef enum atm_bus    Atm_bus;
121
122
123 #define VERSION_LEN     16              /* Length of version info string */
124
125
126 /*
127  * ATM adapter configuration information structure
128  */
129 struct atm_config {
130         Atm_vendor      ac_vendor;      /* Vendor */
131         Atm_vendapi     ac_vendapi;     /* Vendor interface */
132         Atm_device      ac_device;      /* Device model */
133         Atm_media       ac_media;       /* Media type */
134         u_long          ac_serial;      /* Serial number */
135         Atm_bus         ac_bustype;     /* Bus type */
136         u_long          ac_busslot;     /* Bus slot info (bus type dependent) */
137         u_long          ac_ram;         /* Device ram offset */
138         u_long          ac_ramsize;     /* Device ram size */
139         Mac_addr        ac_macaddr;     /* MAC address */
140         char            ac_hard_vers[VERSION_LEN];      /* Hardware version */
141         char            ac_firm_vers[VERSION_LEN];      /* Firmware version */
142 };
143 typedef struct atm_config       Atm_config;
144
145
146 #ifdef ATM_KERNEL
147 /*
148  * Common structure used to define each physical ATM device interface.
149  * This structure will (normally) be embedded at the top of each driver's 
150  * device-specific interface structure.  
151  */
152 struct  atm_pif {
153         struct atm_pif  *pif_next;      /* Next registered atm interface */
154         char            *pif_name;      /* Device name */
155         short           pif_unit;       /* Device unit number */
156         u_char          pif_flags;      /* Interface flags (see below) */
157         struct sigmgr   *pif_sigmgr;    /* Signalling Manager for interface */
158         struct siginst  *pif_siginst;   /* Signalling protocol instance */
159         struct stack_defn       *pif_services;  /* Interface's stack services */
160         struct mac_addr pif_macaddr;    /* Interface's MAC address */
161         struct atm_nif  *pif_nif;       /* List of network interfaces */
162         struct atm_pif  *pif_grnext;    /* Next atm device in group */
163
164 /* Exported functions */
165         int             (*pif_ioctl)    /* Interface ioctl handler */
166                                 (int, caddr_t, caddr_t);
167
168 /* Interface statistics */
169         long            pif_ipdus;      /* PDUs received from interface */
170         long            pif_opdus;      /* PDUs sent to interface */
171         long            pif_ibytes;     /* Bytes received from interface */
172         long            pif_obytes;     /* Bytes sent to interface */
173         long            pif_ierrors;    /* Errors receiving from interface */
174         long            pif_oerrors;    /* Errors sending to interface */
175         long            pif_cmderrors;  /* Interface command errors */
176         caddr_t         pif_cardstats;  /* Card specific statistics */
177
178 /* Interface capabilities */
179         u_short         pif_maxvpi;     /* Maximum VPI value supported */
180         u_short         pif_maxvci;     /* Maximum VCI value supported */
181         u_int           pif_pcr;        /* Peak Cell Rate */
182 };
183
184 /*
185  * Physical interface flags
186  */
187 #define PIF_UP          0x01            /* Interface is up */
188 #define PIF_LOOPBACK    0x02            /* Loopback local packets */
189
190
191 /*
192  * Structure defining an ATM network interface.  This structure is used as 
193  * the hook between the standard BSD network layer interface mechanism and 
194  * the ATM device layer.  There may be one or more network interfaces for 
195  * each physical ATM interface.
196  */
197 struct  atm_nif {
198         struct ifnet    nif_if;         /* Network interface */
199         struct atm_pif  *nif_pif;       /* Our physical interface */
200         char            nif_name[IFNAMSIZ];/* Network interface name */
201         u_char          nif_sel;        /* Interface's address selector */
202         struct atm_nif  *nif_pnext;     /* Next net interface on phys i/f */
203
204 /* Interface statistics (in addition to ifnet stats) */
205         long            nif_ibytes;     /* Bytes received from interface */
206         long            nif_obytes;     /* Bytes sent to interface */
207 };
208
209
210 /*
211  * Common Device VCC Entry
212  *
213  * Contains the common information for each VCC which is opened
214  * through a particular device.
215  */
216 struct cmn_vcc {
217         struct cmn_vcc  *cv_next;       /* Next in list */
218         void            *cv_toku;       /* Upper layer's token */
219         void            (*cv_upper)     /* Upper layer's interface */
220                                 (int, void *, int, int);
221         Atm_connvc      *cv_connvc;     /* Associated connection VCC */
222         u_char          cv_state;       /* VCC state (see below) */
223         u_char          cv_flags;       /* VCC flags (see below) */
224 };
225 typedef struct cmn_vcc  Cmn_vcc;
226
227 /*
228  * VCC States
229  */
230 #define CVS_FREE        0               /* Not allocated */
231 #define CVS_INST        1               /* Instantiated, waiting for INIT */
232 #define CVS_INITED      2               /* Initialized, waiting for driver */
233 #define CVS_ACTIVE      3               /* Device activated by driver */
234 #define CVS_PTERM       4               /* Waiting for TERM */
235 #define CVS_TERM        5               /* Terminated */
236
237 /*
238  * VCC Flags
239  */
240 #define CVF_RSVD        0x0f            /* Reserved for device-specific use */
241
242
243 /*
244  * Common Device Unit Structure
245  *
246  * Contains the common information for a single device (adapter).
247  */
248 struct cmn_unit {
249         struct atm_pif  cu_pif;         /* Physical interface */
250         u_int           cu_unit;        /* Local unit number */
251         u_char          cu_flags;       /* Device flags (see below) */
252         u_int           cu_mtu;         /* Interface MTU */
253
254         u_int           cu_open_vcc;    /* Open VCC count */
255         Cmn_vcc         *cu_vcc;        /* List of VCC's on interface */
256
257         u_int           cu_intrpri;     /* Highest unit interrupt priority */
258         int             cu_savepri;     /* Saved priority for locking device */
259
260         struct sp_info  *cu_vcc_pool;   /* Device VCC pool */
261         struct sp_info  *cu_nif_pool;   /* Device NIF pool */
262
263         int             (*cu_ioctl)     /* Interface ioctl handler */
264                                 (int, caddr_t, caddr_t);
265         int             (*cu_instvcc)   /* VCC stack instantion handler */
266                                 (struct cmn_unit *, Cmn_vcc *);
267         int             (*cu_openvcc)   /* Open VCC handler */
268                                 (struct cmn_unit *, Cmn_vcc *);
269         int             (*cu_closevcc)  /* Close VCC handler */
270                                 (struct cmn_unit *, Cmn_vcc *);
271         void            (*cu_output)    /* Data output handler */
272                                 (struct cmn_unit *, Cmn_vcc *, KBuffer *);
273
274         Atm_config      cu_config;      /* Device configuration data */
275 };
276 typedef struct cmn_unit Cmn_unit;
277
278 /*
279  * Device flags
280  */
281 #define CUF_REGISTER    0x01            /* Device is registered */
282 #define CUF_INITED      0x02            /* Device is initialized */
283
284
285 /*
286  * Structure used to define a network convergence module and its associated
287  * entry points.  A convergence module is used to provide the interface
288  * translations necessary between the ATM system and the BSD network layer
289  * interface mechanism.  There will be one network convergence module for
290  * each protocol address family supporting ATM connections.
291  */
292 struct atm_ncm {
293         struct atm_ncm  *ncm_next;      /* Next in registry list */
294         u_short         ncm_family;     /* Protocol family */
295 /* Exported functions */
296         int             (*ncm_ifoutput) /* Interface if_output handler */
297                                 (struct ifnet *, KBuffer *,
298                                      struct sockaddr *);
299         int             (*ncm_stat)     /* Network i/f status handler */
300                                 (int, struct atm_nif *, int);
301 };
302
303 /*
304  * ncm_stat() commands
305  */
306 #define NCM_ATTACH      1               /* Attaching a new net i/f */
307 #define NCM_DETACH      2               /* Detaching a current net i/f */
308 #define NCM_SETADDR     3               /* Net i/f address change */
309 #define NCM_SIGATTACH   4               /* Attaching a signalling manager */
310 #define NCM_SIGDETACH   5               /* Detaching a signalling manager */
311
312
313 /*
314  * atm_dev_alloc() parameters
315  */
316 #define ATM_DEV_NONCACHE        1       /* Allocate non-cacheable memory */
317
318 /*
319  * atm_dev_compress() buffer allocation sizes
320  */
321 #define ATM_DEV_CMPR_LG MCLBYTES        /* Size of large buffers */
322 #define ATM_DEV_CMPR_SM MLEN            /* Size of small buffers */
323
324 /*
325  * Macros to manage DMA addresses
326  */
327 #define DMA_INIT()
328 #define DMA_GET_ADDR(addr,len,align,flags)      ((void *)vtophys(addr))
329 #define DMA_FREE_ADDR(addr,daddr,len,flags)
330 #define DMA_RELEASE()
331
332 /*
333  * Macros to lock out device interrupts
334  */
335 #define DEVICE_LOCK(u)          ((u)->cu_savepri = splimp())
336 #define DEVICE_UNLOCK(u)        ((void) splx((u)->cu_savepri))
337
338 /*
339  * Macro to schedule the ATM interrupt queue handler
340  */
341 typedef void (atm_intr_t) (void *, KBuffer *); /* Callback function type */
342 typedef atm_intr_t      *atm_intr_func_t; /* Pointer to callback function */
343
344 #define NETISR_ATM      AF_ATM
345 #endif /* ATM_KERNEL */
346
347 #endif  /* _NETATM_ATM_IF_H */