diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/atm/eni.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/atm/eni.c')
-rw-r--r-- | drivers/atm/eni.c | 2299 |
1 files changed, 2299 insertions, 0 deletions
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c new file mode 100644 index 000000000000..78e34ee79df8 --- /dev/null +++ b/drivers/atm/eni.c | |||
@@ -0,0 +1,2299 @@ | |||
1 | /* drivers/atm/eni.c - Efficient Networks ENI155P device driver */ | ||
2 | |||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | ||
4 | |||
5 | |||
6 | #include <linux/module.h> | ||
7 | #include <linux/config.h> | ||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/mm.h> | ||
10 | #include <linux/pci.h> | ||
11 | #include <linux/errno.h> | ||
12 | #include <linux/atm.h> | ||
13 | #include <linux/atmdev.h> | ||
14 | #include <linux/sonet.h> | ||
15 | #include <linux/skbuff.h> | ||
16 | #include <linux/time.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/uio.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/atm_eni.h> | ||
21 | #include <linux/bitops.h> | ||
22 | #include <asm/system.h> | ||
23 | #include <asm/io.h> | ||
24 | #include <asm/atomic.h> | ||
25 | #include <asm/uaccess.h> | ||
26 | #include <asm/string.h> | ||
27 | #include <asm/byteorder.h> | ||
28 | |||
29 | #include "tonga.h" | ||
30 | #include "midway.h" | ||
31 | #include "suni.h" | ||
32 | #include "eni.h" | ||
33 | |||
34 | #if !defined(__i386__) && !defined(__x86_64__) | ||
35 | #ifndef ioremap_nocache | ||
36 | #define ioremap_nocache(X,Y) ioremap(X,Y) | ||
37 | #endif | ||
38 | #endif | ||
39 | |||
40 | /* | ||
41 | * TODO: | ||
42 | * | ||
43 | * Show stoppers | ||
44 | * none | ||
45 | * | ||
46 | * Minor | ||
47 | * - OAM support | ||
48 | * - fix bugs listed below | ||
49 | */ | ||
50 | |||
51 | /* | ||
52 | * KNOWN BUGS: | ||
53 | * | ||
54 | * - may run into JK-JK bug and deadlock | ||
55 | * - should allocate UBR channel first | ||
56 | * - buffer space allocation algorithm is stupid | ||
57 | * (RX: should be maxSDU+maxdelay*rate | ||
58 | * TX: should be maxSDU+min(maxSDU,maxdelay*rate) ) | ||
59 | * - doesn't support OAM cells | ||
60 | * - eni_put_free may hang if not putting memory fragments that _complete_ | ||
61 | * 2^n block (never happens in real life, though) | ||
62 | * - keeps IRQ even if initialization fails | ||
63 | */ | ||
64 | |||
65 | |||
66 | #if 0 | ||
67 | #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args) | ||
68 | #else | ||
69 | #define DPRINTK(format,args...) | ||
70 | #endif | ||
71 | |||
72 | |||
73 | #ifndef CONFIG_ATM_ENI_TUNE_BURST | ||
74 | #define CONFIG_ATM_ENI_BURST_TX_8W | ||
75 | #define CONFIG_ATM_ENI_BURST_RX_4W | ||
76 | #endif | ||
77 | |||
78 | |||
79 | #ifndef CONFIG_ATM_ENI_DEBUG | ||
80 | |||
81 | |||
82 | #define NULLCHECK(x) | ||
83 | |||
84 | #define EVENT(s,a,b) | ||
85 | |||
86 | |||
87 | static void event_dump(void) | ||
88 | { | ||
89 | } | ||
90 | |||
91 | |||
92 | #else | ||
93 | |||
94 | |||
95 | /* | ||
96 | * NULL pointer checking | ||
97 | */ | ||
98 | |||
99 | #define NULLCHECK(x) \ | ||
100 | if ((unsigned long) (x) < 0x30) \ | ||
101 | printk(KERN_CRIT #x "==0x%lx\n",(unsigned long) (x)) | ||
102 | |||
103 | /* | ||
104 | * Very extensive activity logging. Greatly improves bug detection speed but | ||
105 | * costs a few Mbps if enabled. | ||
106 | */ | ||
107 | |||
108 | #define EV 64 | ||
109 | |||
110 | static const char *ev[EV]; | ||
111 | static unsigned long ev_a[EV],ev_b[EV]; | ||
112 | static int ec = 0; | ||
113 | |||
114 | |||
115 | static void EVENT(const char *s,unsigned long a,unsigned long b) | ||
116 | { | ||
117 | ev[ec] = s; | ||
118 | ev_a[ec] = a; | ||
119 | ev_b[ec] = b; | ||
120 | ec = (ec+1) % EV; | ||
121 | } | ||
122 | |||
123 | |||
124 | static void event_dump(void) | ||
125 | { | ||
126 | int n,i; | ||
127 | |||
128 | for (n = 0; n < EV; n++) { | ||
129 | i = (ec+n) % EV; | ||
130 | printk(KERN_NOTICE); | ||
131 | printk(ev[i] ? ev[i] : "(null)",ev_a[i],ev_b[i]); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | |||
136 | #endif /* CONFIG_ATM_ENI_DEBUG */ | ||
137 | |||
138 | |||
139 | /* | ||
140 | * NExx must not be equal at end | ||
141 | * EExx may be equal at end | ||
142 | * xxPJOK verify validity of pointer jumps | ||
143 | * xxPMOK operating on a circular buffer of "c" words | ||
144 | */ | ||
145 | |||
146 | #define NEPJOK(a0,a1,b) \ | ||
147 | ((a0) < (a1) ? (b) <= (a0) || (b) > (a1) : (b) <= (a0) && (b) > (a1)) | ||
148 | #define EEPJOK(a0,a1,b) \ | ||
149 | ((a0) < (a1) ? (b) < (a0) || (b) >= (a1) : (b) < (a0) && (b) >= (a1)) | ||
150 | #define NEPMOK(a0,d,b,c) NEPJOK(a0,(a0+d) & (c-1),b) | ||
151 | #define EEPMOK(a0,d,b,c) EEPJOK(a0,(a0+d) & (c-1),b) | ||
152 | |||
153 | |||
154 | static int tx_complete = 0,dma_complete = 0,queued = 0,requeued = 0, | ||
155 | backlogged = 0,rx_enqueued = 0,rx_dequeued = 0,pushed = 0,submitted = 0, | ||
156 | putting = 0; | ||
157 | |||
158 | static struct atm_dev *eni_boards = NULL; | ||
159 | |||
160 | static u32 *cpu_zeroes = NULL; /* aligned "magic" zeroes */ | ||
161 | static dma_addr_t zeroes; | ||
162 | |||
163 | /* Read/write registers on card */ | ||
164 | #define eni_in(r) readl(eni_dev->reg+(r)*4) | ||
165 | #define eni_out(v,r) writel((v),eni_dev->reg+(r)*4) | ||
166 | |||
167 | |||
168 | /*-------------------------------- utilities --------------------------------*/ | ||
169 | |||
170 | |||
171 | static void dump_mem(struct eni_dev *eni_dev) | ||
172 | { | ||
173 | int i; | ||
174 | |||
175 | for (i = 0; i < eni_dev->free_len; i++) | ||
176 | printk(KERN_DEBUG " %d: %p %d\n",i, | ||
177 | eni_dev->free_list[i].start, | ||
178 | 1 << eni_dev->free_list[i].order); | ||
179 | } | ||
180 | |||
181 | |||
182 | static void dump(struct atm_dev *dev) | ||
183 | { | ||
184 | struct eni_dev *eni_dev; | ||
185 | |||
186 | int i; | ||
187 | |||
188 | eni_dev = ENI_DEV(dev); | ||
189 | printk(KERN_NOTICE "Free memory\n"); | ||
190 | dump_mem(eni_dev); | ||
191 | printk(KERN_NOTICE "TX buffers\n"); | ||
192 | for (i = 0; i < NR_CHAN; i++) | ||
193 | if (eni_dev->tx[i].send) | ||
194 | printk(KERN_NOTICE " TX %d @ %p: %ld\n",i, | ||
195 | eni_dev->tx[i].send,eni_dev->tx[i].words*4); | ||
196 | printk(KERN_NOTICE "RX buffers\n"); | ||
197 | for (i = 0; i < 1024; i++) | ||
198 | if (eni_dev->rx_map[i] && ENI_VCC(eni_dev->rx_map[i])->rx) | ||
199 | printk(KERN_NOTICE " RX %d @ %p: %ld\n",i, | ||
200 | ENI_VCC(eni_dev->rx_map[i])->recv, | ||
201 | ENI_VCC(eni_dev->rx_map[i])->words*4); | ||
202 | printk(KERN_NOTICE "----\n"); | ||
203 | } | ||
204 | |||
205 | |||
206 | static void eni_put_free(struct eni_dev *eni_dev, void __iomem *start, | ||
207 | unsigned long size) | ||
208 | { | ||
209 | struct eni_free *list; | ||
210 | int len,order; | ||
211 | |||
212 | DPRINTK("init 0x%lx+%ld(0x%lx)\n",start,size,size); | ||
213 | start += eni_dev->base_diff; | ||
214 | list = eni_dev->free_list; | ||
215 | len = eni_dev->free_len; | ||
216 | while (size) { | ||
217 | if (len >= eni_dev->free_list_size) { | ||
218 | printk(KERN_CRIT "eni_put_free overflow (%p,%ld)\n", | ||
219 | start,size); | ||
220 | break; | ||
221 | } | ||
222 | for (order = 0; !(((unsigned long)start | size) & (1 << order)); order++); | ||
223 | if (MID_MIN_BUF_SIZE > (1 << order)) { | ||
224 | printk(KERN_CRIT "eni_put_free: order %d too small\n", | ||
225 | order); | ||
226 | break; | ||
227 | } | ||
228 | list[len].start = (void __iomem *) start; | ||
229 | list[len].order = order; | ||
230 | len++; | ||
231 | start += 1 << order; | ||
232 | size -= 1 << order; | ||
233 | } | ||
234 | eni_dev->free_len = len; | ||
235 | /*dump_mem(eni_dev);*/ | ||
236 | } | ||
237 | |||
238 | |||
239 | static void __iomem *eni_alloc_mem(struct eni_dev *eni_dev, unsigned long *size) | ||
240 | { | ||
241 | struct eni_free *list; | ||
242 | void __iomem *start; | ||
243 | int len,i,order,best_order,index; | ||
244 | |||
245 | list = eni_dev->free_list; | ||
246 | len = eni_dev->free_len; | ||
247 | if (*size < MID_MIN_BUF_SIZE) *size = MID_MIN_BUF_SIZE; | ||
248 | if (*size > MID_MAX_BUF_SIZE) return NULL; | ||
249 | for (order = 0; (1 << order) < *size; order++); | ||
250 | DPRINTK("trying: %ld->%d\n",*size,order); | ||
251 | best_order = 65; /* we don't have more than 2^64 of anything ... */ | ||
252 | index = 0; /* silence GCC */ | ||
253 | for (i = 0; i < len; i++) | ||
254 | if (list[i].order == order) { | ||
255 | best_order = order; | ||
256 | index = i; | ||
257 | break; | ||
258 | } | ||
259 | else if (best_order > list[i].order && list[i].order > order) { | ||
260 | best_order = list[i].order; | ||
261 | index = i; | ||
262 | } | ||
263 | if (best_order == 65) return NULL; | ||
264 | start = list[index].start-eni_dev->base_diff; | ||
265 | list[index] = list[--len]; | ||
266 | eni_dev->free_len = len; | ||
267 | *size = 1 << order; | ||
268 | eni_put_free(eni_dev,start+*size,(1 << best_order)-*size); | ||
269 | DPRINTK("%ld bytes (order %d) at 0x%lx\n",*size,order,start); | ||
270 | memset_io(start,0,*size); /* never leak data */ | ||
271 | /*dump_mem(eni_dev);*/ | ||
272 | return start; | ||
273 | } | ||
274 | |||
275 | |||
276 | static void eni_free_mem(struct eni_dev *eni_dev, void __iomem *start, | ||
277 | unsigned long size) | ||
278 | { | ||
279 | struct eni_free *list; | ||
280 | int len,i,order; | ||
281 | |||
282 | start += eni_dev->base_diff; | ||
283 | list = eni_dev->free_list; | ||
284 | len = eni_dev->free_len; | ||
285 | for (order = -1; size; order++) size >>= 1; | ||
286 | DPRINTK("eni_free_mem: %p+0x%lx (order %d)\n",start,size,order); | ||
287 | for (i = 0; i < len; i++) | ||
288 | if (((unsigned long) list[i].start) == ((unsigned long)start^(1 << order)) && | ||
289 | list[i].order == order) { | ||
290 | DPRINTK("match[%d]: 0x%lx/0x%lx(0x%x), %d/%d\n",i, | ||
291 | list[i].start,start,1 << order,list[i].order,order); | ||
292 | list[i] = list[--len]; | ||
293 | start = (void __iomem *) ((unsigned long) start & ~(unsigned long) (1 << order)); | ||
294 | order++; | ||
295 | i = -1; | ||
296 | continue; | ||
297 | } | ||
298 | if (len >= eni_dev->free_list_size) { | ||
299 | printk(KERN_ALERT "eni_free_mem overflow (%p,%d)\n",start, | ||
300 | order); | ||
301 | return; | ||
302 | } | ||
303 | list[len].start = start; | ||
304 | list[len].order = order; | ||
305 | eni_dev->free_len = len+1; | ||
306 | /*dump_mem(eni_dev);*/ | ||
307 | } | ||
308 | |||
309 | |||
310 | /*----------------------------------- RX ------------------------------------*/ | ||
311 | |||
312 | |||
313 | #define ENI_VCC_NOS ((struct atm_vcc *) 1) | ||
314 | |||
315 | |||
316 | static void rx_ident_err(struct atm_vcc *vcc) | ||
317 | { | ||
318 | struct atm_dev *dev; | ||
319 | struct eni_dev *eni_dev; | ||
320 | struct eni_vcc *eni_vcc; | ||
321 | |||
322 | dev = vcc->dev; | ||
323 | eni_dev = ENI_DEV(dev); | ||
324 | /* immediately halt adapter */ | ||
325 | eni_out(eni_in(MID_MC_S) & | ||
326 | ~(MID_DMA_ENABLE | MID_TX_ENABLE | MID_RX_ENABLE),MID_MC_S); | ||
327 | /* dump useful information */ | ||
328 | eni_vcc = ENI_VCC(vcc); | ||
329 | printk(KERN_ALERT DEV_LABEL "(itf %d): driver error - RX ident " | ||
330 | "mismatch\n",dev->number); | ||
331 | printk(KERN_ALERT " VCI %d, rxing %d, words %ld\n",vcc->vci, | ||
332 | eni_vcc->rxing,eni_vcc->words); | ||
333 | printk(KERN_ALERT " host descr 0x%lx, rx pos 0x%lx, descr value " | ||
334 | "0x%x\n",eni_vcc->descr,eni_vcc->rx_pos, | ||
335 | (unsigned) readl(eni_vcc->recv+eni_vcc->descr*4)); | ||
336 | printk(KERN_ALERT " last %p, servicing %d\n",eni_vcc->last, | ||
337 | eni_vcc->servicing); | ||
338 | EVENT("---dump ends here---\n",0,0); | ||
339 | printk(KERN_NOTICE "---recent events---\n"); | ||
340 | event_dump(); | ||
341 | ENI_DEV(dev)->fast = NULL; /* really stop it */ | ||
342 | ENI_DEV(dev)->slow = NULL; | ||
343 | skb_queue_head_init(&ENI_DEV(dev)->rx_queue); | ||
344 | } | ||
345 | |||
346 | |||
347 | static int do_rx_dma(struct atm_vcc *vcc,struct sk_buff *skb, | ||
348 | unsigned long skip,unsigned long size,unsigned long eff) | ||
349 | { | ||
350 | struct eni_dev *eni_dev; | ||
351 | struct eni_vcc *eni_vcc; | ||
352 | u32 dma_rd,dma_wr; | ||
353 | u32 dma[RX_DMA_BUF*2]; | ||
354 | dma_addr_t paddr; | ||
355 | unsigned long here; | ||
356 | int i,j; | ||
357 | |||
358 | eni_dev = ENI_DEV(vcc->dev); | ||
359 | eni_vcc = ENI_VCC(vcc); | ||
360 | paddr = 0; /* GCC, shut up */ | ||
361 | if (skb) { | ||
362 | paddr = pci_map_single(eni_dev->pci_dev,skb->data,skb->len, | ||
363 | PCI_DMA_FROMDEVICE); | ||
364 | ENI_PRV_PADDR(skb) = paddr; | ||
365 | if (paddr & 3) | ||
366 | printk(KERN_CRIT DEV_LABEL "(itf %d): VCI %d has " | ||
367 | "mis-aligned RX data (0x%lx)\n",vcc->dev->number, | ||
368 | vcc->vci,(unsigned long) paddr); | ||
369 | ENI_PRV_SIZE(skb) = size+skip; | ||
370 | /* PDU plus descriptor */ | ||
371 | ATM_SKB(skb)->vcc = vcc; | ||
372 | } | ||
373 | j = 0; | ||
374 | if ((eff && skip) || 1) { /* @@@ actually, skip is always == 1 ... */ | ||
375 | here = (eni_vcc->descr+skip) & (eni_vcc->words-1); | ||
376 | dma[j++] = (here << MID_DMA_COUNT_SHIFT) | (vcc->vci | ||
377 | << MID_DMA_VCI_SHIFT) | MID_DT_JK; | ||
378 | j++; | ||
379 | } | ||
380 | here = (eni_vcc->descr+size+skip) & (eni_vcc->words-1); | ||
381 | if (!eff) size += skip; | ||
382 | else { | ||
383 | unsigned long words; | ||
384 | |||
385 | if (!size) { | ||
386 | DPRINTK("strange things happen ...\n"); | ||
387 | EVENT("strange things happen ... (skip=%ld,eff=%ld)\n", | ||
388 | size,eff); | ||
389 | } | ||
390 | words = eff; | ||
391 | if (paddr & 15) { | ||
392 | unsigned long init; | ||
393 | |||
394 | init = 4-((paddr & 15) >> 2); | ||
395 | if (init > words) init = words; | ||
396 | dma[j++] = MID_DT_WORD | (init << MID_DMA_COUNT_SHIFT) | | ||
397 | (vcc->vci << MID_DMA_VCI_SHIFT); | ||
398 | dma[j++] = paddr; | ||
399 | paddr += init << 2; | ||
400 | words -= init; | ||
401 | } | ||
402 | #ifdef CONFIG_ATM_ENI_BURST_RX_16W /* may work with some PCI chipsets ... */ | ||
403 | if (words & ~15) { | ||
404 | dma[j++] = MID_DT_16W | ((words >> 4) << | ||
405 | MID_DMA_COUNT_SHIFT) | (vcc->vci << | ||
406 | MID_DMA_VCI_SHIFT); | ||
407 | dma[j++] = paddr; | ||
408 | paddr += (words & ~15) << 2; | ||
409 | words &= 15; | ||
410 | } | ||
411 | #endif | ||
412 | #ifdef CONFIG_ATM_ENI_BURST_RX_8W /* works only with *some* PCI chipsets ... */ | ||
413 | if (words & ~7) { | ||
414 | dma[j++] = MID_DT_8W | ((words >> 3) << | ||
415 | MID_DMA_COUNT_SHIFT) | (vcc->vci << | ||
416 | MID_DMA_VCI_SHIFT); | ||
417 | dma[j++] = paddr; | ||
418 | paddr += (words & ~7) << 2; | ||
419 | words &= 7; | ||
420 | } | ||
421 | #endif | ||
422 | #ifdef CONFIG_ATM_ENI_BURST_RX_4W /* recommended */ | ||
423 | if (words & ~3) { | ||
424 | dma[j++] = MID_DT_4W | ((words >> 2) << | ||
425 | MID_DMA_COUNT_SHIFT) | (vcc->vci << | ||
426 | MID_DMA_VCI_SHIFT); | ||
427 | dma[j++] = paddr; | ||
428 | paddr += (words & ~3) << 2; | ||
429 | words &= 3; | ||
430 | } | ||
431 | #endif | ||
432 | #ifdef CONFIG_ATM_ENI_BURST_RX_2W /* probably useless if RX_4W, RX_8W, ... */ | ||
433 | if (words & ~1) { | ||
434 | dma[j++] = MID_DT_2W | ((words >> 1) << | ||
435 | MID_DMA_COUNT_SHIFT) | (vcc->vci << | ||
436 | MID_DMA_VCI_SHIFT); | ||
437 | dma[j++] = paddr; | ||
438 | paddr += (words & ~1) << 2; | ||
439 | words &= 1; | ||
440 | } | ||
441 | #endif | ||
442 | if (words) { | ||
443 | dma[j++] = MID_DT_WORD | (words << MID_DMA_COUNT_SHIFT) | ||
444 | | (vcc->vci << MID_DMA_VCI_SHIFT); | ||
445 | dma[j++] = paddr; | ||
446 | } | ||
447 | } | ||
448 | if (size != eff) { | ||
449 | dma[j++] = (here << MID_DMA_COUNT_SHIFT) | | ||
450 | (vcc->vci << MID_DMA_VCI_SHIFT) | MID_DT_JK; | ||
451 | j++; | ||
452 | } | ||
453 | if (!j || j > 2*RX_DMA_BUF) { | ||
454 | printk(KERN_CRIT DEV_LABEL "!j or j too big!!!\n"); | ||
455 | goto trouble; | ||
456 | } | ||
457 | dma[j-2] |= MID_DMA_END; | ||
458 | j = j >> 1; | ||
459 | dma_wr = eni_in(MID_DMA_WR_RX); | ||
460 | dma_rd = eni_in(MID_DMA_RD_RX); | ||
461 | /* | ||
462 | * Can I move the dma_wr pointer by 2j+1 positions without overwriting | ||
463 | * data that hasn't been read (position of dma_rd) yet ? | ||
464 | */ | ||
465 | if (!NEPMOK(dma_wr,j+j+1,dma_rd,NR_DMA_RX)) { /* @@@ +1 is ugly */ | ||
466 | printk(KERN_WARNING DEV_LABEL "(itf %d): RX DMA full\n", | ||
467 | vcc->dev->number); | ||
468 | goto trouble; | ||
469 | } | ||
470 | for (i = 0; i < j; i++) { | ||
471 | writel(dma[i*2],eni_dev->rx_dma+dma_wr*8); | ||
472 | writel(dma[i*2+1],eni_dev->rx_dma+dma_wr*8+4); | ||
473 | dma_wr = (dma_wr+1) & (NR_DMA_RX-1); | ||
474 | } | ||
475 | if (skb) { | ||
476 | ENI_PRV_POS(skb) = eni_vcc->descr+size+1; | ||
477 | skb_queue_tail(&eni_dev->rx_queue,skb); | ||
478 | eni_vcc->last = skb; | ||
479 | rx_enqueued++; | ||
480 | } | ||
481 | eni_vcc->descr = here; | ||
482 | eni_out(dma_wr,MID_DMA_WR_RX); | ||
483 | return 0; | ||
484 | |||
485 | trouble: | ||
486 | if (paddr) | ||
487 | pci_unmap_single(eni_dev->pci_dev,paddr,skb->len, | ||
488 | PCI_DMA_FROMDEVICE); | ||
489 | if (skb) dev_kfree_skb_irq(skb); | ||
490 | return -1; | ||
491 | } | ||
492 | |||
493 | |||
494 | static void discard(struct atm_vcc *vcc,unsigned long size) | ||
495 | { | ||
496 | struct eni_vcc *eni_vcc; | ||
497 | |||
498 | eni_vcc = ENI_VCC(vcc); | ||
499 | EVENT("discard (size=%ld)\n",size,0); | ||
500 | while (do_rx_dma(vcc,NULL,1,size,0)) EVENT("BUSY LOOP",0,0); | ||
501 | /* could do a full fallback, but that might be more expensive */ | ||
502 | if (eni_vcc->rxing) ENI_PRV_POS(eni_vcc->last) += size+1; | ||
503 | else eni_vcc->rx_pos = (eni_vcc->rx_pos+size+1) & (eni_vcc->words-1); | ||
504 | } | ||
505 | |||
506 | |||
507 | /* | ||
508 | * TODO: should check whether direct copies (without DMA setup, dequeuing on | ||
509 | * interrupt, etc.) aren't much faster for AAL0 | ||
510 | */ | ||
511 | |||
512 | static int rx_aal0(struct atm_vcc *vcc) | ||
513 | { | ||
514 | struct eni_vcc *eni_vcc; | ||
515 | unsigned long descr; | ||
516 | unsigned long length; | ||
517 | struct sk_buff *skb; | ||
518 | |||
519 | DPRINTK(">rx_aal0\n"); | ||
520 | eni_vcc = ENI_VCC(vcc); | ||
521 | descr = readl(eni_vcc->recv+eni_vcc->descr*4); | ||
522 | if ((descr & MID_RED_IDEN) != (MID_RED_RX_ID << MID_RED_SHIFT)) { | ||
523 | rx_ident_err(vcc); | ||
524 | return 1; | ||
525 | } | ||
526 | if (descr & MID_RED_T) { | ||
527 | DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n", | ||
528 | vcc->dev->number); | ||
529 | length = 0; | ||
530 | atomic_inc(&vcc->stats->rx_err); | ||
531 | } | ||
532 | else { | ||
533 | length = ATM_CELL_SIZE-1; /* no HEC */ | ||
534 | } | ||
535 | skb = length ? atm_alloc_charge(vcc,length,GFP_ATOMIC) : NULL; | ||
536 | if (!skb) { | ||
537 | discard(vcc,length >> 2); | ||
538 | return 0; | ||
539 | } | ||
540 | skb_put(skb,length); | ||
541 | skb->stamp = eni_vcc->timestamp; | ||
542 | DPRINTK("got len %ld\n",length); | ||
543 | if (do_rx_dma(vcc,skb,1,length >> 2,length >> 2)) return 1; | ||
544 | eni_vcc->rxing++; | ||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | |||
549 | static int rx_aal5(struct atm_vcc *vcc) | ||
550 | { | ||
551 | struct eni_vcc *eni_vcc; | ||
552 | unsigned long descr; | ||
553 | unsigned long size,eff,length; | ||
554 | struct sk_buff *skb; | ||
555 | |||
556 | EVENT("rx_aal5\n",0,0); | ||
557 | DPRINTK(">rx_aal5\n"); | ||
558 | eni_vcc = ENI_VCC(vcc); | ||
559 | descr = readl(eni_vcc->recv+eni_vcc->descr*4); | ||
560 | if ((descr & MID_RED_IDEN) != (MID_RED_RX_ID << MID_RED_SHIFT)) { | ||
561 | rx_ident_err(vcc); | ||
562 | return 1; | ||
563 | } | ||
564 | if (descr & (MID_RED_T | MID_RED_CRC_ERR)) { | ||
565 | if (descr & MID_RED_T) { | ||
566 | EVENT("empty cell (descr=0x%lx)\n",descr,0); | ||
567 | DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n", | ||
568 | vcc->dev->number); | ||
569 | size = 0; | ||
570 | } | ||
571 | else { | ||
572 | static unsigned long silence = 0; | ||
573 | |||
574 | if (time_after(jiffies, silence) || silence == 0) { | ||
575 | printk(KERN_WARNING DEV_LABEL "(itf %d): " | ||
576 | "discarding PDU(s) with CRC error\n", | ||
577 | vcc->dev->number); | ||
578 | silence = (jiffies+2*HZ)|1; | ||
579 | } | ||
580 | size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2); | ||
581 | EVENT("CRC error (descr=0x%lx,size=%ld)\n",descr, | ||
582 | size); | ||
583 | } | ||
584 | eff = length = 0; | ||
585 | atomic_inc(&vcc->stats->rx_err); | ||
586 | } | ||
587 | else { | ||
588 | size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2); | ||
589 | DPRINTK("size=%ld\n",size); | ||
590 | length = readl(eni_vcc->recv+(((eni_vcc->descr+size-1) & | ||
591 | (eni_vcc->words-1)))*4) & 0xffff; | ||
592 | /* -trailer(2)+header(1) */ | ||
593 | if (length && length <= (size << 2)-8 && length <= | ||
594 | ATM_MAX_AAL5_PDU) eff = (length+3) >> 2; | ||
595 | else { /* ^ trailer length (8) */ | ||
596 | EVENT("bad PDU (descr=0x08%lx,length=%ld)\n",descr, | ||
597 | length); | ||
598 | printk(KERN_ERR DEV_LABEL "(itf %d): bad AAL5 PDU " | ||
599 | "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n", | ||
600 | vcc->dev->number,vcc->vci,length,size << 2,descr); | ||
601 | length = eff = 0; | ||
602 | atomic_inc(&vcc->stats->rx_err); | ||
603 | } | ||
604 | } | ||
605 | skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL; | ||
606 | if (!skb) { | ||
607 | discard(vcc,size); | ||
608 | return 0; | ||
609 | } | ||
610 | skb_put(skb,length); | ||
611 | DPRINTK("got len %ld\n",length); | ||
612 | if (do_rx_dma(vcc,skb,1,size,eff)) return 1; | ||
613 | eni_vcc->rxing++; | ||
614 | return 0; | ||
615 | } | ||
616 | |||
617 | |||
618 | static inline int rx_vcc(struct atm_vcc *vcc) | ||
619 | { | ||
620 | void __iomem *vci_dsc; | ||
621 | unsigned long tmp; | ||
622 | struct eni_vcc *eni_vcc; | ||
623 | |||
624 | eni_vcc = ENI_VCC(vcc); | ||
625 | vci_dsc = ENI_DEV(vcc->dev)->vci+vcc->vci*16; | ||
626 | EVENT("rx_vcc(1)\n",0,0); | ||
627 | while (eni_vcc->descr != (tmp = (readl(vci_dsc+4) & MID_VCI_DESCR) >> | ||
628 | MID_VCI_DESCR_SHIFT)) { | ||
629 | EVENT("rx_vcc(2: host dsc=0x%lx, nic dsc=0x%lx)\n", | ||
630 | eni_vcc->descr,tmp); | ||
631 | DPRINTK("CB_DESCR %ld REG_DESCR %d\n",ENI_VCC(vcc)->descr, | ||
632 | (((unsigned) readl(vci_dsc+4) & MID_VCI_DESCR) >> | ||
633 | MID_VCI_DESCR_SHIFT)); | ||
634 | if (ENI_VCC(vcc)->rx(vcc)) return 1; | ||
635 | } | ||
636 | /* clear IN_SERVICE flag */ | ||
637 | writel(readl(vci_dsc) & ~MID_VCI_IN_SERVICE,vci_dsc); | ||
638 | /* | ||
639 | * If new data has arrived between evaluating the while condition and | ||
640 | * clearing IN_SERVICE, we wouldn't be notified until additional data | ||
641 | * follows. So we have to loop again to be sure. | ||
642 | */ | ||
643 | EVENT("rx_vcc(3)\n",0,0); | ||
644 | while (ENI_VCC(vcc)->descr != (tmp = (readl(vci_dsc+4) & MID_VCI_DESCR) | ||
645 | >> MID_VCI_DESCR_SHIFT)) { | ||
646 | EVENT("rx_vcc(4: host dsc=0x%lx, nic dsc=0x%lx)\n", | ||
647 | eni_vcc->descr,tmp); | ||
648 | DPRINTK("CB_DESCR %ld REG_DESCR %d\n",ENI_VCC(vcc)->descr, | ||
649 | (((unsigned) readl(vci_dsc+4) & MID_VCI_DESCR) >> | ||
650 | MID_VCI_DESCR_SHIFT)); | ||
651 | if (ENI_VCC(vcc)->rx(vcc)) return 1; | ||
652 | } | ||
653 | return 0; | ||
654 | } | ||
655 | |||
656 | |||
657 | static void poll_rx(struct atm_dev *dev) | ||
658 | { | ||
659 | struct eni_dev *eni_dev; | ||
660 | struct atm_vcc *curr; | ||
661 | |||
662 | eni_dev = ENI_DEV(dev); | ||
663 | while ((curr = eni_dev->fast)) { | ||
664 | EVENT("poll_rx.fast\n",0,0); | ||
665 | if (rx_vcc(curr)) return; | ||
666 | eni_dev->fast = ENI_VCC(curr)->next; | ||
667 | ENI_VCC(curr)->next = ENI_VCC_NOS; | ||
668 | barrier(); | ||
669 | ENI_VCC(curr)->servicing--; | ||
670 | } | ||
671 | while ((curr = eni_dev->slow)) { | ||
672 | EVENT("poll_rx.slow\n",0,0); | ||
673 | if (rx_vcc(curr)) return; | ||
674 | eni_dev->slow = ENI_VCC(curr)->next; | ||
675 | ENI_VCC(curr)->next = ENI_VCC_NOS; | ||
676 | barrier(); | ||
677 | ENI_VCC(curr)->servicing--; | ||
678 | } | ||
679 | } | ||
680 | |||
681 | |||
682 | static void get_service(struct atm_dev *dev) | ||
683 | { | ||
684 | struct eni_dev *eni_dev; | ||
685 | struct atm_vcc *vcc; | ||
686 | unsigned long vci; | ||
687 | |||
688 | DPRINTK(">get_service\n"); | ||
689 | eni_dev = ENI_DEV(dev); | ||
690 | while (eni_in(MID_SERV_WRITE) != eni_dev->serv_read) { | ||
691 | vci = readl(eni_dev->service+eni_dev->serv_read*4); | ||
692 | eni_dev->serv_read = (eni_dev->serv_read+1) & (NR_SERVICE-1); | ||
693 | vcc = eni_dev->rx_map[vci & 1023]; | ||
694 | if (!vcc) { | ||
695 | printk(KERN_CRIT DEV_LABEL "(itf %d): VCI %ld not " | ||
696 | "found\n",dev->number,vci); | ||
697 | continue; /* nasty but we try to go on anyway */ | ||
698 | /* @@@ nope, doesn't work */ | ||
699 | } | ||
700 | EVENT("getting from service\n",0,0); | ||
701 | if (ENI_VCC(vcc)->next != ENI_VCC_NOS) { | ||
702 | EVENT("double service\n",0,0); | ||
703 | DPRINTK("Grr, servicing VCC %ld twice\n",vci); | ||
704 | continue; | ||
705 | } | ||
706 | do_gettimeofday(&ENI_VCC(vcc)->timestamp); | ||
707 | ENI_VCC(vcc)->next = NULL; | ||
708 | if (vcc->qos.rxtp.traffic_class == ATM_CBR) { | ||
709 | if (eni_dev->fast) | ||
710 | ENI_VCC(eni_dev->last_fast)->next = vcc; | ||
711 | else eni_dev->fast = vcc; | ||
712 | eni_dev->last_fast = vcc; | ||
713 | } | ||
714 | else { | ||
715 | if (eni_dev->slow) | ||
716 | ENI_VCC(eni_dev->last_slow)->next = vcc; | ||
717 | else eni_dev->slow = vcc; | ||
718 | eni_dev->last_slow = vcc; | ||
719 | } | ||
720 | putting++; | ||
721 | ENI_VCC(vcc)->servicing++; | ||
722 | } | ||
723 | } | ||
724 | |||
725 | |||
726 | static void dequeue_rx(struct atm_dev *dev) | ||
727 | { | ||
728 | struct eni_dev *eni_dev; | ||
729 | struct eni_vcc *eni_vcc; | ||
730 | struct atm_vcc *vcc; | ||
731 | struct sk_buff *skb; | ||
732 | void __iomem *vci_dsc; | ||
733 | int first; | ||
734 | |||
735 | eni_dev = ENI_DEV(dev); | ||
736 | first = 1; | ||
737 | while (1) { | ||
738 | skb = skb_dequeue(&eni_dev->rx_queue); | ||
739 | if (!skb) { | ||
740 | if (first) { | ||
741 | DPRINTK(DEV_LABEL "(itf %d): RX but not " | ||
742 | "rxing\n",dev->number); | ||
743 | EVENT("nothing to dequeue\n",0,0); | ||
744 | } | ||
745 | break; | ||
746 | } | ||
747 | EVENT("dequeued (size=%ld,pos=0x%lx)\n",ENI_PRV_SIZE(skb), | ||
748 | ENI_PRV_POS(skb)); | ||
749 | rx_dequeued++; | ||
750 | vcc = ATM_SKB(skb)->vcc; | ||
751 | eni_vcc = ENI_VCC(vcc); | ||
752 | first = 0; | ||
753 | vci_dsc = eni_dev->vci+vcc->vci*16; | ||
754 | if (!EEPMOK(eni_vcc->rx_pos,ENI_PRV_SIZE(skb), | ||
755 | (readl(vci_dsc+4) & MID_VCI_READ) >> MID_VCI_READ_SHIFT, | ||
756 | eni_vcc->words)) { | ||
757 | EVENT("requeuing\n",0,0); | ||
758 | skb_queue_head(&eni_dev->rx_queue,skb); | ||
759 | break; | ||
760 | } | ||
761 | eni_vcc->rxing--; | ||
762 | eni_vcc->rx_pos = ENI_PRV_POS(skb) & (eni_vcc->words-1); | ||
763 | pci_unmap_single(eni_dev->pci_dev,ENI_PRV_PADDR(skb),skb->len, | ||
764 | PCI_DMA_TODEVICE); | ||
765 | if (!skb->len) dev_kfree_skb_irq(skb); | ||
766 | else { | ||
767 | EVENT("pushing (len=%ld)\n",skb->len,0); | ||
768 | if (vcc->qos.aal == ATM_AAL0) | ||
769 | *(unsigned long *) skb->data = | ||
770 | ntohl(*(unsigned long *) skb->data); | ||
771 | memset(skb->cb,0,sizeof(struct eni_skb_prv)); | ||
772 | vcc->push(vcc,skb); | ||
773 | pushed++; | ||
774 | } | ||
775 | atomic_inc(&vcc->stats->rx); | ||
776 | } | ||
777 | wake_up(&eni_dev->rx_wait); | ||
778 | } | ||
779 | |||
780 | |||
781 | static int open_rx_first(struct atm_vcc *vcc) | ||
782 | { | ||
783 | struct eni_dev *eni_dev; | ||
784 | struct eni_vcc *eni_vcc; | ||
785 | unsigned long size; | ||
786 | |||
787 | DPRINTK("open_rx_first\n"); | ||
788 | eni_dev = ENI_DEV(vcc->dev); | ||
789 | eni_vcc = ENI_VCC(vcc); | ||
790 | eni_vcc->rx = NULL; | ||
791 | if (vcc->qos.rxtp.traffic_class == ATM_NONE) return 0; | ||
792 | size = vcc->qos.rxtp.max_sdu*eni_dev->rx_mult/100; | ||
793 | if (size > MID_MAX_BUF_SIZE && vcc->qos.rxtp.max_sdu <= | ||
794 | MID_MAX_BUF_SIZE) | ||
795 | size = MID_MAX_BUF_SIZE; | ||
796 | eni_vcc->recv = eni_alloc_mem(eni_dev,&size); | ||
797 | DPRINTK("rx at 0x%lx\n",eni_vcc->recv); | ||
798 | eni_vcc->words = size >> 2; | ||
799 | if (!eni_vcc->recv) return -ENOBUFS; | ||
800 | eni_vcc->rx = vcc->qos.aal == ATM_AAL5 ? rx_aal5 : rx_aal0; | ||
801 | eni_vcc->descr = 0; | ||
802 | eni_vcc->rx_pos = 0; | ||
803 | eni_vcc->rxing = 0; | ||
804 | eni_vcc->servicing = 0; | ||
805 | eni_vcc->next = ENI_VCC_NOS; | ||
806 | return 0; | ||
807 | } | ||
808 | |||
809 | |||
810 | static int open_rx_second(struct atm_vcc *vcc) | ||
811 | { | ||
812 | void __iomem *here; | ||
813 | struct eni_dev *eni_dev; | ||
814 | struct eni_vcc *eni_vcc; | ||
815 | unsigned long size; | ||
816 | int order; | ||
817 | |||
818 | DPRINTK("open_rx_second\n"); | ||
819 | eni_dev = ENI_DEV(vcc->dev); | ||
820 | eni_vcc = ENI_VCC(vcc); | ||
821 | if (!eni_vcc->rx) return 0; | ||
822 | /* set up VCI descriptor */ | ||
823 | here = eni_dev->vci+vcc->vci*16; | ||
824 | DPRINTK("loc 0x%x\n",(unsigned) (eni_vcc->recv-eni_dev->ram)/4); | ||
825 | size = eni_vcc->words >> 8; | ||
826 | for (order = -1; size; order++) size >>= 1; | ||
827 | writel(0,here+4); /* descr, read = 0 */ | ||
828 | writel(0,here+8); /* write, state, count = 0 */ | ||
829 | if (eni_dev->rx_map[vcc->vci]) | ||
830 | printk(KERN_CRIT DEV_LABEL "(itf %d): BUG - VCI %d already " | ||
831 | "in use\n",vcc->dev->number,vcc->vci); | ||
832 | eni_dev->rx_map[vcc->vci] = vcc; /* now it counts */ | ||
833 | writel(((vcc->qos.aal != ATM_AAL5 ? MID_MODE_RAW : MID_MODE_AAL5) << | ||
834 | MID_VCI_MODE_SHIFT) | MID_VCI_PTI_MODE | | ||
835 | (((eni_vcc->recv-eni_dev->ram) >> (MID_LOC_SKIP+2)) << | ||
836 | MID_VCI_LOCATION_SHIFT) | (order << MID_VCI_SIZE_SHIFT),here); | ||
837 | return 0; | ||
838 | } | ||
839 | |||
840 | |||
841 | static void close_rx(struct atm_vcc *vcc) | ||
842 | { | ||
843 | DECLARE_WAITQUEUE(wait,current); | ||
844 | void __iomem *here; | ||
845 | struct eni_dev *eni_dev; | ||
846 | struct eni_vcc *eni_vcc; | ||
847 | |||
848 | eni_vcc = ENI_VCC(vcc); | ||
849 | if (!eni_vcc->rx) return; | ||
850 | eni_dev = ENI_DEV(vcc->dev); | ||
851 | if (vcc->vpi != ATM_VPI_UNSPEC && vcc->vci != ATM_VCI_UNSPEC) { | ||
852 | here = eni_dev->vci+vcc->vci*16; | ||
853 | /* block receiver */ | ||
854 | writel((readl(here) & ~MID_VCI_MODE) | (MID_MODE_TRASH << | ||
855 | MID_VCI_MODE_SHIFT),here); | ||
856 | /* wait for receiver to become idle */ | ||
857 | udelay(27); | ||
858 | /* discard pending cell */ | ||
859 | writel(readl(here) & ~MID_VCI_IN_SERVICE,here); | ||
860 | /* don't accept any new ones */ | ||
861 | eni_dev->rx_map[vcc->vci] = NULL; | ||
862 | /* wait for RX queue to drain */ | ||
863 | DPRINTK("eni_close: waiting for RX ...\n"); | ||
864 | EVENT("RX closing\n",0,0); | ||
865 | add_wait_queue(&eni_dev->rx_wait,&wait); | ||
866 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
867 | barrier(); | ||
868 | for (;;) { | ||
869 | /* transition service->rx: rxing++, servicing-- */ | ||
870 | if (!eni_vcc->servicing) { | ||
871 | barrier(); | ||
872 | if (!eni_vcc->rxing) break; | ||
873 | } | ||
874 | EVENT("drain PDUs (rx %ld, serv %ld)\n",eni_vcc->rxing, | ||
875 | eni_vcc->servicing); | ||
876 | printk(KERN_INFO "%d+%d RX left\n",eni_vcc->servicing, | ||
877 | eni_vcc->rxing); | ||
878 | schedule(); | ||
879 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
880 | } | ||
881 | for (;;) { | ||
882 | int at_end; | ||
883 | u32 tmp; | ||
884 | |||
885 | tasklet_disable(&eni_dev->task); | ||
886 | tmp = readl(eni_dev->vci+vcc->vci*16+4) & MID_VCI_READ; | ||
887 | at_end = eni_vcc->rx_pos == tmp >> MID_VCI_READ_SHIFT; | ||
888 | tasklet_enable(&eni_dev->task); | ||
889 | if (at_end) break; | ||
890 | EVENT("drain discard (host 0x%lx, nic 0x%lx)\n", | ||
891 | eni_vcc->rx_pos,tmp); | ||
892 | printk(KERN_INFO "draining RX: host 0x%lx, nic 0x%x\n", | ||
893 | eni_vcc->rx_pos,tmp); | ||
894 | schedule(); | ||
895 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
896 | } | ||
897 | set_current_state(TASK_RUNNING); | ||
898 | remove_wait_queue(&eni_dev->rx_wait,&wait); | ||
899 | } | ||
900 | eni_free_mem(eni_dev,eni_vcc->recv,eni_vcc->words << 2); | ||
901 | eni_vcc->rx = NULL; | ||
902 | } | ||
903 | |||
904 | |||
905 | static int start_rx(struct atm_dev *dev) | ||
906 | { | ||
907 | struct eni_dev *eni_dev; | ||
908 | |||
909 | eni_dev = ENI_DEV(dev); | ||
910 | eni_dev->rx_map = (struct atm_vcc **) get_zeroed_page(GFP_KERNEL); | ||
911 | if (!eni_dev->rx_map) { | ||
912 | printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n", | ||
913 | dev->number); | ||
914 | free_page((unsigned long) eni_dev->free_list); | ||
915 | return -ENOMEM; | ||
916 | } | ||
917 | memset(eni_dev->rx_map,0,PAGE_SIZE); | ||
918 | eni_dev->rx_mult = DEFAULT_RX_MULT; | ||
919 | eni_dev->fast = eni_dev->last_fast = NULL; | ||
920 | eni_dev->slow = eni_dev->last_slow = NULL; | ||
921 | init_waitqueue_head(&eni_dev->rx_wait); | ||
922 | skb_queue_head_init(&eni_dev->rx_queue); | ||
923 | eni_dev->serv_read = eni_in(MID_SERV_WRITE); | ||
924 | eni_out(0,MID_DMA_WR_RX); | ||
925 | return 0; | ||
926 | } | ||
927 | |||
928 | |||
929 | /*----------------------------------- TX ------------------------------------*/ | ||
930 | |||
931 | |||
932 | enum enq_res { enq_ok,enq_next,enq_jam }; | ||
933 | |||
934 | |||
935 | static inline void put_dma(int chan,u32 *dma,int *j,dma_addr_t paddr, | ||
936 | u32 size) | ||
937 | { | ||
938 | u32 init,words; | ||
939 | |||
940 | DPRINTK("put_dma: 0x%lx+0x%x\n",(unsigned long) paddr,size); | ||
941 | EVENT("put_dma: 0x%lx+0x%lx\n",(unsigned long) paddr,size); | ||
942 | #if 0 /* don't complain anymore */ | ||
943 | if (paddr & 3) | ||
944 | printk(KERN_ERR "put_dma: unaligned addr (0x%lx)\n",paddr); | ||
945 | if (size & 3) | ||
946 | printk(KERN_ERR "put_dma: unaligned size (0x%lx)\n",size); | ||
947 | #endif | ||
948 | if (paddr & 3) { | ||
949 | init = 4-(paddr & 3); | ||
950 | if (init > size || size < 7) init = size; | ||
951 | DPRINTK("put_dma: %lx DMA: %d/%d bytes\n", | ||
952 | (unsigned long) paddr,init,size); | ||
953 | dma[(*j)++] = MID_DT_BYTE | (init << MID_DMA_COUNT_SHIFT) | | ||
954 | (chan << MID_DMA_CHAN_SHIFT); | ||
955 | dma[(*j)++] = paddr; | ||
956 | paddr += init; | ||
957 | size -= init; | ||
958 | } | ||
959 | words = size >> 2; | ||
960 | size &= 3; | ||
961 | if (words && (paddr & 31)) { | ||
962 | init = 8-((paddr & 31) >> 2); | ||
963 | if (init > words) init = words; | ||
964 | DPRINTK("put_dma: %lx DMA: %d/%d words\n", | ||
965 | (unsigned long) paddr,init,words); | ||
966 | dma[(*j)++] = MID_DT_WORD | (init << MID_DMA_COUNT_SHIFT) | | ||
967 | (chan << MID_DMA_CHAN_SHIFT); | ||
968 | dma[(*j)++] = paddr; | ||
969 | paddr += init << 2; | ||
970 | words -= init; | ||
971 | } | ||
972 | #ifdef CONFIG_ATM_ENI_BURST_TX_16W /* may work with some PCI chipsets ... */ | ||
973 | if (words & ~15) { | ||
974 | DPRINTK("put_dma: %lx DMA: %d*16/%d words\n", | ||
975 | (unsigned long) paddr,words >> 4,words); | ||
976 | dma[(*j)++] = MID_DT_16W | ((words >> 4) << MID_DMA_COUNT_SHIFT) | ||
977 | | (chan << MID_DMA_CHAN_SHIFT); | ||
978 | dma[(*j)++] = paddr; | ||
979 | paddr += (words & ~15) << 2; | ||
980 | words &= 15; | ||
981 | } | ||
982 | #endif | ||
983 | #ifdef CONFIG_ATM_ENI_BURST_TX_8W /* recommended */ | ||
984 | if (words & ~7) { | ||
985 | DPRINTK("put_dma: %lx DMA: %d*8/%d words\n", | ||
986 | (unsigned long) paddr,words >> 3,words); | ||
987 | dma[(*j)++] = MID_DT_8W | ((words >> 3) << MID_DMA_COUNT_SHIFT) | ||
988 | | (chan << MID_DMA_CHAN_SHIFT); | ||
989 | dma[(*j)++] = paddr; | ||
990 | paddr += (words & ~7) << 2; | ||
991 | words &= 7; | ||
992 | } | ||
993 | #endif | ||
994 | #ifdef CONFIG_ATM_ENI_BURST_TX_4W /* probably useless if TX_8W or TX_16W */ | ||
995 | if (words & ~3) { | ||
996 | DPRINTK("put_dma: %lx DMA: %d*4/%d words\n", | ||
997 | (unsigned long) paddr,words >> 2,words); | ||
998 | dma[(*j)++] = MID_DT_4W | ((words >> 2) << MID_DMA_COUNT_SHIFT) | ||
999 | | (chan << MID_DMA_CHAN_SHIFT); | ||
1000 | dma[(*j)++] = paddr; | ||
1001 | paddr += (words & ~3) << 2; | ||
1002 | words &= 3; | ||
1003 | } | ||
1004 | #endif | ||
1005 | #ifdef CONFIG_ATM_ENI_BURST_TX_2W /* probably useless if TX_4W, TX_8W, ... */ | ||
1006 | if (words & ~1) { | ||
1007 | DPRINTK("put_dma: %lx DMA: %d*2/%d words\n", | ||
1008 | (unsigned long) paddr,words >> 1,words); | ||
1009 | dma[(*j)++] = MID_DT_2W | ((words >> 1) << MID_DMA_COUNT_SHIFT) | ||
1010 | | (chan << MID_DMA_CHAN_SHIFT); | ||
1011 | dma[(*j)++] = paddr; | ||
1012 | paddr += (words & ~1) << 2; | ||
1013 | words &= 1; | ||
1014 | } | ||
1015 | #endif | ||
1016 | if (words) { | ||
1017 | DPRINTK("put_dma: %lx DMA: %d words\n",(unsigned long) paddr, | ||
1018 | words); | ||
1019 | dma[(*j)++] = MID_DT_WORD | (words << MID_DMA_COUNT_SHIFT) | | ||
1020 | (chan << MID_DMA_CHAN_SHIFT); | ||
1021 | dma[(*j)++] = paddr; | ||
1022 | paddr += words << 2; | ||
1023 | } | ||
1024 | if (size) { | ||
1025 | DPRINTK("put_dma: %lx DMA: %d bytes\n",(unsigned long) paddr, | ||
1026 | size); | ||
1027 | dma[(*j)++] = MID_DT_BYTE | (size << MID_DMA_COUNT_SHIFT) | | ||
1028 | (chan << MID_DMA_CHAN_SHIFT); | ||
1029 | dma[(*j)++] = paddr; | ||
1030 | } | ||
1031 | } | ||
1032 | |||
1033 | |||
1034 | static enum enq_res do_tx(struct sk_buff *skb) | ||
1035 | { | ||
1036 | struct atm_vcc *vcc; | ||
1037 | struct eni_dev *eni_dev; | ||
1038 | struct eni_vcc *eni_vcc; | ||
1039 | struct eni_tx *tx; | ||
1040 | dma_addr_t paddr; | ||
1041 | u32 dma_rd,dma_wr; | ||
1042 | u32 size; /* in words */ | ||
1043 | int aal5,dma_size,i,j; | ||
1044 | |||
1045 | DPRINTK(">do_tx\n"); | ||
1046 | NULLCHECK(skb); | ||
1047 | EVENT("do_tx: skb=0x%lx, %ld bytes\n",(unsigned long) skb,skb->len); | ||
1048 | vcc = ATM_SKB(skb)->vcc; | ||
1049 | NULLCHECK(vcc); | ||
1050 | eni_dev = ENI_DEV(vcc->dev); | ||
1051 | NULLCHECK(eni_dev); | ||
1052 | eni_vcc = ENI_VCC(vcc); | ||
1053 | tx = eni_vcc->tx; | ||
1054 | NULLCHECK(tx); | ||
1055 | #if 0 /* Enable this for testing with the "align" program */ | ||
1056 | { | ||
1057 | unsigned int hack = *((char *) skb->data)-'0'; | ||
1058 | |||
1059 | if (hack < 8) { | ||
1060 | skb->data += hack; | ||
1061 | skb->len -= hack; | ||
1062 | } | ||
1063 | } | ||
1064 | #endif | ||
1065 | #if 0 /* should work now */ | ||
1066 | if ((unsigned long) skb->data & 3) | ||
1067 | printk(KERN_ERR DEV_LABEL "(itf %d): VCI %d has mis-aligned " | ||
1068 | "TX data\n",vcc->dev->number,vcc->vci); | ||
1069 | #endif | ||
1070 | /* | ||
1071 | * Potential future IP speedup: make hard_header big enough to put | ||
1072 | * segmentation descriptor directly into PDU. Saves: 4 slave writes, | ||
1073 | * 1 DMA xfer & 2 DMA'ed bytes (protocol layering is for wimps :-) | ||
1074 | */ | ||
1075 | |||
1076 | aal5 = vcc->qos.aal == ATM_AAL5; | ||
1077 | /* check space in buffer */ | ||
1078 | if (!aal5) | ||
1079 | size = (ATM_CELL_PAYLOAD >> 2)+TX_DESCR_SIZE; | ||
1080 | /* cell without HEC plus segmentation header (includes | ||
1081 | four-byte cell header) */ | ||
1082 | else { | ||
1083 | size = skb->len+4*AAL5_TRAILER+ATM_CELL_PAYLOAD-1; | ||
1084 | /* add AAL5 trailer */ | ||
1085 | size = ((size-(size % ATM_CELL_PAYLOAD)) >> 2)+TX_DESCR_SIZE; | ||
1086 | /* add segmentation header */ | ||
1087 | } | ||
1088 | /* | ||
1089 | * Can I move tx_pos by size bytes without getting closer than TX_GAP | ||
1090 | * to the read pointer ? TX_GAP means to leave some space for what | ||
1091 | * the manual calls "too close". | ||
1092 | */ | ||
1093 | if (!NEPMOK(tx->tx_pos,size+TX_GAP, | ||
1094 | eni_in(MID_TX_RDPTR(tx->index)),tx->words)) { | ||
1095 | DPRINTK(DEV_LABEL "(itf %d): TX full (size %d)\n", | ||
1096 | vcc->dev->number,size); | ||
1097 | return enq_next; | ||
1098 | } | ||
1099 | /* check DMA */ | ||
1100 | dma_wr = eni_in(MID_DMA_WR_TX); | ||
1101 | dma_rd = eni_in(MID_DMA_RD_TX); | ||
1102 | dma_size = 3; /* JK for descriptor and final fill, plus final size | ||
1103 | mis-alignment fix */ | ||
1104 | DPRINTK("iovcnt = %d\n",skb_shinfo(skb)->nr_frags); | ||
1105 | if (!skb_shinfo(skb)->nr_frags) dma_size += 5; | ||
1106 | else dma_size += 5*(skb_shinfo(skb)->nr_frags+1); | ||
1107 | if (dma_size > TX_DMA_BUF) { | ||
1108 | printk(KERN_CRIT DEV_LABEL "(itf %d): needs %d DMA entries " | ||
1109 | "(got only %d)\n",vcc->dev->number,dma_size,TX_DMA_BUF); | ||
1110 | } | ||
1111 | DPRINTK("dma_wr is %d, tx_pos is %ld\n",dma_wr,tx->tx_pos); | ||
1112 | if (dma_wr != dma_rd && ((dma_rd+NR_DMA_TX-dma_wr) & (NR_DMA_TX-1)) < | ||
1113 | dma_size) { | ||
1114 | printk(KERN_WARNING DEV_LABEL "(itf %d): TX DMA full\n", | ||
1115 | vcc->dev->number); | ||
1116 | return enq_jam; | ||
1117 | } | ||
1118 | paddr = pci_map_single(eni_dev->pci_dev,skb->data,skb->len, | ||
1119 | PCI_DMA_TODEVICE); | ||
1120 | ENI_PRV_PADDR(skb) = paddr; | ||
1121 | /* prepare DMA queue entries */ | ||
1122 | j = 0; | ||
1123 | eni_dev->dma[j++] = (((tx->tx_pos+TX_DESCR_SIZE) & (tx->words-1)) << | ||
1124 | MID_DMA_COUNT_SHIFT) | (tx->index << MID_DMA_CHAN_SHIFT) | | ||
1125 | MID_DT_JK; | ||
1126 | j++; | ||
1127 | if (!skb_shinfo(skb)->nr_frags) | ||
1128 | if (aal5) put_dma(tx->index,eni_dev->dma,&j,paddr,skb->len); | ||
1129 | else put_dma(tx->index,eni_dev->dma,&j,paddr+4,skb->len-4); | ||
1130 | else { | ||
1131 | DPRINTK("doing direct send\n"); /* @@@ well, this doesn't work anyway */ | ||
1132 | for (i = -1; i < skb_shinfo(skb)->nr_frags; i++) | ||
1133 | if (i == -1) | ||
1134 | put_dma(tx->index,eni_dev->dma,&j,(unsigned long) | ||
1135 | skb->data, | ||
1136 | skb->len - skb->data_len); | ||
1137 | else | ||
1138 | put_dma(tx->index,eni_dev->dma,&j,(unsigned long) | ||
1139 | skb_shinfo(skb)->frags[i].page + skb_shinfo(skb)->frags[i].page_offset, | ||
1140 | skb_shinfo(skb)->frags[i].size); | ||
1141 | } | ||
1142 | if (skb->len & 3) | ||
1143 | put_dma(tx->index,eni_dev->dma,&j,zeroes,4-(skb->len & 3)); | ||
1144 | /* JK for AAL5 trailer - AAL0 doesn't need it, but who cares ... */ | ||
1145 | eni_dev->dma[j++] = (((tx->tx_pos+size) & (tx->words-1)) << | ||
1146 | MID_DMA_COUNT_SHIFT) | (tx->index << MID_DMA_CHAN_SHIFT) | | ||
1147 | MID_DMA_END | MID_DT_JK; | ||
1148 | j++; | ||
1149 | DPRINTK("DMA at end: %d\n",j); | ||
1150 | /* store frame */ | ||
1151 | writel((MID_SEG_TX_ID << MID_SEG_ID_SHIFT) | | ||
1152 | (aal5 ? MID_SEG_AAL5 : 0) | (tx->prescaler << MID_SEG_PR_SHIFT) | | ||
1153 | (tx->resolution << MID_SEG_RATE_SHIFT) | | ||
1154 | (size/(ATM_CELL_PAYLOAD/4)),tx->send+tx->tx_pos*4); | ||
1155 | /*printk("dsc = 0x%08lx\n",(unsigned long) readl(tx->send+tx->tx_pos*4));*/ | ||
1156 | writel((vcc->vci << MID_SEG_VCI_SHIFT) | | ||
1157 | (aal5 ? 0 : (skb->data[3] & 0xf)) | | ||
1158 | (ATM_SKB(skb)->atm_options & ATM_ATMOPT_CLP ? MID_SEG_CLP : 0), | ||
1159 | tx->send+((tx->tx_pos+1) & (tx->words-1))*4); | ||
1160 | DPRINTK("size: %d, len:%d\n",size,skb->len); | ||
1161 | if (aal5) | ||
1162 | writel(skb->len,tx->send+ | ||
1163 | ((tx->tx_pos+size-AAL5_TRAILER) & (tx->words-1))*4); | ||
1164 | j = j >> 1; | ||
1165 | for (i = 0; i < j; i++) { | ||
1166 | writel(eni_dev->dma[i*2],eni_dev->tx_dma+dma_wr*8); | ||
1167 | writel(eni_dev->dma[i*2+1],eni_dev->tx_dma+dma_wr*8+4); | ||
1168 | dma_wr = (dma_wr+1) & (NR_DMA_TX-1); | ||
1169 | } | ||
1170 | ENI_PRV_POS(skb) = tx->tx_pos; | ||
1171 | ENI_PRV_SIZE(skb) = size; | ||
1172 | ENI_VCC(vcc)->txing += size; | ||
1173 | tx->tx_pos = (tx->tx_pos+size) & (tx->words-1); | ||
1174 | DPRINTK("dma_wr set to %d, tx_pos is now %ld\n",dma_wr,tx->tx_pos); | ||
1175 | eni_out(dma_wr,MID_DMA_WR_TX); | ||
1176 | skb_queue_tail(&eni_dev->tx_queue,skb); | ||
1177 | queued++; | ||
1178 | return enq_ok; | ||
1179 | } | ||
1180 | |||
1181 | |||
1182 | static void poll_tx(struct atm_dev *dev) | ||
1183 | { | ||
1184 | struct eni_tx *tx; | ||
1185 | struct sk_buff *skb; | ||
1186 | enum enq_res res; | ||
1187 | int i; | ||
1188 | |||
1189 | DPRINTK(">poll_tx\n"); | ||
1190 | for (i = NR_CHAN-1; i >= 0; i--) { | ||
1191 | tx = &ENI_DEV(dev)->tx[i]; | ||
1192 | if (tx->send) | ||
1193 | while ((skb = skb_dequeue(&tx->backlog))) { | ||
1194 | res = do_tx(skb); | ||
1195 | if (res == enq_ok) continue; | ||
1196 | DPRINTK("re-queuing TX PDU\n"); | ||
1197 | skb_queue_head(&tx->backlog,skb); | ||
1198 | requeued++; | ||
1199 | if (res == enq_jam) return; | ||
1200 | break; | ||
1201 | } | ||
1202 | } | ||
1203 | } | ||
1204 | |||
1205 | |||
1206 | static void dequeue_tx(struct atm_dev *dev) | ||
1207 | { | ||
1208 | struct eni_dev *eni_dev; | ||
1209 | struct atm_vcc *vcc; | ||
1210 | struct sk_buff *skb; | ||
1211 | struct eni_tx *tx; | ||
1212 | |||
1213 | NULLCHECK(dev); | ||
1214 | eni_dev = ENI_DEV(dev); | ||
1215 | NULLCHECK(eni_dev); | ||
1216 | while ((skb = skb_dequeue(&eni_dev->tx_queue))) { | ||
1217 | vcc = ATM_SKB(skb)->vcc; | ||
1218 | NULLCHECK(vcc); | ||
1219 | tx = ENI_VCC(vcc)->tx; | ||
1220 | NULLCHECK(ENI_VCC(vcc)->tx); | ||
1221 | DPRINTK("dequeue_tx: next 0x%lx curr 0x%x\n",ENI_PRV_POS(skb), | ||
1222 | (unsigned) eni_in(MID_TX_DESCRSTART(tx->index))); | ||
1223 | if (ENI_VCC(vcc)->txing < tx->words && ENI_PRV_POS(skb) == | ||
1224 | eni_in(MID_TX_DESCRSTART(tx->index))) { | ||
1225 | skb_queue_head(&eni_dev->tx_queue,skb); | ||
1226 | break; | ||
1227 | } | ||
1228 | ENI_VCC(vcc)->txing -= ENI_PRV_SIZE(skb); | ||
1229 | pci_unmap_single(eni_dev->pci_dev,ENI_PRV_PADDR(skb),skb->len, | ||
1230 | PCI_DMA_TODEVICE); | ||
1231 | if (vcc->pop) vcc->pop(vcc,skb); | ||
1232 | else dev_kfree_skb_irq(skb); | ||
1233 | atomic_inc(&vcc->stats->tx); | ||
1234 | wake_up(&eni_dev->tx_wait); | ||
1235 | dma_complete++; | ||
1236 | } | ||
1237 | } | ||
1238 | |||
1239 | |||
1240 | static struct eni_tx *alloc_tx(struct eni_dev *eni_dev,int ubr) | ||
1241 | { | ||
1242 | int i; | ||
1243 | |||
1244 | for (i = !ubr; i < NR_CHAN; i++) | ||
1245 | if (!eni_dev->tx[i].send) return eni_dev->tx+i; | ||
1246 | return NULL; | ||
1247 | } | ||
1248 | |||
1249 | |||
1250 | static int comp_tx(struct eni_dev *eni_dev,int *pcr,int reserved,int *pre, | ||
1251 | int *res,int unlimited) | ||
1252 | { | ||
1253 | static const int pre_div[] = { 4,16,128,2048 }; | ||
1254 | /* 2^(((x+2)^2-(x+2))/2+1) */ | ||
1255 | |||
1256 | if (unlimited) *pre = *res = 0; | ||
1257 | else { | ||
1258 | if (*pcr > 0) { | ||
1259 | int div; | ||
1260 | |||
1261 | for (*pre = 0; *pre < 3; (*pre)++) | ||
1262 | if (TS_CLOCK/pre_div[*pre]/64 <= *pcr) break; | ||
1263 | div = pre_div[*pre]**pcr; | ||
1264 | DPRINTK("min div %d\n",div); | ||
1265 | *res = TS_CLOCK/div-1; | ||
1266 | } | ||
1267 | else { | ||
1268 | int div; | ||
1269 | |||
1270 | if (!*pcr) *pcr = eni_dev->tx_bw+reserved; | ||
1271 | for (*pre = 3; *pre >= 0; (*pre)--) | ||
1272 | if (TS_CLOCK/pre_div[*pre]/64 > -*pcr) break; | ||
1273 | if (*pre < 3) (*pre)++; /* else fail later */ | ||
1274 | div = pre_div[*pre]*-*pcr; | ||
1275 | DPRINTK("max div %d\n",div); | ||
1276 | *res = (TS_CLOCK+div-1)/div-1; | ||
1277 | } | ||
1278 | if (*res < 0) *res = 0; | ||
1279 | if (*res > MID_SEG_MAX_RATE) *res = MID_SEG_MAX_RATE; | ||
1280 | } | ||
1281 | *pcr = TS_CLOCK/pre_div[*pre]/(*res+1); | ||
1282 | DPRINTK("out pcr: %d (%d:%d)\n",*pcr,*pre,*res); | ||
1283 | return 0; | ||
1284 | } | ||
1285 | |||
1286 | |||
1287 | static int reserve_or_set_tx(struct atm_vcc *vcc,struct atm_trafprm *txtp, | ||
1288 | int set_rsv,int set_shp) | ||
1289 | { | ||
1290 | struct eni_dev *eni_dev = ENI_DEV(vcc->dev); | ||
1291 | struct eni_vcc *eni_vcc = ENI_VCC(vcc); | ||
1292 | struct eni_tx *tx; | ||
1293 | unsigned long size; | ||
1294 | void __iomem *mem; | ||
1295 | int rate,ubr,unlimited,new_tx; | ||
1296 | int pre,res,order; | ||
1297 | int error; | ||
1298 | |||
1299 | rate = atm_pcr_goal(txtp); | ||
1300 | ubr = txtp->traffic_class == ATM_UBR; | ||
1301 | unlimited = ubr && (!rate || rate <= -ATM_OC3_PCR || | ||
1302 | rate >= ATM_OC3_PCR); | ||
1303 | if (!unlimited) { | ||
1304 | size = txtp->max_sdu*eni_dev->tx_mult/100; | ||
1305 | if (size > MID_MAX_BUF_SIZE && txtp->max_sdu <= | ||
1306 | MID_MAX_BUF_SIZE) | ||
1307 | size = MID_MAX_BUF_SIZE; | ||
1308 | } | ||
1309 | else { | ||
1310 | if (eni_dev->ubr) { | ||
1311 | eni_vcc->tx = eni_dev->ubr; | ||
1312 | txtp->pcr = ATM_OC3_PCR; | ||
1313 | return 0; | ||
1314 | } | ||
1315 | size = UBR_BUFFER; | ||
1316 | } | ||
1317 | new_tx = !eni_vcc->tx; | ||
1318 | mem = NULL; /* for gcc */ | ||
1319 | if (!new_tx) tx = eni_vcc->tx; | ||
1320 | else { | ||
1321 | mem = eni_alloc_mem(eni_dev,&size); | ||
1322 | if (!mem) return -ENOBUFS; | ||
1323 | tx = alloc_tx(eni_dev,unlimited); | ||
1324 | if (!tx) { | ||
1325 | eni_free_mem(eni_dev,mem,size); | ||
1326 | return -EBUSY; | ||
1327 | } | ||
1328 | DPRINTK("got chan %d\n",tx->index); | ||
1329 | tx->reserved = tx->shaping = 0; | ||
1330 | tx->send = mem; | ||
1331 | tx->words = size >> 2; | ||
1332 | skb_queue_head_init(&tx->backlog); | ||
1333 | for (order = 0; size > (1 << (order+10)); order++); | ||
1334 | eni_out((order << MID_SIZE_SHIFT) | | ||
1335 | ((tx->send-eni_dev->ram) >> (MID_LOC_SKIP+2)), | ||
1336 | MID_TX_PLACE(tx->index)); | ||
1337 | tx->tx_pos = eni_in(MID_TX_DESCRSTART(tx->index)) & | ||
1338 | MID_DESCR_START; | ||
1339 | } | ||
1340 | error = comp_tx(eni_dev,&rate,tx->reserved,&pre,&res,unlimited); | ||
1341 | if (!error && txtp->min_pcr > rate) error = -EINVAL; | ||
1342 | if (!error && txtp->max_pcr && txtp->max_pcr != ATM_MAX_PCR && | ||
1343 | txtp->max_pcr < rate) error = -EINVAL; | ||
1344 | if (!error && !ubr && rate > eni_dev->tx_bw+tx->reserved) | ||
1345 | error = -EINVAL; | ||
1346 | if (!error && set_rsv && !set_shp && rate < tx->shaping) | ||
1347 | error = -EINVAL; | ||
1348 | if (!error && !set_rsv && rate > tx->reserved && !ubr) | ||
1349 | error = -EINVAL; | ||
1350 | if (error) { | ||
1351 | if (new_tx) { | ||
1352 | tx->send = NULL; | ||
1353 | eni_free_mem(eni_dev,mem,size); | ||
1354 | } | ||
1355 | return error; | ||
1356 | } | ||
1357 | txtp->pcr = rate; | ||
1358 | if (set_rsv && !ubr) { | ||
1359 | eni_dev->tx_bw += tx->reserved; | ||
1360 | tx->reserved = rate; | ||
1361 | eni_dev->tx_bw -= rate; | ||
1362 | } | ||
1363 | if (set_shp || (unlimited && new_tx)) { | ||
1364 | if (unlimited && new_tx) eni_dev->ubr = tx; | ||
1365 | tx->prescaler = pre; | ||
1366 | tx->resolution = res; | ||
1367 | tx->shaping = rate; | ||
1368 | } | ||
1369 | if (set_shp) eni_vcc->tx = tx; | ||
1370 | DPRINTK("rsv %d shp %d\n",tx->reserved,tx->shaping); | ||
1371 | return 0; | ||
1372 | } | ||
1373 | |||
1374 | |||
1375 | static int open_tx_first(struct atm_vcc *vcc) | ||
1376 | { | ||
1377 | ENI_VCC(vcc)->tx = NULL; | ||
1378 | if (vcc->qos.txtp.traffic_class == ATM_NONE) return 0; | ||
1379 | ENI_VCC(vcc)->txing = 0; | ||
1380 | return reserve_or_set_tx(vcc,&vcc->qos.txtp,1,1); | ||
1381 | } | ||
1382 | |||
1383 | |||
1384 | static int open_tx_second(struct atm_vcc *vcc) | ||
1385 | { | ||
1386 | return 0; /* nothing to do */ | ||
1387 | } | ||
1388 | |||
1389 | |||
1390 | static void close_tx(struct atm_vcc *vcc) | ||
1391 | { | ||
1392 | DECLARE_WAITQUEUE(wait,current); | ||
1393 | struct eni_dev *eni_dev; | ||
1394 | struct eni_vcc *eni_vcc; | ||
1395 | |||
1396 | eni_vcc = ENI_VCC(vcc); | ||
1397 | if (!eni_vcc->tx) return; | ||
1398 | eni_dev = ENI_DEV(vcc->dev); | ||
1399 | /* wait for TX queue to drain */ | ||
1400 | DPRINTK("eni_close: waiting for TX ...\n"); | ||
1401 | add_wait_queue(&eni_dev->tx_wait,&wait); | ||
1402 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
1403 | for (;;) { | ||
1404 | int txing; | ||
1405 | |||
1406 | tasklet_disable(&eni_dev->task); | ||
1407 | txing = skb_peek(&eni_vcc->tx->backlog) || eni_vcc->txing; | ||
1408 | tasklet_enable(&eni_dev->task); | ||
1409 | if (!txing) break; | ||
1410 | DPRINTK("%d TX left\n",eni_vcc->txing); | ||
1411 | schedule(); | ||
1412 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
1413 | } | ||
1414 | set_current_state(TASK_RUNNING); | ||
1415 | remove_wait_queue(&eni_dev->tx_wait,&wait); | ||
1416 | if (eni_vcc->tx != eni_dev->ubr) { | ||
1417 | /* | ||
1418 | * Looping a few times in here is probably far cheaper than | ||
1419 | * keeping track of TX completions all the time, so let's poll | ||
1420 | * a bit ... | ||
1421 | */ | ||
1422 | while (eni_in(MID_TX_RDPTR(eni_vcc->tx->index)) != | ||
1423 | eni_in(MID_TX_DESCRSTART(eni_vcc->tx->index))) | ||
1424 | schedule(); | ||
1425 | eni_free_mem(eni_dev,eni_vcc->tx->send,eni_vcc->tx->words << 2); | ||
1426 | eni_vcc->tx->send = NULL; | ||
1427 | eni_dev->tx_bw += eni_vcc->tx->reserved; | ||
1428 | } | ||
1429 | eni_vcc->tx = NULL; | ||
1430 | } | ||
1431 | |||
1432 | |||
1433 | static int start_tx(struct atm_dev *dev) | ||
1434 | { | ||
1435 | struct eni_dev *eni_dev; | ||
1436 | int i; | ||
1437 | |||
1438 | eni_dev = ENI_DEV(dev); | ||
1439 | eni_dev->lost = 0; | ||
1440 | eni_dev->tx_bw = ATM_OC3_PCR; | ||
1441 | eni_dev->tx_mult = DEFAULT_TX_MULT; | ||
1442 | init_waitqueue_head(&eni_dev->tx_wait); | ||
1443 | eni_dev->ubr = NULL; | ||
1444 | skb_queue_head_init(&eni_dev->tx_queue); | ||
1445 | eni_out(0,MID_DMA_WR_TX); | ||
1446 | for (i = 0; i < NR_CHAN; i++) { | ||
1447 | eni_dev->tx[i].send = NULL; | ||
1448 | eni_dev->tx[i].index = i; | ||
1449 | } | ||
1450 | return 0; | ||
1451 | } | ||
1452 | |||
1453 | |||
1454 | /*--------------------------------- common ----------------------------------*/ | ||
1455 | |||
1456 | |||
1457 | #if 0 /* may become useful again when tuning things */ | ||
1458 | |||
1459 | static void foo(void) | ||
1460 | { | ||
1461 | printk(KERN_INFO | ||
1462 | "tx_complete=%d,dma_complete=%d,queued=%d,requeued=%d,sub=%d,\n" | ||
1463 | "backlogged=%d,rx_enqueued=%d,rx_dequeued=%d,putting=%d,pushed=%d\n", | ||
1464 | tx_complete,dma_complete,queued,requeued,submitted,backlogged, | ||
1465 | rx_enqueued,rx_dequeued,putting,pushed); | ||
1466 | if (eni_boards) printk(KERN_INFO "loss: %ld\n",ENI_DEV(eni_boards)->lost); | ||
1467 | } | ||
1468 | |||
1469 | #endif | ||
1470 | |||
1471 | |||
1472 | static void bug_int(struct atm_dev *dev,unsigned long reason) | ||
1473 | { | ||
1474 | struct eni_dev *eni_dev; | ||
1475 | |||
1476 | DPRINTK(">bug_int\n"); | ||
1477 | eni_dev = ENI_DEV(dev); | ||
1478 | if (reason & MID_DMA_ERR_ACK) | ||
1479 | printk(KERN_CRIT DEV_LABEL "(itf %d): driver error - DMA " | ||
1480 | "error\n",dev->number); | ||
1481 | if (reason & MID_TX_IDENT_MISM) | ||
1482 | printk(KERN_CRIT DEV_LABEL "(itf %d): driver error - ident " | ||
1483 | "mismatch\n",dev->number); | ||
1484 | if (reason & MID_TX_DMA_OVFL) | ||
1485 | printk(KERN_CRIT DEV_LABEL "(itf %d): driver error - DMA " | ||
1486 | "overflow\n",dev->number); | ||
1487 | EVENT("---dump ends here---\n",0,0); | ||
1488 | printk(KERN_NOTICE "---recent events---\n"); | ||
1489 | event_dump(); | ||
1490 | } | ||
1491 | |||
1492 | |||
1493 | static irqreturn_t eni_int(int irq,void *dev_id,struct pt_regs *regs) | ||
1494 | { | ||
1495 | struct atm_dev *dev; | ||
1496 | struct eni_dev *eni_dev; | ||
1497 | u32 reason; | ||
1498 | |||
1499 | DPRINTK(">eni_int\n"); | ||
1500 | dev = dev_id; | ||
1501 | eni_dev = ENI_DEV(dev); | ||
1502 | reason = eni_in(MID_ISA); | ||
1503 | DPRINTK(DEV_LABEL ": int 0x%lx\n",(unsigned long) reason); | ||
1504 | /* | ||
1505 | * Must handle these two right now, because reading ISA doesn't clear | ||
1506 | * them, so they re-occur and we never make it to the tasklet. Since | ||
1507 | * they're rare, we don't mind the occasional invocation of eni_tasklet | ||
1508 | * with eni_dev->events == 0. | ||
1509 | */ | ||
1510 | if (reason & MID_STAT_OVFL) { | ||
1511 | EVENT("stat overflow\n",0,0); | ||
1512 | eni_dev->lost += eni_in(MID_STAT) & MID_OVFL_TRASH; | ||
1513 | } | ||
1514 | if (reason & MID_SUNI_INT) { | ||
1515 | EVENT("SUNI int\n",0,0); | ||
1516 | dev->phy->interrupt(dev); | ||
1517 | #if 0 | ||
1518 | foo(); | ||
1519 | #endif | ||
1520 | } | ||
1521 | spin_lock(&eni_dev->lock); | ||
1522 | eni_dev->events |= reason; | ||
1523 | spin_unlock(&eni_dev->lock); | ||
1524 | tasklet_schedule(&eni_dev->task); | ||
1525 | return IRQ_HANDLED; | ||
1526 | } | ||
1527 | |||
1528 | |||
1529 | static void eni_tasklet(unsigned long data) | ||
1530 | { | ||
1531 | struct atm_dev *dev = (struct atm_dev *) data; | ||
1532 | struct eni_dev *eni_dev = ENI_DEV(dev); | ||
1533 | unsigned long flags; | ||
1534 | u32 events; | ||
1535 | |||
1536 | DPRINTK("eni_tasklet (dev %p)\n",dev); | ||
1537 | spin_lock_irqsave(&eni_dev->lock,flags); | ||
1538 | events = xchg(&eni_dev->events,0); | ||
1539 | spin_unlock_irqrestore(&eni_dev->lock,flags); | ||
1540 | if (events & MID_RX_DMA_COMPLETE) { | ||
1541 | EVENT("INT: RX DMA complete, starting dequeue_rx\n",0,0); | ||
1542 | dequeue_rx(dev); | ||
1543 | EVENT("dequeue_rx done, starting poll_rx\n",0,0); | ||
1544 | poll_rx(dev); | ||
1545 | EVENT("poll_rx done\n",0,0); | ||
1546 | /* poll_tx ? */ | ||
1547 | } | ||
1548 | if (events & MID_SERVICE) { | ||
1549 | EVENT("INT: service, starting get_service\n",0,0); | ||
1550 | get_service(dev); | ||
1551 | EVENT("get_service done, starting poll_rx\n",0,0); | ||
1552 | poll_rx(dev); | ||
1553 | EVENT("poll_rx done\n",0,0); | ||
1554 | } | ||
1555 | if (events & MID_TX_DMA_COMPLETE) { | ||
1556 | EVENT("INT: TX DMA COMPLETE\n",0,0); | ||
1557 | dequeue_tx(dev); | ||
1558 | } | ||
1559 | if (events & MID_TX_COMPLETE) { | ||
1560 | EVENT("INT: TX COMPLETE\n",0,0); | ||
1561 | tx_complete++; | ||
1562 | wake_up(&eni_dev->tx_wait); | ||
1563 | /* poll_rx ? */ | ||
1564 | } | ||
1565 | if (events & (MID_DMA_ERR_ACK | MID_TX_IDENT_MISM | MID_TX_DMA_OVFL)) { | ||
1566 | EVENT("bug interrupt\n",0,0); | ||
1567 | bug_int(dev,events); | ||
1568 | } | ||
1569 | poll_tx(dev); | ||
1570 | } | ||
1571 | |||
1572 | |||
1573 | /*--------------------------------- entries ---------------------------------*/ | ||
1574 | |||
1575 | |||
1576 | static const char *media_name[] __devinitdata = { | ||
1577 | "MMF", "SMF", "MMF", "03?", /* 0- 3 */ | ||
1578 | "UTP", "05?", "06?", "07?", /* 4- 7 */ | ||
1579 | "TAXI","09?", "10?", "11?", /* 8-11 */ | ||
1580 | "12?", "13?", "14?", "15?", /* 12-15 */ | ||
1581 | "MMF", "SMF", "18?", "19?", /* 16-19 */ | ||
1582 | "UTP", "21?", "22?", "23?", /* 20-23 */ | ||
1583 | "24?", "25?", "26?", "27?", /* 24-27 */ | ||
1584 | "28?", "29?", "30?", "31?" /* 28-31 */ | ||
1585 | }; | ||
1586 | |||
1587 | |||
1588 | #define SET_SEPROM \ | ||
1589 | ({ if (!error && !pci_error) { \ | ||
1590 | pci_error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,tonga); \ | ||
1591 | udelay(10); /* 10 usecs */ \ | ||
1592 | } }) | ||
1593 | #define GET_SEPROM \ | ||
1594 | ({ if (!error && !pci_error) { \ | ||
1595 | pci_error = pci_read_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,&tonga); \ | ||
1596 | udelay(10); /* 10 usecs */ \ | ||
1597 | } }) | ||
1598 | |||
1599 | |||
1600 | static int __devinit get_esi_asic(struct atm_dev *dev) | ||
1601 | { | ||
1602 | struct eni_dev *eni_dev; | ||
1603 | unsigned char tonga; | ||
1604 | int error,failed,pci_error; | ||
1605 | int address,i,j; | ||
1606 | |||
1607 | eni_dev = ENI_DEV(dev); | ||
1608 | error = pci_error = 0; | ||
1609 | tonga = SEPROM_MAGIC | SEPROM_DATA | SEPROM_CLK; | ||
1610 | SET_SEPROM; | ||
1611 | for (i = 0; i < ESI_LEN && !error && !pci_error; i++) { | ||
1612 | /* start operation */ | ||
1613 | tonga |= SEPROM_DATA; | ||
1614 | SET_SEPROM; | ||
1615 | tonga |= SEPROM_CLK; | ||
1616 | SET_SEPROM; | ||
1617 | tonga &= ~SEPROM_DATA; | ||
1618 | SET_SEPROM; | ||
1619 | tonga &= ~SEPROM_CLK; | ||
1620 | SET_SEPROM; | ||
1621 | /* send address */ | ||
1622 | address = ((i+SEPROM_ESI_BASE) << 1)+1; | ||
1623 | for (j = 7; j >= 0; j--) { | ||
1624 | tonga = (address >> j) & 1 ? tonga | SEPROM_DATA : | ||
1625 | tonga & ~SEPROM_DATA; | ||
1626 | SET_SEPROM; | ||
1627 | tonga |= SEPROM_CLK; | ||
1628 | SET_SEPROM; | ||
1629 | tonga &= ~SEPROM_CLK; | ||
1630 | SET_SEPROM; | ||
1631 | } | ||
1632 | /* get ack */ | ||
1633 | tonga |= SEPROM_DATA; | ||
1634 | SET_SEPROM; | ||
1635 | tonga |= SEPROM_CLK; | ||
1636 | SET_SEPROM; | ||
1637 | GET_SEPROM; | ||
1638 | failed = tonga & SEPROM_DATA; | ||
1639 | tonga &= ~SEPROM_CLK; | ||
1640 | SET_SEPROM; | ||
1641 | tonga |= SEPROM_DATA; | ||
1642 | SET_SEPROM; | ||
1643 | if (failed) error = -EIO; | ||
1644 | else { | ||
1645 | dev->esi[i] = 0; | ||
1646 | for (j = 7; j >= 0; j--) { | ||
1647 | dev->esi[i] <<= 1; | ||
1648 | tonga |= SEPROM_DATA; | ||
1649 | SET_SEPROM; | ||
1650 | tonga |= SEPROM_CLK; | ||
1651 | SET_SEPROM; | ||
1652 | GET_SEPROM; | ||
1653 | if (tonga & SEPROM_DATA) dev->esi[i] |= 1; | ||
1654 | tonga &= ~SEPROM_CLK; | ||
1655 | SET_SEPROM; | ||
1656 | tonga |= SEPROM_DATA; | ||
1657 | SET_SEPROM; | ||
1658 | } | ||
1659 | /* get ack */ | ||
1660 | tonga |= SEPROM_DATA; | ||
1661 | SET_SEPROM; | ||
1662 | tonga |= SEPROM_CLK; | ||
1663 | SET_SEPROM; | ||
1664 | GET_SEPROM; | ||
1665 | if (!(tonga & SEPROM_DATA)) error = -EIO; | ||
1666 | tonga &= ~SEPROM_CLK; | ||
1667 | SET_SEPROM; | ||
1668 | tonga |= SEPROM_DATA; | ||
1669 | SET_SEPROM; | ||
1670 | } | ||
1671 | /* stop operation */ | ||
1672 | tonga &= ~SEPROM_DATA; | ||
1673 | SET_SEPROM; | ||
1674 | tonga |= SEPROM_CLK; | ||
1675 | SET_SEPROM; | ||
1676 | tonga |= SEPROM_DATA; | ||
1677 | SET_SEPROM; | ||
1678 | } | ||
1679 | if (pci_error) { | ||
1680 | printk(KERN_ERR DEV_LABEL "(itf %d): error reading ESI " | ||
1681 | "(0x%02x)\n",dev->number,pci_error); | ||
1682 | error = -EIO; | ||
1683 | } | ||
1684 | return error; | ||
1685 | } | ||
1686 | |||
1687 | |||
1688 | #undef SET_SEPROM | ||
1689 | #undef GET_SEPROM | ||
1690 | |||
1691 | |||
1692 | static int __devinit get_esi_fpga(struct atm_dev *dev, void __iomem *base) | ||
1693 | { | ||
1694 | void __iomem *mac_base; | ||
1695 | int i; | ||
1696 | |||
1697 | mac_base = base+EPROM_SIZE-sizeof(struct midway_eprom); | ||
1698 | for (i = 0; i < ESI_LEN; i++) dev->esi[i] = readb(mac_base+(i^3)); | ||
1699 | return 0; | ||
1700 | } | ||
1701 | |||
1702 | |||
1703 | static int __devinit eni_do_init(struct atm_dev *dev) | ||
1704 | { | ||
1705 | struct midway_eprom __iomem *eprom; | ||
1706 | struct eni_dev *eni_dev; | ||
1707 | struct pci_dev *pci_dev; | ||
1708 | unsigned long real_base; | ||
1709 | void __iomem *base; | ||
1710 | unsigned char revision; | ||
1711 | int error,i,last; | ||
1712 | |||
1713 | DPRINTK(">eni_init\n"); | ||
1714 | dev->ci_range.vpi_bits = 0; | ||
1715 | dev->ci_range.vci_bits = NR_VCI_LD; | ||
1716 | dev->link_rate = ATM_OC3_PCR; | ||
1717 | eni_dev = ENI_DEV(dev); | ||
1718 | pci_dev = eni_dev->pci_dev; | ||
1719 | real_base = pci_resource_start(pci_dev, 0); | ||
1720 | eni_dev->irq = pci_dev->irq; | ||
1721 | error = pci_read_config_byte(pci_dev,PCI_REVISION_ID,&revision); | ||
1722 | if (error) { | ||
1723 | printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n", | ||
1724 | dev->number,error); | ||
1725 | return -EINVAL; | ||
1726 | } | ||
1727 | if ((error = pci_write_config_word(pci_dev,PCI_COMMAND, | ||
1728 | PCI_COMMAND_MEMORY | | ||
1729 | (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) { | ||
1730 | printk(KERN_ERR DEV_LABEL "(itf %d): can't enable memory " | ||
1731 | "(0x%02x)\n",dev->number,error); | ||
1732 | return -EIO; | ||
1733 | } | ||
1734 | printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%lx,irq=%d,", | ||
1735 | dev->number,revision,real_base,eni_dev->irq); | ||
1736 | if (!(base = ioremap_nocache(real_base,MAP_MAX_SIZE))) { | ||
1737 | printk("\n"); | ||
1738 | printk(KERN_ERR DEV_LABEL "(itf %d): can't set up page " | ||
1739 | "mapping\n",dev->number); | ||
1740 | return error; | ||
1741 | } | ||
1742 | eni_dev->base_diff = real_base - (unsigned long) base; | ||
1743 | /* id may not be present in ASIC Tonga boards - check this @@@ */ | ||
1744 | if (!eni_dev->asic) { | ||
1745 | eprom = (base+EPROM_SIZE-sizeof(struct midway_eprom)); | ||
1746 | if (readl(&eprom->magic) != ENI155_MAGIC) { | ||
1747 | printk("\n"); | ||
1748 | printk(KERN_ERR KERN_ERR DEV_LABEL "(itf %d): bad " | ||
1749 | "magic - expected 0x%x, got 0x%x\n",dev->number, | ||
1750 | ENI155_MAGIC,(unsigned) readl(&eprom->magic)); | ||
1751 | return -EINVAL; | ||
1752 | } | ||
1753 | } | ||
1754 | eni_dev->phy = base+PHY_BASE; | ||
1755 | eni_dev->reg = base+REG_BASE; | ||
1756 | eni_dev->ram = base+RAM_BASE; | ||
1757 | last = MAP_MAX_SIZE-RAM_BASE; | ||
1758 | for (i = last-RAM_INCREMENT; i >= 0; i -= RAM_INCREMENT) { | ||
1759 | writel(0x55555555,eni_dev->ram+i); | ||
1760 | if (readl(eni_dev->ram+i) != 0x55555555) last = i; | ||
1761 | else { | ||
1762 | writel(0xAAAAAAAA,eni_dev->ram+i); | ||
1763 | if (readl(eni_dev->ram+i) != 0xAAAAAAAA) last = i; | ||
1764 | else writel(i,eni_dev->ram+i); | ||
1765 | } | ||
1766 | } | ||
1767 | for (i = 0; i < last; i += RAM_INCREMENT) | ||
1768 | if (readl(eni_dev->ram+i) != i) break; | ||
1769 | eni_dev->mem = i; | ||
1770 | memset_io(eni_dev->ram,0,eni_dev->mem); | ||
1771 | /* TODO: should shrink allocation now */ | ||
1772 | printk("mem=%dkB (",eni_dev->mem >> 10); | ||
1773 | /* TODO: check for non-SUNI, check for TAXI ? */ | ||
1774 | if (!(eni_in(MID_RES_ID_MCON) & 0x200) != !eni_dev->asic) { | ||
1775 | printk(")\n"); | ||
1776 | printk(KERN_ERR DEV_LABEL "(itf %d): ERROR - wrong id 0x%x\n", | ||
1777 | dev->number,(unsigned) eni_in(MID_RES_ID_MCON)); | ||
1778 | return -EINVAL; | ||
1779 | } | ||
1780 | error = eni_dev->asic ? get_esi_asic(dev) : get_esi_fpga(dev,base); | ||
1781 | if (error) return error; | ||
1782 | for (i = 0; i < ESI_LEN; i++) | ||
1783 | printk("%s%02X",i ? "-" : "",dev->esi[i]); | ||
1784 | printk(")\n"); | ||
1785 | printk(KERN_NOTICE DEV_LABEL "(itf %d): %s,%s\n",dev->number, | ||
1786 | eni_in(MID_RES_ID_MCON) & 0x200 ? "ASIC" : "FPGA", | ||
1787 | media_name[eni_in(MID_RES_ID_MCON) & DAUGTHER_ID]); | ||
1788 | return suni_init(dev); | ||
1789 | } | ||
1790 | |||
1791 | |||
1792 | static int __devinit eni_start(struct atm_dev *dev) | ||
1793 | { | ||
1794 | struct eni_dev *eni_dev; | ||
1795 | |||
1796 | void __iomem *buf; | ||
1797 | unsigned long buffer_mem; | ||
1798 | int error; | ||
1799 | |||
1800 | DPRINTK(">eni_start\n"); | ||
1801 | eni_dev = ENI_DEV(dev); | ||
1802 | if (request_irq(eni_dev->irq,&eni_int,SA_SHIRQ,DEV_LABEL,dev)) { | ||
1803 | printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n", | ||
1804 | dev->number,eni_dev->irq); | ||
1805 | return -EAGAIN; | ||
1806 | } | ||
1807 | /* @@@ should release IRQ on error */ | ||
1808 | pci_set_master(eni_dev->pci_dev); | ||
1809 | if ((error = pci_write_config_word(eni_dev->pci_dev,PCI_COMMAND, | ||
1810 | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | | ||
1811 | (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) { | ||
1812 | printk(KERN_ERR DEV_LABEL "(itf %d): can't enable memory+" | ||
1813 | "master (0x%02x)\n",dev->number,error); | ||
1814 | return error; | ||
1815 | } | ||
1816 | if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL, | ||
1817 | END_SWAP_DMA))) { | ||
1818 | printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap " | ||
1819 | "(0x%02x)\n",dev->number,error); | ||
1820 | return error; | ||
1821 | } | ||
1822 | /* determine addresses of internal tables */ | ||
1823 | eni_dev->vci = eni_dev->ram; | ||
1824 | eni_dev->rx_dma = eni_dev->ram+NR_VCI*16; | ||
1825 | eni_dev->tx_dma = eni_dev->rx_dma+NR_DMA_RX*8; | ||
1826 | eni_dev->service = eni_dev->tx_dma+NR_DMA_TX*8; | ||
1827 | buf = eni_dev->service+NR_SERVICE*4; | ||
1828 | DPRINTK("vci 0x%lx,rx 0x%lx, tx 0x%lx,srv 0x%lx,buf 0x%lx\n", | ||
1829 | eni_dev->vci,eni_dev->rx_dma,eni_dev->tx_dma, | ||
1830 | eni_dev->service,buf); | ||
1831 | spin_lock_init(&eni_dev->lock); | ||
1832 | tasklet_init(&eni_dev->task,eni_tasklet,(unsigned long) dev); | ||
1833 | eni_dev->events = 0; | ||
1834 | /* initialize memory management */ | ||
1835 | buffer_mem = eni_dev->mem - (buf - eni_dev->ram); | ||
1836 | eni_dev->free_list_size = buffer_mem/MID_MIN_BUF_SIZE/2; | ||
1837 | eni_dev->free_list = (struct eni_free *) kmalloc( | ||
1838 | sizeof(struct eni_free)*(eni_dev->free_list_size+1),GFP_KERNEL); | ||
1839 | if (!eni_dev->free_list) { | ||
1840 | printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n", | ||
1841 | dev->number); | ||
1842 | return -ENOMEM; | ||
1843 | } | ||
1844 | eni_dev->free_len = 0; | ||
1845 | eni_put_free(eni_dev,buf,buffer_mem); | ||
1846 | memset_io(eni_dev->vci,0,16*NR_VCI); /* clear VCI table */ | ||
1847 | /* | ||
1848 | * byte_addr free (k) | ||
1849 | * 0x00000000 512 VCI table | ||
1850 | * 0x00004000 496 RX DMA | ||
1851 | * 0x00005000 492 TX DMA | ||
1852 | * 0x00006000 488 service list | ||
1853 | * 0x00007000 484 buffers | ||
1854 | * 0x00080000 0 end (512kB) | ||
1855 | */ | ||
1856 | eni_out(0xffffffff,MID_IE); | ||
1857 | error = start_tx(dev); | ||
1858 | if (error) return error; | ||
1859 | error = start_rx(dev); | ||
1860 | if (error) return error; | ||
1861 | error = dev->phy->start(dev); | ||
1862 | if (error) return error; | ||
1863 | eni_out(eni_in(MID_MC_S) | (1 << MID_INT_SEL_SHIFT) | | ||
1864 | MID_TX_LOCK_MODE | MID_DMA_ENABLE | MID_TX_ENABLE | MID_RX_ENABLE, | ||
1865 | MID_MC_S); | ||
1866 | /* Tonga uses SBus INTReq1 */ | ||
1867 | (void) eni_in(MID_ISA); /* clear Midway interrupts */ | ||
1868 | return 0; | ||
1869 | } | ||
1870 | |||
1871 | |||
1872 | static void eni_close(struct atm_vcc *vcc) | ||
1873 | { | ||
1874 | DPRINTK(">eni_close\n"); | ||
1875 | if (!ENI_VCC(vcc)) return; | ||
1876 | clear_bit(ATM_VF_READY,&vcc->flags); | ||
1877 | close_rx(vcc); | ||
1878 | close_tx(vcc); | ||
1879 | DPRINTK("eni_close: done waiting\n"); | ||
1880 | /* deallocate memory */ | ||
1881 | kfree(ENI_VCC(vcc)); | ||
1882 | vcc->dev_data = NULL; | ||
1883 | clear_bit(ATM_VF_ADDR,&vcc->flags); | ||
1884 | /*foo();*/ | ||
1885 | } | ||
1886 | |||
1887 | |||
1888 | static int eni_open(struct atm_vcc *vcc) | ||
1889 | { | ||
1890 | struct eni_dev *eni_dev; | ||
1891 | struct eni_vcc *eni_vcc; | ||
1892 | int error; | ||
1893 | short vpi = vcc->vpi; | ||
1894 | int vci = vcc->vci; | ||
1895 | |||
1896 | DPRINTK(">eni_open\n"); | ||
1897 | EVENT("eni_open\n",0,0); | ||
1898 | if (!test_bit(ATM_VF_PARTIAL,&vcc->flags)) | ||
1899 | vcc->dev_data = NULL; | ||
1900 | eni_dev = ENI_DEV(vcc->dev); | ||
1901 | if (vci != ATM_VPI_UNSPEC && vpi != ATM_VCI_UNSPEC) | ||
1902 | set_bit(ATM_VF_ADDR,&vcc->flags); | ||
1903 | if (vcc->qos.aal != ATM_AAL0 && vcc->qos.aal != ATM_AAL5) | ||
1904 | return -EINVAL; | ||
1905 | DPRINTK(DEV_LABEL "(itf %d): open %d.%d\n",vcc->dev->number,vcc->vpi, | ||
1906 | vcc->vci); | ||
1907 | if (!test_bit(ATM_VF_PARTIAL,&vcc->flags)) { | ||
1908 | eni_vcc = kmalloc(sizeof(struct eni_vcc),GFP_KERNEL); | ||
1909 | if (!eni_vcc) return -ENOMEM; | ||
1910 | vcc->dev_data = eni_vcc; | ||
1911 | eni_vcc->tx = NULL; /* for eni_close after open_rx */ | ||
1912 | if ((error = open_rx_first(vcc))) { | ||
1913 | eni_close(vcc); | ||
1914 | return error; | ||
1915 | } | ||
1916 | if ((error = open_tx_first(vcc))) { | ||
1917 | eni_close(vcc); | ||
1918 | return error; | ||
1919 | } | ||
1920 | } | ||
1921 | if (vci == ATM_VPI_UNSPEC || vpi == ATM_VCI_UNSPEC) return 0; | ||
1922 | if ((error = open_rx_second(vcc))) { | ||
1923 | eni_close(vcc); | ||
1924 | return error; | ||
1925 | } | ||
1926 | if ((error = open_tx_second(vcc))) { | ||
1927 | eni_close(vcc); | ||
1928 | return error; | ||
1929 | } | ||
1930 | set_bit(ATM_VF_READY,&vcc->flags); | ||
1931 | /* should power down SUNI while !ref_count @@@ */ | ||
1932 | return 0; | ||
1933 | } | ||
1934 | |||
1935 | |||
1936 | static int eni_change_qos(struct atm_vcc *vcc,struct atm_qos *qos,int flgs) | ||
1937 | { | ||
1938 | struct eni_dev *eni_dev = ENI_DEV(vcc->dev); | ||
1939 | struct eni_tx *tx = ENI_VCC(vcc)->tx; | ||
1940 | struct sk_buff *skb; | ||
1941 | int error,rate,rsv,shp; | ||
1942 | |||
1943 | if (qos->txtp.traffic_class == ATM_NONE) return 0; | ||
1944 | if (tx == eni_dev->ubr) return -EBADFD; | ||
1945 | rate = atm_pcr_goal(&qos->txtp); | ||
1946 | if (rate < 0) rate = -rate; | ||
1947 | rsv = shp = 0; | ||
1948 | if ((flgs & ATM_MF_DEC_RSV) && rate && rate < tx->reserved) rsv = 1; | ||
1949 | if ((flgs & ATM_MF_INC_RSV) && (!rate || rate > tx->reserved)) rsv = 1; | ||
1950 | if ((flgs & ATM_MF_DEC_SHP) && rate && rate < tx->shaping) shp = 1; | ||
1951 | if ((flgs & ATM_MF_INC_SHP) && (!rate || rate > tx->shaping)) shp = 1; | ||
1952 | if (!rsv && !shp) return 0; | ||
1953 | error = reserve_or_set_tx(vcc,&qos->txtp,rsv,shp); | ||
1954 | if (error) return error; | ||
1955 | if (shp && !(flgs & ATM_MF_IMMED)) return 0; | ||
1956 | /* | ||
1957 | * Walk through the send buffer and patch the rate information in all | ||
1958 | * segmentation buffer descriptors of this VCC. | ||
1959 | */ | ||
1960 | tasklet_disable(&eni_dev->task); | ||
1961 | skb_queue_walk(&eni_dev->tx_queue, skb) { | ||
1962 | void __iomem *dsc; | ||
1963 | |||
1964 | if (ATM_SKB(skb)->vcc != vcc) continue; | ||
1965 | dsc = tx->send+ENI_PRV_POS(skb)*4; | ||
1966 | writel((readl(dsc) & ~(MID_SEG_RATE | MID_SEG_PR)) | | ||
1967 | (tx->prescaler << MID_SEG_PR_SHIFT) | | ||
1968 | (tx->resolution << MID_SEG_RATE_SHIFT), dsc); | ||
1969 | } | ||
1970 | tasklet_enable(&eni_dev->task); | ||
1971 | return 0; | ||
1972 | } | ||
1973 | |||
1974 | |||
1975 | static int eni_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg) | ||
1976 | { | ||
1977 | struct eni_dev *eni_dev = ENI_DEV(dev); | ||
1978 | |||
1979 | if (cmd == ENI_MEMDUMP) { | ||
1980 | if (!capable(CAP_NET_ADMIN)) return -EPERM; | ||
1981 | printk(KERN_WARNING "Please use /proc/atm/" DEV_LABEL ":%d " | ||
1982 | "instead of obsolete ioctl ENI_MEMDUMP\n",dev->number); | ||
1983 | dump(dev); | ||
1984 | return 0; | ||
1985 | } | ||
1986 | if (cmd == ENI_SETMULT) { | ||
1987 | struct eni_multipliers mult; | ||
1988 | |||
1989 | if (!capable(CAP_NET_ADMIN)) return -EPERM; | ||
1990 | if (copy_from_user(&mult, arg, | ||
1991 | sizeof(struct eni_multipliers))) | ||
1992 | return -EFAULT; | ||
1993 | if ((mult.tx && mult.tx <= 100) || (mult.rx &&mult.rx <= 100) || | ||
1994 | mult.tx > 65536 || mult.rx > 65536) | ||
1995 | return -EINVAL; | ||
1996 | if (mult.tx) eni_dev->tx_mult = mult.tx; | ||
1997 | if (mult.rx) eni_dev->rx_mult = mult.rx; | ||
1998 | return 0; | ||
1999 | } | ||
2000 | if (cmd == ATM_SETCIRANGE) { | ||
2001 | struct atm_cirange ci; | ||
2002 | |||
2003 | if (copy_from_user(&ci, arg,sizeof(struct atm_cirange))) | ||
2004 | return -EFAULT; | ||
2005 | if ((ci.vpi_bits == 0 || ci.vpi_bits == ATM_CI_MAX) && | ||
2006 | (ci.vci_bits == NR_VCI_LD || ci.vpi_bits == ATM_CI_MAX)) | ||
2007 | return 0; | ||
2008 | return -EINVAL; | ||
2009 | } | ||
2010 | if (!dev->phy->ioctl) return -ENOIOCTLCMD; | ||
2011 | return dev->phy->ioctl(dev,cmd,arg); | ||
2012 | } | ||
2013 | |||
2014 | |||
2015 | static int eni_getsockopt(struct atm_vcc *vcc,int level,int optname, | ||
2016 | void __user *optval,int optlen) | ||
2017 | { | ||
2018 | return -EINVAL; | ||
2019 | } | ||
2020 | |||
2021 | |||
2022 | static int eni_setsockopt(struct atm_vcc *vcc,int level,int optname, | ||
2023 | void __user *optval,int optlen) | ||
2024 | { | ||
2025 | return -EINVAL; | ||
2026 | } | ||
2027 | |||
2028 | |||
2029 | static int eni_send(struct atm_vcc *vcc,struct sk_buff *skb) | ||
2030 | { | ||
2031 | enum enq_res res; | ||
2032 | |||
2033 | DPRINTK(">eni_send\n"); | ||
2034 | if (!ENI_VCC(vcc)->tx) { | ||
2035 | if (vcc->pop) vcc->pop(vcc,skb); | ||
2036 | else dev_kfree_skb(skb); | ||
2037 | return -EINVAL; | ||
2038 | } | ||
2039 | if (!skb) { | ||
2040 | printk(KERN_CRIT "!skb in eni_send ?\n"); | ||
2041 | if (vcc->pop) vcc->pop(vcc,skb); | ||
2042 | return -EINVAL; | ||
2043 | } | ||
2044 | if (vcc->qos.aal == ATM_AAL0) { | ||
2045 | if (skb->len != ATM_CELL_SIZE-1) { | ||
2046 | if (vcc->pop) vcc->pop(vcc,skb); | ||
2047 | else dev_kfree_skb(skb); | ||
2048 | return -EINVAL; | ||
2049 | } | ||
2050 | *(u32 *) skb->data = htonl(*(u32 *) skb->data); | ||
2051 | } | ||
2052 | submitted++; | ||
2053 | ATM_SKB(skb)->vcc = vcc; | ||
2054 | tasklet_disable(&ENI_DEV(vcc->dev)->task); | ||
2055 | res = do_tx(skb); | ||
2056 | tasklet_enable(&ENI_DEV(vcc->dev)->task); | ||
2057 | if (res == enq_ok) return 0; | ||
2058 | skb_queue_tail(&ENI_VCC(vcc)->tx->backlog,skb); | ||
2059 | backlogged++; | ||
2060 | tasklet_schedule(&ENI_DEV(vcc->dev)->task); | ||
2061 | return 0; | ||
2062 | } | ||
2063 | |||
2064 | static void eni_phy_put(struct atm_dev *dev,unsigned char value, | ||
2065 | unsigned long addr) | ||
2066 | { | ||
2067 | writel(value,ENI_DEV(dev)->phy+addr*4); | ||
2068 | } | ||
2069 | |||
2070 | |||
2071 | |||
2072 | static unsigned char eni_phy_get(struct atm_dev *dev,unsigned long addr) | ||
2073 | { | ||
2074 | return readl(ENI_DEV(dev)->phy+addr*4); | ||
2075 | } | ||
2076 | |||
2077 | |||
2078 | static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page) | ||
2079 | { | ||
2080 | struct hlist_node *node; | ||
2081 | struct sock *s; | ||
2082 | static const char *signal[] = { "LOST","unknown","okay" }; | ||
2083 | struct eni_dev *eni_dev = ENI_DEV(dev); | ||
2084 | struct atm_vcc *vcc; | ||
2085 | int left,i; | ||
2086 | |||
2087 | left = *pos; | ||
2088 | if (!left) | ||
2089 | return sprintf(page,DEV_LABEL "(itf %d) signal %s, %dkB, " | ||
2090 | "%d cps remaining\n",dev->number,signal[(int) dev->signal], | ||
2091 | eni_dev->mem >> 10,eni_dev->tx_bw); | ||
2092 | if (!--left) | ||
2093 | return sprintf(page,"%4sBursts: TX" | ||
2094 | #if !defined(CONFIG_ATM_ENI_BURST_TX_16W) && \ | ||
2095 | !defined(CONFIG_ATM_ENI_BURST_TX_8W) && \ | ||
2096 | !defined(CONFIG_ATM_ENI_BURST_TX_4W) && \ | ||
2097 | !defined(CONFIG_ATM_ENI_BURST_TX_2W) | ||
2098 | " none" | ||
2099 | #endif | ||
2100 | #ifdef CONFIG_ATM_ENI_BURST_TX_16W | ||
2101 | " 16W" | ||
2102 | #endif | ||
2103 | #ifdef CONFIG_ATM_ENI_BURST_TX_8W | ||
2104 | " 8W" | ||
2105 | #endif | ||
2106 | #ifdef CONFIG_ATM_ENI_BURST_TX_4W | ||
2107 | " 4W" | ||
2108 | #endif | ||
2109 | #ifdef CONFIG_ATM_ENI_BURST_TX_2W | ||
2110 | " 2W" | ||
2111 | #endif | ||
2112 | ", RX" | ||
2113 | #if !defined(CONFIG_ATM_ENI_BURST_RX_16W) && \ | ||
2114 | !defined(CONFIG_ATM_ENI_BURST_RX_8W) && \ | ||
2115 | !defined(CONFIG_ATM_ENI_BURST_RX_4W) && \ | ||
2116 | !defined(CONFIG_ATM_ENI_BURST_RX_2W) | ||
2117 | " none" | ||
2118 | #endif | ||
2119 | #ifdef CONFIG_ATM_ENI_BURST_RX_16W | ||
2120 | " 16W" | ||
2121 | #endif | ||
2122 | #ifdef CONFIG_ATM_ENI_BURST_RX_8W | ||
2123 | " 8W" | ||
2124 | #endif | ||
2125 | #ifdef CONFIG_ATM_ENI_BURST_RX_4W | ||
2126 | " 4W" | ||
2127 | #endif | ||
2128 | #ifdef CONFIG_ATM_ENI_BURST_RX_2W | ||
2129 | " 2W" | ||
2130 | #endif | ||
2131 | #ifndef CONFIG_ATM_ENI_TUNE_BURST | ||
2132 | " (default)" | ||
2133 | #endif | ||
2134 | "\n",""); | ||
2135 | if (!--left) | ||
2136 | return sprintf(page,"%4sBuffer multipliers: tx %d%%, rx %d%%\n", | ||
2137 | "",eni_dev->tx_mult,eni_dev->rx_mult); | ||
2138 | for (i = 0; i < NR_CHAN; i++) { | ||
2139 | struct eni_tx *tx = eni_dev->tx+i; | ||
2140 | |||
2141 | if (!tx->send) continue; | ||
2142 | if (!--left) { | ||
2143 | return sprintf(page,"tx[%d]: 0x%ld-0x%ld " | ||
2144 | "(%6ld bytes), rsv %d cps, shp %d cps%s\n",i, | ||
2145 | (unsigned long) (tx->send - eni_dev->ram), | ||
2146 | tx->send-eni_dev->ram+tx->words*4-1,tx->words*4, | ||
2147 | tx->reserved,tx->shaping, | ||
2148 | tx == eni_dev->ubr ? " (UBR)" : ""); | ||
2149 | } | ||
2150 | if (--left) continue; | ||
2151 | return sprintf(page,"%10sbacklog %u packets\n","", | ||
2152 | skb_queue_len(&tx->backlog)); | ||
2153 | } | ||
2154 | read_lock(&vcc_sklist_lock); | ||
2155 | for(i = 0; i < VCC_HTABLE_SIZE; ++i) { | ||
2156 | struct hlist_head *head = &vcc_hash[i]; | ||
2157 | |||
2158 | sk_for_each(s, node, head) { | ||
2159 | struct eni_vcc *eni_vcc; | ||
2160 | int length; | ||
2161 | |||
2162 | vcc = atm_sk(s); | ||
2163 | if (vcc->dev != dev) | ||
2164 | continue; | ||
2165 | eni_vcc = ENI_VCC(vcc); | ||
2166 | if (--left) continue; | ||
2167 | length = sprintf(page,"vcc %4d: ",vcc->vci); | ||
2168 | if (eni_vcc->rx) { | ||
2169 | length += sprintf(page+length,"0x%ld-0x%ld " | ||
2170 | "(%6ld bytes)", | ||
2171 | (unsigned long) (eni_vcc->recv - eni_dev->ram), | ||
2172 | eni_vcc->recv-eni_dev->ram+eni_vcc->words*4-1, | ||
2173 | eni_vcc->words*4); | ||
2174 | if (eni_vcc->tx) length += sprintf(page+length,", "); | ||
2175 | } | ||
2176 | if (eni_vcc->tx) | ||
2177 | length += sprintf(page+length,"tx[%d], txing %d bytes", | ||
2178 | eni_vcc->tx->index,eni_vcc->txing); | ||
2179 | page[length] = '\n'; | ||
2180 | read_unlock(&vcc_sklist_lock); | ||
2181 | return length+1; | ||
2182 | } | ||
2183 | } | ||
2184 | read_unlock(&vcc_sklist_lock); | ||
2185 | for (i = 0; i < eni_dev->free_len; i++) { | ||
2186 | struct eni_free *fe = eni_dev->free_list+i; | ||
2187 | unsigned long offset; | ||
2188 | |||
2189 | if (--left) continue; | ||
2190 | offset = (unsigned long) eni_dev->ram+eni_dev->base_diff; | ||
2191 | return sprintf(page,"free %p-%p (%6d bytes)\n", | ||
2192 | fe->start-offset,fe->start-offset+(1 << fe->order)-1, | ||
2193 | 1 << fe->order); | ||
2194 | } | ||
2195 | return 0; | ||
2196 | } | ||
2197 | |||
2198 | |||
2199 | static const struct atmdev_ops ops = { | ||
2200 | .open = eni_open, | ||
2201 | .close = eni_close, | ||
2202 | .ioctl = eni_ioctl, | ||
2203 | .getsockopt = eni_getsockopt, | ||
2204 | .setsockopt = eni_setsockopt, | ||
2205 | .send = eni_send, | ||
2206 | .phy_put = eni_phy_put, | ||
2207 | .phy_get = eni_phy_get, | ||
2208 | .change_qos = eni_change_qos, | ||
2209 | .proc_read = eni_proc_read | ||
2210 | }; | ||
2211 | |||
2212 | |||
2213 | static int __devinit eni_init_one(struct pci_dev *pci_dev, | ||
2214 | const struct pci_device_id *ent) | ||
2215 | { | ||
2216 | struct atm_dev *dev; | ||
2217 | struct eni_dev *eni_dev; | ||
2218 | int error = -ENOMEM; | ||
2219 | |||
2220 | DPRINTK("eni_init_one\n"); | ||
2221 | |||
2222 | if (pci_enable_device(pci_dev)) { | ||
2223 | error = -EIO; | ||
2224 | goto out0; | ||
2225 | } | ||
2226 | |||
2227 | eni_dev = (struct eni_dev *) kmalloc(sizeof(struct eni_dev),GFP_KERNEL); | ||
2228 | if (!eni_dev) goto out0; | ||
2229 | if (!cpu_zeroes) { | ||
2230 | cpu_zeroes = pci_alloc_consistent(pci_dev,ENI_ZEROES_SIZE, | ||
2231 | &zeroes); | ||
2232 | if (!cpu_zeroes) goto out1; | ||
2233 | } | ||
2234 | dev = atm_dev_register(DEV_LABEL,&ops,-1,NULL); | ||
2235 | if (!dev) goto out2; | ||
2236 | pci_set_drvdata(pci_dev, dev); | ||
2237 | eni_dev->pci_dev = pci_dev; | ||
2238 | dev->dev_data = eni_dev; | ||
2239 | eni_dev->asic = ent->driver_data; | ||
2240 | error = eni_do_init(dev); | ||
2241 | if (error) goto out3; | ||
2242 | error = eni_start(dev); | ||
2243 | if (error) goto out3; | ||
2244 | eni_dev->more = eni_boards; | ||
2245 | eni_boards = dev; | ||
2246 | return 0; | ||
2247 | out3: | ||
2248 | atm_dev_deregister(dev); | ||
2249 | out2: | ||
2250 | pci_free_consistent(eni_dev->pci_dev,ENI_ZEROES_SIZE,cpu_zeroes,zeroes); | ||
2251 | cpu_zeroes = NULL; | ||
2252 | out1: | ||
2253 | kfree(eni_dev); | ||
2254 | out0: | ||
2255 | return error; | ||
2256 | } | ||
2257 | |||
2258 | |||
2259 | static struct pci_device_id eni_pci_tbl[] = { | ||
2260 | { PCI_VENDOR_ID_EF, PCI_DEVICE_ID_EF_ATM_FPGA, PCI_ANY_ID, PCI_ANY_ID, | ||
2261 | 0, 0, 0 /* FPGA */ }, | ||
2262 | { PCI_VENDOR_ID_EF, PCI_DEVICE_ID_EF_ATM_ASIC, PCI_ANY_ID, PCI_ANY_ID, | ||
2263 | 0, 0, 1 /* ASIC */ }, | ||
2264 | { 0, } | ||
2265 | }; | ||
2266 | MODULE_DEVICE_TABLE(pci,eni_pci_tbl); | ||
2267 | |||
2268 | |||
2269 | static void __devexit eni_remove_one(struct pci_dev *pci_dev) | ||
2270 | { | ||
2271 | /* grrr */ | ||
2272 | } | ||
2273 | |||
2274 | |||
2275 | static struct pci_driver eni_driver = { | ||
2276 | .name = DEV_LABEL, | ||
2277 | .id_table = eni_pci_tbl, | ||
2278 | .probe = eni_init_one, | ||
2279 | .remove = __devexit_p(eni_remove_one), | ||
2280 | }; | ||
2281 | |||
2282 | |||
2283 | static int __init eni_init(void) | ||
2284 | { | ||
2285 | struct sk_buff *skb; /* dummy for sizeof */ | ||
2286 | |||
2287 | if (sizeof(skb->cb) < sizeof(struct eni_skb_prv)) { | ||
2288 | printk(KERN_ERR "eni_detect: skb->cb is too small (%Zd < %Zd)\n", | ||
2289 | sizeof(skb->cb),sizeof(struct eni_skb_prv)); | ||
2290 | return -EIO; | ||
2291 | } | ||
2292 | return pci_register_driver(&eni_driver); | ||
2293 | } | ||
2294 | |||
2295 | |||
2296 | module_init(eni_init); | ||
2297 | /* @@@ since exit routine not defined, this module can not be unloaded */ | ||
2298 | |||
2299 | MODULE_LICENSE("GPL"); | ||