olympic.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:8k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *  olympic.h (c) 1999 Peter De Schrijver All Rights Reserved
  3.  *                1999,2000 Mike Phillips (mikep@linuxtr.net)
  4.  *
  5.  *  Linux driver for IBM PCI tokenring cards based on the olympic and the PIT/PHY chipset.
  6.  *
  7.  *  Base Driver Skeleton:
  8.  *      Written 1993-94 by Donald Becker.
  9.  *
  10.  *      Copyright 1993 United States Government as represented by the
  11.  *      Director, National Security Agency.
  12.  *
  13.  *  This software may be used and distributed according to the terms
  14.  *  of the GNU General Public License, incorporated herein by reference.
  15.  */
  16. #define CID 0x4e
  17. #define BCTL 0x70
  18. #define BCTL_SOFTRESET (1<<15)
  19. #define BCTL_MIMREB (1<<6)
  20. #define BCTL_MODE_INDICATOR (1<<5)
  21. #define GPR 0x4a
  22. #define GPR_OPTI_BF (1<<6)
  23. #define GPR_NEPTUNE_BF (1<<4) 
  24. #define GPR_AUTOSENSE (1<<2)
  25. #define GPR_16MBPS (1<<3) 
  26. #define PAG 0x85
  27. #define LBC 0x8e
  28. #define LISR 0x10
  29. #define LISR_SUM 0x14
  30. #define LISR_RWM 0x18
  31. #define LISR_LIE (1<<15)
  32. #define LISR_SLIM (1<<13)
  33. #define LISR_SLI (1<<12)
  34. #define LISR_PCMSRMASK (1<<11)
  35. #define LISR_PCMSRINT (1<<10)
  36. #define LISR_WOLMASK (1<<9)
  37. #define LISR_WOL (1<<8)
  38. #define LISR_SRB_CMD (1<<5)
  39. #define LISR_ASB_REPLY (1<<4)
  40. #define LISR_ASB_FREE_REQ (1<<2)
  41. #define LISR_ARB_FREE (1<<1)
  42. #define LISR_TRB_FRAME (1<<0)
  43. #define SISR 0x20
  44. #define SISR_SUM 0x24
  45. #define SISR_RWM 0x28
  46. #define SISR_RR 0x2C
  47. #define SISR_RESMASK 0x30
  48. #define SISR_MASK 0x54
  49. #define SISR_MASK_SUM 0x58
  50. #define SISR_MASK_RWM 0x5C
  51. #define SISR_TX2_IDLE (1<<31)
  52. #define SISR_TX2_HALT (1<<29)
  53. #define SISR_TX2_EOF (1<<28)
  54. #define SISR_TX1_IDLE (1<<27)
  55. #define SISR_TX1_HALT (1<<25)
  56. #define SISR_TX1_EOF (1<<24)
  57. #define SISR_TIMEOUT (1<<23)
  58. #define SISR_RX_NOBUF (1<<22)
  59. #define SISR_RX_STATUS (1<<21)
  60. #define SISR_RX_HALT (1<<18)
  61. #define SISR_RX_EOF_EARLY (1<<16)
  62. #define SISR_MI (1<<15)
  63. #define SISR_PI (1<<13)
  64. #define SISR_ERR (1<<9)
  65. #define SISR_ADAPTER_CHECK (1<<6)
  66. #define SISR_SRB_REPLY (1<<5)
  67. #define SISR_ASB_FREE (1<<4)
  68. #define SISR_ARB_CMD (1<<3)
  69. #define SISR_TRB_REPLY (1<<2)
  70. #define EISR 0x34
  71. #define EISR_RWM 0x38
  72. #define EISR_MASK 0x3c
  73. #define EISR_MASK_OPTIONS 0x001FFF7F
  74. #define LAPA 0x60
  75. #define LAPWWO 0x64
  76. #define LAPWWC 0x68
  77. #define LAPCTL 0x6C
  78. #define LAIPD 0x78
  79. #define LAIPDDINC 0x7C
  80. #define TIMER 0x50
  81. #define CLKCTL 0x74
  82. #define CLKCTL_PAUSE (1<<15) 
  83. #define PM_CON 0x4
  84. #define BMCTL_SUM 0x40
  85. #define BMCTL_RWM 0x44
  86. #define BMCTL_TX2_DIS (1<<30) 
  87. #define BMCTL_TX1_DIS (1<<26) 
  88. #define BMCTL_RX_DIS (1<<22) 
  89. #define BMASR 0xcc
  90. #define RXDESCQ 0x90
  91. #define RXDESCQCNT 0x94
  92. #define RXCDA 0x98
  93. #define RXENQ 0x9C
  94. #define RXSTATQ 0xA0
  95. #define RXSTATQCNT 0xA4
  96. #define RXCSA 0xA8
  97. #define RXCLEN 0xAC
  98. #define RXHLEN 0xAE
  99. #define TXDESCQ_1 0xb0
  100. #define TXDESCQ_2 0xd0
  101. #define TXDESCQCNT_1 0xb4
  102. #define TXDESCQCNT_2 0xd4
  103. #define TXCDA_1 0xb8
  104. #define TXCDA_2 0xd8
  105. #define TXENQ_1 0xbc
  106. #define TXENQ_2 0xdc
  107. #define TXSTATQ_1 0xc0
  108. #define TXSTATQ_2 0xe0
  109. #define TXSTATQCNT_1 0xc4
  110. #define TXSTATQCNT_2 0xe4
  111. #define TXCSA_1 0xc8
  112. #define TXCSA_2 0xe8
  113. /* Cardbus */
  114. #define FERMASK 0xf4
  115. #define FERMASK_INT_BIT (1<<15)
  116. #define OLYMPIC_IO_SPACE 256
  117. #define SRB_COMMAND_SIZE 50
  118. #define OLYMPIC_MAX_ADAPTERS 8 /* 0x08 __MODULE_STRING can't hand 0xnn */
  119. /* Defines for LAN STATUS CHANGE reports */
  120. #define LSC_SIG_LOSS 0x8000
  121. #define LSC_HARD_ERR 0x4000
  122. #define LSC_SOFT_ERR 0x2000
  123. #define LSC_TRAN_BCN 0x1000
  124. #define LSC_LWF      0x0800
  125. #define LSC_ARW      0x0400
  126. #define LSC_FPE      0x0200
  127. #define LSC_RR       0x0100
  128. #define LSC_CO       0x0080
  129. #define LSC_SS       0x0040
  130. #define LSC_RING_REC 0x0020
  131. #define LSC_SR_CO    0x0010
  132. #define LSC_FDX_MODE 0x0004
  133. /* Defines for OPEN ADAPTER command */
  134. #define OPEN_ADAPTER_EXT_WRAP (1<<15)
  135. #define OPEN_ADAPTER_DIS_HARDEE (1<<14)
  136. #define OPEN_ADAPTER_DIS_SOFTERR (1<<13)
  137. #define OPEN_ADAPTER_PASS_ADC_MAC (1<<12)
  138. #define OPEN_ADAPTER_PASS_ATT_MAC (1<<11)
  139. #define OPEN_ADAPTER_ENABLE_EC (1<<10)
  140. #define OPEN_ADAPTER_CONTENDER (1<<8)
  141. #define OPEN_ADAPTER_PASS_BEACON (1<<7)
  142. #define OPEN_ADAPTER_ENABLE_FDX (1<<6)
  143. #define OPEN_ADAPTER_ENABLE_RPL (1<<5)
  144. #define OPEN_ADAPTER_INHIBIT_ETR (1<<4)
  145. #define OPEN_ADAPTER_INTERNAL_WRAP (1<<3)
  146. #define OPEN_ADAPTER_USE_OPTS2 (1<<0)
  147. #define OPEN_ADAPTER_2_ENABLE_ONNOW (1<<15)
  148. /* Defines for SRB Commands */
  149. #define SRB_ACCESS_REGISTER 0x1f
  150. #define SRB_CLOSE_ADAPTER 0x04
  151. #define SRB_CONFIGURE_BRIDGE 0x0c
  152. #define SRB_CONFIGURE_WAKEUP_EVENT 0x1a
  153. #define SRB_MODIFY_BRIDGE_PARMS 0x15
  154. #define SRB_MODIFY_OPEN_OPTIONS 0x01
  155. #define SRB_MODIFY_RECEIVE_OPTIONS 0x17
  156. #define SRB_NO_OPERATION 0x00
  157. #define SRB_OPEN_ADAPTER 0x03
  158. #define SRB_READ_LOG 0x08
  159. #define SRB_READ_SR_COUNTERS 0x16
  160. #define SRB_RESET_GROUP_ADDRESS 0x02
  161. #define SRB_SAVE_CONFIGURATION 0x1b
  162. #define SRB_SET_BRIDGE_PARMS 0x09
  163. #define SRB_SET_BRIDGE_TARGETS 0x10
  164. #define SRB_SET_FUNC_ADDRESS 0x07
  165. #define SRB_SET_GROUP_ADDRESS 0x06
  166. #define SRB_SET_GROUP_ADDR_OPTIONS 0x11
  167. #define SRB_UPDATE_WAKEUP_PATTERN 0x19
  168. /* Clear return code */
  169. #define OLYMPIC_CLEAR_RET_CODE 0xfe 
  170. /* ARB Commands */
  171. #define ARB_RECEIVE_DATA 0x81
  172. #define ARB_LAN_CHANGE_STATUS 0x84
  173. /* ASB Response commands */
  174. #define ASB_RECEIVE_DATA 0x81
  175. /* Olympic defaults for buffers */
  176.  
  177. #define OLYMPIC_RX_RING_SIZE 16 /* should be a power of 2 */
  178. #define OLYMPIC_TX_RING_SIZE 8 /* should be a power of 2 */
  179. #define PKT_BUF_SZ 4096 /* Default packet size */
  180. /* Olympic data structures */
  181. /* xxxx These structures are all little endian in hardware. */
  182. struct olympic_tx_desc {
  183. u32 buffer;
  184. u32 status_length;
  185. };
  186. struct olympic_tx_status {
  187. u32 status;
  188. };
  189. struct olympic_rx_desc {
  190. u32 buffer;
  191. u32 res_length; 
  192. };
  193. struct olympic_rx_status {
  194. u32 fragmentcnt_framelen;
  195. u32 status_buffercnt;
  196. };
  197. /* xxxx END These structures are all little endian in hardware. */
  198. /* xxxx There may be more, but I'm pretty sure about these */
  199. struct mac_receive_buffer {
  200. u16 next ; 
  201. u8 padding ; 
  202. u8 frame_status ;
  203. u16 buffer_length ; 
  204. u8 frame_data ; 
  205. };
  206. struct olympic_private {
  207. u16 srb;      /* be16 */
  208. u16 trb;      /* be16 */
  209. u16 arb;      /* be16 */
  210. u16 asb;      /* be16 */
  211. u8 *olympic_mmio;
  212. u8 *olympic_lap;
  213. struct pci_dev *pdev ; 
  214. char *olympic_card_name ; 
  215. spinlock_t olympic_lock ; 
  216. volatile int srb_queued;    /* True if an SRB is still posted */
  217. wait_queue_head_t srb_wait;
  218. volatile int asb_queued;    /* True if an ASB is posted */
  219. volatile int trb_queued;   /* True if a TRB is posted */
  220. wait_queue_head_t trb_wait ; 
  221. /* These must be on a 4 byte boundary. */
  222. struct olympic_rx_desc olympic_rx_ring[OLYMPIC_RX_RING_SIZE];
  223. struct olympic_tx_desc olympic_tx_ring[OLYMPIC_TX_RING_SIZE];
  224. struct olympic_rx_status olympic_rx_status_ring[OLYMPIC_RX_RING_SIZE];
  225. struct olympic_tx_status olympic_tx_status_ring[OLYMPIC_TX_RING_SIZE];
  226. struct sk_buff *tx_ring_skb[OLYMPIC_TX_RING_SIZE], *rx_ring_skb[OLYMPIC_RX_RING_SIZE];
  227. int tx_ring_free, tx_ring_last_status, rx_ring_last_received,rx_status_last_received, free_tx_ring_entries;
  228. struct net_device_stats olympic_stats ;
  229. u16 olympic_lan_status ;
  230. u8 olympic_ring_speed ;
  231. u16 pkt_buf_sz ; 
  232. u8 olympic_receive_options, olympic_copy_all_options,olympic_message_level, olympic_network_monitor;  
  233. u16 olympic_addr_table_addr, olympic_parms_addr ; 
  234. u8 olympic_laa[6] ; 
  235. u32 rx_ring_dma_addr;
  236. u32 rx_status_ring_dma_addr;
  237. u32 tx_ring_dma_addr;
  238. u32 tx_status_ring_dma_addr;
  239. };
  240. struct olympic_adapter_addr_table {
  241. u8 node_addr[6] ; 
  242. u8 reserved[4] ; 
  243. u8 func_addr[4] ; 
  244. } ; 
  245. struct olympic_parameters_table { 
  246. u8  phys_addr[4] ; 
  247. u8  up_node_addr[6] ; 
  248. u8  up_phys_addr[4] ; 
  249. u8  poll_addr[6] ; 
  250. u16 reserved ; 
  251. u16 acc_priority ; 
  252. u16 auth_source_class ; 
  253. u16 att_code ; 
  254. u8  source_addr[6] ; 
  255. u16 beacon_type ; 
  256. u16 major_vector ; 
  257. u16 lan_status ; 
  258. u16 soft_error_time ; 
  259.   u16 reserved1 ; 
  260. u16 local_ring ; 
  261. u16 mon_error ; 
  262. u16 beacon_transmit ; 
  263. u16 beacon_receive ; 
  264. u16 frame_correl ; 
  265. u8  beacon_naun[6] ; 
  266. u32 reserved2 ; 
  267. u8  beacon_phys[4] ; 
  268. };