lmc_var.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. #ifndef _LMC_VAR_H_
  2. #define _LMC_VAR_H_
  3. /*
  4. * Copyright (c) 1997-2000 LAN Media Corporation (LMC)
  5. * All rights reserved. www.lanmedia.com
  6. *
  7. * This code is written by:
  8. * Andrew Stanley-Jones (asj@cban.com)
  9. * Rob Braun (bbraun@vix.com),
  10. * Michael Graff (explorer@vix.com) and
  11. * Matt Thomas (matt@3am-software.com).
  12. *
  13. * This software may be used and distributed according to the terms
  14. * of the GNU General Public License version 2, incorporated herein by reference.
  15. */
  16. #include <linux/timer.h>
  17. /*
  18. * basic definitions used in lmc include files
  19. */
  20. typedef struct lmc___softc lmc_softc_t;
  21. typedef struct lmc___media lmc_media_t;
  22. typedef struct lmc___ctl lmc_ctl_t;
  23. #define lmc_csrptr_t unsigned long
  24. #define LMC_REG_RANGE 0x80
  25. #define LMC_PRINTF_FMT "%s"
  26. #define LMC_PRINTF_ARGS (sc->lmc_device->name)
  27. #define TX_TIMEOUT (2*HZ)
  28. #define LMC_TXDESCS 32
  29. #define LMC_RXDESCS 32
  30. #define LMC_LINK_UP 1
  31. #define LMC_LINK_DOWN 0
  32. /* These macros for generic read and write to and from the dec chip */
  33. #define LMC_CSR_READ(sc, csr) \
  34. inl((sc)->lmc_csrs.csr)
  35. #define LMC_CSR_WRITE(sc, reg, val) \
  36. outl((val), (sc)->lmc_csrs.reg)
  37. //#ifdef _LINUX_DELAY_H
  38. // #define SLOW_DOWN_IO udelay(2);
  39. // #undef __SLOW_DOWN_IO
  40. // #define __SLOW_DOWN_IO udelay(2);
  41. //#endif
  42. #define DELAY(n) SLOW_DOWN_IO
  43. #define lmc_delay() inl(sc->lmc_csrs.csr_9)
  44. /* This macro sync's up with the mii so that reads and writes can take place */
  45. #define LMC_MII_SYNC(sc) do {int n=32; while( n >= 0 ) { \
  46. LMC_CSR_WRITE((sc), csr_9, 0x20000); \
  47. lmc_delay(); \
  48. LMC_CSR_WRITE((sc), csr_9, 0x30000); \
  49. lmc_delay(); \
  50. n--; }} while(0)
  51. struct lmc_regfile_t {
  52. lmc_csrptr_t csr_busmode; /* CSR0 */
  53. lmc_csrptr_t csr_txpoll; /* CSR1 */
  54. lmc_csrptr_t csr_rxpoll; /* CSR2 */
  55. lmc_csrptr_t csr_rxlist; /* CSR3 */
  56. lmc_csrptr_t csr_txlist; /* CSR4 */
  57. lmc_csrptr_t csr_status; /* CSR5 */
  58. lmc_csrptr_t csr_command; /* CSR6 */
  59. lmc_csrptr_t csr_intr; /* CSR7 */
  60. lmc_csrptr_t csr_missed_frames; /* CSR8 */
  61. lmc_csrptr_t csr_9; /* CSR9 */
  62. lmc_csrptr_t csr_10; /* CSR10 */
  63. lmc_csrptr_t csr_11; /* CSR11 */
  64. lmc_csrptr_t csr_12; /* CSR12 */
  65. lmc_csrptr_t csr_13; /* CSR13 */
  66. lmc_csrptr_t csr_14; /* CSR14 */
  67. lmc_csrptr_t csr_15; /* CSR15 */
  68. };
  69. #define csr_enetrom csr_9 /* 21040 */
  70. #define csr_reserved csr_10 /* 21040 */
  71. #define csr_full_duplex csr_11 /* 21040 */
  72. #define csr_bootrom csr_10 /* 21041/21140A/?? */
  73. #define csr_gp csr_12 /* 21140* */
  74. #define csr_watchdog csr_15 /* 21140* */
  75. #define csr_gp_timer csr_11 /* 21041/21140* */
  76. #define csr_srom_mii csr_9 /* 21041/21140* */
  77. #define csr_sia_status csr_12 /* 2104x */
  78. #define csr_sia_connectivity csr_13 /* 2104x */
  79. #define csr_sia_tx_rx csr_14 /* 2104x */
  80. #define csr_sia_general csr_15 /* 2104x */
  81. /* tulip length/control transmit descriptor definitions
  82. * used to define bits in the second tulip_desc_t field (length)
  83. * for the transmit descriptor -baz */
  84. #define LMC_TDES_FIRST_BUFFER_SIZE ((u32)(0x000007FF))
  85. #define LMC_TDES_SECOND_BUFFER_SIZE ((u32)(0x003FF800))
  86. #define LMC_TDES_HASH_FILTERING ((u32)(0x00400000))
  87. #define LMC_TDES_DISABLE_PADDING ((u32)(0x00800000))
  88. #define LMC_TDES_SECOND_ADDR_CHAINED ((u32)(0x01000000))
  89. #define LMC_TDES_END_OF_RING ((u32)(0x02000000))
  90. #define LMC_TDES_ADD_CRC_DISABLE ((u32)(0x04000000))
  91. #define LMC_TDES_SETUP_PACKET ((u32)(0x08000000))
  92. #define LMC_TDES_INVERSE_FILTERING ((u32)(0x10000000))
  93. #define LMC_TDES_FIRST_SEGMENT ((u32)(0x20000000))
  94. #define LMC_TDES_LAST_SEGMENT ((u32)(0x40000000))
  95. #define LMC_TDES_INTERRUPT_ON_COMPLETION ((u32)(0x80000000))
  96. #define TDES_SECOND_BUFFER_SIZE_BIT_NUMBER 11
  97. #define TDES_COLLISION_COUNT_BIT_NUMBER 3
  98. /* Constants for the RCV descriptor RDES */
  99. #define LMC_RDES_OVERFLOW ((u32)(0x00000001))
  100. #define LMC_RDES_CRC_ERROR ((u32)(0x00000002))
  101. #define LMC_RDES_DRIBBLING_BIT ((u32)(0x00000004))
  102. #define LMC_RDES_REPORT_ON_MII_ERR ((u32)(0x00000008))
  103. #define LMC_RDES_RCV_WATCHDOG_TIMEOUT ((u32)(0x00000010))
  104. #define LMC_RDES_FRAME_TYPE ((u32)(0x00000020))
  105. #define LMC_RDES_COLLISION_SEEN ((u32)(0x00000040))
  106. #define LMC_RDES_FRAME_TOO_LONG ((u32)(0x00000080))
  107. #define LMC_RDES_LAST_DESCRIPTOR ((u32)(0x00000100))
  108. #define LMC_RDES_FIRST_DESCRIPTOR ((u32)(0x00000200))
  109. #define LMC_RDES_MULTICAST_FRAME ((u32)(0x00000400))
  110. #define LMC_RDES_RUNT_FRAME ((u32)(0x00000800))
  111. #define LMC_RDES_DATA_TYPE ((u32)(0x00003000))
  112. #define LMC_RDES_LENGTH_ERROR ((u32)(0x00004000))
  113. #define LMC_RDES_ERROR_SUMMARY ((u32)(0x00008000))
  114. #define LMC_RDES_FRAME_LENGTH ((u32)(0x3FFF0000))
  115. #define LMC_RDES_OWN_BIT ((u32)(0x80000000))
  116. #define RDES_FRAME_LENGTH_BIT_NUMBER 16
  117. #define LMC_RDES_ERROR_MASK ( (u32)( \
  118. LMC_RDES_OVERFLOW \
  119. | LMC_RDES_DRIBBLING_BIT \
  120. | LMC_RDES_REPORT_ON_MII_ERR \
  121. | LMC_RDES_COLLISION_SEEN ) )
  122. /*
  123. * Ioctl info
  124. */
  125. typedef struct {
  126. u32 n;
  127. u32 m;
  128. u32 v;
  129. u32 x;
  130. u32 r;
  131. u32 f;
  132. u32 exact;
  133. } lmc_av9110_t;
  134. /*
  135. * Common structure passed to the ioctl code.
  136. */
  137. struct lmc___ctl {
  138. u32 cardtype;
  139. u32 clock_source; /* HSSI, T1 */
  140. u32 clock_rate; /* T1 */
  141. u32 crc_length;
  142. u32 cable_length; /* DS3 */
  143. u32 scrambler_onoff; /* DS3 */
  144. u32 cable_type; /* T1 */
  145. u32 keepalive_onoff; /* protocol */
  146. u32 ticks; /* ticks/sec */
  147. union {
  148. lmc_av9110_t ssi;
  149. } cardspec;
  150. u32 circuit_type; /* T1 or E1 */
  151. };
  152. /*
  153. * Careful, look at the data sheet, there's more to this
  154. * structure than meets the eye. It should probably be:
  155. *
  156. * struct tulip_desc_t {
  157. * u8 own:1;
  158. * u32 status:31;
  159. * u32 control:10;
  160. * u32 buffer1;
  161. * u32 buffer2;
  162. * };
  163. * You could also expand status control to provide more bit information
  164. */
  165. struct tulip_desc_t {
  166. s32 status;
  167. s32 length;
  168. u32 buffer1;
  169. u32 buffer2;
  170. };
  171. /*
  172. * media independent methods to check on media status, link, light LEDs,
  173. * etc.
  174. */
  175. struct lmc___media {
  176. void (* init)(lmc_softc_t * const);
  177. void (* defaults)(lmc_softc_t * const);
  178. void (* set_status)(lmc_softc_t * const, lmc_ctl_t *);
  179. void (* set_clock_source)(lmc_softc_t * const, int);
  180. void (* set_speed)(lmc_softc_t * const, lmc_ctl_t *);
  181. void (* set_cable_length)(lmc_softc_t * const, int);
  182. void (* set_scrambler)(lmc_softc_t * const, int);
  183. int (* get_link_status)(lmc_softc_t * const);
  184. void (* set_link_status)(lmc_softc_t * const, int);
  185. void (* set_crc_length)(lmc_softc_t * const, int);
  186. void (* set_circuit_type)(lmc_softc_t * const, int);
  187. void (* watchdog)(lmc_softc_t * const);
  188. };
  189. #define STATCHECK 0xBEEFCAFE
  190. struct lmc_extra_statistics
  191. {
  192. u32 version_size;
  193. u32 lmc_cardtype;
  194. u32 tx_ProcTimeout;
  195. u32 tx_IntTimeout;
  196. u32 tx_NoCompleteCnt;
  197. u32 tx_MaxXmtsB4Int;
  198. u32 tx_TimeoutCnt;
  199. u32 tx_OutOfSyncPtr;
  200. u32 tx_tbusy0;
  201. u32 tx_tbusy1;
  202. u32 tx_tbusy_calls;
  203. u32 resetCount;
  204. u32 lmc_txfull;
  205. u32 tbusy;
  206. u32 dirtyTx;
  207. u32 lmc_next_tx;
  208. u32 otherTypeCnt;
  209. u32 lastType;
  210. u32 lastTypeOK;
  211. u32 txLoopCnt;
  212. u32 usedXmtDescripCnt;
  213. u32 txIndexCnt;
  214. u32 rxIntLoopCnt;
  215. u32 rx_SmallPktCnt;
  216. u32 rx_BadPktSurgeCnt;
  217. u32 rx_BuffAllocErr;
  218. u32 tx_lossOfClockCnt;
  219. /* T1 error counters */
  220. u32 framingBitErrorCount;
  221. u32 lineCodeViolationCount;
  222. u32 lossOfFrameCount;
  223. u32 changeOfFrameAlignmentCount;
  224. u32 severelyErroredFrameCount;
  225. u32 check;
  226. };
  227. typedef struct lmc_xinfo {
  228. u32 Magic0; /* BEEFCAFE */
  229. u32 PciCardType;
  230. u32 PciSlotNumber; /* PCI slot number */
  231. u16 DriverMajorVersion;
  232. u16 DriverMinorVersion;
  233. u16 DriverSubVersion;
  234. u16 XilinxRevisionNumber;
  235. u16 MaxFrameSize;
  236. u16 t1_alarm1_status;
  237. u16 t1_alarm2_status;
  238. int link_status;
  239. u32 mii_reg16;
  240. u32 Magic1; /* DEADBEEF */
  241. } LMC_XINFO;
  242. /*
  243. * forward decl
  244. */
  245. struct lmc___softc {
  246. char *name;
  247. u8 board_idx;
  248. struct lmc_extra_statistics extra_stats;
  249. struct net_device *lmc_device;
  250. int hang, rxdesc, bad_packet, some_counter;
  251. u32 txgo;
  252. struct lmc_regfile_t lmc_csrs;
  253. volatile u32 lmc_txtick;
  254. volatile u32 lmc_rxtick;
  255. u32 lmc_flags;
  256. u32 lmc_intrmask; /* our copy of csr_intr */
  257. u32 lmc_cmdmode; /* our copy of csr_cmdmode */
  258. u32 lmc_busmode; /* our copy of csr_busmode */
  259. u32 lmc_gpio_io; /* state of in/out settings */
  260. u32 lmc_gpio; /* state of outputs */
  261. struct sk_buff* lmc_txq[LMC_TXDESCS];
  262. struct sk_buff* lmc_rxq[LMC_RXDESCS];
  263. volatile
  264. struct tulip_desc_t lmc_rxring[LMC_RXDESCS];
  265. volatile
  266. struct tulip_desc_t lmc_txring[LMC_TXDESCS];
  267. unsigned int lmc_next_rx, lmc_next_tx;
  268. volatile
  269. unsigned int lmc_taint_tx, lmc_taint_rx;
  270. int lmc_tx_start, lmc_txfull;
  271. int lmc_txbusy;
  272. u16 lmc_miireg16;
  273. int lmc_ok;
  274. int last_link_status;
  275. int lmc_cardtype;
  276. u32 last_frameerr;
  277. lmc_media_t *lmc_media;
  278. struct timer_list timer;
  279. lmc_ctl_t ictl;
  280. u32 TxDescriptControlInit;
  281. int tx_TimeoutInd; /* additional driver state */
  282. int tx_TimeoutDisplay;
  283. unsigned int lastlmc_taint_tx;
  284. int lasttx_packets;
  285. u32 tx_clockState;
  286. u32 lmc_crcSize;
  287. LMC_XINFO lmc_xinfo;
  288. char lmc_yel, lmc_blue, lmc_red; /* for T1 and DS3 */
  289. char lmc_timing; /* for HSSI and SSI */
  290. int got_irq;
  291. char last_led_err[4];
  292. u32 last_int;
  293. u32 num_int;
  294. spinlock_t lmc_lock;
  295. u16 if_type; /* HDLC/PPP or NET */
  296. /* Failure cases */
  297. u8 failed_ring;
  298. u8 failed_recv_alloc;
  299. /* Structure check */
  300. u32 check;
  301. };
  302. #define LMC_PCI_TIME 1
  303. #define LMC_EXT_TIME 0
  304. #define PKT_BUF_SZ 1542 /* was 1536 */
  305. /* CSR5 settings */
  306. #define TIMER_INT 0x00000800
  307. #define TP_LINK_FAIL 0x00001000
  308. #define TP_LINK_PASS 0x00000010
  309. #define NORMAL_INT 0x00010000
  310. #define ABNORMAL_INT 0x00008000
  311. #define RX_JABBER_INT 0x00000200
  312. #define RX_DIED 0x00000100
  313. #define RX_NOBUFF 0x00000080
  314. #define RX_INT 0x00000040
  315. #define TX_FIFO_UNDER 0x00000020
  316. #define TX_JABBER 0x00000008
  317. #define TX_NOBUFF 0x00000004
  318. #define TX_DIED 0x00000002
  319. #define TX_INT 0x00000001
  320. /* CSR6 settings */
  321. #define OPERATION_MODE 0x00000200 /* Full Duplex */
  322. #define PROMISC_MODE 0x00000040 /* Promiscuous Mode */
  323. #define RECEIVE_ALL 0x40000000 /* Receive All */
  324. #define PASS_BAD_FRAMES 0x00000008 /* Pass Bad Frames */
  325. /* Dec control registers CSR6 as well */
  326. #define LMC_DEC_ST 0x00002000
  327. #define LMC_DEC_SR 0x00000002
  328. /* CSR15 settings */
  329. #define RECV_WATCHDOG_DISABLE 0x00000010
  330. #define JABBER_DISABLE 0x00000001
  331. /* More settings */
  332. /*
  333. * aSR6 -- Command (Operation Mode) Register
  334. */
  335. #define TULIP_CMD_RECEIVEALL 0x40000000L /* (RW) Receivel all frames? */
  336. #define TULIP_CMD_MUSTBEONE 0x02000000L /* (RW) Must Be One (21140) */
  337. #define TULIP_CMD_TXTHRSHLDCTL 0x00400000L /* (RW) Transmit Threshold Mode (21140) */
  338. #define TULIP_CMD_STOREFWD 0x00200000L /* (RW) Store and Forward (21140) */
  339. #define TULIP_CMD_NOHEARTBEAT 0x00080000L /* (RW) No Heartbeat (21140) */
  340. #define TULIP_CMD_PORTSELECT 0x00040000L /* (RW) Post Select (100Mb) (21140) */
  341. #define TULIP_CMD_FULLDUPLEX 0x00000200L /* (RW) Full Duplex Mode */
  342. #define TULIP_CMD_OPERMODE 0x00000C00L /* (RW) Operating Mode */
  343. #define TULIP_CMD_PROMISCUOUS 0x00000041L /* (RW) Promiscuous Mode */
  344. #define TULIP_CMD_PASSBADPKT 0x00000008L /* (RW) Pass Bad Frames */
  345. #define TULIP_CMD_THRESHOLDCTL 0x0000C000L /* (RW) Threshold Control */
  346. #define TULIP_GP_PINSET 0x00000100L
  347. #define TULIP_BUSMODE_SWRESET 0x00000001L
  348. #define TULIP_WATCHDOG_TXDISABLE 0x00000001L
  349. #define TULIP_WATCHDOG_RXDISABLE 0x00000010L
  350. #define TULIP_STS_NORMALINTR 0x00010000L /* (RW) Normal Interrupt */
  351. #define TULIP_STS_ABNRMLINTR 0x00008000L /* (RW) Abnormal Interrupt */
  352. #define TULIP_STS_ERI 0x00004000L /* (RW) Early Receive Interrupt */
  353. #define TULIP_STS_SYSERROR 0x00002000L /* (RW) System Error */
  354. #define TULIP_STS_GTE 0x00000800L /* (RW) General Pupose Timer Exp */
  355. #define TULIP_STS_ETI 0x00000400L /* (RW) Early Transmit Interrupt */
  356. #define TULIP_STS_RXWT 0x00000200L /* (RW) Receiver Watchdog Timeout */
  357. #define TULIP_STS_RXSTOPPED 0x00000100L /* (RW) Receiver Process Stopped */
  358. #define TULIP_STS_RXNOBUF 0x00000080L /* (RW) Receive Buf Unavail */
  359. #define TULIP_STS_RXINTR 0x00000040L /* (RW) Receive Interrupt */
  360. #define TULIP_STS_TXUNDERFLOW 0x00000020L /* (RW) Transmit Underflow */
  361. #define TULIP_STS_TXJABER 0x00000008L /* (RW) Jabber timeout */
  362. #define TULIP_STS_TXNOBUF 0x00000004L
  363. #define TULIP_STS_TXSTOPPED 0x00000002L /* (RW) Transmit Process Stopped */
  364. #define TULIP_STS_TXINTR 0x00000001L /* (RW) Transmit Interrupt */
  365. #define TULIP_STS_RXS_STOPPED 0x00000000L /* 000 - Stopped */
  366. #define TULIP_STS_RXSTOPPED 0x00000100L /* (RW) Receive Process Stopped */
  367. #define TULIP_STS_RXNOBUF 0x00000080L
  368. #define TULIP_CMD_TXRUN 0x00002000L /* (RW) Start/Stop Transmitter */
  369. #define TULIP_CMD_RXRUN 0x00000002L /* (RW) Start/Stop Receive Filtering */
  370. #define TULIP_DSTS_TxDEFERRED 0x00000001 /* Initially Deferred */
  371. #define TULIP_DSTS_OWNER 0x80000000 /* Owner (1 = 21040) */
  372. #define TULIP_DSTS_RxMIIERR 0x00000008
  373. #define LMC_DSTS_ERRSUM (TULIP_DSTS_RxMIIERR)
  374. #define TULIP_DEFAULT_INTR_MASK (TULIP_STS_NORMALINTR \
  375. | TULIP_STS_RXINTR \
  376. | TULIP_STS_TXINTR \
  377. | TULIP_STS_ABNRMLINTR \
  378. | TULIP_STS_SYSERROR \
  379. | TULIP_STS_TXSTOPPED \
  380. | TULIP_STS_TXUNDERFLOW\
  381. | TULIP_STS_RXSTOPPED )
  382. #define DESC_OWNED_BY_SYSTEM ((u32)(0x00000000))
  383. #define DESC_OWNED_BY_DC21X4 ((u32)(0x80000000))
  384. #ifndef TULIP_CMD_RECEIVEALL
  385. #define TULIP_CMD_RECEIVEALL 0x40000000L
  386. #endif
  387. /* Adapter module number */
  388. #define LMC_ADAP_HSSI 2
  389. #define LMC_ADAP_DS3 3
  390. #define LMC_ADAP_SSI 4
  391. #define LMC_ADAP_T1 5
  392. #define LMC_MTU 1500
  393. #define LMC_CRC_LEN_16 2 /* 16-bit CRC */
  394. #define LMC_CRC_LEN_32 4
  395. #endif /* _LMC_VAR_H_ */