nicstar.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * nicstar.h
  4. *
  5. * Header file for the nicstar device driver.
  6. *
  7. * Author: Rui Prior (rprior@inescn.pt)
  8. * PowerPC support by Jay Talbott (jay_talbott@mcg.mot.com) April 1999
  9. *
  10. * (C) INESC 1998
  11. */
  12. #ifndef _LINUX_NICSTAR_H_
  13. #define _LINUX_NICSTAR_H_
  14. /* Includes */
  15. #include <linux/types.h>
  16. #include <linux/pci.h>
  17. #include <linux/idr.h>
  18. #include <linux/uio.h>
  19. #include <linux/skbuff.h>
  20. #include <linux/atmdev.h>
  21. #include <linux/atm_nicstar.h>
  22. /* Options */
  23. #define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards
  24. controlled by the device driver. Must
  25. be <= 5 */
  26. #undef RCQ_SUPPORT /* Do not define this for now */
  27. #define NS_TST_NUM_ENTRIES 2340 /* + 1 for return */
  28. #define NS_TST_RESERVED 340 /* N. entries reserved for UBR/ABR/VBR */
  29. #define NS_SMBUFSIZE 48 /* 48, 96, 240 or 2048 */
  30. #define NS_LGBUFSIZE 16384 /* 2048, 4096, 8192 or 16384 */
  31. #define NS_RSQSIZE 8192 /* 2048, 4096 or 8192 */
  32. #define NS_VPIBITS 2 /* 0, 1, 2, or 8 */
  33. #define NS_MAX_RCTSIZE 4096 /* Number of entries. 4096 or 16384.
  34. Define 4096 only if (all) your card(s)
  35. have 32K x 32bit SRAM, in which case
  36. setting this to 16384 will just waste a
  37. lot of memory.
  38. Setting this to 4096 for a card with
  39. 128K x 32bit SRAM will limit the maximum
  40. VCI. */
  41. /*#define NS_PCI_LATENCY 64*//* Must be a multiple of 32 */
  42. /* Number of buffers initially allocated */
  43. #define NUM_SB 32 /* Must be even */
  44. #define NUM_LB 24 /* Must be even */
  45. #define NUM_HB 8 /* Pre-allocated huge buffers */
  46. #define NUM_IOVB 48 /* Iovec buffers */
  47. /* Lower level for count of buffers */
  48. #define MIN_SB 8 /* Must be even */
  49. #define MIN_LB 8 /* Must be even */
  50. #define MIN_HB 6
  51. #define MIN_IOVB 8
  52. /* Upper level for count of buffers */
  53. #define MAX_SB 64 /* Must be even, <= 508 */
  54. #define MAX_LB 48 /* Must be even, <= 508 */
  55. #define MAX_HB 10
  56. #define MAX_IOVB 80
  57. /* These are the absolute maximum allowed for the ioctl() */
  58. #define TOP_SB 256 /* Must be even, <= 508 */
  59. #define TOP_LB 128 /* Must be even, <= 508 */
  60. #define TOP_HB 64
  61. #define TOP_IOVB 256
  62. #define MAX_TBD_PER_VC 1 /* Number of TBDs before a TSR */
  63. #define MAX_TBD_PER_SCQ 10 /* Only meaningful for variable rate SCQs */
  64. #undef ENABLE_TSQFIE
  65. #define SCQFULL_TIMEOUT (5 * HZ)
  66. #define NS_POLL_PERIOD (HZ)
  67. #define PCR_TOLERANCE (1.0001)
  68. /* ESI stuff */
  69. #define NICSTAR_EPROM_MAC_ADDR_OFFSET 0x6C
  70. #define NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT 0xF6
  71. /* #defines */
  72. #define NS_IOREMAP_SIZE 4096
  73. /*
  74. * BUF_XX distinguish the Rx buffers depending on their (small/large) size.
  75. * BUG_SM and BUG_LG are both used by the driver and the device.
  76. * BUF_NONE is only used by the driver.
  77. */
  78. #define BUF_SM 0x00000000 /* These two are used for push_rxbufs() */
  79. #define BUF_LG 0x00000001 /* CMD, Write_FreeBufQ, LBUF bit */
  80. #define BUF_NONE 0xffffffff /* Software only: */
  81. #define NS_HBUFSIZE 65568 /* Size of max. AAL5 PDU */
  82. #define NS_MAX_IOVECS (2 + (65568 - NS_SMBUFSIZE) / \
  83. (NS_LGBUFSIZE - (NS_LGBUFSIZE % 48)))
  84. #define NS_IOVBUFSIZE (NS_MAX_IOVECS * (sizeof(struct iovec)))
  85. #define NS_SMBUFSIZE_USABLE (NS_SMBUFSIZE - NS_SMBUFSIZE % 48)
  86. #define NS_LGBUFSIZE_USABLE (NS_LGBUFSIZE - NS_LGBUFSIZE % 48)
  87. #define NS_AAL0_HEADER (ATM_AAL0_SDU - ATM_CELL_PAYLOAD) /* 4 bytes */
  88. #define NS_SMSKBSIZE (NS_SMBUFSIZE + NS_AAL0_HEADER)
  89. #define NS_LGSKBSIZE (NS_SMBUFSIZE + NS_LGBUFSIZE)
  90. /* NICStAR structures located in host memory */
  91. /*
  92. * RSQ - Receive Status Queue
  93. *
  94. * Written by the NICStAR, read by the device driver.
  95. */
  96. typedef struct ns_rsqe {
  97. u32 word_1;
  98. u32 buffer_handle;
  99. u32 final_aal5_crc32;
  100. u32 word_4;
  101. } ns_rsqe;
  102. #define ns_rsqe_vpi(ns_rsqep) \
  103. ((le32_to_cpu((ns_rsqep)->word_1) & 0x00FF0000) >> 16)
  104. #define ns_rsqe_vci(ns_rsqep) \
  105. (le32_to_cpu((ns_rsqep)->word_1) & 0x0000FFFF)
  106. #define NS_RSQE_VALID 0x80000000
  107. #define NS_RSQE_NZGFC 0x00004000
  108. #define NS_RSQE_EOPDU 0x00002000
  109. #define NS_RSQE_BUFSIZE 0x00001000
  110. #define NS_RSQE_CONGESTION 0x00000800
  111. #define NS_RSQE_CLP 0x00000400
  112. #define NS_RSQE_CRCERR 0x00000200
  113. #define NS_RSQE_BUFSIZE_SM 0x00000000
  114. #define NS_RSQE_BUFSIZE_LG 0x00001000
  115. #define ns_rsqe_valid(ns_rsqep) \
  116. (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_VALID)
  117. #define ns_rsqe_nzgfc(ns_rsqep) \
  118. (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_NZGFC)
  119. #define ns_rsqe_eopdu(ns_rsqep) \
  120. (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_EOPDU)
  121. #define ns_rsqe_bufsize(ns_rsqep) \
  122. (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_BUFSIZE)
  123. #define ns_rsqe_congestion(ns_rsqep) \
  124. (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CONGESTION)
  125. #define ns_rsqe_clp(ns_rsqep) \
  126. (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CLP)
  127. #define ns_rsqe_crcerr(ns_rsqep) \
  128. (le32_to_cpu((ns_rsqep)->word_4) & NS_RSQE_CRCERR)
  129. #define ns_rsqe_cellcount(ns_rsqep) \
  130. (le32_to_cpu((ns_rsqep)->word_4) & 0x000001FF)
  131. #define ns_rsqe_init(ns_rsqep) \
  132. ((ns_rsqep)->word_4 = cpu_to_le32(0x00000000))
  133. #define NS_RSQ_NUM_ENTRIES (NS_RSQSIZE / 16)
  134. #define NS_RSQ_ALIGNMENT NS_RSQSIZE
  135. /*
  136. * RCQ - Raw Cell Queue
  137. *
  138. * Written by the NICStAR, read by the device driver.
  139. */
  140. typedef struct cell_payload {
  141. u32 word[12];
  142. } cell_payload;
  143. typedef struct ns_rcqe {
  144. u32 word_1;
  145. u32 word_2;
  146. u32 word_3;
  147. u32 word_4;
  148. cell_payload payload;
  149. } ns_rcqe;
  150. #define NS_RCQE_SIZE 64 /* bytes */
  151. #define ns_rcqe_islast(ns_rcqep) \
  152. (le32_to_cpu((ns_rcqep)->word_2) != 0x00000000)
  153. #define ns_rcqe_cellheader(ns_rcqep) \
  154. (le32_to_cpu((ns_rcqep)->word_1))
  155. #define ns_rcqe_nextbufhandle(ns_rcqep) \
  156. (le32_to_cpu((ns_rcqep)->word_2))
  157. /*
  158. * SCQ - Segmentation Channel Queue
  159. *
  160. * Written by the device driver, read by the NICStAR.
  161. */
  162. typedef struct ns_scqe {
  163. u32 word_1;
  164. u32 word_2;
  165. u32 word_3;
  166. u32 word_4;
  167. } ns_scqe;
  168. /* NOTE: SCQ entries can be either a TBD (Transmit Buffer Descriptors)
  169. or TSR (Transmit Status Requests) */
  170. #define NS_SCQE_TYPE_TBD 0x00000000
  171. #define NS_SCQE_TYPE_TSR 0x80000000
  172. #define NS_TBD_EOPDU 0x40000000
  173. #define NS_TBD_AAL0 0x00000000
  174. #define NS_TBD_AAL34 0x04000000
  175. #define NS_TBD_AAL5 0x08000000
  176. #define NS_TBD_VPI_MASK 0x0FF00000
  177. #define NS_TBD_VCI_MASK 0x000FFFF0
  178. #define NS_TBD_VC_MASK (NS_TBD_VPI_MASK | NS_TBD_VCI_MASK)
  179. #define NS_TBD_VPI_SHIFT 20
  180. #define NS_TBD_VCI_SHIFT 4
  181. #define ns_tbd_mkword_1(flags, m, n, buflen) \
  182. (cpu_to_le32((flags) | (m) << 23 | (n) << 16 | (buflen)))
  183. #define ns_tbd_mkword_1_novbr(flags, buflen) \
  184. (cpu_to_le32((flags) | (buflen) | 0x00810000))
  185. #define ns_tbd_mkword_3(control, pdulen) \
  186. (cpu_to_le32((control) << 16 | (pdulen)))
  187. #define ns_tbd_mkword_4(gfc, vpi, vci, pt, clp) \
  188. (cpu_to_le32((gfc) << 28 | (vpi) << 20 | (vci) << 4 | (pt) << 1 | (clp)))
  189. #define NS_TSR_INTENABLE 0x20000000
  190. #define NS_TSR_SCDISVBR 0xFFFF /* Use as scdi for VBR SCD */
  191. #define ns_tsr_mkword_1(flags) \
  192. (cpu_to_le32(NS_SCQE_TYPE_TSR | (flags)))
  193. #define ns_tsr_mkword_2(scdi, scqi) \
  194. (cpu_to_le32((scdi) << 16 | 0x00008000 | (scqi)))
  195. #define ns_scqe_is_tsr(ns_scqep) \
  196. (le32_to_cpu((ns_scqep)->word_1) & NS_SCQE_TYPE_TSR)
  197. #define VBR_SCQ_NUM_ENTRIES 512
  198. #define VBR_SCQSIZE 8192
  199. #define CBR_SCQ_NUM_ENTRIES 64
  200. #define CBR_SCQSIZE 1024
  201. #define NS_SCQE_SIZE 16
  202. /*
  203. * TSQ - Transmit Status Queue
  204. *
  205. * Written by the NICStAR, read by the device driver.
  206. */
  207. typedef struct ns_tsi {
  208. u32 word_1;
  209. u32 word_2;
  210. } ns_tsi;
  211. /* NOTE: The first word can be a status word copied from the TSR which
  212. originated the TSI, or a timer overflow indicator. In this last
  213. case, the value of the first word is all zeroes. */
  214. #define NS_TSI_EMPTY 0x80000000
  215. #define NS_TSI_TIMESTAMP_MASK 0x00FFFFFF
  216. #define ns_tsi_isempty(ns_tsip) \
  217. (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_EMPTY)
  218. #define ns_tsi_gettimestamp(ns_tsip) \
  219. (le32_to_cpu((ns_tsip)->word_2) & NS_TSI_TIMESTAMP_MASK)
  220. #define ns_tsi_init(ns_tsip) \
  221. ((ns_tsip)->word_2 = cpu_to_le32(NS_TSI_EMPTY))
  222. #define NS_TSQSIZE 8192
  223. #define NS_TSQ_NUM_ENTRIES 1024
  224. #define NS_TSQ_ALIGNMENT 8192
  225. #define NS_TSI_SCDISVBR NS_TSR_SCDISVBR
  226. #define ns_tsi_tmrof(ns_tsip) \
  227. (le32_to_cpu((ns_tsip)->word_1) == 0x00000000)
  228. #define ns_tsi_getscdindex(ns_tsip) \
  229. ((le32_to_cpu((ns_tsip)->word_1) & 0xFFFF0000) >> 16)
  230. #define ns_tsi_getscqpos(ns_tsip) \
  231. (le32_to_cpu((ns_tsip)->word_1) & 0x00007FFF)
  232. /* NICStAR structures located in local SRAM */
  233. /*
  234. * RCT - Receive Connection Table
  235. *
  236. * Written by both the NICStAR and the device driver.
  237. */
  238. typedef struct ns_rcte {
  239. u32 word_1;
  240. u32 buffer_handle;
  241. u32 dma_address;
  242. u32 aal5_crc32;
  243. } ns_rcte;
  244. #define NS_RCTE_BSFB 0x00200000 /* Rev. D only */
  245. #define NS_RCTE_NZGFC 0x00100000
  246. #define NS_RCTE_CONNECTOPEN 0x00080000
  247. #define NS_RCTE_AALMASK 0x00070000
  248. #define NS_RCTE_AAL0 0x00000000
  249. #define NS_RCTE_AAL34 0x00010000
  250. #define NS_RCTE_AAL5 0x00020000
  251. #define NS_RCTE_RCQ 0x00030000
  252. #define NS_RCTE_RAWCELLINTEN 0x00008000
  253. #define NS_RCTE_RXCONSTCELLADDR 0x00004000
  254. #define NS_RCTE_BUFFVALID 0x00002000
  255. #define NS_RCTE_FBDSIZE 0x00001000
  256. #define NS_RCTE_EFCI 0x00000800
  257. #define NS_RCTE_CLP 0x00000400
  258. #define NS_RCTE_CRCERROR 0x00000200
  259. #define NS_RCTE_CELLCOUNT_MASK 0x000001FF
  260. #define NS_RCTE_FBDSIZE_SM 0x00000000
  261. #define NS_RCTE_FBDSIZE_LG 0x00001000
  262. #define NS_RCT_ENTRY_SIZE 4 /* Number of dwords */
  263. /* NOTE: We could make macros to contruct the first word of the RCTE,
  264. but that doesn't seem to make much sense... */
  265. /*
  266. * FBD - Free Buffer Descriptor
  267. *
  268. * Written by the device driver using via the command register.
  269. */
  270. typedef struct ns_fbd {
  271. u32 buffer_handle;
  272. u32 dma_address;
  273. } ns_fbd;
  274. /*
  275. * TST - Transmit Schedule Table
  276. *
  277. * Written by the device driver.
  278. */
  279. typedef u32 ns_tste;
  280. #define NS_TST_OPCODE_MASK 0x60000000
  281. #define NS_TST_OPCODE_NULL 0x00000000 /* Insert null cell */
  282. #define NS_TST_OPCODE_FIXED 0x20000000 /* Cell from a fixed rate channel */
  283. #define NS_TST_OPCODE_VARIABLE 0x40000000
  284. #define NS_TST_OPCODE_END 0x60000000 /* Jump */
  285. #define ns_tste_make(opcode, sramad) (opcode | sramad)
  286. /* NOTE:
  287. - When the opcode is FIXED, sramad specifies the SRAM address of the
  288. SCD for that fixed rate channel.
  289. - When the opcode is END, sramad specifies the SRAM address of the
  290. location of the next TST entry to read.
  291. */
  292. /*
  293. * SCD - Segmentation Channel Descriptor
  294. *
  295. * Written by both the device driver and the NICStAR
  296. */
  297. typedef struct ns_scd {
  298. u32 word_1;
  299. u32 word_2;
  300. u32 partial_aal5_crc;
  301. u32 reserved;
  302. ns_scqe cache_a;
  303. ns_scqe cache_b;
  304. } ns_scd;
  305. #define NS_SCD_BASE_MASK_VAR 0xFFFFE000 /* Variable rate */
  306. #define NS_SCD_BASE_MASK_FIX 0xFFFFFC00 /* Fixed rate */
  307. #define NS_SCD_TAIL_MASK_VAR 0x00001FF0
  308. #define NS_SCD_TAIL_MASK_FIX 0x000003F0
  309. #define NS_SCD_HEAD_MASK_VAR 0x00001FF0
  310. #define NS_SCD_HEAD_MASK_FIX 0x000003F0
  311. #define NS_SCD_XMITFOREVER 0x02000000
  312. /* NOTE: There are other fields in word 2 of the SCD, but as they should
  313. not be needed in the device driver they are not defined here. */
  314. /* NICStAR local SRAM memory map */
  315. #define NS_RCT 0x00000
  316. #define NS_RCT_32_END 0x03FFF
  317. #define NS_RCT_128_END 0x0FFFF
  318. #define NS_UNUSED_32 0x04000
  319. #define NS_UNUSED_128 0x10000
  320. #define NS_UNUSED_END 0x1BFFF
  321. #define NS_TST_FRSCD 0x1C000
  322. #define NS_TST_FRSCD_END 0x1E7DB
  323. #define NS_VRSCD2 0x1E7DC
  324. #define NS_VRSCD2_END 0x1E7E7
  325. #define NS_VRSCD1 0x1E7E8
  326. #define NS_VRSCD1_END 0x1E7F3
  327. #define NS_VRSCD0 0x1E7F4
  328. #define NS_VRSCD0_END 0x1E7FF
  329. #define NS_RXFIFO 0x1E800
  330. #define NS_RXFIFO_END 0x1F7FF
  331. #define NS_SMFBQ 0x1F800
  332. #define NS_SMFBQ_END 0x1FBFF
  333. #define NS_LGFBQ 0x1FC00
  334. #define NS_LGFBQ_END 0x1FFFF
  335. /* NISCtAR operation registers */
  336. /* See Section 3.4 of `IDT77211 NICStAR User Manual' from www.idt.com */
  337. enum ns_regs {
  338. DR0 = 0x00, /* Data Register 0 R/W */
  339. DR1 = 0x04, /* Data Register 1 W */
  340. DR2 = 0x08, /* Data Register 2 W */
  341. DR3 = 0x0C, /* Data Register 3 W */
  342. CMD = 0x10, /* Command W */
  343. CFG = 0x14, /* Configuration R/W */
  344. STAT = 0x18, /* Status R/W */
  345. RSQB = 0x1C, /* Receive Status Queue Base W */
  346. RSQT = 0x20, /* Receive Status Queue Tail R */
  347. RSQH = 0x24, /* Receive Status Queue Head W */
  348. CDC = 0x28, /* Cell Drop Counter R/clear */
  349. VPEC = 0x2C, /* VPI/VCI Lookup Error Count R/clear */
  350. ICC = 0x30, /* Invalid Cell Count R/clear */
  351. RAWCT = 0x34, /* Raw Cell Tail R */
  352. TMR = 0x38, /* Timer R */
  353. TSTB = 0x3C, /* Transmit Schedule Table Base R/W */
  354. TSQB = 0x40, /* Transmit Status Queue Base W */
  355. TSQT = 0x44, /* Transmit Status Queue Tail R */
  356. TSQH = 0x48, /* Transmit Status Queue Head W */
  357. GP = 0x4C, /* General Purpose R/W */
  358. VPM = 0x50 /* VPI/VCI Mask W */
  359. };
  360. /* NICStAR commands issued to the CMD register */
  361. /* Top 4 bits are command opcode, lower 28 are parameters. */
  362. #define NS_CMD_NO_OPERATION 0x00000000
  363. /* params always 0 */
  364. #define NS_CMD_OPENCLOSE_CONNECTION 0x20000000
  365. /* b19{1=open,0=close} b18-2{SRAM addr} */
  366. #define NS_CMD_WRITE_SRAM 0x40000000
  367. /* b18-2{SRAM addr} b1-0{burst size} */
  368. #define NS_CMD_READ_SRAM 0x50000000
  369. /* b18-2{SRAM addr} */
  370. #define NS_CMD_WRITE_FREEBUFQ 0x60000000
  371. /* b0{large buf indicator} */
  372. #define NS_CMD_READ_UTILITY 0x80000000
  373. /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
  374. #define NS_CMD_WRITE_UTILITY 0x90000000
  375. /* b8{1=select UTL_CS1} b9{1=select UTL_CS0} b7-0{bus addr} */
  376. #define NS_CMD_OPEN_CONNECTION (NS_CMD_OPENCLOSE_CONNECTION | 0x00080000)
  377. #define NS_CMD_CLOSE_CONNECTION NS_CMD_OPENCLOSE_CONNECTION
  378. /* NICStAR configuration bits */
  379. #define NS_CFG_SWRST 0x80000000 /* Software Reset */
  380. #define NS_CFG_RXPATH 0x20000000 /* Receive Path Enable */
  381. #define NS_CFG_SMBUFSIZE_MASK 0x18000000 /* Small Receive Buffer Size */
  382. #define NS_CFG_LGBUFSIZE_MASK 0x06000000 /* Large Receive Buffer Size */
  383. #define NS_CFG_EFBIE 0x01000000 /* Empty Free Buffer Queue
  384. Interrupt Enable */
  385. #define NS_CFG_RSQSIZE_MASK 0x00C00000 /* Receive Status Queue Size */
  386. #define NS_CFG_ICACCEPT 0x00200000 /* Invalid Cell Accept */
  387. #define NS_CFG_IGNOREGFC 0x00100000 /* Ignore General Flow Control */
  388. #define NS_CFG_VPIBITS_MASK 0x000C0000 /* VPI/VCI Bits Size Select */
  389. #define NS_CFG_RCTSIZE_MASK 0x00030000 /* Receive Connection Table Size */
  390. #define NS_CFG_VCERRACCEPT 0x00008000 /* VPI/VCI Error Cell Accept */
  391. #define NS_CFG_RXINT_MASK 0x00007000 /* End of Receive PDU Interrupt
  392. Handling */
  393. #define NS_CFG_RAWIE 0x00000800 /* Raw Cell Qu' Interrupt Enable */
  394. #define NS_CFG_RSQAFIE 0x00000400 /* Receive Queue Almost Full
  395. Interrupt Enable */
  396. #define NS_CFG_RXRM 0x00000200 /* Receive RM Cells */
  397. #define NS_CFG_TMRROIE 0x00000080 /* Timer Roll Over Interrupt
  398. Enable */
  399. #define NS_CFG_TXEN 0x00000020 /* Transmit Operation Enable */
  400. #define NS_CFG_TXIE 0x00000010 /* Transmit Status Interrupt
  401. Enable */
  402. #define NS_CFG_TXURIE 0x00000008 /* Transmit Under-run Interrupt
  403. Enable */
  404. #define NS_CFG_UMODE 0x00000004 /* Utopia Mode (cell/byte) Select */
  405. #define NS_CFG_TSQFIE 0x00000002 /* Transmit Status Queue Full
  406. Interrupt Enable */
  407. #define NS_CFG_PHYIE 0x00000001 /* PHY Interrupt Enable */
  408. #define NS_CFG_SMBUFSIZE_48 0x00000000
  409. #define NS_CFG_SMBUFSIZE_96 0x08000000
  410. #define NS_CFG_SMBUFSIZE_240 0x10000000
  411. #define NS_CFG_SMBUFSIZE_2048 0x18000000
  412. #define NS_CFG_LGBUFSIZE_2048 0x00000000
  413. #define NS_CFG_LGBUFSIZE_4096 0x02000000
  414. #define NS_CFG_LGBUFSIZE_8192 0x04000000
  415. #define NS_CFG_LGBUFSIZE_16384 0x06000000
  416. #define NS_CFG_RSQSIZE_2048 0x00000000
  417. #define NS_CFG_RSQSIZE_4096 0x00400000
  418. #define NS_CFG_RSQSIZE_8192 0x00800000
  419. #define NS_CFG_VPIBITS_0 0x00000000
  420. #define NS_CFG_VPIBITS_1 0x00040000
  421. #define NS_CFG_VPIBITS_2 0x00080000
  422. #define NS_CFG_VPIBITS_8 0x000C0000
  423. #define NS_CFG_RCTSIZE_4096_ENTRIES 0x00000000
  424. #define NS_CFG_RCTSIZE_8192_ENTRIES 0x00010000
  425. #define NS_CFG_RCTSIZE_16384_ENTRIES 0x00020000
  426. #define NS_CFG_RXINT_NOINT 0x00000000
  427. #define NS_CFG_RXINT_NODELAY 0x00001000
  428. #define NS_CFG_RXINT_314US 0x00002000
  429. #define NS_CFG_RXINT_624US 0x00003000
  430. #define NS_CFG_RXINT_899US 0x00004000
  431. /* NICStAR STATus bits */
  432. #define NS_STAT_SFBQC_MASK 0xFF000000 /* hi 8 bits Small Buffer Queue Count */
  433. #define NS_STAT_LFBQC_MASK 0x00FF0000 /* hi 8 bits Large Buffer Queue Count */
  434. #define NS_STAT_TSIF 0x00008000 /* Transmit Status Queue Indicator */
  435. #define NS_STAT_TXICP 0x00004000 /* Transmit Incomplete PDU */
  436. #define NS_STAT_TSQF 0x00001000 /* Transmit Status Queue Full */
  437. #define NS_STAT_TMROF 0x00000800 /* Timer Overflow */
  438. #define NS_STAT_PHYI 0x00000400 /* PHY Device Interrupt */
  439. #define NS_STAT_CMDBZ 0x00000200 /* Command Busy */
  440. #define NS_STAT_SFBQF 0x00000100 /* Small Buffer Queue Full */
  441. #define NS_STAT_LFBQF 0x00000080 /* Large Buffer Queue Full */
  442. #define NS_STAT_RSQF 0x00000040 /* Receive Status Queue Full */
  443. #define NS_STAT_EOPDU 0x00000020 /* End of PDU */
  444. #define NS_STAT_RAWCF 0x00000010 /* Raw Cell Flag */
  445. #define NS_STAT_SFBQE 0x00000008 /* Small Buffer Queue Empty */
  446. #define NS_STAT_LFBQE 0x00000004 /* Large Buffer Queue Empty */
  447. #define NS_STAT_RSQAF 0x00000002 /* Receive Status Queue Almost Full */
  448. #define ns_stat_sfbqc_get(stat) (((stat) & NS_STAT_SFBQC_MASK) >> 23)
  449. #define ns_stat_lfbqc_get(stat) (((stat) & NS_STAT_LFBQC_MASK) >> 15)
  450. /* #defines which depend on other #defines */
  451. #define NS_TST0 NS_TST_FRSCD
  452. #define NS_TST1 (NS_TST_FRSCD + NS_TST_NUM_ENTRIES + 1)
  453. #define NS_FRSCD (NS_TST1 + NS_TST_NUM_ENTRIES + 1)
  454. #define NS_FRSCD_SIZE 12 /* 12 dwords */
  455. #define NS_FRSCD_NUM ((NS_TST_FRSCD_END + 1 - NS_FRSCD) / NS_FRSCD_SIZE)
  456. #if (NS_SMBUFSIZE == 48)
  457. #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_48
  458. #elif (NS_SMBUFSIZE == 96)
  459. #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_96
  460. #elif (NS_SMBUFSIZE == 240)
  461. #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_240
  462. #elif (NS_SMBUFSIZE == 2048)
  463. #define NS_CFG_SMBUFSIZE NS_CFG_SMBUFSIZE_2048
  464. #else
  465. #error NS_SMBUFSIZE is incorrect in nicstar.h
  466. #endif /* NS_SMBUFSIZE */
  467. #if (NS_LGBUFSIZE == 2048)
  468. #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_2048
  469. #elif (NS_LGBUFSIZE == 4096)
  470. #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_4096
  471. #elif (NS_LGBUFSIZE == 8192)
  472. #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_8192
  473. #elif (NS_LGBUFSIZE == 16384)
  474. #define NS_CFG_LGBUFSIZE NS_CFG_LGBUFSIZE_16384
  475. #else
  476. #error NS_LGBUFSIZE is incorrect in nicstar.h
  477. #endif /* NS_LGBUFSIZE */
  478. #if (NS_RSQSIZE == 2048)
  479. #define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_2048
  480. #elif (NS_RSQSIZE == 4096)
  481. #define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_4096
  482. #elif (NS_RSQSIZE == 8192)
  483. #define NS_CFG_RSQSIZE NS_CFG_RSQSIZE_8192
  484. #else
  485. #error NS_RSQSIZE is incorrect in nicstar.h
  486. #endif /* NS_RSQSIZE */
  487. #if (NS_VPIBITS == 0)
  488. #define NS_CFG_VPIBITS NS_CFG_VPIBITS_0
  489. #elif (NS_VPIBITS == 1)
  490. #define NS_CFG_VPIBITS NS_CFG_VPIBITS_1
  491. #elif (NS_VPIBITS == 2)
  492. #define NS_CFG_VPIBITS NS_CFG_VPIBITS_2
  493. #elif (NS_VPIBITS == 8)
  494. #define NS_CFG_VPIBITS NS_CFG_VPIBITS_8
  495. #else
  496. #error NS_VPIBITS is incorrect in nicstar.h
  497. #endif /* NS_VPIBITS */
  498. #ifdef RCQ_SUPPORT
  499. #define NS_CFG_RAWIE_OPT NS_CFG_RAWIE
  500. #else
  501. #define NS_CFG_RAWIE_OPT 0x00000000
  502. #endif /* RCQ_SUPPORT */
  503. #ifdef ENABLE_TSQFIE
  504. #define NS_CFG_TSQFIE_OPT NS_CFG_TSQFIE
  505. #else
  506. #define NS_CFG_TSQFIE_OPT 0x00000000
  507. #endif /* ENABLE_TSQFIE */
  508. /* PCI stuff */
  509. #ifndef PCI_VENDOR_ID_IDT
  510. #define PCI_VENDOR_ID_IDT 0x111D
  511. #endif /* PCI_VENDOR_ID_IDT */
  512. #ifndef PCI_DEVICE_ID_IDT_IDT77201
  513. #define PCI_DEVICE_ID_IDT_IDT77201 0x0001
  514. #endif /* PCI_DEVICE_ID_IDT_IDT77201 */
  515. /* Device driver structures */
  516. struct ns_skb_prv {
  517. u32 buf_type; /* BUF_SM/BUF_LG/BUF_NONE */
  518. u32 dma;
  519. int iovcnt;
  520. };
  521. #define NS_PRV_BUFTYPE(skb) \
  522. (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->buf_type)
  523. #define NS_PRV_DMA(skb) \
  524. (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->dma)
  525. #define NS_PRV_IOVCNT(skb) \
  526. (((struct ns_skb_prv *)(ATM_SKB(skb)+1))->iovcnt)
  527. typedef struct tsq_info {
  528. void *org;
  529. dma_addr_t dma;
  530. ns_tsi *base;
  531. ns_tsi *next;
  532. ns_tsi *last;
  533. } tsq_info;
  534. typedef struct scq_info {
  535. void *org;
  536. dma_addr_t dma;
  537. ns_scqe *base;
  538. ns_scqe *last;
  539. ns_scqe *next;
  540. volatile ns_scqe *tail; /* Not related to the nicstar register */
  541. unsigned num_entries;
  542. struct sk_buff **skb; /* Pointer to an array of pointers
  543. to the sk_buffs used for tx */
  544. u32 scd; /* SRAM address of the corresponding
  545. SCD */
  546. int tbd_count; /* Only meaningful on variable rate */
  547. wait_queue_head_t scqfull_waitq;
  548. volatile char full; /* SCQ full indicator */
  549. spinlock_t lock; /* SCQ spinlock */
  550. } scq_info;
  551. typedef struct rsq_info {
  552. void *org;
  553. dma_addr_t dma;
  554. ns_rsqe *base;
  555. ns_rsqe *next;
  556. ns_rsqe *last;
  557. } rsq_info;
  558. typedef struct skb_pool {
  559. volatile int count; /* number of buffers in the queue */
  560. struct sk_buff_head queue;
  561. } skb_pool;
  562. /* NOTE: for small and large buffer pools, the count is not used, as the
  563. actual value used for buffer management is the one read from the
  564. card. */
  565. typedef struct vc_map {
  566. volatile unsigned int tx:1; /* TX vc? */
  567. volatile unsigned int rx:1; /* RX vc? */
  568. struct atm_vcc *tx_vcc, *rx_vcc;
  569. struct sk_buff *rx_iov; /* RX iovector skb */
  570. scq_info *scq; /* To keep track of the SCQ */
  571. u32 cbr_scd; /* SRAM address of the corresponding
  572. SCD. 0x00000000 for UBR/VBR/ABR */
  573. int tbd_count;
  574. } vc_map;
  575. typedef struct ns_dev {
  576. int index; /* Card ID to the device driver */
  577. int sram_size; /* In k x 32bit words. 32 or 128 */
  578. void __iomem *membase; /* Card's memory base address */
  579. unsigned long max_pcr;
  580. int rct_size; /* Number of entries */
  581. int vpibits;
  582. int vcibits;
  583. struct pci_dev *pcidev;
  584. struct idr idr;
  585. struct atm_dev *atmdev;
  586. tsq_info tsq;
  587. rsq_info rsq;
  588. scq_info *scq0, *scq1, *scq2; /* VBR SCQs */
  589. skb_pool sbpool; /* Small buffers */
  590. skb_pool lbpool; /* Large buffers */
  591. skb_pool hbpool; /* Pre-allocated huge buffers */
  592. skb_pool iovpool; /* iovector buffers */
  593. volatile int efbie; /* Empty free buf. queue int. enabled */
  594. volatile u32 tst_addr; /* SRAM address of the TST in use */
  595. volatile int tst_free_entries;
  596. vc_map vcmap[NS_MAX_RCTSIZE];
  597. vc_map *tste2vc[NS_TST_NUM_ENTRIES];
  598. vc_map *scd2vc[NS_FRSCD_NUM];
  599. buf_nr sbnr;
  600. buf_nr lbnr;
  601. buf_nr hbnr;
  602. buf_nr iovnr;
  603. int sbfqc;
  604. int lbfqc;
  605. struct sk_buff *sm_handle;
  606. u32 sm_addr;
  607. struct sk_buff *lg_handle;
  608. u32 lg_addr;
  609. struct sk_buff *rcbuf; /* Current raw cell buffer */
  610. struct ns_rcqe *rawcell;
  611. u32 rawch; /* Raw cell queue head */
  612. unsigned intcnt; /* Interrupt counter */
  613. spinlock_t int_lock; /* Interrupt lock */
  614. spinlock_t res_lock; /* Card resource lock */
  615. } ns_dev;
  616. /* NOTE: Each tste2vc entry relates a given TST entry to the corresponding
  617. CBR vc. If the entry is not allocated, it must be NULL.
  618. There are two TSTs so the driver can modify them on the fly
  619. without stopping the transmission.
  620. scd2vc allows us to find out unused fixed rate SCDs, because
  621. they must have a NULL pointer here. */
  622. #endif /* _LINUX_NICSTAR_H_ */