lanstreamer.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*
  2. * lanstreamer.h -- driver for the IBM Auto LANStreamer PCI Adapter
  3. *
  4. * Written By: Mike Sullivan, IBM Corporation
  5. *
  6. * Copyright (C) 1999 IBM Corporation
  7. *
  8. * Linux driver for IBM PCI tokenring cards based on the LanStreamer MPC
  9. * chipset.
  10. *
  11. * This driver is based on the olympic driver for IBM PCI TokenRing cards (Pit/Pit-Phy/Olympic
  12. * chipsets) written by:
  13. * 1999 Peter De Schrijver All Rights Reserved
  14. * 1999 Mike Phillips (phillim@amtrak.com)
  15. *
  16. * Base Driver Skeleton:
  17. * Written 1993-94 by Donald Becker.
  18. *
  19. * Copyright 1993 United States Government as represented by the
  20. * Director, National Security Agency.
  21. *
  22. * This program is free software; you can redistribute it and/or modify
  23. * it under the terms of the GNU General Public License as published by
  24. * the Free Software Foundation; either version 2 of the License, or
  25. * (at your option) any later version.
  26. *
  27. * This program is distributed in the hope that it will be useful,
  28. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. * GNU General Public License for more details.
  31. *
  32. * NO WARRANTY
  33. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  34. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  35. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  36. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  37. * solely responsible for determining the appropriateness of using and
  38. * distributing the Program and assumes all risks associated with its
  39. * exercise of rights under this Agreement, including but not limited to
  40. * the risks and costs of program errors, damage to or loss of data,
  41. * programs or equipment, and unavailability or interruption of operations.
  42. *
  43. * DISCLAIMER OF LIABILITY
  44. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  45. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  46. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  47. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  48. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  49. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  50. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  51. *
  52. * You should have received a copy of the GNU General Public License
  53. * along with this program; if not, write to the Free Software
  54. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  55. *
  56. *
  57. * 12/10/99 - Alpha Release 0.1.0
  58. * First release to the public
  59. * 08/15/01 - Added ioctl() definitions and others - Kent Yoder <yoder1@us.ibm.com>
  60. *
  61. */
  62. /* MAX_INTR - the maximum number of times we can loop
  63. * inside the interrupt function before returning
  64. * control to the OS (maximum value is 256)
  65. */
  66. #define MAX_INTR 5
  67. #define CLS 0x0C
  68. #define MLR 0x86
  69. #define LTR 0x0D
  70. #define BCTL 0x60
  71. #define BCTL_SOFTRESET (1<<15)
  72. #define BCTL_RX_FIFO_8 (1<<1)
  73. #define BCTL_TX_FIFO_8 (1<<3)
  74. #define GPR 0x4a
  75. #define GPR_AUTOSENSE (1<<2)
  76. #define GPR_16MBPS (1<<3)
  77. #define LISR 0x10
  78. #define LISR_SUM 0x12
  79. #define LISR_RUM 0x14
  80. #define LISR_LIE (1<<15)
  81. #define LISR_SLIM (1<<13)
  82. #define LISR_SLI (1<<12)
  83. #define LISR_BPEI (1<<9)
  84. #define LISR_BPE (1<<8)
  85. #define LISR_SRB_CMD (1<<5)
  86. #define LISR_ASB_REPLY (1<<4)
  87. #define LISR_ASB_FREE_REQ (1<<2)
  88. #define LISR_ARB_FREE (1<<1)
  89. #define LISR_TRB_FRAME (1<<0)
  90. #define SISR 0x16
  91. #define SISR_SUM 0x18
  92. #define SISR_RUM 0x1A
  93. #define SISR_MASK 0x54
  94. #define SISR_MASK_SUM 0x56
  95. #define SISR_MASK_RUM 0x58
  96. #define SISR_MI (1<<15)
  97. #define SISR_SERR_ERR (1<<14)
  98. #define SISR_TIMER (1<<11)
  99. #define SISR_LAP_PAR_ERR (1<<10)
  100. #define SISR_LAP_ACC_ERR (1<<9)
  101. #define SISR_PAR_ERR (1<<8)
  102. #define SISR_ADAPTER_CHECK (1<<6)
  103. #define SISR_SRB_REPLY (1<<5)
  104. #define SISR_ASB_FREE (1<<4)
  105. #define SISR_ARB_CMD (1<<3)
  106. #define SISR_TRB_REPLY (1<<2)
  107. #define MISR_RUM 0x5A
  108. #define MISR_MASK 0x5C
  109. #define MISR_MASK_RUM 0x5E
  110. #define MISR_TX2_IDLE (1<<15)
  111. #define MISR_TX2_NO_STATUS (1<<14)
  112. #define MISR_TX2_HALT (1<<13)
  113. #define MISR_TX2_EOF (1<<12)
  114. #define MISR_TX1_IDLE (1<<11)
  115. #define MISR_TX1_NO_STATUS (1<<10)
  116. #define MISR_TX1_HALT (1<<9)
  117. #define MISR_TX1_EOF (1<<8)
  118. #define MISR_RX_NOBUF (1<<5)
  119. #define MISR_RX_EOB (1<<4)
  120. #define MISR_RX_NO_STATUS (1<<2)
  121. #define MISR_RX_HALT (1<<1)
  122. #define MISR_RX_EOF (1<<0)
  123. #define LAPA 0x62
  124. #define LAPE 0x64
  125. #define LAPD 0x66
  126. #define LAPDINC 0x68
  127. #define LAPWWO 0x6A
  128. #define LAPWWC 0x6C
  129. #define LAPCTL 0x6E
  130. #define TIMER 0x4E4
  131. #define BMCTL_SUM 0x50
  132. #define BMCTL_RUM 0x52
  133. #define BMCTL_TX1_DIS (1<<14)
  134. #define BMCTL_TX2_DIS (1<<10)
  135. #define BMCTL_RX_DIS (1<<6)
  136. #define BMCTL_RX_ENABLED (1<<5)
  137. #define RXLBDA 0x90
  138. #define RXBDA 0x94
  139. #define RXSTAT 0x98
  140. #define RXDBA 0x9C
  141. #define TX1LFDA 0xA0
  142. #define TX1FDA 0xA4
  143. #define TX1STAT 0xA8
  144. #define TX1DBA 0xAC
  145. #define TX2LFDA 0xB0
  146. #define TX2FDA 0xB4
  147. #define TX2STAT 0xB8
  148. #define TX2DBA 0xBC
  149. #define STREAMER_IO_SPACE 256
  150. #define SRB_COMMAND_SIZE 50
  151. #define STREAMER_MAX_ADAPTERS 8 /* 0x08 __MODULE_STRING can't hand 0xnn */
  152. /* Defines for LAN STATUS CHANGE reports */
  153. #define LSC_SIG_LOSS 0x8000
  154. #define LSC_HARD_ERR 0x4000
  155. #define LSC_SOFT_ERR 0x2000
  156. #define LSC_TRAN_BCN 0x1000
  157. #define LSC_LWF 0x0800
  158. #define LSC_ARW 0x0400
  159. #define LSC_FPE 0x0200
  160. #define LSC_RR 0x0100
  161. #define LSC_CO 0x0080
  162. #define LSC_SS 0x0040
  163. #define LSC_RING_REC 0x0020
  164. #define LSC_SR_CO 0x0010
  165. #define LSC_FDX_MODE 0x0004
  166. /* Defines for OPEN ADAPTER command */
  167. #define OPEN_ADAPTER_EXT_WRAP (1<<15)
  168. #define OPEN_ADAPTER_DIS_HARDEE (1<<14)
  169. #define OPEN_ADAPTER_DIS_SOFTERR (1<<13)
  170. #define OPEN_ADAPTER_PASS_ADC_MAC (1<<12)
  171. #define OPEN_ADAPTER_PASS_ATT_MAC (1<<11)
  172. #define OPEN_ADAPTER_ENABLE_EC (1<<10)
  173. #define OPEN_ADAPTER_CONTENDER (1<<8)
  174. #define OPEN_ADAPTER_PASS_BEACON (1<<7)
  175. #define OPEN_ADAPTER_ENABLE_FDX (1<<6)
  176. #define OPEN_ADAPTER_ENABLE_RPL (1<<5)
  177. #define OPEN_ADAPTER_INHIBIT_ETR (1<<4)
  178. #define OPEN_ADAPTER_INTERNAL_WRAP (1<<3)
  179. /* Defines for SRB Commands */
  180. #define SRB_CLOSE_ADAPTER 0x04
  181. #define SRB_CONFIGURE_BRIDGE 0x0c
  182. #define SRB_CONFIGURE_HP_CHANNEL 0x13
  183. #define SRB_MODIFY_BRIDGE_PARMS 0x15
  184. #define SRB_MODIFY_OPEN_OPTIONS 0x01
  185. #define SRB_MODIFY_RECEIVE_OPTIONS 0x17
  186. #define SRB_NO_OPERATION 0x00
  187. #define SRB_OPEN_ADAPTER 0x03
  188. #define SRB_READ_LOG 0x08
  189. #define SRB_READ_SR_COUNTERS 0x16
  190. #define SRB_RESET_GROUP_ADDRESS 0x02
  191. #define SRB_RESET_TARGET_SEGMETN 0x14
  192. #define SRB_SAVE_CONFIGURATION 0x1b
  193. #define SRB_SET_BRIDGE_PARMS 0x09
  194. #define SRB_SET_FUNC_ADDRESS 0x07
  195. #define SRB_SET_GROUP_ADDRESS 0x06
  196. #define SRB_SET_TARGET_SEGMENT 0x05
  197. /* Clear return code */
  198. #define STREAMER_CLEAR_RET_CODE 0xfe
  199. /* ARB Commands */
  200. #define ARB_RECEIVE_DATA 0x81
  201. #define ARB_LAN_CHANGE_STATUS 0x84
  202. /* ASB Response commands */
  203. #define ASB_RECEIVE_DATA 0x81
  204. /* Streamer defaults for buffers */
  205. #define STREAMER_RX_RING_SIZE 16 /* should be a power of 2 */
  206. /* Setting the number of TX descriptors to 1 is a workaround for an
  207. * undocumented hardware problem with the lanstreamer board. Setting
  208. * this to something higher may slightly increase the throughput you
  209. * can get from the card, but at the risk of locking up the box. -
  210. * <yoder1@us.ibm.com>
  211. */
  212. #define STREAMER_TX_RING_SIZE 1 /* should be a power of 2 */
  213. #define PKT_BUF_SZ 4096 /* Default packet size */
  214. /* Streamer data structures */
  215. struct streamer_tx_desc {
  216. __u32 forward;
  217. __u32 status;
  218. __u32 bufcnt_framelen;
  219. __u32 buffer;
  220. __u32 buflen;
  221. __u32 rsvd1;
  222. __u32 rsvd2;
  223. __u32 rsvd3;
  224. };
  225. struct streamer_rx_desc {
  226. __u32 forward;
  227. __u32 status;
  228. __u32 buffer;
  229. __u32 framelen_buflen;
  230. };
  231. struct mac_receive_buffer {
  232. __u16 next;
  233. __u8 padding;
  234. __u8 frame_status;
  235. __u16 buffer_length;
  236. __u8 frame_data;
  237. };
  238. struct streamer_private {
  239. __u16 srb;
  240. __u16 trb;
  241. __u16 arb;
  242. __u16 asb;
  243. struct streamer_private *next;
  244. struct pci_dev *pci_dev;
  245. __u8 __iomem *streamer_mmio;
  246. char *streamer_card_name;
  247. spinlock_t streamer_lock;
  248. volatile int srb_queued; /* True if an SRB is still posted */
  249. wait_queue_head_t srb_wait;
  250. volatile int asb_queued; /* True if an ASB is posted */
  251. volatile int trb_queued; /* True if a TRB is posted */
  252. wait_queue_head_t trb_wait;
  253. struct streamer_rx_desc *streamer_rx_ring;
  254. struct streamer_tx_desc *streamer_tx_ring;
  255. struct sk_buff *tx_ring_skb[STREAMER_TX_RING_SIZE],
  256. *rx_ring_skb[STREAMER_RX_RING_SIZE];
  257. int tx_ring_free, tx_ring_last_status, rx_ring_last_received,
  258. free_tx_ring_entries;
  259. __u16 streamer_lan_status;
  260. __u8 streamer_ring_speed;
  261. __u16 pkt_buf_sz;
  262. __u8 streamer_receive_options, streamer_copy_all_options,
  263. streamer_message_level;
  264. __u16 streamer_addr_table_addr, streamer_parms_addr;
  265. __u16 mac_rx_buffer;
  266. __u8 streamer_laa[6];
  267. };
  268. struct streamer_adapter_addr_table {
  269. __u8 node_addr[6];
  270. __u8 reserved[4];
  271. __u8 func_addr[4];
  272. };
  273. struct streamer_parameters_table {
  274. __u8 phys_addr[4];
  275. __u8 up_node_addr[6];
  276. __u8 up_phys_addr[4];
  277. __u8 poll_addr[6];
  278. __u16 reserved;
  279. __u16 acc_priority;
  280. __u16 auth_source_class;
  281. __u16 att_code;
  282. __u8 source_addr[6];
  283. __u16 beacon_type;
  284. __u16 major_vector;
  285. __u16 lan_status;
  286. __u16 soft_error_time;
  287. __u16 reserved1;
  288. __u16 local_ring;
  289. __u16 mon_error;
  290. __u16 beacon_transmit;
  291. __u16 beacon_receive;
  292. __u16 frame_correl;
  293. __u8 beacon_naun[6];
  294. __u32 reserved2;
  295. __u8 beacon_phys[4];
  296. };