Initial import from FreeBSD RELENG_4:
[games.git] / sys / dev / atm / hfa / fore_var.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/dev/hfa/fore_var.h,v 1.2 1999/08/28 00:41:53 peter Exp $
27  *
28  */
29
30 /*
31  * FORE Systems 200-Series Adapter Support
32  * ---------------------------------------
33  *
34  * Host protocol control blocks
35  *
36  */
37
38 #ifndef _FORE_VAR_H
39 #define _FORE_VAR_H
40
41 /*
42  * Device VCC Entry
43  *
44  * Contains the common and Fore-specific information for each VCC 
45  * which is opened through a Fore device.
46  */
47 struct fore_vcc {
48         struct cmn_vcc  fv_cmn;         /* Common VCC stuff */
49         Fore_aal        fv_aal;         /* CP version of AAL */
50 };
51 typedef struct fore_vcc  Fore_vcc;
52
53 #define fv_next         fv_cmn.cv_next
54 #define fv_toku         fv_cmn.cv_toku
55 #define fv_upper        fv_cmn.cv_upper
56 #define fv_connvc       fv_cmn.cv_connvc
57 #define fv_state        fv_cmn.cv_state
58 #define fv_flags        fv_cmn.cv_flags
59
60 /*
61  * VCC Flags
62  */
63 #define FVF_ACTCMD      0x01            /* Activate command issued */
64
65
66 /*
67  * Host Transmit Queue Element
68  *
69  * Defines the host's view of the CP PDU Transmit Queue
70  */
71 struct h_xmit_queue {
72         struct h_xmit_queue     *hxq_next;      /* Next element in queue */
73         Xmit_queue      *hxq_cpelem;    /* CP queue element */
74         Q_status        *hxq_status;    /* Element status word */
75         Xmit_descr      *hxq_descr;     /* Element's transmit descriptor */
76         Xmit_descr      *hxq_descr_dma; /* Element's transmit descriptor */
77         Fore_vcc        *hxq_vcc;       /* Data's VCC */
78         KBuffer         *hxq_buf;       /* Data's buffer chain head */
79         H_dma           hxq_dma[XMIT_MAX_SEGS]; /* DMA addresses for segments */
80 };
81 typedef struct h_xmit_queue     H_xmit_queue;
82
83
84
85 /*
86  * Host Receive Queue Element
87  *
88  * Defines the host's view of the CP PDU Receive Queue
89  */
90 struct h_recv_queue {
91         struct h_recv_queue     *hrq_next;      /* Next element in queue */
92         Recv_queue      *hrq_cpelem;    /* CP queue element */
93         Q_status        *hrq_status;    /* Element status word */
94         Recv_descr      *hrq_descr;     /* Element's receive descriptor */
95         Recv_descr      *hrq_descr_dma; /* Element's receive descriptor */
96 };
97 typedef struct h_recv_queue     H_recv_queue;
98
99
100
101 /*
102  * Host Buffer Supply Queue Element
103  *
104  * Defines the host's view of the CP Buffer Supply Queue
105  */
106 struct h_buf_queue {
107         struct h_buf_queue      *hbq_next;      /* Next element in queue */
108         Buf_queue       *hbq_cpelem;    /* CP queue element */
109         Q_status        *hbq_status;    /* Element status word */
110         Buf_descr       *hbq_descr;     /* Element's buffer descriptor array */
111         Buf_descr       *hbq_descr_dma; /* Element's buffer descriptor array */
112 };
113 typedef struct h_buf_queue      H_buf_queue;
114
115
116
117 /*
118  * Host Command Queue Element
119  *
120  * Defines the host's view of the CP Command Queue
121  */
122 struct h_cmd_queue {
123         struct h_cmd_queue      *hcq_next;      /* Next element in queue */
124         Cmd_queue       *hcq_cpelem;    /* CP queue element */
125         Q_status        *hcq_status;    /* Element status word */
126         Cmd_code        hcq_code;       /* Command code */
127         void            *hcq_arg;       /* Command-specific argument */
128 };
129 typedef struct h_cmd_queue      H_cmd_queue;
130
131
132
133 /*
134  * Host Buffer Handle
135  *
136  * For each buffer supplied to the CP, there will be one of these structures
137  * embedded into the non-data portion of the buffer.  This will allow us to
138  * track which buffers are currently "controlled" by the CP.  The address of
139  * this structure will supplied to/returned from the CP as the buffer handle.
140  */
141 struct buf_handle {
142         Qelem_t         bh_qelem;       /* Queuing element */
143         u_int           bh_type;        /* Buffer type (see below) */
144         H_dma           bh_dma;         /* Buffer DMA address */
145 };
146 typedef struct buf_handle       Buf_handle;
147 #define SIZEOF_Buf_handle       16
148
149 /*
150  * Buffer Types
151  */
152 #define BHT_S1_SMALL    1               /* Buffer strategy 1, small */
153 #define BHT_S1_LARGE    2               /* Buffer strategy 1, large */
154 #define BHT_S2_SMALL    3               /* Buffer strategy 2, small */
155 #define BHT_S2_LARGE    4               /* Buffer strategy 2, large */
156
157
158
159 /*
160  * Device Unit Structure
161  *
162  * Contains all the information for a single device (adapter).
163  */
164 struct fore_unit {
165         Cmn_unit        fu_cmn;         /* Common unit stuff */
166 #ifdef sun
167         struct dev_info *fu_devinfo;    /* Device node for this unit */
168 #endif
169         Fore_reg        *fu_ctlreg;     /* Device control register */
170 #ifdef FORE_SBUS
171         Fore_reg        *fu_intlvl;     /* Interrupt level register */
172 #endif
173 #ifdef FORE_PCI
174         Fore_reg        *fu_imask;      /* Interrupt mask register */
175         Fore_reg        *fu_psr;        /* PCI specific register */
176         pcici_t         fu_pcitag;      /* PCI tag */
177 #endif
178         Fore_mem        *fu_ram;        /* Device RAM */
179         u_int           fu_ramsize;     /* Size of device RAM */
180         Mon960          *fu_mon;        /* Monitor program interface */
181         Aali            *fu_aali;       /* Microcode program interface */
182         u_int           fu_timer;       /* Watchdog timer value */
183
184         /* Transmit Queue */
185         H_xmit_queue    fu_xmit_q[XMIT_QUELEN]; /* Host queue */
186         H_xmit_queue    *fu_xmit_head;  /* Queue head */
187         H_xmit_queue    *fu_xmit_tail;  /* Queue tail */
188         Q_status        *fu_xmit_stat;  /* Status array (host) */
189         Q_status        *fu_xmit_statd; /* Status array (DMA) */
190
191         /* Receive Queue */
192         H_recv_queue    fu_recv_q[RECV_QUELEN]; /* Host queue */
193         H_recv_queue    *fu_recv_head;  /* Queue head */
194         Q_status        *fu_recv_stat;  /* Status array (host) */
195         Q_status        *fu_recv_statd; /* Status array (DMA) */
196         Recv_descr      *fu_recv_desc;  /* Descriptor array (host) */
197         Recv_descr      *fu_recv_descd; /* Descriptor array (DMA) */
198
199         /* Buffer Supply Queue - Strategy 1 Small */
200         H_buf_queue     fu_buf1s_q[BUF1_SM_QUELEN];     /* Host queue */
201         H_buf_queue     *fu_buf1s_head; /* Queue head */
202         H_buf_queue     *fu_buf1s_tail; /* Queue tail */
203         Q_status        *fu_buf1s_stat; /* Status array (host) */
204         Q_status        *fu_buf1s_statd;/* Status array (DMA) */
205         Buf_descr       *fu_buf1s_desc; /* Descriptor array (host) */
206         Buf_descr       *fu_buf1s_descd;/* Descriptor array (DMA) */
207         Queue_t         fu_buf1s_bq;    /* Queue of supplied buffers */
208         u_int           fu_buf1s_cnt;   /* Count of supplied buffers */
209
210         /* Buffer Supply Queue - Strategy 1 Large */
211         H_buf_queue     fu_buf1l_q[BUF1_LG_QUELEN];     /* Host queue */
212         H_buf_queue     *fu_buf1l_head; /* Queue head */
213         H_buf_queue     *fu_buf1l_tail; /* Queue tail */
214         Q_status        *fu_buf1l_stat; /* Status array (host) */
215         Q_status        *fu_buf1l_statd;/* Status array (DMA) */
216         Buf_descr       *fu_buf1l_desc; /* Descriptor array (host) */
217         Buf_descr       *fu_buf1l_descd;/* Descriptor array (DMA) */
218         Queue_t         fu_buf1l_bq;    /* Queue of supplied buffers */
219         u_int           fu_buf1l_cnt;   /* Count of supplied buffers */
220
221         /* Command Queue */
222         H_cmd_queue     fu_cmd_q[CMD_QUELEN];   /* Host queue */
223         H_cmd_queue     *fu_cmd_head;   /* Queue head */
224         H_cmd_queue     *fu_cmd_tail;   /* Queue tail */
225         Q_status        *fu_cmd_stat;   /* Status array (host) */
226         Q_status        *fu_cmd_statd;  /* Status array (DMA) */
227
228         Fore_stats      *fu_stats;      /* Device statistics buffer */
229         Fore_stats      *fu_statsd;     /* Device statistics buffer (DMA) */
230         time_t          fu_stats_time;  /* Last stats request timestamp */
231         int             fu_stats_ret;   /* Stats request return code */
232 #ifdef FORE_PCI
233         Fore_prom       *fu_prom;       /* Device PROM buffer */
234         Fore_prom       *fu_promd;      /* Device PROM buffer (DMA) */
235 #endif
236         struct callout_handle fu_thandle;       /* Timer handle */
237 };
238 typedef struct fore_unit        Fore_unit;
239
240 #define fu_pif          fu_cmn.cu_pif
241 #define fu_unit         fu_cmn.cu_unit
242 #define fu_flags        fu_cmn.cu_flags
243 #define fu_mtu          fu_cmn.cu_mtu
244 #define fu_open_vcc     fu_cmn.cu_open_vcc
245 #define fu_vcc          fu_cmn.cu_vcc
246 #define fu_intrpri      fu_cmn.cu_intrpri
247 #define fu_savepri      fu_cmn.cu_savepri
248 #define fu_vcc_pool     fu_cmn.cu_vcc_pool
249 #define fu_nif_pool     fu_cmn.cu_nif_pool
250 #define fu_ioctl        fu_cmn.cu_ioctl
251 #define fu_instvcc      fu_cmn.cu_instvcc
252 #define fu_openvcc      fu_cmn.cu_openvcc
253 #define fu_closevcc     fu_cmn.cu_closevcc
254 #define fu_output       fu_cmn.cu_output
255 #define fu_config       fu_cmn.cu_config
256
257 /*
258  * Device flags (in addition to CUF_* flags)
259  */
260 #define FUF_STATCMD     0x80            /* Statistics request in progress */
261
262
263 /*
264  * Macros to access CP memory
265  */
266 #define CP_READ(x)      ntohl((u_long)(x))
267 #define CP_WRITE(x)     htonl((u_long)(x))
268
269 #endif  /* _FORE_VAR_H */