162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * nicstar.h
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Header file for the nicstar device driver.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Author: Rui Prior (rprior@inescn.pt)
862306a36Sopenharmony_ci * PowerPC support by Jay Talbott (jay_talbott@mcg.mot.com) April 1999
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * (C) INESC 1998
1162306a36Sopenharmony_ci */
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifndef _LINUX_NICSTAR_H_
1462306a36Sopenharmony_ci#define _LINUX_NICSTAR_H_
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/* Includes */
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#include <linux/types.h>
1962306a36Sopenharmony_ci#include <linux/pci.h>
2062306a36Sopenharmony_ci#include <linux/idr.h>
2162306a36Sopenharmony_ci#include <linux/uio.h>
2262306a36Sopenharmony_ci#include <linux/skbuff.h>
2362306a36Sopenharmony_ci#include <linux/atmdev.h>
2462306a36Sopenharmony_ci#include <linux/atm_nicstar.h>
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* Options */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define NS_MAX_CARDS 4		/* Maximum number of NICStAR based cards
2962306a36Sopenharmony_ci				   controlled by the device driver. Must
3062306a36Sopenharmony_ci				   be <= 5 */
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#undef RCQ_SUPPORT		/* Do not define this for now */
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#define NS_TST_NUM_ENTRIES 2340	/* + 1 for return */
3562306a36Sopenharmony_ci#define NS_TST_RESERVED 340	/* N. entries reserved for UBR/ABR/VBR */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define NS_SMBUFSIZE 48		/* 48, 96, 240 or 2048 */
3862306a36Sopenharmony_ci#define NS_LGBUFSIZE 16384	/* 2048, 4096, 8192 or 16384 */
3962306a36Sopenharmony_ci#define NS_RSQSIZE 8192		/* 2048, 4096 or 8192 */
4062306a36Sopenharmony_ci#define NS_VPIBITS 2		/* 0, 1, 2, or 8 */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define NS_MAX_RCTSIZE 4096	/* Number of entries. 4096 or 16384.
4362306a36Sopenharmony_ci				   Define 4096 only if (all) your card(s)
4462306a36Sopenharmony_ci				   have 32K x 32bit SRAM, in which case
4562306a36Sopenharmony_ci				   setting this to 16384 will just waste a
4662306a36Sopenharmony_ci				   lot of memory.
4762306a36Sopenharmony_ci				   Setting this to 4096 for a card with
4862306a36Sopenharmony_ci				   128K x 32bit SRAM will limit the maximum
4962306a36Sopenharmony_ci				   VCI. */
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci				/*#define NS_PCI_LATENCY 64*//* Must be a multiple of 32 */
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci	/* Number of buffers initially allocated */
5462306a36Sopenharmony_ci#define NUM_SB 32		/* Must be even */
5562306a36Sopenharmony_ci#define NUM_LB 24		/* Must be even */
5662306a36Sopenharmony_ci#define NUM_HB 8		/* Pre-allocated huge buffers */
5762306a36Sopenharmony_ci#define NUM_IOVB 48		/* Iovec buffers */
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci	/* Lower level for count of buffers */
6062306a36Sopenharmony_ci#define MIN_SB 8		/* Must be even */
6162306a36Sopenharmony_ci#define MIN_LB 8		/* Must be even */
6262306a36Sopenharmony_ci#define MIN_HB 6
6362306a36Sopenharmony_ci#define MIN_IOVB 8
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci	/* Upper level for count of buffers */
6662306a36Sopenharmony_ci#define MAX_SB 64		/* Must be even, <= 508 */
6762306a36Sopenharmony_ci#define MAX_LB 48		/* Must be even, <= 508 */
6862306a36Sopenharmony_ci#define MAX_HB 10
6962306a36Sopenharmony_ci#define MAX_IOVB 80
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci	/* These are the absolute maximum allowed for the ioctl() */
7262306a36Sopenharmony_ci#define TOP_SB 256		/* Must be even, <= 508 */
7362306a36Sopenharmony_ci#define TOP_LB 128		/* Must be even, <= 508 */
7462306a36Sopenharmony_ci#define TOP_HB 64
7562306a36Sopenharmony_ci#define TOP_IOVB 256
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci#define MAX_TBD_PER_VC 1	/* Number of TBDs before a TSR */
7862306a36Sopenharmony_ci#define MAX_TBD_PER_SCQ 10	/* Only meaningful for variable rate SCQs */
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci#undef ENABLE_TSQFIE
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#define SCQFULL_TIMEOUT (5 * HZ)
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#define NS_POLL_PERIOD (HZ)
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#define PCR_TOLERANCE (1.0001)
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* ESI stuff */
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C
9162306a36Sopenharmony_ci#define NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT 0xF6
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* #defines */
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define NS_IOREMAP_SIZE 4096
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci/*
9862306a36Sopenharmony_ci * BUF_XX distinguish the Rx buffers depending on their (small/large) size.
9962306a36Sopenharmony_ci * BUG_SM and BUG_LG are both used by the driver and the device.
10062306a36Sopenharmony_ci * BUF_NONE is only used by the driver.
10162306a36Sopenharmony_ci */
10262306a36Sopenharmony_ci#define BUF_SM		0x00000000	/* These two are used for push_rxbufs() */
10362306a36Sopenharmony_ci#define BUF_LG		0x00000001	/* CMD, Write_FreeBufQ, LBUF bit */
10462306a36Sopenharmony_ci#define BUF_NONE 	0xffffffff	/* Software only: */
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#define NS_HBUFSIZE 65568	/* Size of max. AAL5 PDU */
10762306a36Sopenharmony_ci#define NS_MAX_IOVECS (2 + (65568 - NS_SMBUFSIZE) / \
10862306a36Sopenharmony_ci                       (NS_LGBUFSIZE - (NS_LGBUFSIZE % 48)))
10962306a36Sopenharmony_ci#define NS_IOVBUFSIZE (NS_MAX_IOVECS * (sizeof(struct iovec)))
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#define NS_SMBUFSIZE_USABLE (NS_SMBUFSIZE - NS_SMBUFSIZE % 48)
11262306a36Sopenharmony_ci#define NS_LGBUFSIZE_USABLE (NS_LGBUFSIZE - NS_LGBUFSIZE % 48)
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#define NS_AAL0_HEADER (ATM_AAL0_SDU - ATM_CELL_PAYLOAD)	/* 4 bytes */
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define NS_SMSKBSIZE (NS_SMBUFSIZE + NS_AAL0_HEADER)
11762306a36Sopenharmony_ci#define NS_LGSKBSIZE (NS_SMBUFSIZE + NS_LGBUFSIZE)
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci/* NICStAR structures located in host memory */
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci/*
12262306a36Sopenharmony_ci * RSQ - Receive Status Queue
12362306a36Sopenharmony_ci *
12462306a36Sopenharmony_ci * Written by the NICStAR, read by the device driver.
12562306a36Sopenharmony_ci */
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_citypedef struct ns_rsqe {
12862306a36Sopenharmony_ci	u32 word_1;
12962306a36Sopenharmony_ci	u32 buffer_handle;
13062306a36Sopenharmony_ci	u32 final_aal5_crc32;
13162306a36Sopenharmony_ci	u32 word_4;
13262306a36Sopenharmony_ci} ns_rsqe;
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define ns_rsqe_vpi(ns_rsqep) \
13562306a36Sopenharmony_ci        ((le32_to_cpu((ns_rsqep)->word_1) & 0x00FF0000) >> 16)
13662306a36Sopenharmony_ci#define ns_rsqe_vci(ns_rsqep) \
13762306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_1) & 0x0000FFFF)
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define NS_RSQE_VALID      0x80000000
14062306a36Sopenharmony_ci#define NS_RSQE_NZGFC      0x00004000
14162306a36Sopenharmony_ci#define NS_RSQE_EOPDU      0x00002000
14262306a36Sopenharmony_ci#define NS_RSQE_BUFSIZE    0x00001000
14362306a36Sopenharmony_ci#define NS_RSQE_CONGESTION 0x00000800
14462306a36Sopenharmony_ci#define NS_RSQE_CLP        0x00000400
14562306a36Sopenharmony_ci#define NS_RSQE_CRCERR     0x00000200
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci#define NS_RSQE_BUFSIZE_SM 0x00000000
14862306a36Sopenharmony_ci#define NS_RSQE_BUFSIZE_LG 0x00001000
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci#define ns_rsqe_valid(ns_rsqep) \
15162306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_VALID)
15262306a36Sopenharmony_ci#define ns_rsqe_nzgfc(ns_rsqep) \
15362306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_NZGFC)
15462306a36Sopenharmony_ci#define ns_rsqe_eopdu(ns_rsqep) \
15562306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_EOPDU)
15662306a36Sopenharmony_ci#define ns_rsqe_bufsize(ns_rsqep) \
15762306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_BUFSIZE)
15862306a36Sopenharmony_ci#define ns_rsqe_congestion(ns_rsqep) \
15962306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CONGESTION)
16062306a36Sopenharmony_ci#define ns_rsqe_clp(ns_rsqep) \
16162306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CLP)
16262306a36Sopenharmony_ci#define ns_rsqe_crcerr(ns_rsqep) \
16362306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CRCERR)
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#define ns_rsqe_cellcount(ns_rsqep) \
16662306a36Sopenharmony_ci        (le32_to_cpu((ns_rsqep)->word_4) & 0x000001FF)
16762306a36Sopenharmony_ci#define ns_rsqe_init(ns_rsqep) \
16862306a36Sopenharmony_ci        ((ns_rsqep)->word_4 = cpu_to_le32(0x00000000))
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci#define NS_RSQ_NUM_ENTRIES (NS_RSQSIZE / 16)
17162306a36Sopenharmony_ci#define NS_RSQ_ALIGNMENT NS_RSQSIZE
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci/*
17462306a36Sopenharmony_ci * RCQ - Raw Cell Queue
17562306a36Sopenharmony_ci *
17662306a36Sopenharmony_ci * Written by the NICStAR, read by the device driver.
17762306a36Sopenharmony_ci */
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_citypedef struct cell_payload {
18062306a36Sopenharmony_ci	u32 word[12];
18162306a36Sopenharmony_ci} cell_payload;
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_citypedef struct ns_rcqe {
18462306a36Sopenharmony_ci	u32 word_1;
18562306a36Sopenharmony_ci	u32 word_2;
18662306a36Sopenharmony_ci	u32 word_3;
18762306a36Sopenharmony_ci	u32 word_4;
18862306a36Sopenharmony_ci	cell_payload payload;
18962306a36Sopenharmony_ci} ns_rcqe;
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci#define NS_RCQE_SIZE 64		/* bytes */
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci#define ns_rcqe_islast(ns_rcqep) \
19462306a36Sopenharmony_ci        (le32_to_cpu((ns_rcqep)->word_2) != 0x00000000)
19562306a36Sopenharmony_ci#define ns_rcqe_cellheader(ns_rcqep) \
19662306a36Sopenharmony_ci        (le32_to_cpu((ns_rcqep)->word_1))
19762306a36Sopenharmony_ci#define ns_rcqe_nextbufhandle(ns_rcqep) \
19862306a36Sopenharmony_ci        (le32_to_cpu((ns_rcqep)->word_2))
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci/*
20162306a36Sopenharmony_ci * SCQ - Segmentation Channel Queue
20262306a36Sopenharmony_ci *
20362306a36Sopenharmony_ci * Written by the device driver, read by the NICStAR.
20462306a36Sopenharmony_ci */
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_citypedef struct ns_scqe {
20762306a36Sopenharmony_ci	u32 word_1;
20862306a36Sopenharmony_ci	u32 word_2;
20962306a36Sopenharmony_ci	u32 word_3;
21062306a36Sopenharmony_ci	u32 word_4;
21162306a36Sopenharmony_ci} ns_scqe;
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci   /* NOTE: SCQ entries can be either a TBD (Transmit Buffer Descriptors)
21462306a36Sopenharmony_ci      or TSR (Transmit Status Requests) */
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci#define NS_SCQE_TYPE_TBD 0x00000000
21762306a36Sopenharmony_ci#define NS_SCQE_TYPE_TSR 0x80000000
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci#define NS_TBD_EOPDU 0x40000000
22062306a36Sopenharmony_ci#define NS_TBD_AAL0  0x00000000
22162306a36Sopenharmony_ci#define NS_TBD_AAL34 0x04000000
22262306a36Sopenharmony_ci#define NS_TBD_AAL5  0x08000000
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci#define NS_TBD_VPI_MASK 0x0FF00000
22562306a36Sopenharmony_ci#define NS_TBD_VCI_MASK 0x000FFFF0
22662306a36Sopenharmony_ci#define NS_TBD_VC_MASK (NS_TBD_VPI_MASK | NS_TBD_VCI_MASK)
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci#define NS_TBD_VPI_SHIFT 20
22962306a36Sopenharmony_ci#define NS_TBD_VCI_SHIFT 4
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci#define ns_tbd_mkword_1(flags, m, n, buflen) \
23262306a36Sopenharmony_ci      (cpu_to_le32((flags) | (m) << 23 | (n) << 16 | (buflen)))
23362306a36Sopenharmony_ci#define ns_tbd_mkword_1_novbr(flags, buflen) \
23462306a36Sopenharmony_ci      (cpu_to_le32((flags) | (buflen) | 0x00810000))
23562306a36Sopenharmony_ci#define ns_tbd_mkword_3(control, pdulen) \
23662306a36Sopenharmony_ci      (cpu_to_le32((control) << 16 | (pdulen)))
23762306a36Sopenharmony_ci#define ns_tbd_mkword_4(gfc, vpi, vci, pt, clp) \
23862306a36Sopenharmony_ci      (cpu_to_le32((gfc) << 28 | (vpi) << 20 | (vci) << 4 | (pt) << 1 | (clp)))
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci#define NS_TSR_INTENABLE 0x20000000
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci#define NS_TSR_SCDISVBR 0xFFFF	/* Use as scdi for VBR SCD */
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci#define ns_tsr_mkword_1(flags) \
24562306a36Sopenharmony_ci        (cpu_to_le32(NS_SCQE_TYPE_TSR | (flags)))
24662306a36Sopenharmony_ci#define ns_tsr_mkword_2(scdi, scqi) \
24762306a36Sopenharmony_ci        (cpu_to_le32((scdi) << 16 | 0x00008000 | (scqi)))
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci#define ns_scqe_is_tsr(ns_scqep) \
25062306a36Sopenharmony_ci        (le32_to_cpu((ns_scqep)->word_1) & NS_SCQE_TYPE_TSR)
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ci#define VBR_SCQ_NUM_ENTRIES 512
25362306a36Sopenharmony_ci#define VBR_SCQSIZE 8192
25462306a36Sopenharmony_ci#define CBR_SCQ_NUM_ENTRIES 64
25562306a36Sopenharmony_ci#define CBR_SCQSIZE 1024
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci#define NS_SCQE_SIZE 16
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci/*
26062306a36Sopenharmony_ci * TSQ - Transmit Status Queue
26162306a36Sopenharmony_ci *
26262306a36Sopenharmony_ci * Written by the NICStAR, read by the device driver.
26362306a36Sopenharmony_ci */
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_citypedef struct ns_tsi {
26662306a36Sopenharmony_ci	u32 word_1;
26762306a36Sopenharmony_ci	u32 word_2;
26862306a36Sopenharmony_ci} ns_tsi;
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci   /* NOTE: The first word can be a status word copied from the TSR which
27162306a36Sopenharmony_ci      originated the TSI, or a timer overflow indicator. In this last
27262306a36Sopenharmony_ci      case, the value of the first word is all zeroes. */
27362306a36Sopenharmony_ci
27462306a36Sopenharmony_ci#define NS_TSI_EMPTY          0x80000000
27562306a36Sopenharmony_ci#define NS_TSI_TIMESTAMP_MASK 0x00FFFFFF
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci#define ns_tsi_isempty(ns_tsip) \
27862306a36Sopenharmony_ci        (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_EMPTY)
27962306a36Sopenharmony_ci#define ns_tsi_gettimestamp(ns_tsip) \
28062306a36Sopenharmony_ci        (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_TIMESTAMP_MASK)
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci#define ns_tsi_init(ns_tsip) \
28362306a36Sopenharmony_ci        ((ns_tsip)->word_2 = cpu_to_le32(NS_TSI_EMPTY))
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci#define NS_TSQSIZE 8192
28662306a36Sopenharmony_ci#define NS_TSQ_NUM_ENTRIES 1024
28762306a36Sopenharmony_ci#define NS_TSQ_ALIGNMENT 8192
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci#define NS_TSI_SCDISVBR NS_TSR_SCDISVBR
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci#define ns_tsi_tmrof(ns_tsip) \
29262306a36Sopenharmony_ci        (le32_to_cpu((ns_tsip)->word_1) == 0x00000000)
29362306a36Sopenharmony_ci#define ns_tsi_getscdindex(ns_tsip) \
29462306a36Sopenharmony_ci        ((le32_to_cpu((ns_tsip)->word_1) & 0xFFFF0000) >> 16)
29562306a36Sopenharmony_ci#define ns_tsi_getscqpos(ns_tsip) \
29662306a36Sopenharmony_ci        (le32_to_cpu((ns_tsip)->word_1) & 0x00007FFF)
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci/* NICStAR structures located in local SRAM */
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci/*
30162306a36Sopenharmony_ci * RCT - Receive Connection Table
30262306a36Sopenharmony_ci *
30362306a36Sopenharmony_ci * Written by both the NICStAR and the device driver.
30462306a36Sopenharmony_ci */
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_citypedef struct ns_rcte {
30762306a36Sopenharmony_ci	u32 word_1;
30862306a36Sopenharmony_ci	u32 buffer_handle;
30962306a36Sopenharmony_ci	u32 dma_address;
31062306a36Sopenharmony_ci	u32 aal5_crc32;
31162306a36Sopenharmony_ci} ns_rcte;
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci#define NS_RCTE_BSFB            0x00200000	/* Rev. D only */
31462306a36Sopenharmony_ci#define NS_RCTE_NZGFC           0x00100000
31562306a36Sopenharmony_ci#define NS_RCTE_CONNECTOPEN     0x00080000
31662306a36Sopenharmony_ci#define NS_RCTE_AALMASK         0x00070000
31762306a36Sopenharmony_ci#define NS_RCTE_AAL0            0x00000000
31862306a36Sopenharmony_ci#define NS_RCTE_AAL34           0x00010000
31962306a36Sopenharmony_ci#define NS_RCTE_AAL5            0x00020000
32062306a36Sopenharmony_ci#define NS_RCTE_RCQ             0x00030000
32162306a36Sopenharmony_ci#define NS_RCTE_RAWCELLINTEN    0x00008000
32262306a36Sopenharmony_ci#define NS_RCTE_RXCONSTCELLADDR 0x00004000
32362306a36Sopenharmony_ci#define NS_RCTE_BUFFVALID       0x00002000
32462306a36Sopenharmony_ci#define NS_RCTE_FBDSIZE         0x00001000
32562306a36Sopenharmony_ci#define NS_RCTE_EFCI            0x00000800
32662306a36Sopenharmony_ci#define NS_RCTE_CLP             0x00000400
32762306a36Sopenharmony_ci#define NS_RCTE_CRCERROR        0x00000200
32862306a36Sopenharmony_ci#define NS_RCTE_CELLCOUNT_MASK  0x000001FF
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci#define NS_RCTE_FBDSIZE_SM 0x00000000
33162306a36Sopenharmony_ci#define NS_RCTE_FBDSIZE_LG 0x00001000
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci#define NS_RCT_ENTRY_SIZE 4	/* Number of dwords */
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci   /* NOTE: We could make macros to contruct the first word of the RCTE,
33662306a36Sopenharmony_ci      but that doesn't seem to make much sense... */
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci/*
33962306a36Sopenharmony_ci * FBD - Free Buffer Descriptor
34062306a36Sopenharmony_ci *
34162306a36Sopenharmony_ci * Written by the device driver using via the command register.
34262306a36Sopenharmony_ci */
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_citypedef struct ns_fbd {
34562306a36Sopenharmony_ci	u32 buffer_handle;
34662306a36Sopenharmony_ci	u32 dma_address;
34762306a36Sopenharmony_ci} ns_fbd;
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci/*
35062306a36Sopenharmony_ci * TST - Transmit Schedule Table
35162306a36Sopenharmony_ci *
35262306a36Sopenharmony_ci * Written by the device driver.
35362306a36Sopenharmony_ci */
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_citypedef u32 ns_tste;
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci#define NS_TST_OPCODE_MASK 0x60000000
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_ci#define NS_TST_OPCODE_NULL     0x00000000	/* Insert null cell */
36062306a36Sopenharmony_ci#define NS_TST_OPCODE_FIXED    0x20000000	/* Cell from a fixed rate channel */
36162306a36Sopenharmony_ci#define NS_TST_OPCODE_VARIABLE 0x40000000
36262306a36Sopenharmony_ci#define NS_TST_OPCODE_END      0x60000000	/* Jump */
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci#define ns_tste_make(opcode, sramad) (opcode | sramad)
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci   /* NOTE:
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci      - When the opcode is FIXED, sramad specifies the SRAM address of the
36962306a36Sopenharmony_ci      SCD for that fixed rate channel.
37062306a36Sopenharmony_ci      - When the opcode is END, sramad specifies the SRAM address of the
37162306a36Sopenharmony_ci      location of the next TST entry to read.
37262306a36Sopenharmony_ci    */
37362306a36Sopenharmony_ci
37462306a36Sopenharmony_ci/*
37562306a36Sopenharmony_ci * SCD - Segmentation Channel Descriptor
37662306a36Sopenharmony_ci *
37762306a36Sopenharmony_ci * Written by both the device driver and the NICStAR
37862306a36Sopenharmony_ci */
37962306a36Sopenharmony_ci
38062306a36Sopenharmony_citypedef struct ns_scd {
38162306a36Sopenharmony_ci	u32 word_1;
38262306a36Sopenharmony_ci	u32 word_2;
38362306a36Sopenharmony_ci	u32 partial_aal5_crc;
38462306a36Sopenharmony_ci	u32 reserved;
38562306a36Sopenharmony_ci	ns_scqe cache_a;
38662306a36Sopenharmony_ci	ns_scqe cache_b;
38762306a36Sopenharmony_ci} ns_scd;
38862306a36Sopenharmony_ci
38962306a36Sopenharmony_ci#define NS_SCD_BASE_MASK_VAR 0xFFFFE000	/* Variable rate */
39062306a36Sopenharmony_ci#define NS_SCD_BASE_MASK_FIX 0xFFFFFC00	/* Fixed rate */
39162306a36Sopenharmony_ci#define NS_SCD_TAIL_MASK_VAR 0x00001FF0
39262306a36Sopenharmony_ci#define NS_SCD_TAIL_MASK_FIX 0x000003F0
39362306a36Sopenharmony_ci#define NS_SCD_HEAD_MASK_VAR 0x00001FF0
39462306a36Sopenharmony_ci#define NS_SCD_HEAD_MASK_FIX 0x000003F0
39562306a36Sopenharmony_ci#define NS_SCD_XMITFOREVER   0x02000000
39662306a36Sopenharmony_ci
39762306a36Sopenharmony_ci   /* NOTE: There are other fields in word 2 of the SCD, but as they should
39862306a36Sopenharmony_ci      not be needed in the device driver they are not defined here. */
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_ci/* NICStAR local SRAM memory map */
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_ci#define NS_RCT           0x00000
40362306a36Sopenharmony_ci#define NS_RCT_32_END    0x03FFF
40462306a36Sopenharmony_ci#define NS_RCT_128_END   0x0FFFF
40562306a36Sopenharmony_ci#define NS_UNUSED_32     0x04000
40662306a36Sopenharmony_ci#define NS_UNUSED_128    0x10000
40762306a36Sopenharmony_ci#define NS_UNUSED_END    0x1BFFF
40862306a36Sopenharmony_ci#define NS_TST_FRSCD     0x1C000
40962306a36Sopenharmony_ci#define NS_TST_FRSCD_END 0x1E7DB
41062306a36Sopenharmony_ci#define NS_VRSCD2        0x1E7DC
41162306a36Sopenharmony_ci#define NS_VRSCD2_END    0x1E7E7
41262306a36Sopenharmony_ci#define NS_VRSCD1        0x1E7E8
41362306a36Sopenharmony_ci#define NS_VRSCD1_END    0x1E7F3
41462306a36Sopenharmony_ci#define NS_VRSCD0        0x1E7F4
41562306a36Sopenharmony_ci#define NS_VRSCD0_END    0x1E7FF
41662306a36Sopenharmony_ci#define NS_RXFIFO        0x1E800
41762306a36Sopenharmony_ci#define NS_RXFIFO_END    0x1F7FF
41862306a36Sopenharmony_ci#define NS_SMFBQ         0x1F800
41962306a36Sopenharmony_ci#define NS_SMFBQ_END     0x1FBFF
42062306a36Sopenharmony_ci#define NS_LGFBQ         0x1FC00
42162306a36Sopenharmony_ci#define NS_LGFBQ_END     0x1FFFF
42262306a36Sopenharmony_ci
42362306a36Sopenharmony_ci/* NISCtAR operation registers */
42462306a36Sopenharmony_ci
42562306a36Sopenharmony_ci/* See Section 3.4 of `IDT77211 NICStAR User Manual' from www.idt.com */
42662306a36Sopenharmony_ci
42762306a36Sopenharmony_cienum ns_regs {
42862306a36Sopenharmony_ci	DR0 = 0x00,		/* Data Register 0 R/W */
42962306a36Sopenharmony_ci	DR1 = 0x04,		/* Data Register 1 W */
43062306a36Sopenharmony_ci	DR2 = 0x08,		/* Data Register 2 W */
43162306a36Sopenharmony_ci	DR3 = 0x0C,		/* Data Register 3 W */
43262306a36Sopenharmony_ci	CMD = 0x10,		/* Command W */
43362306a36Sopenharmony_ci	CFG = 0x14,		/* Configuration R/W */
43462306a36Sopenharmony_ci	STAT = 0x18,		/* Status R/W */
43562306a36Sopenharmony_ci	RSQB = 0x1C,		/* Receive Status Queue Base W */
43662306a36Sopenharmony_ci	RSQT = 0x20,		/* Receive Status Queue Tail R */
43762306a36Sopenharmony_ci	RSQH = 0x24,		/* Receive Status Queue Head W */
43862306a36Sopenharmony_ci	CDC = 0x28,		/* Cell Drop Counter R/clear */
43962306a36Sopenharmony_ci	VPEC = 0x2C,		/* VPI/VCI Lookup Error Count R/clear */
44062306a36Sopenharmony_ci	ICC = 0x30,		/* Invalid Cell Count R/clear */
44162306a36Sopenharmony_ci	RAWCT = 0x34,		/* Raw Cell Tail R */
44262306a36Sopenharmony_ci	TMR = 0x38,		/* Timer R */
44362306a36Sopenharmony_ci	TSTB = 0x3C,		/* Transmit Schedule Table Base R/W */
44462306a36Sopenharmony_ci	TSQB = 0x40,		/* Transmit Status Queue Base W */
44562306a36Sopenharmony_ci	TSQT = 0x44,		/* Transmit Status Queue Tail R */
44662306a36Sopenharmony_ci	TSQH = 0x48,		/* Transmit Status Queue Head W */
44762306a36Sopenharmony_ci	GP = 0x4C,		/* General Purpose R/W */
44862306a36Sopenharmony_ci	VPM = 0x50		/* VPI/VCI Mask W */
44962306a36Sopenharmony_ci};
45062306a36Sopenharmony_ci
45162306a36Sopenharmony_ci/* NICStAR commands issued to the CMD register */
45262306a36Sopenharmony_ci
45362306a36Sopenharmony_ci/* Top 4 bits are command opcode, lower 28 are parameters. */
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci#define NS_CMD_NO_OPERATION         0x00000000
45662306a36Sopenharmony_ci	/* params always 0 */
45762306a36Sopenharmony_ci
45862306a36Sopenharmony_ci#define NS_CMD_OPENCLOSE_CONNECTION 0x20000000
45962306a36Sopenharmony_ci	/* b19{1=open,0=close} b18-2{SRAM addr} */
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_ci#define NS_CMD_WRITE_SRAM           0x40000000
46262306a36Sopenharmony_ci	/* b18-2{SRAM addr} b1-0{burst size} */
46362306a36Sopenharmony_ci
46462306a36Sopenharmony_ci#define NS_CMD_READ_SRAM            0x50000000
46562306a36Sopenharmony_ci	/* b18-2{SRAM addr} */
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_ci#define NS_CMD_WRITE_FREEBUFQ       0x60000000
46862306a36Sopenharmony_ci	/* b0{large buf indicator} */
46962306a36Sopenharmony_ci
47062306a36Sopenharmony_ci#define NS_CMD_READ_UTILITY         0x80000000
47162306a36Sopenharmony_ci	/* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
47262306a36Sopenharmony_ci
47362306a36Sopenharmony_ci#define NS_CMD_WRITE_UTILITY        0x90000000
47462306a36Sopenharmony_ci	/* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
47562306a36Sopenharmony_ci
47662306a36Sopenharmony_ci#define NS_CMD_OPEN_CONNECTION (NS_CMD_OPENCLOSE_CONNECTION | 0x00080000)
47762306a36Sopenharmony_ci#define NS_CMD_CLOSE_CONNECTION NS_CMD_OPENCLOSE_CONNECTION
47862306a36Sopenharmony_ci
47962306a36Sopenharmony_ci/* NICStAR configuration bits */
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_ci#define NS_CFG_SWRST          0x80000000	/* Software Reset */
48262306a36Sopenharmony_ci#define NS_CFG_RXPATH         0x20000000	/* Receive Path Enable */
48362306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE_MASK 0x18000000	/* Small Receive Buffer Size */
48462306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE_MASK 0x06000000	/* Large Receive Buffer Size */
48562306a36Sopenharmony_ci#define NS_CFG_EFBIE          0x01000000	/* Empty Free Buffer Queue
48662306a36Sopenharmony_ci						   Interrupt Enable */
48762306a36Sopenharmony_ci#define NS_CFG_RSQSIZE_MASK   0x00C00000	/* Receive Status Queue Size */
48862306a36Sopenharmony_ci#define NS_CFG_ICACCEPT       0x00200000	/* Invalid Cell Accept */
48962306a36Sopenharmony_ci#define NS_CFG_IGNOREGFC      0x00100000	/* Ignore General Flow Control */
49062306a36Sopenharmony_ci#define NS_CFG_VPIBITS_MASK   0x000C0000	/* VPI/VCI Bits Size Select */
49162306a36Sopenharmony_ci#define NS_CFG_RCTSIZE_MASK   0x00030000	/* Receive Connection Table Size */
49262306a36Sopenharmony_ci#define NS_CFG_VCERRACCEPT    0x00008000	/* VPI/VCI Error Cell Accept */
49362306a36Sopenharmony_ci#define NS_CFG_RXINT_MASK     0x00007000	/* End of Receive PDU Interrupt
49462306a36Sopenharmony_ci						   Handling */
49562306a36Sopenharmony_ci#define NS_CFG_RAWIE          0x00000800	/* Raw Cell Qu' Interrupt Enable */
49662306a36Sopenharmony_ci#define NS_CFG_RSQAFIE        0x00000400	/* Receive Queue Almost Full
49762306a36Sopenharmony_ci						   Interrupt Enable */
49862306a36Sopenharmony_ci#define NS_CFG_RXRM           0x00000200	/* Receive RM Cells */
49962306a36Sopenharmony_ci#define NS_CFG_TMRROIE        0x00000080	/* Timer Roll Over Interrupt
50062306a36Sopenharmony_ci						   Enable */
50162306a36Sopenharmony_ci#define NS_CFG_TXEN           0x00000020	/* Transmit Operation Enable */
50262306a36Sopenharmony_ci#define NS_CFG_TXIE           0x00000010	/* Transmit Status Interrupt
50362306a36Sopenharmony_ci						   Enable */
50462306a36Sopenharmony_ci#define NS_CFG_TXURIE         0x00000008	/* Transmit Under-run Interrupt
50562306a36Sopenharmony_ci						   Enable */
50662306a36Sopenharmony_ci#define NS_CFG_UMODE          0x00000004	/* Utopia Mode (cell/byte) Select */
50762306a36Sopenharmony_ci#define NS_CFG_TSQFIE         0x00000002	/* Transmit Status Queue Full
50862306a36Sopenharmony_ci						   Interrupt Enable */
50962306a36Sopenharmony_ci#define NS_CFG_PHYIE          0x00000001	/* PHY Interrupt Enable */
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE_48    0x00000000
51262306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE_96    0x08000000
51362306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE_240   0x10000000
51462306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE_2048  0x18000000
51562306a36Sopenharmony_ci
51662306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE_2048  0x00000000
51762306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE_4096  0x02000000
51862306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE_8192  0x04000000
51962306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE_16384 0x06000000
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci#define NS_CFG_RSQSIZE_2048 0x00000000
52262306a36Sopenharmony_ci#define NS_CFG_RSQSIZE_4096 0x00400000
52362306a36Sopenharmony_ci#define NS_CFG_RSQSIZE_8192 0x00800000
52462306a36Sopenharmony_ci
52562306a36Sopenharmony_ci#define NS_CFG_VPIBITS_0 0x00000000
52662306a36Sopenharmony_ci#define NS_CFG_VPIBITS_1 0x00040000
52762306a36Sopenharmony_ci#define NS_CFG_VPIBITS_2 0x00080000
52862306a36Sopenharmony_ci#define NS_CFG_VPIBITS_8 0x000C0000
52962306a36Sopenharmony_ci
53062306a36Sopenharmony_ci#define NS_CFG_RCTSIZE_4096_ENTRIES  0x00000000
53162306a36Sopenharmony_ci#define NS_CFG_RCTSIZE_8192_ENTRIES  0x00010000
53262306a36Sopenharmony_ci#define NS_CFG_RCTSIZE_16384_ENTRIES 0x00020000
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_ci#define NS_CFG_RXINT_NOINT   0x00000000
53562306a36Sopenharmony_ci#define NS_CFG_RXINT_NODELAY 0x00001000
53662306a36Sopenharmony_ci#define NS_CFG_RXINT_314US   0x00002000
53762306a36Sopenharmony_ci#define NS_CFG_RXINT_624US   0x00003000
53862306a36Sopenharmony_ci#define NS_CFG_RXINT_899US   0x00004000
53962306a36Sopenharmony_ci
54062306a36Sopenharmony_ci/* NICStAR STATus bits */
54162306a36Sopenharmony_ci
54262306a36Sopenharmony_ci#define NS_STAT_SFBQC_MASK 0xFF000000	/* hi 8 bits Small Buffer Queue Count */
54362306a36Sopenharmony_ci#define NS_STAT_LFBQC_MASK 0x00FF0000	/* hi 8 bits Large Buffer Queue Count */
54462306a36Sopenharmony_ci#define NS_STAT_TSIF       0x00008000	/* Transmit Status Queue Indicator */
54562306a36Sopenharmony_ci#define NS_STAT_TXICP      0x00004000	/* Transmit Incomplete PDU */
54662306a36Sopenharmony_ci#define NS_STAT_TSQF       0x00001000	/* Transmit Status Queue Full */
54762306a36Sopenharmony_ci#define NS_STAT_TMROF      0x00000800	/* Timer Overflow */
54862306a36Sopenharmony_ci#define NS_STAT_PHYI       0x00000400	/* PHY Device Interrupt */
54962306a36Sopenharmony_ci#define NS_STAT_CMDBZ      0x00000200	/* Command Busy */
55062306a36Sopenharmony_ci#define NS_STAT_SFBQF      0x00000100	/* Small Buffer Queue Full */
55162306a36Sopenharmony_ci#define NS_STAT_LFBQF      0x00000080	/* Large Buffer Queue Full */
55262306a36Sopenharmony_ci#define NS_STAT_RSQF       0x00000040	/* Receive Status Queue Full */
55362306a36Sopenharmony_ci#define NS_STAT_EOPDU      0x00000020	/* End of PDU */
55462306a36Sopenharmony_ci#define NS_STAT_RAWCF      0x00000010	/* Raw Cell Flag */
55562306a36Sopenharmony_ci#define NS_STAT_SFBQE      0x00000008	/* Small Buffer Queue Empty */
55662306a36Sopenharmony_ci#define NS_STAT_LFBQE      0x00000004	/* Large Buffer Queue Empty */
55762306a36Sopenharmony_ci#define NS_STAT_RSQAF      0x00000002	/* Receive Status Queue Almost Full */
55862306a36Sopenharmony_ci
55962306a36Sopenharmony_ci#define ns_stat_sfbqc_get(stat) (((stat) & NS_STAT_SFBQC_MASK) >> 23)
56062306a36Sopenharmony_ci#define ns_stat_lfbqc_get(stat) (((stat) & NS_STAT_LFBQC_MASK) >> 15)
56162306a36Sopenharmony_ci
56262306a36Sopenharmony_ci/* #defines which depend on other #defines */
56362306a36Sopenharmony_ci
56462306a36Sopenharmony_ci#define NS_TST0 NS_TST_FRSCD
56562306a36Sopenharmony_ci#define NS_TST1 (NS_TST_FRSCD + NS_TST_NUM_ENTRIES + 1)
56662306a36Sopenharmony_ci
56762306a36Sopenharmony_ci#define NS_FRSCD (NS_TST1 + NS_TST_NUM_ENTRIES + 1)
56862306a36Sopenharmony_ci#define NS_FRSCD_SIZE 12	/* 12 dwords */
56962306a36Sopenharmony_ci#define NS_FRSCD_NUM ((NS_TST_FRSCD_END + 1 - NS_FRSCD) / NS_FRSCD_SIZE)
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci#if (NS_SMBUFSIZE == 48)
57262306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_48
57362306a36Sopenharmony_ci#elif (NS_SMBUFSIZE == 96)
57462306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_96
57562306a36Sopenharmony_ci#elif (NS_SMBUFSIZE == 240)
57662306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_240
57762306a36Sopenharmony_ci#elif (NS_SMBUFSIZE == 2048)
57862306a36Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_2048
57962306a36Sopenharmony_ci#else
58062306a36Sopenharmony_ci#error NS_SMBUFSIZE is incorrect in nicstar.h
58162306a36Sopenharmony_ci#endif /* NS_SMBUFSIZE */
58262306a36Sopenharmony_ci
58362306a36Sopenharmony_ci#if (NS_LGBUFSIZE == 2048)
58462306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_2048
58562306a36Sopenharmony_ci#elif (NS_LGBUFSIZE == 4096)
58662306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_4096
58762306a36Sopenharmony_ci#elif (NS_LGBUFSIZE == 8192)
58862306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_8192
58962306a36Sopenharmony_ci#elif (NS_LGBUFSIZE == 16384)
59062306a36Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_16384
59162306a36Sopenharmony_ci#else
59262306a36Sopenharmony_ci#error NS_LGBUFSIZE is incorrect in nicstar.h
59362306a36Sopenharmony_ci#endif /* NS_LGBUFSIZE */
59462306a36Sopenharmony_ci
59562306a36Sopenharmony_ci#if (NS_RSQSIZE == 2048)
59662306a36Sopenharmony_ci#define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_2048
59762306a36Sopenharmony_ci#elif (NS_RSQSIZE == 4096)
59862306a36Sopenharmony_ci#define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_4096
59962306a36Sopenharmony_ci#elif (NS_RSQSIZE == 8192)
60062306a36Sopenharmony_ci#define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_8192
60162306a36Sopenharmony_ci#else
60262306a36Sopenharmony_ci#error NS_RSQSIZE is incorrect in nicstar.h
60362306a36Sopenharmony_ci#endif /* NS_RSQSIZE */
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ci#if (NS_VPIBITS == 0)
60662306a36Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_0
60762306a36Sopenharmony_ci#elif (NS_VPIBITS == 1)
60862306a36Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_1
60962306a36Sopenharmony_ci#elif (NS_VPIBITS == 2)
61062306a36Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_2
61162306a36Sopenharmony_ci#elif (NS_VPIBITS == 8)
61262306a36Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_8
61362306a36Sopenharmony_ci#else
61462306a36Sopenharmony_ci#error NS_VPIBITS is incorrect in nicstar.h
61562306a36Sopenharmony_ci#endif /* NS_VPIBITS */
61662306a36Sopenharmony_ci
61762306a36Sopenharmony_ci#ifdef RCQ_SUPPORT
61862306a36Sopenharmony_ci#define NS_CFG_RAWIE_OPT NS_CFG_RAWIE
61962306a36Sopenharmony_ci#else
62062306a36Sopenharmony_ci#define NS_CFG_RAWIE_OPT 0x00000000
62162306a36Sopenharmony_ci#endif /* RCQ_SUPPORT */
62262306a36Sopenharmony_ci
62362306a36Sopenharmony_ci#ifdef ENABLE_TSQFIE
62462306a36Sopenharmony_ci#define NS_CFG_TSQFIE_OPT NS_CFG_TSQFIE
62562306a36Sopenharmony_ci#else
62662306a36Sopenharmony_ci#define NS_CFG_TSQFIE_OPT 0x00000000
62762306a36Sopenharmony_ci#endif /* ENABLE_TSQFIE */
62862306a36Sopenharmony_ci
62962306a36Sopenharmony_ci/* PCI stuff */
63062306a36Sopenharmony_ci
63162306a36Sopenharmony_ci#ifndef PCI_VENDOR_ID_IDT
63262306a36Sopenharmony_ci#define PCI_VENDOR_ID_IDT 0x111D
63362306a36Sopenharmony_ci#endif /* PCI_VENDOR_ID_IDT */
63462306a36Sopenharmony_ci
63562306a36Sopenharmony_ci#ifndef PCI_DEVICE_ID_IDT_IDT77201
63662306a36Sopenharmony_ci#define PCI_DEVICE_ID_IDT_IDT77201 0x0001
63762306a36Sopenharmony_ci#endif /* PCI_DEVICE_ID_IDT_IDT77201 */
63862306a36Sopenharmony_ci
63962306a36Sopenharmony_ci/* Device driver structures */
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_cistruct ns_skb_prv {
64262306a36Sopenharmony_ci	u32 buf_type;		/* BUF_SM/BUF_LG/BUF_NONE */
64362306a36Sopenharmony_ci	u32 dma;
64462306a36Sopenharmony_ci	int iovcnt;
64562306a36Sopenharmony_ci};
64662306a36Sopenharmony_ci
64762306a36Sopenharmony_ci#define NS_PRV_BUFTYPE(skb)   \
64862306a36Sopenharmony_ci        (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->buf_type)
64962306a36Sopenharmony_ci#define NS_PRV_DMA(skb) \
65062306a36Sopenharmony_ci        (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->dma)
65162306a36Sopenharmony_ci#define NS_PRV_IOVCNT(skb) \
65262306a36Sopenharmony_ci        (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->iovcnt)
65362306a36Sopenharmony_ci
65462306a36Sopenharmony_citypedef struct tsq_info {
65562306a36Sopenharmony_ci	void *org;
65662306a36Sopenharmony_ci        dma_addr_t dma;
65762306a36Sopenharmony_ci	ns_tsi *base;
65862306a36Sopenharmony_ci	ns_tsi *next;
65962306a36Sopenharmony_ci	ns_tsi *last;
66062306a36Sopenharmony_ci} tsq_info;
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_citypedef struct scq_info {
66362306a36Sopenharmony_ci	void *org;
66462306a36Sopenharmony_ci	dma_addr_t dma;
66562306a36Sopenharmony_ci	ns_scqe *base;
66662306a36Sopenharmony_ci	ns_scqe *last;
66762306a36Sopenharmony_ci	ns_scqe *next;
66862306a36Sopenharmony_ci	volatile ns_scqe *tail;	/* Not related to the nicstar register */
66962306a36Sopenharmony_ci	unsigned num_entries;
67062306a36Sopenharmony_ci	struct sk_buff **skb;	/* Pointer to an array of pointers
67162306a36Sopenharmony_ci				   to the sk_buffs used for tx */
67262306a36Sopenharmony_ci	u32 scd;		/* SRAM address of the corresponding
67362306a36Sopenharmony_ci				   SCD */
67462306a36Sopenharmony_ci	int tbd_count;		/* Only meaningful on variable rate */
67562306a36Sopenharmony_ci	wait_queue_head_t scqfull_waitq;
67662306a36Sopenharmony_ci	volatile char full;	/* SCQ full indicator */
67762306a36Sopenharmony_ci	spinlock_t lock;	/* SCQ spinlock */
67862306a36Sopenharmony_ci} scq_info;
67962306a36Sopenharmony_ci
68062306a36Sopenharmony_citypedef struct rsq_info {
68162306a36Sopenharmony_ci	void *org;
68262306a36Sopenharmony_ci        dma_addr_t dma;
68362306a36Sopenharmony_ci	ns_rsqe *base;
68462306a36Sopenharmony_ci	ns_rsqe *next;
68562306a36Sopenharmony_ci	ns_rsqe *last;
68662306a36Sopenharmony_ci} rsq_info;
68762306a36Sopenharmony_ci
68862306a36Sopenharmony_citypedef struct skb_pool {
68962306a36Sopenharmony_ci	volatile int count;	/* number of buffers in the queue */
69062306a36Sopenharmony_ci	struct sk_buff_head queue;
69162306a36Sopenharmony_ci} skb_pool;
69262306a36Sopenharmony_ci
69362306a36Sopenharmony_ci/* NOTE: for small and large buffer pools, the count is not used, as the
69462306a36Sopenharmony_ci         actual value used for buffer management is the one read from the
69562306a36Sopenharmony_ci	 card. */
69662306a36Sopenharmony_ci
69762306a36Sopenharmony_citypedef struct vc_map {
69862306a36Sopenharmony_ci	volatile unsigned int tx:1;	/* TX vc? */
69962306a36Sopenharmony_ci	volatile unsigned int rx:1;	/* RX vc? */
70062306a36Sopenharmony_ci	struct atm_vcc *tx_vcc, *rx_vcc;
70162306a36Sopenharmony_ci	struct sk_buff *rx_iov;	/* RX iovector skb */
70262306a36Sopenharmony_ci	scq_info *scq;		/* To keep track of the SCQ */
70362306a36Sopenharmony_ci	u32 cbr_scd;		/* SRAM address of the corresponding
70462306a36Sopenharmony_ci				   SCD. 0x00000000 for UBR/VBR/ABR */
70562306a36Sopenharmony_ci	int tbd_count;
70662306a36Sopenharmony_ci} vc_map;
70762306a36Sopenharmony_ci
70862306a36Sopenharmony_citypedef struct ns_dev {
70962306a36Sopenharmony_ci	int index;		/* Card ID to the device driver */
71062306a36Sopenharmony_ci	int sram_size;		/* In k x 32bit words. 32 or 128 */
71162306a36Sopenharmony_ci	void __iomem *membase;	/* Card's memory base address */
71262306a36Sopenharmony_ci	unsigned long max_pcr;
71362306a36Sopenharmony_ci	int rct_size;		/* Number of entries */
71462306a36Sopenharmony_ci	int vpibits;
71562306a36Sopenharmony_ci	int vcibits;
71662306a36Sopenharmony_ci	struct pci_dev *pcidev;
71762306a36Sopenharmony_ci	struct idr idr;
71862306a36Sopenharmony_ci	struct atm_dev *atmdev;
71962306a36Sopenharmony_ci	tsq_info tsq;
72062306a36Sopenharmony_ci	rsq_info rsq;
72162306a36Sopenharmony_ci	scq_info *scq0, *scq1, *scq2;	/* VBR SCQs */
72262306a36Sopenharmony_ci	skb_pool sbpool;	/* Small buffers */
72362306a36Sopenharmony_ci	skb_pool lbpool;	/* Large buffers */
72462306a36Sopenharmony_ci	skb_pool hbpool;	/* Pre-allocated huge buffers */
72562306a36Sopenharmony_ci	skb_pool iovpool;	/* iovector buffers */
72662306a36Sopenharmony_ci	volatile int efbie;	/* Empty free buf. queue int. enabled */
72762306a36Sopenharmony_ci	volatile u32 tst_addr;	/* SRAM address of the TST in use */
72862306a36Sopenharmony_ci	volatile int tst_free_entries;
72962306a36Sopenharmony_ci	vc_map vcmap[NS_MAX_RCTSIZE];
73062306a36Sopenharmony_ci	vc_map *tste2vc[NS_TST_NUM_ENTRIES];
73162306a36Sopenharmony_ci	vc_map *scd2vc[NS_FRSCD_NUM];
73262306a36Sopenharmony_ci	buf_nr sbnr;
73362306a36Sopenharmony_ci	buf_nr lbnr;
73462306a36Sopenharmony_ci	buf_nr hbnr;
73562306a36Sopenharmony_ci	buf_nr iovnr;
73662306a36Sopenharmony_ci	int sbfqc;
73762306a36Sopenharmony_ci	int lbfqc;
73862306a36Sopenharmony_ci	struct sk_buff *sm_handle;
73962306a36Sopenharmony_ci	u32 sm_addr;
74062306a36Sopenharmony_ci	struct sk_buff *lg_handle;
74162306a36Sopenharmony_ci	u32 lg_addr;
74262306a36Sopenharmony_ci	struct sk_buff *rcbuf;	/* Current raw cell buffer */
74362306a36Sopenharmony_ci        struct ns_rcqe *rawcell;
74462306a36Sopenharmony_ci	u32 rawch;		/* Raw cell queue head */
74562306a36Sopenharmony_ci	unsigned intcnt;	/* Interrupt counter */
74662306a36Sopenharmony_ci	spinlock_t int_lock;	/* Interrupt lock */
74762306a36Sopenharmony_ci	spinlock_t res_lock;	/* Card resource lock */
74862306a36Sopenharmony_ci} ns_dev;
74962306a36Sopenharmony_ci
75062306a36Sopenharmony_ci   /* NOTE: Each tste2vc entry relates a given TST entry to the corresponding
75162306a36Sopenharmony_ci      CBR vc. If the entry is not allocated, it must be NULL.
75262306a36Sopenharmony_ci
75362306a36Sopenharmony_ci      There are two TSTs so the driver can modify them on the fly
75462306a36Sopenharmony_ci      without stopping the transmission.
75562306a36Sopenharmony_ci
75662306a36Sopenharmony_ci      scd2vc allows us to find out unused fixed rate SCDs, because
75762306a36Sopenharmony_ci      they must have a NULL pointer here. */
75862306a36Sopenharmony_ci
75962306a36Sopenharmony_ci#endif /* _LINUX_NICSTAR_H_ */
760