fore200e.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. /* $Id: fore200e.h,v 1.4 2000/04/14 10:10:34 davem Exp $ */
  2. #ifndef _FORE200E_H
  3. #define _FORE200E_H
  4. #ifdef __KERNEL__
  5. #include <linux/config.h>
  6. /* rx buffer sizes */
  7. #define SMALL_BUFFER_SIZE 384 /* size of small buffers (multiple of 48 (PCA) and 64 (SBA) bytes) */
  8. #define LARGE_BUFFER_SIZE 4032 /* size of large buffers (multiple of 48 (PCA) and 64 (SBA) bytes) */
  9. #define RBD_BLK_SIZE 32 /* nbr of supplied rx buffers per rbd */
  10. #define MAX_PDU_SIZE 65535 /* maximum PDU size supported by AALs */
  11. #define BUFFER_S1_SIZE SMALL_BUFFER_SIZE /* size of small buffers, scheme 1 */
  12. #define BUFFER_L1_SIZE LARGE_BUFFER_SIZE /* size of large buffers, scheme 1 */
  13. #define BUFFER_S2_SIZE SMALL_BUFFER_SIZE /* size of small buffers, scheme 2 */
  14. #define BUFFER_L2_SIZE LARGE_BUFFER_SIZE /* size of large buffers, scheme 2 */
  15. #define BUFFER_S1_NBR (RBD_BLK_SIZE * 6)
  16. #define BUFFER_L1_NBR (RBD_BLK_SIZE * 4)
  17. #define BUFFER_S2_NBR (RBD_BLK_SIZE * 6)
  18. #define BUFFER_L2_NBR (RBD_BLK_SIZE * 4)
  19. #define QUEUE_SIZE_CMD 16 /* command queue capacity */
  20. #define QUEUE_SIZE_RX 64 /* receive queue capacity */
  21. #define QUEUE_SIZE_TX 256 /* transmit queue capacity */
  22. #define QUEUE_SIZE_BS 32 /* buffer supply queue capacity */
  23. #define FORE200E_VPI_BITS 0
  24. #define FORE200E_VCI_BITS 10
  25. #define NBR_CONNECT (1 << (FORE200E_VPI_BITS + FORE200E_VCI_BITS)) /* number of connections */
  26. #define TSD_FIXED 2
  27. #define TSD_EXTENSION 0
  28. #define TSD_NBR (TSD_FIXED + TSD_EXTENSION)
  29. /* the cp starts putting a received PDU into one *small* buffer,
  30. then it uses a number of *large* buffers for the trailing data.
  31. we compute here the total number of receive segment descriptors
  32. required to hold the largest possible PDU */
  33. #define RSD_REQUIRED (((MAX_PDU_SIZE - SMALL_BUFFER_SIZE + LARGE_BUFFER_SIZE) / LARGE_BUFFER_SIZE) + 1)
  34. #define RSD_FIXED 3
  35. /* RSD_REQUIRED receive segment descriptors are enough to describe a max-sized PDU,
  36. but we have to keep the size of the receive PDU descriptor multiple of 32 bytes,
  37. so we add one extra RSD to RSD_EXTENSION
  38. (WARNING: THIS MAY CHANGE IF BUFFER SIZES ARE MODIFIED) */
  39. #define RSD_EXTENSION ((RSD_REQUIRED - RSD_FIXED) + 1)
  40. #define RSD_NBR (RSD_FIXED + RSD_EXTENSION)
  41. #define FORE200E_DEV(d) ((struct fore200e*)((d)->dev_data))
  42. #define FORE200E_VCC(d) ((struct fore200e_vcc*)((d)->dev_data))
  43. /* bitfields endian games */
  44. #if defined(__LITTLE_ENDIAN_BITFIELD)
  45. #define BITFIELD2(b1, b2) b1; b2;
  46. #define BITFIELD3(b1, b2, b3) b1; b2; b3;
  47. #define BITFIELD4(b1, b2, b3, b4) b1; b2; b3; b4;
  48. #define BITFIELD5(b1, b2, b3, b4, b5) b1; b2; b3; b4; b5;
  49. #define BITFIELD6(b1, b2, b3, b4, b5, b6) b1; b2; b3; b4; b5; b6;
  50. #elif defined(__BIG_ENDIAN_BITFIELD)
  51. #define BITFIELD2(b1, b2) b2; b1;
  52. #define BITFIELD3(b1, b2, b3) b3; b2; b1;
  53. #define BITFIELD4(b1, b2, b3, b4) b4; b3; b2; b1;
  54. #define BITFIELD5(b1, b2, b3, b4, b5) b5; b4; b3; b2; b1;
  55. #define BITFIELD6(b1, b2, b3, b4, b5, b6) b6; b5; b4; b3; b2; b1;
  56. #else
  57. #error unknown bitfield endianess
  58. #endif
  59. /* ATM cell header (minus HEC byte) */
  60. typedef struct atm_header {
  61. BITFIELD5(
  62. u32 clp : 1, /* cell loss priority */
  63. u32 plt : 3, /* payload type */
  64. u32 vci : 16, /* virtual channel identifier */
  65. u32 vpi : 8, /* virtual path identifier */
  66. u32 gfc : 4 /* generic flow control */
  67. )
  68. } atm_header_t;
  69. /* ATM adaptation layer id */
  70. typedef enum fore200e_aal {
  71. FORE200E_AAL0 = 0,
  72. FORE200E_AAL34 = 4,
  73. FORE200E_AAL5 = 5,
  74. } fore200e_aal_t;
  75. /* transmit PDU descriptor specification */
  76. typedef struct tpd_spec {
  77. BITFIELD4(
  78. u32 length : 16, /* total PDU length */
  79. u32 nseg : 8, /* number of transmit segments */
  80. enum fore200e_aal aal : 4, /* adaptation layer */
  81. u32 intr : 4 /* interrupt requested */
  82. )
  83. } tpd_spec_t;
  84. /* transmit PDU rate control */
  85. typedef struct tpd_rate
  86. {
  87. BITFIELD2(
  88. u32 idle_cells : 16, /* number of idle cells to insert */
  89. u32 data_cells : 16 /* number of data cells to transmit */
  90. )
  91. } tpd_rate_t;
  92. /* transmit segment descriptor */
  93. typedef struct tsd {
  94. u32 buffer; /* transmit buffer DMA address */
  95. u32 length; /* number of bytes in buffer */
  96. } tsd_t;
  97. /* transmit PDU descriptor */
  98. typedef struct tpd {
  99. struct atm_header atm_header; /* ATM header minus HEC byte */
  100. struct tpd_spec spec; /* tpd specification */
  101. struct tpd_rate rate; /* tpd rate control */
  102. u32 pad; /* reserved */
  103. struct tsd tsd[ TSD_NBR ]; /* transmit segment descriptors */
  104. } tpd_t;
  105. /* receive segment descriptor */
  106. typedef struct rsd {
  107. u32 handle; /* host supplied receive buffer handle */
  108. u32 length; /* number of bytes in buffer */
  109. } rsd_t;
  110. /* receive PDU descriptor */
  111. typedef struct rpd {
  112. struct atm_header atm_header; /* ATM header minus HEC byte */
  113. u32 nseg; /* number of receive segments */
  114. struct rsd rsd[ RSD_NBR ]; /* receive segment descriptors */
  115. } rpd_t;
  116. /* buffer scheme */
  117. typedef enum buffer_scheme {
  118. BUFFER_SCHEME_ONE,
  119. BUFFER_SCHEME_TWO,
  120. BUFFER_SCHEME_NBR /* always last */
  121. } buffer_scheme_t;
  122. /* buffer magnitude */
  123. typedef enum buffer_magn {
  124. BUFFER_MAGN_SMALL,
  125. BUFFER_MAGN_LARGE,
  126. BUFFER_MAGN_NBR /* always last */
  127. } buffer_magn_t;
  128. /* receive buffer descriptor */
  129. typedef struct rbd {
  130. u32 handle; /* host supplied handle */
  131. u32 buffer_haddr; /* host DMA address of host buffer */
  132. } rbd_t;
  133. /* receive buffer descriptor block */
  134. typedef struct rbd_block {
  135. struct rbd rbd[ RBD_BLK_SIZE ]; /* receive buffer descriptor */
  136. } rbd_block_t;
  137. /* tpd DMA address */
  138. typedef struct tpd_haddr {
  139. BITFIELD3(
  140. u32 size : 4, /* tpd size expressed in 32 byte blocks */
  141. u32 pad : 1, /* reserved */
  142. u32 haddr : 27 /* tpd DMA addr aligned on 32 byte boundary */
  143. )
  144. } tpd_haddr_t;
  145. #define TPD_HADDR_SHIFT 5 /* addr aligned on 32 byte boundary */
  146. /* cp resident transmit queue entry */
  147. typedef struct cp_txq_entry {
  148. struct tpd_haddr tpd_haddr; /* host DMA address of tpd */
  149. u32 status_haddr; /* host DMA address of completion status */
  150. } cp_txq_entry_t;
  151. /* cp resident receive queue entry */
  152. typedef struct cp_rxq_entry {
  153. u32 rpd_haddr; /* host DMA address of rpd */
  154. u32 status_haddr; /* host DMA address of completion status */
  155. } cp_rxq_entry_t;
  156. /* cp resident buffer supply queue entry */
  157. typedef struct cp_bsq_entry {
  158. u32 rbd_block_haddr; /* host DMA address of rbd block */
  159. u32 status_haddr; /* host DMA address of completion status */
  160. } cp_bsq_entry_t;
  161. /* completion status */
  162. typedef volatile enum status {
  163. STATUS_PENDING = (1<<0), /* initial status (written by host) */
  164. STATUS_COMPLETE = (1<<1), /* completion status (written by cp) */
  165. STATUS_FREE = (1<<2), /* initial status (written by host) */
  166. STATUS_ERROR = (1<<3) /* completion status (written by cp) */
  167. } status_t;
  168. /* cp operation code */
  169. typedef enum opcode {
  170. OPCODE_INITIALIZE = 1, /* initialize board */
  171. OPCODE_ACTIVATE_VCIN, /* activate incoming VCI */
  172. OPCODE_ACTIVATE_VCOUT, /* activate outgoing VCI */
  173. OPCODE_DEACTIVATE_VCIN, /* deactivate incoming VCI */
  174. OPCODE_DEACTIVATE_VCOUT, /* deactivate incoing VCI */
  175. OPCODE_GET_STATS, /* get board statistics */
  176. OPCODE_SET_OC3, /* set OC-3 registers */
  177. OPCODE_GET_OC3, /* get OC-3 registers */
  178. OPCODE_RESET_STATS, /* reset board statistics */
  179. OPCODE_GET_PROM, /* get expansion PROM data (PCI specific) */
  180. OPCODE_SET_VPI_BITS, /* set x bits of those decoded by the
  181. firmware to be low order bits from
  182. the VPI field of the ATM cell header */
  183. OPCODE_REQUEST_INTR = (1<<7) /* request interrupt */
  184. } opcode_t;
  185. /* virtual path / virtual channel identifers */
  186. typedef struct vpvc {
  187. BITFIELD3(
  188. u32 vci : 16, /* virtual channel identifier */
  189. u32 vpi : 8, /* virtual path identifier */
  190. u32 pad : 8 /* reserved */
  191. )
  192. } vpvc_t;
  193. /* activate VC command opcode */
  194. typedef struct activate_opcode {
  195. BITFIELD4(
  196. enum opcode opcode : 8, /* cp opcode */
  197. enum fore200e_aal aal : 8, /* adaptation layer */
  198. enum buffer_scheme scheme : 8, /* buffer scheme */
  199. u32 pad : 8 /* reserved */
  200. )
  201. } activate_opcode_t;
  202. /* activate VC command block */
  203. typedef struct activate_block {
  204. struct activate_opcode opcode; /* activate VC command opcode */
  205. struct vpvc vpvc; /* VPI/VCI */
  206. u32 mtu; /* for AAL0 only */
  207. } activate_block_t;
  208. /* deactivate VC command opcode */
  209. typedef struct deactivate_opcode {
  210. BITFIELD2(
  211. enum opcode opcode : 8, /* cp opcode */
  212. u32 pad : 24 /* reserved */
  213. )
  214. } deactivate_opcode_t;
  215. /* deactivate VC command block */
  216. typedef struct deactivate_block {
  217. struct deactivate_opcode opcode; /* deactivate VC command opcode */
  218. struct vpvc vpvc; /* VPI/VCI */
  219. } deactivate_block_t;
  220. /* OC-3 registers */
  221. typedef struct oc3_regs {
  222. u32 reg[ 128 ]; /* see the PMC Sierra PC5346 S/UNI-155-Lite
  223. Saturn User Network Interface documentation
  224. for a description of the OC-3 chip registers */
  225. } oc3_regs_t;
  226. /* set/get OC-3 regs command opcode */
  227. typedef struct oc3_opcode {
  228. BITFIELD4(
  229. enum opcode opcode : 8, /* cp opcode */
  230. u32 reg : 8, /* register index */
  231. u32 value : 8, /* register value */
  232. u32 mask : 8 /* register mask that specifies which
  233. bits of the register value field
  234. are significant */
  235. )
  236. } oc3_opcode_t;
  237. /* set/get OC-3 regs command block */
  238. typedef struct oc3_block {
  239. struct oc3_opcode opcode; /* set/get OC-3 regs command opcode */
  240. u32 regs_haddr; /* host DMA address of OC-3 regs buffer */
  241. } oc3_block_t;
  242. /* physical encoding statistics */
  243. typedef struct stats_phy {
  244. u32 crc_header_errors; /* cells received with bad header CRC */
  245. u32 framing_errors; /* cells received with bad framing */
  246. u32 pad[ 2 ]; /* i960 padding */
  247. } stats_phy_t;
  248. /* OC-3 statistics */
  249. typedef struct stats_oc3 {
  250. u32 section_bip8_errors; /* section 8 bit interleaved parity */
  251. u32 path_bip8_errors; /* path 8 bit interleaved parity */
  252. u32 line_bip24_errors; /* line 24 bit interleaved parity */
  253. u32 line_febe_errors; /* line far end block errors */
  254. u32 path_febe_errors; /* path far end block errors */
  255. u32 corr_hcs_errors; /* correctable header check sequence */
  256. u32 ucorr_hcs_errors; /* uncorrectable header check sequence */
  257. u32 pad[ 1 ]; /* i960 padding */
  258. } stats_oc3_t;
  259. /* ATM statistics */
  260. typedef struct stats_atm {
  261. u32 cells_transmitted; /* cells transmitted */
  262. u32 cells_received; /* cells received */
  263. u32 vpi_bad_range; /* cell drops: VPI out of range */
  264. u32 vpi_no_conn; /* cell drops: no connection for VPI */
  265. u32 vci_bad_range; /* cell drops: VCI out of range */
  266. u32 vci_no_conn; /* cell drops: no connection for VCI */
  267. u32 pad[ 2 ]; /* i960 padding */
  268. } stats_atm_t;
  269. /* AAL0 statistics */
  270. typedef struct stats_aal0 {
  271. u32 cells_transmitted; /* cells transmitted */
  272. u32 cells_received; /* cells received */
  273. u32 cells_dropped; /* cells dropped */
  274. u32 pad[ 1 ]; /* i960 padding */
  275. } stats_aal0_t;
  276. /* AAL3/4 statistics */
  277. typedef struct stats_aal34 {
  278. u32 cells_transmitted; /* cells transmitted from segmented PDUs */
  279. u32 cells_received; /* cells reassembled into PDUs */
  280. u32 cells_crc_errors; /* payload CRC error count */
  281. u32 cells_protocol_errors; /* SAR or CS layer protocol errors */
  282. u32 cells_dropped; /* cells dropped: partial reassembly */
  283. u32 cspdus_transmitted; /* CS PDUs transmitted */
  284. u32 cspdus_received; /* CS PDUs received */
  285. u32 cspdus_protocol_errors; /* CS layer protocol errors */
  286. u32 cspdus_dropped; /* reassembled PDUs drop'd (in cells) */
  287. u32 pad[ 3 ]; /* i960 padding */
  288. } stats_aal34_t;
  289. /* AAL5 statistics */
  290. typedef struct stats_aal5 {
  291. u32 cells_transmitted; /* cells transmitted from segmented SDUs */
  292. u32 cells_received; /* cells reassembled into SDUs */
  293. u32 cells_dropped; /* reassembled PDUs dropped (in cells) */
  294. u32 congestion_experienced; /* CRC error and length wrong */
  295. u32 cspdus_transmitted; /* CS PDUs transmitted */
  296. u32 cspdus_received; /* CS PDUs received */
  297. u32 cspdus_crc_errors; /* CS PDUs CRC errors */
  298. u32 cspdus_protocol_errors; /* CS layer protocol errors */
  299. u32 cspdus_dropped; /* reassembled PDUs dropped */
  300. u32 pad[ 3 ]; /* i960 padding */
  301. } stats_aal5_t;
  302. /* auxiliary statistics */
  303. typedef struct stats_aux {
  304. u32 small_b1_failed; /* receive BD allocation failures */
  305. u32 large_b1_failed; /* receive BD allocation failures */
  306. u32 small_b2_failed; /* receive BD allocation failures */
  307. u32 large_b2_failed; /* receive BD allocation failures */
  308. u32 rpd_alloc_failed; /* receive PDU allocation failures */
  309. u32 receive_carrier; /* no carrier = 0, carrier = 1 */
  310. u32 pad[ 2 ]; /* i960 padding */
  311. } stats_aux_t;
  312. /* whole statistics buffer */
  313. typedef struct stats {
  314. struct stats_phy phy; /* physical encoding statistics */
  315. struct stats_oc3 oc3; /* OC-3 statistics */
  316. struct stats_atm atm; /* ATM statistics */
  317. struct stats_aal0 aal0; /* AAL0 statistics */
  318. struct stats_aal34 aal34; /* AAL3/4 statistics */
  319. struct stats_aal5 aal5; /* AAL5 statistics */
  320. struct stats_aux aux; /* auxiliary statistics */
  321. } stats_t;
  322. /* get statistics command opcode */
  323. typedef struct stats_opcode {
  324. BITFIELD2(
  325. enum opcode opcode : 8, /* cp opcode */
  326. u32 pad : 24 /* reserved */
  327. )
  328. } stats_opcode_t;
  329. /* get statistics command block */
  330. typedef struct stats_block {
  331. struct stats_opcode opcode; /* get statistics command opcode */
  332. u32 stats_haddr; /* host DMA address of stats buffer */
  333. } stats_block_t;
  334. /* expansion PROM data (PCI specific) */
  335. typedef struct prom_data {
  336. u32 hw_revision; /* hardware revision */
  337. u32 serial_number; /* board serial number */
  338. u8 mac_addr[ 8 ]; /* board MAC address */
  339. } prom_data_t;
  340. /* get expansion PROM data command opcode */
  341. typedef struct prom_opcode {
  342. BITFIELD2(
  343. enum opcode opcode : 8, /* cp opcode */
  344. u32 pad : 24 /* reserved */
  345. )
  346. } prom_opcode_t;
  347. /* get expansion PROM data command block */
  348. typedef struct prom_block {
  349. struct prom_opcode opcode; /* get PROM data command opcode */
  350. u32 prom_haddr; /* host DMA address of PROM buffer */
  351. } prom_block_t;
  352. /* cp command */
  353. typedef union cmd {
  354. enum opcode opcode; /* operation code */
  355. struct activate_block activate_block; /* activate VC */
  356. struct deactivate_block deactivate_block; /* deactivate VC */
  357. struct stats_block stats_block; /* get statistics */
  358. struct prom_block prom_block; /* get expansion PROM data */
  359. struct oc3_block oc3_block; /* get/set OC-3 registers */
  360. u32 pad[ 4 ]; /* i960 padding */
  361. } cmd_t;
  362. /* cp resident command queue */
  363. typedef struct cp_cmdq_entry {
  364. union cmd cmd; /* command */
  365. u32 status_haddr; /* host DMA address of completion status */
  366. u32 pad[ 3 ]; /* i960 padding */
  367. } cp_cmdq_entry_t;
  368. /* host resident transmit queue entry */
  369. typedef struct host_txq_entry {
  370. struct cp_txq_entry __iomem *cp_entry; /* addr of cp resident tx queue entry */
  371. enum status* status; /* addr of host resident status */
  372. struct tpd* tpd; /* addr of transmit PDU descriptor */
  373. u32 tpd_dma; /* DMA address of tpd */
  374. struct sk_buff* skb; /* related skb */
  375. void* data; /* copy of misaligned data */
  376. unsigned long incarn; /* vc_map incarnation when submitted for tx */
  377. struct fore200e_vc_map* vc_map;
  378. } host_txq_entry_t;
  379. /* host resident receive queue entry */
  380. typedef struct host_rxq_entry {
  381. struct cp_rxq_entry __iomem *cp_entry; /* addr of cp resident rx queue entry */
  382. enum status* status; /* addr of host resident status */
  383. struct rpd* rpd; /* addr of receive PDU descriptor */
  384. u32 rpd_dma; /* DMA address of rpd */
  385. } host_rxq_entry_t;
  386. /* host resident buffer supply queue entry */
  387. typedef struct host_bsq_entry {
  388. struct cp_bsq_entry __iomem *cp_entry; /* addr of cp resident buffer supply queue entry */
  389. enum status* status; /* addr of host resident status */
  390. struct rbd_block* rbd_block; /* addr of receive buffer descriptor block */
  391. u32 rbd_block_dma; /* DMA address od rdb */
  392. } host_bsq_entry_t;
  393. /* host resident command queue entry */
  394. typedef struct host_cmdq_entry {
  395. struct cp_cmdq_entry __iomem *cp_entry; /* addr of cp resident cmd queue entry */
  396. enum status *status; /* addr of host resident status */
  397. } host_cmdq_entry_t;
  398. /* chunk of memory */
  399. typedef struct chunk {
  400. void* alloc_addr; /* base address of allocated chunk */
  401. void* align_addr; /* base address of aligned chunk */
  402. dma_addr_t dma_addr; /* DMA address of aligned chunk */
  403. int direction; /* direction of DMA mapping */
  404. u32 alloc_size; /* length of allocated chunk */
  405. u32 align_size; /* length of aligned chunk */
  406. } chunk_t;
  407. #define dma_size align_size /* DMA useable size */
  408. /* host resident receive buffer */
  409. typedef struct buffer {
  410. struct buffer* next; /* next receive buffer */
  411. enum buffer_scheme scheme; /* buffer scheme */
  412. enum buffer_magn magn; /* buffer magnitude */
  413. struct chunk data; /* data buffer */
  414. #ifdef FORE200E_BSQ_DEBUG
  415. unsigned long index; /* buffer # in queue */
  416. int supplied; /* 'buffer supplied' flag */
  417. #endif
  418. } buffer_t;
  419. #if (BITS_PER_LONG == 32)
  420. #define FORE200E_BUF2HDL(buffer) ((u32)(buffer))
  421. #define FORE200E_HDL2BUF(handle) ((struct buffer*)(handle))
  422. #else /* deal with 64 bit pointers */
  423. #define FORE200E_BUF2HDL(buffer) ((u32)((u64)(buffer)))
  424. #define FORE200E_HDL2BUF(handle) ((struct buffer*)(((u64)(handle)) | PAGE_OFFSET))
  425. #endif
  426. /* host resident command queue */
  427. typedef struct host_cmdq {
  428. struct host_cmdq_entry host_entry[ QUEUE_SIZE_CMD ]; /* host resident cmd queue entries */
  429. int head; /* head of cmd queue */
  430. struct chunk status; /* array of completion status */
  431. } host_cmdq_t;
  432. /* host resident transmit queue */
  433. typedef struct host_txq {
  434. struct host_txq_entry host_entry[ QUEUE_SIZE_TX ]; /* host resident tx queue entries */
  435. int head; /* head of tx queue */
  436. int tail; /* tail of tx queue */
  437. struct chunk tpd; /* array of tpds */
  438. struct chunk status; /* arry of completion status */
  439. int txing; /* number of pending PDUs in tx queue */
  440. } host_txq_t;
  441. /* host resident receive queue */
  442. typedef struct host_rxq {
  443. struct host_rxq_entry host_entry[ QUEUE_SIZE_RX ]; /* host resident rx queue entries */
  444. int head; /* head of rx queue */
  445. struct chunk rpd; /* array of rpds */
  446. struct chunk status; /* array of completion status */
  447. } host_rxq_t;
  448. /* host resident buffer supply queues */
  449. typedef struct host_bsq {
  450. struct host_bsq_entry host_entry[ QUEUE_SIZE_BS ]; /* host resident buffer supply queue entries */
  451. int head; /* head of buffer supply queue */
  452. struct chunk rbd_block; /* array of rbds */
  453. struct chunk status; /* array of completion status */
  454. struct buffer* buffer; /* array of rx buffers */
  455. struct buffer* freebuf; /* list of free rx buffers */
  456. volatile int freebuf_count; /* count of free rx buffers */
  457. } host_bsq_t;
  458. /* header of the firmware image */
  459. typedef struct fw_header {
  460. u32 magic; /* magic number */
  461. u32 version; /* firmware version id */
  462. u32 load_offset; /* fw load offset in board memory */
  463. u32 start_offset; /* fw execution start address in board memory */
  464. } fw_header_t;
  465. #define FW_HEADER_MAGIC 0x65726f66 /* 'fore' */
  466. /* receive buffer supply queues scheme specification */
  467. typedef struct bs_spec {
  468. u32 queue_length; /* queue capacity */
  469. u32 buffer_size; /* host buffer size */
  470. u32 pool_size; /* number of rbds */
  471. u32 supply_blksize; /* num of rbds in I/O block (multiple
  472. of 4 between 4 and 124 inclusive) */
  473. } bs_spec_t;
  474. /* initialization command block (one-time command, not in cmd queue) */
  475. typedef struct init_block {
  476. enum opcode opcode; /* initialize command */
  477. enum status status; /* related status word */
  478. u32 receive_threshold; /* not used */
  479. u32 num_connect; /* ATM connections */
  480. u32 cmd_queue_len; /* length of command queue */
  481. u32 tx_queue_len; /* length of transmit queue */
  482. u32 rx_queue_len; /* length of receive queue */
  483. u32 rsd_extension; /* number of extra 32 byte blocks */
  484. u32 tsd_extension; /* number of extra 32 byte blocks */
  485. u32 conless_vpvc; /* not used */
  486. u32 pad[ 2 ]; /* force quad alignment */
  487. struct bs_spec bs_spec[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ]; /* buffer supply queues spec */
  488. } init_block_t;
  489. typedef enum media_type {
  490. MEDIA_TYPE_CAT5_UTP = 0x06, /* unshielded twisted pair */
  491. MEDIA_TYPE_MM_OC3_ST = 0x16, /* multimode fiber ST */
  492. MEDIA_TYPE_MM_OC3_SC = 0x26, /* multimode fiber SC */
  493. MEDIA_TYPE_SM_OC3_ST = 0x36, /* single-mode fiber ST */
  494. MEDIA_TYPE_SM_OC3_SC = 0x46 /* single-mode fiber SC */
  495. } media_type_t;
  496. #define FORE200E_MEDIA_INDEX(media_type) ((media_type)>>4)
  497. /* cp resident queues */
  498. typedef struct cp_queues {
  499. u32 cp_cmdq; /* command queue */
  500. u32 cp_txq; /* transmit queue */
  501. u32 cp_rxq; /* receive queue */
  502. u32 cp_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ]; /* buffer supply queues */
  503. u32 imask; /* 1 enables cp to host interrupts */
  504. u32 istat; /* 1 for interrupt posted */
  505. u32 heap_base; /* offset form beginning of ram */
  506. u32 heap_size; /* space available for queues */
  507. u32 hlogger; /* non zero for host logging */
  508. u32 heartbeat; /* cp heartbeat */
  509. u32 fw_release; /* firmware version */
  510. u32 mon960_release; /* i960 monitor version */
  511. u32 tq_plen; /* transmit throughput measurements */
  512. /* make sure the init block remains on a quad word boundary */
  513. struct init_block init; /* one time cmd, not in cmd queue */
  514. enum media_type media_type; /* media type id */
  515. u32 oc3_revision; /* OC-3 revision number */
  516. } cp_queues_t;
  517. /* boot status */
  518. typedef enum boot_status {
  519. BSTAT_COLD_START = (u32) 0xc01dc01d, /* cold start */
  520. BSTAT_SELFTEST_OK = (u32) 0x02201958, /* self-test ok */
  521. BSTAT_SELFTEST_FAIL = (u32) 0xadbadbad, /* self-test failed */
  522. BSTAT_CP_RUNNING = (u32) 0xce11feed, /* cp is running */
  523. BSTAT_MON_TOO_BIG = (u32) 0x10aded00 /* i960 monitor is too big */
  524. } boot_status_t;
  525. /* software UART */
  526. typedef struct soft_uart {
  527. u32 send; /* write register */
  528. u32 recv; /* read register */
  529. } soft_uart_t;
  530. #define FORE200E_CP_MONITOR_UART_FREE 0x00000000
  531. #define FORE200E_CP_MONITOR_UART_AVAIL 0x01000000
  532. /* i960 monitor */
  533. typedef struct cp_monitor {
  534. struct soft_uart soft_uart; /* software UART */
  535. enum boot_status bstat; /* boot status */
  536. u32 app_base; /* application base offset */
  537. u32 mon_version; /* i960 monitor version */
  538. } cp_monitor_t;
  539. /* device state */
  540. typedef enum fore200e_state {
  541. FORE200E_STATE_BLANK, /* initial state */
  542. FORE200E_STATE_REGISTER, /* device registered */
  543. FORE200E_STATE_CONFIGURE, /* bus interface configured */
  544. FORE200E_STATE_MAP, /* board space mapped in host memory */
  545. FORE200E_STATE_RESET, /* board resetted */
  546. FORE200E_STATE_LOAD_FW, /* firmware loaded */
  547. FORE200E_STATE_START_FW, /* firmware started */
  548. FORE200E_STATE_INITIALIZE, /* initialize command successful */
  549. FORE200E_STATE_INIT_CMDQ, /* command queue initialized */
  550. FORE200E_STATE_INIT_TXQ, /* transmit queue initialized */
  551. FORE200E_STATE_INIT_RXQ, /* receive queue initialized */
  552. FORE200E_STATE_INIT_BSQ, /* buffer supply queue initialized */
  553. FORE200E_STATE_ALLOC_BUF, /* receive buffers allocated */
  554. FORE200E_STATE_IRQ, /* host interrupt requested */
  555. FORE200E_STATE_COMPLETE /* initialization completed */
  556. } fore200e_state;
  557. /* PCA-200E registers */
  558. typedef struct fore200e_pca_regs {
  559. volatile u32 __iomem * hcr; /* address of host control register */
  560. volatile u32 __iomem * imr; /* address of host interrupt mask register */
  561. volatile u32 __iomem * psr; /* address of PCI specific register */
  562. } fore200e_pca_regs_t;
  563. /* SBA-200E registers */
  564. typedef struct fore200e_sba_regs {
  565. volatile u32 __iomem *hcr; /* address of host control register */
  566. volatile u32 __iomem *bsr; /* address of burst transfer size register */
  567. volatile u32 __iomem *isr; /* address of interrupt level selection register */
  568. } fore200e_sba_regs_t;
  569. /* model-specific registers */
  570. typedef union fore200e_regs {
  571. struct fore200e_pca_regs pca; /* PCA-200E registers */
  572. struct fore200e_sba_regs sba; /* SBA-200E registers */
  573. } fore200e_regs;
  574. struct fore200e;
  575. /* bus-dependent data */
  576. typedef struct fore200e_bus {
  577. char* model_name; /* board model name */
  578. char* proc_name; /* board name under /proc/atm */
  579. int descr_alignment; /* tpd/rpd/rbd DMA alignment requirement */
  580. int buffer_alignment; /* rx buffers DMA alignment requirement */
  581. int status_alignment; /* status words DMA alignment requirement */
  582. const unsigned char* fw_data; /* address of firmware data start */
  583. const unsigned int* fw_size; /* address of firmware data size */
  584. u32 (*read)(volatile u32 __iomem *);
  585. void (*write)(u32, volatile u32 __iomem *);
  586. u32 (*dma_map)(struct fore200e*, void*, int, int);
  587. void (*dma_unmap)(struct fore200e*, u32, int, int);
  588. void (*dma_sync_for_cpu)(struct fore200e*, u32, int, int);
  589. void (*dma_sync_for_device)(struct fore200e*, u32, int, int);
  590. int (*dma_chunk_alloc)(struct fore200e*, struct chunk*, int, int, int);
  591. void (*dma_chunk_free)(struct fore200e*, struct chunk*);
  592. struct fore200e* (*detect)(const struct fore200e_bus*, int);
  593. int (*configure)(struct fore200e*);
  594. int (*map)(struct fore200e*);
  595. void (*reset)(struct fore200e*);
  596. int (*prom_read)(struct fore200e*, struct prom_data*);
  597. void (*unmap)(struct fore200e*);
  598. void (*irq_enable)(struct fore200e*);
  599. int (*irq_check)(struct fore200e*);
  600. void (*irq_ack)(struct fore200e*);
  601. int (*proc_read)(struct fore200e*, char*);
  602. } fore200e_bus_t;
  603. /* vc mapping */
  604. typedef struct fore200e_vc_map {
  605. struct atm_vcc* vcc; /* vcc entry */
  606. unsigned long incarn; /* vcc incarnation number */
  607. } fore200e_vc_map_t;
  608. #define FORE200E_VC_MAP(fore200e, vpi, vci) \
  609. (& (fore200e)->vc_map[ ((vpi) << FORE200E_VCI_BITS) | (vci) ])
  610. /* per-device data */
  611. typedef struct fore200e {
  612. struct list_head entry; /* next device */
  613. const struct fore200e_bus* bus; /* bus-dependent code and data */
  614. union fore200e_regs regs; /* bus-dependent registers */
  615. struct atm_dev* atm_dev; /* ATM device */
  616. enum fore200e_state state; /* device state */
  617. char name[16]; /* device name */
  618. void* bus_dev; /* bus-specific kernel data */
  619. int irq; /* irq number */
  620. unsigned long phys_base; /* physical base address */
  621. void __iomem * virt_base; /* virtual base address */
  622. unsigned char esi[ ESI_LEN ]; /* end system identifier */
  623. struct cp_monitor __iomem * cp_monitor; /* i960 monitor address */
  624. struct cp_queues __iomem * cp_queues; /* cp resident queues */
  625. struct host_cmdq host_cmdq; /* host resident cmd queue */
  626. struct host_txq host_txq; /* host resident tx queue */
  627. struct host_rxq host_rxq; /* host resident rx queue */
  628. /* host resident buffer supply queues */
  629. struct host_bsq host_bsq[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ];
  630. u32 available_cell_rate; /* remaining pseudo-CBR bw on link */
  631. int loop_mode; /* S/UNI loopback mode */
  632. struct stats* stats; /* last snapshot of the stats */
  633. struct semaphore rate_sf; /* protects rate reservation ops */
  634. spinlock_t q_lock; /* protects queue ops */
  635. #ifdef FORE200E_USE_TASKLET
  636. struct tasklet_struct tx_tasklet; /* performs tx interrupt work */
  637. struct tasklet_struct rx_tasklet; /* performs rx interrupt work */
  638. #endif
  639. unsigned long tx_sat; /* tx queue saturation count */
  640. unsigned long incarn_count;
  641. struct fore200e_vc_map vc_map[ NBR_CONNECT ]; /* vc mapping */
  642. } fore200e_t;
  643. /* per-vcc data */
  644. typedef struct fore200e_vcc {
  645. enum buffer_scheme scheme; /* rx buffer scheme */
  646. struct tpd_rate rate; /* tx rate control data */
  647. int rx_min_pdu; /* size of smallest PDU received */
  648. int rx_max_pdu; /* size of largest PDU received */
  649. int tx_min_pdu; /* size of smallest PDU transmitted */
  650. int tx_max_pdu; /* size of largest PDU transmitted */
  651. unsigned long tx_pdu; /* nbr of tx pdus */
  652. unsigned long rx_pdu; /* nbr of rx pdus */
  653. } fore200e_vcc_t;
  654. /* 200E-series common memory layout */
  655. #define FORE200E_CP_MONITOR_OFFSET 0x00000400 /* i960 monitor interface */
  656. #define FORE200E_CP_QUEUES_OFFSET 0x00004d40 /* cp resident queues */
  657. /* PCA-200E memory layout */
  658. #define PCA200E_IOSPACE_LENGTH 0x00200000
  659. #define PCA200E_HCR_OFFSET 0x00100000 /* board control register */
  660. #define PCA200E_IMR_OFFSET 0x00100004 /* host IRQ mask register */
  661. #define PCA200E_PSR_OFFSET 0x00100008 /* PCI specific register */
  662. /* PCA-200E host control register */
  663. #define PCA200E_HCR_RESET (1<<0) /* read / write */
  664. #define PCA200E_HCR_HOLD_LOCK (1<<1) /* read / write */
  665. #define PCA200E_HCR_I960FAIL (1<<2) /* read */
  666. #define PCA200E_HCR_INTRB (1<<2) /* write */
  667. #define PCA200E_HCR_HOLD_ACK (1<<3) /* read */
  668. #define PCA200E_HCR_INTRA (1<<3) /* write */
  669. #define PCA200E_HCR_OUTFULL (1<<4) /* read */
  670. #define PCA200E_HCR_CLRINTR (1<<4) /* write */
  671. #define PCA200E_HCR_ESPHOLD (1<<5) /* read */
  672. #define PCA200E_HCR_INFULL (1<<6) /* read */
  673. #define PCA200E_HCR_TESTMODE (1<<7) /* read */
  674. /* PCA-200E PCI bus interface regs (offsets in PCI config space) */
  675. #define PCA200E_PCI_LATENCY 0x40 /* maximum slave latenty */
  676. #define PCA200E_PCI_MASTER_CTRL 0x41 /* master control */
  677. #define PCA200E_PCI_THRESHOLD 0x42 /* burst / continous req threshold */
  678. /* PBI master control register */
  679. #define PCA200E_CTRL_DIS_CACHE_RD (1<<0) /* disable cache-line reads */
  680. #define PCA200E_CTRL_DIS_WRT_INVAL (1<<1) /* disable writes and invalidates */
  681. #define PCA200E_CTRL_2_CACHE_WRT_INVAL (1<<2) /* require 2 cache-lines for writes and invalidates */
  682. #define PCA200E_CTRL_IGN_LAT_TIMER (1<<3) /* ignore the latency timer */
  683. #define PCA200E_CTRL_ENA_CONT_REQ_MODE (1<<4) /* enable continuous request mode */
  684. #define PCA200E_CTRL_LARGE_PCI_BURSTS (1<<5) /* force large PCI bus bursts */
  685. #define PCA200E_CTRL_CONVERT_ENDIAN (1<<6) /* convert endianess of slave RAM accesses */
  686. #define SBA200E_PROM_NAME "FORE,sba-200e" /* device name in openprom tree */
  687. /* size of SBA-200E registers */
  688. #define SBA200E_HCR_LENGTH 4
  689. #define SBA200E_BSR_LENGTH 4
  690. #define SBA200E_ISR_LENGTH 4
  691. #define SBA200E_RAM_LENGTH 0x40000
  692. /* SBA-200E SBUS burst transfer size register */
  693. #define SBA200E_BSR_BURST4 0x04
  694. #define SBA200E_BSR_BURST8 0x08
  695. #define SBA200E_BSR_BURST16 0x10
  696. /* SBA-200E host control register */
  697. #define SBA200E_HCR_RESET (1<<0) /* read / write (sticky) */
  698. #define SBA200E_HCR_HOLD_LOCK (1<<1) /* read / write (sticky) */
  699. #define SBA200E_HCR_I960FAIL (1<<2) /* read */
  700. #define SBA200E_HCR_I960SETINTR (1<<2) /* write */
  701. #define SBA200E_HCR_OUTFULL (1<<3) /* read */
  702. #define SBA200E_HCR_INTR_CLR (1<<3) /* write */
  703. #define SBA200E_HCR_INTR_ENA (1<<4) /* read / write (sticky) */
  704. #define SBA200E_HCR_ESPHOLD (1<<5) /* read */
  705. #define SBA200E_HCR_INFULL (1<<6) /* read */
  706. #define SBA200E_HCR_TESTMODE (1<<7) /* read */
  707. #define SBA200E_HCR_INTR_REQ (1<<8) /* read */
  708. #define SBA200E_HCR_STICKY (SBA200E_HCR_RESET | SBA200E_HCR_HOLD_LOCK | SBA200E_HCR_INTR_ENA)
  709. #endif /* __KERNEL__ */
  710. #endif /* _FORE200E_H */