Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
3c505.h
Go to the documentation of this file.
1 /*****************************************************************
2  *
3  * defines for 3Com Etherlink Plus adapter
4  *
5  *****************************************************************/
6 
7 #define ELP_DMA 6
8 #define ELP_RX_PCBS 4
9 #define ELP_MAX_CARDS 4
10 
11 /*
12  * I/O register offsets
13  */
14 #define PORT_COMMAND 0x00 /* read/write, 8-bit */
15 #define PORT_STATUS 0x02 /* read only, 8-bit */
16 #define PORT_AUXDMA 0x02 /* write only, 8-bit */
17 #define PORT_DATA 0x04 /* read/write, 16-bit */
18 #define PORT_CONTROL 0x06 /* read/write, 8-bit */
19 
20 #define ELP_IO_EXTENT 0x10 /* size of used IO registers */
21 
22 /*
23  * host control registers bits
24  */
25 #define ATTN 0x80 /* attention */
26 #define FLSH 0x40 /* flush data register */
27 #define DMAE 0x20 /* DMA enable */
28 #define DIR 0x10 /* direction */
29 #define TCEN 0x08 /* terminal count interrupt enable */
30 #define CMDE 0x04 /* command register interrupt enable */
31 #define HSF2 0x02 /* host status flag 2 */
32 #define HSF1 0x01 /* host status flag 1 */
33 
34 /*
35  * combinations of HSF flags used for PCB transmission
36  */
37 #define HSF_PCB_ACK HSF1
38 #define HSF_PCB_NAK HSF2
39 #define HSF_PCB_END (HSF2|HSF1)
40 #define HSF_PCB_MASK (HSF2|HSF1)
41 
42 /*
43  * host status register bits
44  */
45 #define HRDY 0x80 /* data register ready */
46 #define HCRE 0x40 /* command register empty */
47 #define ACRF 0x20 /* adapter command register full */
48 /* #define DIR 0x10 direction - same as in control register */
49 #define DONE 0x08 /* DMA done */
50 #define ASF3 0x04 /* adapter status flag 3 */
51 #define ASF2 0x02 /* adapter status flag 2 */
52 #define ASF1 0x01 /* adapter status flag 1 */
53 
54 /*
55  * combinations of ASF flags used for PCB reception
56  */
57 #define ASF_PCB_ACK ASF1
58 #define ASF_PCB_NAK ASF2
59 #define ASF_PCB_END (ASF2|ASF1)
60 #define ASF_PCB_MASK (ASF2|ASF1)
61 
62 /*
63  * host aux DMA register bits
64  */
65 #define DMA_BRST 0x01 /* DMA burst */
66 
67 /*
68  * maximum amount of data allowed in a PCB
69  */
70 #define MAX_PCB_DATA 62
71 
72 /*****************************************************************
73  *
74  * timeout value
75  * this is a rough value used for loops to stop them from
76  * locking up the whole machine in the case of failure or
77  * error conditions
78  *
79  *****************************************************************/
80 
81 #define TIMEOUT 300
82 
83 /*****************************************************************
84  *
85  * PCB commands
86  *
87  *****************************************************************/
88 
89 enum {
90  /*
91  * host PCB commands
92  */
111 
112  /*
113  * adapter PCB commands
114  */
130 };
131 
132 /* Definitions for the PCB data structure */
133 
134 /* Data units */
135 typedef unsigned char byte;
136 typedef unsigned short int word;
137 typedef unsigned long int dword;
138 
139 /* Data structures */
140 struct Memconf {
142  rcv_q,
143  mcast,
144  frame,
145  rcv_b,
146  progs;
147 };
148 
149 struct Rcv_pkt {
151  buf_seg,
152  buf_len,
153  timeout;
154 };
155 
156 struct Xmit_pkt {
158  buf_seg,
159  pkt_len;
160 };
161 
162 struct Rcv_resp {
164  buf_seg,
165  buf_len,
166  pkt_len,
167  timeout,
168  status;
170 };
171 
172 struct Xmit_resp {
174  buf_seg,
175  c_stat,
176  status;
177 };
178 
179 
180 struct Netstat {
182  tot_xmit;
184  err_align,
185  err_res,
186  err_ovrrun;
187 };
188 
189 
190 struct Selftest {
192  union {
194  struct {
196  } RAM;
198  } failure;
199 };
200 
201 struct Info {
203  major_vers;
205  RAM_sz,
206  free_ofs,
207  free_seg;
208 };
209 
210 struct Memdump {
212  off,
213  seg;
214 };
215 
216 /*
217 Primary Command Block. The most important data structure. All communication
218 between the host and the adapter is done with these. (Except for the actual
219 Ethernet data, which has different packaging.)
220 */
221 typedef struct {
224  union {
225  struct Memconf memconf;
227  struct Rcv_pkt rcv_pkt;
228  struct Xmit_pkt xmit_pkt;
229  byte multicast[10][6];
232  struct Rcv_resp rcv_resp;
233  struct Xmit_resp xmit_resp;
234  struct Netstat netstat;
236  struct Info info;
237  struct Memdump memdump;
238  byte raw[62];
239  } data;
240 } pcb_struct;
241 
242 /* These defines for 'configure' */
243 #define RECV_STATION 0x00
244 #define RECV_BROAD 0x01
245 #define RECV_MULTI 0x02
246 #define RECV_PROMISC 0x04
247 #define NO_LOOPBACK 0x00
248 #define INT_LOOPBACK 0x08
249 #define EXT_LOOPBACK 0x10
250 
251 /*****************************************************************
252  *
253  * structure to hold context information for adapter
254  *
255  *****************************************************************/
256 
257 #define DMA_BUFFER_SIZE 1600
258 #define BACKLOG_SIZE 4
259 
260 typedef struct {
261  volatile short got[NUM_TRANSMIT_CMDS]; /* flags for
262  command completion */
263  pcb_struct tx_pcb; /* PCB for foreground sending */
264  pcb_struct rx_pcb; /* PCB for foreground receiving */
265  pcb_struct itx_pcb; /* PCB for background sending */
266  pcb_struct irx_pcb; /* PCB for background receiving */
267 
268  void *dma_buffer;
269 
270  struct {
271  unsigned int length[BACKLOG_SIZE];
272  unsigned int in;
273  unsigned int out;
274  } rx_backlog;
275 
276  struct {
277  unsigned int direction;
278  unsigned int length;
279  struct sk_buff *skb;
280  void *target;
281  unsigned long start_time;
282  } current_dma;
283 
284  /* flags */
285  unsigned long send_pcb_semaphore;
286  unsigned long dmaing;
287  unsigned long busy;
288 
289  unsigned int rx_active; /* number of receive PCBs */
290  volatile unsigned char hcr_val; /* what we think the HCR contains */
291  spinlock_t lock; /* Interrupt v tx lock */
292 } elp_device;