update atp870u driver to 0.78 from D-Link source
[linux-2.4.git] / drivers / atm / zatm.h
1 /* drivers/atm/zatm.h - ZeitNet ZN122x device driver declarations */
2
3 /* Written 1995-1998 by Werner Almesberger, EPFL LRC/ICA */
4
5
6 #ifndef DRIVER_ATM_ZATM_H
7 #define DRIVER_ATM_ZATM_H
8
9 #include <linux/config.h>
10 #include <linux/skbuff.h>
11 #include <linux/atm.h>
12 #include <linux/atmdev.h>
13 #include <linux/sonet.h>
14 #include <linux/pci.h>
15
16
17 #define DEV_LABEL       "zatm"
18
19 #define MAX_AAL5_PDU    10240   /* allocate for AAL5 PDUs of this size */
20 #define MAX_RX_SIZE_LD  14      /* ceil(log2((MAX_AAL5_PDU+47)/48)) */
21
22 #define LOW_MARK        12      /* start adding new buffers if less than 12 */
23 #define HIGH_MARK       30      /* stop adding buffers after reaching 30 */
24 #define OFF_CNG_THRES   5       /* threshold for offset changes */
25
26 #define RX_SIZE         2       /* RX lookup entry size (in bytes) */
27 #define NR_POOLS        32      /* number of free buffer pointers */
28 #define POOL_SIZE       8       /* buffer entry size (in bytes) */
29 #define NR_SHAPERS      16      /* number of shapers */
30 #define SHAPER_SIZE     4       /* shaper entry size (in bytes) */
31 #define VC_SIZE         32      /* VC dsc (TX or RX) size (in bytes) */
32
33 #define RING_ENTRIES    32      /* ring entries (without back pointer) */
34 #define RING_WORDS      4       /* ring element size */
35 #define RING_SIZE       (sizeof(unsigned long)*(RING_ENTRIES+1)*RING_WORDS)
36
37 #define NR_MBX          4       /* four mailboxes */
38 #define MBX_RX_0        0       /* mailbox indices */
39 #define MBX_RX_1        1
40 #define MBX_TX_0        2
41 #define MBX_TX_1        3
42
43
44 /*
45  * mkdep doesn't spot this dependency, but that's okay, because zatm.c uses
46  * CONFIG_ATM_ZATM_EXACT_TS too.
47  */
48
49 #ifdef CONFIG_ATM_ZATM_EXACT_TS
50 #define POLL_INTERVAL   60      /* TSR poll interval in seconds; must be <=
51                                    (2^31-1)/clock */
52 #define TIMER_SHIFT     20      /* scale factor for fixed-point arithmetic;
53                                    1 << TIMER_SHIFT must be
54                                      (1)  <= (2^64-1)/(POLL_INTERVAL*clock),
55                                      (2)  >> clock/10^6, and
56                                      (3)  <= (2^32-1)/1000  */
57 #define ADJ_IGN_THRES   1000000 /* don't adjust if we're off by more than that
58                                    many usecs - this filters clock corrections,
59                                    time zone changes, etc. */
60 #define ADJ_REP_THRES   20000   /* report only differences of more than that
61                                    many usecs (don't mention single lost timer
62                                    ticks; 10 msec is only 0.03% anyway) */
63 #define ADJ_MSG_THRES   5       /* issue complaints only if getting that many
64                                    significant timer differences in a row */
65 #endif
66
67
68 struct zatm_vcc {
69         /*-------------------------------- RX part */
70         int rx_chan;                    /* RX channel, 0 if none */
71         int pool;                       /* free buffer pool */
72         /*-------------------------------- TX part */
73         int tx_chan;                    /* TX channel, 0 if none */
74         int shaper;                     /* shaper, <0 if none */
75         struct sk_buff_head tx_queue;   /* list of buffers in transit */
76         wait_queue_head_t tx_wait;      /* for close */
77         u32 *ring;                      /* transmit ring */
78         int ring_curr;                  /* current write position */
79         int txing;                      /* number of transmits in progress */
80         struct sk_buff_head backlog;    /* list of buffers waiting for ring */
81 };
82
83 struct zatm_dev {
84         /*-------------------------------- TX part */
85         int tx_bw;                      /* remaining bandwidth */
86         u32 free_shapers;               /* bit set */
87         int ubr;                        /* UBR shaper; -1 if none */
88         int ubr_ref_cnt;                /* number of VCs using UBR shaper */
89         /*-------------------------------- RX part */
90         int pool_ref[NR_POOLS];         /* free buffer pool usage counters */
91         volatile struct sk_buff *last_free[NR_POOLS];
92                                         /* last entry in respective pool */
93         struct sk_buff_head pool[NR_POOLS];/* free buffer pools */
94         struct zatm_pool_info pool_info[NR_POOLS]; /* pool information */
95         /*-------------------------------- maps */
96         struct atm_vcc **tx_map;        /* TX VCCs */
97         struct atm_vcc **rx_map;        /* RX VCCs */
98         int chans;                      /* map size, must be 2^n */
99         /*-------------------------------- mailboxes */
100         unsigned long mbx_start[NR_MBX];/* start addresses */
101         u16 mbx_end[NR_MBX];            /* end offset (in bytes) */
102         /*-------------------------------- other pointers */
103         u32 pool_base;                  /* Free buffer pool dsc (word addr) */
104         /*-------------------------------- ZATM links */
105         struct atm_dev *more;           /* other ZATM devices */
106 #ifdef CONFIG_ATM_ZATM_EXACT_TS
107         /*-------------------------------- timestamp calculation */
108         u32 last_clk;                   /* results of last poll: clock, */
109         struct timeval last_time;       /*   virtual time and */
110         struct timeval last_real_time;  /*   real time */
111         u32 factor;                     /* multiplication factor */
112         int timer_diffs;                /* number of significant deviations */
113         struct zatm_t_hist timer_history[ZATM_TIMER_HISTORY_SIZE];
114                                         /* record of timer synchronizations */
115         int th_curr;                    /* current position */
116 #endif
117         /*-------------------------------- general information */
118         int mem;                        /* RAM on board (in bytes) */
119         int khz;                        /* timer clock */
120         int copper;                     /* PHY type */
121         unsigned char irq;              /* IRQ */
122         unsigned int base;              /* IO base address */
123         struct pci_dev *pci_dev;        /* PCI stuff */
124 };
125
126
127 #define ZATM_DEV(d) ((struct zatm_dev *) (d)->dev_data)
128 #define ZATM_VCC(d) ((struct zatm_vcc *) (d)->dev_data)
129
130
131 struct zatm_skb_prv {
132         struct atm_skb_data _;          /* reserved */
133         u32 *dsc;                       /* pointer to skb's descriptor */
134 };
135
136 #define ZATM_PRV_DSC(skb) (((struct zatm_skb_prv *) (skb)->cb)->dsc)
137
138 #endif