nicstar.h 23 KB

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