defza.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /* FDDI network adapter driver for DEC FDDIcontroller 700/700-C devices.
  3. *
  4. * Copyright (c) 2018 Maciej W. Rozycki
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. *
  11. * References:
  12. *
  13. * Dave Sawyer & Phil Weeks & Frank Itkowsky,
  14. * "DEC FDDIcontroller 700 Port Specification",
  15. * Revision 1.1, Digital Equipment Corporation
  16. */
  17. #include <linux/compiler.h>
  18. #include <linux/if_fddi.h>
  19. #include <linux/spinlock.h>
  20. #include <linux/timer.h>
  21. #include <linux/types.h>
  22. /* IOmem register offsets. */
  23. #define FZA_REG_BASE 0x100000 /* register base address */
  24. #define FZA_REG_RESET 0x100200 /* reset, r/w */
  25. #define FZA_REG_INT_EVENT 0x100400 /* interrupt event, r/w1c */
  26. #define FZA_REG_STATUS 0x100402 /* status, r/o */
  27. #define FZA_REG_INT_MASK 0x100404 /* interrupt mask, r/w */
  28. #define FZA_REG_CONTROL_A 0x100500 /* control A, r/w1s */
  29. #define FZA_REG_CONTROL_B 0x100502 /* control B, r/w */
  30. /* Reset register constants. Bits 1:0 are r/w, others are fixed at 0. */
  31. #define FZA_RESET_DLU 0x0002 /* OR with INIT to blast flash memory */
  32. #define FZA_RESET_INIT 0x0001 /* switch into the reset state */
  33. #define FZA_RESET_CLR 0x0000 /* run self-test and return to work */
  34. /* Interrupt event register constants. All bits are r/w1c. */
  35. #define FZA_EVENT_DLU_DONE 0x0800 /* flash memory write complete */
  36. #define FZA_EVENT_FLUSH_TX 0x0400 /* transmit ring flush request */
  37. #define FZA_EVENT_PM_PARITY_ERR 0x0200 /* onboard packet memory parity err */
  38. #define FZA_EVENT_HB_PARITY_ERR 0x0100 /* host bus parity error */
  39. #define FZA_EVENT_NXM_ERR 0x0080 /* non-existent memory access error;
  40. * also raised for unaligned and
  41. * unsupported partial-word accesses
  42. */
  43. #define FZA_EVENT_LINK_ST_CHG 0x0040 /* link status change */
  44. #define FZA_EVENT_STATE_CHG 0x0020 /* adapter state change */
  45. #define FZA_EVENT_UNS_POLL 0x0010 /* unsolicited event service request */
  46. #define FZA_EVENT_CMD_DONE 0x0008 /* command done ack */
  47. #define FZA_EVENT_SMT_TX_POLL 0x0004 /* SMT frame transmit request */
  48. #define FZA_EVENT_RX_POLL 0x0002 /* receive request (packet avail.) */
  49. #define FZA_EVENT_TX_DONE 0x0001 /* RMC transmit done ack */
  50. /* Status register constants. All bits are r/o. */
  51. #define FZA_STATUS_DLU_SHIFT 0xc /* down line upgrade status bits */
  52. #define FZA_STATUS_DLU_MASK 0x03
  53. #define FZA_STATUS_LINK_SHIFT 0xb /* link status bits */
  54. #define FZA_STATUS_LINK_MASK 0x01
  55. #define FZA_STATUS_STATE_SHIFT 0x8 /* adapter state bits */
  56. #define FZA_STATUS_STATE_MASK 0x07
  57. #define FZA_STATUS_HALT_SHIFT 0x0 /* halt reason bits */
  58. #define FZA_STATUS_HALT_MASK 0xff
  59. #define FZA_STATUS_TEST_SHIFT 0x0 /* test failure bits */
  60. #define FZA_STATUS_TEST_MASK 0xff
  61. #define FZA_STATUS_GET_DLU(x) (((x) >> FZA_STATUS_DLU_SHIFT) & \
  62. FZA_STATUS_DLU_MASK)
  63. #define FZA_STATUS_GET_LINK(x) (((x) >> FZA_STATUS_LINK_SHIFT) & \
  64. FZA_STATUS_LINK_MASK)
  65. #define FZA_STATUS_GET_STATE(x) (((x) >> FZA_STATUS_STATE_SHIFT) & \
  66. FZA_STATUS_STATE_MASK)
  67. #define FZA_STATUS_GET_HALT(x) (((x) >> FZA_STATUS_HALT_SHIFT) & \
  68. FZA_STATUS_HALT_MASK)
  69. #define FZA_STATUS_GET_TEST(x) (((x) >> FZA_STATUS_TEST_SHIFT) & \
  70. FZA_STATUS_TEST_MASK)
  71. #define FZA_DLU_FAILURE 0x0 /* DLU catastrophic error; brain dead */
  72. #define FZA_DLU_ERROR 0x1 /* DLU error; old firmware intact */
  73. #define FZA_DLU_SUCCESS 0x2 /* DLU OK; new firmware loaded */
  74. #define FZA_LINK_OFF 0x0 /* link unavailable */
  75. #define FZA_LINK_ON 0x1 /* link available */
  76. #define FZA_STATE_RESET 0x0 /* resetting */
  77. #define FZA_STATE_UNINITIALIZED 0x1 /* after a reset */
  78. #define FZA_STATE_INITIALIZED 0x2 /* initialized */
  79. #define FZA_STATE_RUNNING 0x3 /* running (link active) */
  80. #define FZA_STATE_MAINTENANCE 0x4 /* running (link looped back) */
  81. #define FZA_STATE_HALTED 0x5 /* halted (error condition) */
  82. #define FZA_HALT_UNKNOWN 0x00 /* unknown reason */
  83. #define FZA_HALT_HOST 0x01 /* host-directed HALT */
  84. #define FZA_HALT_HB_PARITY 0x02 /* host bus parity error */
  85. #define FZA_HALT_NXM 0x03 /* adapter non-existent memory ref. */
  86. #define FZA_HALT_SW 0x04 /* adapter software fault */
  87. #define FZA_HALT_HW 0x05 /* adapter hardware fault */
  88. #define FZA_HALT_PC_TRACE 0x06 /* PC Trace path test */
  89. #define FZA_HALT_DLSW 0x07 /* data link software fault */
  90. #define FZA_HALT_DLHW 0x08 /* data link hardware fault */
  91. #define FZA_TEST_FATAL 0x00 /* self-test catastrophic failure */
  92. #define FZA_TEST_68K 0x01 /* 68000 CPU */
  93. #define FZA_TEST_SRAM_BWADDR 0x02 /* SRAM byte/word address */
  94. #define FZA_TEST_SRAM_DBUS 0x03 /* SRAM data bus */
  95. #define FZA_TEST_SRAM_STUCK1 0x04 /* SRAM stuck-at range 1 */
  96. #define FZA_TEST_SRAM_STUCK2 0x05 /* SRAM stuck-at range 2 */
  97. #define FZA_TEST_SRAM_COUPL1 0x06 /* SRAM coupling range 1 */
  98. #define FZA_TEST_SRAM_COUPL2 0x07 /* SRAM coupling */
  99. #define FZA_TEST_FLASH_CRC 0x08 /* Flash CRC */
  100. #define FZA_TEST_ROM 0x09 /* option ROM */
  101. #define FZA_TEST_PHY_CSR 0x0a /* PHY CSR */
  102. #define FZA_TEST_MAC_BIST 0x0b /* MAC BiST */
  103. #define FZA_TEST_MAC_CSR 0x0c /* MAC CSR */
  104. #define FZA_TEST_MAC_ADDR_UNIQ 0x0d /* MAC unique address */
  105. #define FZA_TEST_ELM_BIST 0x0e /* ELM BiST */
  106. #define FZA_TEST_ELM_CSR 0x0f /* ELM CSR */
  107. #define FZA_TEST_ELM_ADDR_UNIQ 0x10 /* ELM unique address */
  108. #define FZA_TEST_CAM 0x11 /* CAM */
  109. #define FZA_TEST_NIROM 0x12 /* NI ROM checksum */
  110. #define FZA_TEST_SC_LOOP 0x13 /* SC loopback packet */
  111. #define FZA_TEST_LM_LOOP 0x14 /* LM loopback packet */
  112. #define FZA_TEST_EB_LOOP 0x15 /* EB loopback packet */
  113. #define FZA_TEST_SC_LOOP_BYPS 0x16 /* SC bypass loopback packet */
  114. #define FZA_TEST_LM_LOOP_LOCAL 0x17 /* LM local loopback packet */
  115. #define FZA_TEST_EB_LOOP_LOCAL 0x18 /* EB local loopback packet */
  116. #define FZA_TEST_CDC_LOOP 0x19 /* CDC loopback packet */
  117. #define FZA_TEST_FIBER_LOOP 0x1A /* FIBER loopback packet */
  118. #define FZA_TEST_CAM_MATCH_LOOP 0x1B /* CAM match packet loopback */
  119. #define FZA_TEST_68K_IRQ_STUCK 0x1C /* 68000 interrupt line stuck-at */
  120. #define FZA_TEST_IRQ_PRESENT 0x1D /* interrupt present register */
  121. #define FZA_TEST_RMC_BIST 0x1E /* RMC BiST */
  122. #define FZA_TEST_RMC_CSR 0x1F /* RMC CSR */
  123. #define FZA_TEST_RMC_ADDR_UNIQ 0x20 /* RMC unique address */
  124. #define FZA_TEST_PM_DPATH 0x21 /* packet memory data path */
  125. #define FZA_TEST_PM_ADDR 0x22 /* packet memory address */
  126. #define FZA_TEST_RES_23 0x23 /* reserved */
  127. #define FZA_TEST_PM_DESC 0x24 /* packet memory descriptor */
  128. #define FZA_TEST_PM_OWN 0x25 /* packet memory own bit */
  129. #define FZA_TEST_PM_PARITY 0x26 /* packet memory parity */
  130. #define FZA_TEST_PM_BSWAP 0x27 /* packet memory byte swap */
  131. #define FZA_TEST_PM_WSWAP 0x28 /* packet memory word swap */
  132. #define FZA_TEST_PM_REF 0x29 /* packet memory refresh */
  133. #define FZA_TEST_PM_CSR 0x2A /* PM CSR */
  134. #define FZA_TEST_PORT_STATUS 0x2B /* port status register */
  135. #define FZA_TEST_HOST_IRQMASK 0x2C /* host interrupt mask */
  136. #define FZA_TEST_TIMER_IRQ1 0x2D /* RTOS timer */
  137. #define FZA_TEST_FORCE_IRQ1 0x2E /* force RTOS IRQ1 */
  138. #define FZA_TEST_TIMER_IRQ5 0x2F /* IRQ5 backoff timer */
  139. #define FZA_TEST_FORCE_IRQ5 0x30 /* force IRQ5 */
  140. #define FZA_TEST_RES_31 0x31 /* reserved */
  141. #define FZA_TEST_IC_PRIO 0x32 /* interrupt controller priority */
  142. #define FZA_TEST_PM_FULL 0x33 /* full packet memory */
  143. #define FZA_TEST_PMI_DMA 0x34 /* PMI DMA */
  144. /* Interrupt mask register constants. All bits are r/w. */
  145. #define FZA_MASK_RESERVED 0xf000 /* unused */
  146. #define FZA_MASK_DLU_DONE 0x0800 /* flash memory write complete */
  147. #define FZA_MASK_FLUSH_TX 0x0400 /* transmit ring flush request */
  148. #define FZA_MASK_PM_PARITY_ERR 0x0200 /* onboard packet memory parity error
  149. */
  150. #define FZA_MASK_HB_PARITY_ERR 0x0100 /* host bus parity error */
  151. #define FZA_MASK_NXM_ERR 0x0080 /* adapter non-existent memory
  152. * reference
  153. */
  154. #define FZA_MASK_LINK_ST_CHG 0x0040 /* link status change */
  155. #define FZA_MASK_STATE_CHG 0x0020 /* adapter state change */
  156. #define FZA_MASK_UNS_POLL 0x0010 /* unsolicited event service request */
  157. #define FZA_MASK_CMD_DONE 0x0008 /* command ring entry processed */
  158. #define FZA_MASK_SMT_TX_POLL 0x0004 /* SMT frame transmit request */
  159. #define FZA_MASK_RCV_POLL 0x0002 /* receive request (packet available)
  160. */
  161. #define FZA_MASK_TX_DONE 0x0001 /* RMC transmit done acknowledge */
  162. /* Which interrupts to receive: 0/1 is mask/unmask. */
  163. #define FZA_MASK_NONE 0x0000
  164. #define FZA_MASK_NORMAL \
  165. ((~(FZA_MASK_RESERVED | FZA_MASK_DLU_DONE | \
  166. FZA_MASK_PM_PARITY_ERR | FZA_MASK_HB_PARITY_ERR | \
  167. FZA_MASK_NXM_ERR)) & 0xffff)
  168. /* Control A register constants. */
  169. #define FZA_CONTROL_A_HB_PARITY_ERR 0x8000 /* host bus parity error */
  170. #define FZA_CONTROL_A_NXM_ERR 0x4000 /* adapter non-existent memory
  171. * reference
  172. */
  173. #define FZA_CONTROL_A_SMT_RX_OVFL 0x0040 /* SMT receive overflow */
  174. #define FZA_CONTROL_A_FLUSH_DONE 0x0020 /* flush tx request complete */
  175. #define FZA_CONTROL_A_SHUT 0x0010 /* turn the interface off */
  176. #define FZA_CONTROL_A_HALT 0x0008 /* halt the controller */
  177. #define FZA_CONTROL_A_CMD_POLL 0x0004 /* command ring poll */
  178. #define FZA_CONTROL_A_SMT_RX_POLL 0x0002 /* SMT receive ring poll */
  179. #define FZA_CONTROL_A_TX_POLL 0x0001 /* transmit poll */
  180. /* Control B register constants. All bits are r/w.
  181. *
  182. * Possible values:
  183. * 0x0000 after booting into REX,
  184. * 0x0003 after issuing `boot #/mop'.
  185. */
  186. #define FZA_CONTROL_B_CONSOLE 0x0002 /* OR with DRIVER for console
  187. * (TC firmware) mode
  188. */
  189. #define FZA_CONTROL_B_DRIVER 0x0001 /* driver mode */
  190. #define FZA_CONTROL_B_IDLE 0x0000 /* no driver installed */
  191. #define FZA_RESET_PAD \
  192. (FZA_REG_RESET - FZA_REG_BASE)
  193. #define FZA_INT_EVENT_PAD \
  194. (FZA_REG_INT_EVENT - FZA_REG_RESET - sizeof(u16))
  195. #define FZA_CONTROL_A_PAD \
  196. (FZA_REG_CONTROL_A - FZA_REG_INT_MASK - sizeof(u16))
  197. /* Layout of registers. */
  198. struct fza_regs {
  199. u8 pad0[FZA_RESET_PAD];
  200. u16 reset; /* reset register */
  201. u8 pad1[FZA_INT_EVENT_PAD];
  202. u16 int_event; /* interrupt event register */
  203. u16 status; /* status register */
  204. u16 int_mask; /* interrupt mask register */
  205. u8 pad2[FZA_CONTROL_A_PAD];
  206. u16 control_a; /* control A register */
  207. u16 control_b; /* control B register */
  208. };
  209. /* Command descriptor ring entry. */
  210. struct fza_ring_cmd {
  211. u32 cmd_own; /* bit 31: ownership, bits [30:0]: command */
  212. u32 stat; /* command status */
  213. u32 buffer; /* address of the buffer in the FZA space */
  214. u32 pad0;
  215. };
  216. #define FZA_RING_CMD 0x200400 /* command ring address */
  217. #define FZA_RING_CMD_SIZE 0x40 /* command descriptor ring
  218. * size
  219. */
  220. /* Command constants. */
  221. #define FZA_RING_CMD_MASK 0x7fffffff
  222. #define FZA_RING_CMD_NOP 0x00000000 /* nop */
  223. #define FZA_RING_CMD_INIT 0x00000001 /* initialize */
  224. #define FZA_RING_CMD_MODCAM 0x00000002 /* modify CAM */
  225. #define FZA_RING_CMD_PARAM 0x00000003 /* set system parameters */
  226. #define FZA_RING_CMD_MODPROM 0x00000004 /* modify promiscuous mode */
  227. #define FZA_RING_CMD_SETCHAR 0x00000005 /* set link characteristics */
  228. #define FZA_RING_CMD_RDCNTR 0x00000006 /* read counters */
  229. #define FZA_RING_CMD_STATUS 0x00000007 /* get link status */
  230. #define FZA_RING_CMD_RDCAM 0x00000008 /* read CAM */
  231. /* Command status constants. */
  232. #define FZA_RING_STAT_SUCCESS 0x00000000
  233. /* Unsolicited event descriptor ring entry. */
  234. struct fza_ring_uns {
  235. u32 own; /* bit 31: ownership, bits [30:0]: reserved */
  236. u32 id; /* event ID */
  237. u32 buffer; /* address of the buffer in the FZA space */
  238. u32 pad0; /* reserved */
  239. };
  240. #define FZA_RING_UNS 0x200800 /* unsolicited ring address */
  241. #define FZA_RING_UNS_SIZE 0x40 /* unsolicited descriptor ring
  242. * size
  243. */
  244. /* Unsolicited event constants. */
  245. #define FZA_RING_UNS_UND 0x00000000 /* undefined event ID */
  246. #define FZA_RING_UNS_INIT_IN 0x00000001 /* ring init initiated */
  247. #define FZA_RING_UNS_INIT_RX 0x00000002 /* ring init received */
  248. #define FZA_RING_UNS_BEAC_IN 0x00000003 /* ring beaconing initiated */
  249. #define FZA_RING_UNS_DUP_ADDR 0x00000004 /* duplicate address detected */
  250. #define FZA_RING_UNS_DUP_TOK 0x00000005 /* duplicate token detected */
  251. #define FZA_RING_UNS_PURG_ERR 0x00000006 /* ring purger error */
  252. #define FZA_RING_UNS_STRIP_ERR 0x00000007 /* bridge strip error */
  253. #define FZA_RING_UNS_OP_OSC 0x00000008 /* ring op oscillation */
  254. #define FZA_RING_UNS_BEAC_RX 0x00000009 /* directed beacon received */
  255. #define FZA_RING_UNS_PCT_IN 0x0000000a /* PC trace initiated */
  256. #define FZA_RING_UNS_PCT_RX 0x0000000b /* PC trace received */
  257. #define FZA_RING_UNS_TX_UNDER 0x0000000c /* transmit underrun */
  258. #define FZA_RING_UNS_TX_FAIL 0x0000000d /* transmit failure */
  259. #define FZA_RING_UNS_RX_OVER 0x0000000e /* receive overrun */
  260. /* RMC (Ring Memory Control) transmit descriptor ring entry. */
  261. struct fza_ring_rmc_tx {
  262. u32 rmc; /* RMC information */
  263. u32 avl; /* available for host (unused by RMC) */
  264. u32 own; /* bit 31: ownership, bits [30:0]: reserved */
  265. u32 pad0; /* reserved */
  266. };
  267. #define FZA_TX_BUFFER_ADDR(x) (0x200000 | (((x) & 0xffff) << 5))
  268. #define FZA_TX_BUFFER_SIZE 512
  269. struct fza_buffer_tx {
  270. u32 data[FZA_TX_BUFFER_SIZE / sizeof(u32)];
  271. };
  272. /* Transmit ring RMC constants. */
  273. #define FZA_RING_TX_SOP 0x80000000 /* start of packet */
  274. #define FZA_RING_TX_EOP 0x40000000 /* end of packet */
  275. #define FZA_RING_TX_DTP 0x20000000 /* discard this packet */
  276. #define FZA_RING_TX_VBC 0x10000000 /* valid buffer byte count */
  277. #define FZA_RING_TX_DCC_MASK 0x0f000000 /* DMA completion code */
  278. #define FZA_RING_TX_DCC_SUCCESS 0x01000000 /* transmit succeeded */
  279. #define FZA_RING_TX_DCC_DTP_SOP 0x02000000 /* DTP set at SOP */
  280. #define FZA_RING_TX_DCC_DTP 0x04000000 /* DTP set within packet */
  281. #define FZA_RING_TX_DCC_ABORT 0x05000000 /* MAC-requested abort */
  282. #define FZA_RING_TX_DCC_PARITY 0x06000000 /* xmit data parity error */
  283. #define FZA_RING_TX_DCC_UNDRRUN 0x07000000 /* transmit underrun */
  284. #define FZA_RING_TX_XPO_MASK 0x003fe000 /* transmit packet offset */
  285. /* Host receive descriptor ring entry. */
  286. struct fza_ring_hst_rx {
  287. u32 buf0_own; /* bit 31: ownership, bits [30:23]: unused,
  288. * bits [22:0]: right-shifted address of the
  289. * buffer in system memory (low buffer)
  290. */
  291. u32 buffer1; /* bits [31:23]: unused,
  292. * bits [22:0]: right-shifted address of the
  293. * buffer in system memory (high buffer)
  294. */
  295. u32 rmc; /* RMC information */
  296. u32 pad0;
  297. };
  298. #define FZA_RX_BUFFER_SIZE (4096 + 512) /* buffer length */
  299. /* Receive ring RMC constants. */
  300. #define FZA_RING_RX_SOP 0x80000000 /* start of packet */
  301. #define FZA_RING_RX_EOP 0x40000000 /* end of packet */
  302. #define FZA_RING_RX_FSC_MASK 0x38000000 /* # of frame status bits */
  303. #define FZA_RING_RX_FSB_MASK 0x07c00000 /* frame status bits */
  304. #define FZA_RING_RX_FSB_ERR 0x04000000 /* error detected */
  305. #define FZA_RING_RX_FSB_ADDR 0x02000000 /* address recognized */
  306. #define FZA_RING_RX_FSB_COP 0x01000000 /* frame copied */
  307. #define FZA_RING_RX_FSB_F0 0x00800000 /* first additional flag */
  308. #define FZA_RING_RX_FSB_F1 0x00400000 /* second additional flag */
  309. #define FZA_RING_RX_BAD 0x00200000 /* bad packet */
  310. #define FZA_RING_RX_CRC 0x00100000 /* CRC error */
  311. #define FZA_RING_RX_RRR_MASK 0x000e0000 /* MAC receive status bits */
  312. #define FZA_RING_RX_RRR_OK 0x00000000 /* receive OK */
  313. #define FZA_RING_RX_RRR_SADDR 0x00020000 /* source address matched */
  314. #define FZA_RING_RX_RRR_DADDR 0x00040000 /* dest address not matched */
  315. #define FZA_RING_RX_RRR_ABORT 0x00060000 /* RMC abort */
  316. #define FZA_RING_RX_RRR_LENGTH 0x00080000 /* invalid length */
  317. #define FZA_RING_RX_RRR_FRAG 0x000a0000 /* fragment */
  318. #define FZA_RING_RX_RRR_FORMAT 0x000c0000 /* format error */
  319. #define FZA_RING_RX_RRR_RESET 0x000e0000 /* MAC reset */
  320. #define FZA_RING_RX_DA_MASK 0x00018000 /* daddr match status bits */
  321. #define FZA_RING_RX_DA_NONE 0x00000000 /* no match */
  322. #define FZA_RING_RX_DA_PROM 0x00008000 /* promiscuous match */
  323. #define FZA_RING_RX_DA_CAM 0x00010000 /* CAM entry match */
  324. #define FZA_RING_RX_DA_LOCAL 0x00018000 /* link addr or LLC bcast */
  325. #define FZA_RING_RX_SA_MASK 0x00006000 /* saddr match status bits */
  326. #define FZA_RING_RX_SA_NONE 0x00000000 /* no match */
  327. #define FZA_RING_RX_SA_ALIAS 0x00002000 /* alias address match */
  328. #define FZA_RING_RX_SA_CAM 0x00004000 /* CAM entry match */
  329. #define FZA_RING_RX_SA_LOCAL 0x00006000 /* link address match */
  330. /* SMT (Station Management) transmit/receive descriptor ring entry. */
  331. struct fza_ring_smt {
  332. u32 own; /* bit 31: ownership, bits [30:0]: unused */
  333. u32 rmc; /* RMC information */
  334. u32 buffer; /* address of the buffer */
  335. u32 pad0; /* reserved */
  336. };
  337. /* Ownership constants.
  338. *
  339. * Only an owner is permitted to process a given ring entry.
  340. * RMC transmit ring meanings are reversed.
  341. */
  342. #define FZA_RING_OWN_MASK 0x80000000
  343. #define FZA_RING_OWN_FZA 0x00000000 /* permit FZA, forbid host */
  344. #define FZA_RING_OWN_HOST 0x80000000 /* permit host, forbid FZA */
  345. #define FZA_RING_TX_OWN_RMC 0x80000000 /* permit RMC, forbid host */
  346. #define FZA_RING_TX_OWN_HOST 0x00000000 /* permit host, forbid RMC */
  347. /* RMC constants. */
  348. #define FZA_RING_PBC_MASK 0x00001fff /* frame length */
  349. /* Layout of counter buffers. */
  350. struct fza_counter {
  351. u32 msw;
  352. u32 lsw;
  353. };
  354. struct fza_counters {
  355. struct fza_counter sys_buf; /* system buffer unavailable */
  356. struct fza_counter tx_under; /* transmit underruns */
  357. struct fza_counter tx_fail; /* transmit failures */
  358. struct fza_counter rx_over; /* receive data overruns */
  359. struct fza_counter frame_cnt; /* frame count */
  360. struct fza_counter error_cnt; /* error count */
  361. struct fza_counter lost_cnt; /* lost count */
  362. struct fza_counter rinit_in; /* ring initialization initiated */
  363. struct fza_counter rinit_rx; /* ring initialization received */
  364. struct fza_counter beac_in; /* ring beacon initiated */
  365. struct fza_counter dup_addr; /* duplicate address test failures */
  366. struct fza_counter dup_tok; /* duplicate token detected */
  367. struct fza_counter purg_err; /* ring purge errors */
  368. struct fza_counter strip_err; /* bridge strip errors */
  369. struct fza_counter pct_in; /* traces initiated */
  370. struct fza_counter pct_rx; /* traces received */
  371. struct fza_counter lem_rej; /* LEM rejects */
  372. struct fza_counter tne_rej; /* TNE expiry rejects */
  373. struct fza_counter lem_event; /* LEM events */
  374. struct fza_counter lct_rej; /* LCT rejects */
  375. struct fza_counter conn_cmpl; /* connections completed */
  376. struct fza_counter el_buf; /* elasticity buffer errors */
  377. };
  378. /* Layout of command buffers. */
  379. /* INIT command buffer.
  380. *
  381. * Values of default link parameters given are as obtained from a
  382. * DEFZA-AA rev. C03 board. The board counts time in units of 80ns.
  383. */
  384. struct fza_cmd_init {
  385. u32 tx_mode; /* transmit mode */
  386. u32 hst_rx_size; /* host receive ring entries */
  387. struct fza_counters counters; /* counters */
  388. u8 rmc_rev[4]; /* RMC revision */
  389. u8 rom_rev[4]; /* ROM revision */
  390. u8 fw_rev[4]; /* firmware revision */
  391. u32 mop_type; /* MOP device type */
  392. u32 hst_rx; /* base of host rx descriptor ring */
  393. u32 rmc_tx; /* base of RMC tx descriptor ring */
  394. u32 rmc_tx_size; /* size of RMC tx descriptor ring */
  395. u32 smt_tx; /* base of SMT tx descriptor ring */
  396. u32 smt_tx_size; /* size of SMT tx descriptor ring */
  397. u32 smt_rx; /* base of SMT rx descriptor ring */
  398. u32 smt_rx_size; /* size of SMT rx descriptor ring */
  399. u32 hw_addr[2]; /* link address */
  400. u32 def_t_req; /* default Requested TTRT (T_REQ) --
  401. * C03: 100000 [80ns]
  402. */
  403. u32 def_tvx; /* default Valid Transmission Time
  404. * (TVX) -- C03: 32768 [80ns]
  405. */
  406. u32 def_t_max; /* default Maximum TTRT (T_MAX) --
  407. * C03: 2162688 [80ns]
  408. */
  409. u32 lem_threshold; /* default LEM threshold -- C03: 8 */
  410. u32 def_station_id[2]; /* default station ID */
  411. u32 pmd_type_alt; /* alternative PMD type code */
  412. u32 smt_ver; /* SMT version */
  413. u32 rtoken_timeout; /* default restricted token timeout
  414. * -- C03: 12500000 [80ns]
  415. */
  416. u32 ring_purger; /* default ring purger enable --
  417. * C03: 1
  418. */
  419. u32 smt_ver_max; /* max SMT version ID */
  420. u32 smt_ver_min; /* min SMT version ID */
  421. u32 pmd_type; /* PMD type code */
  422. };
  423. /* INIT command PMD type codes. */
  424. #define FZA_PMD_TYPE_MMF 0 /* Multimode fiber */
  425. #define FZA_PMD_TYPE_TW 101 /* ThinWire */
  426. #define FZA_PMD_TYPE_STP 102 /* STP */
  427. /* MODCAM/RDCAM command buffer. */
  428. #define FZA_CMD_CAM_SIZE 64 /* CAM address entry count */
  429. struct fza_cmd_cam {
  430. u32 hw_addr[FZA_CMD_CAM_SIZE][2]; /* CAM address entries */
  431. };
  432. /* PARAM command buffer.
  433. *
  434. * Permitted ranges given are as defined by the spec and obtained from a
  435. * DEFZA-AA rev. C03 board, respectively. The rtoken_timeout field is
  436. * erroneously interpreted in units of ms.
  437. */
  438. struct fza_cmd_param {
  439. u32 loop_mode; /* loopback mode */
  440. u32 t_max; /* Maximum TTRT (T_MAX)
  441. * def: ??? [80ns]
  442. * C03: [t_req+1,4294967295] [80ns]
  443. */
  444. u32 t_req; /* Requested TTRT (T_REQ)
  445. * def: [50000,2097151] [80ns]
  446. * C03: [50001,t_max-1] [80ns]
  447. */
  448. u32 tvx; /* Valid Transmission Time (TVX)
  449. * def: [29375,65280] [80ns]
  450. * C03: [29376,65279] [80ns]
  451. */
  452. u32 lem_threshold; /* LEM threshold */
  453. u32 station_id[2]; /* station ID */
  454. u32 rtoken_timeout; /* restricted token timeout
  455. * def: [0,125000000] [80ns]
  456. * C03: [0,9999] [ms]
  457. */
  458. u32 ring_purger; /* ring purger enable: 0|1 */
  459. };
  460. /* Loopback modes for the PARAM command. */
  461. #define FZA_LOOP_NORMAL 0
  462. #define FZA_LOOP_INTERN 1
  463. #define FZA_LOOP_EXTERN 2
  464. /* MODPROM command buffer. */
  465. struct fza_cmd_modprom {
  466. u32 llc_prom; /* LLC promiscuous enable */
  467. u32 smt_prom; /* SMT promiscuous enable */
  468. u32 llc_multi; /* LLC multicast promiscuous enable */
  469. u32 llc_bcast; /* LLC broadcast promiscuous enable */
  470. };
  471. /* SETCHAR command buffer.
  472. *
  473. * Permitted ranges are as for the PARAM command.
  474. */
  475. struct fza_cmd_setchar {
  476. u32 t_max; /* Maximum TTRT (T_MAX) */
  477. u32 t_req; /* Requested TTRT (T_REQ) */
  478. u32 tvx; /* Valid Transmission Time (TVX) */
  479. u32 lem_threshold; /* LEM threshold */
  480. u32 rtoken_timeout; /* restricted token timeout */
  481. u32 ring_purger; /* ring purger enable */
  482. };
  483. /* RDCNTR command buffer. */
  484. struct fza_cmd_rdcntr {
  485. struct fza_counters counters; /* counters */
  486. };
  487. /* STATUS command buffer. */
  488. struct fza_cmd_status {
  489. u32 led_state; /* LED state */
  490. u32 rmt_state; /* ring management state */
  491. u32 link_state; /* link state */
  492. u32 dup_addr; /* duplicate address flag */
  493. u32 ring_purger; /* ring purger state */
  494. u32 t_neg; /* negotiated TTRT [80ns] */
  495. u32 una[2]; /* upstream neighbour address */
  496. u32 una_timeout; /* UNA timed out */
  497. u32 strip_mode; /* frame strip mode */
  498. u32 yield_mode; /* claim token yield mode */
  499. u32 phy_state; /* PHY state */
  500. u32 neigh_phy; /* neighbour PHY type */
  501. u32 reject; /* reject reason */
  502. u32 phy_lee; /* PHY link error estimate [-log10] */
  503. u32 una_old[2]; /* old upstream neighbour address */
  504. u32 rmt_mac; /* remote MAC indicated */
  505. u32 ring_err; /* ring error reason */
  506. u32 beac_rx[2]; /* sender of last directed beacon */
  507. u32 un_dup_addr; /* upstream neighbr dup address flag */
  508. u32 dna[2]; /* downstream neighbour address */
  509. u32 dna_old[2]; /* old downstream neighbour address */
  510. };
  511. /* Common command buffer. */
  512. union fza_cmd_buf {
  513. struct fza_cmd_init init;
  514. struct fza_cmd_cam cam;
  515. struct fza_cmd_param param;
  516. struct fza_cmd_modprom modprom;
  517. struct fza_cmd_setchar setchar;
  518. struct fza_cmd_rdcntr rdcntr;
  519. struct fza_cmd_status status;
  520. };
  521. /* MAC (Media Access Controller) chip packet request header constants. */
  522. /* Packet request header byte #0. */
  523. #define FZA_PRH0_FMT_TYPE_MASK 0xc0 /* type of packet, always zero */
  524. #define FZA_PRH0_TOK_TYPE_MASK 0x30 /* type of token required
  525. * to send this frame
  526. */
  527. #define FZA_PRH0_TKN_TYPE_ANY 0x30 /* use either token type */
  528. #define FZA_PRH0_TKN_TYPE_UNR 0x20 /* use an unrestricted token */
  529. #define FZA_PRH0_TKN_TYPE_RST 0x10 /* use a restricted token */
  530. #define FZA_PRH0_TKN_TYPE_IMM 0x00 /* send immediately, no token required
  531. */
  532. #define FZA_PRH0_FRAME_MASK 0x08 /* type of frame to send */
  533. #define FZA_PRH0_FRAME_SYNC 0x08 /* send a synchronous frame */
  534. #define FZA_PRH0_FRAME_ASYNC 0x00 /* send an asynchronous frame */
  535. #define FZA_PRH0_MODE_MASK 0x04 /* send mode */
  536. #define FZA_PRH0_MODE_IMMED 0x04 /* an immediate mode, send regardless
  537. * of the ring operational state
  538. */
  539. #define FZA_PRH0_MODE_NORMAL 0x00 /* a normal mode, send only if ring
  540. * operational
  541. */
  542. #define FZA_PRH0_SF_MASK 0x02 /* send frame first */
  543. #define FZA_PRH0_SF_FIRST 0x02 /* send this frame first
  544. * with this token capture
  545. */
  546. #define FZA_PRH0_SF_NORMAL 0x00 /* treat this frame normally */
  547. #define FZA_PRH0_BCN_MASK 0x01 /* beacon frame */
  548. #define FZA_PRH0_BCN_BEACON 0x01 /* send the frame only
  549. * if in the beacon state
  550. */
  551. #define FZA_PRH0_BCN_DATA 0x01 /* send the frame only
  552. * if in the data state
  553. */
  554. /* Packet request header byte #1. */
  555. /* bit 7 always zero */
  556. #define FZA_PRH1_SL_MASK 0x40 /* send frame last */
  557. #define FZA_PRH1_SL_LAST 0x40 /* send this frame last, releasing
  558. * the token afterwards
  559. */
  560. #define FZA_PRH1_SL_NORMAL 0x00 /* treat this frame normally */
  561. #define FZA_PRH1_CRC_MASK 0x20 /* CRC append */
  562. #define FZA_PRH1_CRC_NORMAL 0x20 /* calculate the CRC and append it
  563. * as the FCS field to the frame
  564. */
  565. #define FZA_PRH1_CRC_SKIP 0x00 /* leave the frame as is */
  566. #define FZA_PRH1_TKN_SEND_MASK 0x18 /* type of token to send after the
  567. * frame if this is the last frame
  568. */
  569. #define FZA_PRH1_TKN_SEND_ORIG 0x18 /* send a token of the same type as the
  570. * originally captured one
  571. */
  572. #define FZA_PRH1_TKN_SEND_RST 0x10 /* send a restricted token */
  573. #define FZA_PRH1_TKN_SEND_UNR 0x08 /* send an unrestricted token */
  574. #define FZA_PRH1_TKN_SEND_NONE 0x00 /* send no token */
  575. #define FZA_PRH1_EXTRA_FS_MASK 0x07 /* send extra frame status indicators
  576. */
  577. #define FZA_PRH1_EXTRA_FS_ST 0x07 /* TR RR ST II */
  578. #define FZA_PRH1_EXTRA_FS_SS 0x06 /* TR RR SS II */
  579. #define FZA_PRH1_EXTRA_FS_SR 0x05 /* TR RR SR II */
  580. #define FZA_PRH1_EXTRA_FS_NONE1 0x04 /* TR RR II II */
  581. #define FZA_PRH1_EXTRA_FS_RT 0x03 /* TR RR RT II */
  582. #define FZA_PRH1_EXTRA_FS_RS 0x02 /* TR RR RS II */
  583. #define FZA_PRH1_EXTRA_FS_RR 0x01 /* TR RR RR II */
  584. #define FZA_PRH1_EXTRA_FS_NONE 0x00 /* TR RR II II */
  585. /* Packet request header byte #2. */
  586. #define FZA_PRH2_NORMAL 0x00 /* always zero */
  587. /* PRH used for LLC frames. */
  588. #define FZA_PRH0_LLC (FZA_PRH0_TKN_TYPE_UNR)
  589. #define FZA_PRH1_LLC (FZA_PRH1_CRC_NORMAL | FZA_PRH1_TKN_SEND_UNR)
  590. #define FZA_PRH2_LLC (FZA_PRH2_NORMAL)
  591. /* PRH used for SMT frames. */
  592. #define FZA_PRH0_SMT (FZA_PRH0_TKN_TYPE_UNR)
  593. #define FZA_PRH1_SMT (FZA_PRH1_CRC_NORMAL | FZA_PRH1_TKN_SEND_UNR)
  594. #define FZA_PRH2_SMT (FZA_PRH2_NORMAL)
  595. #if ((FZA_RING_RX_SIZE) < 2) || ((FZA_RING_RX_SIZE) > 256)
  596. # error FZA_RING_RX_SIZE has to be from 2 up to 256
  597. #endif
  598. #if ((FZA_RING_TX_MODE) != 0) && ((FZA_RING_TX_MODE) != 1)
  599. # error FZA_RING_TX_MODE has to be either 0 or 1
  600. #endif
  601. #define FZA_RING_TX_SIZE (512 << (FZA_RING_TX_MODE))
  602. struct fza_private {
  603. struct device *bdev; /* pointer to the bus device */
  604. const char *name; /* printable device name */
  605. void __iomem *mmio; /* MMIO ioremap cookie */
  606. struct fza_regs __iomem *regs; /* pointer to FZA registers */
  607. struct sk_buff *rx_skbuff[FZA_RING_RX_SIZE];
  608. /* all skbs assigned to the host
  609. * receive descriptors
  610. */
  611. dma_addr_t rx_dma[FZA_RING_RX_SIZE];
  612. /* their corresponding DMA addresses */
  613. struct fza_ring_cmd __iomem *ring_cmd;
  614. /* pointer to the command descriptor
  615. * ring
  616. */
  617. int ring_cmd_index; /* index to the command descriptor ring
  618. * for the next command
  619. */
  620. struct fza_ring_uns __iomem *ring_uns;
  621. /* pointer to the unsolicited
  622. * descriptor ring
  623. */
  624. int ring_uns_index; /* index to the unsolicited descriptor
  625. * ring for the next event
  626. */
  627. struct fza_ring_rmc_tx __iomem *ring_rmc_tx;
  628. /* pointer to the RMC transmit
  629. * descriptor ring (obtained from the
  630. * INIT command)
  631. */
  632. int ring_rmc_tx_size; /* number of entries in the RMC
  633. * transmit descriptor ring (obtained
  634. * from the INIT command)
  635. */
  636. int ring_rmc_tx_index; /* index to the RMC transmit descriptor
  637. * ring for the next transmission
  638. */
  639. int ring_rmc_txd_index; /* index to the RMC transmit descriptor
  640. * ring for the next transmit done
  641. * acknowledge
  642. */
  643. struct fza_ring_hst_rx __iomem *ring_hst_rx;
  644. /* pointer to the host receive
  645. * descriptor ring (obtained from the
  646. * INIT command)
  647. */
  648. int ring_hst_rx_size; /* number of entries in the host
  649. * receive descriptor ring (set by the
  650. * INIT command)
  651. */
  652. int ring_hst_rx_index; /* index to the host receive descriptor
  653. * ring for the next transmission
  654. */
  655. struct fza_ring_smt __iomem *ring_smt_tx;
  656. /* pointer to the SMT transmit
  657. * descriptor ring (obtained from the
  658. * INIT command)
  659. */
  660. int ring_smt_tx_size; /* number of entries in the SMT
  661. * transmit descriptor ring (obtained
  662. * from the INIT command)
  663. */
  664. int ring_smt_tx_index; /* index to the SMT transmit descriptor
  665. * ring for the next transmission
  666. */
  667. struct fza_ring_smt __iomem *ring_smt_rx;
  668. /* pointer to the SMT transmit
  669. * descriptor ring (obtained from the
  670. * INIT command)
  671. */
  672. int ring_smt_rx_size; /* number of entries in the SMT
  673. * receive descriptor ring (obtained
  674. * from the INIT command)
  675. */
  676. int ring_smt_rx_index; /* index to the SMT receive descriptor
  677. * ring for the next transmission
  678. */
  679. struct fza_buffer_tx __iomem *buffer_tx;
  680. /* pointer to the RMC transmit buffers
  681. */
  682. uint state; /* adapter expected state */
  683. spinlock_t lock; /* for device & private data access */
  684. uint int_mask; /* interrupt source selector */
  685. int cmd_done_flag; /* command completion trigger */
  686. wait_queue_head_t cmd_done_wait;
  687. int state_chg_flag; /* state change trigger */
  688. wait_queue_head_t state_chg_wait;
  689. struct timer_list reset_timer; /* RESET time-out trigger */
  690. int timer_state; /* RESET trigger state */
  691. int queue_active; /* whether to enable queueing */
  692. struct net_device_stats stats;
  693. uint irq_count_flush_tx; /* transmit flush irqs */
  694. uint irq_count_uns_poll; /* unsolicited event irqs */
  695. uint irq_count_smt_tx_poll; /* SMT transmit irqs */
  696. uint irq_count_rx_poll; /* host receive irqs */
  697. uint irq_count_tx_done; /* transmit done irqs */
  698. uint irq_count_cmd_done; /* command done irqs */
  699. uint irq_count_state_chg; /* state change irqs */
  700. uint irq_count_link_st_chg; /* link status change irqs */
  701. uint t_max; /* T_MAX */
  702. uint t_req; /* T_REQ */
  703. uint tvx; /* TVX */
  704. uint lem_threshold; /* LEM threshold */
  705. uint station_id[2]; /* station ID */
  706. uint rtoken_timeout; /* restricted token timeout */
  707. uint ring_purger; /* ring purger enable flag */
  708. };
  709. struct fza_fddihdr {
  710. u8 pa[2]; /* preamble */
  711. u8 sd; /* starting delimiter */
  712. struct fddihdr hdr;
  713. } __packed;