FreeBSD/Linux Kernel Cross Reference
sys/dev/idt/idtvar.h
1 /*-
2 * Copyright (c) 2000, 2001 Richard Hodges and Matriplex, inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Matriplex, inc.
16 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 ******************************************************************************
32 *
33 * This driver is derived from the Nicstar driver by Mark Tinguely, and
34 * some of the original driver still exists here. Those portions are...
35 * Copyright (c) 1996, 1997, 1998, 1999 Mark Tinguely
36 * All rights reserved.
37 *
38 ******************************************************************************
39 *
40 * This driver supports the Fore LE155, LE25, and IDT 77211 cards.
41 *
42 * ATM CBR connections are supported, and bandwidth is allocated in
43 * slots of 64k each. Three VBR queues handle traffic for VBR and
44 * UBR. Two UBR queues prioritize UBR traffic. ILMI and signalling
45 * get the higher priority queue, as well as UBR traffic that specifies
46 * a peak cell rate. All other UBR traffic goes into the lower queue.
47 *
48 ******************************************************************************
49 *
50 * $FreeBSD$
51 */
52
53 /*******************************************************************************
54 *
55 * New data types
56 */
57
58 typedef struct {
59 struct mbuf *mget; /* head of mbuf queue, pull mbufs from here */
60 struct mbuf **mput; /* tail (ptr to m_nextpkt) put mbufs here */
61 u_long scd; /* segmentation channel descriptor address */
62 u_long *scq_base; /* segmentation channel queue base address */
63 u_long *scq_next; /* next address */
64 u_long *scq_last; /* last address written */
65 int scq_len; /* size of SCQ buffer (64 or 512) */
66 int scq_cur; /* current number entries in SCQ buffer */
67 int rate; /* cells per second allocated to this queue */
68 int vbr_m; /* VBR m/n = max duty cycle for queue */
69 int vbr_n; /* 1 <= m <= 7 and 1 <= n <= 127 */
70 } TX_QUEUE;
71
72 /* To avoid expensive SRAM reads, scq_cur tracks the number of SCQ entries
73 * in use. Only idt_transmit_top may increase this, and only idt_intr_tsq
74 * may decrease it.
75 */
76
77 /* mbuf chains on the queue use the fields:
78 * m_next is the usual pointer to next mbuf
79 * m_nextpkt is the next packet on the queue
80 * m_pkthdr.rcvif is a pointer to the connection
81 * m_pkthdr.header is a pointer to the TX queue
82 */
83
84 typedef struct {
85 struct vccb *vccinf;
86 char status; /* zero if closed */
87 char vpi;
88 u_short vci;
89 TX_QUEUE *queue; /* transmit queue for this connection */
90 struct mbuf *recv; /* current receive mbuf, or NULL */
91 int rlen; /* current receive length */
92 int maxpdu; /* largest PDU we will ever see */
93 int traf_pcr; /* peak cell rate */
94 int traf_scr; /* sustained cell rate */
95 u_char aal; /* AAL for this connection */
96 u_char class; /* T_ATM_CBR, T_ATM_VBR, or T_ATM_UBR */
97 u_char flg_mpeg2ts:1; /* send data as 2 TS == 8 AAL5 cells */
98 u_char flg_clp:1; /* CLP flag for outbound cells */
99 } CONNECTION;
100
101 #define MAX_CONNECTION 4096 /* max number of connections */
102
103 #define GET_RDTSC(var) {__asm__ volatile("rdtsc":"=A"(var)); }
104
105 /*******************************************************************************
106 *
107 * Device softc structure
108 */
109
110 struct idt_softc {
111 /* HARP data */
112 /* XXX: must be first member of struct. */
113 Cmn_unit iu_cmn; /* Common unit stuff */
114
115 #if 0
116 struct arpcom idt_ac; /* ifnet for device */
117 #endif
118
119 /* Device data */
120 device_t dev;
121 int debug;
122
123 struct resource * mem;
124 int mem_rid;
125 int mem_type;
126 bus_space_tag_t bustag;
127 bus_space_handle_t bushandle;
128
129 struct resource * irq;
130 int irq_rid;
131 void * irq_ih;
132
133 struct callout_handle ch;
134
135 struct mtx mtx;
136
137 vm_offset_t virt_baseaddr; /* nicstar register virtual address */
138 vm_offset_t cmd_reg; /* command register offset 0x14 */
139 vm_offset_t stat_reg; /* status register offset 0x60 */
140 vm_offset_t fixbuf; /* buffer that holds TSQ, RSQ, variable SCQ */
141
142 u_long timer_wrap; /* keep track of wrapped timers */
143 u_long rsqh; /* Recieve Status Queue, reg is write-only */
144
145 CONNECTION *connection; /* connection table */
146 int conn_maxvpi; /* number of VPI values */
147 int conn_maxvci; /* number of VCI values */
148 int cellrate_rmax; /* max RX cells per second */
149 int cellrate_tmax; /* max TX cells per second */
150 int cellrate_rcur; /* current committed RX cellrate */
151 int cellrate_tcur; /* current committed TX cellrate */
152 int txslots_max; /* number of CBR TX slots for interface */
153 int txslots_cur; /* current CBR TX slots in use */
154 TX_QUEUE cbr_txqb[IDT_MAX_CBRQUEUE];
155 TX_QUEUE *cbr_slot[IDT_MAX_CBRSLOTS];
156 TX_QUEUE *cbr_free[IDT_MAX_CBRQUEUE];
157 TX_QUEUE queue_vbr;
158 TX_QUEUE queue_abr;
159 TX_QUEUE queue_ubr;
160 vm_offset_t cbr_base; /* base of memory for CBR TX queues */
161 int cbr_size; /* size of memory for CBR TX queues */
162 int cbr_freect;
163 u_long raw_headp; /* head of raw cell queue, physical */
164 struct mbuf *raw_headm; /* head of raw cell queue, virtual */
165 u_long *tsq_base; /* virtual TSQ base address */
166 u_long *tsq_head; /* virtual TSQ head pointer */
167 int tsq_size; /* number of TSQ entries (1024) */
168 volatile u_long *reg_cfg;
169 volatile u_long *reg_cmd;
170 volatile u_long *reg_data;
171 volatile u_long *reg_tsqh;
172 volatile u_long *reg_gp;
173 volatile u_long *reg_stat;
174 struct mbuf **mcheck;
175
176 int sram; /* amount of SRAM */
177 int pci_rev; /* hardware revision ID */
178 char *hardware; /* hardware description string */
179 u_char flg_le25:1; /* flag indicates LE25 instead of LE155 */
180 u_char flg_igcrc:1; /* ignore receive CRC errors */
181 };
182
183 typedef struct idt_softc nicstar_reg_t;
184 typedef struct idt_softc IDT;
185
186 #define iu_pif iu_cmn.cu_pif
187 #define stats_ipdus iu_pif.pif_ipdus
188 #define stats_opdus iu_pif.pif_opdus
189 #define stats_ibytes iu_pif.pif_ibytes
190 #define stats_obytes iu_pif.pif_obytes
191 #define stats_ierrors iu_pif.pif_ierrors
192 #define stats_oerrors iu_pif.pif_oerrors
193 #define stats_cmderrors iu_pif.pif_cmderrors
194
195 /*
196 * Device VCC Entry
197 *
198 * Contains the common and IDT-specific information for each VCC
199 * which is opened through an IDT device.
200 */
201 struct nidt_vcc {
202 struct cmn_vcc iv_cmn; /* Common VCC stuff */
203 };
204
205 typedef struct nidt_vcc Idt_vcc;
206
207 extern int idt_sysctl_logvcs;
208 extern int idt_sysctl_vbriscbr;
209
210 void nicstar_intr(void *);
211 void phys_init(nicstar_reg_t * const);
212 void nicstar_init(nicstar_reg_t * const);
213 int idt_harp_init(nicstar_reg_t * const);
214 void idt_device_stop(IDT *);
215 void idt_release_mem(IDT *);
216
217 CONNECTION *idt_connect_find(IDT *, int, int);
218 caddr_t idt_mbuf_base(struct mbuf *);
219 int idt_slots_cbr(IDT *, int);
220
221 int idt_connect_opencls(IDT *, CONNECTION *, int);
222 int idt_connect_txopen(IDT *, CONNECTION *);
223 int idt_connect_txclose(IDT *, CONNECTION *);
224
225 int nicstar_eeprom_rd(nicstar_reg_t * const, u_long);
226
227 void idt_receive(IDT *, struct mbuf *, int, int);
228 void idt_transmit(IDT *, struct mbuf *, int, int, int);
Cache object: 10311f194991054cd01e5070a9f1bab2
|