sbni.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* sbni.h: definitions for a Granch SBNI12 driver, version 5.0.0
  2. * Written 2001 Denis I.Timofeev (timofeev@granch.ru)
  3. * This file is distributed under the GNU GPL
  4. */
  5. #ifndef SBNI_H
  6. #define SBNI_H
  7. #ifdef SBNI_DEBUG
  8. #define DP( A ) A
  9. #else
  10. #define DP( A )
  11. #endif
  12. /* We don't have official vendor id yet... */
  13. #define SBNI_PCI_VENDOR 0x55
  14. #define SBNI_PCI_DEVICE 0x9f
  15. #define ISA_MODE 0x00
  16. #define PCI_MODE 0x01
  17. #define SBNI_IO_EXTENT 4
  18. enum sbni_reg {
  19. CSR0 = 0,
  20. CSR1 = 1,
  21. DAT = 2
  22. };
  23. /* CSR0 mapping */
  24. enum {
  25. BU_EMP = 0x02,
  26. RC_CHK = 0x04,
  27. CT_ZER = 0x08,
  28. TR_REQ = 0x10,
  29. TR_RDY = 0x20,
  30. EN_INT = 0x40,
  31. RC_RDY = 0x80
  32. };
  33. /* CSR1 mapping */
  34. #define PR_RES 0x80
  35. struct sbni_csr1 {
  36. #ifdef __LITTLE_ENDIAN_BITFIELD
  37. u8 rxl : 5;
  38. u8 rate : 2;
  39. u8 : 1;
  40. #else
  41. u8 : 1;
  42. u8 rate : 2;
  43. u8 rxl : 5;
  44. #endif
  45. };
  46. /* fields in frame header */
  47. #define FRAME_ACK_MASK (unsigned short)0x7000
  48. #define FRAME_LEN_MASK (unsigned short)0x03FF
  49. #define FRAME_FIRST (unsigned short)0x8000
  50. #define FRAME_RETRY (unsigned short)0x0800
  51. #define FRAME_SENT_BAD (unsigned short)0x4000
  52. #define FRAME_SENT_OK (unsigned short)0x3000
  53. /* state flags */
  54. enum {
  55. FL_WAIT_ACK = 0x01,
  56. FL_NEED_RESEND = 0x02,
  57. FL_PREV_OK = 0x04,
  58. FL_SLOW_MODE = 0x08,
  59. FL_SECONDARY = 0x10,
  60. #ifdef CONFIG_SBNI_MULTILINE
  61. FL_SLAVE = 0x20,
  62. #endif
  63. FL_LINE_DOWN = 0x40
  64. };
  65. enum {
  66. DEFAULT_IOBASEADDR = 0x210,
  67. DEFAULT_INTERRUPTNUMBER = 5,
  68. DEFAULT_RATE = 0,
  69. DEFAULT_FRAME_LEN = 1012
  70. };
  71. #define DEF_RXL_DELTA -1
  72. #define DEF_RXL 0xf
  73. #define SBNI_SIG 0x5a
  74. #define SBNI_MIN_LEN 60 /* Shortest Ethernet frame without FCS */
  75. #define SBNI_MAX_FRAME 1023
  76. #define ETHER_MAX_LEN 1518
  77. #define SBNI_TIMEOUT (HZ/10)
  78. #define TR_ERROR_COUNT 32
  79. #define CHANGE_LEVEL_START_TICKS 4
  80. #define SBNI_MAX_NUM_CARDS 16
  81. /* internal SBNI-specific statistics */
  82. struct sbni_in_stats {
  83. u32 all_rx_number;
  84. u32 bad_rx_number;
  85. u32 timeout_number;
  86. u32 all_tx_number;
  87. u32 resend_tx_number;
  88. };
  89. /* SBNI ioctl params */
  90. #define SIOCDEVGETINSTATS SIOCDEVPRIVATE
  91. #define SIOCDEVRESINSTATS SIOCDEVPRIVATE+1
  92. #define SIOCDEVGHWSTATE SIOCDEVPRIVATE+2
  93. #define SIOCDEVSHWSTATE SIOCDEVPRIVATE+3
  94. #define SIOCDEVENSLAVE SIOCDEVPRIVATE+4
  95. #define SIOCDEVEMANSIPATE SIOCDEVPRIVATE+5
  96. /* data packet for SIOCDEVGHWSTATE/SIOCDEVSHWSTATE ioctl requests */
  97. struct sbni_flags {
  98. u32 rxl : 4;
  99. u32 rate : 2;
  100. u32 fixed_rxl : 1;
  101. u32 slow_mode : 1;
  102. u32 mac_addr : 24;
  103. };
  104. /*
  105. * CRC-32 stuff
  106. */
  107. #define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00FFFFFF))
  108. /* CRC generator 0xEDB88320 */
  109. /* CRC remainder 0x2144DF1C */
  110. /* CRC initial value 0x00000000 */
  111. #define CRC32_REMAINDER 0x2144DF1C
  112. #define CRC32_INITIAL 0x00000000
  113. #ifndef __initdata
  114. #define __initdata
  115. #endif
  116. #endif