Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * nicstar.h
0004  *
0005  * Header file for the nicstar device driver.
0006  *
0007  * Author: Rui Prior (rprior@inescn.pt)
0008  * PowerPC support by Jay Talbott (jay_talbott@mcg.mot.com) April 1999
0009  *
0010  * (C) INESC 1998
0011  */
0012 
0013 #ifndef _LINUX_NICSTAR_H_
0014 #define _LINUX_NICSTAR_H_
0015 
0016 /* Includes */
0017 
0018 #include <linux/types.h>
0019 #include <linux/pci.h>
0020 #include <linux/idr.h>
0021 #include <linux/uio.h>
0022 #include <linux/skbuff.h>
0023 #include <linux/atmdev.h>
0024 #include <linux/atm_nicstar.h>
0025 
0026 /* Options */
0027 
0028 #define NS_MAX_CARDS 4      /* Maximum number of NICStAR based cards
0029                    controlled by the device driver. Must
0030                    be <= 5 */
0031 
0032 #undef RCQ_SUPPORT      /* Do not define this for now */
0033 
0034 #define NS_TST_NUM_ENTRIES 2340 /* + 1 for return */
0035 #define NS_TST_RESERVED 340 /* N. entries reserved for UBR/ABR/VBR */
0036 
0037 #define NS_SMBUFSIZE 48     /* 48, 96, 240 or 2048 */
0038 #define NS_LGBUFSIZE 16384  /* 2048, 4096, 8192 or 16384 */
0039 #define NS_RSQSIZE 8192     /* 2048, 4096 or 8192 */
0040 #define NS_VPIBITS 2        /* 0, 1, 2, or 8 */
0041 
0042 #define NS_MAX_RCTSIZE 4096 /* Number of entries. 4096 or 16384.
0043                    Define 4096 only if (all) your card(s)
0044                    have 32K x 32bit SRAM, in which case
0045                    setting this to 16384 will just waste a
0046                    lot of memory.
0047                    Setting this to 4096 for a card with
0048                    128K x 32bit SRAM will limit the maximum
0049                    VCI. */
0050 
0051                 /*#define NS_PCI_LATENCY 64*//* Must be a multiple of 32 */
0052 
0053     /* Number of buffers initially allocated */
0054 #define NUM_SB 32       /* Must be even */
0055 #define NUM_LB 24       /* Must be even */
0056 #define NUM_HB 8        /* Pre-allocated huge buffers */
0057 #define NUM_IOVB 48     /* Iovec buffers */
0058 
0059     /* Lower level for count of buffers */
0060 #define MIN_SB 8        /* Must be even */
0061 #define MIN_LB 8        /* Must be even */
0062 #define MIN_HB 6
0063 #define MIN_IOVB 8
0064 
0065     /* Upper level for count of buffers */
0066 #define MAX_SB 64       /* Must be even, <= 508 */
0067 #define MAX_LB 48       /* Must be even, <= 508 */
0068 #define MAX_HB 10
0069 #define MAX_IOVB 80
0070 
0071     /* These are the absolute maximum allowed for the ioctl() */
0072 #define TOP_SB 256      /* Must be even, <= 508 */
0073 #define TOP_LB 128      /* Must be even, <= 508 */
0074 #define TOP_HB 64
0075 #define TOP_IOVB 256
0076 
0077 #define MAX_TBD_PER_VC 1    /* Number of TBDs before a TSR */
0078 #define MAX_TBD_PER_SCQ 10  /* Only meaningful for variable rate SCQs */
0079 
0080 #undef ENABLE_TSQFIE
0081 
0082 #define SCQFULL_TIMEOUT (5 * HZ)
0083 
0084 #define NS_POLL_PERIOD (HZ)
0085 
0086 #define PCR_TOLERANCE (1.0001)
0087 
0088 /* ESI stuff */
0089 
0090 #define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C
0091 #define NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT 0xF6
0092 
0093 /* #defines */
0094 
0095 #define NS_IOREMAP_SIZE 4096
0096 
0097 /*
0098  * BUF_XX distinguish the Rx buffers depending on their (small/large) size.
0099  * BUG_SM and BUG_LG are both used by the driver and the device.
0100  * BUF_NONE is only used by the driver.
0101  */
0102 #define BUF_SM      0x00000000  /* These two are used for push_rxbufs() */
0103 #define BUF_LG      0x00000001  /* CMD, Write_FreeBufQ, LBUF bit */
0104 #define BUF_NONE    0xffffffff  /* Software only: */
0105 
0106 #define NS_HBUFSIZE 65568   /* Size of max. AAL5 PDU */
0107 #define NS_MAX_IOVECS (2 + (65568 - NS_SMBUFSIZE) / \
0108                        (NS_LGBUFSIZE - (NS_LGBUFSIZE % 48)))
0109 #define NS_IOVBUFSIZE (NS_MAX_IOVECS * (sizeof(struct iovec)))
0110 
0111 #define NS_SMBUFSIZE_USABLE (NS_SMBUFSIZE - NS_SMBUFSIZE % 48)
0112 #define NS_LGBUFSIZE_USABLE (NS_LGBUFSIZE - NS_LGBUFSIZE % 48)
0113 
0114 #define NS_AAL0_HEADER (ATM_AAL0_SDU - ATM_CELL_PAYLOAD)    /* 4 bytes */
0115 
0116 #define NS_SMSKBSIZE (NS_SMBUFSIZE + NS_AAL0_HEADER)
0117 #define NS_LGSKBSIZE (NS_SMBUFSIZE + NS_LGBUFSIZE)
0118 
0119 /* NICStAR structures located in host memory */
0120 
0121 /*
0122  * RSQ - Receive Status Queue
0123  *
0124  * Written by the NICStAR, read by the device driver.
0125  */
0126 
0127 typedef struct ns_rsqe {
0128     u32 word_1;
0129     u32 buffer_handle;
0130     u32 final_aal5_crc32;
0131     u32 word_4;
0132 } ns_rsqe;
0133 
0134 #define ns_rsqe_vpi(ns_rsqep) \
0135         ((le32_to_cpu((ns_rsqep)->word_1) & 0x00FF0000) >> 16)
0136 #define ns_rsqe_vci(ns_rsqep) \
0137         (le32_to_cpu((ns_rsqep)->word_1) & 0x0000FFFF)
0138 
0139 #define NS_RSQE_VALID      0x80000000
0140 #define NS_RSQE_NZGFC      0x00004000
0141 #define NS_RSQE_EOPDU      0x00002000
0142 #define NS_RSQE_BUFSIZE    0x00001000
0143 #define NS_RSQE_CONGESTION 0x00000800
0144 #define NS_RSQE_CLP        0x00000400
0145 #define NS_RSQE_CRCERR     0x00000200
0146 
0147 #define NS_RSQE_BUFSIZE_SM 0x00000000
0148 #define NS_RSQE_BUFSIZE_LG 0x00001000
0149 
0150 #define ns_rsqe_valid(ns_rsqep) \
0151         (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_VALID)
0152 #define ns_rsqe_nzgfc(ns_rsqep) \
0153         (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_NZGFC)
0154 #define ns_rsqe_eopdu(ns_rsqep) \
0155         (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_EOPDU)
0156 #define ns_rsqe_bufsize(ns_rsqep) \
0157         (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_BUFSIZE)
0158 #define ns_rsqe_congestion(ns_rsqep) \
0159         (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CONGESTION)
0160 #define ns_rsqe_clp(ns_rsqep) \
0161         (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CLP)
0162 #define ns_rsqe_crcerr(ns_rsqep) \
0163         (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CRCERR)
0164 
0165 #define ns_rsqe_cellcount(ns_rsqep) \
0166         (le32_to_cpu((ns_rsqep)->word_4) & 0x000001FF)
0167 #define ns_rsqe_init(ns_rsqep) \
0168         ((ns_rsqep)->word_4 = cpu_to_le32(0x00000000))
0169 
0170 #define NS_RSQ_NUM_ENTRIES (NS_RSQSIZE / 16)
0171 #define NS_RSQ_ALIGNMENT NS_RSQSIZE
0172 
0173 /*
0174  * RCQ - Raw Cell Queue
0175  *
0176  * Written by the NICStAR, read by the device driver.
0177  */
0178 
0179 typedef struct cell_payload {
0180     u32 word[12];
0181 } cell_payload;
0182 
0183 typedef struct ns_rcqe {
0184     u32 word_1;
0185     u32 word_2;
0186     u32 word_3;
0187     u32 word_4;
0188     cell_payload payload;
0189 } ns_rcqe;
0190 
0191 #define NS_RCQE_SIZE 64     /* bytes */
0192 
0193 #define ns_rcqe_islast(ns_rcqep) \
0194         (le32_to_cpu((ns_rcqep)->word_2) != 0x00000000)
0195 #define ns_rcqe_cellheader(ns_rcqep) \
0196         (le32_to_cpu((ns_rcqep)->word_1))
0197 #define ns_rcqe_nextbufhandle(ns_rcqep) \
0198         (le32_to_cpu((ns_rcqep)->word_2))
0199 
0200 /*
0201  * SCQ - Segmentation Channel Queue
0202  *
0203  * Written by the device driver, read by the NICStAR.
0204  */
0205 
0206 typedef struct ns_scqe {
0207     u32 word_1;
0208     u32 word_2;
0209     u32 word_3;
0210     u32 word_4;
0211 } ns_scqe;
0212 
0213    /* NOTE: SCQ entries can be either a TBD (Transmit Buffer Descriptors)
0214       or TSR (Transmit Status Requests) */
0215 
0216 #define NS_SCQE_TYPE_TBD 0x00000000
0217 #define NS_SCQE_TYPE_TSR 0x80000000
0218 
0219 #define NS_TBD_EOPDU 0x40000000
0220 #define NS_TBD_AAL0  0x00000000
0221 #define NS_TBD_AAL34 0x04000000
0222 #define NS_TBD_AAL5  0x08000000
0223 
0224 #define NS_TBD_VPI_MASK 0x0FF00000
0225 #define NS_TBD_VCI_MASK 0x000FFFF0
0226 #define NS_TBD_VC_MASK (NS_TBD_VPI_MASK | NS_TBD_VCI_MASK)
0227 
0228 #define NS_TBD_VPI_SHIFT 20
0229 #define NS_TBD_VCI_SHIFT 4
0230 
0231 #define ns_tbd_mkword_1(flags, m, n, buflen) \
0232       (cpu_to_le32((flags) | (m) << 23 | (n) << 16 | (buflen)))
0233 #define ns_tbd_mkword_1_novbr(flags, buflen) \
0234       (cpu_to_le32((flags) | (buflen) | 0x00810000))
0235 #define ns_tbd_mkword_3(control, pdulen) \
0236       (cpu_to_le32((control) << 16 | (pdulen)))
0237 #define ns_tbd_mkword_4(gfc, vpi, vci, pt, clp) \
0238       (cpu_to_le32((gfc) << 28 | (vpi) << 20 | (vci) << 4 | (pt) << 1 | (clp)))
0239 
0240 #define NS_TSR_INTENABLE 0x20000000
0241 
0242 #define NS_TSR_SCDISVBR 0xFFFF  /* Use as scdi for VBR SCD */
0243 
0244 #define ns_tsr_mkword_1(flags) \
0245         (cpu_to_le32(NS_SCQE_TYPE_TSR | (flags)))
0246 #define ns_tsr_mkword_2(scdi, scqi) \
0247         (cpu_to_le32((scdi) << 16 | 0x00008000 | (scqi)))
0248 
0249 #define ns_scqe_is_tsr(ns_scqep) \
0250         (le32_to_cpu((ns_scqep)->word_1) & NS_SCQE_TYPE_TSR)
0251 
0252 #define VBR_SCQ_NUM_ENTRIES 512
0253 #define VBR_SCQSIZE 8192
0254 #define CBR_SCQ_NUM_ENTRIES 64
0255 #define CBR_SCQSIZE 1024
0256 
0257 #define NS_SCQE_SIZE 16
0258 
0259 /*
0260  * TSQ - Transmit Status Queue
0261  *
0262  * Written by the NICStAR, read by the device driver.
0263  */
0264 
0265 typedef struct ns_tsi {
0266     u32 word_1;
0267     u32 word_2;
0268 } ns_tsi;
0269 
0270    /* NOTE: The first word can be a status word copied from the TSR which
0271       originated the TSI, or a timer overflow indicator. In this last
0272       case, the value of the first word is all zeroes. */
0273 
0274 #define NS_TSI_EMPTY          0x80000000
0275 #define NS_TSI_TIMESTAMP_MASK 0x00FFFFFF
0276 
0277 #define ns_tsi_isempty(ns_tsip) \
0278         (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_EMPTY)
0279 #define ns_tsi_gettimestamp(ns_tsip) \
0280         (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_TIMESTAMP_MASK)
0281 
0282 #define ns_tsi_init(ns_tsip) \
0283         ((ns_tsip)->word_2 = cpu_to_le32(NS_TSI_EMPTY))
0284 
0285 #define NS_TSQSIZE 8192
0286 #define NS_TSQ_NUM_ENTRIES 1024
0287 #define NS_TSQ_ALIGNMENT 8192
0288 
0289 #define NS_TSI_SCDISVBR NS_TSR_SCDISVBR
0290 
0291 #define ns_tsi_tmrof(ns_tsip) \
0292         (le32_to_cpu((ns_tsip)->word_1) == 0x00000000)
0293 #define ns_tsi_getscdindex(ns_tsip) \
0294         ((le32_to_cpu((ns_tsip)->word_1) & 0xFFFF0000) >> 16)
0295 #define ns_tsi_getscqpos(ns_tsip) \
0296         (le32_to_cpu((ns_tsip)->word_1) & 0x00007FFF)
0297 
0298 /* NICStAR structures located in local SRAM */
0299 
0300 /*
0301  * RCT - Receive Connection Table
0302  *
0303  * Written by both the NICStAR and the device driver.
0304  */
0305 
0306 typedef struct ns_rcte {
0307     u32 word_1;
0308     u32 buffer_handle;
0309     u32 dma_address;
0310     u32 aal5_crc32;
0311 } ns_rcte;
0312 
0313 #define NS_RCTE_BSFB            0x00200000  /* Rev. D only */
0314 #define NS_RCTE_NZGFC           0x00100000
0315 #define NS_RCTE_CONNECTOPEN     0x00080000
0316 #define NS_RCTE_AALMASK         0x00070000
0317 #define NS_RCTE_AAL0            0x00000000
0318 #define NS_RCTE_AAL34           0x00010000
0319 #define NS_RCTE_AAL5            0x00020000
0320 #define NS_RCTE_RCQ             0x00030000
0321 #define NS_RCTE_RAWCELLINTEN    0x00008000
0322 #define NS_RCTE_RXCONSTCELLADDR 0x00004000
0323 #define NS_RCTE_BUFFVALID       0x00002000
0324 #define NS_RCTE_FBDSIZE         0x00001000
0325 #define NS_RCTE_EFCI            0x00000800
0326 #define NS_RCTE_CLP             0x00000400
0327 #define NS_RCTE_CRCERROR        0x00000200
0328 #define NS_RCTE_CELLCOUNT_MASK  0x000001FF
0329 
0330 #define NS_RCTE_FBDSIZE_SM 0x00000000
0331 #define NS_RCTE_FBDSIZE_LG 0x00001000
0332 
0333 #define NS_RCT_ENTRY_SIZE 4 /* Number of dwords */
0334 
0335    /* NOTE: We could make macros to contruct the first word of the RCTE,
0336       but that doesn't seem to make much sense... */
0337 
0338 /*
0339  * FBD - Free Buffer Descriptor
0340  *
0341  * Written by the device driver using via the command register.
0342  */
0343 
0344 typedef struct ns_fbd {
0345     u32 buffer_handle;
0346     u32 dma_address;
0347 } ns_fbd;
0348 
0349 /*
0350  * TST - Transmit Schedule Table
0351  *
0352  * Written by the device driver.
0353  */
0354 
0355 typedef u32 ns_tste;
0356 
0357 #define NS_TST_OPCODE_MASK 0x60000000
0358 
0359 #define NS_TST_OPCODE_NULL     0x00000000   /* Insert null cell */
0360 #define NS_TST_OPCODE_FIXED    0x20000000   /* Cell from a fixed rate channel */
0361 #define NS_TST_OPCODE_VARIABLE 0x40000000
0362 #define NS_TST_OPCODE_END      0x60000000   /* Jump */
0363 
0364 #define ns_tste_make(opcode, sramad) (opcode | sramad)
0365 
0366    /* NOTE:
0367 
0368       - When the opcode is FIXED, sramad specifies the SRAM address of the
0369       SCD for that fixed rate channel.
0370       - When the opcode is END, sramad specifies the SRAM address of the
0371       location of the next TST entry to read.
0372     */
0373 
0374 /*
0375  * SCD - Segmentation Channel Descriptor
0376  *
0377  * Written by both the device driver and the NICStAR
0378  */
0379 
0380 typedef struct ns_scd {
0381     u32 word_1;
0382     u32 word_2;
0383     u32 partial_aal5_crc;
0384     u32 reserved;
0385     ns_scqe cache_a;
0386     ns_scqe cache_b;
0387 } ns_scd;
0388 
0389 #define NS_SCD_BASE_MASK_VAR 0xFFFFE000 /* Variable rate */
0390 #define NS_SCD_BASE_MASK_FIX 0xFFFFFC00 /* Fixed rate */
0391 #define NS_SCD_TAIL_MASK_VAR 0x00001FF0
0392 #define NS_SCD_TAIL_MASK_FIX 0x000003F0
0393 #define NS_SCD_HEAD_MASK_VAR 0x00001FF0
0394 #define NS_SCD_HEAD_MASK_FIX 0x000003F0
0395 #define NS_SCD_XMITFOREVER   0x02000000
0396 
0397    /* NOTE: There are other fields in word 2 of the SCD, but as they should
0398       not be needed in the device driver they are not defined here. */
0399 
0400 /* NICStAR local SRAM memory map */
0401 
0402 #define NS_RCT           0x00000
0403 #define NS_RCT_32_END    0x03FFF
0404 #define NS_RCT_128_END   0x0FFFF
0405 #define NS_UNUSED_32     0x04000
0406 #define NS_UNUSED_128    0x10000
0407 #define NS_UNUSED_END    0x1BFFF
0408 #define NS_TST_FRSCD     0x1C000
0409 #define NS_TST_FRSCD_END 0x1E7DB
0410 #define NS_VRSCD2        0x1E7DC
0411 #define NS_VRSCD2_END    0x1E7E7
0412 #define NS_VRSCD1        0x1E7E8
0413 #define NS_VRSCD1_END    0x1E7F3
0414 #define NS_VRSCD0        0x1E7F4
0415 #define NS_VRSCD0_END    0x1E7FF
0416 #define NS_RXFIFO        0x1E800
0417 #define NS_RXFIFO_END    0x1F7FF
0418 #define NS_SMFBQ         0x1F800
0419 #define NS_SMFBQ_END     0x1FBFF
0420 #define NS_LGFBQ         0x1FC00
0421 #define NS_LGFBQ_END     0x1FFFF
0422 
0423 /* NISCtAR operation registers */
0424 
0425 /* See Section 3.4 of `IDT77211 NICStAR User Manual' from www.idt.com */
0426 
0427 enum ns_regs {
0428     DR0 = 0x00,     /* Data Register 0 R/W */
0429     DR1 = 0x04,     /* Data Register 1 W */
0430     DR2 = 0x08,     /* Data Register 2 W */
0431     DR3 = 0x0C,     /* Data Register 3 W */
0432     CMD = 0x10,     /* Command W */
0433     CFG = 0x14,     /* Configuration R/W */
0434     STAT = 0x18,        /* Status R/W */
0435     RSQB = 0x1C,        /* Receive Status Queue Base W */
0436     RSQT = 0x20,        /* Receive Status Queue Tail R */
0437     RSQH = 0x24,        /* Receive Status Queue Head W */
0438     CDC = 0x28,     /* Cell Drop Counter R/clear */
0439     VPEC = 0x2C,        /* VPI/VCI Lookup Error Count R/clear */
0440     ICC = 0x30,     /* Invalid Cell Count R/clear */
0441     RAWCT = 0x34,       /* Raw Cell Tail R */
0442     TMR = 0x38,     /* Timer R */
0443     TSTB = 0x3C,        /* Transmit Schedule Table Base R/W */
0444     TSQB = 0x40,        /* Transmit Status Queue Base W */
0445     TSQT = 0x44,        /* Transmit Status Queue Tail R */
0446     TSQH = 0x48,        /* Transmit Status Queue Head W */
0447     GP = 0x4C,      /* General Purpose R/W */
0448     VPM = 0x50      /* VPI/VCI Mask W */
0449 };
0450 
0451 /* NICStAR commands issued to the CMD register */
0452 
0453 /* Top 4 bits are command opcode, lower 28 are parameters. */
0454 
0455 #define NS_CMD_NO_OPERATION         0x00000000
0456     /* params always 0 */
0457 
0458 #define NS_CMD_OPENCLOSE_CONNECTION 0x20000000
0459     /* b19{1=open,0=close} b18-2{SRAM addr} */
0460 
0461 #define NS_CMD_WRITE_SRAM           0x40000000
0462     /* b18-2{SRAM addr} b1-0{burst size} */
0463 
0464 #define NS_CMD_READ_SRAM            0x50000000
0465     /* b18-2{SRAM addr} */
0466 
0467 #define NS_CMD_WRITE_FREEBUFQ       0x60000000
0468     /* b0{large buf indicator} */
0469 
0470 #define NS_CMD_READ_UTILITY         0x80000000
0471     /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
0472 
0473 #define NS_CMD_WRITE_UTILITY        0x90000000
0474     /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
0475 
0476 #define NS_CMD_OPEN_CONNECTION (NS_CMD_OPENCLOSE_CONNECTION | 0x00080000)
0477 #define NS_CMD_CLOSE_CONNECTION NS_CMD_OPENCLOSE_CONNECTION
0478 
0479 /* NICStAR configuration bits */
0480 
0481 #define NS_CFG_SWRST          0x80000000    /* Software Reset */
0482 #define NS_CFG_RXPATH         0x20000000    /* Receive Path Enable */
0483 #define NS_CFG_SMBUFSIZE_MASK 0x18000000    /* Small Receive Buffer Size */
0484 #define NS_CFG_LGBUFSIZE_MASK 0x06000000    /* Large Receive Buffer Size */
0485 #define NS_CFG_EFBIE          0x01000000    /* Empty Free Buffer Queue
0486                            Interrupt Enable */
0487 #define NS_CFG_RSQSIZE_MASK   0x00C00000    /* Receive Status Queue Size */
0488 #define NS_CFG_ICACCEPT       0x00200000    /* Invalid Cell Accept */
0489 #define NS_CFG_IGNOREGFC      0x00100000    /* Ignore General Flow Control */
0490 #define NS_CFG_VPIBITS_MASK   0x000C0000    /* VPI/VCI Bits Size Select */
0491 #define NS_CFG_RCTSIZE_MASK   0x00030000    /* Receive Connection Table Size */
0492 #define NS_CFG_VCERRACCEPT    0x00008000    /* VPI/VCI Error Cell Accept */
0493 #define NS_CFG_RXINT_MASK     0x00007000    /* End of Receive PDU Interrupt
0494                            Handling */
0495 #define NS_CFG_RAWIE          0x00000800    /* Raw Cell Qu' Interrupt Enable */
0496 #define NS_CFG_RSQAFIE        0x00000400    /* Receive Queue Almost Full
0497                            Interrupt Enable */
0498 #define NS_CFG_RXRM           0x00000200    /* Receive RM Cells */
0499 #define NS_CFG_TMRROIE        0x00000080    /* Timer Roll Over Interrupt
0500                            Enable */
0501 #define NS_CFG_TXEN           0x00000020    /* Transmit Operation Enable */
0502 #define NS_CFG_TXIE           0x00000010    /* Transmit Status Interrupt
0503                            Enable */
0504 #define NS_CFG_TXURIE         0x00000008    /* Transmit Under-run Interrupt
0505                            Enable */
0506 #define NS_CFG_UMODE          0x00000004    /* Utopia Mode (cell/byte) Select */
0507 #define NS_CFG_TSQFIE         0x00000002    /* Transmit Status Queue Full
0508                            Interrupt Enable */
0509 #define NS_CFG_PHYIE          0x00000001    /* PHY Interrupt Enable */
0510 
0511 #define NS_CFG_SMBUFSIZE_48    0x00000000
0512 #define NS_CFG_SMBUFSIZE_96    0x08000000
0513 #define NS_CFG_SMBUFSIZE_240   0x10000000
0514 #define NS_CFG_SMBUFSIZE_2048  0x18000000
0515 
0516 #define NS_CFG_LGBUFSIZE_2048  0x00000000
0517 #define NS_CFG_LGBUFSIZE_4096  0x02000000
0518 #define NS_CFG_LGBUFSIZE_8192  0x04000000
0519 #define NS_CFG_LGBUFSIZE_16384 0x06000000
0520 
0521 #define NS_CFG_RSQSIZE_2048 0x00000000
0522 #define NS_CFG_RSQSIZE_4096 0x00400000
0523 #define NS_CFG_RSQSIZE_8192 0x00800000
0524 
0525 #define NS_CFG_VPIBITS_0 0x00000000
0526 #define NS_CFG_VPIBITS_1 0x00040000
0527 #define NS_CFG_VPIBITS_2 0x00080000
0528 #define NS_CFG_VPIBITS_8 0x000C0000
0529 
0530 #define NS_CFG_RCTSIZE_4096_ENTRIES  0x00000000
0531 #define NS_CFG_RCTSIZE_8192_ENTRIES  0x00010000
0532 #define NS_CFG_RCTSIZE_16384_ENTRIES 0x00020000
0533 
0534 #define NS_CFG_RXINT_NOINT   0x00000000
0535 #define NS_CFG_RXINT_NODELAY 0x00001000
0536 #define NS_CFG_RXINT_314US   0x00002000
0537 #define NS_CFG_RXINT_624US   0x00003000
0538 #define NS_CFG_RXINT_899US   0x00004000
0539 
0540 /* NICStAR STATus bits */
0541 
0542 #define NS_STAT_SFBQC_MASK 0xFF000000   /* hi 8 bits Small Buffer Queue Count */
0543 #define NS_STAT_LFBQC_MASK 0x00FF0000   /* hi 8 bits Large Buffer Queue Count */
0544 #define NS_STAT_TSIF       0x00008000   /* Transmit Status Queue Indicator */
0545 #define NS_STAT_TXICP      0x00004000   /* Transmit Incomplete PDU */
0546 #define NS_STAT_TSQF       0x00001000   /* Transmit Status Queue Full */
0547 #define NS_STAT_TMROF      0x00000800   /* Timer Overflow */
0548 #define NS_STAT_PHYI       0x00000400   /* PHY Device Interrupt */
0549 #define NS_STAT_CMDBZ      0x00000200   /* Command Busy */
0550 #define NS_STAT_SFBQF      0x00000100   /* Small Buffer Queue Full */
0551 #define NS_STAT_LFBQF      0x00000080   /* Large Buffer Queue Full */
0552 #define NS_STAT_RSQF       0x00000040   /* Receive Status Queue Full */
0553 #define NS_STAT_EOPDU      0x00000020   /* End of PDU */
0554 #define NS_STAT_RAWCF      0x00000010   /* Raw Cell Flag */
0555 #define NS_STAT_SFBQE      0x00000008   /* Small Buffer Queue Empty */
0556 #define NS_STAT_LFBQE      0x00000004   /* Large Buffer Queue Empty */
0557 #define NS_STAT_RSQAF      0x00000002   /* Receive Status Queue Almost Full */
0558 
0559 #define ns_stat_sfbqc_get(stat) (((stat) & NS_STAT_SFBQC_MASK) >> 23)
0560 #define ns_stat_lfbqc_get(stat) (((stat) & NS_STAT_LFBQC_MASK) >> 15)
0561 
0562 /* #defines which depend on other #defines */
0563 
0564 #define NS_TST0 NS_TST_FRSCD
0565 #define NS_TST1 (NS_TST_FRSCD + NS_TST_NUM_ENTRIES + 1)
0566 
0567 #define NS_FRSCD (NS_TST1 + NS_TST_NUM_ENTRIES + 1)
0568 #define NS_FRSCD_SIZE 12    /* 12 dwords */
0569 #define NS_FRSCD_NUM ((NS_TST_FRSCD_END + 1 - NS_FRSCD) / NS_FRSCD_SIZE)
0570 
0571 #if (NS_SMBUFSIZE == 48)
0572 #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_48
0573 #elif (NS_SMBUFSIZE == 96)
0574 #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_96
0575 #elif (NS_SMBUFSIZE == 240)
0576 #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_240
0577 #elif (NS_SMBUFSIZE == 2048)
0578 #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_2048
0579 #else
0580 #error NS_SMBUFSIZE is incorrect in nicstar.h
0581 #endif /* NS_SMBUFSIZE */
0582 
0583 #if (NS_LGBUFSIZE == 2048)
0584 #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_2048
0585 #elif (NS_LGBUFSIZE == 4096)
0586 #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_4096
0587 #elif (NS_LGBUFSIZE == 8192)
0588 #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_8192
0589 #elif (NS_LGBUFSIZE == 16384)
0590 #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_16384
0591 #else
0592 #error NS_LGBUFSIZE is incorrect in nicstar.h
0593 #endif /* NS_LGBUFSIZE */
0594 
0595 #if (NS_RSQSIZE == 2048)
0596 #define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_2048
0597 #elif (NS_RSQSIZE == 4096)
0598 #define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_4096
0599 #elif (NS_RSQSIZE == 8192)
0600 #define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_8192
0601 #else
0602 #error NS_RSQSIZE is incorrect in nicstar.h
0603 #endif /* NS_RSQSIZE */
0604 
0605 #if (NS_VPIBITS == 0)
0606 #define NS_CFG_VPIBITS NS_CFG_VPIBITS_0
0607 #elif (NS_VPIBITS == 1)
0608 #define NS_CFG_VPIBITS NS_CFG_VPIBITS_1
0609 #elif (NS_VPIBITS == 2)
0610 #define NS_CFG_VPIBITS NS_CFG_VPIBITS_2
0611 #elif (NS_VPIBITS == 8)
0612 #define NS_CFG_VPIBITS NS_CFG_VPIBITS_8
0613 #else
0614 #error NS_VPIBITS is incorrect in nicstar.h
0615 #endif /* NS_VPIBITS */
0616 
0617 #ifdef RCQ_SUPPORT
0618 #define NS_CFG_RAWIE_OPT NS_CFG_RAWIE
0619 #else
0620 #define NS_CFG_RAWIE_OPT 0x00000000
0621 #endif /* RCQ_SUPPORT */
0622 
0623 #ifdef ENABLE_TSQFIE
0624 #define NS_CFG_TSQFIE_OPT NS_CFG_TSQFIE
0625 #else
0626 #define NS_CFG_TSQFIE_OPT 0x00000000
0627 #endif /* ENABLE_TSQFIE */
0628 
0629 /* PCI stuff */
0630 
0631 #ifndef PCI_VENDOR_ID_IDT
0632 #define PCI_VENDOR_ID_IDT 0x111D
0633 #endif /* PCI_VENDOR_ID_IDT */
0634 
0635 #ifndef PCI_DEVICE_ID_IDT_IDT77201
0636 #define PCI_DEVICE_ID_IDT_IDT77201 0x0001
0637 #endif /* PCI_DEVICE_ID_IDT_IDT77201 */
0638 
0639 /* Device driver structures */
0640 
0641 struct ns_skb_prv {
0642     u32 buf_type;       /* BUF_SM/BUF_LG/BUF_NONE */
0643     u32 dma;
0644     int iovcnt;
0645 };
0646 
0647 #define NS_PRV_BUFTYPE(skb)   \
0648         (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->buf_type)
0649 #define NS_PRV_DMA(skb) \
0650         (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->dma)
0651 #define NS_PRV_IOVCNT(skb) \
0652         (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->iovcnt)
0653 
0654 typedef struct tsq_info {
0655     void *org;
0656         dma_addr_t dma;
0657     ns_tsi *base;
0658     ns_tsi *next;
0659     ns_tsi *last;
0660 } tsq_info;
0661 
0662 typedef struct scq_info {
0663     void *org;
0664     dma_addr_t dma;
0665     ns_scqe *base;
0666     ns_scqe *last;
0667     ns_scqe *next;
0668     volatile ns_scqe *tail; /* Not related to the nicstar register */
0669     unsigned num_entries;
0670     struct sk_buff **skb;   /* Pointer to an array of pointers
0671                    to the sk_buffs used for tx */
0672     u32 scd;        /* SRAM address of the corresponding
0673                    SCD */
0674     int tbd_count;      /* Only meaningful on variable rate */
0675     wait_queue_head_t scqfull_waitq;
0676     volatile char full; /* SCQ full indicator */
0677     spinlock_t lock;    /* SCQ spinlock */
0678 } scq_info;
0679 
0680 typedef struct rsq_info {
0681     void *org;
0682         dma_addr_t dma;
0683     ns_rsqe *base;
0684     ns_rsqe *next;
0685     ns_rsqe *last;
0686 } rsq_info;
0687 
0688 typedef struct skb_pool {
0689     volatile int count; /* number of buffers in the queue */
0690     struct sk_buff_head queue;
0691 } skb_pool;
0692 
0693 /* NOTE: for small and large buffer pools, the count is not used, as the
0694          actual value used for buffer management is the one read from the
0695      card. */
0696 
0697 typedef struct vc_map {
0698     volatile unsigned int tx:1; /* TX vc? */
0699     volatile unsigned int rx:1; /* RX vc? */
0700     struct atm_vcc *tx_vcc, *rx_vcc;
0701     struct sk_buff *rx_iov; /* RX iovector skb */
0702     scq_info *scq;      /* To keep track of the SCQ */
0703     u32 cbr_scd;        /* SRAM address of the corresponding
0704                    SCD. 0x00000000 for UBR/VBR/ABR */
0705     int tbd_count;
0706 } vc_map;
0707 
0708 typedef struct ns_dev {
0709     int index;      /* Card ID to the device driver */
0710     int sram_size;      /* In k x 32bit words. 32 or 128 */
0711     void __iomem *membase;  /* Card's memory base address */
0712     unsigned long max_pcr;
0713     int rct_size;       /* Number of entries */
0714     int vpibits;
0715     int vcibits;
0716     struct pci_dev *pcidev;
0717     struct idr idr;
0718     struct atm_dev *atmdev;
0719     tsq_info tsq;
0720     rsq_info rsq;
0721     scq_info *scq0, *scq1, *scq2;   /* VBR SCQs */
0722     skb_pool sbpool;    /* Small buffers */
0723     skb_pool lbpool;    /* Large buffers */
0724     skb_pool hbpool;    /* Pre-allocated huge buffers */
0725     skb_pool iovpool;   /* iovector buffers */
0726     volatile int efbie; /* Empty free buf. queue int. enabled */
0727     volatile u32 tst_addr;  /* SRAM address of the TST in use */
0728     volatile int tst_free_entries;
0729     vc_map vcmap[NS_MAX_RCTSIZE];
0730     vc_map *tste2vc[NS_TST_NUM_ENTRIES];
0731     vc_map *scd2vc[NS_FRSCD_NUM];
0732     buf_nr sbnr;
0733     buf_nr lbnr;
0734     buf_nr hbnr;
0735     buf_nr iovnr;
0736     int sbfqc;
0737     int lbfqc;
0738     struct sk_buff *sm_handle;
0739     u32 sm_addr;
0740     struct sk_buff *lg_handle;
0741     u32 lg_addr;
0742     struct sk_buff *rcbuf;  /* Current raw cell buffer */
0743         struct ns_rcqe *rawcell;
0744     u32 rawch;      /* Raw cell queue head */
0745     unsigned intcnt;    /* Interrupt counter */
0746     spinlock_t int_lock;    /* Interrupt lock */
0747     spinlock_t res_lock;    /* Card resource lock */
0748 } ns_dev;
0749 
0750    /* NOTE: Each tste2vc entry relates a given TST entry to the corresponding
0751       CBR vc. If the entry is not allocated, it must be NULL.
0752 
0753       There are two TSTs so the driver can modify them on the fly
0754       without stopping the transmission.
0755 
0756       scd2vc allows us to find out unused fixed rate SCDs, because
0757       they must have a NULL pointer here. */
0758 
0759 #endif /* _LINUX_NICSTAR_H_ */