18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * nicstar.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Header file for the nicstar device driver. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: Rui Prior (rprior@inescn.pt) 88c2ecf20Sopenharmony_ci * PowerPC support by Jay Talbott (jay_talbott@mcg.mot.com) April 1999 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * (C) INESC 1998 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef _LINUX_NICSTAR_H_ 148c2ecf20Sopenharmony_ci#define _LINUX_NICSTAR_H_ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* Includes */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/types.h> 198c2ecf20Sopenharmony_ci#include <linux/pci.h> 208c2ecf20Sopenharmony_ci#include <linux/idr.h> 218c2ecf20Sopenharmony_ci#include <linux/uio.h> 228c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 238c2ecf20Sopenharmony_ci#include <linux/atmdev.h> 248c2ecf20Sopenharmony_ci#include <linux/atm_nicstar.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* Options */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards 298c2ecf20Sopenharmony_ci controlled by the device driver. Must 308c2ecf20Sopenharmony_ci be <= 5 */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#undef RCQ_SUPPORT /* Do not define this for now */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define NS_TST_NUM_ENTRIES 2340 /* + 1 for return */ 358c2ecf20Sopenharmony_ci#define NS_TST_RESERVED 340 /* N. entries reserved for UBR/ABR/VBR */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define NS_SMBUFSIZE 48 /* 48, 96, 240 or 2048 */ 388c2ecf20Sopenharmony_ci#define NS_LGBUFSIZE 16384 /* 2048, 4096, 8192 or 16384 */ 398c2ecf20Sopenharmony_ci#define NS_RSQSIZE 8192 /* 2048, 4096 or 8192 */ 408c2ecf20Sopenharmony_ci#define NS_VPIBITS 2 /* 0, 1, 2, or 8 */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define NS_MAX_RCTSIZE 4096 /* Number of entries. 4096 or 16384. 438c2ecf20Sopenharmony_ci Define 4096 only if (all) your card(s) 448c2ecf20Sopenharmony_ci have 32K x 32bit SRAM, in which case 458c2ecf20Sopenharmony_ci setting this to 16384 will just waste a 468c2ecf20Sopenharmony_ci lot of memory. 478c2ecf20Sopenharmony_ci Setting this to 4096 for a card with 488c2ecf20Sopenharmony_ci 128K x 32bit SRAM will limit the maximum 498c2ecf20Sopenharmony_ci VCI. */ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci /*#define NS_PCI_LATENCY 64*//* Must be a multiple of 32 */ 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci /* Number of buffers initially allocated */ 548c2ecf20Sopenharmony_ci#define NUM_SB 32 /* Must be even */ 558c2ecf20Sopenharmony_ci#define NUM_LB 24 /* Must be even */ 568c2ecf20Sopenharmony_ci#define NUM_HB 8 /* Pre-allocated huge buffers */ 578c2ecf20Sopenharmony_ci#define NUM_IOVB 48 /* Iovec buffers */ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci /* Lower level for count of buffers */ 608c2ecf20Sopenharmony_ci#define MIN_SB 8 /* Must be even */ 618c2ecf20Sopenharmony_ci#define MIN_LB 8 /* Must be even */ 628c2ecf20Sopenharmony_ci#define MIN_HB 6 638c2ecf20Sopenharmony_ci#define MIN_IOVB 8 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci /* Upper level for count of buffers */ 668c2ecf20Sopenharmony_ci#define MAX_SB 64 /* Must be even, <= 508 */ 678c2ecf20Sopenharmony_ci#define MAX_LB 48 /* Must be even, <= 508 */ 688c2ecf20Sopenharmony_ci#define MAX_HB 10 698c2ecf20Sopenharmony_ci#define MAX_IOVB 80 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci /* These are the absolute maximum allowed for the ioctl() */ 728c2ecf20Sopenharmony_ci#define TOP_SB 256 /* Must be even, <= 508 */ 738c2ecf20Sopenharmony_ci#define TOP_LB 128 /* Must be even, <= 508 */ 748c2ecf20Sopenharmony_ci#define TOP_HB 64 758c2ecf20Sopenharmony_ci#define TOP_IOVB 256 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define MAX_TBD_PER_VC 1 /* Number of TBDs before a TSR */ 788c2ecf20Sopenharmony_ci#define MAX_TBD_PER_SCQ 10 /* Only meaningful for variable rate SCQs */ 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#undef ENABLE_TSQFIE 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define SCQFULL_TIMEOUT (5 * HZ) 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define NS_POLL_PERIOD (HZ) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define PCR_TOLERANCE (1.0001) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* ESI stuff */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C 918c2ecf20Sopenharmony_ci#define NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT 0xF6 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* #defines */ 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define NS_IOREMAP_SIZE 4096 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* 988c2ecf20Sopenharmony_ci * BUF_XX distinguish the Rx buffers depending on their (small/large) size. 998c2ecf20Sopenharmony_ci * BUG_SM and BUG_LG are both used by the driver and the device. 1008c2ecf20Sopenharmony_ci * BUF_NONE is only used by the driver. 1018c2ecf20Sopenharmony_ci */ 1028c2ecf20Sopenharmony_ci#define BUF_SM 0x00000000 /* These two are used for push_rxbufs() */ 1038c2ecf20Sopenharmony_ci#define BUF_LG 0x00000001 /* CMD, Write_FreeBufQ, LBUF bit */ 1048c2ecf20Sopenharmony_ci#define BUF_NONE 0xffffffff /* Software only: */ 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define NS_HBUFSIZE 65568 /* Size of max. AAL5 PDU */ 1078c2ecf20Sopenharmony_ci#define NS_MAX_IOVECS (2 + (65568 - NS_SMBUFSIZE) / \ 1088c2ecf20Sopenharmony_ci (NS_LGBUFSIZE - (NS_LGBUFSIZE % 48))) 1098c2ecf20Sopenharmony_ci#define NS_IOVBUFSIZE (NS_MAX_IOVECS * (sizeof(struct iovec))) 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define NS_SMBUFSIZE_USABLE (NS_SMBUFSIZE - NS_SMBUFSIZE % 48) 1128c2ecf20Sopenharmony_ci#define NS_LGBUFSIZE_USABLE (NS_LGBUFSIZE - NS_LGBUFSIZE % 48) 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#define NS_AAL0_HEADER (ATM_AAL0_SDU - ATM_CELL_PAYLOAD) /* 4 bytes */ 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define NS_SMSKBSIZE (NS_SMBUFSIZE + NS_AAL0_HEADER) 1178c2ecf20Sopenharmony_ci#define NS_LGSKBSIZE (NS_SMBUFSIZE + NS_LGBUFSIZE) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci/* NICStAR structures located in host memory */ 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* 1228c2ecf20Sopenharmony_ci * RSQ - Receive Status Queue 1238c2ecf20Sopenharmony_ci * 1248c2ecf20Sopenharmony_ci * Written by the NICStAR, read by the device driver. 1258c2ecf20Sopenharmony_ci */ 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_citypedef struct ns_rsqe { 1288c2ecf20Sopenharmony_ci u32 word_1; 1298c2ecf20Sopenharmony_ci u32 buffer_handle; 1308c2ecf20Sopenharmony_ci u32 final_aal5_crc32; 1318c2ecf20Sopenharmony_ci u32 word_4; 1328c2ecf20Sopenharmony_ci} ns_rsqe; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define ns_rsqe_vpi(ns_rsqep) \ 1358c2ecf20Sopenharmony_ci ((le32_to_cpu((ns_rsqep)->word_1) & 0x00FF0000) >> 16) 1368c2ecf20Sopenharmony_ci#define ns_rsqe_vci(ns_rsqep) \ 1378c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_1) & 0x0000FFFF) 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#define NS_RSQE_VALID 0x80000000 1408c2ecf20Sopenharmony_ci#define NS_RSQE_NZGFC 0x00004000 1418c2ecf20Sopenharmony_ci#define NS_RSQE_EOPDU 0x00002000 1428c2ecf20Sopenharmony_ci#define NS_RSQE_BUFSIZE 0x00001000 1438c2ecf20Sopenharmony_ci#define NS_RSQE_CONGESTION 0x00000800 1448c2ecf20Sopenharmony_ci#define NS_RSQE_CLP 0x00000400 1458c2ecf20Sopenharmony_ci#define NS_RSQE_CRCERR 0x00000200 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#define NS_RSQE_BUFSIZE_SM 0x00000000 1488c2ecf20Sopenharmony_ci#define NS_RSQE_BUFSIZE_LG 0x00001000 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci#define ns_rsqe_valid(ns_rsqep) \ 1518c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_VALID) 1528c2ecf20Sopenharmony_ci#define ns_rsqe_nzgfc(ns_rsqep) \ 1538c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_NZGFC) 1548c2ecf20Sopenharmony_ci#define ns_rsqe_eopdu(ns_rsqep) \ 1558c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_EOPDU) 1568c2ecf20Sopenharmony_ci#define ns_rsqe_bufsize(ns_rsqep) \ 1578c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_BUFSIZE) 1588c2ecf20Sopenharmony_ci#define ns_rsqe_congestion(ns_rsqep) \ 1598c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CONGESTION) 1608c2ecf20Sopenharmony_ci#define ns_rsqe_clp(ns_rsqep) \ 1618c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CLP) 1628c2ecf20Sopenharmony_ci#define ns_rsqe_crcerr(ns_rsqep) \ 1638c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CRCERR) 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci#define ns_rsqe_cellcount(ns_rsqep) \ 1668c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rsqep)->word_4) & 0x000001FF) 1678c2ecf20Sopenharmony_ci#define ns_rsqe_init(ns_rsqep) \ 1688c2ecf20Sopenharmony_ci ((ns_rsqep)->word_4 = cpu_to_le32(0x00000000)) 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define NS_RSQ_NUM_ENTRIES (NS_RSQSIZE / 16) 1718c2ecf20Sopenharmony_ci#define NS_RSQ_ALIGNMENT NS_RSQSIZE 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* 1748c2ecf20Sopenharmony_ci * RCQ - Raw Cell Queue 1758c2ecf20Sopenharmony_ci * 1768c2ecf20Sopenharmony_ci * Written by the NICStAR, read by the device driver. 1778c2ecf20Sopenharmony_ci */ 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_citypedef struct cell_payload { 1808c2ecf20Sopenharmony_ci u32 word[12]; 1818c2ecf20Sopenharmony_ci} cell_payload; 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_citypedef struct ns_rcqe { 1848c2ecf20Sopenharmony_ci u32 word_1; 1858c2ecf20Sopenharmony_ci u32 word_2; 1868c2ecf20Sopenharmony_ci u32 word_3; 1878c2ecf20Sopenharmony_ci u32 word_4; 1888c2ecf20Sopenharmony_ci cell_payload payload; 1898c2ecf20Sopenharmony_ci} ns_rcqe; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define NS_RCQE_SIZE 64 /* bytes */ 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci#define ns_rcqe_islast(ns_rcqep) \ 1948c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rcqep)->word_2) != 0x00000000) 1958c2ecf20Sopenharmony_ci#define ns_rcqe_cellheader(ns_rcqep) \ 1968c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rcqep)->word_1)) 1978c2ecf20Sopenharmony_ci#define ns_rcqe_nextbufhandle(ns_rcqep) \ 1988c2ecf20Sopenharmony_ci (le32_to_cpu((ns_rcqep)->word_2)) 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci/* 2018c2ecf20Sopenharmony_ci * SCQ - Segmentation Channel Queue 2028c2ecf20Sopenharmony_ci * 2038c2ecf20Sopenharmony_ci * Written by the device driver, read by the NICStAR. 2048c2ecf20Sopenharmony_ci */ 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_citypedef struct ns_scqe { 2078c2ecf20Sopenharmony_ci u32 word_1; 2088c2ecf20Sopenharmony_ci u32 word_2; 2098c2ecf20Sopenharmony_ci u32 word_3; 2108c2ecf20Sopenharmony_ci u32 word_4; 2118c2ecf20Sopenharmony_ci} ns_scqe; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci /* NOTE: SCQ entries can be either a TBD (Transmit Buffer Descriptors) 2148c2ecf20Sopenharmony_ci or TSR (Transmit Status Requests) */ 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#define NS_SCQE_TYPE_TBD 0x00000000 2178c2ecf20Sopenharmony_ci#define NS_SCQE_TYPE_TSR 0x80000000 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci#define NS_TBD_EOPDU 0x40000000 2208c2ecf20Sopenharmony_ci#define NS_TBD_AAL0 0x00000000 2218c2ecf20Sopenharmony_ci#define NS_TBD_AAL34 0x04000000 2228c2ecf20Sopenharmony_ci#define NS_TBD_AAL5 0x08000000 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci#define NS_TBD_VPI_MASK 0x0FF00000 2258c2ecf20Sopenharmony_ci#define NS_TBD_VCI_MASK 0x000FFFF0 2268c2ecf20Sopenharmony_ci#define NS_TBD_VC_MASK (NS_TBD_VPI_MASK | NS_TBD_VCI_MASK) 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci#define NS_TBD_VPI_SHIFT 20 2298c2ecf20Sopenharmony_ci#define NS_TBD_VCI_SHIFT 4 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci#define ns_tbd_mkword_1(flags, m, n, buflen) \ 2328c2ecf20Sopenharmony_ci (cpu_to_le32((flags) | (m) << 23 | (n) << 16 | (buflen))) 2338c2ecf20Sopenharmony_ci#define ns_tbd_mkword_1_novbr(flags, buflen) \ 2348c2ecf20Sopenharmony_ci (cpu_to_le32((flags) | (buflen) | 0x00810000)) 2358c2ecf20Sopenharmony_ci#define ns_tbd_mkword_3(control, pdulen) \ 2368c2ecf20Sopenharmony_ci (cpu_to_le32((control) << 16 | (pdulen))) 2378c2ecf20Sopenharmony_ci#define ns_tbd_mkword_4(gfc, vpi, vci, pt, clp) \ 2388c2ecf20Sopenharmony_ci (cpu_to_le32((gfc) << 28 | (vpi) << 20 | (vci) << 4 | (pt) << 1 | (clp))) 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci#define NS_TSR_INTENABLE 0x20000000 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci#define NS_TSR_SCDISVBR 0xFFFF /* Use as scdi for VBR SCD */ 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci#define ns_tsr_mkword_1(flags) \ 2458c2ecf20Sopenharmony_ci (cpu_to_le32(NS_SCQE_TYPE_TSR | (flags))) 2468c2ecf20Sopenharmony_ci#define ns_tsr_mkword_2(scdi, scqi) \ 2478c2ecf20Sopenharmony_ci (cpu_to_le32((scdi) << 16 | 0x00008000 | (scqi))) 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci#define ns_scqe_is_tsr(ns_scqep) \ 2508c2ecf20Sopenharmony_ci (le32_to_cpu((ns_scqep)->word_1) & NS_SCQE_TYPE_TSR) 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci#define VBR_SCQ_NUM_ENTRIES 512 2538c2ecf20Sopenharmony_ci#define VBR_SCQSIZE 8192 2548c2ecf20Sopenharmony_ci#define CBR_SCQ_NUM_ENTRIES 64 2558c2ecf20Sopenharmony_ci#define CBR_SCQSIZE 1024 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci#define NS_SCQE_SIZE 16 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci/* 2608c2ecf20Sopenharmony_ci * TSQ - Transmit Status Queue 2618c2ecf20Sopenharmony_ci * 2628c2ecf20Sopenharmony_ci * Written by the NICStAR, read by the device driver. 2638c2ecf20Sopenharmony_ci */ 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_citypedef struct ns_tsi { 2668c2ecf20Sopenharmony_ci u32 word_1; 2678c2ecf20Sopenharmony_ci u32 word_2; 2688c2ecf20Sopenharmony_ci} ns_tsi; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci /* NOTE: The first word can be a status word copied from the TSR which 2718c2ecf20Sopenharmony_ci originated the TSI, or a timer overflow indicator. In this last 2728c2ecf20Sopenharmony_ci case, the value of the first word is all zeroes. */ 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci#define NS_TSI_EMPTY 0x80000000 2758c2ecf20Sopenharmony_ci#define NS_TSI_TIMESTAMP_MASK 0x00FFFFFF 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci#define ns_tsi_isempty(ns_tsip) \ 2788c2ecf20Sopenharmony_ci (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_EMPTY) 2798c2ecf20Sopenharmony_ci#define ns_tsi_gettimestamp(ns_tsip) \ 2808c2ecf20Sopenharmony_ci (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_TIMESTAMP_MASK) 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci#define ns_tsi_init(ns_tsip) \ 2838c2ecf20Sopenharmony_ci ((ns_tsip)->word_2 = cpu_to_le32(NS_TSI_EMPTY)) 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci#define NS_TSQSIZE 8192 2868c2ecf20Sopenharmony_ci#define NS_TSQ_NUM_ENTRIES 1024 2878c2ecf20Sopenharmony_ci#define NS_TSQ_ALIGNMENT 8192 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci#define NS_TSI_SCDISVBR NS_TSR_SCDISVBR 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci#define ns_tsi_tmrof(ns_tsip) \ 2928c2ecf20Sopenharmony_ci (le32_to_cpu((ns_tsip)->word_1) == 0x00000000) 2938c2ecf20Sopenharmony_ci#define ns_tsi_getscdindex(ns_tsip) \ 2948c2ecf20Sopenharmony_ci ((le32_to_cpu((ns_tsip)->word_1) & 0xFFFF0000) >> 16) 2958c2ecf20Sopenharmony_ci#define ns_tsi_getscqpos(ns_tsip) \ 2968c2ecf20Sopenharmony_ci (le32_to_cpu((ns_tsip)->word_1) & 0x00007FFF) 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci/* NICStAR structures located in local SRAM */ 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci/* 3018c2ecf20Sopenharmony_ci * RCT - Receive Connection Table 3028c2ecf20Sopenharmony_ci * 3038c2ecf20Sopenharmony_ci * Written by both the NICStAR and the device driver. 3048c2ecf20Sopenharmony_ci */ 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_citypedef struct ns_rcte { 3078c2ecf20Sopenharmony_ci u32 word_1; 3088c2ecf20Sopenharmony_ci u32 buffer_handle; 3098c2ecf20Sopenharmony_ci u32 dma_address; 3108c2ecf20Sopenharmony_ci u32 aal5_crc32; 3118c2ecf20Sopenharmony_ci} ns_rcte; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci#define NS_RCTE_BSFB 0x00200000 /* Rev. D only */ 3148c2ecf20Sopenharmony_ci#define NS_RCTE_NZGFC 0x00100000 3158c2ecf20Sopenharmony_ci#define NS_RCTE_CONNECTOPEN 0x00080000 3168c2ecf20Sopenharmony_ci#define NS_RCTE_AALMASK 0x00070000 3178c2ecf20Sopenharmony_ci#define NS_RCTE_AAL0 0x00000000 3188c2ecf20Sopenharmony_ci#define NS_RCTE_AAL34 0x00010000 3198c2ecf20Sopenharmony_ci#define NS_RCTE_AAL5 0x00020000 3208c2ecf20Sopenharmony_ci#define NS_RCTE_RCQ 0x00030000 3218c2ecf20Sopenharmony_ci#define NS_RCTE_RAWCELLINTEN 0x00008000 3228c2ecf20Sopenharmony_ci#define NS_RCTE_RXCONSTCELLADDR 0x00004000 3238c2ecf20Sopenharmony_ci#define NS_RCTE_BUFFVALID 0x00002000 3248c2ecf20Sopenharmony_ci#define NS_RCTE_FBDSIZE 0x00001000 3258c2ecf20Sopenharmony_ci#define NS_RCTE_EFCI 0x00000800 3268c2ecf20Sopenharmony_ci#define NS_RCTE_CLP 0x00000400 3278c2ecf20Sopenharmony_ci#define NS_RCTE_CRCERROR 0x00000200 3288c2ecf20Sopenharmony_ci#define NS_RCTE_CELLCOUNT_MASK 0x000001FF 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci#define NS_RCTE_FBDSIZE_SM 0x00000000 3318c2ecf20Sopenharmony_ci#define NS_RCTE_FBDSIZE_LG 0x00001000 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci#define NS_RCT_ENTRY_SIZE 4 /* Number of dwords */ 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci /* NOTE: We could make macros to contruct the first word of the RCTE, 3368c2ecf20Sopenharmony_ci but that doesn't seem to make much sense... */ 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci/* 3398c2ecf20Sopenharmony_ci * FBD - Free Buffer Descriptor 3408c2ecf20Sopenharmony_ci * 3418c2ecf20Sopenharmony_ci * Written by the device driver using via the command register. 3428c2ecf20Sopenharmony_ci */ 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_citypedef struct ns_fbd { 3458c2ecf20Sopenharmony_ci u32 buffer_handle; 3468c2ecf20Sopenharmony_ci u32 dma_address; 3478c2ecf20Sopenharmony_ci} ns_fbd; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci/* 3508c2ecf20Sopenharmony_ci * TST - Transmit Schedule Table 3518c2ecf20Sopenharmony_ci * 3528c2ecf20Sopenharmony_ci * Written by the device driver. 3538c2ecf20Sopenharmony_ci */ 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_citypedef u32 ns_tste; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci#define NS_TST_OPCODE_MASK 0x60000000 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci#define NS_TST_OPCODE_NULL 0x00000000 /* Insert null cell */ 3608c2ecf20Sopenharmony_ci#define NS_TST_OPCODE_FIXED 0x20000000 /* Cell from a fixed rate channel */ 3618c2ecf20Sopenharmony_ci#define NS_TST_OPCODE_VARIABLE 0x40000000 3628c2ecf20Sopenharmony_ci#define NS_TST_OPCODE_END 0x60000000 /* Jump */ 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci#define ns_tste_make(opcode, sramad) (opcode | sramad) 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci /* NOTE: 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci - When the opcode is FIXED, sramad specifies the SRAM address of the 3698c2ecf20Sopenharmony_ci SCD for that fixed rate channel. 3708c2ecf20Sopenharmony_ci - When the opcode is END, sramad specifies the SRAM address of the 3718c2ecf20Sopenharmony_ci location of the next TST entry to read. 3728c2ecf20Sopenharmony_ci */ 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci/* 3758c2ecf20Sopenharmony_ci * SCD - Segmentation Channel Descriptor 3768c2ecf20Sopenharmony_ci * 3778c2ecf20Sopenharmony_ci * Written by both the device driver and the NICStAR 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_citypedef struct ns_scd { 3818c2ecf20Sopenharmony_ci u32 word_1; 3828c2ecf20Sopenharmony_ci u32 word_2; 3838c2ecf20Sopenharmony_ci u32 partial_aal5_crc; 3848c2ecf20Sopenharmony_ci u32 reserved; 3858c2ecf20Sopenharmony_ci ns_scqe cache_a; 3868c2ecf20Sopenharmony_ci ns_scqe cache_b; 3878c2ecf20Sopenharmony_ci} ns_scd; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci#define NS_SCD_BASE_MASK_VAR 0xFFFFE000 /* Variable rate */ 3908c2ecf20Sopenharmony_ci#define NS_SCD_BASE_MASK_FIX 0xFFFFFC00 /* Fixed rate */ 3918c2ecf20Sopenharmony_ci#define NS_SCD_TAIL_MASK_VAR 0x00001FF0 3928c2ecf20Sopenharmony_ci#define NS_SCD_TAIL_MASK_FIX 0x000003F0 3938c2ecf20Sopenharmony_ci#define NS_SCD_HEAD_MASK_VAR 0x00001FF0 3948c2ecf20Sopenharmony_ci#define NS_SCD_HEAD_MASK_FIX 0x000003F0 3958c2ecf20Sopenharmony_ci#define NS_SCD_XMITFOREVER 0x02000000 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci /* NOTE: There are other fields in word 2 of the SCD, but as they should 3988c2ecf20Sopenharmony_ci not be needed in the device driver they are not defined here. */ 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci/* NICStAR local SRAM memory map */ 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci#define NS_RCT 0x00000 4038c2ecf20Sopenharmony_ci#define NS_RCT_32_END 0x03FFF 4048c2ecf20Sopenharmony_ci#define NS_RCT_128_END 0x0FFFF 4058c2ecf20Sopenharmony_ci#define NS_UNUSED_32 0x04000 4068c2ecf20Sopenharmony_ci#define NS_UNUSED_128 0x10000 4078c2ecf20Sopenharmony_ci#define NS_UNUSED_END 0x1BFFF 4088c2ecf20Sopenharmony_ci#define NS_TST_FRSCD 0x1C000 4098c2ecf20Sopenharmony_ci#define NS_TST_FRSCD_END 0x1E7DB 4108c2ecf20Sopenharmony_ci#define NS_VRSCD2 0x1E7DC 4118c2ecf20Sopenharmony_ci#define NS_VRSCD2_END 0x1E7E7 4128c2ecf20Sopenharmony_ci#define NS_VRSCD1 0x1E7E8 4138c2ecf20Sopenharmony_ci#define NS_VRSCD1_END 0x1E7F3 4148c2ecf20Sopenharmony_ci#define NS_VRSCD0 0x1E7F4 4158c2ecf20Sopenharmony_ci#define NS_VRSCD0_END 0x1E7FF 4168c2ecf20Sopenharmony_ci#define NS_RXFIFO 0x1E800 4178c2ecf20Sopenharmony_ci#define NS_RXFIFO_END 0x1F7FF 4188c2ecf20Sopenharmony_ci#define NS_SMFBQ 0x1F800 4198c2ecf20Sopenharmony_ci#define NS_SMFBQ_END 0x1FBFF 4208c2ecf20Sopenharmony_ci#define NS_LGFBQ 0x1FC00 4218c2ecf20Sopenharmony_ci#define NS_LGFBQ_END 0x1FFFF 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci/* NISCtAR operation registers */ 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci/* See Section 3.4 of `IDT77211 NICStAR User Manual' from www.idt.com */ 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_cienum ns_regs { 4288c2ecf20Sopenharmony_ci DR0 = 0x00, /* Data Register 0 R/W */ 4298c2ecf20Sopenharmony_ci DR1 = 0x04, /* Data Register 1 W */ 4308c2ecf20Sopenharmony_ci DR2 = 0x08, /* Data Register 2 W */ 4318c2ecf20Sopenharmony_ci DR3 = 0x0C, /* Data Register 3 W */ 4328c2ecf20Sopenharmony_ci CMD = 0x10, /* Command W */ 4338c2ecf20Sopenharmony_ci CFG = 0x14, /* Configuration R/W */ 4348c2ecf20Sopenharmony_ci STAT = 0x18, /* Status R/W */ 4358c2ecf20Sopenharmony_ci RSQB = 0x1C, /* Receive Status Queue Base W */ 4368c2ecf20Sopenharmony_ci RSQT = 0x20, /* Receive Status Queue Tail R */ 4378c2ecf20Sopenharmony_ci RSQH = 0x24, /* Receive Status Queue Head W */ 4388c2ecf20Sopenharmony_ci CDC = 0x28, /* Cell Drop Counter R/clear */ 4398c2ecf20Sopenharmony_ci VPEC = 0x2C, /* VPI/VCI Lookup Error Count R/clear */ 4408c2ecf20Sopenharmony_ci ICC = 0x30, /* Invalid Cell Count R/clear */ 4418c2ecf20Sopenharmony_ci RAWCT = 0x34, /* Raw Cell Tail R */ 4428c2ecf20Sopenharmony_ci TMR = 0x38, /* Timer R */ 4438c2ecf20Sopenharmony_ci TSTB = 0x3C, /* Transmit Schedule Table Base R/W */ 4448c2ecf20Sopenharmony_ci TSQB = 0x40, /* Transmit Status Queue Base W */ 4458c2ecf20Sopenharmony_ci TSQT = 0x44, /* Transmit Status Queue Tail R */ 4468c2ecf20Sopenharmony_ci TSQH = 0x48, /* Transmit Status Queue Head W */ 4478c2ecf20Sopenharmony_ci GP = 0x4C, /* General Purpose R/W */ 4488c2ecf20Sopenharmony_ci VPM = 0x50 /* VPI/VCI Mask W */ 4498c2ecf20Sopenharmony_ci}; 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ci/* NICStAR commands issued to the CMD register */ 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci/* Top 4 bits are command opcode, lower 28 are parameters. */ 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci#define NS_CMD_NO_OPERATION 0x00000000 4568c2ecf20Sopenharmony_ci /* params always 0 */ 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci#define NS_CMD_OPENCLOSE_CONNECTION 0x20000000 4598c2ecf20Sopenharmony_ci /* b19{1=open,0=close} b18-2{SRAM addr} */ 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci#define NS_CMD_WRITE_SRAM 0x40000000 4628c2ecf20Sopenharmony_ci /* b18-2{SRAM addr} b1-0{burst size} */ 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci#define NS_CMD_READ_SRAM 0x50000000 4658c2ecf20Sopenharmony_ci /* b18-2{SRAM addr} */ 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci#define NS_CMD_WRITE_FREEBUFQ 0x60000000 4688c2ecf20Sopenharmony_ci /* b0{large buf indicator} */ 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci#define NS_CMD_READ_UTILITY 0x80000000 4718c2ecf20Sopenharmony_ci /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */ 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci#define NS_CMD_WRITE_UTILITY 0x90000000 4748c2ecf20Sopenharmony_ci /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */ 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci#define NS_CMD_OPEN_CONNECTION (NS_CMD_OPENCLOSE_CONNECTION | 0x00080000) 4778c2ecf20Sopenharmony_ci#define NS_CMD_CLOSE_CONNECTION NS_CMD_OPENCLOSE_CONNECTION 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci/* NICStAR configuration bits */ 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_ci#define NS_CFG_SWRST 0x80000000 /* Software Reset */ 4828c2ecf20Sopenharmony_ci#define NS_CFG_RXPATH 0x20000000 /* Receive Path Enable */ 4838c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE_MASK 0x18000000 /* Small Receive Buffer Size */ 4848c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE_MASK 0x06000000 /* Large Receive Buffer Size */ 4858c2ecf20Sopenharmony_ci#define NS_CFG_EFBIE 0x01000000 /* Empty Free Buffer Queue 4868c2ecf20Sopenharmony_ci Interrupt Enable */ 4878c2ecf20Sopenharmony_ci#define NS_CFG_RSQSIZE_MASK 0x00C00000 /* Receive Status Queue Size */ 4888c2ecf20Sopenharmony_ci#define NS_CFG_ICACCEPT 0x00200000 /* Invalid Cell Accept */ 4898c2ecf20Sopenharmony_ci#define NS_CFG_IGNOREGFC 0x00100000 /* Ignore General Flow Control */ 4908c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS_MASK 0x000C0000 /* VPI/VCI Bits Size Select */ 4918c2ecf20Sopenharmony_ci#define NS_CFG_RCTSIZE_MASK 0x00030000 /* Receive Connection Table Size */ 4928c2ecf20Sopenharmony_ci#define NS_CFG_VCERRACCEPT 0x00008000 /* VPI/VCI Error Cell Accept */ 4938c2ecf20Sopenharmony_ci#define NS_CFG_RXINT_MASK 0x00007000 /* End of Receive PDU Interrupt 4948c2ecf20Sopenharmony_ci Handling */ 4958c2ecf20Sopenharmony_ci#define NS_CFG_RAWIE 0x00000800 /* Raw Cell Qu' Interrupt Enable */ 4968c2ecf20Sopenharmony_ci#define NS_CFG_RSQAFIE 0x00000400 /* Receive Queue Almost Full 4978c2ecf20Sopenharmony_ci Interrupt Enable */ 4988c2ecf20Sopenharmony_ci#define NS_CFG_RXRM 0x00000200 /* Receive RM Cells */ 4998c2ecf20Sopenharmony_ci#define NS_CFG_TMRROIE 0x00000080 /* Timer Roll Over Interrupt 5008c2ecf20Sopenharmony_ci Enable */ 5018c2ecf20Sopenharmony_ci#define NS_CFG_TXEN 0x00000020 /* Transmit Operation Enable */ 5028c2ecf20Sopenharmony_ci#define NS_CFG_TXIE 0x00000010 /* Transmit Status Interrupt 5038c2ecf20Sopenharmony_ci Enable */ 5048c2ecf20Sopenharmony_ci#define NS_CFG_TXURIE 0x00000008 /* Transmit Under-run Interrupt 5058c2ecf20Sopenharmony_ci Enable */ 5068c2ecf20Sopenharmony_ci#define NS_CFG_UMODE 0x00000004 /* Utopia Mode (cell/byte) Select */ 5078c2ecf20Sopenharmony_ci#define NS_CFG_TSQFIE 0x00000002 /* Transmit Status Queue Full 5088c2ecf20Sopenharmony_ci Interrupt Enable */ 5098c2ecf20Sopenharmony_ci#define NS_CFG_PHYIE 0x00000001 /* PHY Interrupt Enable */ 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE_48 0x00000000 5128c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE_96 0x08000000 5138c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE_240 0x10000000 5148c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE_2048 0x18000000 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE_2048 0x00000000 5178c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE_4096 0x02000000 5188c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE_8192 0x04000000 5198c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE_16384 0x06000000 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci#define NS_CFG_RSQSIZE_2048 0x00000000 5228c2ecf20Sopenharmony_ci#define NS_CFG_RSQSIZE_4096 0x00400000 5238c2ecf20Sopenharmony_ci#define NS_CFG_RSQSIZE_8192 0x00800000 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS_0 0x00000000 5268c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS_1 0x00040000 5278c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS_2 0x00080000 5288c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS_8 0x000C0000 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci#define NS_CFG_RCTSIZE_4096_ENTRIES 0x00000000 5318c2ecf20Sopenharmony_ci#define NS_CFG_RCTSIZE_8192_ENTRIES 0x00010000 5328c2ecf20Sopenharmony_ci#define NS_CFG_RCTSIZE_16384_ENTRIES 0x00020000 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci#define NS_CFG_RXINT_NOINT 0x00000000 5358c2ecf20Sopenharmony_ci#define NS_CFG_RXINT_NODELAY 0x00001000 5368c2ecf20Sopenharmony_ci#define NS_CFG_RXINT_314US 0x00002000 5378c2ecf20Sopenharmony_ci#define NS_CFG_RXINT_624US 0x00003000 5388c2ecf20Sopenharmony_ci#define NS_CFG_RXINT_899US 0x00004000 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci/* NICStAR STATus bits */ 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_ci#define NS_STAT_SFBQC_MASK 0xFF000000 /* hi 8 bits Small Buffer Queue Count */ 5438c2ecf20Sopenharmony_ci#define NS_STAT_LFBQC_MASK 0x00FF0000 /* hi 8 bits Large Buffer Queue Count */ 5448c2ecf20Sopenharmony_ci#define NS_STAT_TSIF 0x00008000 /* Transmit Status Queue Indicator */ 5458c2ecf20Sopenharmony_ci#define NS_STAT_TXICP 0x00004000 /* Transmit Incomplete PDU */ 5468c2ecf20Sopenharmony_ci#define NS_STAT_TSQF 0x00001000 /* Transmit Status Queue Full */ 5478c2ecf20Sopenharmony_ci#define NS_STAT_TMROF 0x00000800 /* Timer Overflow */ 5488c2ecf20Sopenharmony_ci#define NS_STAT_PHYI 0x00000400 /* PHY Device Interrupt */ 5498c2ecf20Sopenharmony_ci#define NS_STAT_CMDBZ 0x00000200 /* Command Busy */ 5508c2ecf20Sopenharmony_ci#define NS_STAT_SFBQF 0x00000100 /* Small Buffer Queue Full */ 5518c2ecf20Sopenharmony_ci#define NS_STAT_LFBQF 0x00000080 /* Large Buffer Queue Full */ 5528c2ecf20Sopenharmony_ci#define NS_STAT_RSQF 0x00000040 /* Receive Status Queue Full */ 5538c2ecf20Sopenharmony_ci#define NS_STAT_EOPDU 0x00000020 /* End of PDU */ 5548c2ecf20Sopenharmony_ci#define NS_STAT_RAWCF 0x00000010 /* Raw Cell Flag */ 5558c2ecf20Sopenharmony_ci#define NS_STAT_SFBQE 0x00000008 /* Small Buffer Queue Empty */ 5568c2ecf20Sopenharmony_ci#define NS_STAT_LFBQE 0x00000004 /* Large Buffer Queue Empty */ 5578c2ecf20Sopenharmony_ci#define NS_STAT_RSQAF 0x00000002 /* Receive Status Queue Almost Full */ 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci#define ns_stat_sfbqc_get(stat) (((stat) & NS_STAT_SFBQC_MASK) >> 23) 5608c2ecf20Sopenharmony_ci#define ns_stat_lfbqc_get(stat) (((stat) & NS_STAT_LFBQC_MASK) >> 15) 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci/* #defines which depend on other #defines */ 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci#define NS_TST0 NS_TST_FRSCD 5658c2ecf20Sopenharmony_ci#define NS_TST1 (NS_TST_FRSCD + NS_TST_NUM_ENTRIES + 1) 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci#define NS_FRSCD (NS_TST1 + NS_TST_NUM_ENTRIES + 1) 5688c2ecf20Sopenharmony_ci#define NS_FRSCD_SIZE 12 /* 12 dwords */ 5698c2ecf20Sopenharmony_ci#define NS_FRSCD_NUM ((NS_TST_FRSCD_END + 1 - NS_FRSCD) / NS_FRSCD_SIZE) 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci#if (NS_SMBUFSIZE == 48) 5728c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_48 5738c2ecf20Sopenharmony_ci#elif (NS_SMBUFSIZE == 96) 5748c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_96 5758c2ecf20Sopenharmony_ci#elif (NS_SMBUFSIZE == 240) 5768c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_240 5778c2ecf20Sopenharmony_ci#elif (NS_SMBUFSIZE == 2048) 5788c2ecf20Sopenharmony_ci#define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_2048 5798c2ecf20Sopenharmony_ci#else 5808c2ecf20Sopenharmony_ci#error NS_SMBUFSIZE is incorrect in nicstar.h 5818c2ecf20Sopenharmony_ci#endif /* NS_SMBUFSIZE */ 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci#if (NS_LGBUFSIZE == 2048) 5848c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_2048 5858c2ecf20Sopenharmony_ci#elif (NS_LGBUFSIZE == 4096) 5868c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_4096 5878c2ecf20Sopenharmony_ci#elif (NS_LGBUFSIZE == 8192) 5888c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_8192 5898c2ecf20Sopenharmony_ci#elif (NS_LGBUFSIZE == 16384) 5908c2ecf20Sopenharmony_ci#define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_16384 5918c2ecf20Sopenharmony_ci#else 5928c2ecf20Sopenharmony_ci#error NS_LGBUFSIZE is incorrect in nicstar.h 5938c2ecf20Sopenharmony_ci#endif /* NS_LGBUFSIZE */ 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci#if (NS_RSQSIZE == 2048) 5968c2ecf20Sopenharmony_ci#define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_2048 5978c2ecf20Sopenharmony_ci#elif (NS_RSQSIZE == 4096) 5988c2ecf20Sopenharmony_ci#define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_4096 5998c2ecf20Sopenharmony_ci#elif (NS_RSQSIZE == 8192) 6008c2ecf20Sopenharmony_ci#define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_8192 6018c2ecf20Sopenharmony_ci#else 6028c2ecf20Sopenharmony_ci#error NS_RSQSIZE is incorrect in nicstar.h 6038c2ecf20Sopenharmony_ci#endif /* NS_RSQSIZE */ 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci#if (NS_VPIBITS == 0) 6068c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_0 6078c2ecf20Sopenharmony_ci#elif (NS_VPIBITS == 1) 6088c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_1 6098c2ecf20Sopenharmony_ci#elif (NS_VPIBITS == 2) 6108c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_2 6118c2ecf20Sopenharmony_ci#elif (NS_VPIBITS == 8) 6128c2ecf20Sopenharmony_ci#define NS_CFG_VPIBITS NS_CFG_VPIBITS_8 6138c2ecf20Sopenharmony_ci#else 6148c2ecf20Sopenharmony_ci#error NS_VPIBITS is incorrect in nicstar.h 6158c2ecf20Sopenharmony_ci#endif /* NS_VPIBITS */ 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci#ifdef RCQ_SUPPORT 6188c2ecf20Sopenharmony_ci#define NS_CFG_RAWIE_OPT NS_CFG_RAWIE 6198c2ecf20Sopenharmony_ci#else 6208c2ecf20Sopenharmony_ci#define NS_CFG_RAWIE_OPT 0x00000000 6218c2ecf20Sopenharmony_ci#endif /* RCQ_SUPPORT */ 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci#ifdef ENABLE_TSQFIE 6248c2ecf20Sopenharmony_ci#define NS_CFG_TSQFIE_OPT NS_CFG_TSQFIE 6258c2ecf20Sopenharmony_ci#else 6268c2ecf20Sopenharmony_ci#define NS_CFG_TSQFIE_OPT 0x00000000 6278c2ecf20Sopenharmony_ci#endif /* ENABLE_TSQFIE */ 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci/* PCI stuff */ 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci#ifndef PCI_VENDOR_ID_IDT 6328c2ecf20Sopenharmony_ci#define PCI_VENDOR_ID_IDT 0x111D 6338c2ecf20Sopenharmony_ci#endif /* PCI_VENDOR_ID_IDT */ 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci#ifndef PCI_DEVICE_ID_IDT_IDT77201 6368c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_IDT_IDT77201 0x0001 6378c2ecf20Sopenharmony_ci#endif /* PCI_DEVICE_ID_IDT_IDT77201 */ 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ci/* Device driver structures */ 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_cistruct ns_skb_prv { 6428c2ecf20Sopenharmony_ci u32 buf_type; /* BUF_SM/BUF_LG/BUF_NONE */ 6438c2ecf20Sopenharmony_ci u32 dma; 6448c2ecf20Sopenharmony_ci int iovcnt; 6458c2ecf20Sopenharmony_ci}; 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_ci#define NS_PRV_BUFTYPE(skb) \ 6488c2ecf20Sopenharmony_ci (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->buf_type) 6498c2ecf20Sopenharmony_ci#define NS_PRV_DMA(skb) \ 6508c2ecf20Sopenharmony_ci (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->dma) 6518c2ecf20Sopenharmony_ci#define NS_PRV_IOVCNT(skb) \ 6528c2ecf20Sopenharmony_ci (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->iovcnt) 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_citypedef struct tsq_info { 6558c2ecf20Sopenharmony_ci void *org; 6568c2ecf20Sopenharmony_ci dma_addr_t dma; 6578c2ecf20Sopenharmony_ci ns_tsi *base; 6588c2ecf20Sopenharmony_ci ns_tsi *next; 6598c2ecf20Sopenharmony_ci ns_tsi *last; 6608c2ecf20Sopenharmony_ci} tsq_info; 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_citypedef struct scq_info { 6638c2ecf20Sopenharmony_ci void *org; 6648c2ecf20Sopenharmony_ci dma_addr_t dma; 6658c2ecf20Sopenharmony_ci ns_scqe *base; 6668c2ecf20Sopenharmony_ci ns_scqe *last; 6678c2ecf20Sopenharmony_ci ns_scqe *next; 6688c2ecf20Sopenharmony_ci volatile ns_scqe *tail; /* Not related to the nicstar register */ 6698c2ecf20Sopenharmony_ci unsigned num_entries; 6708c2ecf20Sopenharmony_ci struct sk_buff **skb; /* Pointer to an array of pointers 6718c2ecf20Sopenharmony_ci to the sk_buffs used for tx */ 6728c2ecf20Sopenharmony_ci u32 scd; /* SRAM address of the corresponding 6738c2ecf20Sopenharmony_ci SCD */ 6748c2ecf20Sopenharmony_ci int tbd_count; /* Only meaningful on variable rate */ 6758c2ecf20Sopenharmony_ci wait_queue_head_t scqfull_waitq; 6768c2ecf20Sopenharmony_ci volatile char full; /* SCQ full indicator */ 6778c2ecf20Sopenharmony_ci spinlock_t lock; /* SCQ spinlock */ 6788c2ecf20Sopenharmony_ci} scq_info; 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_citypedef struct rsq_info { 6818c2ecf20Sopenharmony_ci void *org; 6828c2ecf20Sopenharmony_ci dma_addr_t dma; 6838c2ecf20Sopenharmony_ci ns_rsqe *base; 6848c2ecf20Sopenharmony_ci ns_rsqe *next; 6858c2ecf20Sopenharmony_ci ns_rsqe *last; 6868c2ecf20Sopenharmony_ci} rsq_info; 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_citypedef struct skb_pool { 6898c2ecf20Sopenharmony_ci volatile int count; /* number of buffers in the queue */ 6908c2ecf20Sopenharmony_ci struct sk_buff_head queue; 6918c2ecf20Sopenharmony_ci} skb_pool; 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_ci/* NOTE: for small and large buffer pools, the count is not used, as the 6948c2ecf20Sopenharmony_ci actual value used for buffer management is the one read from the 6958c2ecf20Sopenharmony_ci card. */ 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_citypedef struct vc_map { 6988c2ecf20Sopenharmony_ci volatile unsigned int tx:1; /* TX vc? */ 6998c2ecf20Sopenharmony_ci volatile unsigned int rx:1; /* RX vc? */ 7008c2ecf20Sopenharmony_ci struct atm_vcc *tx_vcc, *rx_vcc; 7018c2ecf20Sopenharmony_ci struct sk_buff *rx_iov; /* RX iovector skb */ 7028c2ecf20Sopenharmony_ci scq_info *scq; /* To keep track of the SCQ */ 7038c2ecf20Sopenharmony_ci u32 cbr_scd; /* SRAM address of the corresponding 7048c2ecf20Sopenharmony_ci SCD. 0x00000000 for UBR/VBR/ABR */ 7058c2ecf20Sopenharmony_ci int tbd_count; 7068c2ecf20Sopenharmony_ci} vc_map; 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_citypedef struct ns_dev { 7098c2ecf20Sopenharmony_ci int index; /* Card ID to the device driver */ 7108c2ecf20Sopenharmony_ci int sram_size; /* In k x 32bit words. 32 or 128 */ 7118c2ecf20Sopenharmony_ci void __iomem *membase; /* Card's memory base address */ 7128c2ecf20Sopenharmony_ci unsigned long max_pcr; 7138c2ecf20Sopenharmony_ci int rct_size; /* Number of entries */ 7148c2ecf20Sopenharmony_ci int vpibits; 7158c2ecf20Sopenharmony_ci int vcibits; 7168c2ecf20Sopenharmony_ci struct pci_dev *pcidev; 7178c2ecf20Sopenharmony_ci struct idr idr; 7188c2ecf20Sopenharmony_ci struct atm_dev *atmdev; 7198c2ecf20Sopenharmony_ci tsq_info tsq; 7208c2ecf20Sopenharmony_ci rsq_info rsq; 7218c2ecf20Sopenharmony_ci scq_info *scq0, *scq1, *scq2; /* VBR SCQs */ 7228c2ecf20Sopenharmony_ci skb_pool sbpool; /* Small buffers */ 7238c2ecf20Sopenharmony_ci skb_pool lbpool; /* Large buffers */ 7248c2ecf20Sopenharmony_ci skb_pool hbpool; /* Pre-allocated huge buffers */ 7258c2ecf20Sopenharmony_ci skb_pool iovpool; /* iovector buffers */ 7268c2ecf20Sopenharmony_ci volatile int efbie; /* Empty free buf. queue int. enabled */ 7278c2ecf20Sopenharmony_ci volatile u32 tst_addr; /* SRAM address of the TST in use */ 7288c2ecf20Sopenharmony_ci volatile int tst_free_entries; 7298c2ecf20Sopenharmony_ci vc_map vcmap[NS_MAX_RCTSIZE]; 7308c2ecf20Sopenharmony_ci vc_map *tste2vc[NS_TST_NUM_ENTRIES]; 7318c2ecf20Sopenharmony_ci vc_map *scd2vc[NS_FRSCD_NUM]; 7328c2ecf20Sopenharmony_ci buf_nr sbnr; 7338c2ecf20Sopenharmony_ci buf_nr lbnr; 7348c2ecf20Sopenharmony_ci buf_nr hbnr; 7358c2ecf20Sopenharmony_ci buf_nr iovnr; 7368c2ecf20Sopenharmony_ci int sbfqc; 7378c2ecf20Sopenharmony_ci int lbfqc; 7388c2ecf20Sopenharmony_ci struct sk_buff *sm_handle; 7398c2ecf20Sopenharmony_ci u32 sm_addr; 7408c2ecf20Sopenharmony_ci struct sk_buff *lg_handle; 7418c2ecf20Sopenharmony_ci u32 lg_addr; 7428c2ecf20Sopenharmony_ci struct sk_buff *rcbuf; /* Current raw cell buffer */ 7438c2ecf20Sopenharmony_ci struct ns_rcqe *rawcell; 7448c2ecf20Sopenharmony_ci u32 rawch; /* Raw cell queue head */ 7458c2ecf20Sopenharmony_ci unsigned intcnt; /* Interrupt counter */ 7468c2ecf20Sopenharmony_ci spinlock_t int_lock; /* Interrupt lock */ 7478c2ecf20Sopenharmony_ci spinlock_t res_lock; /* Card resource lock */ 7488c2ecf20Sopenharmony_ci} ns_dev; 7498c2ecf20Sopenharmony_ci 7508c2ecf20Sopenharmony_ci /* NOTE: Each tste2vc entry relates a given TST entry to the corresponding 7518c2ecf20Sopenharmony_ci CBR vc. If the entry is not allocated, it must be NULL. 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_ci There are two TSTs so the driver can modify them on the fly 7548c2ecf20Sopenharmony_ci without stopping the transmission. 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci scd2vc allows us to find out unused fixed rate SCDs, because 7578c2ecf20Sopenharmony_ci they must have a NULL pointer here. */ 7588c2ecf20Sopenharmony_ci 7598c2ecf20Sopenharmony_ci#endif /* _LINUX_NICSTAR_H_ */ 760