lanstreamer.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. #include <linux/version.h>
  63. /* MAX_INTR - the maximum number of times we can loop
  64. * inside the interrupt function before returning
  65. * control to the OS (maximum value is 256)
  66. */
  67. #define MAX_INTR 5
  68. #define CLS 0x0C
  69. #define MLR 0x86
  70. #define LTR 0x0D
  71. #define BCTL 0x60
  72. #define BCTL_SOFTRESET (1<<15)
  73. #define BCTL_RX_FIFO_8 (1<<1)
  74. #define BCTL_TX_FIFO_8 (1<<3)
  75. #define GPR 0x4a
  76. #define GPR_AUTOSENSE (1<<2)
  77. #define GPR_16MBPS (1<<3)
  78. #define LISR 0x10
  79. #define LISR_SUM 0x12
  80. #define LISR_RUM 0x14
  81. #define LISR_LIE (1<<15)
  82. #define LISR_SLIM (1<<13)
  83. #define LISR_SLI (1<<12)
  84. #define LISR_BPEI (1<<9)
  85. #define LISR_BPE (1<<8)
  86. #define LISR_SRB_CMD (1<<5)
  87. #define LISR_ASB_REPLY (1<<4)
  88. #define LISR_ASB_FREE_REQ (1<<2)
  89. #define LISR_ARB_FREE (1<<1)
  90. #define LISR_TRB_FRAME (1<<0)
  91. #define SISR 0x16
  92. #define SISR_SUM 0x18
  93. #define SISR_RUM 0x1A
  94. #define SISR_MASK 0x54
  95. #define SISR_MASK_SUM 0x56
  96. #define SISR_MASK_RUM 0x58
  97. #define SISR_MI (1<<15)
  98. #define SISR_SERR_ERR (1<<14)
  99. #define SISR_TIMER (1<<11)
  100. #define SISR_LAP_PAR_ERR (1<<10)
  101. #define SISR_LAP_ACC_ERR (1<<9)
  102. #define SISR_PAR_ERR (1<<8)
  103. #define SISR_ADAPTER_CHECK (1<<6)
  104. #define SISR_SRB_REPLY (1<<5)
  105. #define SISR_ASB_FREE (1<<4)
  106. #define SISR_ARB_CMD (1<<3)
  107. #define SISR_TRB_REPLY (1<<2)
  108. #define MISR_RUM 0x5A
  109. #define MISR_MASK 0x5C
  110. #define MISR_MASK_RUM 0x5E
  111. #define MISR_TX2_IDLE (1<<15)
  112. #define MISR_TX2_NO_STATUS (1<<14)
  113. #define MISR_TX2_HALT (1<<13)
  114. #define MISR_TX2_EOF (1<<12)
  115. #define MISR_TX1_IDLE (1<<11)
  116. #define MISR_TX1_NO_STATUS (1<<10)
  117. #define MISR_TX1_HALT (1<<9)
  118. #define MISR_TX1_EOF (1<<8)
  119. #define MISR_RX_NOBUF (1<<5)
  120. #define MISR_RX_EOB (1<<4)
  121. #define MISR_RX_NO_STATUS (1<<2)
  122. #define MISR_RX_HALT (1<<1)
  123. #define MISR_RX_EOF (1<<0)
  124. #define LAPA 0x62
  125. #define LAPE 0x64
  126. #define LAPD 0x66
  127. #define LAPDINC 0x68
  128. #define LAPWWO 0x6A
  129. #define LAPWWC 0x6C
  130. #define LAPCTL 0x6E
  131. #define TIMER 0x4E4
  132. #define BMCTL_SUM 0x50
  133. #define BMCTL_RUM 0x52
  134. #define BMCTL_TX1_DIS (1<<14)
  135. #define BMCTL_TX2_DIS (1<<10)
  136. #define BMCTL_RX_DIS (1<<6)
  137. #define BMCTL_RX_ENABLED (1<<5)
  138. #define RXLBDA 0x90
  139. #define RXBDA 0x94
  140. #define RXSTAT 0x98
  141. #define RXDBA 0x9C
  142. #define TX1LFDA 0xA0
  143. #define TX1FDA 0xA4
  144. #define TX1STAT 0xA8
  145. #define TX1DBA 0xAC
  146. #define TX2LFDA 0xB0
  147. #define TX2FDA 0xB4
  148. #define TX2STAT 0xB8
  149. #define TX2DBA 0xBC
  150. #define STREAMER_IO_SPACE 256
  151. #define SRB_COMMAND_SIZE 50
  152. #define STREAMER_MAX_ADAPTERS 8 /* 0x08 __MODULE_STRING can't hand 0xnn */
  153. /* Defines for LAN STATUS CHANGE reports */
  154. #define LSC_SIG_LOSS 0x8000
  155. #define LSC_HARD_ERR 0x4000
  156. #define LSC_SOFT_ERR 0x2000
  157. #define LSC_TRAN_BCN 0x1000
  158. #define LSC_LWF 0x0800
  159. #define LSC_ARW 0x0400
  160. #define LSC_FPE 0x0200
  161. #define LSC_RR 0x0100
  162. #define LSC_CO 0x0080
  163. #define LSC_SS 0x0040
  164. #define LSC_RING_REC 0x0020
  165. #define LSC_SR_CO 0x0010
  166. #define LSC_FDX_MODE 0x0004
  167. /* Defines for OPEN ADAPTER command */
  168. #define OPEN_ADAPTER_EXT_WRAP (1<<15)
  169. #define OPEN_ADAPTER_DIS_HARDEE (1<<14)
  170. #define OPEN_ADAPTER_DIS_SOFTERR (1<<13)
  171. #define OPEN_ADAPTER_PASS_ADC_MAC (1<<12)
  172. #define OPEN_ADAPTER_PASS_ATT_MAC (1<<11)
  173. #define OPEN_ADAPTER_ENABLE_EC (1<<10)
  174. #define OPEN_ADAPTER_CONTENDER (1<<8)
  175. #define OPEN_ADAPTER_PASS_BEACON (1<<7)
  176. #define OPEN_ADAPTER_ENABLE_FDX (1<<6)
  177. #define OPEN_ADAPTER_ENABLE_RPL (1<<5)
  178. #define OPEN_ADAPTER_INHIBIT_ETR (1<<4)
  179. #define OPEN_ADAPTER_INTERNAL_WRAP (1<<3)
  180. /* Defines for SRB Commands */
  181. #define SRB_CLOSE_ADAPTER 0x04
  182. #define SRB_CONFIGURE_BRIDGE 0x0c
  183. #define SRB_CONFIGURE_HP_CHANNEL 0x13
  184. #define SRB_MODIFY_BRIDGE_PARMS 0x15
  185. #define SRB_MODIFY_OPEN_OPTIONS 0x01
  186. #define SRB_MODIFY_RECEIVE_OPTIONS 0x17
  187. #define SRB_NO_OPERATION 0x00
  188. #define SRB_OPEN_ADAPTER 0x03
  189. #define SRB_READ_LOG 0x08
  190. #define SRB_READ_SR_COUNTERS 0x16
  191. #define SRB_RESET_GROUP_ADDRESS 0x02
  192. #define SRB_RESET_TARGET_SEGMETN 0x14
  193. #define SRB_SAVE_CONFIGURATION 0x1b
  194. #define SRB_SET_BRIDGE_PARMS 0x09
  195. #define SRB_SET_FUNC_ADDRESS 0x07
  196. #define SRB_SET_GROUP_ADDRESS 0x06
  197. #define SRB_SET_TARGET_SEGMENT 0x05
  198. /* Clear return code */
  199. #define STREAMER_CLEAR_RET_CODE 0xfe
  200. /* ARB Commands */
  201. #define ARB_RECEIVE_DATA 0x81
  202. #define ARB_LAN_CHANGE_STATUS 0x84
  203. /* ASB Response commands */
  204. #define ASB_RECEIVE_DATA 0x81
  205. /* Streamer defaults for buffers */
  206. #define STREAMER_RX_RING_SIZE 16 /* should be a power of 2 */
  207. /* Setting the number of TX descriptors to 1 is a workaround for an
  208. * undocumented hardware problem with the lanstreamer board. Setting
  209. * this to something higher may slightly increase the throughput you
  210. * can get from the card, but at the risk of locking up the box. -
  211. * <yoder1@us.ibm.com>
  212. */
  213. #define STREAMER_TX_RING_SIZE 1 /* should be a power of 2 */
  214. #define PKT_BUF_SZ 4096 /* Default packet size */
  215. /* Streamer data structures */
  216. struct streamer_tx_desc {
  217. __u32 forward;
  218. __u32 status;
  219. __u32 bufcnt_framelen;
  220. __u32 buffer;
  221. __u32 buflen;
  222. __u32 rsvd1;
  223. __u32 rsvd2;
  224. __u32 rsvd3;
  225. };
  226. struct streamer_rx_desc {
  227. __u32 forward;
  228. __u32 status;
  229. __u32 buffer;
  230. __u32 framelen_buflen;
  231. };
  232. struct mac_receive_buffer {
  233. __u16 next;
  234. __u8 padding;
  235. __u8 frame_status;
  236. __u16 buffer_length;
  237. __u8 frame_data;
  238. };
  239. struct streamer_private {
  240. __u16 srb;
  241. __u16 trb;
  242. __u16 arb;
  243. __u16 asb;
  244. struct streamer_private *next;
  245. struct pci_dev *pci_dev;
  246. __u8 __iomem *streamer_mmio;
  247. char *streamer_card_name;
  248. spinlock_t streamer_lock;
  249. volatile int srb_queued; /* True if an SRB is still posted */
  250. wait_queue_head_t srb_wait;
  251. volatile int asb_queued; /* True if an ASB is posted */
  252. volatile int trb_queued; /* True if a TRB is posted */
  253. wait_queue_head_t trb_wait;
  254. struct streamer_rx_desc *streamer_rx_ring;
  255. struct streamer_tx_desc *streamer_tx_ring;
  256. struct sk_buff *tx_ring_skb[STREAMER_TX_RING_SIZE],
  257. *rx_ring_skb[STREAMER_RX_RING_SIZE];
  258. int tx_ring_free, tx_ring_last_status, rx_ring_last_received,
  259. free_tx_ring_entries;
  260. struct net_device_stats streamer_stats;
  261. __u16 streamer_lan_status;
  262. __u8 streamer_ring_speed;
  263. __u16 pkt_buf_sz;
  264. __u8 streamer_receive_options, streamer_copy_all_options,
  265. streamer_message_level;
  266. __u16 streamer_addr_table_addr, streamer_parms_addr;
  267. __u16 mac_rx_buffer;
  268. __u8 streamer_laa[6];
  269. };
  270. struct streamer_adapter_addr_table {
  271. __u8 node_addr[6];
  272. __u8 reserved[4];
  273. __u8 func_addr[4];
  274. };
  275. struct streamer_parameters_table {
  276. __u8 phys_addr[4];
  277. __u8 up_node_addr[6];
  278. __u8 up_phys_addr[4];
  279. __u8 poll_addr[6];
  280. __u16 reserved;
  281. __u16 acc_priority;
  282. __u16 auth_source_class;
  283. __u16 att_code;
  284. __u8 source_addr[6];
  285. __u16 beacon_type;
  286. __u16 major_vector;
  287. __u16 lan_status;
  288. __u16 soft_error_time;
  289. __u16 reserved1;
  290. __u16 local_ring;
  291. __u16 mon_error;
  292. __u16 beacon_transmit;
  293. __u16 beacon_receive;
  294. __u16 frame_correl;
  295. __u8 beacon_naun[6];
  296. __u32 reserved2;
  297. __u8 beacon_phys[4];
  298. };