1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef AMBASSADOR_H
24#define AMBASSADOR_H
25
26#include <linux/config.h>
27
28#ifdef CONFIG_ATM_AMBASSADOR_DEBUG
29#define DEBUG_AMBASSADOR
30#endif
31
32#define DEV_LABEL "amb"
33
34#ifndef PCI_VENDOR_ID_MADGE
35#define PCI_VENDOR_ID_MADGE 0x10B6
36#endif
37#ifndef PCI_VENDOR_ID_MADGE_AMBASSADOR
38#define PCI_DEVICE_ID_MADGE_AMBASSADOR 0x1001
39#endif
40#ifndef PCI_VENDOR_ID_MADGE_AMBASSADOR_BAD
41#define PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD 0x1002
42#endif
43
44
45
46#define PRINTK(severity,format,args...) \
47 printk(severity DEV_LABEL ": " format "\n" , ## args)
48
49#ifdef DEBUG_AMBASSADOR
50
51#define DBG_ERR 0x0001
52#define DBG_WARN 0x0002
53#define DBG_INFO 0x0004
54#define DBG_INIT 0x0008
55#define DBG_LOAD 0x0010
56#define DBG_VCC 0x0020
57#define DBG_QOS 0x0040
58#define DBG_CMD 0x0080
59#define DBG_TX 0x0100
60#define DBG_RX 0x0200
61#define DBG_SKB 0x0400
62#define DBG_POOL 0x0800
63#define DBG_IRQ 0x1000
64#define DBG_FLOW 0x2000
65#define DBG_REGS 0x4000
66#define DBG_DATA 0x8000
67#define DBG_MASK 0xffff
68
69
70
71#define PRINTDB(bits,format,args...) \
72 ( (debug & (bits)) ? printk (KERN_INFO DEV_LABEL ": " format , ## args) : 1 )
73#define PRINTDM(bits,format,args...) \
74 ( (debug & (bits)) ? printk (format , ## args) : 1 )
75#define PRINTDE(bits,format,args...) \
76 ( (debug & (bits)) ? printk (format "\n" , ## args) : 1 )
77#define PRINTD(bits,format,args...) \
78 ( (debug & (bits)) ? printk (KERN_INFO DEV_LABEL ": " format "\n" , ## args) : 1 )
79
80#else
81
82#define PRINTD(bits,format,args...)
83#define PRINTDB(bits,format,args...)
84#define PRINTDM(bits,format,args...)
85#define PRINTDE(bits,format,args...)
86
87#endif
88
89#define PRINTDD(bits,format,args...)
90#define PRINTDDB(sec,fmt,args...)
91#define PRINTDDM(sec,fmt,args...)
92#define PRINTDDE(sec,fmt,args...)
93
94
95
96
97#define COM_Q_ENTRIES 8
98#define TX_Q_ENTRIES 32
99#define RX_Q_ENTRIES 64
100
101
102
103
104#define AMB_EXTENT 0x80
105
106
107#define MIN_QUEUE_SIZE 2
108
109
110#define NUM_RX_POOLS 4
111
112
113#define MIN_RX_BUFFERS 1
114
115
116#define MIN_PCI_LATENCY 64
117
118
119#define NUM_VPI_BITS 0
120#define NUM_VCI_BITS 10
121#define NUM_VCS 1024
122
123
124#define RX_ERR 0x8000
125#define CRC_ERR 0x4000
126#define LEN_ERR 0x2000
127#define ABORT_ERR 0x1000
128#define UNUSED_ERR 0x0800
129
130
131
132#define SRB_OPEN_VC 0
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148#define SRB_CLOSE_VC 1
149
150
151#define SRB_GET_BIA 2
152
153
154
155
156#define SRB_GET_SUNI_STATS 3
157
158
159#define SRB_SET_BITS_8 4
160#define SRB_SET_BITS_16 5
161#define SRB_SET_BITS_32 6
162#define SRB_CLEAR_BITS_8 7
163#define SRB_CLEAR_BITS_16 8
164#define SRB_CLEAR_BITS_32 9
165
166
167
168#define SRB_SET_8 10
169#define SRB_SET_16 11
170#define SRB_SET_32 12
171
172
173
174#define SRB_GET_32 13
175
176
177
178
179#define SRB_GET_VERSION 14
180
181
182
183
184#define SRB_FLUSH_BUFFER_Q 15
185
186
187
188#define SRB_GET_DMA_SPEEDS 16
189
190
191
192
193#define SRB_MODIFY_VC_RATE 17
194
195
196
197#define SRB_MODIFY_VC_FLAGS 18
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212#define SRB_RATE_SHIFT 16
213#define SRB_POOL_SHIFT (SRB_FLAGS_SHIFT+5)
214#define SRB_FLAGS_SHIFT 16
215
216#define SRB_STOP_TASKING 19
217#define SRB_START_TASKING 20
218#define SRB_SHUT_DOWN 21
219#define MAX_SRB 21
220
221#define SRB_COMPLETE 0xffffffff
222
223#define TX_FRAME 0x80000000
224
225
226#define NUM_OF_SRB 32
227
228
229#define MAX_RATE_BITS 6
230
231#define TX_UBR 0x0000
232#define TX_UBR_CAPPED 0x0008
233#define TX_ABR 0x0018
234#define TX_FRAME_NOTCAP 0x0000
235#define TX_FRAME_CAPPED 0x8000
236
237#define FP_155_RATE 0x24b1
238#define FP_25_RATE 0x1f9d
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253#define VERSION_NUMBER 0x01050025
254
255
256#define DMA_VALID 0xb728e149
257
258#define FLASH_BASE 0xa0c00000
259#define FLASH_SIZE 0x00020000
260#define BIA_BASE (FLASH_BASE+0x0001c000)
261#define BIA_ADDRESS ((void *)0xa0c1c000)
262#define PLX_BASE 0xe0000000
263
264typedef enum {
265 host_memory_test = 1,
266 read_adapter_memory,
267 write_adapter_memory,
268 adapter_start,
269 get_version_number,
270 interrupt_host,
271 flash_erase_sector,
272 adap_download_block = 0x20,
273 adap_erase_flash,
274 adap_run_in_iram,
275 adap_end_download
276} loader_command;
277
278#define BAD_COMMAND (-1)
279#define COMMAND_IN_PROGRESS 1
280#define COMMAND_PASSED_TEST 2
281#define COMMAND_FAILED_TEST 3
282#define COMMAND_READ_DATA_OK 4
283#define COMMAND_READ_BAD_ADDRESS 5
284#define COMMAND_WRITE_DATA_OK 6
285#define COMMAND_WRITE_BAD_ADDRESS 7
286#define COMMAND_WRITE_FLASH_FAILURE 8
287#define COMMAND_COMPLETE 9
288#define COMMAND_FLASH_ERASE_FAILURE 10
289#define COMMAND_WRITE_BAD_DATA 11
290
291
292
293#define GPINT_TST_FAILURE 0x00000001
294#define SUNI_DATA_PATTERN_FAILURE 0x00000002
295#define SUNI_DATA_BITS_FAILURE 0x00000004
296#define SUNI_UTOPIA_FAILURE 0x00000008
297#define SUNI_FIFO_FAILURE 0x00000010
298#define SRAM_FAILURE 0x00000020
299#define SELF_TEST_FAILURE 0x0000003f
300
301
302
303
304
305
306
307
308
309
310#define UNUSED_LOADER_MAILBOXES 6
311
312typedef struct {
313 u32 stuff[16];
314 union {
315 struct {
316 u32 result;
317 u32 ready;
318 u32 stuff[UNUSED_LOADER_MAILBOXES];
319 } loader;
320 struct {
321 u32 cmd_address;
322 u32 tx_address;
323 u32 rx_address[NUM_RX_POOLS];
324 u32 gen_counter;
325 u32 spare;
326 } adapter;
327 } mb;
328 u32 doorbell;
329 u32 interrupt;
330 u32 interrupt_control;
331 u32 reset_control;
332} amb_mem;
333
334
335#define AMB_RESET_BITS 0x40000000
336#define AMB_INTERRUPT_BITS 0x00000300
337#define AMB_DOORBELL_BITS 0x00030000
338
339
340
341#define MAX_COMMAND_DATA 13
342#define MAX_TRANSFER_DATA 11
343
344typedef struct {
345 u32 address;
346 u32 count;
347 u32 data[MAX_TRANSFER_DATA];
348} transfer_block;
349
350typedef struct {
351 u32 result;
352 u32 command;
353 union {
354 transfer_block transfer;
355 u32 version;
356 u32 start;
357 u32 data[MAX_COMMAND_DATA];
358 } payload;
359 u32 valid;
360} loader_block;
361
362
363
364
365
366typedef struct {
367 union {
368 struct {
369 u32 vc;
370 u32 flags;
371 u32 rate;
372 } open;
373 struct {
374 u32 vc;
375 u32 rate;
376 } modify_rate;
377 struct {
378 u32 vc;
379 u32 flags;
380 } modify_flags;
381 struct {
382 u32 vc;
383 } close;
384 struct {
385 u32 lower4;
386 u32 upper2;
387 } bia;
388 struct {
389 u32 address;
390 } suni;
391 struct {
392 u32 major;
393 u32 minor;
394 } version;
395 struct {
396 u32 read;
397 u32 write;
398 } speed;
399 struct {
400 u32 flags;
401 } flush;
402 struct {
403 u32 address;
404 u32 data;
405 } memory;
406 u32 par[3];
407 } args;
408 u32 request;
409} command;
410
411
412
413
414
415
416
417
418
419typedef struct {
420 u32 bytes;
421 u32 address;
422} tx_frag;
423
424
425
426
427typedef struct {
428 u32 handle;
429 u16 vc;
430 u16 next_descriptor_length;
431 u32 next_descriptor;
432#ifdef AMB_NEW_MICROCODE
433 u8 cpcs_uu;
434 u8 cpi;
435 u16 pad;
436#endif
437} tx_frag_end;
438
439typedef struct {
440 tx_frag tx_frag;
441 tx_frag_end tx_frag_end;
442 struct sk_buff * skb;
443} tx_simple;
444
445#if 0
446typedef union {
447 tx_frag fragment;
448 tx_frag_end end_of_list;
449} tx_descr;
450#endif
451
452
453
454typedef struct {
455 u16 vc;
456 u16 tx_descr_length;
457 u32 tx_descr_addr;
458} tx_in;
459
460
461
462typedef struct {
463 u32 handle;
464} tx_out;
465
466
467
468
469
470
471
472typedef struct {
473 u32 handle;
474 u16 vc;
475 u16 lec_id;
476 u16 status;
477 u16 length;
478} rx_out;
479
480
481
482typedef struct {
483 u32 handle;
484 u32 host_address;
485} rx_in;
486
487
488
489
490
491
492
493
494
495
496
497typedef struct {
498 u32 command_start;
499 u32 command_end;
500 u32 tx_start;
501 u32 tx_end;
502 u32 txcom_start;
503 u32 txcom_end;
504 struct {
505 u32 buffer_start;
506 u32 buffer_end;
507 u32 buffer_q_get;
508 u32 buffer_q_end;
509 u32 buffer_aptr;
510 u32 rx_start;
511 u32 rx_end;
512 u32 rx_ptr;
513 u32 buffer_size;
514 } rec_struct[NUM_RX_POOLS];
515#ifdef AMB_NEW_MICROCODE
516 u16 init_flags;
517 u16 talk_block_spare;
518#endif
519} adap_talk_block;
520
521
522
523
524
525
526typedef struct {
527 u8 racp_chcs;
528 u8 racp_uhcs;
529 u16 spare;
530 u32 racp_rcell;
531 u32 tacp_tcell;
532 u32 flags;
533 u32 dropped_cells;
534 u32 dropped_frames;
535} suni_stats;
536
537typedef enum {
538 dead
539} amb_flags;
540
541#define NEXTQ(current,start,limit) \
542 ( (current)+1 < (limit) ? (current)+1 : (start) )
543
544typedef struct {
545 command * start;
546 command * in;
547 command * out;
548 command * limit;
549} amb_cq_ptrs;
550
551typedef struct {
552 spinlock_t lock;
553 unsigned int pending;
554 unsigned int high;
555 unsigned int filled;
556 unsigned int maximum;
557 amb_cq_ptrs ptrs;
558} amb_cq;
559
560typedef struct {
561 spinlock_t lock;
562 unsigned int pending;
563 unsigned int high;
564 unsigned int filled;
565 unsigned int maximum;
566 struct {
567 tx_in * start;
568 tx_in * ptr;
569 tx_in * limit;
570 } in;
571 struct {
572 tx_out * start;
573 tx_out * ptr;
574 tx_out * limit;
575 } out;
576} amb_txq;
577
578typedef struct {
579 spinlock_t lock;
580 unsigned int pending;
581 unsigned int low;
582 unsigned int emptied;
583 unsigned int maximum;
584 struct {
585 rx_in * start;
586 rx_in * ptr;
587 rx_in * limit;
588 } in;
589 struct {
590 rx_out * start;
591 rx_out * ptr;
592 rx_out * limit;
593 } out;
594 unsigned int buffers_wanted;
595 unsigned int buffer_size;
596} amb_rxq;
597
598typedef struct {
599 unsigned long tx_ok;
600 struct {
601 unsigned long ok;
602 unsigned long error;
603 unsigned long badcrc;
604 unsigned long toolong;
605 unsigned long aborted;
606 unsigned long unused;
607 } rx;
608} amb_stats;
609
610
611
612typedef struct {
613 u8 tx_vc_bits:7;
614 u8 tx_present:1;
615} amb_tx_info;
616
617typedef struct {
618 unsigned char pool;
619} amb_rx_info;
620
621typedef struct {
622 amb_rx_info rx_info;
623 u16 tx_frame_bits;
624 unsigned int tx_rate;
625 unsigned int rx_rate;
626} amb_vcc;
627
628struct amb_dev {
629 u8 irq;
630 u8 flags;
631 u32 iobase;
632 u32 * membase;
633
634#ifdef FILL_RX_POOLS_IN_BH
635 struct tq_struct bh;
636#endif
637
638 amb_cq cq;
639 amb_txq txq;
640 amb_rxq rxq[NUM_RX_POOLS];
641
642 struct semaphore vcc_sf;
643 amb_tx_info txer[NUM_VCS];
644 struct atm_vcc * rxer[NUM_VCS];
645 unsigned int tx_avail;
646 unsigned int rx_avail;
647
648 amb_stats stats;
649
650 struct atm_dev * atm_dev;
651 struct pci_dev * pci_dev;
652 struct amb_dev * prev;
653};
654
655typedef struct amb_dev amb_dev;
656
657#define AMB_DEV(atm_dev) ((amb_dev *) (atm_dev)->dev_data)
658#define AMB_VCC(atm_vcc) ((amb_vcc *) (atm_vcc)->dev_data)
659
660
661
662typedef struct {
663 u32 start;
664 unsigned int count;
665} region;
666
667static region ucode_regions[];
668static u32 ucode_data[];
669static u32 ucode_start;
670
671
672
673typedef enum {
674 round_up,
675 round_down,
676 round_nearest
677} rounding;
678
679#endif
680