fore200e.h 39 KB

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