1 |
1626 |
jcastillo |
/*
|
2 |
|
|
** hp100.c
|
3 |
|
|
** HP CASCADE Architecture Driver for 100VG-AnyLan Network Adapters
|
4 |
|
|
**
|
5 |
|
|
** $Id: hp100.c,v 1.1 2005-12-20 10:17:14 jcastillo Exp $
|
6 |
|
|
**
|
7 |
|
|
** Based on the HP100 driver written by Jaroslav Kysela <perex@jcu.cz>
|
8 |
|
|
** Extended for new busmaster capable chipsets by
|
9 |
|
|
** Siegfried "Frieder" Loeffler (dg1sek) <floeff@mathematik.uni-stuttgart.de>
|
10 |
|
|
**
|
11 |
|
|
** Maintained by: Jaroslav Kysela <perex@jcu.cz>
|
12 |
|
|
**
|
13 |
|
|
** This driver has only been tested with
|
14 |
|
|
** -- HP J2585B 10/100 Mbit/s PCI Busmaster
|
15 |
|
|
** -- HP J2585A 10/100 Mbit/s PCI
|
16 |
|
|
** -- HP J2970 10 Mbit/s PCI Combo 10base-T/BNC
|
17 |
|
|
** -- HP J2973 10 Mbit/s PCI 10base-T
|
18 |
|
|
** -- HP J2573 10/100 ISA
|
19 |
|
|
** -- Compex ReadyLink ENET100-VG4 10/100 Mbit/s PCI / EISA
|
20 |
|
|
** -- Compex FreedomLine 100/VG 10/100 Mbit/s ISA / EISA / PCI
|
21 |
|
|
**
|
22 |
|
|
** but it should also work with the other CASCADE based adapters.
|
23 |
|
|
**
|
24 |
|
|
** TODO:
|
25 |
|
|
** - J2573 seems to hang sometimes when in shared memory mode.
|
26 |
|
|
** - Mode for Priority TX
|
27 |
|
|
** - Check PCI registers, performance might be improved?
|
28 |
|
|
** - To reduce interrupt load in busmaster, one could switch off
|
29 |
|
|
** the interrupts that are used to refill the queues whenever the
|
30 |
|
|
** queues are filled up to more than a certain threshold.
|
31 |
|
|
** - some updates for EISA version of card
|
32 |
|
|
**
|
33 |
|
|
**
|
34 |
|
|
** This source/code is public free; you can distribute it and/or modify
|
35 |
|
|
** it under terms of the GNU General Public License (published by the
|
36 |
|
|
** Free Software Foundation) either version two of this License, or any
|
37 |
|
|
** later version.
|
38 |
|
|
**
|
39 |
|
|
** 1.55 -> 1.56
|
40 |
|
|
** - removed printk in misc. interrupt and update statistics to allow
|
41 |
|
|
** monitoring of card status
|
42 |
|
|
** - timing changes in xmit routines, relogin to 100VG hub added when
|
43 |
|
|
** driver does reset
|
44 |
|
|
** - included fix for Compex FreedomLine PCI adapter
|
45 |
|
|
**
|
46 |
|
|
** 1.54 -> 1.55
|
47 |
|
|
** - fixed bad initialization in init_module
|
48 |
|
|
** - added Compex FreedomLine adapter
|
49 |
|
|
** - some fixes in card initialization
|
50 |
|
|
**
|
51 |
|
|
** 1.53 -> 1.54
|
52 |
|
|
** - added hardware multicast filter support (doesn't work)
|
53 |
|
|
** - little changes in hp100_sense_lan routine
|
54 |
|
|
** - added support for Coax and AUI (J2970)
|
55 |
|
|
** - fix for multiple cards and hp100_mode parameter (insmod)
|
56 |
|
|
** - fix for shared IRQ
|
57 |
|
|
**
|
58 |
|
|
** 1.52 -> 1.53
|
59 |
|
|
** - fixed bug in multicast support
|
60 |
|
|
**
|
61 |
|
|
*/
|
62 |
|
|
|
63 |
|
|
#define HP100_DEFAULT_PRIORITY_TX 0
|
64 |
|
|
|
65 |
|
|
#undef HP100_DEBUG
|
66 |
|
|
#undef HP100_DEBUG_B /* Trace */
|
67 |
|
|
#undef HP100_DEBUG_BM /* Debug busmaster code (PDL stuff) */
|
68 |
|
|
|
69 |
|
|
#undef HP100_DEBUG_TRAINING /* Debug login-to-hub procedure */
|
70 |
|
|
#undef HP100_DEBUG_TX
|
71 |
|
|
#undef HP100_DEBUG_IRQ
|
72 |
|
|
#undef HP100_DEBUG_RX
|
73 |
|
|
|
74 |
|
|
#undef HP100_MULTICAST_FILTER /* Need to be debugged... */
|
75 |
|
|
|
76 |
|
|
#include <linux/version.h>
|
77 |
|
|
#include <linux/module.h>
|
78 |
|
|
#include <linux/kernel.h>
|
79 |
|
|
#include <linux/sched.h>
|
80 |
|
|
#include <linux/string.h>
|
81 |
|
|
#include <linux/errno.h>
|
82 |
|
|
#include <linux/ioport.h>
|
83 |
|
|
#include <linux/malloc.h>
|
84 |
|
|
#include <linux/interrupt.h>
|
85 |
|
|
#include <linux/pci.h>
|
86 |
|
|
#include <linux/bios32.h>
|
87 |
|
|
#include <asm/bitops.h>
|
88 |
|
|
#include <asm/io.h>
|
89 |
|
|
|
90 |
|
|
#include <linux/netdevice.h>
|
91 |
|
|
#include <linux/etherdevice.h>
|
92 |
|
|
#include <linux/skbuff.h>
|
93 |
|
|
|
94 |
|
|
#include <linux/types.h>
|
95 |
|
|
#include <linux/config.h> /* for CONFIG_PCI */
|
96 |
|
|
#include <linux/delay.h>
|
97 |
|
|
|
98 |
|
|
#if LINUX_VERSION_CODE < 0x020100
|
99 |
|
|
#define ioremap vremap
|
100 |
|
|
#define iounmap vfree
|
101 |
|
|
typedef struct enet_statistics hp100_stats_t;
|
102 |
|
|
#else
|
103 |
|
|
#define LINUX_2_1
|
104 |
|
|
typedef struct net_device_stats hp100_stats_t;
|
105 |
|
|
#endif
|
106 |
|
|
|
107 |
|
|
#ifndef __initfunc
|
108 |
|
|
#define __initfunc(__initarg) __initarg
|
109 |
|
|
#else
|
110 |
|
|
#include <linux/init.h>
|
111 |
|
|
#endif
|
112 |
|
|
|
113 |
|
|
#include "hp100.h"
|
114 |
|
|
|
115 |
|
|
/*
|
116 |
|
|
* defines
|
117 |
|
|
*/
|
118 |
|
|
|
119 |
|
|
#define HP100_BUS_ISA 0
|
120 |
|
|
#define HP100_BUS_EISA 1
|
121 |
|
|
#define HP100_BUS_PCI 2
|
122 |
|
|
|
123 |
|
|
#ifndef PCI_DEVICE_ID_HP_J2585B
|
124 |
|
|
#define PCI_DEVICE_ID_HP_J2585B 0x1031
|
125 |
|
|
#endif
|
126 |
|
|
#ifndef PCI_VENDOR_ID_COMPEX
|
127 |
|
|
#define PCI_VENDOR_ID_COMPEX 0x11f6
|
128 |
|
|
#endif
|
129 |
|
|
#ifndef PCI_DEVICE_ID_COMPEX_ENET100VG4
|
130 |
|
|
#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112
|
131 |
|
|
#endif
|
132 |
|
|
#ifndef PCI_VENDOR_ID_COMPEX2
|
133 |
|
|
#define PCI_VENDOR_ID_COMPEX2 0x101a
|
134 |
|
|
#endif
|
135 |
|
|
#ifndef PCI_DEVICE_ID_COMPEX2_100VG
|
136 |
|
|
#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005
|
137 |
|
|
#endif
|
138 |
|
|
|
139 |
|
|
#define HP100_REGION_SIZE 0x20 /* for ioports */
|
140 |
|
|
|
141 |
|
|
#define HP100_MAX_PACKET_SIZE (1536+4)
|
142 |
|
|
#define HP100_MIN_PACKET_SIZE 60
|
143 |
|
|
|
144 |
|
|
#ifndef HP100_DEFAULT_RX_RATIO
|
145 |
|
|
/* default - 75% onboard memory on the card are used for RX packets */
|
146 |
|
|
#define HP100_DEFAULT_RX_RATIO 75
|
147 |
|
|
#endif
|
148 |
|
|
|
149 |
|
|
#ifndef HP100_DEFAULT_PRIORITY_TX
|
150 |
|
|
/* default - don't enable transmit outgoing packets as priority */
|
151 |
|
|
#define HP100_DEFAULT_PRIORITY_TX 0
|
152 |
|
|
#endif
|
153 |
|
|
|
154 |
|
|
/*
|
155 |
|
|
* structures
|
156 |
|
|
*/
|
157 |
|
|
|
158 |
|
|
struct hp100_eisa_id {
|
159 |
|
|
u_int id;
|
160 |
|
|
const char *name;
|
161 |
|
|
u_char bus;
|
162 |
|
|
};
|
163 |
|
|
|
164 |
|
|
struct hp100_pci_id {
|
165 |
|
|
u_short vendor;
|
166 |
|
|
u_short device;
|
167 |
|
|
};
|
168 |
|
|
|
169 |
|
|
struct hp100_private {
|
170 |
|
|
struct hp100_eisa_id *id;
|
171 |
|
|
u_short chip;
|
172 |
|
|
u_short soft_model;
|
173 |
|
|
u_int memory_size;
|
174 |
|
|
u_int virt_memory_size;
|
175 |
|
|
u_short rx_ratio; /* 1 - 99 */
|
176 |
|
|
u_short priority_tx; /* != 0 - priority tx */
|
177 |
|
|
u_short mode; /* PIO, Shared Mem or Busmaster */
|
178 |
|
|
u_char bus;
|
179 |
|
|
u_char pci_bus;
|
180 |
|
|
u_char pci_device_fn;
|
181 |
|
|
short mem_mapped; /* memory mapped access */
|
182 |
|
|
u_int *mem_ptr_virt; /* virtual memory mapped area, maybe NULL */
|
183 |
|
|
u_int *mem_ptr_phys; /* physical memory mapped area */
|
184 |
|
|
short lan_type; /* 10Mb/s, 100Mb/s or -1 (error) */
|
185 |
|
|
int hub_status; /* was login to hub successful? */
|
186 |
|
|
u_char mac1_mode;
|
187 |
|
|
u_char mac2_mode;
|
188 |
|
|
u_char hash_bytes[ 8 ];
|
189 |
|
|
hp100_stats_t stats;
|
190 |
|
|
|
191 |
|
|
/* Rings for busmaster mode: */
|
192 |
|
|
hp100_ring_t *rxrhead; /* Head (oldest) index into rxring */
|
193 |
|
|
hp100_ring_t *rxrtail; /* Tail (newest) index into rxring */
|
194 |
|
|
hp100_ring_t *txrhead; /* Head (oldest) index into txring */
|
195 |
|
|
hp100_ring_t *txrtail; /* Tail (newest) index into txring */
|
196 |
|
|
|
197 |
|
|
hp100_ring_t rxring[ MAX_RX_PDL ];
|
198 |
|
|
hp100_ring_t txring[ MAX_TX_PDL ];
|
199 |
|
|
|
200 |
|
|
u_int *page_vaddr; /* Virtual address of allocated page */
|
201 |
|
|
u_int *page_vaddr_algn; /* Aligned virtual address of allocated page */
|
202 |
|
|
int rxrcommit; /* # Rx PDLs commited to adapter */
|
203 |
|
|
int txrcommit; /* # Tx PDLs commited to adapter */
|
204 |
|
|
};
|
205 |
|
|
|
206 |
|
|
/*
|
207 |
|
|
* variables
|
208 |
|
|
*/
|
209 |
|
|
|
210 |
|
|
static struct hp100_eisa_id hp100_eisa_ids[] = {
|
211 |
|
|
|
212 |
|
|
/* 10/100 EISA card with revision A Cascade chip */
|
213 |
|
|
{ 0x80F1F022, "HP J2577 rev A", HP100_BUS_EISA },
|
214 |
|
|
|
215 |
|
|
/* 10/100 ISA card with revision A Cascade chip */
|
216 |
|
|
{ 0x50F1F022, "HP J2573 rev A", HP100_BUS_ISA },
|
217 |
|
|
|
218 |
|
|
/* 10 only EISA card with Cascade chip */
|
219 |
|
|
{ 0x2019F022, "HP 27248B", HP100_BUS_EISA },
|
220 |
|
|
|
221 |
|
|
/* 10/100 EISA card with Cascade chip */
|
222 |
|
|
{ 0x4019F022, "HP J2577", HP100_BUS_EISA },
|
223 |
|
|
|
224 |
|
|
/* 10/100 ISA card with Cascade chip */
|
225 |
|
|
{ 0x5019F022, "HP J2573", HP100_BUS_ISA },
|
226 |
|
|
|
227 |
|
|
/* 10/100 PCI card - old J2585A */
|
228 |
|
|
{ 0x1030103c, "HP J2585A", HP100_BUS_PCI },
|
229 |
|
|
|
230 |
|
|
/* 10/100 PCI card - new J2585B - master capable */
|
231 |
|
|
{ 0x1041103c, "HP J2585B", HP100_BUS_PCI },
|
232 |
|
|
|
233 |
|
|
/* 10 Mbit Combo Adapter */
|
234 |
|
|
{ 0x1042103c, "HP J2970", HP100_BUS_PCI },
|
235 |
|
|
|
236 |
|
|
/* 10 Mbit 10baseT Adapter */
|
237 |
|
|
{ 0x1040103c, "HP J2973", HP100_BUS_PCI },
|
238 |
|
|
|
239 |
|
|
/* 10/100 EISA card from Compex */
|
240 |
|
|
{ 0x0103180e, "ReadyLink ENET100-VG4", HP100_BUS_EISA },
|
241 |
|
|
|
242 |
|
|
/* 10/100 EISA card from Compex - FreedomLine (sq5bpf) */
|
243 |
|
|
/* Note: plhbrod@mbox.vol.cz reported that same ID have ISA */
|
244 |
|
|
/* version of adapter, too... */
|
245 |
|
|
{ 0x0104180e, "FreedomLine 100/VG", HP100_BUS_EISA },
|
246 |
|
|
|
247 |
|
|
/* 10/100 PCI card from Compex - FreedomLine
|
248 |
|
|
*
|
249 |
|
|
* I think this card doesn't like aic7178 scsi controller, but
|
250 |
|
|
* I haven't tested this much. It works fine on diskless machines.
|
251 |
|
|
* Jacek Lipkowski <sq5bpf@acid.ch.pw.edu.pl>
|
252 |
|
|
*/
|
253 |
|
|
{ 0x021211f6, "FreedomLine 100/VG", HP100_BUS_PCI },
|
254 |
|
|
|
255 |
|
|
/* 10/100 PCI card from Compex (J2585A compatible) */
|
256 |
|
|
{ 0x011211f6, "ReadyLink ENET100-VG4", HP100_BUS_PCI }
|
257 |
|
|
|
258 |
|
|
};
|
259 |
|
|
|
260 |
|
|
#define HP100_EISA_IDS_SIZE (sizeof(hp100_eisa_ids)/sizeof(struct hp100_eisa_id))
|
261 |
|
|
|
262 |
|
|
static struct hp100_pci_id hp100_pci_ids[] = {
|
263 |
|
|
{ PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585A },
|
264 |
|
|
{ PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585B },
|
265 |
|
|
{ PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_ENET100VG4 },
|
266 |
|
|
{ PCI_VENDOR_ID_COMPEX2, PCI_DEVICE_ID_COMPEX2_100VG }
|
267 |
|
|
};
|
268 |
|
|
|
269 |
|
|
#define HP100_PCI_IDS_SIZE (sizeof(hp100_pci_ids)/sizeof(struct hp100_pci_id))
|
270 |
|
|
|
271 |
|
|
static int hp100_rx_ratio = HP100_DEFAULT_RX_RATIO;
|
272 |
|
|
static int hp100_priority_tx = HP100_DEFAULT_PRIORITY_TX;
|
273 |
|
|
static int hp100_mode = 1;
|
274 |
|
|
|
275 |
|
|
#ifdef LINUX_2_1
|
276 |
|
|
MODULE_PARM( hp100_rx_ratio, "1i" );
|
277 |
|
|
MODULE_PARM( hp100_priority_tx, "1i" );
|
278 |
|
|
MODULE_PARM( hp100_mode, "1i" );
|
279 |
|
|
#endif
|
280 |
|
|
|
281 |
|
|
/*
|
282 |
|
|
* prototypes
|
283 |
|
|
*/
|
284 |
|
|
|
285 |
|
|
static int hp100_probe1( struct device *dev, int ioaddr, u_char bus, u_char pci_bus, u_char pci_device_fn );
|
286 |
|
|
static int hp100_open( struct device *dev );
|
287 |
|
|
static int hp100_close( struct device *dev );
|
288 |
|
|
static int hp100_start_xmit( struct sk_buff *skb, struct device *dev );
|
289 |
|
|
static int hp100_start_xmit_bm (struct sk_buff *skb, struct device *dev );
|
290 |
|
|
static void hp100_rx( struct device *dev );
|
291 |
|
|
static hp100_stats_t *hp100_get_stats( struct device *dev );
|
292 |
|
|
static void hp100_misc_interrupt( struct device *dev );
|
293 |
|
|
static void hp100_update_stats( struct device *dev );
|
294 |
|
|
static void hp100_clear_stats( int ioaddr );
|
295 |
|
|
static void hp100_set_multicast_list( struct device *dev);
|
296 |
|
|
static void hp100_interrupt( int irq, void *dev_id, struct pt_regs *regs );
|
297 |
|
|
static void hp100_start_interface( struct device *dev );
|
298 |
|
|
static void hp100_stop_interface( struct device *dev );
|
299 |
|
|
static void hp100_load_eeprom( struct device *dev, u_short ioaddr );
|
300 |
|
|
static int hp100_sense_lan( struct device *dev );
|
301 |
|
|
static int hp100_login_to_vg_hub( struct device *dev, u_short force_relogin );
|
302 |
|
|
static int hp100_down_vg_link( struct device *dev );
|
303 |
|
|
static void hp100_cascade_reset( struct device *dev, u_short enable );
|
304 |
|
|
static void hp100_BM_shutdown( struct device *dev );
|
305 |
|
|
static void hp100_mmuinit( struct device *dev );
|
306 |
|
|
static void hp100_init_pdls( struct device *dev );
|
307 |
|
|
static int hp100_init_rxpdl( struct device *dev, register hp100_ring_t *ringptr, register u_int *pdlptr);
|
308 |
|
|
static int hp100_init_txpdl( struct device *dev, register hp100_ring_t *ringptr, register u_int *pdlptr);
|
309 |
|
|
static void hp100_rxfill( struct device *dev );
|
310 |
|
|
static void hp100_hwinit( struct device *dev );
|
311 |
|
|
static void hp100_clean_txring( struct device *dev );
|
312 |
|
|
#ifdef HP100_DEBUG
|
313 |
|
|
static void hp100_RegisterDump( struct device *dev );
|
314 |
|
|
#endif
|
315 |
|
|
|
316 |
|
|
/* TODO: This function should not really be needed in a good design... */
|
317 |
|
|
static void wait( void )
|
318 |
|
|
{
|
319 |
|
|
udelay( 1000 );
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
/*
|
323 |
|
|
* probe functions
|
324 |
|
|
* These functions should - if possible - avoid doing write operations
|
325 |
|
|
* since this could cause problems when the card is not installed.
|
326 |
|
|
*/
|
327 |
|
|
|
328 |
|
|
__initfunc(int hp100_probe( struct device *dev ))
|
329 |
|
|
{
|
330 |
|
|
int base_addr = dev ? dev -> base_addr : 0;
|
331 |
|
|
int ioaddr = 0;
|
332 |
|
|
#ifdef CONFIG_PCI
|
333 |
|
|
int pci_start_index = 0;
|
334 |
|
|
#endif
|
335 |
|
|
|
336 |
|
|
#ifdef HP100_DEBUG_B
|
337 |
|
|
hp100_outw( 0x4200, TRACE );
|
338 |
|
|
printk( "hp100: %s: probe\n", dev->name );
|
339 |
|
|
#endif
|
340 |
|
|
|
341 |
|
|
if ( base_addr > 0xff ) /* Check a single specified location. */
|
342 |
|
|
{
|
343 |
|
|
if ( check_region( base_addr, HP100_REGION_SIZE ) ) return -EINVAL;
|
344 |
|
|
if ( base_addr < 0x400 )
|
345 |
|
|
return hp100_probe1( dev, base_addr, HP100_BUS_ISA, 0, 0 );
|
346 |
|
|
if ( EISA_bus && base_addr >= 0x1c38 && ( (base_addr - 0x1c38) & 0x3ff ) == 0 )
|
347 |
|
|
return hp100_probe1( dev, base_addr, HP100_BUS_EISA, 0, 0 );
|
348 |
|
|
#ifdef CONFIG_PCI
|
349 |
|
|
printk( "hp100: %s: You may specify card # in i/o address parameter for PCI bus...", dev->name );
|
350 |
|
|
return hp100_probe1( dev, base_addr, HP100_BUS_PCI, 0, 0 );
|
351 |
|
|
#else
|
352 |
|
|
return -ENODEV;
|
353 |
|
|
#endif
|
354 |
|
|
}
|
355 |
|
|
else
|
356 |
|
|
#ifdef CONFIG_PCI
|
357 |
|
|
if ( base_addr > 0 && base_addr < 8 + 1 )
|
358 |
|
|
pci_start_index = 0x100 | ( base_addr - 1 );
|
359 |
|
|
else
|
360 |
|
|
#endif
|
361 |
|
|
if ( base_addr != 0 ) return -ENXIO;
|
362 |
|
|
|
363 |
|
|
/* at first - scan PCI bus(es) */
|
364 |
|
|
|
365 |
|
|
#ifdef CONFIG_PCI
|
366 |
|
|
if ( pcibios_present() )
|
367 |
|
|
{
|
368 |
|
|
int pci_index;
|
369 |
|
|
|
370 |
|
|
#ifdef HP100_DEBUG_PCI
|
371 |
|
|
printk( "hp100: %s: PCI BIOS is present, checking for devices..\n", dev->name );
|
372 |
|
|
#endif
|
373 |
|
|
for ( pci_index = pci_start_index & 7; pci_index < 8; pci_index++ )
|
374 |
|
|
{
|
375 |
|
|
u_char pci_bus, pci_device_fn;
|
376 |
|
|
u_short pci_command;
|
377 |
|
|
int pci_id_index;
|
378 |
|
|
|
379 |
|
|
for ( pci_id_index = 0; pci_id_index < HP100_PCI_IDS_SIZE; pci_id_index++ )
|
380 |
|
|
if ( pcibios_find_device( hp100_pci_ids[ pci_id_index ].vendor,
|
381 |
|
|
hp100_pci_ids[ pci_id_index ].device,
|
382 |
|
|
pci_index, &pci_bus,
|
383 |
|
|
&pci_device_fn ) == 0 ) goto __pci_found;
|
384 |
|
|
break;
|
385 |
|
|
|
386 |
|
|
__pci_found:
|
387 |
|
|
pcibios_read_config_dword( pci_bus, pci_device_fn,
|
388 |
|
|
PCI_BASE_ADDRESS_0, &ioaddr );
|
389 |
|
|
|
390 |
|
|
ioaddr &= ~3; /* remove I/O space marker in bit 0. */
|
391 |
|
|
|
392 |
|
|
if ( check_region( ioaddr, HP100_REGION_SIZE ) ) continue;
|
393 |
|
|
|
394 |
|
|
pcibios_read_config_word( pci_bus, pci_device_fn,
|
395 |
|
|
PCI_COMMAND, &pci_command );
|
396 |
|
|
if ( !( pci_command & PCI_COMMAND_IO ) )
|
397 |
|
|
{
|
398 |
|
|
#ifdef HP100_DEBUG
|
399 |
|
|
printk( "hp100: %s: PCI I/O Bit has not been set. Setting...\n", dev->name );
|
400 |
|
|
#endif
|
401 |
|
|
pci_command |= PCI_COMMAND_IO;
|
402 |
|
|
pcibios_write_config_word( pci_bus, pci_device_fn,
|
403 |
|
|
PCI_COMMAND, pci_command );
|
404 |
|
|
}
|
405 |
|
|
if ( !( pci_command & PCI_COMMAND_MASTER ) )
|
406 |
|
|
{
|
407 |
|
|
#ifdef HP100_DEBUG
|
408 |
|
|
printk( "hp100: %s: PCI Master Bit has not been set. Setting...\n", dev->name );
|
409 |
|
|
#endif
|
410 |
|
|
pci_command |= PCI_COMMAND_MASTER;
|
411 |
|
|
pcibios_write_config_word( pci_bus, pci_device_fn,
|
412 |
|
|
PCI_COMMAND, pci_command );
|
413 |
|
|
}
|
414 |
|
|
#ifdef HP100_DEBUG
|
415 |
|
|
printk( "hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr );
|
416 |
|
|
#endif
|
417 |
|
|
if ( hp100_probe1( dev, ioaddr, HP100_BUS_PCI, pci_bus, pci_device_fn ) == 0 )
|
418 |
|
|
return 0;
|
419 |
|
|
}
|
420 |
|
|
}
|
421 |
|
|
if ( pci_start_index > 0 ) return -ENODEV;
|
422 |
|
|
#endif /* CONFIG_PCI */
|
423 |
|
|
|
424 |
|
|
/* Second: Probe all EISA possible port regions (if EISA bus present) */
|
425 |
|
|
for ( ioaddr = 0x1c38; EISA_bus && ioaddr < 0x10000; ioaddr += 0x400 )
|
426 |
|
|
{
|
427 |
|
|
if ( check_region( ioaddr, HP100_REGION_SIZE ) ) continue;
|
428 |
|
|
if ( hp100_probe1( dev, ioaddr, HP100_BUS_EISA, 0, 0 ) == 0 ) return 0;
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
/* Third Probe all ISA possible port regions */
|
432 |
|
|
for ( ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x20 )
|
433 |
|
|
{
|
434 |
|
|
if ( check_region( ioaddr, HP100_REGION_SIZE ) ) continue;
|
435 |
|
|
if ( hp100_probe1( dev, ioaddr, HP100_BUS_ISA, 0, 0 ) == 0 ) return 0;
|
436 |
|
|
}
|
437 |
|
|
|
438 |
|
|
return -ENODEV;
|
439 |
|
|
}
|
440 |
|
|
|
441 |
|
|
|
442 |
|
|
__initfunc(static int hp100_probe1( struct device *dev, int ioaddr, u_char bus, u_char pci_bus, u_char pci_device_fn ))
|
443 |
|
|
{
|
444 |
|
|
int i;
|
445 |
|
|
|
446 |
|
|
u_char uc, uc_1;
|
447 |
|
|
u_int eisa_id;
|
448 |
|
|
u_int chip;
|
449 |
|
|
u_int memory_size = 0, virt_memory_size = 0;
|
450 |
|
|
u_short local_mode, lsw;
|
451 |
|
|
short mem_mapped;
|
452 |
|
|
u_int *mem_ptr_phys, *mem_ptr_virt;
|
453 |
|
|
struct hp100_private *lp;
|
454 |
|
|
struct hp100_eisa_id *eid;
|
455 |
|
|
|
456 |
|
|
#ifdef HP100_DEBUG_B
|
457 |
|
|
hp100_outw( 0x4201, TRACE );
|
458 |
|
|
printk("hp100: %s: probe1\n",dev->name);
|
459 |
|
|
#endif
|
460 |
|
|
|
461 |
|
|
if ( dev == NULL )
|
462 |
|
|
{
|
463 |
|
|
#ifdef HP100_DEBUG
|
464 |
|
|
printk( "hp100_probe1: %s: dev == NULL ?\n", dev->name );
|
465 |
|
|
#endif
|
466 |
|
|
return EIO;
|
467 |
|
|
}
|
468 |
|
|
|
469 |
|
|
if ( hp100_inw( HW_ID ) != HP100_HW_ID_CASCADE )
|
470 |
|
|
{
|
471 |
|
|
return -ENODEV;
|
472 |
|
|
}
|
473 |
|
|
else
|
474 |
|
|
{
|
475 |
|
|
chip = hp100_inw( PAGING ) & HP100_CHIPID_MASK;
|
476 |
|
|
#ifdef HP100_DEBUG
|
477 |
|
|
if ( chip == HP100_CHIPID_SHASTA )
|
478 |
|
|
printk("hp100: %s: Shasta Chip detected. (This is a pre 802.12 chip)\n", dev->name);
|
479 |
|
|
else if ( chip == HP100_CHIPID_RAINIER )
|
480 |
|
|
printk("hp100: %s: Rainier Chip detected. (This is a pre 802.12 chip)\n", dev->name);
|
481 |
|
|
else if ( chip == HP100_CHIPID_LASSEN )
|
482 |
|
|
printk("hp100: %s: Lassen Chip detected.\n", dev->name);
|
483 |
|
|
else
|
484 |
|
|
printk("hp100: %s: Warning: Unknown CASCADE chip (id=0x%.4x).\n",dev->name,chip);
|
485 |
|
|
#endif
|
486 |
|
|
}
|
487 |
|
|
|
488 |
|
|
dev->base_addr = ioaddr;
|
489 |
|
|
|
490 |
|
|
hp100_page( ID_MAC_ADDR );
|
491 |
|
|
for ( i = uc = eisa_id = 0; i < 4; i++ )
|
492 |
|
|
{
|
493 |
|
|
eisa_id >>= 8;
|
494 |
|
|
uc_1 = hp100_inb( BOARD_ID + i );
|
495 |
|
|
eisa_id |= uc_1 << 24;
|
496 |
|
|
uc += uc_1;
|
497 |
|
|
}
|
498 |
|
|
uc += hp100_inb( BOARD_ID + 4 );
|
499 |
|
|
|
500 |
|
|
if ( uc != 0xff ) /* bad checksum? */
|
501 |
|
|
{
|
502 |
|
|
printk("hp100_probe: %s: bad EISA ID checksum at base port 0x%x\n", dev->name, ioaddr );
|
503 |
|
|
return -ENODEV;
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
for ( i=0; i < HP100_EISA_IDS_SIZE; i++)
|
507 |
|
|
if ( hp100_eisa_ids[ i ].id == eisa_id )
|
508 |
|
|
break;
|
509 |
|
|
if ( i >= HP100_EISA_IDS_SIZE ) {
|
510 |
|
|
for ( i = 0; i < HP100_EISA_IDS_SIZE; i++)
|
511 |
|
|
if ( ( hp100_eisa_ids[ i ].id & 0xf0ffffff ) == ( eisa_id & 0xf0ffffff ) )
|
512 |
|
|
break;
|
513 |
|
|
if ( i >= HP100_EISA_IDS_SIZE ) {
|
514 |
|
|
printk( "hp100_probe: %s: card at port 0x%x isn't known (id = 0x%x)\n", dev -> name, ioaddr, eisa_id );
|
515 |
|
|
return -ENODEV;
|
516 |
|
|
}
|
517 |
|
|
}
|
518 |
|
|
eid = &hp100_eisa_ids[ i ];
|
519 |
|
|
if ( ( eid->id & 0x0f000000 ) < ( eisa_id & 0x0f000000 ) )
|
520 |
|
|
{
|
521 |
|
|
printk( "hp100_probe: %s: newer version of card %s at port 0x%x - unsupported\n",
|
522 |
|
|
dev->name, eid->name, ioaddr );
|
523 |
|
|
return -ENODEV;
|
524 |
|
|
}
|
525 |
|
|
|
526 |
|
|
for ( i = uc = 0; i < 7; i++ )
|
527 |
|
|
uc += hp100_inb( LAN_ADDR + i );
|
528 |
|
|
if ( uc != 0xff )
|
529 |
|
|
{
|
530 |
|
|
printk("hp100_probe: %s: bad lan address checksum (card %s at port 0x%x)\n",
|
531 |
|
|
dev->name, eid->name, ioaddr );
|
532 |
|
|
return -EIO;
|
533 |
|
|
}
|
534 |
|
|
|
535 |
|
|
/* Make sure, that all registers are correctly updated... */
|
536 |
|
|
|
537 |
|
|
hp100_load_eeprom( dev, ioaddr );
|
538 |
|
|
wait();
|
539 |
|
|
|
540 |
|
|
/*
|
541 |
|
|
* Determine driver operation mode
|
542 |
|
|
*
|
543 |
|
|
* Use the variable "hp100_mode" upon insmod or as kernel parameter to
|
544 |
|
|
* force driver modes:
|
545 |
|
|
* hp100_mode=1 -> default, use busmaster mode if configured.
|
546 |
|
|
* hp100_mode=2 -> enable shared memory mode
|
547 |
|
|
* hp100_mode=3 -> force use of i/o mapped mode.
|
548 |
|
|
* hp100_mode=4 -> same as 1, but re-set the enable bit on the card.
|
549 |
|
|
*/
|
550 |
|
|
|
551 |
|
|
/*
|
552 |
|
|
* LSW values:
|
553 |
|
|
* 0x2278 -> J2585B, PnP shared memory mode
|
554 |
|
|
* 0x2270 -> J2585B, shared memory mode, 0xdc000
|
555 |
|
|
* 0xa23c -> J2585B, I/O mapped mode
|
556 |
|
|
* 0x2240 -> EISA COMPEX, BusMaster (Shasta Chip)
|
557 |
|
|
* 0x2220 -> EISA HP, I/O (Shasta Chip)
|
558 |
|
|
* 0x2260 -> EISA HP, BusMaster (Shasta Chip)
|
559 |
|
|
*/
|
560 |
|
|
|
561 |
|
|
#if 0
|
562 |
|
|
local_mode = 0x2270;
|
563 |
|
|
hp100_outw(0xfefe,OPTION_LSW);
|
564 |
|
|
hp100_outw(local_mode|HP100_SET_LB|HP100_SET_HB,OPTION_LSW);
|
565 |
|
|
#endif
|
566 |
|
|
|
567 |
|
|
/* hp100_mode value maybe used in future by another card */
|
568 |
|
|
local_mode=hp100_mode;
|
569 |
|
|
if ( local_mode < 1 || local_mode > 4 )
|
570 |
|
|
local_mode = 1; /* default */
|
571 |
|
|
#ifdef HP100_DEBUG
|
572 |
|
|
printk( "hp100: %s: original LSW = 0x%x\n", dev->name, hp100_inw(OPTION_LSW) );
|
573 |
|
|
#endif
|
574 |
|
|
|
575 |
|
|
if(local_mode==3)
|
576 |
|
|
{
|
577 |
|
|
hp100_outw(HP100_MEM_EN|HP100_RESET_LB, OPTION_LSW);
|
578 |
|
|
hp100_outw(HP100_IO_EN|HP100_SET_LB, OPTION_LSW);
|
579 |
|
|
hp100_outw(HP100_BM_WRITE|HP100_BM_READ|HP100_RESET_HB, OPTION_LSW);
|
580 |
|
|
printk("hp100: %s: IO mapped mode forced.\n", dev->name);
|
581 |
|
|
}
|
582 |
|
|
else if(local_mode==2)
|
583 |
|
|
{
|
584 |
|
|
hp100_outw(HP100_MEM_EN|HP100_SET_LB, OPTION_LSW);
|
585 |
|
|
hp100_outw(HP100_IO_EN |HP100_SET_LB, OPTION_LSW);
|
586 |
|
|
hp100_outw(HP100_BM_WRITE|HP100_BM_READ|HP100_RESET_HB, OPTION_LSW);
|
587 |
|
|
printk("hp100: %s: Shared memory mode requested.\n", dev->name);
|
588 |
|
|
}
|
589 |
|
|
else if(local_mode==4)
|
590 |
|
|
{
|
591 |
|
|
if(chip==HP100_CHIPID_LASSEN)
|
592 |
|
|
{
|
593 |
|
|
hp100_outw(HP100_BM_WRITE|
|
594 |
|
|
HP100_BM_READ | HP100_SET_HB, OPTION_LSW);
|
595 |
|
|
hp100_outw(HP100_IO_EN |
|
596 |
|
|
HP100_MEM_EN | HP100_RESET_LB, OPTION_LSW);
|
597 |
|
|
printk("hp100: %s: Busmaster mode requested.\n",dev->name);
|
598 |
|
|
}
|
599 |
|
|
local_mode=1;
|
600 |
|
|
}
|
601 |
|
|
|
602 |
|
|
if(local_mode==1) /* default behaviour */
|
603 |
|
|
{
|
604 |
|
|
lsw = hp100_inw(OPTION_LSW);
|
605 |
|
|
|
606 |
|
|
if ( (lsw & HP100_IO_EN) &&
|
607 |
|
|
(~lsw & HP100_MEM_EN) &&
|
608 |
|
|
(~lsw & (HP100_BM_WRITE|HP100_BM_READ)) )
|
609 |
|
|
{
|
610 |
|
|
#ifdef HP100_DEBUG
|
611 |
|
|
printk("hp100: %s: IO_EN bit is set on card.\n",dev->name);
|
612 |
|
|
#endif
|
613 |
|
|
local_mode=3;
|
614 |
|
|
}
|
615 |
|
|
else if ( chip == HP100_CHIPID_LASSEN &&
|
616 |
|
|
( lsw & (HP100_BM_WRITE|HP100_BM_READ) ) ==
|
617 |
|
|
(HP100_BM_WRITE|HP100_BM_READ) )
|
618 |
|
|
{
|
619 |
|
|
printk("hp100: %s: Busmaster mode enabled.\n",dev->name);
|
620 |
|
|
hp100_outw(HP100_MEM_EN|HP100_IO_EN|HP100_RESET_LB, OPTION_LSW);
|
621 |
|
|
}
|
622 |
|
|
else
|
623 |
|
|
{
|
624 |
|
|
#ifdef HP100_DEBUG
|
625 |
|
|
printk("hp100: %s: Card not configured for BM or BM not supported with this card.\n", dev->name );
|
626 |
|
|
printk("hp100: %s: Trying shared memory mode.\n", dev->name);
|
627 |
|
|
#endif
|
628 |
|
|
/* In this case, try shared memory mode */
|
629 |
|
|
local_mode=2;
|
630 |
|
|
hp100_outw(HP100_MEM_EN|HP100_SET_LB, OPTION_LSW);
|
631 |
|
|
/* hp100_outw(HP100_IO_EN|HP100_RESET_LB, OPTION_LSW); */
|
632 |
|
|
}
|
633 |
|
|
}
|
634 |
|
|
|
635 |
|
|
#ifdef HP100_DEBUG
|
636 |
|
|
printk( "hp100: %s: new LSW = 0x%x\n", dev->name, hp100_inw(OPTION_LSW) );
|
637 |
|
|
#endif
|
638 |
|
|
|
639 |
|
|
/* Check for shared memory on the card, eventually remap it */
|
640 |
|
|
hp100_page( HW_MAP );
|
641 |
|
|
mem_mapped = (( hp100_inw( OPTION_LSW ) & ( HP100_MEM_EN ) ) != 0);
|
642 |
|
|
mem_ptr_phys = mem_ptr_virt = NULL;
|
643 |
|
|
memory_size = (8192<<( (hp100_inb(SRAM)>>5)&0x07));
|
644 |
|
|
virt_memory_size = 0;
|
645 |
|
|
|
646 |
|
|
/* For memory mapped or busmaster mode, we want the memory address */
|
647 |
|
|
if ( mem_mapped || (local_mode==1))
|
648 |
|
|
{
|
649 |
|
|
mem_ptr_phys = (u_int *)( hp100_inw( MEM_MAP_LSW ) |
|
650 |
|
|
( hp100_inw( MEM_MAP_MSW ) << 16 ) );
|
651 |
|
|
(u_int)mem_ptr_phys &= ~0x1fff; /* 8k alignment */
|
652 |
|
|
|
653 |
|
|
if ( bus == HP100_BUS_ISA && ( (u_long)mem_ptr_phys & ~0xfffff ) != 0 )
|
654 |
|
|
{
|
655 |
|
|
printk("hp100: %s: Can only use programmed i/o mode.\n", dev->name);
|
656 |
|
|
mem_ptr_phys = NULL;
|
657 |
|
|
mem_mapped = 0;
|
658 |
|
|
local_mode=3; /* Use programmed i/o */
|
659 |
|
|
}
|
660 |
|
|
|
661 |
|
|
/* We do not need access to shared memory in busmaster mode */
|
662 |
|
|
/* However in slave mode we need to remap high (>1GB) card memory */
|
663 |
|
|
if(local_mode!=1) /* = not busmaster */
|
664 |
|
|
{
|
665 |
|
|
if ( bus == HP100_BUS_PCI && mem_ptr_phys >= (u_int *)0x100000 )
|
666 |
|
|
{
|
667 |
|
|
/* We try with smaller memory sizes, if ioremap fails */
|
668 |
|
|
for(virt_memory_size = memory_size; virt_memory_size>16383; virt_memory_size>>=1)
|
669 |
|
|
{
|
670 |
|
|
if((mem_ptr_virt=ioremap((u_long)mem_ptr_phys,virt_memory_size))==NULL)
|
671 |
|
|
{
|
672 |
|
|
#ifdef HP100_DEBUG
|
673 |
|
|
printk( "hp100: %s: ioremap for 0x%x bytes high PCI memory at 0x%lx failed\n", dev->name, virt_memory_size, (u_long)mem_ptr_phys );
|
674 |
|
|
#endif
|
675 |
|
|
}
|
676 |
|
|
else
|
677 |
|
|
{
|
678 |
|
|
#ifdef HP100_DEBUG
|
679 |
|
|
printk( "hp100: %s: remapped 0x%x bytes high PCI memory at 0x%lx to 0x%lx.\n", dev->name, virt_memory_size, (u_long)mem_ptr_phys, (u_long)mem_ptr_virt);
|
680 |
|
|
#endif
|
681 |
|
|
break;
|
682 |
|
|
}
|
683 |
|
|
}
|
684 |
|
|
|
685 |
|
|
if(mem_ptr_virt==NULL) /* all ioremap tries failed */
|
686 |
|
|
{
|
687 |
|
|
printk("hp100: %s: Failed to ioremap the PCI card memory. Will have to use i/o mapped mode.\n", dev->name);
|
688 |
|
|
local_mode=3;
|
689 |
|
|
virt_memory_size = 0;
|
690 |
|
|
}
|
691 |
|
|
}
|
692 |
|
|
}
|
693 |
|
|
|
694 |
|
|
}
|
695 |
|
|
|
696 |
|
|
if(local_mode==3) /* io mapped forced */
|
697 |
|
|
{
|
698 |
|
|
mem_mapped = 0;
|
699 |
|
|
mem_ptr_phys = mem_ptr_virt = NULL;
|
700 |
|
|
printk("hp100: %s: Using (slow) programmed i/o mode.\n", dev->name);
|
701 |
|
|
}
|
702 |
|
|
|
703 |
|
|
/* Initialise the "private" data structure for this card. */
|
704 |
|
|
if ( (dev->priv=kmalloc(sizeof(struct hp100_private), GFP_KERNEL)) == NULL)
|
705 |
|
|
return -ENOMEM;
|
706 |
|
|
memset( dev->priv, 0, sizeof(struct hp100_private) );
|
707 |
|
|
|
708 |
|
|
lp = (struct hp100_private *)dev->priv;
|
709 |
|
|
lp->id = eid;
|
710 |
|
|
lp->chip = chip;
|
711 |
|
|
lp->mode = local_mode;
|
712 |
|
|
lp->pci_bus = pci_bus;
|
713 |
|
|
lp->bus = bus;
|
714 |
|
|
lp->pci_device_fn = pci_device_fn;
|
715 |
|
|
lp->priority_tx = hp100_priority_tx;
|
716 |
|
|
lp->rx_ratio = hp100_rx_ratio;
|
717 |
|
|
lp->mem_ptr_phys = mem_ptr_phys;
|
718 |
|
|
lp->mem_ptr_virt = mem_ptr_virt;
|
719 |
|
|
hp100_page( ID_MAC_ADDR );
|
720 |
|
|
lp->soft_model = hp100_inb( SOFT_MODEL );
|
721 |
|
|
lp->mac1_mode = HP100_MAC1MODE3;
|
722 |
|
|
lp->mac2_mode = HP100_MAC2MODE3;
|
723 |
|
|
memset( &lp->hash_bytes, 0x00, 8 );
|
724 |
|
|
|
725 |
|
|
dev->base_addr = ioaddr;
|
726 |
|
|
|
727 |
|
|
lp->memory_size = memory_size;
|
728 |
|
|
lp->virt_memory_size = virt_memory_size;
|
729 |
|
|
lp->rx_ratio = hp100_rx_ratio; /* can be conf'd with insmod */
|
730 |
|
|
|
731 |
|
|
/* memory region for programmed i/o */
|
732 |
|
|
request_region( dev->base_addr, HP100_REGION_SIZE, eid->name );
|
733 |
|
|
|
734 |
|
|
dev->open = hp100_open;
|
735 |
|
|
dev->stop = hp100_close;
|
736 |
|
|
|
737 |
|
|
if (lp->mode==1) /* busmaster */
|
738 |
|
|
dev->hard_start_xmit = hp100_start_xmit_bm;
|
739 |
|
|
else
|
740 |
|
|
dev->hard_start_xmit = hp100_start_xmit;
|
741 |
|
|
|
742 |
|
|
dev->get_stats = hp100_get_stats;
|
743 |
|
|
dev->set_multicast_list = &hp100_set_multicast_list;
|
744 |
|
|
|
745 |
|
|
/* Ask the card for which IRQ line it is configured */
|
746 |
|
|
hp100_page( HW_MAP );
|
747 |
|
|
dev->irq = hp100_inb( IRQ_CHANNEL ) & HP100_IRQMASK;
|
748 |
|
|
if ( dev->irq == 2 )
|
749 |
|
|
dev->irq = 9;
|
750 |
|
|
|
751 |
|
|
if(lp->mode==1) /* busmaster */
|
752 |
|
|
dev->dma=4;
|
753 |
|
|
|
754 |
|
|
/* Ask the card for its MAC address and store it for later use. */
|
755 |
|
|
hp100_page( ID_MAC_ADDR );
|
756 |
|
|
for ( i = uc = 0; i < 6; i++ )
|
757 |
|
|
dev->dev_addr[ i ] = hp100_inb( LAN_ADDR + i );
|
758 |
|
|
|
759 |
|
|
/* Reset statistics (counters) */
|
760 |
|
|
hp100_clear_stats( ioaddr );
|
761 |
|
|
|
762 |
|
|
ether_setup( dev );
|
763 |
|
|
|
764 |
|
|
/* If busmaster mode is wanted, a dma-capable memory area is needed for
|
765 |
|
|
* the rx and tx PDLs
|
766 |
|
|
* PCI cards can access the whole PC memory. Therefore GFP_DMA is not
|
767 |
|
|
* needed for the allocation of the memory area.
|
768 |
|
|
*/
|
769 |
|
|
|
770 |
|
|
/* TODO: We do not need this with old cards, where PDLs are stored
|
771 |
|
|
* in the cards shared memory area. But currently, busmaster has been
|
772 |
|
|
* implemented/tested only with the lassen chip anyway... */
|
773 |
|
|
if(lp->mode==1) /* busmaster */
|
774 |
|
|
{
|
775 |
|
|
/* Get physically continous memory for TX & RX PDLs */
|
776 |
|
|
if ( (lp->page_vaddr=kmalloc(MAX_RINGSIZE+0x0f,GFP_KERNEL) ) == NULL)
|
777 |
|
|
return -ENOMEM;
|
778 |
|
|
lp->page_vaddr_algn=((u_int *) ( ((u_int)(lp->page_vaddr)+0x0f) &~0x0f));
|
779 |
|
|
memset(lp->page_vaddr, 0, MAX_RINGSIZE+0x0f);
|
780 |
|
|
|
781 |
|
|
#ifdef HP100_DEBUG_BM
|
782 |
|
|
printk("hp100: %s: Reserved DMA memory from 0x%x to 0x%x\n",
|
783 |
|
|
dev->name,
|
784 |
|
|
(u_int)lp->page_vaddr_algn,
|
785 |
|
|
(u_int)lp->page_vaddr_algn+MAX_RINGSIZE);
|
786 |
|
|
#endif
|
787 |
|
|
lp->rxrcommit = lp->txrcommit = 0;
|
788 |
|
|
lp->rxrhead = lp->rxrtail = &(lp->rxring[0]);
|
789 |
|
|
lp->txrhead = lp->txrtail = &(lp->txring[0]);
|
790 |
|
|
}
|
791 |
|
|
|
792 |
|
|
/* Initialise the card. */
|
793 |
|
|
/* (I'm not really sure if it's a good idea to do this during probing, but
|
794 |
|
|
* like this it's assured that the lan connection type can be sensed
|
795 |
|
|
* correctly)
|
796 |
|
|
*/
|
797 |
|
|
hp100_hwinit( dev );
|
798 |
|
|
|
799 |
|
|
/* Try to find out which kind of LAN the card is connected to. */
|
800 |
|
|
lp->lan_type = hp100_sense_lan( dev );
|
801 |
|
|
|
802 |
|
|
/* Print out a message what about what we think we have probed. */
|
803 |
|
|
printk( "hp100: %s: %s at 0x%x, IRQ %d, ",
|
804 |
|
|
dev->name, lp->id->name, ioaddr, dev->irq );
|
805 |
|
|
switch ( bus ) {
|
806 |
|
|
case HP100_BUS_EISA: printk( "EISA" ); break;
|
807 |
|
|
case HP100_BUS_PCI: printk( "PCI" ); break;
|
808 |
|
|
default: printk( "ISA" ); break;
|
809 |
|
|
}
|
810 |
|
|
printk( " bus, %dk SRAM (rx/tx %d%%).\n",
|
811 |
|
|
lp->memory_size >> 10, lp->rx_ratio );
|
812 |
|
|
|
813 |
|
|
if ( lp->mode==2 ) /* memory mapped */
|
814 |
|
|
{
|
815 |
|
|
printk( "hp100: %s: Memory area at 0x%lx-0x%lx",
|
816 |
|
|
dev->name,(u_long)mem_ptr_phys,
|
817 |
|
|
((u_long)mem_ptr_phys+(mem_ptr_phys>(u_int *)0x100000?(u_long)lp->memory_size:16*1024))-1 );
|
818 |
|
|
if ( mem_ptr_virt )
|
819 |
|
|
printk( " (virtual base 0x%lx)", (u_long)mem_ptr_virt );
|
820 |
|
|
printk( ".\n" );
|
821 |
|
|
|
822 |
|
|
/* Set for info when doing ifconfig */
|
823 |
|
|
dev->mem_start = (u_long)mem_ptr_phys;
|
824 |
|
|
dev->mem_end = (u_long)mem_ptr_phys+(u_long)lp->memory_size;
|
825 |
|
|
}
|
826 |
|
|
printk( "hp100: %s: ", dev->name );
|
827 |
|
|
if ( lp->lan_type != HP100_LAN_ERR )
|
828 |
|
|
printk( "Adapter is attached to " );
|
829 |
|
|
switch ( lp->lan_type ) {
|
830 |
|
|
case HP100_LAN_100:
|
831 |
|
|
printk( "100Mb/s Voice Grade AnyLAN network.\n" );
|
832 |
|
|
break;
|
833 |
|
|
case HP100_LAN_10:
|
834 |
|
|
printk( "10Mb/s network.\n" );
|
835 |
|
|
break;
|
836 |
|
|
default:
|
837 |
|
|
printk( "Warning! Link down.\n" );
|
838 |
|
|
}
|
839 |
|
|
|
840 |
|
|
return 0;
|
841 |
|
|
}
|
842 |
|
|
|
843 |
|
|
|
844 |
|
|
/* This procedure puts the card into a stable init state */
|
845 |
|
|
static void hp100_hwinit( struct device *dev )
|
846 |
|
|
{
|
847 |
|
|
int ioaddr = dev->base_addr;
|
848 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
849 |
|
|
|
850 |
|
|
#ifdef HP100_DEBUG_B
|
851 |
|
|
hp100_outw( 0x4202, TRACE );
|
852 |
|
|
printk("hp100: %s: hwinit\n", dev->name);
|
853 |
|
|
#endif
|
854 |
|
|
|
855 |
|
|
/* Initialise the card. -------------------------------------------- */
|
856 |
|
|
|
857 |
|
|
/* Clear all pending Ints and disable Ints */
|
858 |
|
|
hp100_page( PERFORMANCE );
|
859 |
|
|
hp100_outw( 0xfefe, IRQ_MASK ); /* mask off all ints */
|
860 |
|
|
hp100_outw( 0xffff, IRQ_STATUS ); /* clear all pending ints */
|
861 |
|
|
|
862 |
|
|
hp100_outw( HP100_INT_EN | HP100_RESET_LB, OPTION_LSW );
|
863 |
|
|
hp100_outw( HP100_TRI_INT | HP100_SET_HB, OPTION_LSW );
|
864 |
|
|
|
865 |
|
|
if(lp->mode==1)
|
866 |
|
|
{
|
867 |
|
|
hp100_BM_shutdown( dev ); /* disables BM, puts cascade in reset */
|
868 |
|
|
wait();
|
869 |
|
|
}
|
870 |
|
|
else
|
871 |
|
|
{
|
872 |
|
|
hp100_outw( HP100_INT_EN | HP100_RESET_LB, OPTION_LSW );
|
873 |
|
|
hp100_cascade_reset( dev, TRUE );
|
874 |
|
|
hp100_page( MAC_CTRL );
|
875 |
|
|
hp100_andb( ~(HP100_RX_EN|HP100_TX_EN), MAC_CFG_1);
|
876 |
|
|
}
|
877 |
|
|
|
878 |
|
|
/* Initiate EEPROM reload */
|
879 |
|
|
hp100_load_eeprom( dev, 0 );
|
880 |
|
|
|
881 |
|
|
wait();
|
882 |
|
|
|
883 |
|
|
/* Go into reset again. */
|
884 |
|
|
hp100_cascade_reset( dev, TRUE );
|
885 |
|
|
|
886 |
|
|
/* Set Option Registers to a safe state */
|
887 |
|
|
hp100_outw( HP100_DEBUG_EN |
|
888 |
|
|
HP100_RX_HDR |
|
889 |
|
|
HP100_EE_EN |
|
890 |
|
|
HP100_BM_WRITE |
|
891 |
|
|
HP100_BM_READ | HP100_RESET_HB |
|
892 |
|
|
HP100_FAKE_INT |
|
893 |
|
|
HP100_INT_EN |
|
894 |
|
|
HP100_MEM_EN |
|
895 |
|
|
HP100_IO_EN | HP100_RESET_LB, OPTION_LSW);
|
896 |
|
|
|
897 |
|
|
hp100_outw( HP100_TRI_INT |
|
898 |
|
|
HP100_MMAP_DIS | HP100_SET_HB, OPTION_LSW );
|
899 |
|
|
|
900 |
|
|
hp100_outb( HP100_PRIORITY_TX |
|
901 |
|
|
HP100_ADV_NXT_PKT |
|
902 |
|
|
HP100_TX_CMD | HP100_RESET_LB, OPTION_MSW );
|
903 |
|
|
|
904 |
|
|
/* TODO: Configure MMU for Ram Test. */
|
905 |
|
|
/* TODO: Ram Test. */
|
906 |
|
|
|
907 |
|
|
/* Re-check if adapter is still at same i/o location */
|
908 |
|
|
/* (If the base i/o in eeprom has been changed but the */
|
909 |
|
|
/* registers had not been changed, a reload of the eeprom */
|
910 |
|
|
/* would move the adapter to the address stored in eeprom */
|
911 |
|
|
|
912 |
|
|
/* TODO: Code to implement. */
|
913 |
|
|
|
914 |
|
|
/* Until here it was code from HWdiscover procedure. */
|
915 |
|
|
/* Next comes code from mmuinit procedure of SCO BM driver which is
|
916 |
|
|
* called from HWconfigure in the SCO driver. */
|
917 |
|
|
|
918 |
|
|
/* Initialise MMU, eventually switch on Busmaster Mode, initialise
|
919 |
|
|
* multicast filter...
|
920 |
|
|
*/
|
921 |
|
|
hp100_mmuinit( dev );
|
922 |
|
|
|
923 |
|
|
/* We don't turn the interrupts on here - this is done by start_interface. */
|
924 |
|
|
wait(); /* TODO: Do we really need this? */
|
925 |
|
|
|
926 |
|
|
/* Enable Hardware (e.g. unreset) */
|
927 |
|
|
hp100_cascade_reset( dev, FALSE );
|
928 |
|
|
|
929 |
|
|
/* ------- initialisation complete ----------- */
|
930 |
|
|
|
931 |
|
|
/* Finally try to log in the Hub if there may be a VG connection. */
|
932 |
|
|
if( lp->lan_type != HP100_LAN_10 )
|
933 |
|
|
hp100_login_to_vg_hub( dev, FALSE ); /* relogin */
|
934 |
|
|
}
|
935 |
|
|
|
936 |
|
|
|
937 |
|
|
/*
|
938 |
|
|
* mmuinit - Reinitialise Cascade MMU and MAC settings.
|
939 |
|
|
* Note: Must already be in reset and leaves card in reset.
|
940 |
|
|
*/
|
941 |
|
|
static void hp100_mmuinit( struct device *dev )
|
942 |
|
|
{
|
943 |
|
|
int ioaddr = dev->base_addr;
|
944 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
945 |
|
|
int i;
|
946 |
|
|
|
947 |
|
|
#ifdef HP100_DEBUG_B
|
948 |
|
|
hp100_outw( 0x4203, TRACE );
|
949 |
|
|
printk("hp100: %s: mmuinit\n",dev->name);
|
950 |
|
|
#endif
|
951 |
|
|
|
952 |
|
|
#ifdef HP100_DEBUG
|
953 |
|
|
if( 0!=(hp100_inw(OPTION_LSW)&HP100_HW_RST) )
|
954 |
|
|
{
|
955 |
|
|
printk("hp100: %s: Not in reset when entering mmuinit. Fix me.\n",dev->name);
|
956 |
|
|
return;
|
957 |
|
|
}
|
958 |
|
|
#endif
|
959 |
|
|
|
960 |
|
|
/* Make sure IRQs are masked off and ack'ed. */
|
961 |
|
|
hp100_page( PERFORMANCE );
|
962 |
|
|
hp100_outw( 0xfefe, IRQ_MASK ); /* mask off all ints */
|
963 |
|
|
hp100_outw( 0xffff, IRQ_STATUS ); /* ack IRQ */
|
964 |
|
|
|
965 |
|
|
/*
|
966 |
|
|
* Enable Hardware
|
967 |
|
|
* - Clear Debug En, Rx Hdr Pipe, EE En, I/O En, Fake Int and Intr En
|
968 |
|
|
* - Set Tri-State Int, Bus Master Rd/Wr, and Mem Map Disable
|
969 |
|
|
* - Clear Priority, Advance Pkt and Xmit Cmd
|
970 |
|
|
*/
|
971 |
|
|
|
972 |
|
|
hp100_outw( HP100_DEBUG_EN |
|
973 |
|
|
HP100_RX_HDR |
|
974 |
|
|
HP100_EE_EN | HP100_RESET_HB |
|
975 |
|
|
HP100_IO_EN |
|
976 |
|
|
HP100_FAKE_INT |
|
977 |
|
|
HP100_INT_EN | HP100_RESET_LB, OPTION_LSW );
|
978 |
|
|
|
979 |
|
|
hp100_outw( HP100_TRI_INT | HP100_SET_HB, OPTION_LSW);
|
980 |
|
|
|
981 |
|
|
if(lp->mode==1) /* busmaster */
|
982 |
|
|
{
|
983 |
|
|
hp100_outw( HP100_BM_WRITE |
|
984 |
|
|
HP100_BM_READ |
|
985 |
|
|
HP100_MMAP_DIS | HP100_SET_HB, OPTION_LSW );
|
986 |
|
|
}
|
987 |
|
|
else if(lp->mode==2) /* memory mapped */
|
988 |
|
|
{
|
989 |
|
|
hp100_outw( HP100_BM_WRITE |
|
990 |
|
|
HP100_BM_READ | HP100_RESET_HB, OPTION_LSW );
|
991 |
|
|
hp100_outw( HP100_MMAP_DIS | HP100_RESET_HB, OPTION_LSW );
|
992 |
|
|
hp100_outw( HP100_MEM_EN | HP100_SET_LB, OPTION_LSW );
|
993 |
|
|
hp100_outw( HP100_IO_EN | HP100_SET_LB, OPTION_LSW );
|
994 |
|
|
}
|
995 |
|
|
else if( lp->mode==3 ) /* i/o mapped mode */
|
996 |
|
|
{
|
997 |
|
|
hp100_outw( HP100_MMAP_DIS | HP100_SET_HB |
|
998 |
|
|
HP100_IO_EN | HP100_SET_LB, OPTION_LSW );
|
999 |
|
|
}
|
1000 |
|
|
|
1001 |
|
|
hp100_page( HW_MAP );
|
1002 |
|
|
hp100_outb( 0, EARLYRXCFG );
|
1003 |
|
|
hp100_outw( 0, EARLYTXCFG );
|
1004 |
|
|
|
1005 |
|
|
/*
|
1006 |
|
|
* Enable Bus Master mode
|
1007 |
|
|
*/
|
1008 |
|
|
if(lp->mode==1) /* busmaster */
|
1009 |
|
|
{
|
1010 |
|
|
/* Experimental: Set some PCI configuration bits */
|
1011 |
|
|
hp100_page( HW_MAP );
|
1012 |
|
|
hp100_andb( ~HP100_PDL_USE3, MODECTRL1 ); /* BM engine read maximum */
|
1013 |
|
|
hp100_andb( ~HP100_TX_DUALQ, MODECTRL1 ); /* No Queue for Priority TX */
|
1014 |
|
|
|
1015 |
|
|
/* PCI Bus failures should result in a Misc. Interrupt */
|
1016 |
|
|
hp100_orb( HP100_EN_BUS_FAIL, MODECTRL2);
|
1017 |
|
|
|
1018 |
|
|
hp100_outw( HP100_BM_READ | HP100_BM_WRITE | HP100_SET_HB, OPTION_LSW );
|
1019 |
|
|
hp100_page( HW_MAP );
|
1020 |
|
|
/* Use Burst Mode and switch on PAGE_CK */
|
1021 |
|
|
hp100_orb( HP100_BM_BURST_RD |
|
1022 |
|
|
HP100_BM_BURST_WR, BM);
|
1023 |
|
|
if((lp->chip==HP100_CHIPID_RAINIER)||(lp->chip==HP100_CHIPID_SHASTA))
|
1024 |
|
|
hp100_orb( HP100_BM_PAGE_CK, BM );
|
1025 |
|
|
hp100_orb( HP100_BM_MASTER, BM );
|
1026 |
|
|
}
|
1027 |
|
|
else /* not busmaster */
|
1028 |
|
|
{
|
1029 |
|
|
hp100_page(HW_MAP);
|
1030 |
|
|
hp100_andb(~HP100_BM_MASTER, BM );
|
1031 |
|
|
}
|
1032 |
|
|
|
1033 |
|
|
/*
|
1034 |
|
|
* Divide card memory into regions for Rx, Tx and, if non-ETR chip, PDLs
|
1035 |
|
|
*/
|
1036 |
|
|
hp100_page( MMU_CFG );
|
1037 |
|
|
if(lp->mode==1) /* only needed for Busmaster */
|
1038 |
|
|
{
|
1039 |
|
|
int xmit_stop, recv_stop;
|
1040 |
|
|
|
1041 |
|
|
if((lp->chip==HP100_CHIPID_RAINIER)||(lp->chip==HP100_CHIPID_SHASTA))
|
1042 |
|
|
{
|
1043 |
|
|
int pdl_stop;
|
1044 |
|
|
|
1045 |
|
|
/*
|
1046 |
|
|
* Each pdl is 508 bytes long. (63 frags * 4 bytes for address and
|
1047 |
|
|
* 4 bytes for header). We will leave NUM_RXPDLS * 508 (rounded
|
1048 |
|
|
* to the next higher 1k boundary) bytes for the rx-pdl's
|
1049 |
|
|
* Note: For non-etr chips the transmit stop register must be
|
1050 |
|
|
* programmed on a 1k boundary, i.e. bits 9:0 must be zero.
|
1051 |
|
|
*/
|
1052 |
|
|
pdl_stop = lp->memory_size;
|
1053 |
|
|
xmit_stop = ( pdl_stop-508*(MAX_RX_PDL)-16 )& ~(0x03ff);
|
1054 |
|
|
recv_stop = ( xmit_stop * (lp->rx_ratio)/100 ) &~(0x03ff);
|
1055 |
|
|
hp100_outw( (pdl_stop>>4)-1, PDL_MEM_STOP );
|
1056 |
|
|
#ifdef HP100_DEBUG_BM
|
1057 |
|
|
printk("hp100: %s: PDL_STOP = 0x%x\n", dev->name, pdl_stop);
|
1058 |
|
|
#endif
|
1059 |
|
|
}
|
1060 |
|
|
else /* ETR chip (Lassen) in busmaster mode */
|
1061 |
|
|
{
|
1062 |
|
|
xmit_stop = ( lp->memory_size ) - 1;
|
1063 |
|
|
recv_stop = ( ( lp->memory_size * lp->rx_ratio ) / 100 ) & ~(0x03ff);
|
1064 |
|
|
}
|
1065 |
|
|
|
1066 |
|
|
hp100_outw( xmit_stop>>4 , TX_MEM_STOP );
|
1067 |
|
|
hp100_outw( recv_stop>>4 , RX_MEM_STOP );
|
1068 |
|
|
#ifdef HP100_DEBUG_BM
|
1069 |
|
|
printk("hp100: %s: TX_STOP = 0x%x\n",dev->name,xmit_stop>>4);
|
1070 |
|
|
printk("hp100: %s: RX_STOP = 0x%x\n",dev->name,recv_stop>>4);
|
1071 |
|
|
#endif
|
1072 |
|
|
}
|
1073 |
|
|
else /* Slave modes (memory mapped and programmed io) */
|
1074 |
|
|
{
|
1075 |
|
|
hp100_outw( (((lp->memory_size*lp->rx_ratio)/100)>>4), RX_MEM_STOP );
|
1076 |
|
|
hp100_outw( ((lp->memory_size - 1 )>>4), TX_MEM_STOP );
|
1077 |
|
|
#ifdef HP100_DEBUG
|
1078 |
|
|
printk("hp100: %s: TX_MEM_STOP: 0x%x\n", dev->name,hp100_inw(TX_MEM_STOP));
|
1079 |
|
|
printk("hp100: %s: RX_MEM_STOP: 0x%x\n", dev->name,hp100_inw(RX_MEM_STOP));
|
1080 |
|
|
#endif
|
1081 |
|
|
}
|
1082 |
|
|
|
1083 |
|
|
/* Write MAC address into page 1 */
|
1084 |
|
|
hp100_page( MAC_ADDRESS );
|
1085 |
|
|
for ( i = 0; i < 6; i++ )
|
1086 |
|
|
hp100_outb( dev->dev_addr[ i ], MAC_ADDR + i );
|
1087 |
|
|
|
1088 |
|
|
/* Zero the multicast hash registers */
|
1089 |
|
|
for ( i = 0; i < 8; i++ )
|
1090 |
|
|
hp100_outb( 0x0, HASH_BYTE0 + i );
|
1091 |
|
|
|
1092 |
|
|
/* Set up MAC defaults */
|
1093 |
|
|
hp100_page( MAC_CTRL );
|
1094 |
|
|
|
1095 |
|
|
/* Go to LAN Page and zero all filter bits */
|
1096 |
|
|
/* Zero accept error, accept multicast, accept broadcast and accept */
|
1097 |
|
|
/* all directed packet bits */
|
1098 |
|
|
hp100_andb( ~(HP100_RX_EN|
|
1099 |
|
|
HP100_TX_EN|
|
1100 |
|
|
HP100_ACC_ERRORED|
|
1101 |
|
|
HP100_ACC_MC|
|
1102 |
|
|
HP100_ACC_BC|
|
1103 |
|
|
HP100_ACC_PHY), MAC_CFG_1 );
|
1104 |
|
|
|
1105 |
|
|
hp100_outb( 0x00, MAC_CFG_2 );
|
1106 |
|
|
|
1107 |
|
|
/* Zero the frame format bit. This works around a training bug in the */
|
1108 |
|
|
/* new hubs. */
|
1109 |
|
|
hp100_outb( 0x00, VG_LAN_CFG_2); /* (use 802.3) */
|
1110 |
|
|
|
1111 |
|
|
if(lp->priority_tx)
|
1112 |
|
|
hp100_outb( HP100_PRIORITY_TX | HP100_SET_LB, OPTION_MSW );
|
1113 |
|
|
else
|
1114 |
|
|
hp100_outb( HP100_PRIORITY_TX | HP100_RESET_LB, OPTION_MSW );
|
1115 |
|
|
|
1116 |
|
|
hp100_outb( HP100_ADV_NXT_PKT |
|
1117 |
|
|
HP100_TX_CMD | HP100_RESET_LB, OPTION_MSW );
|
1118 |
|
|
|
1119 |
|
|
/* If busmaster, initialize the PDLs */
|
1120 |
|
|
if(lp->mode==1)
|
1121 |
|
|
hp100_init_pdls( dev );
|
1122 |
|
|
|
1123 |
|
|
/* Go to performance page and initalize isr and imr registers */
|
1124 |
|
|
hp100_page( PERFORMANCE );
|
1125 |
|
|
hp100_outw( 0xfefe, IRQ_MASK ); /* mask off all ints */
|
1126 |
|
|
hp100_outw( 0xffff, IRQ_STATUS ); /* ack IRQ */
|
1127 |
|
|
}
|
1128 |
|
|
|
1129 |
|
|
|
1130 |
|
|
/*
|
1131 |
|
|
* open/close functions
|
1132 |
|
|
*/
|
1133 |
|
|
|
1134 |
|
|
static int hp100_open( struct device *dev )
|
1135 |
|
|
{
|
1136 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1137 |
|
|
#ifdef HP100_DEBUG_B
|
1138 |
|
|
int ioaddr=dev->base_addr;
|
1139 |
|
|
#endif
|
1140 |
|
|
|
1141 |
|
|
#ifdef HP100_DEBUG_B
|
1142 |
|
|
hp100_outw( 0x4204, TRACE );
|
1143 |
|
|
printk("hp100: %s: open\n",dev->name);
|
1144 |
|
|
#endif
|
1145 |
|
|
|
1146 |
|
|
/* New: if bus is PCI or EISA, interrupts might be shared interrupts */
|
1147 |
|
|
if ( request_irq(dev->irq, hp100_interrupt,
|
1148 |
|
|
lp->bus==HP100_BUS_PCI||lp->bus==HP100_BUS_EISA?SA_SHIRQ:SA_INTERRUPT,
|
1149 |
|
|
lp->id->name, dev))
|
1150 |
|
|
{
|
1151 |
|
|
printk( "hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq );
|
1152 |
|
|
return -EAGAIN;
|
1153 |
|
|
}
|
1154 |
|
|
|
1155 |
|
|
MOD_INC_USE_COUNT;
|
1156 |
|
|
|
1157 |
|
|
dev->tbusy = 0;
|
1158 |
|
|
dev->trans_start = jiffies;
|
1159 |
|
|
dev->interrupt = 0;
|
1160 |
|
|
dev->start = 1;
|
1161 |
|
|
|
1162 |
|
|
lp->lan_type = hp100_sense_lan( dev );
|
1163 |
|
|
lp->mac1_mode = HP100_MAC1MODE3;
|
1164 |
|
|
lp->mac2_mode = HP100_MAC2MODE3;
|
1165 |
|
|
memset( &lp->hash_bytes, 0x00, 8 );
|
1166 |
|
|
|
1167 |
|
|
hp100_stop_interface( dev );
|
1168 |
|
|
|
1169 |
|
|
hp100_hwinit( dev );
|
1170 |
|
|
|
1171 |
|
|
hp100_start_interface( dev ); /* sets mac modes, enables interrupts */
|
1172 |
|
|
|
1173 |
|
|
return 0;
|
1174 |
|
|
}
|
1175 |
|
|
|
1176 |
|
|
|
1177 |
|
|
/* The close function is called when the interface is to be brought down */
|
1178 |
|
|
static int hp100_close( struct device *dev )
|
1179 |
|
|
{
|
1180 |
|
|
int ioaddr = dev->base_addr;
|
1181 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1182 |
|
|
|
1183 |
|
|
#ifdef HP100_DEBUG_B
|
1184 |
|
|
hp100_outw( 0x4205, TRACE );
|
1185 |
|
|
printk("hp100: %s: close\n", dev->name);
|
1186 |
|
|
#endif
|
1187 |
|
|
|
1188 |
|
|
hp100_page( PERFORMANCE );
|
1189 |
|
|
hp100_outw( 0xfefe, IRQ_MASK ); /* mask off all IRQs */
|
1190 |
|
|
|
1191 |
|
|
hp100_stop_interface( dev );
|
1192 |
|
|
|
1193 |
|
|
if ( lp->lan_type == HP100_LAN_100 )
|
1194 |
|
|
lp->hub_status=hp100_login_to_vg_hub( dev, FALSE );
|
1195 |
|
|
|
1196 |
|
|
dev->tbusy = 1;
|
1197 |
|
|
dev->start = 0;
|
1198 |
|
|
|
1199 |
|
|
free_irq( dev->irq, dev );
|
1200 |
|
|
|
1201 |
|
|
#ifdef HP100_DEBUG
|
1202 |
|
|
printk( "hp100: %s: close LSW = 0x%x\n", dev->name, hp100_inw(OPTION_LSW) );
|
1203 |
|
|
#endif
|
1204 |
|
|
|
1205 |
|
|
MOD_DEC_USE_COUNT;
|
1206 |
|
|
return 0;
|
1207 |
|
|
}
|
1208 |
|
|
|
1209 |
|
|
|
1210 |
|
|
/*
|
1211 |
|
|
* Configure the PDL Rx rings and LAN
|
1212 |
|
|
*/
|
1213 |
|
|
static void hp100_init_pdls( struct device *dev )
|
1214 |
|
|
{
|
1215 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1216 |
|
|
hp100_ring_t *ringptr;
|
1217 |
|
|
u_int *pageptr;
|
1218 |
|
|
int i;
|
1219 |
|
|
|
1220 |
|
|
#ifdef HP100_DEBUG_B
|
1221 |
|
|
int ioaddr = dev->base_addr;
|
1222 |
|
|
#endif
|
1223 |
|
|
|
1224 |
|
|
#ifdef HP100_DEBUG_B
|
1225 |
|
|
hp100_outw( 0x4206, TRACE );
|
1226 |
|
|
printk("hp100: %s: init pdls\n", dev->name);
|
1227 |
|
|
#endif
|
1228 |
|
|
|
1229 |
|
|
if(0==lp->page_vaddr_algn)
|
1230 |
|
|
printk("hp100: %s: Warning: lp->page_vaddr_algn not initialised!\n",dev->name);
|
1231 |
|
|
else
|
1232 |
|
|
{
|
1233 |
|
|
/* pageptr shall point into the DMA accessible memory region */
|
1234 |
|
|
/* we use this pointer to status the upper limit of allocated */
|
1235 |
|
|
/* memory in the allocated page. */
|
1236 |
|
|
/* note: align the pointers to the pci cache line size */
|
1237 |
|
|
memset(lp->page_vaddr_algn, 0, MAX_RINGSIZE); /* Zero Rx/Tx ring page */
|
1238 |
|
|
pageptr=lp->page_vaddr_algn;
|
1239 |
|
|
|
1240 |
|
|
lp->rxrcommit =0;
|
1241 |
|
|
ringptr = lp->rxrhead = lp-> rxrtail = &(lp->rxring[0]);
|
1242 |
|
|
|
1243 |
|
|
/* Initialise Rx Ring */
|
1244 |
|
|
for (i=MAX_RX_PDL-1; i>=0; i--)
|
1245 |
|
|
{
|
1246 |
|
|
lp->rxring[i].next = ringptr;
|
1247 |
|
|
ringptr=&(lp->rxring[i]);
|
1248 |
|
|
pageptr+=hp100_init_rxpdl(dev, ringptr, pageptr);
|
1249 |
|
|
}
|
1250 |
|
|
|
1251 |
|
|
/* Initialise Tx Ring */
|
1252 |
|
|
lp->txrcommit = 0;
|
1253 |
|
|
ringptr = lp->txrhead = lp->txrtail = &(lp->txring[0]);
|
1254 |
|
|
for (i=MAX_TX_PDL-1; i>=0; i--)
|
1255 |
|
|
{
|
1256 |
|
|
lp->txring[i].next = ringptr;
|
1257 |
|
|
ringptr=&(lp->txring[i]);
|
1258 |
|
|
pageptr+=hp100_init_txpdl(dev, ringptr, pageptr);
|
1259 |
|
|
}
|
1260 |
|
|
}
|
1261 |
|
|
}
|
1262 |
|
|
|
1263 |
|
|
|
1264 |
|
|
/* These functions "format" the entries in the pdl structure */
|
1265 |
|
|
/* They return how much memory the fragments need. */
|
1266 |
|
|
static int hp100_init_rxpdl( struct device *dev, register hp100_ring_t *ringptr, register u32 *pdlptr )
|
1267 |
|
|
{
|
1268 |
|
|
/* pdlptr is starting adress for this pdl */
|
1269 |
|
|
|
1270 |
|
|
if( 0!=( ((unsigned)pdlptr) & 0xf) )
|
1271 |
|
|
printk("hp100: %s: Init rxpdl: Unaligned pdlptr 0x%x.\n",dev->name,(unsigned)pdlptr);
|
1272 |
|
|
|
1273 |
|
|
ringptr->pdl = pdlptr+1;
|
1274 |
|
|
ringptr->pdl_paddr = virt_to_bus(pdlptr+1);
|
1275 |
|
|
ringptr->skb = (void *) NULL;
|
1276 |
|
|
|
1277 |
|
|
/*
|
1278 |
|
|
* Write address and length of first PDL Fragment (which is used for
|
1279 |
|
|
* storing the RX-Header
|
1280 |
|
|
* We use the 4 bytes _before_ the PDH in the pdl memory area to
|
1281 |
|
|
* store this information. (PDH is at offset 0x04)
|
1282 |
|
|
*/
|
1283 |
|
|
/* Note that pdlptr+1 and not pdlptr is the pointer to the PDH */
|
1284 |
|
|
|
1285 |
|
|
*(pdlptr+2) =(u_int) virt_to_bus(pdlptr); /* Address Frag 1 */
|
1286 |
|
|
*(pdlptr+3) = 4; /* Length Frag 1 */
|
1287 |
|
|
|
1288 |
|
|
return( ( ((MAX_RX_FRAG*2+2)+3) /4)*4 );
|
1289 |
|
|
}
|
1290 |
|
|
|
1291 |
|
|
|
1292 |
|
|
static int hp100_init_txpdl( struct device *dev, register hp100_ring_t *ringptr, register u32 *pdlptr )
|
1293 |
|
|
{
|
1294 |
|
|
if( 0!=( ((unsigned)pdlptr) & 0xf) )
|
1295 |
|
|
printk("hp100: %s: Init txpdl: Unaligned pdlptr 0x%x.\n",dev->name,(unsigned) pdlptr);
|
1296 |
|
|
|
1297 |
|
|
ringptr->pdl = pdlptr; /* +1; */
|
1298 |
|
|
ringptr->pdl_paddr = virt_to_bus(pdlptr); /* +1 */
|
1299 |
|
|
ringptr->skb = (void *) NULL;
|
1300 |
|
|
|
1301 |
|
|
return((((MAX_TX_FRAG*2+2)+3)/4)*4);
|
1302 |
|
|
}
|
1303 |
|
|
|
1304 |
|
|
|
1305 |
|
|
/*
|
1306 |
|
|
* hp100_build_rx_pdl allocates an skb_buff of maximum size plus two bytes
|
1307 |
|
|
* for possible odd word alignment rounding up to next dword and set PDL
|
1308 |
|
|
* address for fragment#2
|
1309 |
|
|
* Returns: 0 if unable to allocate skb_buff
|
1310 |
|
|
* 1 if successful
|
1311 |
|
|
*/
|
1312 |
|
|
int hp100_build_rx_pdl( hp100_ring_t *ringptr, struct device *dev )
|
1313 |
|
|
{
|
1314 |
|
|
#ifdef HP100_DEBUG_B
|
1315 |
|
|
int ioaddr = dev->base_addr;
|
1316 |
|
|
#endif
|
1317 |
|
|
#ifdef HP100_DEBUG_BM
|
1318 |
|
|
u_int *p;
|
1319 |
|
|
#endif
|
1320 |
|
|
|
1321 |
|
|
#ifdef HP100_DEBUG_B
|
1322 |
|
|
hp100_outw( 0x4207, TRACE );
|
1323 |
|
|
printk("hp100: %s: build rx pdl\n", dev->name);
|
1324 |
|
|
#endif
|
1325 |
|
|
|
1326 |
|
|
/* Allocate skb buffer of maximum size */
|
1327 |
|
|
/* Note: This depends on the alloc_skb functions allocating more
|
1328 |
|
|
* space than requested, i.e. aligning to 16bytes */
|
1329 |
|
|
|
1330 |
|
|
ringptr->skb = dev_alloc_skb( ((MAX_ETHER_SIZE+2+3)/4)*4 );
|
1331 |
|
|
|
1332 |
|
|
if(NULL!=ringptr->skb)
|
1333 |
|
|
{
|
1334 |
|
|
/*
|
1335 |
|
|
* Reserve 2 bytes at the head of the buffer to land the IP header
|
1336 |
|
|
* on a long word boundary (According to the Network Driver section
|
1337 |
|
|
* in the Linux KHG, this should help to increase performance.)
|
1338 |
|
|
*/
|
1339 |
|
|
skb_reserve(ringptr->skb, 2);
|
1340 |
|
|
|
1341 |
|
|
ringptr->skb->dev=dev;
|
1342 |
|
|
ringptr->skb->data=(u_char *)skb_put(ringptr->skb, MAX_ETHER_SIZE );
|
1343 |
|
|
|
1344 |
|
|
/* ringptr->pdl points to the beginning of the PDL, i.e. the PDH */
|
1345 |
|
|
/* Note: 1st Fragment is used for the 4 byte packet status
|
1346 |
|
|
* (receive header). Its PDL entries are set up by init_rxpdl. So
|
1347 |
|
|
* here we only have to set up the PDL fragment entries for the data
|
1348 |
|
|
* part. Those 4 bytes will be stored in the DMA memory region
|
1349 |
|
|
* directly before the PDL.
|
1350 |
|
|
*/
|
1351 |
|
|
#ifdef HP100_DEBUG_BM
|
1352 |
|
|
printk("hp100: %s: build_rx_pdl: PDH@0x%x, skb->data (len %d) at 0x%x\n",
|
1353 |
|
|
dev->name,
|
1354 |
|
|
(u_int) ringptr->pdl,
|
1355 |
|
|
((MAX_ETHER_SIZE+2+3)/4)*4,
|
1356 |
|
|
(unsigned int) ringptr->skb->data);
|
1357 |
|
|
#endif
|
1358 |
|
|
|
1359 |
|
|
ringptr->pdl[0] = 0x00020000; /* Write PDH */
|
1360 |
|
|
ringptr->pdl[3] = ((u_int)virt_to_bus(ringptr->skb->data));
|
1361 |
|
|
ringptr->pdl[4] = MAX_ETHER_SIZE; /* Length of Data */
|
1362 |
|
|
|
1363 |
|
|
#ifdef HP100_DEBUG_BM
|
1364 |
|
|
for(p=(ringptr->pdl); p<(ringptr->pdl+5); p++)
|
1365 |
|
|
printk("hp100: %s: Adr 0x%.8x = 0x%.8x\n",dev->name,(u_int) p,(u_int) *p );
|
1366 |
|
|
#endif
|
1367 |
|
|
return(1);
|
1368 |
|
|
}
|
1369 |
|
|
/* else: */
|
1370 |
|
|
/* alloc_skb failed (no memory) -> still can receive the header
|
1371 |
|
|
* fragment into PDL memory. make PDL safe by clearing msgptr and
|
1372 |
|
|
* making the PDL only 1 fragment (i.e. the 4 byte packet status)
|
1373 |
|
|
*/
|
1374 |
|
|
#ifdef HP100_DEBUG_BM
|
1375 |
|
|
printk("hp100: %s: build_rx_pdl: PDH@0x%x, No space for skb.\n",
|
1376 |
|
|
dev->name,
|
1377 |
|
|
(u_int) ringptr->pdl);
|
1378 |
|
|
#endif
|
1379 |
|
|
|
1380 |
|
|
ringptr->pdl[0]=0x00010000; /* PDH: Count=1 Fragment */
|
1381 |
|
|
|
1382 |
|
|
return(0);
|
1383 |
|
|
}
|
1384 |
|
|
|
1385 |
|
|
|
1386 |
|
|
/*
|
1387 |
|
|
* hp100_rxfill - attempt to fill the Rx Ring will empty skb's
|
1388 |
|
|
*
|
1389 |
|
|
* Makes assumption that skb's are always contiguous memory areas and
|
1390 |
|
|
* therefore PDLs contain only 2 physical fragments.
|
1391 |
|
|
* - While the number of Rx PDLs with buffers is less than maximum
|
1392 |
|
|
* a. Get a maximum packet size skb
|
1393 |
|
|
* b. Put the physical address of the buffer into the PDL.
|
1394 |
|
|
* c. Output physical address of PDL to adapter.
|
1395 |
|
|
*/
|
1396 |
|
|
static void hp100_rxfill( struct device *dev )
|
1397 |
|
|
{
|
1398 |
|
|
int ioaddr=dev->base_addr;
|
1399 |
|
|
|
1400 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1401 |
|
|
hp100_ring_t *ringptr;
|
1402 |
|
|
|
1403 |
|
|
#ifdef HP100_DEBUG_B
|
1404 |
|
|
hp100_outw( 0x4208, TRACE );
|
1405 |
|
|
printk("hp100: %s: rxfill\n",dev->name);
|
1406 |
|
|
#endif
|
1407 |
|
|
|
1408 |
|
|
hp100_page( PERFORMANCE );
|
1409 |
|
|
|
1410 |
|
|
while (lp->rxrcommit < MAX_RX_PDL)
|
1411 |
|
|
{
|
1412 |
|
|
/*
|
1413 |
|
|
** Attempt to get a buffer and build a Rx PDL.
|
1414 |
|
|
*/
|
1415 |
|
|
ringptr = lp->rxrtail;
|
1416 |
|
|
if (0 == hp100_build_rx_pdl( ringptr, dev ))
|
1417 |
|
|
{
|
1418 |
|
|
return; /* None available, return */
|
1419 |
|
|
}
|
1420 |
|
|
|
1421 |
|
|
/* Hand this PDL over to the card */
|
1422 |
|
|
/* Note: This needs performance page selected! */
|
1423 |
|
|
#ifdef HP100_DEBUG_BM
|
1424 |
|
|
printk("hp100: %s: rxfill: Hand to card: pdl #%d @0x%x phys:0x%x, buffer: 0x%x\n",
|
1425 |
|
|
dev->name,
|
1426 |
|
|
lp->rxrcommit,
|
1427 |
|
|
(u_int)ringptr->pdl,
|
1428 |
|
|
(u_int)ringptr->pdl_paddr,
|
1429 |
|
|
(u_int)ringptr->pdl[3]);
|
1430 |
|
|
#endif
|
1431 |
|
|
|
1432 |
|
|
hp100_outl( (u32)ringptr->pdl_paddr, RX_PDA);
|
1433 |
|
|
|
1434 |
|
|
lp->rxrcommit += 1;
|
1435 |
|
|
lp->rxrtail = ringptr->next;
|
1436 |
|
|
}
|
1437 |
|
|
}
|
1438 |
|
|
|
1439 |
|
|
|
1440 |
|
|
/*
|
1441 |
|
|
* BM_shutdown - shutdown bus mastering and leave chip in reset state
|
1442 |
|
|
*/
|
1443 |
|
|
|
1444 |
|
|
static void hp100_BM_shutdown( struct device *dev )
|
1445 |
|
|
{
|
1446 |
|
|
int ioaddr = dev->base_addr;
|
1447 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1448 |
|
|
unsigned long time;
|
1449 |
|
|
|
1450 |
|
|
#ifdef HP100_DEBUG_B
|
1451 |
|
|
hp100_outw( 0x4209, TRACE );
|
1452 |
|
|
printk("hp100: %s: bm shutdown\n",dev->name);
|
1453 |
|
|
#endif
|
1454 |
|
|
|
1455 |
|
|
hp100_page( PERFORMANCE );
|
1456 |
|
|
hp100_outw( 0xfefe, IRQ_MASK ); /* mask off all ints */
|
1457 |
|
|
hp100_outw( 0xffff, IRQ_STATUS ); /* Ack all ints */
|
1458 |
|
|
|
1459 |
|
|
/* Ensure Interrupts are off */
|
1460 |
|
|
hp100_outw( HP100_INT_EN | HP100_RESET_LB , OPTION_LSW );
|
1461 |
|
|
|
1462 |
|
|
/* Disable all MAC activity */
|
1463 |
|
|
hp100_page( MAC_CTRL );
|
1464 |
|
|
hp100_andb( ~(HP100_RX_EN | HP100_TX_EN), MAC_CFG_1 ); /* stop rx/tx */
|
1465 |
|
|
|
1466 |
|
|
/* If cascade MMU is not already in reset */
|
1467 |
|
|
if (0 != (hp100_inw(OPTION_LSW)&HP100_HW_RST) )
|
1468 |
|
|
{
|
1469 |
|
|
/* Wait 1.3ms (10Mb max packet time) to ensure MAC is idle so
|
1470 |
|
|
* MMU pointers will not be reset out from underneath
|
1471 |
|
|
*/
|
1472 |
|
|
hp100_page( MAC_CTRL );
|
1473 |
|
|
for(time=0; time<5000; time++)
|
1474 |
|
|
{
|
1475 |
|
|
if( (hp100_inb(MAC_CFG_1)&(HP100_TX_IDLE|HP100_RX_IDLE))==
|
1476 |
|
|
(HP100_TX_IDLE|HP100_RX_IDLE) ) break;
|
1477 |
|
|
}
|
1478 |
|
|
|
1479 |
|
|
/* Shutdown algorithm depends on the generation of Cascade */
|
1480 |
|
|
if( lp->chip==HP100_CHIPID_LASSEN )
|
1481 |
|
|
{ /* ETR shutdown/reset */
|
1482 |
|
|
/* Disable Busmaster mode and wait for bit to go to zero. */
|
1483 |
|
|
hp100_page(HW_MAP);
|
1484 |
|
|
hp100_andb( ~HP100_BM_MASTER, BM );
|
1485 |
|
|
/* 100 ms timeout */
|
1486 |
|
|
for(time=0; time<32000; time++)
|
1487 |
|
|
{
|
1488 |
|
|
if ( 0 == (hp100_inb( BM ) & HP100_BM_MASTER) ) break;
|
1489 |
|
|
}
|
1490 |
|
|
}
|
1491 |
|
|
else
|
1492 |
|
|
{ /* Shasta or Rainier Shutdown/Reset */
|
1493 |
|
|
/* To ensure all bus master inloading activity has ceased,
|
1494 |
|
|
* wait for no Rx PDAs or no Rx packets on card.
|
1495 |
|
|
*/
|
1496 |
|
|
hp100_page( PERFORMANCE );
|
1497 |
|
|
/* 100 ms timeout */
|
1498 |
|
|
for(time=0; time<10000; time++)
|
1499 |
|
|
{
|
1500 |
|
|
/* RX_PDL: PDLs not executed. */
|
1501 |
|
|
/* RX_PKT_CNT: RX'd packets on card. */
|
1502 |
|
|
if ( (hp100_inb( RX_PDL ) == 0) &&
|
1503 |
|
|
(hp100_inb( RX_PKT_CNT ) == 0) ) break;
|
1504 |
|
|
}
|
1505 |
|
|
|
1506 |
|
|
if(time>=10000)
|
1507 |
|
|
printk("hp100: %s: BM shutdown error.\n", dev->name);
|
1508 |
|
|
|
1509 |
|
|
/* To ensure all bus master outloading activity has ceased,
|
1510 |
|
|
* wait until the Tx PDA count goes to zero or no more Tx space
|
1511 |
|
|
* available in the Tx region of the card.
|
1512 |
|
|
*/
|
1513 |
|
|
/* 100 ms timeout */
|
1514 |
|
|
for(time=0; time<10000; time++) {
|
1515 |
|
|
if ( (0 == hp100_inb( TX_PKT_CNT )) &&
|
1516 |
|
|
(0 != (hp100_inb( TX_MEM_FREE )&HP100_AUTO_COMPARE))) break;
|
1517 |
|
|
}
|
1518 |
|
|
|
1519 |
|
|
/* Disable Busmaster mode */
|
1520 |
|
|
hp100_page(HW_MAP);
|
1521 |
|
|
hp100_andb( ~HP100_BM_MASTER, BM );
|
1522 |
|
|
} /* end of shutdown procedure for non-etr parts */
|
1523 |
|
|
|
1524 |
|
|
hp100_cascade_reset( dev, TRUE );
|
1525 |
|
|
}
|
1526 |
|
|
hp100_page( PERFORMANCE );
|
1527 |
|
|
/* hp100_outw( HP100_BM_READ | HP100_BM_WRITE | HP100_RESET_HB, OPTION_LSW ); */
|
1528 |
|
|
/* Busmaster mode should be shut down now. */
|
1529 |
|
|
}
|
1530 |
|
|
|
1531 |
|
|
|
1532 |
|
|
|
1533 |
|
|
/*
|
1534 |
|
|
* transmit functions
|
1535 |
|
|
*/
|
1536 |
|
|
|
1537 |
|
|
/* tx function for busmaster mode */
|
1538 |
|
|
static int hp100_start_xmit_bm( struct sk_buff *skb, struct device *dev )
|
1539 |
|
|
{
|
1540 |
|
|
unsigned long flags;
|
1541 |
|
|
int i, ok_flag;
|
1542 |
|
|
int ioaddr = dev->base_addr;
|
1543 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1544 |
|
|
hp100_ring_t *ringptr;
|
1545 |
|
|
|
1546 |
|
|
#ifdef HP100_DEBUG_B
|
1547 |
|
|
hp100_outw( 0x4210, TRACE );
|
1548 |
|
|
printk("hp100: %s: start_xmit_bm\n",dev->name);
|
1549 |
|
|
#endif
|
1550 |
|
|
|
1551 |
|
|
if ( skb==NULL )
|
1552 |
|
|
{
|
1553 |
|
|
#ifndef LINUX_2_1
|
1554 |
|
|
dev_tint( dev );
|
1555 |
|
|
#endif
|
1556 |
|
|
return 0;
|
1557 |
|
|
}
|
1558 |
|
|
|
1559 |
|
|
if ( skb->len <= 0 ) return 0;
|
1560 |
|
|
|
1561 |
|
|
/* Get Tx ring tail pointer */
|
1562 |
|
|
if( lp->txrtail->next==lp->txrhead )
|
1563 |
|
|
{
|
1564 |
|
|
/* No memory. */
|
1565 |
|
|
#ifdef HP100_DEBUG
|
1566 |
|
|
printk("hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name);
|
1567 |
|
|
#endif
|
1568 |
|
|
/* not waited long enough since last tx? */
|
1569 |
|
|
if ( jiffies - dev->trans_start < HZ ) return -EAGAIN;
|
1570 |
|
|
|
1571 |
|
|
if ( lp->lan_type < 0 ) /* no LAN type detected yet? */
|
1572 |
|
|
{
|
1573 |
|
|
hp100_stop_interface( dev );
|
1574 |
|
|
if ( ( lp->lan_type = hp100_sense_lan( dev ) ) < 0 )
|
1575 |
|
|
{
|
1576 |
|
|
printk( "hp100: %s: no connection found - check wire\n", dev->name );
|
1577 |
|
|
hp100_start_interface( dev ); /* 10Mb/s RX pkts maybe handled */
|
1578 |
|
|
return -EIO;
|
1579 |
|
|
}
|
1580 |
|
|
if ( lp->lan_type == HP100_LAN_100 )
|
1581 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE ); /* relogin */
|
1582 |
|
|
hp100_start_interface( dev );
|
1583 |
|
|
}
|
1584 |
|
|
|
1585 |
|
|
if ( lp->lan_type == HP100_LAN_100 && lp->hub_status < 0 )
|
1586 |
|
|
/* we have a 100Mb/s adapter but it isn't connected to hub */
|
1587 |
|
|
{
|
1588 |
|
|
printk( "hp100: %s: login to 100Mb/s hub retry\n", dev->name );
|
1589 |
|
|
hp100_stop_interface( dev );
|
1590 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE );
|
1591 |
|
|
hp100_start_interface( dev );
|
1592 |
|
|
}
|
1593 |
|
|
else
|
1594 |
|
|
{
|
1595 |
|
|
hp100_ints_off();
|
1596 |
|
|
i = hp100_sense_lan( dev );
|
1597 |
|
|
hp100_ints_on();
|
1598 |
|
|
if ( i == HP100_LAN_ERR )
|
1599 |
|
|
printk( "hp100: %s: link down detected\n", dev->name );
|
1600 |
|
|
else
|
1601 |
|
|
if ( lp->lan_type != i ) /* cable change! */
|
1602 |
|
|
{
|
1603 |
|
|
/* it's very hard - all network setting must be changed!!! */
|
1604 |
|
|
printk( "hp100: %s: cable change 10Mb/s <-> 100Mb/s detected\n", dev->name );
|
1605 |
|
|
lp->lan_type = i;
|
1606 |
|
|
hp100_stop_interface( dev );
|
1607 |
|
|
if ( lp->lan_type == HP100_LAN_100 )
|
1608 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE );
|
1609 |
|
|
hp100_start_interface( dev );
|
1610 |
|
|
}
|
1611 |
|
|
else
|
1612 |
|
|
{
|
1613 |
|
|
printk( "hp100: %s: interface reset\n", dev->name );
|
1614 |
|
|
hp100_stop_interface( dev );
|
1615 |
|
|
if ( lp->lan_type == HP100_LAN_100 )
|
1616 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE );
|
1617 |
|
|
hp100_start_interface( dev );
|
1618 |
|
|
}
|
1619 |
|
|
}
|
1620 |
|
|
|
1621 |
|
|
dev->trans_start = jiffies;
|
1622 |
|
|
return -EAGAIN;
|
1623 |
|
|
}
|
1624 |
|
|
|
1625 |
|
|
/*
|
1626 |
|
|
* we have to turn int's off before modifying this, otherwise
|
1627 |
|
|
* a tx_pdl_cleanup could occur at the same time
|
1628 |
|
|
*/
|
1629 |
|
|
save_flags( flags );
|
1630 |
|
|
cli();
|
1631 |
|
|
ringptr=lp->txrtail;
|
1632 |
|
|
lp->txrtail=ringptr->next;
|
1633 |
|
|
|
1634 |
|
|
/* Check whether packet has minimal packet size */
|
1635 |
|
|
ok_flag = skb->len >= HP100_MIN_PACKET_SIZE;
|
1636 |
|
|
i = ok_flag ? skb->len : HP100_MIN_PACKET_SIZE;
|
1637 |
|
|
|
1638 |
|
|
ringptr->skb=skb;
|
1639 |
|
|
ringptr->pdl[0]=((1<<16) | i); /* PDH: 1 Fragment & length */
|
1640 |
|
|
ringptr->pdl[1]=(u32)virt_to_bus(skb->data); /* 1st Frag: Adr. of data */
|
1641 |
|
|
if(lp->chip==HP100_CHIPID_SHASTA)
|
1642 |
|
|
{
|
1643 |
|
|
/* TODO:Could someone who has the EISA card please check if this works? */
|
1644 |
|
|
ringptr->pdl[2]=i;
|
1645 |
|
|
}
|
1646 |
|
|
else /* Lassen */
|
1647 |
|
|
{
|
1648 |
|
|
/* In the PDL, don't use the padded size but the real packet size: */
|
1649 |
|
|
ringptr->pdl[2]=skb->len; /* 1st Frag: Length of frag */
|
1650 |
|
|
}
|
1651 |
|
|
|
1652 |
|
|
/* Hand this PDL to the card. */
|
1653 |
|
|
hp100_outl( ringptr->pdl_paddr, TX_PDA_L ); /* Low Prio. Queue */
|
1654 |
|
|
|
1655 |
|
|
lp->txrcommit++;
|
1656 |
|
|
restore_flags( flags );
|
1657 |
|
|
|
1658 |
|
|
/* Update statistics */
|
1659 |
|
|
lp->stats.tx_packets++;
|
1660 |
|
|
#ifdef LINUX_2_1
|
1661 |
|
|
lp->stats.tx_bytes += skb->len;
|
1662 |
|
|
#endif
|
1663 |
|
|
dev->trans_start = jiffies;
|
1664 |
|
|
|
1665 |
|
|
return 0;
|
1666 |
|
|
}
|
1667 |
|
|
|
1668 |
|
|
|
1669 |
|
|
/* clean_txring checks if packets have been sent by the card by reading
|
1670 |
|
|
* the TX_PDL register from the performance page and comparing it to the
|
1671 |
|
|
* number of commited packets. It then frees the skb's of the packets that
|
1672 |
|
|
* obviously have been sent to the network.
|
1673 |
|
|
*
|
1674 |
|
|
* Needs the PERFORMANCE page selected.
|
1675 |
|
|
*/
|
1676 |
|
|
static void hp100_clean_txring( struct device *dev )
|
1677 |
|
|
{
|
1678 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1679 |
|
|
int ioaddr = dev->base_addr;
|
1680 |
|
|
int donecount;
|
1681 |
|
|
|
1682 |
|
|
#ifdef HP100_DEBUG_B
|
1683 |
|
|
hp100_outw( 0x4211, TRACE );
|
1684 |
|
|
printk("hp100: %s: clean txring\n", dev->name);
|
1685 |
|
|
#endif
|
1686 |
|
|
|
1687 |
|
|
/* How many PDLs have been transmitted? */
|
1688 |
|
|
donecount=(lp->txrcommit)-hp100_inb(TX_PDL);
|
1689 |
|
|
|
1690 |
|
|
#ifdef HP100_DEBUG
|
1691 |
|
|
if(donecount>MAX_TX_PDL)
|
1692 |
|
|
printk("hp100: %s: Warning: More PDLs transmitted than commited to card???\n",dev->name);
|
1693 |
|
|
#endif
|
1694 |
|
|
|
1695 |
|
|
for( ; 0!=donecount; donecount-- )
|
1696 |
|
|
{
|
1697 |
|
|
#ifdef HP100_DEBUG_BM
|
1698 |
|
|
printk("hp100: %s: Free skb: data @0x%.8x txrcommit=0x%x TXPDL=0x%x, done=0x%x\n",
|
1699 |
|
|
dev->name,
|
1700 |
|
|
(u_int) lp->txrhead->skb->data,
|
1701 |
|
|
lp->txrcommit,
|
1702 |
|
|
hp100_inb(TX_PDL),
|
1703 |
|
|
donecount);
|
1704 |
|
|
#endif
|
1705 |
|
|
#ifdef LINUX_2_1
|
1706 |
|
|
dev_kfree_skb( lp->txrhead->skb );
|
1707 |
|
|
#else
|
1708 |
|
|
dev_kfree_skb( lp->txrhead->skb, FREE_WRITE );
|
1709 |
|
|
#endif
|
1710 |
|
|
lp->txrhead->skb=(void *)NULL;
|
1711 |
|
|
lp->txrhead=lp->txrhead->next;
|
1712 |
|
|
lp->txrcommit--;
|
1713 |
|
|
}
|
1714 |
|
|
}
|
1715 |
|
|
|
1716 |
|
|
|
1717 |
|
|
/* tx function for slave modes */
|
1718 |
|
|
static int hp100_start_xmit( struct sk_buff *skb, struct device *dev )
|
1719 |
|
|
{
|
1720 |
|
|
int i, ok_flag;
|
1721 |
|
|
int ioaddr = dev->base_addr;
|
1722 |
|
|
u_short val;
|
1723 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1724 |
|
|
|
1725 |
|
|
#ifdef HP100_DEBUG_B
|
1726 |
|
|
hp100_outw( 0x4212, TRACE );
|
1727 |
|
|
printk("hp100: %s: start_xmit\n", dev->name);
|
1728 |
|
|
#endif
|
1729 |
|
|
|
1730 |
|
|
if ( skb==NULL )
|
1731 |
|
|
{
|
1732 |
|
|
#ifndef LINUX_2_1
|
1733 |
|
|
dev_tint( dev );
|
1734 |
|
|
#endif
|
1735 |
|
|
return 0;
|
1736 |
|
|
}
|
1737 |
|
|
|
1738 |
|
|
if ( skb->len <= 0 ) return 0;
|
1739 |
|
|
|
1740 |
|
|
if ( lp->lan_type < 0 ) /* no LAN type detected yet? */
|
1741 |
|
|
{
|
1742 |
|
|
hp100_stop_interface( dev );
|
1743 |
|
|
if ( ( lp->lan_type = hp100_sense_lan( dev ) ) < 0 )
|
1744 |
|
|
{
|
1745 |
|
|
printk( "hp100: %s: no connection found - check wire\n", dev->name );
|
1746 |
|
|
hp100_start_interface( dev ); /* 10Mb/s RX packets maybe handled */
|
1747 |
|
|
return -EIO;
|
1748 |
|
|
}
|
1749 |
|
|
if ( lp->lan_type == HP100_LAN_100 )
|
1750 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE ); /* relogin */
|
1751 |
|
|
hp100_start_interface( dev );
|
1752 |
|
|
}
|
1753 |
|
|
|
1754 |
|
|
/* If there is not enough free memory on the card... */
|
1755 |
|
|
i=hp100_inl(TX_MEM_FREE)&0x7fffffff;
|
1756 |
|
|
if ( !(((i/2)-539)>(skb->len+16) && (hp100_inb(TX_PKT_CNT)<255)) )
|
1757 |
|
|
{
|
1758 |
|
|
#ifdef HP100_DEBUG
|
1759 |
|
|
printk( "hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i );
|
1760 |
|
|
#endif
|
1761 |
|
|
/* not waited long enough since last failed tx try? */
|
1762 |
|
|
if ( jiffies - dev->trans_start < HZ )
|
1763 |
|
|
{
|
1764 |
|
|
#ifdef HP100_DEBUG
|
1765 |
|
|
printk("hp100: %s: trans_start timing problem\n", dev->name);
|
1766 |
|
|
#endif
|
1767 |
|
|
return -EAGAIN;
|
1768 |
|
|
}
|
1769 |
|
|
if ( lp->lan_type == HP100_LAN_100 && lp->hub_status < 0 )
|
1770 |
|
|
/* we have a 100Mb/s adapter but it isn't connected to hub */
|
1771 |
|
|
{
|
1772 |
|
|
printk( "hp100: %s: login to 100Mb/s hub retry\n", dev->name );
|
1773 |
|
|
hp100_stop_interface( dev );
|
1774 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE );
|
1775 |
|
|
hp100_start_interface( dev );
|
1776 |
|
|
}
|
1777 |
|
|
else
|
1778 |
|
|
{
|
1779 |
|
|
hp100_ints_off();
|
1780 |
|
|
i = hp100_sense_lan( dev );
|
1781 |
|
|
hp100_ints_on();
|
1782 |
|
|
if ( i == HP100_LAN_ERR )
|
1783 |
|
|
printk( "hp100: %s: link down detected\n", dev->name );
|
1784 |
|
|
else
|
1785 |
|
|
if ( lp->lan_type != i ) /* cable change! */
|
1786 |
|
|
{
|
1787 |
|
|
/* it's very hard - all network setting must be changed!!! */
|
1788 |
|
|
printk( "hp100: %s: cable change 10Mb/s <-> 100Mb/s detected\n", dev->name );
|
1789 |
|
|
lp->lan_type = i;
|
1790 |
|
|
hp100_stop_interface( dev );
|
1791 |
|
|
if ( lp->lan_type == HP100_LAN_100 )
|
1792 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE );
|
1793 |
|
|
hp100_start_interface( dev );
|
1794 |
|
|
}
|
1795 |
|
|
else
|
1796 |
|
|
{
|
1797 |
|
|
printk( "hp100: %s: interface reset\n", dev->name );
|
1798 |
|
|
hp100_stop_interface( dev );
|
1799 |
|
|
if ( lp->lan_type == HP100_LAN_100 )
|
1800 |
|
|
lp->hub_status = hp100_login_to_vg_hub( dev, FALSE );
|
1801 |
|
|
hp100_start_interface( dev );
|
1802 |
|
|
udelay(1000);
|
1803 |
|
|
}
|
1804 |
|
|
}
|
1805 |
|
|
dev->trans_start = jiffies;
|
1806 |
|
|
return -EAGAIN;
|
1807 |
|
|
}
|
1808 |
|
|
|
1809 |
|
|
for ( i=0; i<6000 && ( hp100_inb( OPTION_MSW ) & HP100_TX_CMD ); i++ )
|
1810 |
|
|
{
|
1811 |
|
|
#ifdef HP100_DEBUG_TX
|
1812 |
|
|
printk( "hp100: %s: start_xmit: busy\n", dev->name );
|
1813 |
|
|
#endif
|
1814 |
|
|
}
|
1815 |
|
|
|
1816 |
|
|
hp100_ints_off();
|
1817 |
|
|
val = hp100_inw( IRQ_STATUS );
|
1818 |
|
|
/* Ack / clear the interrupt TX_COMPLETE interrupt - this interrupt is set
|
1819 |
|
|
* when the current packet being transmitted on the wire is completed. */
|
1820 |
|
|
hp100_outw( HP100_TX_COMPLETE, IRQ_STATUS );
|
1821 |
|
|
#ifdef HP100_DEBUG_TX
|
1822 |
|
|
printk("hp100: %s: start_xmit: irq_status=0x%.4x, irqmask=0x%.4x, len=%d\n",dev->name,val,hp100_inw(IRQ_MASK),(int)skb->len );
|
1823 |
|
|
#endif
|
1824 |
|
|
|
1825 |
|
|
ok_flag = skb->len >= HP100_MIN_PACKET_SIZE;
|
1826 |
|
|
i = ok_flag ? skb->len : HP100_MIN_PACKET_SIZE;
|
1827 |
|
|
|
1828 |
|
|
hp100_outw( i, DATA32 ); /* tell card the total packet length */
|
1829 |
|
|
hp100_outw( i, FRAGMENT_LEN ); /* and first/only fragment length */
|
1830 |
|
|
|
1831 |
|
|
if ( lp->mode==2 ) /* memory mapped */
|
1832 |
|
|
{
|
1833 |
|
|
if ( lp->mem_ptr_virt ) /* high pci memory was remapped */
|
1834 |
|
|
{
|
1835 |
|
|
/* Note: The J2585B needs alignment to 32bits here! */
|
1836 |
|
|
memcpy( lp->mem_ptr_virt, skb->data, ( skb->len + 3 ) & ~3 );
|
1837 |
|
|
if ( !ok_flag )
|
1838 |
|
|
memset( lp->mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb->len );
|
1839 |
|
|
}
|
1840 |
|
|
else
|
1841 |
|
|
{
|
1842 |
|
|
/* Note: The J2585B needs alignment to 32bits here! */
|
1843 |
|
|
memcpy_toio( lp->mem_ptr_phys, skb->data, (skb->len + 3) & ~3 );
|
1844 |
|
|
if ( !ok_flag )
|
1845 |
|
|
memset_io( lp->mem_ptr_phys, 0, HP100_MIN_PACKET_SIZE - skb->len );
|
1846 |
|
|
}
|
1847 |
|
|
}
|
1848 |
|
|
else /* programmed i/o */
|
1849 |
|
|
{
|
1850 |
|
|
outsl( ioaddr + HP100_REG_DATA32, skb->data, ( skb->len + 3 ) >> 2 );
|
1851 |
|
|
if ( !ok_flag )
|
1852 |
|
|
for ( i = ( skb->len + 3 ) & ~3; i < HP100_MIN_PACKET_SIZE; i += 4 )
|
1853 |
|
|
hp100_outl( 0, DATA32 );
|
1854 |
|
|
}
|
1855 |
|
|
|
1856 |
|
|
hp100_outb( HP100_TX_CMD | HP100_SET_LB, OPTION_MSW ); /* send packet */
|
1857 |
|
|
|
1858 |
|
|
lp->stats.tx_packets++;
|
1859 |
|
|
#ifdef LINUX_2_1
|
1860 |
|
|
lp->stats.tx_bytes += skb->len;
|
1861 |
|
|
#endif
|
1862 |
|
|
dev->trans_start=jiffies;
|
1863 |
|
|
hp100_ints_on();
|
1864 |
|
|
|
1865 |
|
|
#ifdef LINUX_2_1
|
1866 |
|
|
dev_kfree_skb( skb );
|
1867 |
|
|
#else
|
1868 |
|
|
dev_kfree_skb( skb, FREE_WRITE );
|
1869 |
|
|
#endif
|
1870 |
|
|
|
1871 |
|
|
#ifdef HP100_DEBUG_TX
|
1872 |
|
|
printk( "hp100: %s: start_xmit: end\n", dev->name );
|
1873 |
|
|
#endif
|
1874 |
|
|
|
1875 |
|
|
return 0;
|
1876 |
|
|
}
|
1877 |
|
|
|
1878 |
|
|
|
1879 |
|
|
/*
|
1880 |
|
|
* Receive Function (Non-Busmaster mode)
|
1881 |
|
|
* Called when an "Receive Packet" interrupt occurs, i.e. the receive
|
1882 |
|
|
* packet counter is non-zero.
|
1883 |
|
|
* For non-busmaster, this function does the whole work of transfering
|
1884 |
|
|
* the packet to the host memory and then up to higher layers via skb
|
1885 |
|
|
* and netif_rx.
|
1886 |
|
|
*/
|
1887 |
|
|
|
1888 |
|
|
static void hp100_rx( struct device *dev )
|
1889 |
|
|
{
|
1890 |
|
|
int packets, pkt_len;
|
1891 |
|
|
int ioaddr = dev->base_addr;
|
1892 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
1893 |
|
|
u_int header;
|
1894 |
|
|
struct sk_buff *skb;
|
1895 |
|
|
|
1896 |
|
|
#ifdef DEBUG_B
|
1897 |
|
|
hp100_outw( 0x4213, TRACE );
|
1898 |
|
|
printk("hp100: %s: rx\n", dev->name);
|
1899 |
|
|
#endif
|
1900 |
|
|
|
1901 |
|
|
/* First get indication of received lan packet */
|
1902 |
|
|
/* RX_PKT_CND indicates the number of packets which have been fully */
|
1903 |
|
|
/* received onto the card but have not been fully transfered of the card */
|
1904 |
|
|
packets = hp100_inb( RX_PKT_CNT );
|
1905 |
|
|
#ifdef HP100_DEBUG_RX
|
1906 |
|
|
if ( packets > 1 )
|
1907 |
|
|
printk( "hp100: %s: rx: waiting packets = %d\n", dev->name,packets );
|
1908 |
|
|
#endif
|
1909 |
|
|
|
1910 |
|
|
while ( packets-- > 0 )
|
1911 |
|
|
{
|
1912 |
|
|
/* If ADV_NXT_PKT is still set, we have to wait until the card has */
|
1913 |
|
|
/* really advanced to the next packet. */
|
1914 |
|
|
for (pkt_len=0; pkt_len<6000 &&(hp100_inb(OPTION_MSW)&HP100_ADV_NXT_PKT);
|
1915 |
|
|
pkt_len++ )
|
1916 |
|
|
{
|
1917 |
|
|
#ifdef HP100_DEBUG_RX
|
1918 |
|
|
printk( "hp100: %s: rx: busy, remaining packets = %d\n", dev->name, packets );
|
1919 |
|
|
#endif
|
1920 |
|
|
}
|
1921 |
|
|
|
1922 |
|
|
/* First we get the header, which contains information about the */
|
1923 |
|
|
/* actual length of the received packet. */
|
1924 |
|
|
if( lp->mode==2 ) /* memory mapped mode */
|
1925 |
|
|
{
|
1926 |
|
|
if ( lp->mem_ptr_virt ) /* if memory was remapped */
|
1927 |
|
|
header = *(__u32 *)lp->mem_ptr_virt;
|
1928 |
|
|
else
|
1929 |
|
|
header = readl( lp->mem_ptr_phys );
|
1930 |
|
|
}
|
1931 |
|
|
else /* programmed i/o */
|
1932 |
|
|
header = hp100_inl( DATA32 );
|
1933 |
|
|
|
1934 |
|
|
pkt_len = ((header & HP100_PKT_LEN_MASK) + 3) & ~3;
|
1935 |
|
|
|
1936 |
|
|
#ifdef HP100_DEBUG_RX
|
1937 |
|
|
printk( "hp100: %s: rx: new packet - length=%d, errors=0x%x, dest=0x%x\n",
|
1938 |
|
|
dev->name,
|
1939 |
|
|
header & HP100_PKT_LEN_MASK, (header>>16)&0xfff8,
|
1940 |
|
|
(header>>16)&7);
|
1941 |
|
|
#endif
|
1942 |
|
|
|
1943 |
|
|
/* Now we allocate the skb and transfer the data into it. */
|
1944 |
|
|
skb = dev_alloc_skb( pkt_len );
|
1945 |
|
|
if ( skb == NULL ) /* Not enough memory->drop packet */
|
1946 |
|
|
{
|
1947 |
|
|
#ifdef HP100_DEBUG
|
1948 |
|
|
printk( "hp100: %s: rx: couldn't allocate a sk_buff of size %d\n", dev->name, pkt_len );
|
1949 |
|
|
#endif
|
1950 |
|
|
lp->stats.rx_dropped++;
|
1951 |
|
|
}
|
1952 |
|
|
else /* skb successfully allocated */
|
1953 |
|
|
{
|
1954 |
|
|
u_char *ptr;
|
1955 |
|
|
|
1956 |
|
|
skb->dev = dev;
|
1957 |
|
|
|
1958 |
|
|
/* ptr to start of the sk_buff data area */
|
1959 |
|
|
ptr = (u_char *)skb_put( skb, pkt_len );
|
1960 |
|
|
|
1961 |
|
|
/* Now transfer the data from the card into that area */
|
1962 |
|
|
if ( lp->mode==2 )
|
1963 |
|
|
{
|
1964 |
|
|
if ( lp->mem_ptr_virt )
|
1965 |
|
|
memcpy( ptr, lp->mem_ptr_virt, pkt_len );
|
1966 |
|
|
/* Note alignment to 32bit transfers */
|
1967 |
|
|
else
|
1968 |
|
|
memcpy_fromio( ptr, lp->mem_ptr_phys, pkt_len );
|
1969 |
|
|
}
|
1970 |
|
|
else /* io mapped */
|
1971 |
|
|
insl( ioaddr + HP100_REG_DATA32, ptr, pkt_len >> 2 );
|
1972 |
|
|
|
1973 |
|
|
skb->protocol = eth_type_trans( skb, dev );
|
1974 |
|
|
|
1975 |
|
|
netif_rx( skb );
|
1976 |
|
|
lp->stats.rx_packets++;
|
1977 |
|
|
#ifdef LINUX_2_1
|
1978 |
|
|
lp->stats.rx_bytes += skb->len;
|
1979 |
|
|
#endif
|
1980 |
|
|
|
1981 |
|
|
#ifdef HP100_DEBUG_RX
|
1982 |
|
|
printk( "hp100: %s: rx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
|
1983 |
|
|
dev->name,
|
1984 |
|
|
ptr[ 0 ], ptr[ 1 ], ptr[ 2 ], ptr[ 3 ], ptr[ 4 ], ptr[ 5 ],
|
1985 |
|
|
ptr[ 6 ], ptr[ 7 ], ptr[ 8 ], ptr[ 9 ], ptr[ 10 ], ptr[ 11 ] );
|
1986 |
|
|
#endif
|
1987 |
|
|
}
|
1988 |
|
|
|
1989 |
|
|
/* Indicate the card that we have got the packet */
|
1990 |
|
|
hp100_outb( HP100_ADV_NXT_PKT | HP100_SET_LB, OPTION_MSW );
|
1991 |
|
|
|
1992 |
|
|
switch ( header & 0x00070000 ) {
|
1993 |
|
|
case (HP100_MULTI_ADDR_HASH<<16):
|
1994 |
|
|
case (HP100_MULTI_ADDR_NO_HASH<<16):
|
1995 |
|
|
lp->stats.multicast++; break;
|
1996 |
|
|
}
|
1997 |
|
|
} /* end of while(there are packets) loop */
|
1998 |
|
|
#ifdef HP100_DEBUG_RX
|
1999 |
|
|
printk( "hp100_rx: %s: end\n", dev->name );
|
2000 |
|
|
#endif
|
2001 |
|
|
}
|
2002 |
|
|
|
2003 |
|
|
|
2004 |
|
|
/*
|
2005 |
|
|
* Receive Function for Busmaster Mode
|
2006 |
|
|
*/
|
2007 |
|
|
static void hp100_rx_bm( struct device *dev )
|
2008 |
|
|
{
|
2009 |
|
|
int ioaddr = dev->base_addr;
|
2010 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2011 |
|
|
hp100_ring_t *ptr;
|
2012 |
|
|
u_int header;
|
2013 |
|
|
int pkt_len;
|
2014 |
|
|
|
2015 |
|
|
#ifdef HP100_DEBUG_B
|
2016 |
|
|
hp100_outw( 0x4214, TRACE );
|
2017 |
|
|
printk("hp100: %s: rx_bm\n", dev->name);
|
2018 |
|
|
#endif
|
2019 |
|
|
|
2020 |
|
|
#ifdef HP100_DEBUG
|
2021 |
|
|
if(0==lp->rxrcommit)
|
2022 |
|
|
{
|
2023 |
|
|
printk("hp100: %s: rx_bm called although no PDLs were committed to adapter?\n", dev->name);
|
2024 |
|
|
return;
|
2025 |
|
|
}
|
2026 |
|
|
else
|
2027 |
|
|
|
2028 |
|
|
/* RX_PKT_CNT states how many PDLs are currently formatted and available to
|
2029 |
|
|
* the cards BM engine */
|
2030 |
|
|
if( (hp100_inw(RX_PKT_CNT)&0x00ff) >= lp->rxrcommit)
|
2031 |
|
|
{
|
2032 |
|
|
printk("hp100: %s: More packets received than commited? RX_PKT_CNT=0x%x, commit=0x%x\n", dev->name, hp100_inw(RX_PKT_CNT)&0x00ff, lp->rxrcommit);
|
2033 |
|
|
return;
|
2034 |
|
|
}
|
2035 |
|
|
#endif
|
2036 |
|
|
|
2037 |
|
|
while( (lp->rxrcommit > hp100_inb(RX_PDL)) )
|
2038 |
|
|
{
|
2039 |
|
|
/*
|
2040 |
|
|
* The packet was received into the pdl pointed to by lp->rxrhead (
|
2041 |
|
|
* the oldest pdl in the ring
|
2042 |
|
|
*/
|
2043 |
|
|
|
2044 |
|
|
/* First we get the header, which contains information about the */
|
2045 |
|
|
/* actual length of the received packet. */
|
2046 |
|
|
|
2047 |
|
|
ptr=lp->rxrhead;
|
2048 |
|
|
|
2049 |
|
|
header = *(ptr->pdl-1);
|
2050 |
|
|
pkt_len = (header & HP100_PKT_LEN_MASK);
|
2051 |
|
|
|
2052 |
|
|
#ifdef HP100_DEBUG_BM
|
2053 |
|
|
printk( "hp100: %s: rx_bm: header@0x%x=0x%x length=%d, errors=0x%x, dest=0x%x\n",
|
2054 |
|
|
dev->name,
|
2055 |
|
|
(u_int) (ptr->pdl-1),(u_int) header,
|
2056 |
|
|
pkt_len,
|
2057 |
|
|
(header>>16)&0xfff8,
|
2058 |
|
|
(header>>16)&7);
|
2059 |
|
|
printk( "hp100: %s: RX_PDL_COUNT:0x%x TX_PDL_COUNT:0x%x, RX_PKT_CNT=0x%x PDH=0x%x, Data@0x%x len=0x%x\n",
|
2060 |
|
|
dev->name,
|
2061 |
|
|
hp100_inb( RX_PDL ),
|
2062 |
|
|
hp100_inb( TX_PDL ),
|
2063 |
|
|
hp100_inb( RX_PKT_CNT ),
|
2064 |
|
|
(u_int) *(ptr->pdl),
|
2065 |
|
|
(u_int) *(ptr->pdl+3),
|
2066 |
|
|
(u_int) *(ptr->pdl+4));
|
2067 |
|
|
#endif
|
2068 |
|
|
|
2069 |
|
|
if( (pkt_len>=MIN_ETHER_SIZE) &&
|
2070 |
|
|
(pkt_len<=MAX_ETHER_SIZE) )
|
2071 |
|
|
{
|
2072 |
|
|
if(ptr->skb==NULL)
|
2073 |
|
|
{
|
2074 |
|
|
printk("hp100: %s: rx_bm: skb null\n", dev->name);
|
2075 |
|
|
/* can happen if we only allocated room for the pdh due to memory shortage. */
|
2076 |
|
|
lp->stats.rx_dropped++;
|
2077 |
|
|
}
|
2078 |
|
|
else
|
2079 |
|
|
{
|
2080 |
|
|
skb_trim( ptr->skb, pkt_len ); /* Shorten it */
|
2081 |
|
|
ptr->skb->protocol = eth_type_trans( ptr->skb, dev );
|
2082 |
|
|
|
2083 |
|
|
netif_rx( ptr->skb ); /* Up and away... */
|
2084 |
|
|
|
2085 |
|
|
lp->stats.rx_packets++;
|
2086 |
|
|
#ifdef LINUX_2_1
|
2087 |
|
|
lp->stats.rx_bytes += ptr->skb->len;
|
2088 |
|
|
#endif
|
2089 |
|
|
}
|
2090 |
|
|
|
2091 |
|
|
switch ( header & 0x00070000 ) {
|
2092 |
|
|
case (HP100_MULTI_ADDR_HASH<<16):
|
2093 |
|
|
case (HP100_MULTI_ADDR_NO_HASH<<16):
|
2094 |
|
|
lp->stats.multicast++; break;
|
2095 |
|
|
}
|
2096 |
|
|
}
|
2097 |
|
|
else
|
2098 |
|
|
{
|
2099 |
|
|
#ifdef HP100_DEBUG
|
2100 |
|
|
printk("hp100: %s: rx_bm: Received bad packet (length=%d)\n",dev->name,pkt_len);
|
2101 |
|
|
#endif
|
2102 |
|
|
if(ptr->skb!=NULL)
|
2103 |
|
|
#ifdef LINUX_2_1
|
2104 |
|
|
dev_kfree_skb( ptr->skb );
|
2105 |
|
|
#else
|
2106 |
|
|
dev_kfree_skb( ptr->skb, FREE_READ );
|
2107 |
|
|
#endif
|
2108 |
|
|
lp->stats.rx_errors++;
|
2109 |
|
|
}
|
2110 |
|
|
|
2111 |
|
|
lp->rxrhead=lp->rxrhead->next;
|
2112 |
|
|
|
2113 |
|
|
/* Allocate a new rx PDL (so lp->rxrcommit stays the same) */
|
2114 |
|
|
if (0 == hp100_build_rx_pdl( lp->rxrtail, dev ))
|
2115 |
|
|
{
|
2116 |
|
|
/* No space for skb, header can still be received. */
|
2117 |
|
|
#ifdef HP100_DEBUG
|
2118 |
|
|
printk("hp100: %s: rx_bm: No space for new PDL.\n", dev->name);
|
2119 |
|
|
#endif
|
2120 |
|
|
return;
|
2121 |
|
|
}
|
2122 |
|
|
else
|
2123 |
|
|
{ /* successfully allocated new PDL - put it in ringlist at tail. */
|
2124 |
|
|
hp100_outl((u32)lp->rxrtail->pdl_paddr, RX_PDA);
|
2125 |
|
|
lp->rxrtail=lp->rxrtail->next;
|
2126 |
|
|
}
|
2127 |
|
|
|
2128 |
|
|
}
|
2129 |
|
|
}
|
2130 |
|
|
|
2131 |
|
|
|
2132 |
|
|
|
2133 |
|
|
/*
|
2134 |
|
|
* statistics
|
2135 |
|
|
*/
|
2136 |
|
|
static hp100_stats_t *hp100_get_stats( struct device *dev )
|
2137 |
|
|
{
|
2138 |
|
|
int ioaddr = dev->base_addr;
|
2139 |
|
|
|
2140 |
|
|
#ifdef HP100_DEBUG_B
|
2141 |
|
|
hp100_outw( 0x4215, TRACE );
|
2142 |
|
|
#endif
|
2143 |
|
|
|
2144 |
|
|
hp100_ints_off();
|
2145 |
|
|
hp100_update_stats( dev );
|
2146 |
|
|
hp100_ints_on();
|
2147 |
|
|
return &((struct hp100_private *)dev->priv)->stats;
|
2148 |
|
|
}
|
2149 |
|
|
|
2150 |
|
|
static void hp100_update_stats( struct device *dev )
|
2151 |
|
|
{
|
2152 |
|
|
int ioaddr = dev->base_addr;
|
2153 |
|
|
u_short val;
|
2154 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2155 |
|
|
|
2156 |
|
|
#ifdef HP100_DEBUG_B
|
2157 |
|
|
hp100_outw( 0x4216, TRACE );
|
2158 |
|
|
printk("hp100: %s: update-stats\n", dev->name);
|
2159 |
|
|
#endif
|
2160 |
|
|
|
2161 |
|
|
/* Note: Statistics counters clear when read. */
|
2162 |
|
|
hp100_page( MAC_CTRL );
|
2163 |
|
|
val = hp100_inw( DROPPED ) & 0x0fff;
|
2164 |
|
|
lp->stats.rx_errors += val;
|
2165 |
|
|
lp->stats.rx_over_errors += val;
|
2166 |
|
|
val = hp100_inb( CRC );
|
2167 |
|
|
lp->stats.rx_errors += val;
|
2168 |
|
|
lp->stats.rx_crc_errors += val;
|
2169 |
|
|
val = hp100_inb( ABORT );
|
2170 |
|
|
lp->stats.tx_errors += val;
|
2171 |
|
|
lp->stats.tx_aborted_errors += val;
|
2172 |
|
|
hp100_page( PERFORMANCE );
|
2173 |
|
|
}
|
2174 |
|
|
|
2175 |
|
|
static void hp100_misc_interrupt( struct device *dev )
|
2176 |
|
|
{
|
2177 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2178 |
|
|
|
2179 |
|
|
#ifdef HP100_DEBUG_B
|
2180 |
|
|
hp100_outw( 0x4216, TRACE );
|
2181 |
|
|
printk("hp100: %s: misc_interrupt\n", dev->name);
|
2182 |
|
|
#endif
|
2183 |
|
|
|
2184 |
|
|
/* Note: Statistics counters clear when read. */
|
2185 |
|
|
lp->stats.rx_errors++;
|
2186 |
|
|
lp->stats.tx_errors++;
|
2187 |
|
|
}
|
2188 |
|
|
|
2189 |
|
|
static void hp100_clear_stats( int ioaddr )
|
2190 |
|
|
{
|
2191 |
|
|
unsigned long flags;
|
2192 |
|
|
|
2193 |
|
|
#ifdef HP100_DEBUG_B
|
2194 |
|
|
hp100_outw( 0x4217, TRACE );
|
2195 |
|
|
printk("hp100: %s: clear_stats\n", dev->name);
|
2196 |
|
|
#endif
|
2197 |
|
|
|
2198 |
|
|
save_flags( flags );
|
2199 |
|
|
cli();
|
2200 |
|
|
hp100_page( MAC_CTRL ); /* get all statistics bytes */
|
2201 |
|
|
hp100_inw( DROPPED );
|
2202 |
|
|
hp100_inb( CRC );
|
2203 |
|
|
hp100_inb( ABORT );
|
2204 |
|
|
hp100_page( PERFORMANCE );
|
2205 |
|
|
restore_flags( flags );
|
2206 |
|
|
}
|
2207 |
|
|
|
2208 |
|
|
|
2209 |
|
|
/*
|
2210 |
|
|
* multicast setup
|
2211 |
|
|
*/
|
2212 |
|
|
|
2213 |
|
|
/*
|
2214 |
|
|
* Set or clear the multicast filter for this adapter.
|
2215 |
|
|
*/
|
2216 |
|
|
|
2217 |
|
|
static void hp100_set_multicast_list( struct device *dev )
|
2218 |
|
|
{
|
2219 |
|
|
unsigned long flags;
|
2220 |
|
|
int ioaddr = dev->base_addr;
|
2221 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2222 |
|
|
|
2223 |
|
|
#ifdef HP100_DEBUG_B
|
2224 |
|
|
hp100_outw( 0x4218, TRACE );
|
2225 |
|
|
printk("hp100: %s: set_mc_list\n", dev->name);
|
2226 |
|
|
#endif
|
2227 |
|
|
|
2228 |
|
|
save_flags( flags );
|
2229 |
|
|
cli();
|
2230 |
|
|
hp100_ints_off();
|
2231 |
|
|
hp100_page( MAC_CTRL );
|
2232 |
|
|
hp100_andb( ~(HP100_RX_EN | HP100_TX_EN), MAC_CFG_1 ); /* stop rx/tx */
|
2233 |
|
|
|
2234 |
|
|
if ( dev->flags & IFF_PROMISC )
|
2235 |
|
|
{
|
2236 |
|
|
lp->mac2_mode = HP100_MAC2MODE6; /* promiscuous mode = get all good */
|
2237 |
|
|
lp->mac1_mode = HP100_MAC1MODE6; /* packets on the net */
|
2238 |
|
|
memset( &lp->hash_bytes, 0xff, 8 );
|
2239 |
|
|
}
|
2240 |
|
|
else if ( dev->mc_count || (dev->flags&IFF_ALLMULTI) )
|
2241 |
|
|
{
|
2242 |
|
|
lp->mac2_mode = HP100_MAC2MODE5; /* multicast mode = get packets for */
|
2243 |
|
|
lp->mac1_mode = HP100_MAC1MODE5; /* me, broadcasts and all multicasts */
|
2244 |
|
|
#ifdef HP100_MULTICAST_FILTER /* doesn't work!!! */
|
2245 |
|
|
if ( dev -> flags & IFF_ALLMULTI )
|
2246 |
|
|
{
|
2247 |
|
|
/* set hash filter to receive all multicast packets */
|
2248 |
|
|
memset( &lp->hash_bytes, 0xff, 8 );
|
2249 |
|
|
}
|
2250 |
|
|
else
|
2251 |
|
|
{
|
2252 |
|
|
int i, j, idx;
|
2253 |
|
|
u_char *addrs;
|
2254 |
|
|
struct dev_mc_list *dmi;
|
2255 |
|
|
|
2256 |
|
|
memset( &lp->hash_bytes, 0x00, 8 );
|
2257 |
|
|
#ifdef HP100_DEBUG
|
2258 |
|
|
printk("hp100: %s: computing hash filter - mc_count = %i\n", dev -> name, dev -> mc_count );
|
2259 |
|
|
#endif
|
2260 |
|
|
for ( i = 0, dmi = dev -> mc_list; i < dev -> mc_count; i++, dmi = dmi -> next )
|
2261 |
|
|
{
|
2262 |
|
|
addrs = dmi -> dmi_addr;
|
2263 |
|
|
if ( ( *addrs & 0x01 ) == 0x01 ) /* multicast address? */
|
2264 |
|
|
{
|
2265 |
|
|
#ifdef HP100_DEBUG
|
2266 |
|
|
printk("hp100: %s: multicast = %02x:%02x:%02x:%02x:%02x:%02x, ",
|
2267 |
|
|
dev -> name,
|
2268 |
|
|
addrs[ 0 ], addrs[ 1 ], addrs[ 2 ],
|
2269 |
|
|
addrs[ 3 ], addrs[ 4 ], addrs[ 5 ] );
|
2270 |
|
|
#endif
|
2271 |
|
|
for ( j = idx = 0; j < 6; j++ )
|
2272 |
|
|
{
|
2273 |
|
|
idx ^= *addrs++ & 0x3f;
|
2274 |
|
|
printk( ":%02x:", idx );
|
2275 |
|
|
}
|
2276 |
|
|
#ifdef HP100_DEBUG
|
2277 |
|
|
printk("idx = %i\n", idx );
|
2278 |
|
|
#endif
|
2279 |
|
|
lp->hash_bytes[ idx >> 3 ] |= ( 1 << ( idx & 7 ) );
|
2280 |
|
|
}
|
2281 |
|
|
}
|
2282 |
|
|
}
|
2283 |
|
|
#else
|
2284 |
|
|
memset( &lp->hash_bytes, 0xff, 8 );
|
2285 |
|
|
#endif
|
2286 |
|
|
}
|
2287 |
|
|
else
|
2288 |
|
|
{
|
2289 |
|
|
lp->mac2_mode = HP100_MAC2MODE3; /* normal mode = get packets for me */
|
2290 |
|
|
lp->mac1_mode = HP100_MAC1MODE3; /* and broadcasts */
|
2291 |
|
|
memset( &lp->hash_bytes, 0x00, 8 );
|
2292 |
|
|
}
|
2293 |
|
|
|
2294 |
|
|
if ( ( (hp100_inb(MAC_CFG_1) & 0x0f)!=lp->mac1_mode ) ||
|
2295 |
|
|
( hp100_inb(MAC_CFG_2)!=lp->mac2_mode ) )
|
2296 |
|
|
{
|
2297 |
|
|
int i;
|
2298 |
|
|
|
2299 |
|
|
hp100_outb( lp->mac2_mode, MAC_CFG_2 );
|
2300 |
|
|
hp100_andb( HP100_MAC1MODEMASK, MAC_CFG_1 ); /* clear mac1 mode bits */
|
2301 |
|
|
hp100_orb( lp->mac1_mode, MAC_CFG_1 ); /* and set the new mode */
|
2302 |
|
|
|
2303 |
|
|
hp100_page( MAC_ADDRESS );
|
2304 |
|
|
for ( i = 0; i < 8; i++ )
|
2305 |
|
|
hp100_outb( lp->hash_bytes[ i ], HASH_BYTE0 + i );
|
2306 |
|
|
#ifdef HP100_DEBUG
|
2307 |
|
|
printk("hp100: %s: mac1 = 0x%x, mac2 = 0x%x, multicast hash = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
2308 |
|
|
dev->name, lp->mac1_mode, lp->mac2_mode,
|
2309 |
|
|
lp->hash_bytes[ 0 ], lp->hash_bytes[ 1 ],
|
2310 |
|
|
lp->hash_bytes[ 2 ], lp->hash_bytes[ 3 ],
|
2311 |
|
|
lp->hash_bytes[ 4 ], lp->hash_bytes[ 5 ],
|
2312 |
|
|
lp->hash_bytes[ 6 ], lp->hash_bytes[ 7 ]
|
2313 |
|
|
);
|
2314 |
|
|
#endif
|
2315 |
|
|
|
2316 |
|
|
if(lp->lan_type==HP100_LAN_100)
|
2317 |
|
|
{
|
2318 |
|
|
#ifdef HP100_DEBUG
|
2319 |
|
|
printk("hp100: %s: 100VG MAC settings have changed - relogin.\n", dev->name);
|
2320 |
|
|
#endif
|
2321 |
|
|
lp->hub_status=hp100_login_to_vg_hub( dev, TRUE ); /* force a relogin to the hub */
|
2322 |
|
|
}
|
2323 |
|
|
}
|
2324 |
|
|
else
|
2325 |
|
|
{
|
2326 |
|
|
int i;
|
2327 |
|
|
u_char old_hash_bytes[ 8 ];
|
2328 |
|
|
|
2329 |
|
|
hp100_page( MAC_ADDRESS );
|
2330 |
|
|
for ( i = 0; i < 8; i++ )
|
2331 |
|
|
old_hash_bytes[ i ] = hp100_inb( HASH_BYTE0 + i );
|
2332 |
|
|
if ( memcmp( old_hash_bytes, &lp->hash_bytes, 8 ) )
|
2333 |
|
|
{
|
2334 |
|
|
for ( i = 0; i < 8; i++ )
|
2335 |
|
|
hp100_outb( lp->hash_bytes[ i ], HASH_BYTE0 + i );
|
2336 |
|
|
#ifdef HP100_DEBUG
|
2337 |
|
|
printk("hp100: %s: multicast hash = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
2338 |
|
|
dev->name,
|
2339 |
|
|
lp->hash_bytes[ 0 ], lp->hash_bytes[ 1 ],
|
2340 |
|
|
lp->hash_bytes[ 2 ], lp->hash_bytes[ 3 ],
|
2341 |
|
|
lp->hash_bytes[ 4 ], lp->hash_bytes[ 5 ],
|
2342 |
|
|
lp->hash_bytes[ 6 ], lp->hash_bytes[ 7 ]
|
2343 |
|
|
);
|
2344 |
|
|
#endif
|
2345 |
|
|
|
2346 |
|
|
if(lp->lan_type==HP100_LAN_100)
|
2347 |
|
|
{
|
2348 |
|
|
#ifdef HP100_DEBUG
|
2349 |
|
|
printk("hp100: %s: 100VG MAC settings have changed - relogin.\n", dev->name);
|
2350 |
|
|
#endif
|
2351 |
|
|
lp->hub_status=hp100_login_to_vg_hub( dev, TRUE ); /* force a relogin to the hub */
|
2352 |
|
|
}
|
2353 |
|
|
}
|
2354 |
|
|
}
|
2355 |
|
|
|
2356 |
|
|
hp100_page( MAC_CTRL );
|
2357 |
|
|
hp100_orb( HP100_RX_EN | HP100_RX_IDLE | /* enable rx */
|
2358 |
|
|
HP100_TX_EN | HP100_TX_IDLE, MAC_CFG_1 ); /* enable tx */
|
2359 |
|
|
|
2360 |
|
|
hp100_page( PERFORMANCE );
|
2361 |
|
|
hp100_ints_on();
|
2362 |
|
|
restore_flags( flags );
|
2363 |
|
|
}
|
2364 |
|
|
|
2365 |
|
|
|
2366 |
|
|
/*
|
2367 |
|
|
* hardware interrupt handling
|
2368 |
|
|
*/
|
2369 |
|
|
|
2370 |
|
|
static void hp100_interrupt( int irq, void *dev_id, struct pt_regs *regs )
|
2371 |
|
|
{
|
2372 |
|
|
struct device *dev = (struct device *)dev_id;
|
2373 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2374 |
|
|
|
2375 |
|
|
int ioaddr;
|
2376 |
|
|
u_int val;
|
2377 |
|
|
|
2378 |
|
|
if ( dev == NULL ) return;
|
2379 |
|
|
ioaddr = dev->base_addr;
|
2380 |
|
|
|
2381 |
|
|
if ( dev->interrupt )
|
2382 |
|
|
printk( "hp100: %s: re-entering the interrupt handler\n", dev->name );
|
2383 |
|
|
hp100_ints_off();
|
2384 |
|
|
dev->interrupt = 1; /* mark that we are inside the handler */
|
2385 |
|
|
|
2386 |
|
|
#ifdef HP100_DEBUG_B
|
2387 |
|
|
hp100_outw( 0x4219, TRACE );
|
2388 |
|
|
#endif
|
2389 |
|
|
|
2390 |
|
|
/* hp100_page( PERFORMANCE ); */
|
2391 |
|
|
val = hp100_inw( IRQ_STATUS );
|
2392 |
|
|
#ifdef HP100_DEBUG_IRQ
|
2393 |
|
|
printk( "hp100: %s: mode=%x,IRQ_STAT=0x%.4x,RXPKTCNT=0x%.2x RXPDL=0x%.2x TXPKTCNT=0x%.2x TXPDL=0x%.2x\n",
|
2394 |
|
|
dev->name,
|
2395 |
|
|
lp->mode,
|
2396 |
|
|
(u_int)val,
|
2397 |
|
|
hp100_inb( RX_PKT_CNT ),
|
2398 |
|
|
hp100_inb( RX_PDL ),
|
2399 |
|
|
hp100_inb( TX_PKT_CNT ),
|
2400 |
|
|
hp100_inb( TX_PDL )
|
2401 |
|
|
);
|
2402 |
|
|
#endif
|
2403 |
|
|
|
2404 |
|
|
if(val==0) /* might be a shared interrupt */
|
2405 |
|
|
{
|
2406 |
|
|
dev->interrupt=0;
|
2407 |
|
|
hp100_ints_on();
|
2408 |
|
|
return;
|
2409 |
|
|
}
|
2410 |
|
|
/* We're only interested in those interrupts we really enabled. */
|
2411 |
|
|
/* val &= hp100_inw( IRQ_MASK ); */
|
2412 |
|
|
|
2413 |
|
|
/*
|
2414 |
|
|
* RX_PDL_FILL_COMPL is set whenever a RX_PDL has been executed. A RX_PDL
|
2415 |
|
|
* is considered executed whenever the RX_PDL data structure is no longer
|
2416 |
|
|
* needed.
|
2417 |
|
|
*/
|
2418 |
|
|
if ( val & HP100_RX_PDL_FILL_COMPL )
|
2419 |
|
|
{
|
2420 |
|
|
if(lp->mode==1)
|
2421 |
|
|
hp100_rx_bm( dev );
|
2422 |
|
|
else
|
2423 |
|
|
{
|
2424 |
|
|
printk("hp100: %s: rx_pdl_fill_compl interrupt although not busmaster?\n", dev->name);
|
2425 |
|
|
}
|
2426 |
|
|
}
|
2427 |
|
|
|
2428 |
|
|
/*
|
2429 |
|
|
* The RX_PACKET interrupt is set, when the receive packet counter is
|
2430 |
|
|
* non zero. We use this interrupt for receiving in slave mode. In
|
2431 |
|
|
* busmaster mode, we use it to make sure we did not miss any rx_pdl_fill
|
2432 |
|
|
* interrupts. If rx_pdl_fill_compl is not set and rx_packet is set, then
|
2433 |
|
|
* we somehow have missed a rx_pdl_fill_compl interrupt.
|
2434 |
|
|
*/
|
2435 |
|
|
|
2436 |
|
|
if ( val & HP100_RX_PACKET ) /* Receive Packet Counter is non zero */
|
2437 |
|
|
{
|
2438 |
|
|
if(lp->mode!=1) /* non busmaster */
|
2439 |
|
|
hp100_rx( dev );
|
2440 |
|
|
else if ( !(val & HP100_RX_PDL_FILL_COMPL ))
|
2441 |
|
|
{
|
2442 |
|
|
/* Shouldnt happen - maybe we missed a RX_PDL_FILL Interrupt? */
|
2443 |
|
|
hp100_rx_bm( dev );
|
2444 |
|
|
}
|
2445 |
|
|
}
|
2446 |
|
|
|
2447 |
|
|
/*
|
2448 |
|
|
* Ack. that we have noticed the interrupt and thereby allow next one.
|
2449 |
|
|
* Note that this is now done after the slave rx function, since first
|
2450 |
|
|
* acknowledging and then setting ADV_NXT_PKT caused an extra interrupt
|
2451 |
|
|
* on the J2573.
|
2452 |
|
|
*/
|
2453 |
|
|
hp100_outw( val, IRQ_STATUS );
|
2454 |
|
|
|
2455 |
|
|
/*
|
2456 |
|
|
* RX_ERROR is set when a packet is dropped due to no memory resources on
|
2457 |
|
|
* the card or when a RCV_ERR occurs.
|
2458 |
|
|
* TX_ERROR is set when a TX_ABORT condition occurs in the MAC->exists
|
2459 |
|
|
* only in the 802.3 MAC and happens when 16 collisions occur during a TX
|
2460 |
|
|
*/
|
2461 |
|
|
if ( val & ( HP100_TX_ERROR | HP100_RX_ERROR ) )
|
2462 |
|
|
{
|
2463 |
|
|
#ifdef HP100_DEBUG_IRQ
|
2464 |
|
|
printk("hp100: %s: TX/RX Error IRQ\n", dev->name);
|
2465 |
|
|
#endif
|
2466 |
|
|
hp100_update_stats( dev );
|
2467 |
|
|
if(lp->mode==1)
|
2468 |
|
|
{
|
2469 |
|
|
hp100_rxfill( dev );
|
2470 |
|
|
hp100_clean_txring( dev );
|
2471 |
|
|
}
|
2472 |
|
|
}
|
2473 |
|
|
|
2474 |
|
|
/*
|
2475 |
|
|
* RX_PDA_ZERO is set when the PDA count goes from non-zero to zero.
|
2476 |
|
|
*/
|
2477 |
|
|
if ( (lp->mode==1)&&(val &(HP100_RX_PDA_ZERO)) )
|
2478 |
|
|
hp100_rxfill( dev );
|
2479 |
|
|
|
2480 |
|
|
/*
|
2481 |
|
|
* HP100_TX_COMPLETE interrupt occurs when packet transmitted on wire
|
2482 |
|
|
* is completed
|
2483 |
|
|
*/
|
2484 |
|
|
if ( (lp->mode==1) && ( val & ( HP100_TX_COMPLETE )) )
|
2485 |
|
|
hp100_clean_txring( dev );
|
2486 |
|
|
|
2487 |
|
|
/*
|
2488 |
|
|
* MISC_ERROR is set when either the LAN link goes down or a detected
|
2489 |
|
|
* bus error occurs.
|
2490 |
|
|
*/
|
2491 |
|
|
if ( val & HP100_MISC_ERROR ) /* New for J2585B */
|
2492 |
|
|
{
|
2493 |
|
|
#ifdef HP100_DEBUG_IRQ
|
2494 |
|
|
printk("hp100: %s: Misc. Error Interrupt - Check cabling.\n", dev->name);
|
2495 |
|
|
#endif
|
2496 |
|
|
if(lp->mode==1)
|
2497 |
|
|
{
|
2498 |
|
|
hp100_clean_txring( dev );
|
2499 |
|
|
hp100_rxfill( dev );
|
2500 |
|
|
}
|
2501 |
|
|
hp100_misc_interrupt( dev );
|
2502 |
|
|
}
|
2503 |
|
|
|
2504 |
|
|
dev->interrupt = 0;
|
2505 |
|
|
hp100_ints_on();
|
2506 |
|
|
}
|
2507 |
|
|
|
2508 |
|
|
|
2509 |
|
|
/*
|
2510 |
|
|
* some misc functions
|
2511 |
|
|
*/
|
2512 |
|
|
|
2513 |
|
|
static void hp100_start_interface( struct device *dev )
|
2514 |
|
|
{
|
2515 |
|
|
unsigned long flags;
|
2516 |
|
|
int ioaddr = dev->base_addr;
|
2517 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2518 |
|
|
|
2519 |
|
|
#ifdef HP100_DEBUG_B
|
2520 |
|
|
hp100_outw( 0x4220, TRACE );
|
2521 |
|
|
printk("hp100: %s: hp100_start_interface\n",dev->name);
|
2522 |
|
|
#endif
|
2523 |
|
|
|
2524 |
|
|
save_flags( flags );
|
2525 |
|
|
cli();
|
2526 |
|
|
|
2527 |
|
|
/* Ensure the adapter does not want to request an interrupt when */
|
2528 |
|
|
/* enabling the IRQ line to be active on the bus (i.e. not tri-stated) */
|
2529 |
|
|
hp100_page( PERFORMANCE );
|
2530 |
|
|
hp100_outw( 0xfefe, IRQ_MASK ); /* mask off all ints */
|
2531 |
|
|
hp100_outw( 0xffff, IRQ_STATUS ); /* ack all IRQs */
|
2532 |
|
|
hp100_outw( HP100_FAKE_INT|HP100_INT_EN|HP100_RESET_LB, OPTION_LSW);
|
2533 |
|
|
/* Un Tri-state int. TODO: Check if shared interrupts can be realised? */
|
2534 |
|
|
hp100_outw( HP100_TRI_INT | HP100_RESET_HB, OPTION_LSW );
|
2535 |
|
|
|
2536 |
|
|
if(lp->mode==1)
|
2537 |
|
|
{
|
2538 |
|
|
/* Make sure BM bit is set... */
|
2539 |
|
|
hp100_page(HW_MAP);
|
2540 |
|
|
hp100_orb( HP100_BM_MASTER, BM );
|
2541 |
|
|
hp100_rxfill( dev );
|
2542 |
|
|
}
|
2543 |
|
|
else if(lp->mode==2)
|
2544 |
|
|
{
|
2545 |
|
|
/* Enable memory mapping. Note: Don't do this when busmaster. */
|
2546 |
|
|
hp100_outw( HP100_MMAP_DIS | HP100_RESET_HB, OPTION_LSW );
|
2547 |
|
|
}
|
2548 |
|
|
|
2549 |
|
|
hp100_page(PERFORMANCE);
|
2550 |
|
|
hp100_outw( 0xfefe, IRQ_MASK ); /* mask off all ints */
|
2551 |
|
|
hp100_outw( 0xffff, IRQ_STATUS ); /* ack IRQ */
|
2552 |
|
|
|
2553 |
|
|
/* enable a few interrupts: */
|
2554 |
|
|
if(lp->mode==1) /* busmaster mode */
|
2555 |
|
|
{
|
2556 |
|
|
hp100_outw( HP100_RX_PDL_FILL_COMPL |
|
2557 |
|
|
HP100_RX_PDA_ZERO |
|
2558 |
|
|
HP100_RX_ERROR |
|
2559 |
|
|
/* HP100_RX_PACKET | */
|
2560 |
|
|
/* HP100_RX_EARLY_INT | */ HP100_SET_HB |
|
2561 |
|
|
/* HP100_TX_PDA_ZERO | */
|
2562 |
|
|
HP100_TX_COMPLETE |
|
2563 |
|
|
/* HP100_MISC_ERROR | */
|
2564 |
|
|
HP100_TX_ERROR | HP100_SET_LB, IRQ_MASK );
|
2565 |
|
|
}
|
2566 |
|
|
else
|
2567 |
|
|
{
|
2568 |
|
|
hp100_outw( HP100_RX_PACKET |
|
2569 |
|
|
HP100_RX_ERROR | HP100_SET_HB |
|
2570 |
|
|
HP100_TX_ERROR | HP100_SET_LB , IRQ_MASK );
|
2571 |
|
|
}
|
2572 |
|
|
|
2573 |
|
|
/* Enable MAC Tx and RX, set MAC modes, ... */
|
2574 |
|
|
hp100_set_multicast_list( dev );
|
2575 |
|
|
|
2576 |
|
|
restore_flags( flags );
|
2577 |
|
|
}
|
2578 |
|
|
|
2579 |
|
|
|
2580 |
|
|
static void hp100_stop_interface( struct device *dev )
|
2581 |
|
|
{
|
2582 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2583 |
|
|
int ioaddr = dev->base_addr;
|
2584 |
|
|
u_int val;
|
2585 |
|
|
|
2586 |
|
|
#ifdef HP100_DEBUG_B
|
2587 |
|
|
printk("hp100: %s: hp100_stop_interface\n",dev->name);
|
2588 |
|
|
hp100_outw( 0x4221, TRACE );
|
2589 |
|
|
#endif
|
2590 |
|
|
|
2591 |
|
|
if (lp->mode==1)
|
2592 |
|
|
hp100_BM_shutdown( dev );
|
2593 |
|
|
else
|
2594 |
|
|
{
|
2595 |
|
|
/* Note: MMAP_DIS will be reenabled by start_interface */
|
2596 |
|
|
hp100_outw( HP100_INT_EN | HP100_RESET_LB |
|
2597 |
|
|
HP100_TRI_INT | HP100_MMAP_DIS | HP100_SET_HB, OPTION_LSW );
|
2598 |
|
|
val = hp100_inw( OPTION_LSW );
|
2599 |
|
|
|
2600 |
|
|
hp100_page( MAC_CTRL );
|
2601 |
|
|
hp100_andb( ~(HP100_RX_EN | HP100_TX_EN), MAC_CFG_1 );
|
2602 |
|
|
|
2603 |
|
|
if ( !(val & HP100_HW_RST) ) return; /* If reset, imm. return ... */
|
2604 |
|
|
/* ... else: busy wait until idle */
|
2605 |
|
|
for ( val = 0; val < 6000; val++ )
|
2606 |
|
|
if ( ( hp100_inb( MAC_CFG_1 ) & (HP100_TX_IDLE | HP100_RX_IDLE) ) ==
|
2607 |
|
|
(HP100_TX_IDLE | HP100_RX_IDLE) )
|
2608 |
|
|
{
|
2609 |
|
|
hp100_page(PERFORMANCE);
|
2610 |
|
|
return;
|
2611 |
|
|
}
|
2612 |
|
|
printk( "hp100: %s: hp100_stop_interface - timeout\n", dev->name );
|
2613 |
|
|
hp100_page(PERFORMANCE);
|
2614 |
|
|
}
|
2615 |
|
|
}
|
2616 |
|
|
|
2617 |
|
|
|
2618 |
|
|
static void hp100_load_eeprom( struct device *dev, u_short probe_ioaddr )
|
2619 |
|
|
{
|
2620 |
|
|
int i;
|
2621 |
|
|
int ioaddr = probe_ioaddr > 0 ? probe_ioaddr : dev->base_addr;
|
2622 |
|
|
|
2623 |
|
|
#ifdef HP100_DEBUG_B
|
2624 |
|
|
hp100_outw( 0x4222, TRACE );
|
2625 |
|
|
#endif
|
2626 |
|
|
|
2627 |
|
|
hp100_page( EEPROM_CTRL );
|
2628 |
|
|
hp100_andw( ~HP100_EEPROM_LOAD, EEPROM_CTRL );
|
2629 |
|
|
hp100_orw( HP100_EEPROM_LOAD, EEPROM_CTRL );
|
2630 |
|
|
for ( i = 0; i < 10000; i++ )
|
2631 |
|
|
if ( !( hp100_inb( OPTION_MSW ) & HP100_EE_LOAD ) ) return;
|
2632 |
|
|
printk( "hp100: %s: hp100_load_eeprom - timeout\n", dev->name );
|
2633 |
|
|
}
|
2634 |
|
|
|
2635 |
|
|
|
2636 |
|
|
/* Sense connection status.
|
2637 |
|
|
* return values: LAN_10 - Connected to 10Mbit/s network
|
2638 |
|
|
* LAN_100 - Connected to 100Mbit/s network
|
2639 |
|
|
* LAN_ERR - not connected or 100Mbit/s Hub down
|
2640 |
|
|
*/
|
2641 |
|
|
static int hp100_sense_lan( struct device *dev )
|
2642 |
|
|
{
|
2643 |
|
|
int ioaddr = dev->base_addr;
|
2644 |
|
|
u_short val_VG, val_10;
|
2645 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2646 |
|
|
|
2647 |
|
|
#ifdef HP100_DEBUG_B
|
2648 |
|
|
hp100_outw( 0x4223, TRACE );
|
2649 |
|
|
#endif
|
2650 |
|
|
|
2651 |
|
|
hp100_page( MAC_CTRL );
|
2652 |
|
|
val_10 = hp100_inb( 10_LAN_CFG_1 );
|
2653 |
|
|
val_VG = hp100_inb( VG_LAN_CFG_1 );
|
2654 |
|
|
hp100_page( PERFORMANCE );
|
2655 |
|
|
#ifdef HP100_DEBUG
|
2656 |
|
|
printk( "hp100: %s: sense_lan: val_VG = 0x%04x, val_10 = 0x%04x\n", dev->name, val_VG, val_10 );
|
2657 |
|
|
#endif
|
2658 |
|
|
|
2659 |
|
|
if ( val_10 & HP100_LINK_BEAT_ST ) /* 10Mb connection is active */
|
2660 |
|
|
return HP100_LAN_10;
|
2661 |
|
|
|
2662 |
|
|
if ( val_10 & HP100_AUI_ST ) /* have we BNC or AUI onboard? */
|
2663 |
|
|
{
|
2664 |
|
|
val_10 |= HP100_AUI_SEL | HP100_LOW_TH;
|
2665 |
|
|
hp100_page( MAC_CTRL );
|
2666 |
|
|
hp100_outb( val_10, 10_LAN_CFG_1 );
|
2667 |
|
|
hp100_page( PERFORMANCE );
|
2668 |
|
|
return HP100_LAN_10;
|
2669 |
|
|
}
|
2670 |
|
|
|
2671 |
|
|
if ( (lp->id->id == 0x02019F022) ||
|
2672 |
|
|
(lp->id->id == 0x01042103c) ||
|
2673 |
|
|
(lp->id->id == 0x01040103c) )
|
2674 |
|
|
return HP100_LAN_ERR; /* Those cards don't have a 100 Mbit connector */
|
2675 |
|
|
|
2676 |
|
|
if ( val_VG & HP100_LINK_CABLE_ST ) /* Can hear the HUBs tone. */
|
2677 |
|
|
return HP100_LAN_100;
|
2678 |
|
|
return HP100_LAN_ERR;
|
2679 |
|
|
}
|
2680 |
|
|
|
2681 |
|
|
|
2682 |
|
|
|
2683 |
|
|
static int hp100_down_vg_link( struct device *dev )
|
2684 |
|
|
{
|
2685 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2686 |
|
|
int ioaddr = dev->base_addr;
|
2687 |
|
|
unsigned long time;
|
2688 |
|
|
long savelan, newlan;
|
2689 |
|
|
|
2690 |
|
|
#ifdef HP100_DEBUG_B
|
2691 |
|
|
hp100_outw( 0x4224, TRACE );
|
2692 |
|
|
printk("hp100: %s: down_vg_link\n", dev->name);
|
2693 |
|
|
#endif
|
2694 |
|
|
|
2695 |
|
|
hp100_page( MAC_CTRL );
|
2696 |
|
|
time=jiffies+(HZ/4);
|
2697 |
|
|
do{
|
2698 |
|
|
if ( hp100_inb( VG_LAN_CFG_1 ) & HP100_LINK_CABLE_ST ) break;
|
2699 |
|
|
} while (time>jiffies);
|
2700 |
|
|
|
2701 |
|
|
if ( jiffies >= time ) /* no signal->no logout */
|
2702 |
|
|
return 0;
|
2703 |
|
|
|
2704 |
|
|
/* Drop the VG Link by clearing the link up cmd and load addr.*/
|
2705 |
|
|
|
2706 |
|
|
hp100_andb( ~( HP100_LOAD_ADDR| HP100_LINK_CMD), VG_LAN_CFG_1);
|
2707 |
|
|
hp100_orb( HP100_VG_SEL, VG_LAN_CFG_1);
|
2708 |
|
|
|
2709 |
|
|
/* Conditionally stall for >250ms on Link-Up Status (to go down) */
|
2710 |
|
|
time=jiffies+(HZ/2);
|
2711 |
|
|
do{
|
2712 |
|
|
if ( !(hp100_inb( VG_LAN_CFG_1) & HP100_LINK_UP_ST) ) break;
|
2713 |
|
|
} while(time>jiffies);
|
2714 |
|
|
|
2715 |
|
|
#ifdef HP100_DEBUG
|
2716 |
|
|
if (jiffies>=time)
|
2717 |
|
|
printk("hp100: %s: down_vg_link: Link does not go down?\n", dev->name);
|
2718 |
|
|
#endif
|
2719 |
|
|
|
2720 |
|
|
/* To prevent condition where Rev 1 VG MAC and old hubs do not complete */
|
2721 |
|
|
/* logout under traffic (even though all the status bits are cleared), */
|
2722 |
|
|
/* do this workaround to get the Rev 1 MAC in its idle state */
|
2723 |
|
|
if ( lp->chip==HP100_CHIPID_LASSEN )
|
2724 |
|
|
{
|
2725 |
|
|
/* Reset VG MAC to insure it leaves the logoff state even if */
|
2726 |
|
|
/* the Hub is still emitting tones */
|
2727 |
|
|
hp100_andb(~HP100_VG_RESET, VG_LAN_CFG_1);
|
2728 |
|
|
udelay(1500); /* wait for >1ms */
|
2729 |
|
|
hp100_orb(HP100_VG_RESET, VG_LAN_CFG_1); /* Release Reset */
|
2730 |
|
|
udelay(1500);
|
2731 |
|
|
}
|
2732 |
|
|
|
2733 |
|
|
/* New: For lassen, switch to 10 Mbps mac briefly to clear training ACK */
|
2734 |
|
|
/* to get the VG mac to full reset. This is not req.d with later chips */
|
2735 |
|
|
/* Note: It will take the between 1 and 2 seconds for the VG mac to be */
|
2736 |
|
|
/* selected again! This will be left to the connect hub function to */
|
2737 |
|
|
/* perform if desired. */
|
2738 |
|
|
if (lp->chip==HP100_CHIPID_LASSEN)
|
2739 |
|
|
{
|
2740 |
|
|
/* Have to write to 10 and 100VG control registers simultaneously */
|
2741 |
|
|
savelan=newlan=hp100_inl(10_LAN_CFG_1); /* read 10+100 LAN_CFG regs */
|
2742 |
|
|
newlan &= ~(HP100_VG_SEL<<16);
|
2743 |
|
|
newlan |= (HP100_DOT3_MAC)<<8;
|
2744 |
|
|
hp100_andb( ~HP100_AUTO_MODE, MAC_CFG_3); /* Autosel off */
|
2745 |
|
|
hp100_outl(newlan, 10_LAN_CFG_1);
|
2746 |
|
|
|
2747 |
|
|
/* Conditionally stall for 5sec on VG selected. */
|
2748 |
|
|
time=jiffies+(HZ*5);
|
2749 |
|
|
do{
|
2750 |
|
|
if( !(hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST) ) break;
|
2751 |
|
|
} while(time>jiffies);
|
2752 |
|
|
|
2753 |
|
|
hp100_orb( HP100_AUTO_MODE, MAC_CFG_3); /* Autosel back on */
|
2754 |
|
|
hp100_outl(savelan, 10_LAN_CFG_1);
|
2755 |
|
|
}
|
2756 |
|
|
|
2757 |
|
|
time=jiffies+(3*HZ); /* Timeout 3s */
|
2758 |
|
|
do {
|
2759 |
|
|
if ( (hp100_inb( VG_LAN_CFG_1 )&HP100_LINK_CABLE_ST) == 0) break;
|
2760 |
|
|
} while (time>jiffies);
|
2761 |
|
|
|
2762 |
|
|
if(time<=jiffies)
|
2763 |
|
|
{
|
2764 |
|
|
#ifdef HP100_DEBUG
|
2765 |
|
|
printk( "hp100: %s: down_vg_link: timeout\n", dev->name );
|
2766 |
|
|
#endif
|
2767 |
|
|
return -EIO;
|
2768 |
|
|
}
|
2769 |
|
|
|
2770 |
|
|
time=jiffies+(2*HZ); /* This seems to take a while.... */
|
2771 |
|
|
do {} while (time>jiffies);
|
2772 |
|
|
|
2773 |
|
|
return 0;
|
2774 |
|
|
}
|
2775 |
|
|
|
2776 |
|
|
|
2777 |
|
|
static int hp100_login_to_vg_hub( struct device *dev, u_short force_relogin )
|
2778 |
|
|
{
|
2779 |
|
|
int ioaddr = dev->base_addr;
|
2780 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2781 |
|
|
u_short val=0;
|
2782 |
|
|
unsigned long time;
|
2783 |
|
|
int startst;
|
2784 |
|
|
|
2785 |
|
|
#ifdef HP100_DEBUG_B
|
2786 |
|
|
hp100_outw( 0x4225, TRACE );
|
2787 |
|
|
printk("hp100: %s: login_to_vg_hub\n", dev->name);
|
2788 |
|
|
#endif
|
2789 |
|
|
|
2790 |
|
|
/* Initiate a login sequence iff VG MAC is enabled and either Load Address
|
2791 |
|
|
* bit is zero or the force relogin flag is set (e.g. due to MAC address or
|
2792 |
|
|
* promiscuous mode change)
|
2793 |
|
|
*/
|
2794 |
|
|
hp100_page( MAC_CTRL );
|
2795 |
|
|
startst=hp100_inb( VG_LAN_CFG_1 );
|
2796 |
|
|
if((force_relogin==TRUE)||(hp100_inb( MAC_CFG_4 )&HP100_MAC_SEL_ST))
|
2797 |
|
|
{
|
2798 |
|
|
#ifdef HP100_DEBUG_TRAINING
|
2799 |
|
|
printk("hp100: %s: Start training\n", dev->name);
|
2800 |
|
|
#endif
|
2801 |
|
|
|
2802 |
|
|
/* Ensure VG Reset bit is 1 (i.e., do not reset)*/
|
2803 |
|
|
hp100_orb( HP100_VG_RESET , VG_LAN_CFG_1 );
|
2804 |
|
|
|
2805 |
|
|
/* If Lassen AND auto-select-mode AND VG tones were sensed on */
|
2806 |
|
|
/* entry then temporarily put them into force 100Mbit mode */
|
2807 |
|
|
if((lp->chip==HP100_CHIPID_LASSEN)&&( startst & HP100_LINK_CABLE_ST ) )
|
2808 |
|
|
hp100_andb( ~HP100_DOT3_MAC, 10_LAN_CFG_2 );
|
2809 |
|
|
|
2810 |
|
|
/* Drop the VG link by zeroing Link Up Command and Load Address */
|
2811 |
|
|
hp100_andb( ~(HP100_LINK_CMD/* |HP100_LOAD_ADDR */), VG_LAN_CFG_1);
|
2812 |
|
|
|
2813 |
|
|
#ifdef HP100_DEBUG_TRAINING
|
2814 |
|
|
printk("hp100: %s: Bring down the link\n", dev->name);
|
2815 |
|
|
#endif
|
2816 |
|
|
|
2817 |
|
|
/* Wait for link to drop */
|
2818 |
|
|
time = jiffies + (HZ/10);
|
2819 |
|
|
do {
|
2820 |
|
|
if (~(hp100_inb( VG_LAN_CFG_1 )& HP100_LINK_UP_ST) ) break;
|
2821 |
|
|
} while (time>jiffies);
|
2822 |
|
|
|
2823 |
|
|
/* Start an addressed training and optionally request promiscuous port */
|
2824 |
|
|
if ( (dev->flags) & IFF_PROMISC )
|
2825 |
|
|
{
|
2826 |
|
|
hp100_orb( HP100_PROM_MODE, VG_LAN_CFG_2);
|
2827 |
|
|
if(lp->chip==HP100_CHIPID_LASSEN)
|
2828 |
|
|
hp100_orw( HP100_MACRQ_PROMSC, TRAIN_REQUEST );
|
2829 |
|
|
}
|
2830 |
|
|
else
|
2831 |
|
|
{
|
2832 |
|
|
hp100_andb( ~HP100_PROM_MODE, VG_LAN_CFG_2);
|
2833 |
|
|
/* For ETR parts we need to reset the prom. bit in the training
|
2834 |
|
|
* register, otherwise promiscious mode won't be disabled.
|
2835 |
|
|
*/
|
2836 |
|
|
if(lp->chip==HP100_CHIPID_LASSEN)
|
2837 |
|
|
{
|
2838 |
|
|
hp100_andw( ~HP100_MACRQ_PROMSC, TRAIN_REQUEST );
|
2839 |
|
|
}
|
2840 |
|
|
}
|
2841 |
|
|
|
2842 |
|
|
/* With ETR parts, frame format request bits can be set. */
|
2843 |
|
|
if(lp->chip==HP100_CHIPID_LASSEN)
|
2844 |
|
|
hp100_orb( HP100_MACRQ_FRAMEFMT_EITHER, TRAIN_REQUEST);
|
2845 |
|
|
|
2846 |
|
|
hp100_orb( HP100_LINK_CMD|HP100_LOAD_ADDR|HP100_VG_RESET, VG_LAN_CFG_1);
|
2847 |
|
|
|
2848 |
|
|
/* Note: Next wait could be omitted for Hood and earlier chips under */
|
2849 |
|
|
/* certain circumstances */
|
2850 |
|
|
/* TODO: check if hood/earlier and skip wait. */
|
2851 |
|
|
|
2852 |
|
|
/* Wait for either short timeout for VG tones or long for login */
|
2853 |
|
|
/* Wait for the card hardware to signalise link cable status ok... */
|
2854 |
|
|
hp100_page( MAC_CTRL );
|
2855 |
|
|
time = jiffies + ( 1*HZ ); /* 1 sec timeout for cable st */
|
2856 |
|
|
do {
|
2857 |
|
|
if ( hp100_inb( VG_LAN_CFG_1 ) & HP100_LINK_CABLE_ST ) break;
|
2858 |
|
|
} while ( jiffies < time );
|
2859 |
|
|
|
2860 |
|
|
if ( jiffies >= time )
|
2861 |
|
|
{
|
2862 |
|
|
#ifdef HP100_DEBUG_TRAINING
|
2863 |
|
|
printk( "hp100: %s: Link cable status not ok? Training aborted.\n", dev->name );
|
2864 |
|
|
#endif
|
2865 |
|
|
}
|
2866 |
|
|
else
|
2867 |
|
|
{
|
2868 |
|
|
#ifdef HP100_DEBUG_TRAINING
|
2869 |
|
|
printk( "hp100: %s: HUB tones detected. Trying to train.\n", dev->name);
|
2870 |
|
|
#endif
|
2871 |
|
|
|
2872 |
|
|
time = jiffies + ( 2*HZ ); /* again a timeout */
|
2873 |
|
|
do {
|
2874 |
|
|
val = hp100_inb( VG_LAN_CFG_1 );
|
2875 |
|
|
if ( (val & ( HP100_LINK_UP_ST )) )
|
2876 |
|
|
{
|
2877 |
|
|
#ifdef HP100_DEBUG_TRAINING
|
2878 |
|
|
printk( "hp100: %s: Passed training.\n", dev->name);
|
2879 |
|
|
#endif
|
2880 |
|
|
break;
|
2881 |
|
|
}
|
2882 |
|
|
} while ( time > jiffies );
|
2883 |
|
|
}
|
2884 |
|
|
|
2885 |
|
|
/* If LINK_UP_ST is set, then we are logged into the hub. */
|
2886 |
|
|
if ( (jiffies<=time) && (val & HP100_LINK_UP_ST) )
|
2887 |
|
|
{
|
2888 |
|
|
#ifdef HP100_DEBUG_TRAINING
|
2889 |
|
|
printk( "hp100: %s: Successfully logged into the HUB.\n", dev->name);
|
2890 |
|
|
if(lp->chip==HP100_CHIPID_LASSEN)
|
2891 |
|
|
{
|
2892 |
|
|
val = hp100_inw(TRAIN_ALLOW);
|
2893 |
|
|
printk( "hp100: %s: Card supports 100VG MAC Version \"%s\" ",
|
2894 |
|
|
dev->name,(hp100_inw(TRAIN_REQUEST)&HP100_CARD_MACVER) ? "802.12" : "Pre");
|
2895 |
|
|
printk( "Driver will use MAC Version \"%s\"\n",
|
2896 |
|
|
( val & HP100_HUB_MACVER) ? "802.12" : "Pre" );
|
2897 |
|
|
printk( "hp100: %s: Frame format is %s.\n",dev->name,(val&HP100_MALLOW_FRAMEFMT)?"802.5":"802.3");
|
2898 |
|
|
}
|
2899 |
|
|
#endif
|
2900 |
|
|
}
|
2901 |
|
|
else
|
2902 |
|
|
{
|
2903 |
|
|
/* If LINK_UP_ST is not set, login was not successful */
|
2904 |
|
|
printk("hp100: %s: Problem logging into the HUB.\n",dev->name);
|
2905 |
|
|
if(lp->chip==HP100_CHIPID_LASSEN)
|
2906 |
|
|
{
|
2907 |
|
|
/* Check allowed Register to find out why there is a problem. */
|
2908 |
|
|
val = hp100_inw( TRAIN_ALLOW ); /* wont work on non-ETR card */
|
2909 |
|
|
#ifdef HP100_DEBUG_TRAINING
|
2910 |
|
|
printk("hp100: %s: MAC Configuration requested: 0x%04x, HUB allowed: 0x%04x\n", dev->name, hp100_inw(TRAIN_REQUEST), val);
|
2911 |
|
|
#endif
|
2912 |
|
|
if ( val & HP100_MALLOW_ACCDENIED )
|
2913 |
|
|
printk("hp100: %s: HUB access denied.\n", dev->name);
|
2914 |
|
|
if ( val & HP100_MALLOW_CONFIGURE )
|
2915 |
|
|
printk("hp100: %s: MAC Configuration is incompatible with the Network.\n", dev->name);
|
2916 |
|
|
if ( val & HP100_MALLOW_DUPADDR )
|
2917 |
|
|
printk("hp100: %s: Duplicate MAC Address on the Network.\n", dev->name);
|
2918 |
|
|
}
|
2919 |
|
|
}
|
2920 |
|
|
|
2921 |
|
|
/* If we have put the chip into forced 100 Mbit mode earlier, go back */
|
2922 |
|
|
/* to auto-select mode */
|
2923 |
|
|
|
2924 |
|
|
if( (lp->chip==HP100_CHIPID_LASSEN)&&(startst & HP100_LINK_CABLE_ST) )
|
2925 |
|
|
{
|
2926 |
|
|
hp100_page( MAC_CTRL );
|
2927 |
|
|
hp100_orb( HP100_DOT3_MAC, 10_LAN_CFG_2 );
|
2928 |
|
|
}
|
2929 |
|
|
|
2930 |
|
|
val=hp100_inb(VG_LAN_CFG_1);
|
2931 |
|
|
|
2932 |
|
|
/* Clear the MISC_ERROR Interrupt, which might be generated when doing the relogin */
|
2933 |
|
|
hp100_page(PERFORMANCE);
|
2934 |
|
|
hp100_outw( HP100_MISC_ERROR, IRQ_STATUS);
|
2935 |
|
|
|
2936 |
|
|
if (val&HP100_LINK_UP_ST)
|
2937 |
|
|
return(0); /* login was ok */
|
2938 |
|
|
else
|
2939 |
|
|
{
|
2940 |
|
|
printk("hp100: %s: Training failed.\n", dev->name);
|
2941 |
|
|
hp100_down_vg_link( dev );
|
2942 |
|
|
return -EIO;
|
2943 |
|
|
}
|
2944 |
|
|
}
|
2945 |
|
|
/* no forced relogin & already link there->no training. */
|
2946 |
|
|
return -EIO;
|
2947 |
|
|
}
|
2948 |
|
|
|
2949 |
|
|
|
2950 |
|
|
static void hp100_cascade_reset( struct device *dev, u_short enable )
|
2951 |
|
|
{
|
2952 |
|
|
int ioaddr = dev->base_addr;
|
2953 |
|
|
struct hp100_private *lp = (struct hp100_private *)dev->priv;
|
2954 |
|
|
int i;
|
2955 |
|
|
|
2956 |
|
|
#ifdef HP100_DEBUG_B
|
2957 |
|
|
hp100_outw( 0x4226, TRACE );
|
2958 |
|
|
printk("hp100: %s: cascade_reset\n", dev->name);
|
2959 |
|
|
#endif
|
2960 |
|
|
|
2961 |
|
|
if (enable==TRUE)
|
2962 |
|
|
{
|
2963 |
|
|
hp100_outw( HP100_HW_RST | HP100_RESET_LB, OPTION_LSW );
|
2964 |
|
|
if(lp->chip==HP100_CHIPID_LASSEN)
|
2965 |
|
|
{
|
2966 |
|
|
/* Lassen requires a PCI transmit fifo reset */
|
2967 |
|
|
hp100_page( HW_MAP );
|
2968 |
|
|
hp100_andb( ~HP100_PCI_RESET, PCICTRL2 );
|
2969 |
|
|
hp100_orb( HP100_PCI_RESET, PCICTRL2 );
|
2970 |
|
|
/* Wait for min. 300 ns */
|
2971 |
|
|
/* we cant use jiffies here, because it may be */
|
2972 |
|
|
/* that we have disabled the timer... */
|
2973 |
|
|
for (i=0; i<0xffff; i++);
|
2974 |
|
|
hp100_andb( ~HP100_PCI_RESET, PCICTRL2 );
|
2975 |
|
|
hp100_page( PERFORMANCE );
|
2976 |
|
|
}
|
2977 |
|
|
}
|
2978 |
|
|
else
|
2979 |
|
|
{ /* bring out of reset */
|
2980 |
|
|
hp100_outw(HP100_HW_RST|HP100_SET_LB, OPTION_LSW);
|
2981 |
|
|
for (i=0; i<0xffff; i++ );
|
2982 |
|
|
hp100_page(PERFORMANCE);
|
2983 |
|
|
}
|
2984 |
|
|
}
|
2985 |
|
|
|
2986 |
|
|
#ifdef HP100_DEBUG
|
2987 |
|
|
void hp100_RegisterDump( struct device *dev )
|
2988 |
|
|
{
|
2989 |
|
|
int ioaddr=dev->base_addr;
|
2990 |
|
|
int Page;
|
2991 |
|
|
int Register;
|
2992 |
|
|
|
2993 |
|
|
/* Dump common registers */
|
2994 |
|
|
printk("hp100: %s: Cascade Register Dump\n", dev->name);
|
2995 |
|
|
printk("hardware id #1: 0x%.2x\n",hp100_inb(HW_ID));
|
2996 |
|
|
printk("hardware id #2/paging: 0x%.2x\n",hp100_inb(PAGING));
|
2997 |
|
|
printk("option #1: 0x%.4x\n",hp100_inw(OPTION_LSW));
|
2998 |
|
|
printk("option #2: 0x%.4x\n",hp100_inw(OPTION_MSW));
|
2999 |
|
|
|
3000 |
|
|
/* Dump paged registers */
|
3001 |
|
|
for (Page = 0; Page < 8; Page++)
|
3002 |
|
|
{
|
3003 |
|
|
/* Dump registers */
|
3004 |
|
|
printk("page: 0x%.2x\n",Page);
|
3005 |
|
|
outw( Page, ioaddr+0x02);
|
3006 |
|
|
for (Register = 0x8; Register < 0x22; Register += 2)
|
3007 |
|
|
{
|
3008 |
|
|
/* Display Register contents except data port */
|
3009 |
|
|
if (((Register != 0x10) && (Register != 0x12)) || (Page > 0))
|
3010 |
|
|
{
|
3011 |
|
|
printk("0x%.2x = 0x%.4x\n",Register,inw(ioaddr+Register));
|
3012 |
|
|
}
|
3013 |
|
|
}
|
3014 |
|
|
}
|
3015 |
|
|
hp100_page(PERFORMANCE);
|
3016 |
|
|
}
|
3017 |
|
|
#endif
|
3018 |
|
|
|
3019 |
|
|
|
3020 |
|
|
|
3021 |
|
|
/*
|
3022 |
|
|
* module section
|
3023 |
|
|
*/
|
3024 |
|
|
|
3025 |
|
|
#ifdef MODULE
|
3026 |
|
|
|
3027 |
|
|
/* Parameters set by insmod */
|
3028 |
|
|
int hp100_port[5] = { 0, -1, -1, -1, -1 };
|
3029 |
|
|
#ifdef LINUX_2_1
|
3030 |
|
|
MODULE_PARM(hp100_port, "1-5i");
|
3031 |
|
|
#endif
|
3032 |
|
|
|
3033 |
|
|
#ifdef LINUX_2_1
|
3034 |
|
|
char hp100_name[5][IFNAMSIZ] = { "", "", "", "", "" };
|
3035 |
|
|
MODULE_PARM(hp100_name, "1-5c" __MODULE_STRING(IFNAMSIZ));
|
3036 |
|
|
#else
|
3037 |
|
|
static char devname[5][IFNAMSIZ] = { "", "", "", "", "" };
|
3038 |
|
|
static char *hp100_name[5] = { devname[0], devname[1],
|
3039 |
|
|
devname[2], devname[3],
|
3040 |
|
|
devname[4] };
|
3041 |
|
|
#endif
|
3042 |
|
|
|
3043 |
|
|
/* List of devices */
|
3044 |
|
|
static struct device *hp100_devlist[5] = { NULL, NULL, NULL, NULL, NULL };
|
3045 |
|
|
|
3046 |
|
|
/*
|
3047 |
|
|
* Note: if you have more than five 100vg cards in your pc, feel free to
|
3048 |
|
|
* increase this value
|
3049 |
|
|
*/
|
3050 |
|
|
|
3051 |
|
|
/*
|
3052 |
|
|
* Note: to register three eisa or pci devices, use:
|
3053 |
|
|
* option hp100 hp100_port=0,0,0
|
3054 |
|
|
* to register one card at io 0x280 as eth239, use:
|
3055 |
|
|
* option hp100 hp100_port=0x280 hp100_name=eth239
|
3056 |
|
|
*/
|
3057 |
|
|
|
3058 |
|
|
int init_module( void )
|
3059 |
|
|
{
|
3060 |
|
|
int i, cards;
|
3061 |
|
|
|
3062 |
|
|
if (hp100_port == 0 && !EISA_bus && !pcibios_present())
|
3063 |
|
|
printk("hp100: You should not use auto-probing with insmod!\n");
|
3064 |
|
|
|
3065 |
|
|
/* Loop on all possible base addresses */
|
3066 |
|
|
i = -1; cards = 0;
|
3067 |
|
|
while((hp100_port[++i] != -1) && (i < 5))
|
3068 |
|
|
{
|
3069 |
|
|
/* Create device and set basics args */
|
3070 |
|
|
hp100_devlist[i] = kmalloc(sizeof(struct device), GFP_KERNEL);
|
3071 |
|
|
memset(hp100_devlist[i], 0x00, sizeof(struct device));
|
3072 |
|
|
hp100_devlist[i]->name = hp100_name[i];
|
3073 |
|
|
hp100_devlist[i]->base_addr = hp100_port[i];
|
3074 |
|
|
hp100_devlist[i]->init = &hp100_probe;
|
3075 |
|
|
|
3076 |
|
|
/* Try to create the device */
|
3077 |
|
|
if(register_netdev(hp100_devlist[i]) != 0)
|
3078 |
|
|
{
|
3079 |
|
|
/* DeAllocate everything */
|
3080 |
|
|
/* Note: if dev->priv is mallocated, there is no way to fail */
|
3081 |
|
|
kfree_s(hp100_devlist[i], sizeof(struct device));
|
3082 |
|
|
hp100_devlist[i] = (struct device *) NULL;
|
3083 |
|
|
}
|
3084 |
|
|
else
|
3085 |
|
|
cards++;
|
3086 |
|
|
} /* Loop over all devices */
|
3087 |
|
|
|
3088 |
|
|
return cards > 0 ? 0 : -ENODEV;
|
3089 |
|
|
}
|
3090 |
|
|
|
3091 |
|
|
void cleanup_module( void )
|
3092 |
|
|
{
|
3093 |
|
|
int i;
|
3094 |
|
|
|
3095 |
|
|
/* TODO: Check if all skb's are released/freed. */
|
3096 |
|
|
for(i = 0; i < 5; i++)
|
3097 |
|
|
if(hp100_devlist[i] != (struct device *) NULL)
|
3098 |
|
|
{
|
3099 |
|
|
unregister_netdev( hp100_devlist[i] );
|
3100 |
|
|
release_region( hp100_devlist[i]->base_addr, HP100_REGION_SIZE );
|
3101 |
|
|
if( ((struct hp100_private *)hp100_devlist[i]->priv)->mode==1 ) /* busmaster */
|
3102 |
|
|
kfree_s( ((struct hp100_private *)hp100_devlist[i]->priv)->page_vaddr, MAX_RINGSIZE+0x0f);
|
3103 |
|
|
if ( ((struct hp100_private *)hp100_devlist[i]->priv) -> mem_ptr_virt )
|
3104 |
|
|
iounmap( ((struct hp100_private *)hp100_devlist[i]->priv) -> mem_ptr_virt );
|
3105 |
|
|
kfree_s( hp100_devlist[i]->priv, sizeof( struct hp100_private ) );
|
3106 |
|
|
hp100_devlist[i]->priv = NULL;
|
3107 |
|
|
kfree_s(hp100_devlist[i], sizeof(struct device));
|
3108 |
|
|
hp100_devlist[i] = (struct device *) NULL;
|
3109 |
|
|
}
|
3110 |
|
|
}
|
3111 |
|
|
|
3112 |
|
|
#endif /* MODULE */
|
3113 |
|
|
|
3114 |
|
|
|
3115 |
|
|
|
3116 |
|
|
/*
|
3117 |
|
|
* Local variables:
|
3118 |
|
|
* compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c hp100.c"
|
3119 |
|
|
* c-indent-level: 2
|
3120 |
|
|
* tab-width: 8
|
3121 |
|
|
* End:
|
3122 |
|
|
*/
|