You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pcnet32.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2010 Andrei Faur <da3drus@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. */
  20. FILE_LICENCE ( GPL2_OR_LATER );
  21. #ifndef _PCNET32_H_
  22. #define _PCNET32_H_
  23. /*
  24. * Set the number of Tx and Rx buffers, using Log_2(# buffers).
  25. * Set default values to 16 Tx buffers and 32 Rx buffers.
  26. */
  27. #define PCNET32_LOG_TX_BUFFERS 4
  28. #define PCNET32_LOG_RX_BUFFERS 5
  29. /* Maximum number of descriptor rings is 512 */
  30. #define PCNET32_LOG_MAX_TX_BUFFERS 9
  31. #define PCNET32_LOG_MAX_RX_BUFFERS 9
  32. #define TX_RING_SIZE ( 1 << ( PCNET32_LOG_TX_BUFFERS ) )
  33. #define TX_MAX_RING_SIZE ( 1 << ( PCNET32_LOG_MAX_TX_BUFFERS ) )
  34. #define RX_RING_SIZE ( 1 << ( PCNET32_LOG_RX_BUFFERS ) )
  35. #define RX_MAX_RING_SIZE ( 1 << ( PCNET32_LOG_MAX_RX_BUFFERS ) )
  36. #define RX_RING_BYTES ( RX_RING_SIZE * sizeof(struct pcnet32_rx_desc ) )
  37. #define TX_RING_BYTES ( TX_RING_SIZE * sizeof(struct pcnet32_tx_desc ) )
  38. #define PKT_BUF_SIZE 1536
  39. #define RX_RING_ALIGN 16
  40. #define TX_RING_ALIGN 16
  41. #define INIT_BLOCK_ALIGN 32
  42. #define PCNET32_WIO_RDP 0x10
  43. #define PCNET32_WIO_RAP 0x12
  44. #define PCNET32_WIO_RESET 0x14
  45. #define PCNET32_WIO_BDP 0x16
  46. #define PCNET32_DWIO_RDP 0x10
  47. #define PCNET32_DWIO_RAP 0x14
  48. #define PCNET32_DWIO_RESET 0x18
  49. #define PCNET32_DWIO_BDP 0x1C
  50. #define PCNET32_PORT_AUI 0x00
  51. #define PCNET32_PORT_10BT 0x01
  52. #define PCNET32_PORT_GPSI 0x02
  53. #define PCNET32_PORT_MII 0x03
  54. #define PCNET32_PORT_PORTSEL 0x03
  55. #define PCNET32_PORT_ASEL 0x04
  56. #define PCNET32_PORT_100 0x40
  57. #define PCNET32_PORT_FD 0x80
  58. #define PCNET32_SWSTYLE_LANCE 0x00
  59. #define PCNET32_SWSTYLE_ILACC 0x01
  60. #define PCNET32_SWSTYLE_PCNET32 0x02
  61. #define PCNET32_MAX_PHYS 32
  62. #ifndef PCI_VENDOR_ID_AT
  63. #define PCI_VENDOR_ID_AT 0x1259
  64. #endif
  65. #ifndef PCI_SUBDEVICE_ID_AT_2700FX
  66. #define PCI_SUBDEVICE_ID_AT_2700FX 0x2701
  67. #endif
  68. #ifndef PCI_SUBDEVICE_ID_AT_2701FX
  69. #define PCI_SUBDEVICE_ID_AT_2701FX 0x2703
  70. #endif
  71. struct pcnet32_rx_desc {
  72. u32 base;
  73. s16 buf_length;
  74. s16 status;
  75. u32 msg_length;
  76. u32 reserved;
  77. };
  78. struct pcnet32_tx_desc {
  79. u32 base;
  80. s16 length;
  81. s16 status;
  82. u32 misc;
  83. u32 reserved;
  84. };
  85. struct pcnet32_init_block {
  86. u16 mode;
  87. u16 tlen_rlen;
  88. u8 phys_addr[6];
  89. u16 reserved;
  90. u32 filter[2];
  91. u32 rx_ring;
  92. u32 tx_ring;
  93. };
  94. struct pcnet32_access {
  95. u16 ( *read_csr ) ( unsigned long, int );
  96. void ( *write_csr ) ( unsigned long, int, u16 );
  97. u16 ( *read_bcr ) ( unsigned long, int );
  98. void ( *write_bcr ) ( unsigned long, int, u16 );
  99. u16 ( *read_rap ) ( unsigned long );
  100. void ( *write_rap ) ( unsigned long, u16 );
  101. void ( *reset ) ( unsigned long );
  102. };
  103. struct pcnet32_private {
  104. struct pcnet32_init_block init_block __attribute__((aligned(32)));
  105. struct pci_device *pci_dev;
  106. struct net_device *netdev;
  107. struct io_buffer *rx_iobuf[RX_RING_SIZE];
  108. struct io_buffer *tx_iobuf[TX_RING_SIZE];
  109. struct pcnet32_rx_desc *rx_base;
  110. struct pcnet32_tx_desc *tx_base;
  111. uint32_t rx_curr;
  112. uint32_t tx_curr;
  113. uint32_t tx_tail;
  114. uint32_t tx_fill_ctr;
  115. struct pcnet32_access *a;
  116. int options;
  117. unsigned int mii:1,
  118. full_duplex:1;
  119. unsigned short chip_version;
  120. char irq_enabled;
  121. };
  122. enum pcnet32_desc_status_bit {
  123. DescOwn = (1 << 15),
  124. StartOfPacket = (1 << 9),
  125. EndOfPacket = (1 << 8)
  126. };
  127. enum pcnet32_register_content {
  128. /* CSR0 bits - Controller status register */
  129. RxInt = (1 << 10),
  130. TxInt = (1 << 9),
  131. InitDone = (1 << 8),
  132. IntFlag = (1 << 7),
  133. IntEnable = (1 << 6),
  134. TxDemand = (1 << 3),
  135. Stop = (1 << 2),
  136. Strt = (1 << 1),
  137. Init = (1 << 0),
  138. /* CSR3 bits - Controller status register */
  139. BablMask = (1 << 14),
  140. MissFrameMask = (1 << 12),
  141. MemErrMask = (1 << 11),
  142. RxIntMask = (1 << 10),
  143. TxIntMask = (1 << 9),
  144. InitDoneMask = (1 << 8)
  145. };
  146. #endif /* _PCNET32_H_ */