summaryrefslogtreecommitdiffstats
path: root/drivers/atm/nicstar.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/atm/nicstar.h')
-rw-r--r--drivers/atm/nicstar.h602
1 files changed, 270 insertions, 332 deletions
diff --git a/drivers/atm/nicstar.h b/drivers/atm/nicstar.h
index 6010e3daa6a2..9bc27ea5088e 100644
--- a/drivers/atm/nicstar.h
+++ b/drivers/atm/nicstar.h
@@ -1,5 +1,4 @@
1/****************************************************************************** 1/*
2 *
3 * nicstar.h 2 * nicstar.h
4 * 3 *
5 * Header file for the nicstar device driver. 4 * Header file for the nicstar device driver.
@@ -8,29 +7,26 @@
8 * PowerPC support by Jay Talbott (jay_talbott@mcg.mot.com) April 1999 7 * PowerPC support by Jay Talbott (jay_talbott@mcg.mot.com) April 1999
9 * 8 *
10 * (C) INESC 1998 9 * (C) INESC 1998
11 * 10 */
12 ******************************************************************************/
13
14 11
15#ifndef _LINUX_NICSTAR_H_ 12#ifndef _LINUX_NICSTAR_H_
16#define _LINUX_NICSTAR_H_ 13#define _LINUX_NICSTAR_H_
17 14
18 15/* Includes */
19/* Includes *******************************************************************/
20 16
21#include <linux/types.h> 17#include <linux/types.h>
22#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/idr.h>
23#include <linux/uio.h> 20#include <linux/uio.h>
24#include <linux/skbuff.h> 21#include <linux/skbuff.h>
25#include <linux/atmdev.h> 22#include <linux/atmdev.h>
26#include <linux/atm_nicstar.h> 23#include <linux/atm_nicstar.h>
27 24
28 25/* Options */
29/* Options ********************************************************************/
30 26
31#define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards 27#define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards
32 controlled by the device driver. Must 28 controlled by the device driver. Must
33 be <= 5 */ 29 be <= 5 */
34 30
35#undef RCQ_SUPPORT /* Do not define this for now */ 31#undef RCQ_SUPPORT /* Do not define this for now */
36 32
@@ -43,7 +39,7 @@
43#define NS_VPIBITS 2 /* 0, 1, 2, or 8 */ 39#define NS_VPIBITS 2 /* 0, 1, 2, or 8 */
44 40
45#define NS_MAX_RCTSIZE 4096 /* Number of entries. 4096 or 16384. 41#define NS_MAX_RCTSIZE 4096 /* Number of entries. 4096 or 16384.
46 Define 4096 only if (all) your card(s) 42 Define 4096 only if (all) your card(s)
47 have 32K x 32bit SRAM, in which case 43 have 32K x 32bit SRAM, in which case
48 setting this to 16384 will just waste a 44 setting this to 16384 will just waste a
49 lot of memory. 45 lot of memory.
@@ -51,33 +47,32 @@
51 128K x 32bit SRAM will limit the maximum 47 128K x 32bit SRAM will limit the maximum
52 VCI. */ 48 VCI. */
53 49
54/*#define NS_PCI_LATENCY 64*/ /* Must be a multiple of 32 */ 50 /*#define NS_PCI_LATENCY 64*//* Must be a multiple of 32 */
55 51
56 /* Number of buffers initially allocated */ 52 /* Number of buffers initially allocated */
57#define NUM_SB 32 /* Must be even */ 53#define NUM_SB 32 /* Must be even */
58#define NUM_LB 24 /* Must be even */ 54#define NUM_LB 24 /* Must be even */
59#define NUM_HB 8 /* Pre-allocated huge buffers */ 55#define NUM_HB 8 /* Pre-allocated huge buffers */
60#define NUM_IOVB 48 /* Iovec buffers */ 56#define NUM_IOVB 48 /* Iovec buffers */
61 57
62 /* Lower level for count of buffers */ 58 /* Lower level for count of buffers */
63#define MIN_SB 8 /* Must be even */ 59#define MIN_SB 8 /* Must be even */
64#define MIN_LB 8 /* Must be even */ 60#define MIN_LB 8 /* Must be even */
65#define MIN_HB 6 61#define MIN_HB 6
66#define MIN_IOVB 8 62#define MIN_IOVB 8
67 63
68 /* Upper level for count of buffers */ 64 /* Upper level for count of buffers */
69#define MAX_SB 64 /* Must be even, <= 508 */ 65#define MAX_SB 64 /* Must be even, <= 508 */
70#define MAX_LB 48 /* Must be even, <= 508 */ 66#define MAX_LB 48 /* Must be even, <= 508 */
71#define MAX_HB 10 67#define MAX_HB 10
72#define MAX_IOVB 80 68#define MAX_IOVB 80
73 69
74 /* These are the absolute maximum allowed for the ioctl() */ 70 /* These are the absolute maximum allowed for the ioctl() */
75#define TOP_SB 256 /* Must be even, <= 508 */ 71#define TOP_SB 256 /* Must be even, <= 508 */
76#define TOP_LB 128 /* Must be even, <= 508 */ 72#define TOP_LB 128 /* Must be even, <= 508 */
77#define TOP_HB 64 73#define TOP_HB 64
78#define TOP_IOVB 256 74#define TOP_IOVB 256
79 75
80
81#define MAX_TBD_PER_VC 1 /* Number of TBDs before a TSR */ 76#define MAX_TBD_PER_VC 1 /* Number of TBDs before a TSR */
82#define MAX_TBD_PER_SCQ 10 /* Only meaningful for variable rate SCQs */ 77#define MAX_TBD_PER_SCQ 10 /* Only meaningful for variable rate SCQs */
83 78
@@ -89,15 +84,12 @@
89 84
90#define PCR_TOLERANCE (1.0001) 85#define PCR_TOLERANCE (1.0001)
91 86
92 87/* ESI stuff */
93
94/* ESI stuff ******************************************************************/
95 88
96#define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C 89#define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C
97#define NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT 0xF6 90#define NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT 0xF6
98 91
99 92/* #defines */
100/* #defines *******************************************************************/
101 93
102#define NS_IOREMAP_SIZE 4096 94#define NS_IOREMAP_SIZE 4096
103 95
@@ -123,22 +115,19 @@
123#define NS_SMSKBSIZE (NS_SMBUFSIZE + NS_AAL0_HEADER) 115#define NS_SMSKBSIZE (NS_SMBUFSIZE + NS_AAL0_HEADER)
124#define NS_LGSKBSIZE (NS_SMBUFSIZE + NS_LGBUFSIZE) 116#define NS_LGSKBSIZE (NS_SMBUFSIZE + NS_LGBUFSIZE)
125 117
118/* NICStAR structures located in host memory */
126 119
127/* NICStAR structures located in host memory **********************************/ 120/*
128 121 * RSQ - Receive Status Queue
129
130
131/* RSQ - Receive Status Queue
132 * 122 *
133 * Written by the NICStAR, read by the device driver. 123 * Written by the NICStAR, read by the device driver.
134 */ 124 */
135 125
136typedef struct ns_rsqe 126typedef struct ns_rsqe {
137{ 127 u32 word_1;
138 u32 word_1; 128 u32 buffer_handle;
139 u32 buffer_handle; 129 u32 final_aal5_crc32;
140 u32 final_aal5_crc32; 130 u32 word_4;
141 u32 word_4;
142} ns_rsqe; 131} ns_rsqe;
143 132
144#define ns_rsqe_vpi(ns_rsqep) \ 133#define ns_rsqe_vpi(ns_rsqep) \
@@ -175,30 +164,27 @@ typedef struct ns_rsqe
175#define ns_rsqe_cellcount(ns_rsqep) \ 164#define ns_rsqe_cellcount(ns_rsqep) \
176 (le32_to_cpu((ns_rsqep)->word_4) & 0x000001FF) 165 (le32_to_cpu((ns_rsqep)->word_4) & 0x000001FF)
177#define ns_rsqe_init(ns_rsqep) \ 166#define ns_rsqe_init(ns_rsqep) \
178 ((ns_rsqep)->word_4 = cpu_to_le32(0x00000000)) 167 ((ns_rsqep)->word_4 = cpu_to_le32(0x00000000))
179 168
180#define NS_RSQ_NUM_ENTRIES (NS_RSQSIZE / 16) 169#define NS_RSQ_NUM_ENTRIES (NS_RSQSIZE / 16)
181#define NS_RSQ_ALIGNMENT NS_RSQSIZE 170#define NS_RSQ_ALIGNMENT NS_RSQSIZE
182 171
183 172/*
184 173 * RCQ - Raw Cell Queue
185/* RCQ - Raw Cell Queue
186 * 174 *
187 * Written by the NICStAR, read by the device driver. 175 * Written by the NICStAR, read by the device driver.
188 */ 176 */
189 177
190typedef struct cell_payload 178typedef struct cell_payload {
191{ 179 u32 word[12];
192 u32 word[12];
193} cell_payload; 180} cell_payload;
194 181
195typedef struct ns_rcqe 182typedef struct ns_rcqe {
196{ 183 u32 word_1;
197 u32 word_1; 184 u32 word_2;
198 u32 word_2; 185 u32 word_3;
199 u32 word_3; 186 u32 word_4;
200 u32 word_4; 187 cell_payload payload;
201 cell_payload payload;
202} ns_rcqe; 188} ns_rcqe;
203 189
204#define NS_RCQE_SIZE 64 /* bytes */ 190#define NS_RCQE_SIZE 64 /* bytes */
@@ -210,28 +196,25 @@ typedef struct ns_rcqe
210#define ns_rcqe_nextbufhandle(ns_rcqep) \ 196#define ns_rcqe_nextbufhandle(ns_rcqep) \
211 (le32_to_cpu((ns_rcqep)->word_2)) 197 (le32_to_cpu((ns_rcqep)->word_2))
212 198
213 199/*
214 200 * SCQ - Segmentation Channel Queue
215/* SCQ - Segmentation Channel Queue
216 * 201 *
217 * Written by the device driver, read by the NICStAR. 202 * Written by the device driver, read by the NICStAR.
218 */ 203 */
219 204
220typedef struct ns_scqe 205typedef struct ns_scqe {
221{ 206 u32 word_1;
222 u32 word_1; 207 u32 word_2;
223 u32 word_2; 208 u32 word_3;
224 u32 word_3; 209 u32 word_4;
225 u32 word_4;
226} ns_scqe; 210} ns_scqe;
227 211
228 /* NOTE: SCQ entries can be either a TBD (Transmit Buffer Descriptors) 212 /* NOTE: SCQ entries can be either a TBD (Transmit Buffer Descriptors)
229 or TSR (Transmit Status Requests) */ 213 or TSR (Transmit Status Requests) */
230 214
231#define NS_SCQE_TYPE_TBD 0x00000000 215#define NS_SCQE_TYPE_TBD 0x00000000
232#define NS_SCQE_TYPE_TSR 0x80000000 216#define NS_SCQE_TYPE_TSR 0x80000000
233 217
234
235#define NS_TBD_EOPDU 0x40000000 218#define NS_TBD_EOPDU 0x40000000
236#define NS_TBD_AAL0 0x00000000 219#define NS_TBD_AAL0 0x00000000
237#define NS_TBD_AAL34 0x04000000 220#define NS_TBD_AAL34 0x04000000
@@ -253,10 +236,9 @@ typedef struct ns_scqe
253#define ns_tbd_mkword_4(gfc, vpi, vci, pt, clp) \ 236#define ns_tbd_mkword_4(gfc, vpi, vci, pt, clp) \
254 (cpu_to_le32((gfc) << 28 | (vpi) << 20 | (vci) << 4 | (pt) << 1 | (clp))) 237 (cpu_to_le32((gfc) << 28 | (vpi) << 20 | (vci) << 4 | (pt) << 1 | (clp)))
255 238
256
257#define NS_TSR_INTENABLE 0x20000000 239#define NS_TSR_INTENABLE 0x20000000
258 240
259#define NS_TSR_SCDISVBR 0xFFFF /* Use as scdi for VBR SCD */ 241#define NS_TSR_SCDISVBR 0xFFFF /* Use as scdi for VBR SCD */
260 242
261#define ns_tsr_mkword_1(flags) \ 243#define ns_tsr_mkword_1(flags) \
262 (cpu_to_le32(NS_SCQE_TYPE_TSR | (flags))) 244 (cpu_to_le32(NS_SCQE_TYPE_TSR | (flags)))
@@ -273,22 +255,20 @@ typedef struct ns_scqe
273 255
274#define NS_SCQE_SIZE 16 256#define NS_SCQE_SIZE 16
275 257
276 258/*
277 259 * TSQ - Transmit Status Queue
278/* TSQ - Transmit Status Queue
279 * 260 *
280 * Written by the NICStAR, read by the device driver. 261 * Written by the NICStAR, read by the device driver.
281 */ 262 */
282 263
283typedef struct ns_tsi 264typedef struct ns_tsi {
284{ 265 u32 word_1;
285 u32 word_1; 266 u32 word_2;
286 u32 word_2;
287} ns_tsi; 267} ns_tsi;
288 268
289 /* NOTE: The first word can be a status word copied from the TSR which 269 /* NOTE: The first word can be a status word copied from the TSR which
290 originated the TSI, or a timer overflow indicator. In this last 270 originated the TSI, or a timer overflow indicator. In this last
291 case, the value of the first word is all zeroes. */ 271 case, the value of the first word is all zeroes. */
292 272
293#define NS_TSI_EMPTY 0x80000000 273#define NS_TSI_EMPTY 0x80000000
294#define NS_TSI_TIMESTAMP_MASK 0x00FFFFFF 274#define NS_TSI_TIMESTAMP_MASK 0x00FFFFFF
@@ -301,12 +281,10 @@ typedef struct ns_tsi
301#define ns_tsi_init(ns_tsip) \ 281#define ns_tsi_init(ns_tsip) \
302 ((ns_tsip)->word_2 = cpu_to_le32(NS_TSI_EMPTY)) 282 ((ns_tsip)->word_2 = cpu_to_le32(NS_TSI_EMPTY))
303 283
304
305#define NS_TSQSIZE 8192 284#define NS_TSQSIZE 8192
306#define NS_TSQ_NUM_ENTRIES 1024 285#define NS_TSQ_NUM_ENTRIES 1024
307#define NS_TSQ_ALIGNMENT 8192 286#define NS_TSQ_ALIGNMENT 8192
308 287
309
310#define NS_TSI_SCDISVBR NS_TSR_SCDISVBR 288#define NS_TSI_SCDISVBR NS_TSR_SCDISVBR
311 289
312#define ns_tsi_tmrof(ns_tsip) \ 290#define ns_tsi_tmrof(ns_tsip) \
@@ -316,26 +294,22 @@ typedef struct ns_tsi
316#define ns_tsi_getscqpos(ns_tsip) \ 294#define ns_tsi_getscqpos(ns_tsip) \
317 (le32_to_cpu((ns_tsip)->word_1) & 0x00007FFF) 295 (le32_to_cpu((ns_tsip)->word_1) & 0x00007FFF)
318 296
297/* NICStAR structures located in local SRAM */
319 298
320 299/*
321/* NICStAR structures located in local SRAM ***********************************/ 300 * RCT - Receive Connection Table
322
323
324
325/* RCT - Receive Connection Table
326 * 301 *
327 * Written by both the NICStAR and the device driver. 302 * Written by both the NICStAR and the device driver.
328 */ 303 */
329 304
330typedef struct ns_rcte 305typedef struct ns_rcte {
331{ 306 u32 word_1;
332 u32 word_1; 307 u32 buffer_handle;
333 u32 buffer_handle; 308 u32 dma_address;
334 u32 dma_address; 309 u32 aal5_crc32;
335 u32 aal5_crc32;
336} ns_rcte; 310} ns_rcte;
337 311
338#define NS_RCTE_BSFB 0x00200000 /* Rev. D only */ 312#define NS_RCTE_BSFB 0x00200000 /* Rev. D only */
339#define NS_RCTE_NZGFC 0x00100000 313#define NS_RCTE_NZGFC 0x00100000
340#define NS_RCTE_CONNECTOPEN 0x00080000 314#define NS_RCTE_CONNECTOPEN 0x00080000
341#define NS_RCTE_AALMASK 0x00070000 315#define NS_RCTE_AALMASK 0x00070000
@@ -358,25 +332,21 @@ typedef struct ns_rcte
358#define NS_RCT_ENTRY_SIZE 4 /* Number of dwords */ 332#define NS_RCT_ENTRY_SIZE 4 /* Number of dwords */
359 333
360 /* NOTE: We could make macros to contruct the first word of the RCTE, 334 /* NOTE: We could make macros to contruct the first word of the RCTE,
361 but that doesn't seem to make much sense... */ 335 but that doesn't seem to make much sense... */
362 336
363 337/*
364 338 * FBD - Free Buffer Descriptor
365/* FBD - Free Buffer Descriptor
366 * 339 *
367 * Written by the device driver using via the command register. 340 * Written by the device driver using via the command register.
368 */ 341 */
369 342
370typedef struct ns_fbd 343typedef struct ns_fbd {
371{ 344 u32 buffer_handle;
372 u32 buffer_handle; 345 u32 dma_address;
373 u32 dma_address;
374} ns_fbd; 346} ns_fbd;
375 347
376 348/*
377 349 * TST - Transmit Schedule Table
378
379/* TST - Transmit Schedule Table
380 * 350 *
381 * Written by the device driver. 351 * Written by the device driver.
382 */ 352 */
@@ -385,40 +355,38 @@ typedef u32 ns_tste;
385 355
386#define NS_TST_OPCODE_MASK 0x60000000 356#define NS_TST_OPCODE_MASK 0x60000000
387 357
388#define NS_TST_OPCODE_NULL 0x00000000 /* Insert null cell */ 358#define NS_TST_OPCODE_NULL 0x00000000 /* Insert null cell */
389#define NS_TST_OPCODE_FIXED 0x20000000 /* Cell from a fixed rate channel */ 359#define NS_TST_OPCODE_FIXED 0x20000000 /* Cell from a fixed rate channel */
390#define NS_TST_OPCODE_VARIABLE 0x40000000 360#define NS_TST_OPCODE_VARIABLE 0x40000000
391#define NS_TST_OPCODE_END 0x60000000 /* Jump */ 361#define NS_TST_OPCODE_END 0x60000000 /* Jump */
392 362
393#define ns_tste_make(opcode, sramad) (opcode | sramad) 363#define ns_tste_make(opcode, sramad) (opcode | sramad)
394 364
395 /* NOTE: 365 /* NOTE:
396 366
397 - When the opcode is FIXED, sramad specifies the SRAM address of the 367 - When the opcode is FIXED, sramad specifies the SRAM address of the
398 SCD for that fixed rate channel. 368 SCD for that fixed rate channel.
399 - When the opcode is END, sramad specifies the SRAM address of the 369 - When the opcode is END, sramad specifies the SRAM address of the
400 location of the next TST entry to read. 370 location of the next TST entry to read.
401 */ 371 */
402 372
403 373/*
404 374 * SCD - Segmentation Channel Descriptor
405/* SCD - Segmentation Channel Descriptor
406 * 375 *
407 * Written by both the device driver and the NICStAR 376 * Written by both the device driver and the NICStAR
408 */ 377 */
409 378
410typedef struct ns_scd 379typedef struct ns_scd {
411{ 380 u32 word_1;
412 u32 word_1; 381 u32 word_2;
413 u32 word_2; 382 u32 partial_aal5_crc;
414 u32 partial_aal5_crc; 383 u32 reserved;
415 u32 reserved; 384 ns_scqe cache_a;
416 ns_scqe cache_a; 385 ns_scqe cache_b;
417 ns_scqe cache_b;
418} ns_scd; 386} ns_scd;
419 387
420#define NS_SCD_BASE_MASK_VAR 0xFFFFE000 /* Variable rate */ 388#define NS_SCD_BASE_MASK_VAR 0xFFFFE000 /* Variable rate */
421#define NS_SCD_BASE_MASK_FIX 0xFFFFFC00 /* Fixed rate */ 389#define NS_SCD_BASE_MASK_FIX 0xFFFFFC00 /* Fixed rate */
422#define NS_SCD_TAIL_MASK_VAR 0x00001FF0 390#define NS_SCD_TAIL_MASK_VAR 0x00001FF0
423#define NS_SCD_TAIL_MASK_FIX 0x000003F0 391#define NS_SCD_TAIL_MASK_FIX 0x000003F0
424#define NS_SCD_HEAD_MASK_VAR 0x00001FF0 392#define NS_SCD_HEAD_MASK_VAR 0x00001FF0
@@ -426,13 +394,9 @@ typedef struct ns_scd
426#define NS_SCD_XMITFOREVER 0x02000000 394#define NS_SCD_XMITFOREVER 0x02000000
427 395
428 /* NOTE: There are other fields in word 2 of the SCD, but as they should 396 /* NOTE: There are other fields in word 2 of the SCD, but as they should
429 not be needed in the device driver they are not defined here. */ 397 not be needed in the device driver they are not defined here. */
430
431
432
433
434/* NICStAR local SRAM memory map **********************************************/
435 398
399/* NICStAR local SRAM memory map */
436 400
437#define NS_RCT 0x00000 401#define NS_RCT 0x00000
438#define NS_RCT_32_END 0x03FFF 402#define NS_RCT_32_END 0x03FFF
@@ -455,100 +419,93 @@ typedef struct ns_scd
455#define NS_LGFBQ 0x1FC00 419#define NS_LGFBQ 0x1FC00
456#define NS_LGFBQ_END 0x1FFFF 420#define NS_LGFBQ_END 0x1FFFF
457 421
458 422/* NISCtAR operation registers */
459
460/* NISCtAR operation registers ************************************************/
461
462 423
463/* See Section 3.4 of `IDT77211 NICStAR User Manual' from www.idt.com */ 424/* See Section 3.4 of `IDT77211 NICStAR User Manual' from www.idt.com */
464 425
465enum ns_regs 426enum ns_regs {
466{ 427 DR0 = 0x00, /* Data Register 0 R/W */
467 DR0 = 0x00, /* Data Register 0 R/W*/ 428 DR1 = 0x04, /* Data Register 1 W */
468 DR1 = 0x04, /* Data Register 1 W */ 429 DR2 = 0x08, /* Data Register 2 W */
469 DR2 = 0x08, /* Data Register 2 W */ 430 DR3 = 0x0C, /* Data Register 3 W */
470 DR3 = 0x0C, /* Data Register 3 W */ 431 CMD = 0x10, /* Command W */
471 CMD = 0x10, /* Command W */ 432 CFG = 0x14, /* Configuration R/W */
472 CFG = 0x14, /* Configuration R/W */ 433 STAT = 0x18, /* Status R/W */
473 STAT = 0x18, /* Status R/W */ 434 RSQB = 0x1C, /* Receive Status Queue Base W */
474 RSQB = 0x1C, /* Receive Status Queue Base W */ 435 RSQT = 0x20, /* Receive Status Queue Tail R */
475 RSQT = 0x20, /* Receive Status Queue Tail R */ 436 RSQH = 0x24, /* Receive Status Queue Head W */
476 RSQH = 0x24, /* Receive Status Queue Head W */ 437 CDC = 0x28, /* Cell Drop Counter R/clear */
477 CDC = 0x28, /* Cell Drop Counter R/clear */ 438 VPEC = 0x2C, /* VPI/VCI Lookup Error Count R/clear */
478 VPEC = 0x2C, /* VPI/VCI Lookup Error Count R/clear */ 439 ICC = 0x30, /* Invalid Cell Count R/clear */
479 ICC = 0x30, /* Invalid Cell Count R/clear */ 440 RAWCT = 0x34, /* Raw Cell Tail R */
480 RAWCT = 0x34, /* Raw Cell Tail R */ 441 TMR = 0x38, /* Timer R */
481 TMR = 0x38, /* Timer R */ 442 TSTB = 0x3C, /* Transmit Schedule Table Base R/W */
482 TSTB = 0x3C, /* Transmit Schedule Table Base R/W */ 443 TSQB = 0x40, /* Transmit Status Queue Base W */
483 TSQB = 0x40, /* Transmit Status Queue Base W */ 444 TSQT = 0x44, /* Transmit Status Queue Tail R */
484 TSQT = 0x44, /* Transmit Status Queue Tail R */ 445 TSQH = 0x48, /* Transmit Status Queue Head W */
485 TSQH = 0x48, /* Transmit Status Queue Head W */ 446 GP = 0x4C, /* General Purpose R/W */
486 GP = 0x4C, /* General Purpose R/W */ 447 VPM = 0x50 /* VPI/VCI Mask W */
487 VPM = 0x50 /* VPI/VCI Mask W */
488}; 448};
489 449
490 450/* NICStAR commands issued to the CMD register */
491/* NICStAR commands issued to the CMD register ********************************/
492
493 451
494/* Top 4 bits are command opcode, lower 28 are parameters. */ 452/* Top 4 bits are command opcode, lower 28 are parameters. */
495 453
496#define NS_CMD_NO_OPERATION 0x00000000 454#define NS_CMD_NO_OPERATION 0x00000000
497 /* params always 0 */ 455 /* params always 0 */
498 456
499#define NS_CMD_OPENCLOSE_CONNECTION 0x20000000 457#define NS_CMD_OPENCLOSE_CONNECTION 0x20000000
500 /* b19{1=open,0=close} b18-2{SRAM addr} */ 458 /* b19{1=open,0=close} b18-2{SRAM addr} */
501 459
502#define NS_CMD_WRITE_SRAM 0x40000000 460#define NS_CMD_WRITE_SRAM 0x40000000
503 /* b18-2{SRAM addr} b1-0{burst size} */ 461 /* b18-2{SRAM addr} b1-0{burst size} */
504 462
505#define NS_CMD_READ_SRAM 0x50000000 463#define NS_CMD_READ_SRAM 0x50000000
506 /* b18-2{SRAM addr} */ 464 /* b18-2{SRAM addr} */
507 465
508#define NS_CMD_WRITE_FREEBUFQ 0x60000000 466#define NS_CMD_WRITE_FREEBUFQ 0x60000000
509 /* b0{large buf indicator} */ 467 /* b0{large buf indicator} */
510 468
511#define NS_CMD_READ_UTILITY 0x80000000 469#define NS_CMD_READ_UTILITY 0x80000000
512 /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */ 470 /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
513 471
514#define NS_CMD_WRITE_UTILITY 0x90000000 472#define NS_CMD_WRITE_UTILITY 0x90000000
515 /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */ 473 /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
516 474
517#define NS_CMD_OPEN_CONNECTION (NS_CMD_OPENCLOSE_CONNECTION | 0x00080000) 475#define NS_CMD_OPEN_CONNECTION (NS_CMD_OPENCLOSE_CONNECTION | 0x00080000)
518#define NS_CMD_CLOSE_CONNECTION NS_CMD_OPENCLOSE_CONNECTION 476#define NS_CMD_CLOSE_CONNECTION NS_CMD_OPENCLOSE_CONNECTION
519 477
520 478/* NICStAR configuration bits */
521/* NICStAR configuration bits *************************************************/ 479
522 480#define NS_CFG_SWRST 0x80000000 /* Software Reset */
523#define NS_CFG_SWRST 0x80000000 /* Software Reset */ 481#define NS_CFG_RXPATH 0x20000000 /* Receive Path Enable */
524#define NS_CFG_RXPATH 0x20000000 /* Receive Path Enable */ 482#define NS_CFG_SMBUFSIZE_MASK 0x18000000 /* Small Receive Buffer Size */
525#define NS_CFG_SMBUFSIZE_MASK 0x18000000 /* Small Receive Buffer Size */ 483#define NS_CFG_LGBUFSIZE_MASK 0x06000000 /* Large Receive Buffer Size */
526#define NS_CFG_LGBUFSIZE_MASK 0x06000000 /* Large Receive Buffer Size */ 484#define NS_CFG_EFBIE 0x01000000 /* Empty Free Buffer Queue
527#define NS_CFG_EFBIE 0x01000000 /* Empty Free Buffer Queue 485 Interrupt Enable */
528 Interrupt Enable */ 486#define NS_CFG_RSQSIZE_MASK 0x00C00000 /* Receive Status Queue Size */
529#define NS_CFG_RSQSIZE_MASK 0x00C00000 /* Receive Status Queue Size */ 487#define NS_CFG_ICACCEPT 0x00200000 /* Invalid Cell Accept */
530#define NS_CFG_ICACCEPT 0x00200000 /* Invalid Cell Accept */ 488#define NS_CFG_IGNOREGFC 0x00100000 /* Ignore General Flow Control */
531#define NS_CFG_IGNOREGFC 0x00100000 /* Ignore General Flow Control */ 489#define NS_CFG_VPIBITS_MASK 0x000C0000 /* VPI/VCI Bits Size Select */
532#define NS_CFG_VPIBITS_MASK 0x000C0000 /* VPI/VCI Bits Size Select */ 490#define NS_CFG_RCTSIZE_MASK 0x00030000 /* Receive Connection Table Size */
533#define NS_CFG_RCTSIZE_MASK 0x00030000 /* Receive Connection Table Size */ 491#define NS_CFG_VCERRACCEPT 0x00008000 /* VPI/VCI Error Cell Accept */
534#define NS_CFG_VCERRACCEPT 0x00008000 /* VPI/VCI Error Cell Accept */ 492#define NS_CFG_RXINT_MASK 0x00007000 /* End of Receive PDU Interrupt
535#define NS_CFG_RXINT_MASK 0x00007000 /* End of Receive PDU Interrupt 493 Handling */
536 Handling */ 494#define NS_CFG_RAWIE 0x00000800 /* Raw Cell Qu' Interrupt Enable */
537#define NS_CFG_RAWIE 0x00000800 /* Raw Cell Qu' Interrupt Enable */ 495#define NS_CFG_RSQAFIE 0x00000400 /* Receive Queue Almost Full
538#define NS_CFG_RSQAFIE 0x00000400 /* Receive Queue Almost Full 496 Interrupt Enable */
539 Interrupt Enable */ 497#define NS_CFG_RXRM 0x00000200 /* Receive RM Cells */
540#define NS_CFG_RXRM 0x00000200 /* Receive RM Cells */ 498#define NS_CFG_TMRROIE 0x00000080 /* Timer Roll Over Interrupt
541#define NS_CFG_TMRROIE 0x00000080 /* Timer Roll Over Interrupt 499 Enable */
542 Enable */ 500#define NS_CFG_TXEN 0x00000020 /* Transmit Operation Enable */
543#define NS_CFG_TXEN 0x00000020 /* Transmit Operation Enable */ 501#define NS_CFG_TXIE 0x00000010 /* Transmit Status Interrupt
544#define NS_CFG_TXIE 0x00000010 /* Transmit Status Interrupt 502 Enable */
545 Enable */ 503#define NS_CFG_TXURIE 0x00000008 /* Transmit Under-run Interrupt
546#define NS_CFG_TXURIE 0x00000008 /* Transmit Under-run Interrupt 504 Enable */
547 Enable */ 505#define NS_CFG_UMODE 0x00000004 /* Utopia Mode (cell/byte) Select */
548#define NS_CFG_UMODE 0x00000004 /* Utopia Mode (cell/byte) Select */ 506#define NS_CFG_TSQFIE 0x00000002 /* Transmit Status Queue Full
549#define NS_CFG_TSQFIE 0x00000002 /* Transmit Status Queue Full 507 Interrupt Enable */
550 Interrupt Enable */ 508#define NS_CFG_PHYIE 0x00000001 /* PHY Interrupt Enable */
551#define NS_CFG_PHYIE 0x00000001 /* PHY Interrupt Enable */
552 509
553#define NS_CFG_SMBUFSIZE_48 0x00000000 510#define NS_CFG_SMBUFSIZE_48 0x00000000
554#define NS_CFG_SMBUFSIZE_96 0x08000000 511#define NS_CFG_SMBUFSIZE_96 0x08000000
@@ -579,33 +536,29 @@ enum ns_regs
579#define NS_CFG_RXINT_624US 0x00003000 536#define NS_CFG_RXINT_624US 0x00003000
580#define NS_CFG_RXINT_899US 0x00004000 537#define NS_CFG_RXINT_899US 0x00004000
581 538
582 539/* NICStAR STATus bits */
583/* NICStAR STATus bits ********************************************************/ 540
584 541#define NS_STAT_SFBQC_MASK 0xFF000000 /* hi 8 bits Small Buffer Queue Count */
585#define NS_STAT_SFBQC_MASK 0xFF000000 /* hi 8 bits Small Buffer Queue Count */ 542#define NS_STAT_LFBQC_MASK 0x00FF0000 /* hi 8 bits Large Buffer Queue Count */
586#define NS_STAT_LFBQC_MASK 0x00FF0000 /* hi 8 bits Large Buffer Queue Count */ 543#define NS_STAT_TSIF 0x00008000 /* Transmit Status Queue Indicator */
587#define NS_STAT_TSIF 0x00008000 /* Transmit Status Queue Indicator */ 544#define NS_STAT_TXICP 0x00004000 /* Transmit Incomplete PDU */
588#define NS_STAT_TXICP 0x00004000 /* Transmit Incomplete PDU */ 545#define NS_STAT_TSQF 0x00001000 /* Transmit Status Queue Full */
589#define NS_STAT_TSQF 0x00001000 /* Transmit Status Queue Full */ 546#define NS_STAT_TMROF 0x00000800 /* Timer Overflow */
590#define NS_STAT_TMROF 0x00000800 /* Timer Overflow */ 547#define NS_STAT_PHYI 0x00000400 /* PHY Device Interrupt */
591#define NS_STAT_PHYI 0x00000400 /* PHY Device Interrupt */ 548#define NS_STAT_CMDBZ 0x00000200 /* Command Busy */
592#define NS_STAT_CMDBZ 0x00000200 /* Command Busy */ 549#define NS_STAT_SFBQF 0x00000100 /* Small Buffer Queue Full */
593#define NS_STAT_SFBQF 0x00000100 /* Small Buffer Queue Full */ 550#define NS_STAT_LFBQF 0x00000080 /* Large Buffer Queue Full */
594#define NS_STAT_LFBQF 0x00000080 /* Large Buffer Queue Full */ 551#define NS_STAT_RSQF 0x00000040 /* Receive Status Queue Full */
595#define NS_STAT_RSQF 0x00000040 /* Receive Status Queue Full */ 552#define NS_STAT_EOPDU 0x00000020 /* End of PDU */
596#define NS_STAT_EOPDU 0x00000020 /* End of PDU */ 553#define NS_STAT_RAWCF 0x00000010 /* Raw Cell Flag */
597#define NS_STAT_RAWCF 0x00000010 /* Raw Cell Flag */ 554#define NS_STAT_SFBQE 0x00000008 /* Small Buffer Queue Empty */
598#define NS_STAT_SFBQE 0x00000008 /* Small Buffer Queue Empty */ 555#define NS_STAT_LFBQE 0x00000004 /* Large Buffer Queue Empty */
599#define NS_STAT_LFBQE 0x00000004 /* Large Buffer Queue Empty */ 556#define NS_STAT_RSQAF 0x00000002 /* Receive Status Queue Almost Full */
600#define NS_STAT_RSQAF 0x00000002 /* Receive Status Queue Almost Full */
601 557
602#define ns_stat_sfbqc_get(stat) (((stat) & NS_STAT_SFBQC_MASK) >> 23) 558#define ns_stat_sfbqc_get(stat) (((stat) & NS_STAT_SFBQC_MASK) >> 23)
603#define ns_stat_lfbqc_get(stat) (((stat) & NS_STAT_LFBQC_MASK) >> 15) 559#define ns_stat_lfbqc_get(stat) (((stat) & NS_STAT_LFBQC_MASK) >> 15)
604 560
605 561/* #defines which depend on other #defines */
606
607/* #defines which depend on other #defines ************************************/
608
609 562
610#define NS_TST0 NS_TST_FRSCD 563#define NS_TST0 NS_TST_FRSCD
611#define NS_TST1 (NS_TST_FRSCD + NS_TST_NUM_ENTRIES + 1) 564#define NS_TST1 (NS_TST_FRSCD + NS_TST_NUM_ENTRIES + 1)
@@ -672,8 +625,7 @@ enum ns_regs
672#define NS_CFG_TSQFIE_OPT 0x00000000 625#define NS_CFG_TSQFIE_OPT 0x00000000
673#endif /* ENABLE_TSQFIE */ 626#endif /* ENABLE_TSQFIE */
674 627
675 628/* PCI stuff */
676/* PCI stuff ******************************************************************/
677 629
678#ifndef PCI_VENDOR_ID_IDT 630#ifndef PCI_VENDOR_ID_IDT
679#define PCI_VENDOR_ID_IDT 0x111D 631#define PCI_VENDOR_ID_IDT 0x111D
@@ -683,138 +635,124 @@ enum ns_regs
683#define PCI_DEVICE_ID_IDT_IDT77201 0x0001 635#define PCI_DEVICE_ID_IDT_IDT77201 0x0001
684#endif /* PCI_DEVICE_ID_IDT_IDT77201 */ 636#endif /* PCI_DEVICE_ID_IDT_IDT77201 */
685 637
638/* Device driver structures */
686 639
687 640struct ns_skb_prv {
688/* Device driver structures ***************************************************/ 641 u32 buf_type; /* BUF_SM/BUF_LG/BUF_NONE */
689 642 u32 dma;
690 643 int iovcnt;
691struct ns_skb_cb {
692 u32 buf_type; /* BUF_SM/BUF_LG/BUF_NONE */
693}; 644};
694 645
695#define NS_SKB_CB(skb) ((struct ns_skb_cb *)((skb)->cb)) 646#define NS_PRV_BUFTYPE(skb) \
696 647 (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->buf_type)
697typedef struct tsq_info 648#define NS_PRV_DMA(skb) \
698{ 649 (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->dma)
699 void *org; 650#define NS_PRV_IOVCNT(skb) \
700 ns_tsi *base; 651 (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->iovcnt)
701 ns_tsi *next; 652
702 ns_tsi *last; 653typedef struct tsq_info {
654 void *org;
655 dma_addr_t dma;
656 ns_tsi *base;
657 ns_tsi *next;
658 ns_tsi *last;
703} tsq_info; 659} tsq_info;
704 660
705 661typedef struct scq_info {
706typedef struct scq_info 662 void *org;
707{ 663 dma_addr_t dma;
708 void *org; 664 ns_scqe *base;
709 ns_scqe *base; 665 ns_scqe *last;
710 ns_scqe *last; 666 ns_scqe *next;
711 ns_scqe *next; 667 volatile ns_scqe *tail; /* Not related to the nicstar register */
712 volatile ns_scqe *tail; /* Not related to the nicstar register */ 668 unsigned num_entries;
713 unsigned num_entries; 669 struct sk_buff **skb; /* Pointer to an array of pointers
714 struct sk_buff **skb; /* Pointer to an array of pointers 670 to the sk_buffs used for tx */
715 to the sk_buffs used for tx */ 671 u32 scd; /* SRAM address of the corresponding
716 u32 scd; /* SRAM address of the corresponding 672 SCD */
717 SCD */ 673 int tbd_count; /* Only meaningful on variable rate */
718 int tbd_count; /* Only meaningful on variable rate */ 674 wait_queue_head_t scqfull_waitq;
719 wait_queue_head_t scqfull_waitq; 675 volatile char full; /* SCQ full indicator */
720 volatile char full; /* SCQ full indicator */ 676 spinlock_t lock; /* SCQ spinlock */
721 spinlock_t lock; /* SCQ spinlock */
722} scq_info; 677} scq_info;
723 678
724 679typedef struct rsq_info {
725 680 void *org;
726typedef struct rsq_info 681 dma_addr_t dma;
727{ 682 ns_rsqe *base;
728 void *org; 683 ns_rsqe *next;
729 ns_rsqe *base; 684 ns_rsqe *last;
730 ns_rsqe *next;
731 ns_rsqe *last;
732} rsq_info; 685} rsq_info;
733 686
734 687typedef struct skb_pool {
735typedef struct skb_pool 688 volatile int count; /* number of buffers in the queue */
736{ 689 struct sk_buff_head queue;
737 volatile int count; /* number of buffers in the queue */
738 struct sk_buff_head queue;
739} skb_pool; 690} skb_pool;
740 691
741/* NOTE: for small and large buffer pools, the count is not used, as the 692/* NOTE: for small and large buffer pools, the count is not used, as the
742 actual value used for buffer management is the one read from the 693 actual value used for buffer management is the one read from the
743 card. */ 694 card. */
744 695
745 696typedef struct vc_map {
746typedef struct vc_map 697 volatile unsigned int tx:1; /* TX vc? */
747{ 698 volatile unsigned int rx:1; /* RX vc? */
748 volatile unsigned int tx:1; /* TX vc? */ 699 struct atm_vcc *tx_vcc, *rx_vcc;
749 volatile unsigned int rx:1; /* RX vc? */ 700 struct sk_buff *rx_iov; /* RX iovector skb */
750 struct atm_vcc *tx_vcc, *rx_vcc; 701 scq_info *scq; /* To keep track of the SCQ */
751 struct sk_buff *rx_iov; /* RX iovector skb */ 702 u32 cbr_scd; /* SRAM address of the corresponding
752 scq_info *scq; /* To keep track of the SCQ */ 703 SCD. 0x00000000 for UBR/VBR/ABR */
753 u32 cbr_scd; /* SRAM address of the corresponding 704 int tbd_count;
754 SCD. 0x00000000 for UBR/VBR/ABR */
755 int tbd_count;
756} vc_map; 705} vc_map;
757 706
758 707typedef struct ns_dev {
759struct ns_skb_data 708 int index; /* Card ID to the device driver */
760{ 709 int sram_size; /* In k x 32bit words. 32 or 128 */
761 struct atm_vcc *vcc; 710 void __iomem *membase; /* Card's memory base address */
762 int iovcnt; 711 unsigned long max_pcr;
763}; 712 int rct_size; /* Number of entries */
764 713 int vpibits;
765#define NS_SKB(skb) (((struct ns_skb_data *) (skb)->cb)) 714 int vcibits;
766 715 struct pci_dev *pcidev;
767 716 struct idr idr;
768typedef struct ns_dev 717 struct atm_dev *atmdev;
769{ 718 tsq_info tsq;
770 int index; /* Card ID to the device driver */ 719 rsq_info rsq;
771 int sram_size; /* In k x 32bit words. 32 or 128 */ 720 scq_info *scq0, *scq1, *scq2; /* VBR SCQs */
772 void __iomem *membase; /* Card's memory base address */ 721 skb_pool sbpool; /* Small buffers */
773 unsigned long max_pcr; 722 skb_pool lbpool; /* Large buffers */
774 int rct_size; /* Number of entries */ 723 skb_pool hbpool; /* Pre-allocated huge buffers */
775 int vpibits; 724 skb_pool iovpool; /* iovector buffers */
776 int vcibits; 725 volatile int efbie; /* Empty free buf. queue int. enabled */
777 struct pci_dev *pcidev; 726 volatile u32 tst_addr; /* SRAM address of the TST in use */
778 struct atm_dev *atmdev; 727 volatile int tst_free_entries;
779 tsq_info tsq; 728 vc_map vcmap[NS_MAX_RCTSIZE];
780 rsq_info rsq; 729 vc_map *tste2vc[NS_TST_NUM_ENTRIES];
781 scq_info *scq0, *scq1, *scq2; /* VBR SCQs */ 730 vc_map *scd2vc[NS_FRSCD_NUM];
782 skb_pool sbpool; /* Small buffers */ 731 buf_nr sbnr;
783 skb_pool lbpool; /* Large buffers */ 732 buf_nr lbnr;
784 skb_pool hbpool; /* Pre-allocated huge buffers */ 733 buf_nr hbnr;
785 skb_pool iovpool; /* iovector buffers */ 734 buf_nr iovnr;
786 volatile int efbie; /* Empty free buf. queue int. enabled */ 735 int sbfqc;
787 volatile u32 tst_addr; /* SRAM address of the TST in use */ 736 int lbfqc;
788 volatile int tst_free_entries; 737 struct sk_buff *sm_handle;
789 vc_map vcmap[NS_MAX_RCTSIZE]; 738 u32 sm_addr;
790 vc_map *tste2vc[NS_TST_NUM_ENTRIES]; 739 struct sk_buff *lg_handle;
791 vc_map *scd2vc[NS_FRSCD_NUM]; 740 u32 lg_addr;
792 buf_nr sbnr; 741 struct sk_buff *rcbuf; /* Current raw cell buffer */
793 buf_nr lbnr; 742 struct ns_rcqe *rawcell;
794 buf_nr hbnr; 743 u32 rawch; /* Raw cell queue head */
795 buf_nr iovnr; 744 unsigned intcnt; /* Interrupt counter */
796 int sbfqc; 745 spinlock_t int_lock; /* Interrupt lock */
797 int lbfqc; 746 spinlock_t res_lock; /* Card resource lock */
798 u32 sm_handle;
799 u32 sm_addr;
800 u32 lg_handle;
801 u32 lg_addr;
802 struct sk_buff *rcbuf; /* Current raw cell buffer */
803 u32 rawch; /* Raw cell queue head */
804 unsigned intcnt; /* Interrupt counter */
805 spinlock_t int_lock; /* Interrupt lock */
806 spinlock_t res_lock; /* Card resource lock */
807} ns_dev; 747} ns_dev;
808 748
809
810 /* NOTE: Each tste2vc entry relates a given TST entry to the corresponding 749 /* NOTE: Each tste2vc entry relates a given TST entry to the corresponding
811 CBR vc. If the entry is not allocated, it must be NULL. 750 CBR vc. If the entry is not allocated, it must be NULL.
812 751
813 There are two TSTs so the driver can modify them on the fly 752 There are two TSTs so the driver can modify them on the fly
814 without stopping the transmission. 753 without stopping the transmission.
815
816 scd2vc allows us to find out unused fixed rate SCDs, because
817 they must have a NULL pointer here. */
818 754
755 scd2vc allows us to find out unused fixed rate SCDs, because
756 they must have a NULL pointer here. */
819 757
820#endif /* _LINUX_NICSTAR_H_ */ 758#endif /* _LINUX_NICSTAR_H_ */