1 |
62 |
marcus.erl |
/*
|
2 |
|
|
* Wavelan Pcmcia driver
|
3 |
|
|
*
|
4 |
|
|
* Jean II - HPLB '96
|
5 |
|
|
*
|
6 |
|
|
* Reorganisation and extension of the driver.
|
7 |
|
|
* Original copyright follow. See wavelan_cs.p.h for details.
|
8 |
|
|
*
|
9 |
|
|
* This code is derived from Anthony D. Joseph's code and all the changes here
|
10 |
|
|
* are also under the original copyright below.
|
11 |
|
|
*
|
12 |
|
|
* This code supports version 2.00 of WaveLAN/PCMCIA cards (2.4GHz), and
|
13 |
|
|
* can work on Linux 2.0.36 with support of David Hinds' PCMCIA Card Services
|
14 |
|
|
*
|
15 |
|
|
* Joe Finney (joe@comp.lancs.ac.uk) at Lancaster University in UK added
|
16 |
|
|
* critical code in the routine to initialize the Modem Management Controller.
|
17 |
|
|
*
|
18 |
|
|
* Thanks to Alan Cox and Bruce Janson for their advice.
|
19 |
|
|
*
|
20 |
|
|
* -- Yunzhou Li (scip4166@nus.sg)
|
21 |
|
|
*
|
22 |
|
|
#ifdef WAVELAN_ROAMING
|
23 |
|
|
* Roaming support added 07/22/98 by Justin Seger (jseger@media.mit.edu)
|
24 |
|
|
* based on patch by Joe Finney from Lancaster University.
|
25 |
|
|
#endif
|
26 |
|
|
*
|
27 |
|
|
* Lucent (formerly AT&T GIS, formerly NCR) WaveLAN PCMCIA card: An
|
28 |
|
|
* Ethernet-like radio transceiver controlled by an Intel 82593 coprocessor.
|
29 |
|
|
*
|
30 |
|
|
* A non-shared memory PCMCIA ethernet driver for linux
|
31 |
|
|
*
|
32 |
|
|
* ISA version modified to support PCMCIA by Anthony Joseph (adj@lcs.mit.edu)
|
33 |
|
|
*
|
34 |
|
|
*
|
35 |
|
|
* Joseph O'Sullivan & John Langford (josullvn@cs.cmu.edu & jcl@cs.cmu.edu)
|
36 |
|
|
*
|
37 |
|
|
* Apr 2 '98 made changes to bring the i82593 control/int handling in line
|
38 |
|
|
* with offical specs...
|
39 |
|
|
*
|
40 |
|
|
****************************************************************************
|
41 |
|
|
* Copyright 1995
|
42 |
|
|
* Anthony D. Joseph
|
43 |
|
|
* Massachusetts Institute of Technology
|
44 |
|
|
*
|
45 |
|
|
* Permission to use, copy, modify, and distribute this program
|
46 |
|
|
* for any purpose and without fee is hereby granted, provided
|
47 |
|
|
* that this copyright and permission notice appear on all copies
|
48 |
|
|
* and supporting documentation, the name of M.I.T. not be used
|
49 |
|
|
* in advertising or publicity pertaining to distribution of the
|
50 |
|
|
* program without specific prior permission, and notice be given
|
51 |
|
|
* in supporting documentation that copying and distribution is
|
52 |
|
|
* by permission of M.I.T. M.I.T. makes no representations about
|
53 |
|
|
* the suitability of this software for any purpose. It is pro-
|
54 |
|
|
* vided "as is" without express or implied warranty.
|
55 |
|
|
****************************************************************************
|
56 |
|
|
*
|
57 |
|
|
*/
|
58 |
|
|
|
59 |
|
|
/* Do *NOT* add other headers here, you are guaranteed to be wrong - Jean II */
|
60 |
|
|
#include "wavelan_cs.p.h" /* Private header */
|
61 |
|
|
|
62 |
|
|
#ifdef WAVELAN_ROAMING
|
63 |
|
|
static void wl_cell_expiry(unsigned long data);
|
64 |
|
|
static void wl_del_wavepoint(wavepoint_history *wavepoint, struct net_local *lp);
|
65 |
|
|
static void wv_nwid_filter(unsigned char mode, net_local *lp);
|
66 |
|
|
#endif /* WAVELAN_ROAMING */
|
67 |
|
|
|
68 |
|
|
/************************* MISC SUBROUTINES **************************/
|
69 |
|
|
/*
|
70 |
|
|
* Subroutines which won't fit in one of the following category
|
71 |
|
|
* (wavelan modem or i82593)
|
72 |
|
|
*/
|
73 |
|
|
|
74 |
|
|
#ifdef STRUCT_CHECK
|
75 |
|
|
/*------------------------------------------------------------------*/
|
76 |
|
|
/*
|
77 |
|
|
* Sanity routine to verify the sizes of the various WaveLAN interface
|
78 |
|
|
* structures.
|
79 |
|
|
*/
|
80 |
|
|
static char *
|
81 |
|
|
wv_structuct_check(void)
|
82 |
|
|
{
|
83 |
|
|
#define SC(t,s,n) if (sizeof(t) != s) return(n);
|
84 |
|
|
|
85 |
|
|
SC(psa_t, PSA_SIZE, "psa_t");
|
86 |
|
|
SC(mmw_t, MMW_SIZE, "mmw_t");
|
87 |
|
|
SC(mmr_t, MMR_SIZE, "mmr_t");
|
88 |
|
|
|
89 |
|
|
#undef SC
|
90 |
|
|
|
91 |
|
|
return((char *) NULL);
|
92 |
|
|
} /* wv_structuct_check */
|
93 |
|
|
#endif /* STRUCT_CHECK */
|
94 |
|
|
|
95 |
|
|
/******************* MODEM MANAGEMENT SUBROUTINES *******************/
|
96 |
|
|
/*
|
97 |
|
|
* Useful subroutines to manage the modem of the wavelan
|
98 |
|
|
*/
|
99 |
|
|
|
100 |
|
|
/*------------------------------------------------------------------*/
|
101 |
|
|
/*
|
102 |
|
|
* Read from card's Host Adaptor Status Register.
|
103 |
|
|
*/
|
104 |
|
|
static inline u_char
|
105 |
|
|
hasr_read(u_long base)
|
106 |
|
|
{
|
107 |
|
|
return(inb(HASR(base)));
|
108 |
|
|
} /* hasr_read */
|
109 |
|
|
|
110 |
|
|
/*------------------------------------------------------------------*/
|
111 |
|
|
/*
|
112 |
|
|
* Write to card's Host Adapter Command Register.
|
113 |
|
|
*/
|
114 |
|
|
static inline void
|
115 |
|
|
hacr_write(u_long base,
|
116 |
|
|
u_char hacr)
|
117 |
|
|
{
|
118 |
|
|
outb(hacr, HACR(base));
|
119 |
|
|
} /* hacr_write */
|
120 |
|
|
|
121 |
|
|
/*------------------------------------------------------------------*/
|
122 |
|
|
/*
|
123 |
|
|
* Write to card's Host Adapter Command Register. Include a delay for
|
124 |
|
|
* those times when it is needed.
|
125 |
|
|
*/
|
126 |
|
|
static inline void
|
127 |
|
|
hacr_write_slow(u_long base,
|
128 |
|
|
u_char hacr)
|
129 |
|
|
{
|
130 |
|
|
hacr_write(base, hacr);
|
131 |
|
|
/* delay might only be needed sometimes */
|
132 |
|
|
mdelay(1);
|
133 |
|
|
} /* hacr_write_slow */
|
134 |
|
|
|
135 |
|
|
/*------------------------------------------------------------------*/
|
136 |
|
|
/*
|
137 |
|
|
* Read the Parameter Storage Area from the WaveLAN card's memory
|
138 |
|
|
*/
|
139 |
|
|
static void
|
140 |
|
|
psa_read(struct net_device * dev,
|
141 |
|
|
int o, /* offset in PSA */
|
142 |
|
|
u_char * b, /* buffer to fill */
|
143 |
|
|
int n) /* size to read */
|
144 |
|
|
{
|
145 |
|
|
net_local *lp = netdev_priv(dev);
|
146 |
|
|
u_char __iomem *ptr = lp->mem + PSA_ADDR + (o << 1);
|
147 |
|
|
|
148 |
|
|
while(n-- > 0)
|
149 |
|
|
{
|
150 |
|
|
*b++ = readb(ptr);
|
151 |
|
|
/* Due to a lack of address decode pins, the WaveLAN PCMCIA card
|
152 |
|
|
* only supports reading even memory addresses. That means the
|
153 |
|
|
* increment here MUST be two.
|
154 |
|
|
* Because of that, we can't use memcpy_fromio()...
|
155 |
|
|
*/
|
156 |
|
|
ptr += 2;
|
157 |
|
|
}
|
158 |
|
|
} /* psa_read */
|
159 |
|
|
|
160 |
|
|
/*------------------------------------------------------------------*/
|
161 |
|
|
/*
|
162 |
|
|
* Write the Paramter Storage Area to the WaveLAN card's memory
|
163 |
|
|
*/
|
164 |
|
|
static void
|
165 |
|
|
psa_write(struct net_device * dev,
|
166 |
|
|
int o, /* Offset in psa */
|
167 |
|
|
u_char * b, /* Buffer in memory */
|
168 |
|
|
int n) /* Length of buffer */
|
169 |
|
|
{
|
170 |
|
|
net_local *lp = netdev_priv(dev);
|
171 |
|
|
u_char __iomem *ptr = lp->mem + PSA_ADDR + (o << 1);
|
172 |
|
|
int count = 0;
|
173 |
|
|
kio_addr_t base = dev->base_addr;
|
174 |
|
|
/* As there seem to have no flag PSA_BUSY as in the ISA model, we are
|
175 |
|
|
* oblige to verify this address to know when the PSA is ready... */
|
176 |
|
|
volatile u_char __iomem *verify = lp->mem + PSA_ADDR +
|
177 |
|
|
(psaoff(0, psa_comp_number) << 1);
|
178 |
|
|
|
179 |
|
|
/* Authorize writing to PSA */
|
180 |
|
|
hacr_write(base, HACR_PWR_STAT | HACR_ROM_WEN);
|
181 |
|
|
|
182 |
|
|
while(n-- > 0)
|
183 |
|
|
{
|
184 |
|
|
/* write to PSA */
|
185 |
|
|
writeb(*b++, ptr);
|
186 |
|
|
ptr += 2;
|
187 |
|
|
|
188 |
|
|
/* I don't have the spec, so I don't know what the correct
|
189 |
|
|
* sequence to write is. This hack seem to work for me... */
|
190 |
|
|
count = 0;
|
191 |
|
|
while((readb(verify) != PSA_COMP_PCMCIA_915) && (count++ < 100))
|
192 |
|
|
mdelay(1);
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
/* Put the host interface back in standard state */
|
196 |
|
|
hacr_write(base, HACR_DEFAULT);
|
197 |
|
|
} /* psa_write */
|
198 |
|
|
|
199 |
|
|
#ifdef SET_PSA_CRC
|
200 |
|
|
/*------------------------------------------------------------------*/
|
201 |
|
|
/*
|
202 |
|
|
* Calculate the PSA CRC
|
203 |
|
|
* Thanks to Valster, Nico <NVALSTER@wcnd.nl.lucent.com> for the code
|
204 |
|
|
* NOTE: By specifying a length including the CRC position the
|
205 |
|
|
* returned value should be zero. (i.e. a correct checksum in the PSA)
|
206 |
|
|
*
|
207 |
|
|
* The Windows drivers don't use the CRC, but the AP and the PtP tool
|
208 |
|
|
* depend on it.
|
209 |
|
|
*/
|
210 |
|
|
static u_short
|
211 |
|
|
psa_crc(unsigned char * psa, /* The PSA */
|
212 |
|
|
int size) /* Number of short for CRC */
|
213 |
|
|
{
|
214 |
|
|
int byte_cnt; /* Loop on the PSA */
|
215 |
|
|
u_short crc_bytes = 0; /* Data in the PSA */
|
216 |
|
|
int bit_cnt; /* Loop on the bits of the short */
|
217 |
|
|
|
218 |
|
|
for(byte_cnt = 0; byte_cnt < size; byte_cnt++ )
|
219 |
|
|
{
|
220 |
|
|
crc_bytes ^= psa[byte_cnt]; /* Its an xor */
|
221 |
|
|
|
222 |
|
|
for(bit_cnt = 1; bit_cnt < 9; bit_cnt++ )
|
223 |
|
|
{
|
224 |
|
|
if(crc_bytes & 0x0001)
|
225 |
|
|
crc_bytes = (crc_bytes >> 1) ^ 0xA001;
|
226 |
|
|
else
|
227 |
|
|
crc_bytes >>= 1 ;
|
228 |
|
|
}
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
return crc_bytes;
|
232 |
|
|
} /* psa_crc */
|
233 |
|
|
#endif /* SET_PSA_CRC */
|
234 |
|
|
|
235 |
|
|
/*------------------------------------------------------------------*/
|
236 |
|
|
/*
|
237 |
|
|
* update the checksum field in the Wavelan's PSA
|
238 |
|
|
*/
|
239 |
|
|
static void
|
240 |
|
|
update_psa_checksum(struct net_device * dev)
|
241 |
|
|
{
|
242 |
|
|
#ifdef SET_PSA_CRC
|
243 |
|
|
psa_t psa;
|
244 |
|
|
u_short crc;
|
245 |
|
|
|
246 |
|
|
/* read the parameter storage area */
|
247 |
|
|
psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa));
|
248 |
|
|
|
249 |
|
|
/* update the checksum */
|
250 |
|
|
crc = psa_crc((unsigned char *) &psa,
|
251 |
|
|
sizeof(psa) - sizeof(psa.psa_crc[0]) - sizeof(psa.psa_crc[1])
|
252 |
|
|
- sizeof(psa.psa_crc_status));
|
253 |
|
|
|
254 |
|
|
psa.psa_crc[0] = crc & 0xFF;
|
255 |
|
|
psa.psa_crc[1] = (crc & 0xFF00) >> 8;
|
256 |
|
|
|
257 |
|
|
/* Write it ! */
|
258 |
|
|
psa_write(dev, (char *)&psa.psa_crc - (char *)&psa,
|
259 |
|
|
(unsigned char *)&psa.psa_crc, 2);
|
260 |
|
|
|
261 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
262 |
|
|
printk (KERN_DEBUG "%s: update_psa_checksum(): crc = 0x%02x%02x\n",
|
263 |
|
|
dev->name, psa.psa_crc[0], psa.psa_crc[1]);
|
264 |
|
|
|
265 |
|
|
/* Check again (luxury !) */
|
266 |
|
|
crc = psa_crc((unsigned char *) &psa,
|
267 |
|
|
sizeof(psa) - sizeof(psa.psa_crc_status));
|
268 |
|
|
|
269 |
|
|
if(crc != 0)
|
270 |
|
|
printk(KERN_WARNING "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n", dev->name);
|
271 |
|
|
#endif /* DEBUG_IOCTL_INFO */
|
272 |
|
|
#endif /* SET_PSA_CRC */
|
273 |
|
|
} /* update_psa_checksum */
|
274 |
|
|
|
275 |
|
|
/*------------------------------------------------------------------*/
|
276 |
|
|
/*
|
277 |
|
|
* Write 1 byte to the MMC.
|
278 |
|
|
*/
|
279 |
|
|
static inline void
|
280 |
|
|
mmc_out(u_long base,
|
281 |
|
|
u_short o,
|
282 |
|
|
u_char d)
|
283 |
|
|
{
|
284 |
|
|
int count = 0;
|
285 |
|
|
|
286 |
|
|
/* Wait for MMC to go idle */
|
287 |
|
|
while((count++ < 100) && (inb(HASR(base)) & HASR_MMI_BUSY))
|
288 |
|
|
udelay(10);
|
289 |
|
|
|
290 |
|
|
outb((u_char)((o << 1) | MMR_MMI_WR), MMR(base));
|
291 |
|
|
outb(d, MMD(base));
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
/*------------------------------------------------------------------*/
|
295 |
|
|
/*
|
296 |
|
|
* Routine to write bytes to the Modem Management Controller.
|
297 |
|
|
* We start by the end because it is the way it should be !
|
298 |
|
|
*/
|
299 |
|
|
static inline void
|
300 |
|
|
mmc_write(u_long base,
|
301 |
|
|
u_char o,
|
302 |
|
|
u_char * b,
|
303 |
|
|
int n)
|
304 |
|
|
{
|
305 |
|
|
o += n;
|
306 |
|
|
b += n;
|
307 |
|
|
|
308 |
|
|
while(n-- > 0 )
|
309 |
|
|
mmc_out(base, --o, *(--b));
|
310 |
|
|
} /* mmc_write */
|
311 |
|
|
|
312 |
|
|
/*------------------------------------------------------------------*/
|
313 |
|
|
/*
|
314 |
|
|
* Read 1 byte from the MMC.
|
315 |
|
|
* Optimised version for 1 byte, avoid using memory...
|
316 |
|
|
*/
|
317 |
|
|
static inline u_char
|
318 |
|
|
mmc_in(u_long base,
|
319 |
|
|
u_short o)
|
320 |
|
|
{
|
321 |
|
|
int count = 0;
|
322 |
|
|
|
323 |
|
|
while((count++ < 100) && (inb(HASR(base)) & HASR_MMI_BUSY))
|
324 |
|
|
udelay(10);
|
325 |
|
|
outb(o << 1, MMR(base)); /* Set the read address */
|
326 |
|
|
|
327 |
|
|
outb(0, MMD(base)); /* Required dummy write */
|
328 |
|
|
|
329 |
|
|
while((count++ < 100) && (inb(HASR(base)) & HASR_MMI_BUSY))
|
330 |
|
|
udelay(10);
|
331 |
|
|
return (u_char) (inb(MMD(base))); /* Now do the actual read */
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
/*------------------------------------------------------------------*/
|
335 |
|
|
/*
|
336 |
|
|
* Routine to read bytes from the Modem Management Controller.
|
337 |
|
|
* The implementation is complicated by a lack of address lines,
|
338 |
|
|
* which prevents decoding of the low-order bit.
|
339 |
|
|
* (code has just been moved in the above function)
|
340 |
|
|
* We start by the end because it is the way it should be !
|
341 |
|
|
*/
|
342 |
|
|
static inline void
|
343 |
|
|
mmc_read(u_long base,
|
344 |
|
|
u_char o,
|
345 |
|
|
u_char * b,
|
346 |
|
|
int n)
|
347 |
|
|
{
|
348 |
|
|
o += n;
|
349 |
|
|
b += n;
|
350 |
|
|
|
351 |
|
|
while(n-- > 0)
|
352 |
|
|
*(--b) = mmc_in(base, --o);
|
353 |
|
|
} /* mmc_read */
|
354 |
|
|
|
355 |
|
|
/*------------------------------------------------------------------*/
|
356 |
|
|
/*
|
357 |
|
|
* Get the type of encryption available...
|
358 |
|
|
*/
|
359 |
|
|
static inline int
|
360 |
|
|
mmc_encr(u_long base) /* i/o port of the card */
|
361 |
|
|
{
|
362 |
|
|
int temp;
|
363 |
|
|
|
364 |
|
|
temp = mmc_in(base, mmroff(0, mmr_des_avail));
|
365 |
|
|
if((temp != MMR_DES_AVAIL_DES) && (temp != MMR_DES_AVAIL_AES))
|
366 |
|
|
return 0;
|
367 |
|
|
else
|
368 |
|
|
return temp;
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
/*------------------------------------------------------------------*/
|
372 |
|
|
/*
|
373 |
|
|
* Wait for the frequency EEprom to complete a command...
|
374 |
|
|
* I hope this one will be optimally inlined...
|
375 |
|
|
*/
|
376 |
|
|
static inline void
|
377 |
|
|
fee_wait(u_long base, /* i/o port of the card */
|
378 |
|
|
int delay, /* Base delay to wait for */
|
379 |
|
|
int number) /* Number of time to wait */
|
380 |
|
|
{
|
381 |
|
|
int count = 0; /* Wait only a limited time */
|
382 |
|
|
|
383 |
|
|
while((count++ < number) &&
|
384 |
|
|
(mmc_in(base, mmroff(0, mmr_fee_status)) & MMR_FEE_STATUS_BUSY))
|
385 |
|
|
udelay(delay);
|
386 |
|
|
}
|
387 |
|
|
|
388 |
|
|
/*------------------------------------------------------------------*/
|
389 |
|
|
/*
|
390 |
|
|
* Read bytes from the Frequency EEprom (frequency select cards).
|
391 |
|
|
*/
|
392 |
|
|
static void
|
393 |
|
|
fee_read(u_long base, /* i/o port of the card */
|
394 |
|
|
u_short o, /* destination offset */
|
395 |
|
|
u_short * b, /* data buffer */
|
396 |
|
|
int n) /* number of registers */
|
397 |
|
|
{
|
398 |
|
|
b += n; /* Position at the end of the area */
|
399 |
|
|
|
400 |
|
|
/* Write the address */
|
401 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), o + n - 1);
|
402 |
|
|
|
403 |
|
|
/* Loop on all buffer */
|
404 |
|
|
while(n-- > 0)
|
405 |
|
|
{
|
406 |
|
|
/* Write the read command */
|
407 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_READ);
|
408 |
|
|
|
409 |
|
|
/* Wait until EEprom is ready (should be quick !) */
|
410 |
|
|
fee_wait(base, 10, 100);
|
411 |
|
|
|
412 |
|
|
/* Read the value */
|
413 |
|
|
*--b = ((mmc_in(base, mmroff(0, mmr_fee_data_h)) << 8) |
|
414 |
|
|
mmc_in(base, mmroff(0, mmr_fee_data_l)));
|
415 |
|
|
}
|
416 |
|
|
}
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
/*------------------------------------------------------------------*/
|
420 |
|
|
/*
|
421 |
|
|
* Write bytes from the Frequency EEprom (frequency select cards).
|
422 |
|
|
* This is a bit complicated, because the frequency eeprom has to
|
423 |
|
|
* be unprotected and the write enabled.
|
424 |
|
|
* Jean II
|
425 |
|
|
*/
|
426 |
|
|
static void
|
427 |
|
|
fee_write(u_long base, /* i/o port of the card */
|
428 |
|
|
u_short o, /* destination offset */
|
429 |
|
|
u_short * b, /* data buffer */
|
430 |
|
|
int n) /* number of registers */
|
431 |
|
|
{
|
432 |
|
|
b += n; /* Position at the end of the area */
|
433 |
|
|
|
434 |
|
|
#ifdef EEPROM_IS_PROTECTED /* disabled */
|
435 |
|
|
#ifdef DOESNT_SEEM_TO_WORK /* disabled */
|
436 |
|
|
/* Ask to read the protected register */
|
437 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRREAD);
|
438 |
|
|
|
439 |
|
|
fee_wait(base, 10, 100);
|
440 |
|
|
|
441 |
|
|
/* Read the protected register */
|
442 |
|
|
printk("Protected 2 : %02X-%02X\n",
|
443 |
|
|
mmc_in(base, mmroff(0, mmr_fee_data_h)),
|
444 |
|
|
mmc_in(base, mmroff(0, mmr_fee_data_l)));
|
445 |
|
|
#endif /* DOESNT_SEEM_TO_WORK */
|
446 |
|
|
|
447 |
|
|
/* Enable protected register */
|
448 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_EN);
|
449 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PREN);
|
450 |
|
|
|
451 |
|
|
fee_wait(base, 10, 100);
|
452 |
|
|
|
453 |
|
|
/* Unprotect area */
|
454 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), o + n);
|
455 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRWRITE);
|
456 |
|
|
#ifdef DOESNT_SEEM_TO_WORK /* disabled */
|
457 |
|
|
/* Or use : */
|
458 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRCLEAR);
|
459 |
|
|
#endif /* DOESNT_SEEM_TO_WORK */
|
460 |
|
|
|
461 |
|
|
fee_wait(base, 10, 100);
|
462 |
|
|
#endif /* EEPROM_IS_PROTECTED */
|
463 |
|
|
|
464 |
|
|
/* Write enable */
|
465 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_EN);
|
466 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WREN);
|
467 |
|
|
|
468 |
|
|
fee_wait(base, 10, 100);
|
469 |
|
|
|
470 |
|
|
/* Write the EEprom address */
|
471 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), o + n - 1);
|
472 |
|
|
|
473 |
|
|
/* Loop on all buffer */
|
474 |
|
|
while(n-- > 0)
|
475 |
|
|
{
|
476 |
|
|
/* Write the value */
|
477 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_data_h), (*--b) >> 8);
|
478 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_data_l), *b & 0xFF);
|
479 |
|
|
|
480 |
|
|
/* Write the write command */
|
481 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WRITE);
|
482 |
|
|
|
483 |
|
|
/* Wavelan doc says : wait at least 10 ms for EEBUSY = 0 */
|
484 |
|
|
mdelay(10);
|
485 |
|
|
fee_wait(base, 10, 100);
|
486 |
|
|
}
|
487 |
|
|
|
488 |
|
|
/* Write disable */
|
489 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_DS);
|
490 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WDS);
|
491 |
|
|
|
492 |
|
|
fee_wait(base, 10, 100);
|
493 |
|
|
|
494 |
|
|
#ifdef EEPROM_IS_PROTECTED /* disabled */
|
495 |
|
|
/* Reprotect EEprom */
|
496 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), 0x00);
|
497 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRWRITE);
|
498 |
|
|
|
499 |
|
|
fee_wait(base, 10, 100);
|
500 |
|
|
#endif /* EEPROM_IS_PROTECTED */
|
501 |
|
|
}
|
502 |
|
|
|
503 |
|
|
/******************* WaveLAN Roaming routines... ********************/
|
504 |
|
|
|
505 |
|
|
#ifdef WAVELAN_ROAMING /* Conditional compile, see wavelan_cs.h */
|
506 |
|
|
|
507 |
|
|
static unsigned char WAVELAN_BEACON_ADDRESS[] = {0x09,0x00,0x0e,0x20,0x03,0x00};
|
508 |
|
|
|
509 |
|
|
static void wv_roam_init(struct net_device *dev)
|
510 |
|
|
{
|
511 |
|
|
net_local *lp= netdev_priv(dev);
|
512 |
|
|
|
513 |
|
|
/* Do not remove this unless you have a good reason */
|
514 |
|
|
printk(KERN_NOTICE "%s: Warning, you have enabled roaming on"
|
515 |
|
|
" device %s !\n", dev->name, dev->name);
|
516 |
|
|
printk(KERN_NOTICE "Roaming is currently an experimental unsupported feature"
|
517 |
|
|
" of the Wavelan driver.\n");
|
518 |
|
|
printk(KERN_NOTICE "It may work, but may also make the driver behave in"
|
519 |
|
|
" erratic ways or crash.\n");
|
520 |
|
|
|
521 |
|
|
lp->wavepoint_table.head=NULL; /* Initialise WavePoint table */
|
522 |
|
|
lp->wavepoint_table.num_wavepoints=0;
|
523 |
|
|
lp->wavepoint_table.locked=0;
|
524 |
|
|
lp->curr_point=NULL; /* No default WavePoint */
|
525 |
|
|
lp->cell_search=0;
|
526 |
|
|
|
527 |
|
|
lp->cell_timer.data=(long)lp; /* Start cell expiry timer */
|
528 |
|
|
lp->cell_timer.function=wl_cell_expiry;
|
529 |
|
|
lp->cell_timer.expires=jiffies+CELL_TIMEOUT;
|
530 |
|
|
add_timer(&lp->cell_timer);
|
531 |
|
|
|
532 |
|
|
wv_nwid_filter(NWID_PROMISC,lp) ; /* Enter NWID promiscuous mode */
|
533 |
|
|
/* to build up a good WavePoint */
|
534 |
|
|
/* table... */
|
535 |
|
|
printk(KERN_DEBUG "WaveLAN: Roaming enabled on device %s\n",dev->name);
|
536 |
|
|
}
|
537 |
|
|
|
538 |
|
|
static void wv_roam_cleanup(struct net_device *dev)
|
539 |
|
|
{
|
540 |
|
|
wavepoint_history *ptr,*old_ptr;
|
541 |
|
|
net_local *lp= netdev_priv(dev);
|
542 |
|
|
|
543 |
|
|
printk(KERN_DEBUG "WaveLAN: Roaming Disabled on device %s\n",dev->name);
|
544 |
|
|
|
545 |
|
|
/* Fixme : maybe we should check that the timer exist before deleting it */
|
546 |
|
|
del_timer(&lp->cell_timer); /* Remove cell expiry timer */
|
547 |
|
|
ptr=lp->wavepoint_table.head; /* Clear device's WavePoint table */
|
548 |
|
|
while(ptr!=NULL)
|
549 |
|
|
{
|
550 |
|
|
old_ptr=ptr;
|
551 |
|
|
ptr=ptr->next;
|
552 |
|
|
wl_del_wavepoint(old_ptr,lp);
|
553 |
|
|
}
|
554 |
|
|
}
|
555 |
|
|
|
556 |
|
|
/* Enable/Disable NWID promiscuous mode on a given device */
|
557 |
|
|
static void wv_nwid_filter(unsigned char mode, net_local *lp)
|
558 |
|
|
{
|
559 |
|
|
mm_t m;
|
560 |
|
|
unsigned long flags;
|
561 |
|
|
|
562 |
|
|
#ifdef WAVELAN_ROAMING_DEBUG
|
563 |
|
|
printk(KERN_DEBUG "WaveLAN: NWID promisc %s, device %s\n",(mode==NWID_PROMISC) ? "on" : "off", lp->dev->name);
|
564 |
|
|
#endif
|
565 |
|
|
|
566 |
|
|
/* Disable interrupts & save flags */
|
567 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
568 |
|
|
|
569 |
|
|
m.w.mmw_loopt_sel = (mode==NWID_PROMISC) ? MMW_LOOPT_SEL_DIS_NWID : 0x00;
|
570 |
|
|
mmc_write(lp->dev->base_addr, (char *)&m.w.mmw_loopt_sel - (char *)&m, (unsigned char *)&m.w.mmw_loopt_sel, 1);
|
571 |
|
|
|
572 |
|
|
if(mode==NWID_PROMISC)
|
573 |
|
|
lp->cell_search=1;
|
574 |
|
|
else
|
575 |
|
|
lp->cell_search=0;
|
576 |
|
|
|
577 |
|
|
/* ReEnable interrupts & restore flags */
|
578 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
579 |
|
|
}
|
580 |
|
|
|
581 |
|
|
/* Find a record in the WavePoint table matching a given NWID */
|
582 |
|
|
static wavepoint_history *wl_roam_check(unsigned short nwid, net_local *lp)
|
583 |
|
|
{
|
584 |
|
|
wavepoint_history *ptr=lp->wavepoint_table.head;
|
585 |
|
|
|
586 |
|
|
while(ptr!=NULL){
|
587 |
|
|
if(ptr->nwid==nwid)
|
588 |
|
|
return ptr;
|
589 |
|
|
ptr=ptr->next;
|
590 |
|
|
}
|
591 |
|
|
return NULL;
|
592 |
|
|
}
|
593 |
|
|
|
594 |
|
|
/* Create a new wavepoint table entry */
|
595 |
|
|
static wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char seq, net_local* lp)
|
596 |
|
|
{
|
597 |
|
|
wavepoint_history *new_wavepoint;
|
598 |
|
|
|
599 |
|
|
#ifdef WAVELAN_ROAMING_DEBUG
|
600 |
|
|
printk(KERN_DEBUG "WaveLAN: New Wavepoint, NWID:%.4X\n",nwid);
|
601 |
|
|
#endif
|
602 |
|
|
|
603 |
|
|
if(lp->wavepoint_table.num_wavepoints==MAX_WAVEPOINTS)
|
604 |
|
|
return NULL;
|
605 |
|
|
|
606 |
|
|
new_wavepoint = kmalloc(sizeof(wavepoint_history),GFP_ATOMIC);
|
607 |
|
|
if(new_wavepoint==NULL)
|
608 |
|
|
return NULL;
|
609 |
|
|
|
610 |
|
|
new_wavepoint->nwid=nwid; /* New WavePoints NWID */
|
611 |
|
|
new_wavepoint->average_fast=0; /* Running Averages..*/
|
612 |
|
|
new_wavepoint->average_slow=0;
|
613 |
|
|
new_wavepoint->qualptr=0; /* Start of ringbuffer */
|
614 |
|
|
new_wavepoint->last_seq=seq-1; /* Last sequence no.seen */
|
615 |
|
|
memset(new_wavepoint->sigqual,0,WAVEPOINT_HISTORY);/* Empty ringbuffer */
|
616 |
|
|
|
617 |
|
|
new_wavepoint->next=lp->wavepoint_table.head;/* Add to wavepoint table */
|
618 |
|
|
new_wavepoint->prev=NULL;
|
619 |
|
|
|
620 |
|
|
if(lp->wavepoint_table.head!=NULL)
|
621 |
|
|
lp->wavepoint_table.head->prev=new_wavepoint;
|
622 |
|
|
|
623 |
|
|
lp->wavepoint_table.head=new_wavepoint;
|
624 |
|
|
|
625 |
|
|
lp->wavepoint_table.num_wavepoints++; /* no. of visible wavepoints */
|
626 |
|
|
|
627 |
|
|
return new_wavepoint;
|
628 |
|
|
}
|
629 |
|
|
|
630 |
|
|
/* Remove a wavepoint entry from WavePoint table */
|
631 |
|
|
static void wl_del_wavepoint(wavepoint_history *wavepoint, struct net_local *lp)
|
632 |
|
|
{
|
633 |
|
|
if(wavepoint==NULL)
|
634 |
|
|
return;
|
635 |
|
|
|
636 |
|
|
if(lp->curr_point==wavepoint)
|
637 |
|
|
lp->curr_point=NULL;
|
638 |
|
|
|
639 |
|
|
if(wavepoint->prev!=NULL)
|
640 |
|
|
wavepoint->prev->next=wavepoint->next;
|
641 |
|
|
|
642 |
|
|
if(wavepoint->next!=NULL)
|
643 |
|
|
wavepoint->next->prev=wavepoint->prev;
|
644 |
|
|
|
645 |
|
|
if(lp->wavepoint_table.head==wavepoint)
|
646 |
|
|
lp->wavepoint_table.head=wavepoint->next;
|
647 |
|
|
|
648 |
|
|
lp->wavepoint_table.num_wavepoints--;
|
649 |
|
|
kfree(wavepoint);
|
650 |
|
|
}
|
651 |
|
|
|
652 |
|
|
/* Timer callback function - checks WavePoint table for stale entries */
|
653 |
|
|
static void wl_cell_expiry(unsigned long data)
|
654 |
|
|
{
|
655 |
|
|
net_local *lp=(net_local *)data;
|
656 |
|
|
wavepoint_history *wavepoint=lp->wavepoint_table.head,*old_point;
|
657 |
|
|
|
658 |
|
|
#if WAVELAN_ROAMING_DEBUG > 1
|
659 |
|
|
printk(KERN_DEBUG "WaveLAN: Wavepoint timeout, dev %s\n",lp->dev->name);
|
660 |
|
|
#endif
|
661 |
|
|
|
662 |
|
|
if(lp->wavepoint_table.locked)
|
663 |
|
|
{
|
664 |
|
|
#if WAVELAN_ROAMING_DEBUG > 1
|
665 |
|
|
printk(KERN_DEBUG "WaveLAN: Wavepoint table locked...\n");
|
666 |
|
|
#endif
|
667 |
|
|
|
668 |
|
|
lp->cell_timer.expires=jiffies+1; /* If table in use, come back later */
|
669 |
|
|
add_timer(&lp->cell_timer);
|
670 |
|
|
return;
|
671 |
|
|
}
|
672 |
|
|
|
673 |
|
|
while(wavepoint!=NULL)
|
674 |
|
|
{
|
675 |
|
|
if(time_after(jiffies, wavepoint->last_seen + CELL_TIMEOUT))
|
676 |
|
|
{
|
677 |
|
|
#ifdef WAVELAN_ROAMING_DEBUG
|
678 |
|
|
printk(KERN_DEBUG "WaveLAN: Bye bye %.4X\n",wavepoint->nwid);
|
679 |
|
|
#endif
|
680 |
|
|
|
681 |
|
|
old_point=wavepoint;
|
682 |
|
|
wavepoint=wavepoint->next;
|
683 |
|
|
wl_del_wavepoint(old_point,lp);
|
684 |
|
|
}
|
685 |
|
|
else
|
686 |
|
|
wavepoint=wavepoint->next;
|
687 |
|
|
}
|
688 |
|
|
lp->cell_timer.expires=jiffies+CELL_TIMEOUT;
|
689 |
|
|
add_timer(&lp->cell_timer);
|
690 |
|
|
}
|
691 |
|
|
|
692 |
|
|
/* Update SNR history of a wavepoint */
|
693 |
|
|
static void wl_update_history(wavepoint_history *wavepoint, unsigned char sigqual, unsigned char seq)
|
694 |
|
|
{
|
695 |
|
|
int i=0,num_missed=0,ptr=0;
|
696 |
|
|
int average_fast=0,average_slow=0;
|
697 |
|
|
|
698 |
|
|
num_missed=(seq-wavepoint->last_seq)%WAVEPOINT_HISTORY;/* Have we missed
|
699 |
|
|
any beacons? */
|
700 |
|
|
if(num_missed)
|
701 |
|
|
for(i=0;i<num_missed;i++)
|
702 |
|
|
{
|
703 |
|
|
wavepoint->sigqual[wavepoint->qualptr++]=0; /* If so, enter them as 0's */
|
704 |
|
|
wavepoint->qualptr %=WAVEPOINT_HISTORY; /* in the ringbuffer. */
|
705 |
|
|
}
|
706 |
|
|
wavepoint->last_seen=jiffies; /* Add beacon to history */
|
707 |
|
|
wavepoint->last_seq=seq;
|
708 |
|
|
wavepoint->sigqual[wavepoint->qualptr++]=sigqual;
|
709 |
|
|
wavepoint->qualptr %=WAVEPOINT_HISTORY;
|
710 |
|
|
ptr=(wavepoint->qualptr-WAVEPOINT_FAST_HISTORY+WAVEPOINT_HISTORY)%WAVEPOINT_HISTORY;
|
711 |
|
|
|
712 |
|
|
for(i=0;i<WAVEPOINT_FAST_HISTORY;i++) /* Update running averages */
|
713 |
|
|
{
|
714 |
|
|
average_fast+=wavepoint->sigqual[ptr++];
|
715 |
|
|
ptr %=WAVEPOINT_HISTORY;
|
716 |
|
|
}
|
717 |
|
|
|
718 |
|
|
average_slow=average_fast;
|
719 |
|
|
for(i=WAVEPOINT_FAST_HISTORY;i<WAVEPOINT_HISTORY;i++)
|
720 |
|
|
{
|
721 |
|
|
average_slow+=wavepoint->sigqual[ptr++];
|
722 |
|
|
ptr %=WAVEPOINT_HISTORY;
|
723 |
|
|
}
|
724 |
|
|
|
725 |
|
|
wavepoint->average_fast=average_fast/WAVEPOINT_FAST_HISTORY;
|
726 |
|
|
wavepoint->average_slow=average_slow/WAVEPOINT_HISTORY;
|
727 |
|
|
}
|
728 |
|
|
|
729 |
|
|
/* Perform a handover to a new WavePoint */
|
730 |
|
|
static void wv_roam_handover(wavepoint_history *wavepoint, net_local *lp)
|
731 |
|
|
{
|
732 |
|
|
kio_addr_t base = lp->dev->base_addr;
|
733 |
|
|
mm_t m;
|
734 |
|
|
unsigned long flags;
|
735 |
|
|
|
736 |
|
|
if(wavepoint==lp->curr_point) /* Sanity check... */
|
737 |
|
|
{
|
738 |
|
|
wv_nwid_filter(!NWID_PROMISC,lp);
|
739 |
|
|
return;
|
740 |
|
|
}
|
741 |
|
|
|
742 |
|
|
#ifdef WAVELAN_ROAMING_DEBUG
|
743 |
|
|
printk(KERN_DEBUG "WaveLAN: Doing handover to %.4X, dev %s\n",wavepoint->nwid,lp->dev->name);
|
744 |
|
|
#endif
|
745 |
|
|
|
746 |
|
|
/* Disable interrupts & save flags */
|
747 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
748 |
|
|
|
749 |
|
|
m.w.mmw_netw_id_l = wavepoint->nwid & 0xFF;
|
750 |
|
|
m.w.mmw_netw_id_h = (wavepoint->nwid & 0xFF00) >> 8;
|
751 |
|
|
|
752 |
|
|
mmc_write(base, (char *)&m.w.mmw_netw_id_l - (char *)&m, (unsigned char *)&m.w.mmw_netw_id_l, 2);
|
753 |
|
|
|
754 |
|
|
/* ReEnable interrupts & restore flags */
|
755 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
756 |
|
|
|
757 |
|
|
wv_nwid_filter(!NWID_PROMISC,lp);
|
758 |
|
|
lp->curr_point=wavepoint;
|
759 |
|
|
}
|
760 |
|
|
|
761 |
|
|
/* Called when a WavePoint beacon is received */
|
762 |
|
|
static inline void wl_roam_gather(struct net_device * dev,
|
763 |
|
|
u_char * hdr, /* Beacon header */
|
764 |
|
|
u_char * stats) /* SNR, Signal quality
|
765 |
|
|
of packet */
|
766 |
|
|
{
|
767 |
|
|
wavepoint_beacon *beacon= (wavepoint_beacon *)hdr; /* Rcvd. Beacon */
|
768 |
|
|
unsigned short nwid=ntohs(beacon->nwid);
|
769 |
|
|
unsigned short sigqual=stats[2] & MMR_SGNL_QUAL; /* SNR of beacon */
|
770 |
|
|
wavepoint_history *wavepoint=NULL; /* WavePoint table entry */
|
771 |
|
|
net_local *lp = netdev_priv(dev); /* Device info */
|
772 |
|
|
|
773 |
|
|
#ifdef I_NEED_THIS_FEATURE
|
774 |
|
|
/* Some people don't need this, some other may need it */
|
775 |
|
|
nwid=nwid^ntohs(beacon->domain_id);
|
776 |
|
|
#endif
|
777 |
|
|
|
778 |
|
|
#if WAVELAN_ROAMING_DEBUG > 1
|
779 |
|
|
printk(KERN_DEBUG "WaveLAN: beacon, dev %s:\n",dev->name);
|
780 |
|
|
printk(KERN_DEBUG "Domain: %.4X NWID: %.4X SigQual=%d\n",ntohs(beacon->domain_id),nwid,sigqual);
|
781 |
|
|
#endif
|
782 |
|
|
|
783 |
|
|
lp->wavepoint_table.locked=1; /* <Mutex> */
|
784 |
|
|
|
785 |
|
|
wavepoint=wl_roam_check(nwid,lp); /* Find WavePoint table entry */
|
786 |
|
|
if(wavepoint==NULL) /* If no entry, Create a new one... */
|
787 |
|
|
{
|
788 |
|
|
wavepoint=wl_new_wavepoint(nwid,beacon->seq,lp);
|
789 |
|
|
if(wavepoint==NULL)
|
790 |
|
|
goto out;
|
791 |
|
|
}
|
792 |
|
|
if(lp->curr_point==NULL) /* If this is the only WavePoint, */
|
793 |
|
|
wv_roam_handover(wavepoint, lp); /* Jump on it! */
|
794 |
|
|
|
795 |
|
|
wl_update_history(wavepoint, sigqual, beacon->seq); /* Update SNR history
|
796 |
|
|
stats. */
|
797 |
|
|
|
798 |
|
|
if(lp->curr_point->average_slow < SEARCH_THRESH_LOW) /* If our current */
|
799 |
|
|
if(!lp->cell_search) /* WavePoint is getting faint, */
|
800 |
|
|
wv_nwid_filter(NWID_PROMISC,lp); /* start looking for a new one */
|
801 |
|
|
|
802 |
|
|
if(wavepoint->average_slow >
|
803 |
|
|
lp->curr_point->average_slow + WAVELAN_ROAMING_DELTA)
|
804 |
|
|
wv_roam_handover(wavepoint, lp); /* Handover to a better WavePoint */
|
805 |
|
|
|
806 |
|
|
if(lp->curr_point->average_slow > SEARCH_THRESH_HIGH) /* If our SNR is */
|
807 |
|
|
if(lp->cell_search) /* getting better, drop out of cell search mode */
|
808 |
|
|
wv_nwid_filter(!NWID_PROMISC,lp);
|
809 |
|
|
|
810 |
|
|
out:
|
811 |
|
|
lp->wavepoint_table.locked=0; /* </MUTEX> :-) */
|
812 |
|
|
}
|
813 |
|
|
|
814 |
|
|
/* Test this MAC frame a WavePoint beacon */
|
815 |
|
|
static inline int WAVELAN_BEACON(unsigned char *data)
|
816 |
|
|
{
|
817 |
|
|
wavepoint_beacon *beacon= (wavepoint_beacon *)data;
|
818 |
|
|
static wavepoint_beacon beacon_template={0xaa,0xaa,0x03,0x08,0x00,0x0e,0x20,0x03,0x00};
|
819 |
|
|
|
820 |
|
|
if(memcmp(beacon,&beacon_template,9)==0)
|
821 |
|
|
return 1;
|
822 |
|
|
else
|
823 |
|
|
return 0;
|
824 |
|
|
}
|
825 |
|
|
#endif /* WAVELAN_ROAMING */
|
826 |
|
|
|
827 |
|
|
/************************ I82593 SUBROUTINES *************************/
|
828 |
|
|
/*
|
829 |
|
|
* Useful subroutines to manage the Ethernet controller
|
830 |
|
|
*/
|
831 |
|
|
|
832 |
|
|
/*------------------------------------------------------------------*/
|
833 |
|
|
/*
|
834 |
|
|
* Routine to synchronously send a command to the i82593 chip.
|
835 |
|
|
* Should be called with interrupts disabled.
|
836 |
|
|
* (called by wv_packet_write(), wv_ru_stop(), wv_ru_start(),
|
837 |
|
|
* wv_82593_config() & wv_diag())
|
838 |
|
|
*/
|
839 |
|
|
static int
|
840 |
|
|
wv_82593_cmd(struct net_device * dev,
|
841 |
|
|
char * str,
|
842 |
|
|
int cmd,
|
843 |
|
|
int result)
|
844 |
|
|
{
|
845 |
|
|
kio_addr_t base = dev->base_addr;
|
846 |
|
|
int status;
|
847 |
|
|
int wait_completed;
|
848 |
|
|
long spin;
|
849 |
|
|
|
850 |
|
|
/* Spin until the chip finishes executing its current command (if any) */
|
851 |
|
|
spin = 1000;
|
852 |
|
|
do
|
853 |
|
|
{
|
854 |
|
|
/* Time calibration of the loop */
|
855 |
|
|
udelay(10);
|
856 |
|
|
|
857 |
|
|
/* Read the interrupt register */
|
858 |
|
|
outb(OP0_NOP | CR0_STATUS_3, LCCR(base));
|
859 |
|
|
status = inb(LCSR(base));
|
860 |
|
|
}
|
861 |
|
|
while(((status & SR3_EXEC_STATE_MASK) != SR3_EXEC_IDLE) && (spin-- > 0));
|
862 |
|
|
|
863 |
|
|
/* If the interrupt hasn't be posted */
|
864 |
|
|
if(spin <= 0)
|
865 |
|
|
{
|
866 |
|
|
#ifdef DEBUG_INTERRUPT_ERROR
|
867 |
|
|
printk(KERN_INFO "wv_82593_cmd: %s timeout (previous command), status 0x%02x\n",
|
868 |
|
|
str, status);
|
869 |
|
|
#endif
|
870 |
|
|
return(FALSE);
|
871 |
|
|
}
|
872 |
|
|
|
873 |
|
|
/* Issue the command to the controller */
|
874 |
|
|
outb(cmd, LCCR(base));
|
875 |
|
|
|
876 |
|
|
/* If we don't have to check the result of the command
|
877 |
|
|
* Note : this mean that the irq handler will deal with that */
|
878 |
|
|
if(result == SR0_NO_RESULT)
|
879 |
|
|
return(TRUE);
|
880 |
|
|
|
881 |
|
|
/* We are waiting for command completion */
|
882 |
|
|
wait_completed = TRUE;
|
883 |
|
|
|
884 |
|
|
/* Busy wait while the LAN controller executes the command. */
|
885 |
|
|
spin = 1000;
|
886 |
|
|
do
|
887 |
|
|
{
|
888 |
|
|
/* Time calibration of the loop */
|
889 |
|
|
udelay(10);
|
890 |
|
|
|
891 |
|
|
/* Read the interrupt register */
|
892 |
|
|
outb(CR0_STATUS_0 | OP0_NOP, LCCR(base));
|
893 |
|
|
status = inb(LCSR(base));
|
894 |
|
|
|
895 |
|
|
/* Check if there was an interrupt posted */
|
896 |
|
|
if((status & SR0_INTERRUPT))
|
897 |
|
|
{
|
898 |
|
|
/* Acknowledge the interrupt */
|
899 |
|
|
outb(CR0_INT_ACK | OP0_NOP, LCCR(base));
|
900 |
|
|
|
901 |
|
|
/* Check if interrupt is a command completion */
|
902 |
|
|
if(((status & SR0_BOTH_RX_TX) != SR0_BOTH_RX_TX) &&
|
903 |
|
|
((status & SR0_BOTH_RX_TX) != 0x0) &&
|
904 |
|
|
!(status & SR0_RECEPTION))
|
905 |
|
|
{
|
906 |
|
|
/* Signal command completion */
|
907 |
|
|
wait_completed = FALSE;
|
908 |
|
|
}
|
909 |
|
|
else
|
910 |
|
|
{
|
911 |
|
|
/* Note : Rx interrupts will be handled later, because we can
|
912 |
|
|
* handle multiple Rx packets at once */
|
913 |
|
|
#ifdef DEBUG_INTERRUPT_INFO
|
914 |
|
|
printk(KERN_INFO "wv_82593_cmd: not our interrupt\n");
|
915 |
|
|
#endif
|
916 |
|
|
}
|
917 |
|
|
}
|
918 |
|
|
}
|
919 |
|
|
while(wait_completed && (spin-- > 0));
|
920 |
|
|
|
921 |
|
|
/* If the interrupt hasn't be posted */
|
922 |
|
|
if(wait_completed)
|
923 |
|
|
{
|
924 |
|
|
#ifdef DEBUG_INTERRUPT_ERROR
|
925 |
|
|
printk(KERN_INFO "wv_82593_cmd: %s timeout, status 0x%02x\n",
|
926 |
|
|
str, status);
|
927 |
|
|
#endif
|
928 |
|
|
return(FALSE);
|
929 |
|
|
}
|
930 |
|
|
|
931 |
|
|
/* Check the return code returned by the card (see above) against
|
932 |
|
|
* the expected return code provided by the caller */
|
933 |
|
|
if((status & SR0_EVENT_MASK) != result)
|
934 |
|
|
{
|
935 |
|
|
#ifdef DEBUG_INTERRUPT_ERROR
|
936 |
|
|
printk(KERN_INFO "wv_82593_cmd: %s failed, status = 0x%x\n",
|
937 |
|
|
str, status);
|
938 |
|
|
#endif
|
939 |
|
|
return(FALSE);
|
940 |
|
|
}
|
941 |
|
|
|
942 |
|
|
return(TRUE);
|
943 |
|
|
} /* wv_82593_cmd */
|
944 |
|
|
|
945 |
|
|
/*------------------------------------------------------------------*/
|
946 |
|
|
/*
|
947 |
|
|
* This routine does a 593 op-code number 7, and obtains the diagnose
|
948 |
|
|
* status for the WaveLAN.
|
949 |
|
|
*/
|
950 |
|
|
static inline int
|
951 |
|
|
wv_diag(struct net_device * dev)
|
952 |
|
|
{
|
953 |
|
|
return(wv_82593_cmd(dev, "wv_diag(): diagnose",
|
954 |
|
|
OP0_DIAGNOSE, SR0_DIAGNOSE_PASSED));
|
955 |
|
|
} /* wv_diag */
|
956 |
|
|
|
957 |
|
|
/*------------------------------------------------------------------*/
|
958 |
|
|
/*
|
959 |
|
|
* Routine to read len bytes from the i82593's ring buffer, starting at
|
960 |
|
|
* chip address addr. The results read from the chip are stored in buf.
|
961 |
|
|
* The return value is the address to use for next the call.
|
962 |
|
|
*/
|
963 |
|
|
static int
|
964 |
|
|
read_ringbuf(struct net_device * dev,
|
965 |
|
|
int addr,
|
966 |
|
|
char * buf,
|
967 |
|
|
int len)
|
968 |
|
|
{
|
969 |
|
|
kio_addr_t base = dev->base_addr;
|
970 |
|
|
int ring_ptr = addr;
|
971 |
|
|
int chunk_len;
|
972 |
|
|
char * buf_ptr = buf;
|
973 |
|
|
|
974 |
|
|
/* Get all the buffer */
|
975 |
|
|
while(len > 0)
|
976 |
|
|
{
|
977 |
|
|
/* Position the Program I/O Register at the ring buffer pointer */
|
978 |
|
|
outb(ring_ptr & 0xff, PIORL(base));
|
979 |
|
|
outb(((ring_ptr >> 8) & PIORH_MASK), PIORH(base));
|
980 |
|
|
|
981 |
|
|
/* First, determine how much we can read without wrapping around the
|
982 |
|
|
ring buffer */
|
983 |
|
|
if((addr + len) < (RX_BASE + RX_SIZE))
|
984 |
|
|
chunk_len = len;
|
985 |
|
|
else
|
986 |
|
|
chunk_len = RX_BASE + RX_SIZE - addr;
|
987 |
|
|
insb(PIOP(base), buf_ptr, chunk_len);
|
988 |
|
|
buf_ptr += chunk_len;
|
989 |
|
|
len -= chunk_len;
|
990 |
|
|
ring_ptr = (ring_ptr - RX_BASE + chunk_len) % RX_SIZE + RX_BASE;
|
991 |
|
|
}
|
992 |
|
|
return(ring_ptr);
|
993 |
|
|
} /* read_ringbuf */
|
994 |
|
|
|
995 |
|
|
/*------------------------------------------------------------------*/
|
996 |
|
|
/*
|
997 |
|
|
* Reconfigure the i82593, or at least ask for it...
|
998 |
|
|
* Because wv_82593_config use the transmission buffer, we must do it
|
999 |
|
|
* when we are sure that there is no transmission, so we do it now
|
1000 |
|
|
* or in wavelan_packet_xmit() (I can't find any better place,
|
1001 |
|
|
* wavelan_interrupt is not an option...), so you may experience
|
1002 |
|
|
* some delay sometime...
|
1003 |
|
|
*/
|
1004 |
|
|
static inline void
|
1005 |
|
|
wv_82593_reconfig(struct net_device * dev)
|
1006 |
|
|
{
|
1007 |
|
|
net_local * lp = netdev_priv(dev);
|
1008 |
|
|
struct pcmcia_device * link = lp->link;
|
1009 |
|
|
unsigned long flags;
|
1010 |
|
|
|
1011 |
|
|
/* Arm the flag, will be cleard in wv_82593_config() */
|
1012 |
|
|
lp->reconfig_82593 = TRUE;
|
1013 |
|
|
|
1014 |
|
|
/* Check if we can do it now ! */
|
1015 |
|
|
if((link->open) && (netif_running(dev)) && !(netif_queue_stopped(dev)))
|
1016 |
|
|
{
|
1017 |
|
|
spin_lock_irqsave(&lp->spinlock, flags); /* Disable interrupts */
|
1018 |
|
|
wv_82593_config(dev);
|
1019 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags); /* Re-enable interrupts */
|
1020 |
|
|
}
|
1021 |
|
|
else
|
1022 |
|
|
{
|
1023 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
1024 |
|
|
printk(KERN_DEBUG
|
1025 |
|
|
"%s: wv_82593_reconfig(): delayed (state = %lX, link = %d)\n",
|
1026 |
|
|
dev->name, dev->state, link->open);
|
1027 |
|
|
#endif
|
1028 |
|
|
}
|
1029 |
|
|
}
|
1030 |
|
|
|
1031 |
|
|
/********************* DEBUG & INFO SUBROUTINES *********************/
|
1032 |
|
|
/*
|
1033 |
|
|
* This routines are used in the code to show debug informations.
|
1034 |
|
|
* Most of the time, it dump the content of hardware structures...
|
1035 |
|
|
*/
|
1036 |
|
|
|
1037 |
|
|
#ifdef DEBUG_PSA_SHOW
|
1038 |
|
|
/*------------------------------------------------------------------*/
|
1039 |
|
|
/*
|
1040 |
|
|
* Print the formatted contents of the Parameter Storage Area.
|
1041 |
|
|
*/
|
1042 |
|
|
static void
|
1043 |
|
|
wv_psa_show(psa_t * p)
|
1044 |
|
|
{
|
1045 |
|
|
DECLARE_MAC_BUF(mac);
|
1046 |
|
|
printk(KERN_DEBUG "##### wavelan psa contents: #####\n");
|
1047 |
|
|
printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n",
|
1048 |
|
|
p->psa_io_base_addr_1,
|
1049 |
|
|
p->psa_io_base_addr_2,
|
1050 |
|
|
p->psa_io_base_addr_3,
|
1051 |
|
|
p->psa_io_base_addr_4);
|
1052 |
|
|
printk(KERN_DEBUG "psa_rem_boot_addr_1: 0x%02X %02X %02X\n",
|
1053 |
|
|
p->psa_rem_boot_addr_1,
|
1054 |
|
|
p->psa_rem_boot_addr_2,
|
1055 |
|
|
p->psa_rem_boot_addr_3);
|
1056 |
|
|
printk(KERN_DEBUG "psa_holi_params: 0x%02x, ", p->psa_holi_params);
|
1057 |
|
|
printk("psa_int_req_no: %d\n", p->psa_int_req_no);
|
1058 |
|
|
#ifdef DEBUG_SHOW_UNUSED
|
1059 |
|
|
printk(KERN_DEBUG "psa_unused0[]: %s\n",
|
1060 |
|
|
print_mac(mac, p->psa_unused0));
|
1061 |
|
|
#endif /* DEBUG_SHOW_UNUSED */
|
1062 |
|
|
printk(KERN_DEBUG "psa_univ_mac_addr[]: %s\n",
|
1063 |
|
|
print_mac(mac, p->psa_univ_mac_addr));
|
1064 |
|
|
printk(KERN_DEBUG "psa_local_mac_addr[]: %s\n",
|
1065 |
|
|
print_mac(mac, p->psa_local_mac_addr));
|
1066 |
|
|
printk(KERN_DEBUG "psa_univ_local_sel: %d, ", p->psa_univ_local_sel);
|
1067 |
|
|
printk("psa_comp_number: %d, ", p->psa_comp_number);
|
1068 |
|
|
printk("psa_thr_pre_set: 0x%02x\n", p->psa_thr_pre_set);
|
1069 |
|
|
printk(KERN_DEBUG "psa_feature_select/decay_prm: 0x%02x, ",
|
1070 |
|
|
p->psa_feature_select);
|
1071 |
|
|
printk("psa_subband/decay_update_prm: %d\n", p->psa_subband);
|
1072 |
|
|
printk(KERN_DEBUG "psa_quality_thr: 0x%02x, ", p->psa_quality_thr);
|
1073 |
|
|
printk("psa_mod_delay: 0x%02x\n", p->psa_mod_delay);
|
1074 |
|
|
printk(KERN_DEBUG "psa_nwid: 0x%02x%02x, ", p->psa_nwid[0], p->psa_nwid[1]);
|
1075 |
|
|
printk("psa_nwid_select: %d\n", p->psa_nwid_select);
|
1076 |
|
|
printk(KERN_DEBUG "psa_encryption_select: %d, ", p->psa_encryption_select);
|
1077 |
|
|
printk("psa_encryption_key[]: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
1078 |
|
|
p->psa_encryption_key[0],
|
1079 |
|
|
p->psa_encryption_key[1],
|
1080 |
|
|
p->psa_encryption_key[2],
|
1081 |
|
|
p->psa_encryption_key[3],
|
1082 |
|
|
p->psa_encryption_key[4],
|
1083 |
|
|
p->psa_encryption_key[5],
|
1084 |
|
|
p->psa_encryption_key[6],
|
1085 |
|
|
p->psa_encryption_key[7]);
|
1086 |
|
|
printk(KERN_DEBUG "psa_databus_width: %d\n", p->psa_databus_width);
|
1087 |
|
|
printk(KERN_DEBUG "psa_call_code/auto_squelch: 0x%02x, ",
|
1088 |
|
|
p->psa_call_code[0]);
|
1089 |
|
|
printk("psa_call_code[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
|
1090 |
|
|
p->psa_call_code[0],
|
1091 |
|
|
p->psa_call_code[1],
|
1092 |
|
|
p->psa_call_code[2],
|
1093 |
|
|
p->psa_call_code[3],
|
1094 |
|
|
p->psa_call_code[4],
|
1095 |
|
|
p->psa_call_code[5],
|
1096 |
|
|
p->psa_call_code[6],
|
1097 |
|
|
p->psa_call_code[7]);
|
1098 |
|
|
#ifdef DEBUG_SHOW_UNUSED
|
1099 |
|
|
printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n",
|
1100 |
|
|
p->psa_reserved[0],
|
1101 |
|
|
p->psa_reserved[1],
|
1102 |
|
|
p->psa_reserved[2],
|
1103 |
|
|
p->psa_reserved[3]);
|
1104 |
|
|
#endif /* DEBUG_SHOW_UNUSED */
|
1105 |
|
|
printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status);
|
1106 |
|
|
printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]);
|
1107 |
|
|
printk("psa_crc_status: 0x%02x\n", p->psa_crc_status);
|
1108 |
|
|
} /* wv_psa_show */
|
1109 |
|
|
#endif /* DEBUG_PSA_SHOW */
|
1110 |
|
|
|
1111 |
|
|
#ifdef DEBUG_MMC_SHOW
|
1112 |
|
|
/*------------------------------------------------------------------*/
|
1113 |
|
|
/*
|
1114 |
|
|
* Print the formatted status of the Modem Management Controller.
|
1115 |
|
|
* This function need to be completed...
|
1116 |
|
|
*/
|
1117 |
|
|
static void
|
1118 |
|
|
wv_mmc_show(struct net_device * dev)
|
1119 |
|
|
{
|
1120 |
|
|
kio_addr_t base = dev->base_addr;
|
1121 |
|
|
net_local * lp = netdev_priv(dev);
|
1122 |
|
|
mmr_t m;
|
1123 |
|
|
|
1124 |
|
|
/* Basic check */
|
1125 |
|
|
if(hasr_read(base) & HASR_NO_CLK)
|
1126 |
|
|
{
|
1127 |
|
|
printk(KERN_WARNING "%s: wv_mmc_show: modem not connected\n",
|
1128 |
|
|
dev->name);
|
1129 |
|
|
return;
|
1130 |
|
|
}
|
1131 |
|
|
|
1132 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
1133 |
|
|
|
1134 |
|
|
/* Read the mmc */
|
1135 |
|
|
mmc_out(base, mmwoff(0, mmw_freeze), 1);
|
1136 |
|
|
mmc_read(base, 0, (u_char *)&m, sizeof(m));
|
1137 |
|
|
mmc_out(base, mmwoff(0, mmw_freeze), 0);
|
1138 |
|
|
|
1139 |
|
|
/* Don't forget to update statistics */
|
1140 |
|
|
lp->wstats.discard.nwid += (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
|
1141 |
|
|
|
1142 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
1143 |
|
|
|
1144 |
|
|
printk(KERN_DEBUG "##### wavelan modem status registers: #####\n");
|
1145 |
|
|
#ifdef DEBUG_SHOW_UNUSED
|
1146 |
|
|
printk(KERN_DEBUG "mmc_unused0[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
|
1147 |
|
|
m.mmr_unused0[0],
|
1148 |
|
|
m.mmr_unused0[1],
|
1149 |
|
|
m.mmr_unused0[2],
|
1150 |
|
|
m.mmr_unused0[3],
|
1151 |
|
|
m.mmr_unused0[4],
|
1152 |
|
|
m.mmr_unused0[5],
|
1153 |
|
|
m.mmr_unused0[6],
|
1154 |
|
|
m.mmr_unused0[7]);
|
1155 |
|
|
#endif /* DEBUG_SHOW_UNUSED */
|
1156 |
|
|
printk(KERN_DEBUG "Encryption algorithm: %02X - Status: %02X\n",
|
1157 |
|
|
m.mmr_des_avail, m.mmr_des_status);
|
1158 |
|
|
#ifdef DEBUG_SHOW_UNUSED
|
1159 |
|
|
printk(KERN_DEBUG "mmc_unused1[]: %02X:%02X:%02X:%02X:%02X\n",
|
1160 |
|
|
m.mmr_unused1[0],
|
1161 |
|
|
m.mmr_unused1[1],
|
1162 |
|
|
m.mmr_unused1[2],
|
1163 |
|
|
m.mmr_unused1[3],
|
1164 |
|
|
m.mmr_unused1[4]);
|
1165 |
|
|
#endif /* DEBUG_SHOW_UNUSED */
|
1166 |
|
|
printk(KERN_DEBUG "dce_status: 0x%x [%s%s%s%s]\n",
|
1167 |
|
|
m.mmr_dce_status,
|
1168 |
|
|
(m.mmr_dce_status & MMR_DCE_STATUS_RX_BUSY) ? "energy detected,":"",
|
1169 |
|
|
(m.mmr_dce_status & MMR_DCE_STATUS_LOOPT_IND) ?
|
1170 |
|
|
"loop test indicated," : "",
|
1171 |
|
|
(m.mmr_dce_status & MMR_DCE_STATUS_TX_BUSY) ? "transmitter on," : "",
|
1172 |
|
|
(m.mmr_dce_status & MMR_DCE_STATUS_JBR_EXPIRED) ?
|
1173 |
|
|
"jabber timer expired," : "");
|
1174 |
|
|
printk(KERN_DEBUG "Dsp ID: %02X\n",
|
1175 |
|
|
m.mmr_dsp_id);
|
1176 |
|
|
#ifdef DEBUG_SHOW_UNUSED
|
1177 |
|
|
printk(KERN_DEBUG "mmc_unused2[]: %02X:%02X\n",
|
1178 |
|
|
m.mmr_unused2[0],
|
1179 |
|
|
m.mmr_unused2[1]);
|
1180 |
|
|
#endif /* DEBUG_SHOW_UNUSED */
|
1181 |
|
|
printk(KERN_DEBUG "# correct_nwid: %d, # wrong_nwid: %d\n",
|
1182 |
|
|
(m.mmr_correct_nwid_h << 8) | m.mmr_correct_nwid_l,
|
1183 |
|
|
(m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l);
|
1184 |
|
|
printk(KERN_DEBUG "thr_pre_set: 0x%x [current signal %s]\n",
|
1185 |
|
|
m.mmr_thr_pre_set & MMR_THR_PRE_SET,
|
1186 |
|
|
(m.mmr_thr_pre_set & MMR_THR_PRE_SET_CUR) ? "above" : "below");
|
1187 |
|
|
printk(KERN_DEBUG "signal_lvl: %d [%s], ",
|
1188 |
|
|
m.mmr_signal_lvl & MMR_SIGNAL_LVL,
|
1189 |
|
|
(m.mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) ? "new msg" : "no new msg");
|
1190 |
|
|
printk("silence_lvl: %d [%s], ", m.mmr_silence_lvl & MMR_SILENCE_LVL,
|
1191 |
|
|
(m.mmr_silence_lvl & MMR_SILENCE_LVL_VALID) ? "update done" : "no new update");
|
1192 |
|
|
printk("sgnl_qual: 0x%x [%s]\n", m.mmr_sgnl_qual & MMR_SGNL_QUAL,
|
1193 |
|
|
(m.mmr_sgnl_qual & MMR_SGNL_QUAL_ANT) ? "Antenna 1" : "Antenna 0");
|
1194 |
|
|
#ifdef DEBUG_SHOW_UNUSED
|
1195 |
|
|
printk(KERN_DEBUG "netw_id_l: %x\n", m.mmr_netw_id_l);
|
1196 |
|
|
#endif /* DEBUG_SHOW_UNUSED */
|
1197 |
|
|
} /* wv_mmc_show */
|
1198 |
|
|
#endif /* DEBUG_MMC_SHOW */
|
1199 |
|
|
|
1200 |
|
|
#ifdef DEBUG_I82593_SHOW
|
1201 |
|
|
/*------------------------------------------------------------------*/
|
1202 |
|
|
/*
|
1203 |
|
|
* Print the formatted status of the i82593's receive unit.
|
1204 |
|
|
*/
|
1205 |
|
|
static void
|
1206 |
|
|
wv_ru_show(struct net_device * dev)
|
1207 |
|
|
{
|
1208 |
|
|
net_local *lp = netdev_priv(dev);
|
1209 |
|
|
|
1210 |
|
|
printk(KERN_DEBUG "##### wavelan i82593 receiver status: #####\n");
|
1211 |
|
|
printk(KERN_DEBUG "ru: rfp %d stop %d", lp->rfp, lp->stop);
|
1212 |
|
|
/*
|
1213 |
|
|
* Not implemented yet...
|
1214 |
|
|
*/
|
1215 |
|
|
printk("\n");
|
1216 |
|
|
} /* wv_ru_show */
|
1217 |
|
|
#endif /* DEBUG_I82593_SHOW */
|
1218 |
|
|
|
1219 |
|
|
#ifdef DEBUG_DEVICE_SHOW
|
1220 |
|
|
/*------------------------------------------------------------------*/
|
1221 |
|
|
/*
|
1222 |
|
|
* Print the formatted status of the WaveLAN PCMCIA device driver.
|
1223 |
|
|
*/
|
1224 |
|
|
static void
|
1225 |
|
|
wv_dev_show(struct net_device * dev)
|
1226 |
|
|
{
|
1227 |
|
|
printk(KERN_DEBUG "dev:");
|
1228 |
|
|
printk(" state=%lX,", dev->state);
|
1229 |
|
|
printk(" trans_start=%ld,", dev->trans_start);
|
1230 |
|
|
printk(" flags=0x%x,", dev->flags);
|
1231 |
|
|
printk("\n");
|
1232 |
|
|
} /* wv_dev_show */
|
1233 |
|
|
|
1234 |
|
|
/*------------------------------------------------------------------*/
|
1235 |
|
|
/*
|
1236 |
|
|
* Print the formatted status of the WaveLAN PCMCIA device driver's
|
1237 |
|
|
* private information.
|
1238 |
|
|
*/
|
1239 |
|
|
static void
|
1240 |
|
|
wv_local_show(struct net_device * dev)
|
1241 |
|
|
{
|
1242 |
|
|
net_local *lp = netdev_priv(dev);
|
1243 |
|
|
|
1244 |
|
|
printk(KERN_DEBUG "local:");
|
1245 |
|
|
/*
|
1246 |
|
|
* Not implemented yet...
|
1247 |
|
|
*/
|
1248 |
|
|
printk("\n");
|
1249 |
|
|
} /* wv_local_show */
|
1250 |
|
|
#endif /* DEBUG_DEVICE_SHOW */
|
1251 |
|
|
|
1252 |
|
|
#if defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO)
|
1253 |
|
|
/*------------------------------------------------------------------*/
|
1254 |
|
|
/*
|
1255 |
|
|
* Dump packet header (and content if necessary) on the screen
|
1256 |
|
|
*/
|
1257 |
|
|
static inline void
|
1258 |
|
|
wv_packet_info(u_char * p, /* Packet to dump */
|
1259 |
|
|
int length, /* Length of the packet */
|
1260 |
|
|
char * msg1, /* Name of the device */
|
1261 |
|
|
char * msg2) /* Name of the function */
|
1262 |
|
|
{
|
1263 |
|
|
int i;
|
1264 |
|
|
int maxi;
|
1265 |
|
|
DECLARE_MAC_BUF(mac);
|
1266 |
|
|
|
1267 |
|
|
printk(KERN_DEBUG "%s: %s(): dest %s, length %d\n",
|
1268 |
|
|
msg1, msg2, print_mac(mac, p), length);
|
1269 |
|
|
printk(KERN_DEBUG "%s: %s(): src %s, type 0x%02X%02X\n",
|
1270 |
|
|
msg1, msg2, print_mac(mac, &p[6]), p[12], p[13]);
|
1271 |
|
|
|
1272 |
|
|
#ifdef DEBUG_PACKET_DUMP
|
1273 |
|
|
|
1274 |
|
|
printk(KERN_DEBUG "data=\"");
|
1275 |
|
|
|
1276 |
|
|
if((maxi = length) > DEBUG_PACKET_DUMP)
|
1277 |
|
|
maxi = DEBUG_PACKET_DUMP;
|
1278 |
|
|
for(i = 14; i < maxi; i++)
|
1279 |
|
|
if(p[i] >= ' ' && p[i] <= '~')
|
1280 |
|
|
printk(" %c", p[i]);
|
1281 |
|
|
else
|
1282 |
|
|
printk("%02X", p[i]);
|
1283 |
|
|
if(maxi < length)
|
1284 |
|
|
printk("..");
|
1285 |
|
|
printk("\"\n");
|
1286 |
|
|
printk(KERN_DEBUG "\n");
|
1287 |
|
|
#endif /* DEBUG_PACKET_DUMP */
|
1288 |
|
|
}
|
1289 |
|
|
#endif /* defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO) */
|
1290 |
|
|
|
1291 |
|
|
/*------------------------------------------------------------------*/
|
1292 |
|
|
/*
|
1293 |
|
|
* This is the information which is displayed by the driver at startup
|
1294 |
|
|
* There is a lot of flag to configure it at your will...
|
1295 |
|
|
*/
|
1296 |
|
|
static inline void
|
1297 |
|
|
wv_init_info(struct net_device * dev)
|
1298 |
|
|
{
|
1299 |
|
|
kio_addr_t base = dev->base_addr;
|
1300 |
|
|
psa_t psa;
|
1301 |
|
|
DECLARE_MAC_BUF(mac);
|
1302 |
|
|
|
1303 |
|
|
/* Read the parameter storage area */
|
1304 |
|
|
psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa));
|
1305 |
|
|
|
1306 |
|
|
#ifdef DEBUG_PSA_SHOW
|
1307 |
|
|
wv_psa_show(&psa);
|
1308 |
|
|
#endif
|
1309 |
|
|
#ifdef DEBUG_MMC_SHOW
|
1310 |
|
|
wv_mmc_show(dev);
|
1311 |
|
|
#endif
|
1312 |
|
|
#ifdef DEBUG_I82593_SHOW
|
1313 |
|
|
wv_ru_show(dev);
|
1314 |
|
|
#endif
|
1315 |
|
|
|
1316 |
|
|
#ifdef DEBUG_BASIC_SHOW
|
1317 |
|
|
/* Now, let's go for the basic stuff */
|
1318 |
|
|
printk(KERN_NOTICE "%s: WaveLAN: port %#lx, irq %d, "
|
1319 |
|
|
"hw_addr %s",
|
1320 |
|
|
dev->name, base, dev->irq,
|
1321 |
|
|
print_mac(mac, dev->dev_addr));
|
1322 |
|
|
|
1323 |
|
|
/* Print current network id */
|
1324 |
|
|
if(psa.psa_nwid_select)
|
1325 |
|
|
printk(", nwid 0x%02X-%02X", psa.psa_nwid[0], psa.psa_nwid[1]);
|
1326 |
|
|
else
|
1327 |
|
|
printk(", nwid off");
|
1328 |
|
|
|
1329 |
|
|
/* If 2.00 card */
|
1330 |
|
|
if(!(mmc_in(base, mmroff(0, mmr_fee_status)) &
|
1331 |
|
|
(MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY)))
|
1332 |
|
|
{
|
1333 |
|
|
unsigned short freq;
|
1334 |
|
|
|
1335 |
|
|
/* Ask the EEprom to read the frequency from the first area */
|
1336 |
|
|
fee_read(base, 0x00 /* 1st area - frequency... */,
|
1337 |
|
|
&freq, 1);
|
1338 |
|
|
|
1339 |
|
|
/* Print frequency */
|
1340 |
|
|
printk(", 2.00, %ld", (freq >> 6) + 2400L);
|
1341 |
|
|
|
1342 |
|
|
/* Hack !!! */
|
1343 |
|
|
if(freq & 0x20)
|
1344 |
|
|
printk(".5");
|
1345 |
|
|
}
|
1346 |
|
|
else
|
1347 |
|
|
{
|
1348 |
|
|
printk(", PCMCIA, ");
|
1349 |
|
|
switch (psa.psa_subband)
|
1350 |
|
|
{
|
1351 |
|
|
case PSA_SUBBAND_915:
|
1352 |
|
|
printk("915");
|
1353 |
|
|
break;
|
1354 |
|
|
case PSA_SUBBAND_2425:
|
1355 |
|
|
printk("2425");
|
1356 |
|
|
break;
|
1357 |
|
|
case PSA_SUBBAND_2460:
|
1358 |
|
|
printk("2460");
|
1359 |
|
|
break;
|
1360 |
|
|
case PSA_SUBBAND_2484:
|
1361 |
|
|
printk("2484");
|
1362 |
|
|
break;
|
1363 |
|
|
case PSA_SUBBAND_2430_5:
|
1364 |
|
|
printk("2430.5");
|
1365 |
|
|
break;
|
1366 |
|
|
default:
|
1367 |
|
|
printk("unknown");
|
1368 |
|
|
}
|
1369 |
|
|
}
|
1370 |
|
|
|
1371 |
|
|
printk(" MHz\n");
|
1372 |
|
|
#endif /* DEBUG_BASIC_SHOW */
|
1373 |
|
|
|
1374 |
|
|
#ifdef DEBUG_VERSION_SHOW
|
1375 |
|
|
/* Print version information */
|
1376 |
|
|
printk(KERN_NOTICE "%s", version);
|
1377 |
|
|
#endif
|
1378 |
|
|
} /* wv_init_info */
|
1379 |
|
|
|
1380 |
|
|
/********************* IOCTL, STATS & RECONFIG *********************/
|
1381 |
|
|
/*
|
1382 |
|
|
* We found here routines that are called by Linux on differents
|
1383 |
|
|
* occasions after the configuration and not for transmitting data
|
1384 |
|
|
* These may be called when the user use ifconfig, /proc/net/dev
|
1385 |
|
|
* or wireless extensions
|
1386 |
|
|
*/
|
1387 |
|
|
|
1388 |
|
|
/*------------------------------------------------------------------*/
|
1389 |
|
|
/*
|
1390 |
|
|
* Get the current ethernet statistics. This may be called with the
|
1391 |
|
|
* card open or closed.
|
1392 |
|
|
* Used when the user read /proc/net/dev
|
1393 |
|
|
*/
|
1394 |
|
|
static en_stats *
|
1395 |
|
|
wavelan_get_stats(struct net_device * dev)
|
1396 |
|
|
{
|
1397 |
|
|
#ifdef DEBUG_IOCTL_TRACE
|
1398 |
|
|
printk(KERN_DEBUG "%s: <>wavelan_get_stats()\n", dev->name);
|
1399 |
|
|
#endif
|
1400 |
|
|
|
1401 |
|
|
return(&((net_local *)netdev_priv(dev))->stats);
|
1402 |
|
|
}
|
1403 |
|
|
|
1404 |
|
|
/*------------------------------------------------------------------*/
|
1405 |
|
|
/*
|
1406 |
|
|
* Set or clear the multicast filter for this adaptor.
|
1407 |
|
|
* num_addrs == -1 Promiscuous mode, receive all packets
|
1408 |
|
|
* num_addrs == 0 Normal mode, clear multicast list
|
1409 |
|
|
* num_addrs > 0 Multicast mode, receive normal and MC packets,
|
1410 |
|
|
* and do best-effort filtering.
|
1411 |
|
|
*/
|
1412 |
|
|
|
1413 |
|
|
static void
|
1414 |
|
|
wavelan_set_multicast_list(struct net_device * dev)
|
1415 |
|
|
{
|
1416 |
|
|
net_local * lp = netdev_priv(dev);
|
1417 |
|
|
|
1418 |
|
|
#ifdef DEBUG_IOCTL_TRACE
|
1419 |
|
|
printk(KERN_DEBUG "%s: ->wavelan_set_multicast_list()\n", dev->name);
|
1420 |
|
|
#endif
|
1421 |
|
|
|
1422 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
1423 |
|
|
printk(KERN_DEBUG "%s: wavelan_set_multicast_list(): setting Rx mode %02X to %d addresses.\n",
|
1424 |
|
|
dev->name, dev->flags, dev->mc_count);
|
1425 |
|
|
#endif
|
1426 |
|
|
|
1427 |
|
|
if(dev->flags & IFF_PROMISC)
|
1428 |
|
|
{
|
1429 |
|
|
/*
|
1430 |
|
|
* Enable promiscuous mode: receive all packets.
|
1431 |
|
|
*/
|
1432 |
|
|
if(!lp->promiscuous)
|
1433 |
|
|
{
|
1434 |
|
|
lp->promiscuous = 1;
|
1435 |
|
|
lp->allmulticast = 0;
|
1436 |
|
|
lp->mc_count = 0;
|
1437 |
|
|
|
1438 |
|
|
wv_82593_reconfig(dev);
|
1439 |
|
|
|
1440 |
|
|
/* Tell the kernel that we are doing a really bad job... */
|
1441 |
|
|
dev->flags |= IFF_PROMISC;
|
1442 |
|
|
}
|
1443 |
|
|
}
|
1444 |
|
|
else
|
1445 |
|
|
/* If all multicast addresses
|
1446 |
|
|
* or too much multicast addresses for the hardware filter */
|
1447 |
|
|
if((dev->flags & IFF_ALLMULTI) ||
|
1448 |
|
|
(dev->mc_count > I82593_MAX_MULTICAST_ADDRESSES))
|
1449 |
|
|
{
|
1450 |
|
|
/*
|
1451 |
|
|
* Disable promiscuous mode, but active the all multicast mode
|
1452 |
|
|
*/
|
1453 |
|
|
if(!lp->allmulticast)
|
1454 |
|
|
{
|
1455 |
|
|
lp->promiscuous = 0;
|
1456 |
|
|
lp->allmulticast = 1;
|
1457 |
|
|
lp->mc_count = 0;
|
1458 |
|
|
|
1459 |
|
|
wv_82593_reconfig(dev);
|
1460 |
|
|
|
1461 |
|
|
/* Tell the kernel that we are doing a really bad job... */
|
1462 |
|
|
dev->flags |= IFF_ALLMULTI;
|
1463 |
|
|
}
|
1464 |
|
|
}
|
1465 |
|
|
else
|
1466 |
|
|
/* If there is some multicast addresses to send */
|
1467 |
|
|
if(dev->mc_list != (struct dev_mc_list *) NULL)
|
1468 |
|
|
{
|
1469 |
|
|
/*
|
1470 |
|
|
* Disable promiscuous mode, but receive all packets
|
1471 |
|
|
* in multicast list
|
1472 |
|
|
*/
|
1473 |
|
|
#ifdef MULTICAST_AVOID
|
1474 |
|
|
if(lp->promiscuous || lp->allmulticast ||
|
1475 |
|
|
(dev->mc_count != lp->mc_count))
|
1476 |
|
|
#endif
|
1477 |
|
|
{
|
1478 |
|
|
lp->promiscuous = 0;
|
1479 |
|
|
lp->allmulticast = 0;
|
1480 |
|
|
lp->mc_count = dev->mc_count;
|
1481 |
|
|
|
1482 |
|
|
wv_82593_reconfig(dev);
|
1483 |
|
|
}
|
1484 |
|
|
}
|
1485 |
|
|
else
|
1486 |
|
|
{
|
1487 |
|
|
/*
|
1488 |
|
|
* Switch to normal mode: disable promiscuous mode and
|
1489 |
|
|
* clear the multicast list.
|
1490 |
|
|
*/
|
1491 |
|
|
if(lp->promiscuous || lp->mc_count == 0)
|
1492 |
|
|
{
|
1493 |
|
|
lp->promiscuous = 0;
|
1494 |
|
|
lp->allmulticast = 0;
|
1495 |
|
|
lp->mc_count = 0;
|
1496 |
|
|
|
1497 |
|
|
wv_82593_reconfig(dev);
|
1498 |
|
|
}
|
1499 |
|
|
}
|
1500 |
|
|
#ifdef DEBUG_IOCTL_TRACE
|
1501 |
|
|
printk(KERN_DEBUG "%s: <-wavelan_set_multicast_list()\n", dev->name);
|
1502 |
|
|
#endif
|
1503 |
|
|
}
|
1504 |
|
|
|
1505 |
|
|
/*------------------------------------------------------------------*/
|
1506 |
|
|
/*
|
1507 |
|
|
* This function doesn't exist...
|
1508 |
|
|
* (Note : it was a nice way to test the reconfigure stuff...)
|
1509 |
|
|
*/
|
1510 |
|
|
#ifdef SET_MAC_ADDRESS
|
1511 |
|
|
static int
|
1512 |
|
|
wavelan_set_mac_address(struct net_device * dev,
|
1513 |
|
|
void * addr)
|
1514 |
|
|
{
|
1515 |
|
|
struct sockaddr * mac = addr;
|
1516 |
|
|
|
1517 |
|
|
/* Copy the address */
|
1518 |
|
|
memcpy(dev->dev_addr, mac->sa_data, WAVELAN_ADDR_SIZE);
|
1519 |
|
|
|
1520 |
|
|
/* Reconfig the beast */
|
1521 |
|
|
wv_82593_reconfig(dev);
|
1522 |
|
|
|
1523 |
|
|
return 0;
|
1524 |
|
|
}
|
1525 |
|
|
#endif /* SET_MAC_ADDRESS */
|
1526 |
|
|
|
1527 |
|
|
|
1528 |
|
|
/*------------------------------------------------------------------*/
|
1529 |
|
|
/*
|
1530 |
|
|
* Frequency setting (for hardware able of it)
|
1531 |
|
|
* It's a bit complicated and you don't really want to look into it...
|
1532 |
|
|
*/
|
1533 |
|
|
static inline int
|
1534 |
|
|
wv_set_frequency(u_long base, /* i/o port of the card */
|
1535 |
|
|
iw_freq * frequency)
|
1536 |
|
|
{
|
1537 |
|
|
const int BAND_NUM = 10; /* Number of bands */
|
1538 |
|
|
long freq = 0L; /* offset to 2.4 GHz in .5 MHz */
|
1539 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
1540 |
|
|
int i;
|
1541 |
|
|
#endif
|
1542 |
|
|
|
1543 |
|
|
/* Setting by frequency */
|
1544 |
|
|
/* Theoritically, you may set any frequency between
|
1545 |
|
|
* the two limits with a 0.5 MHz precision. In practice,
|
1546 |
|
|
* I don't want you to have trouble with local
|
1547 |
|
|
* regulations... */
|
1548 |
|
|
if((frequency->e == 1) &&
|
1549 |
|
|
(frequency->m >= (int) 2.412e8) && (frequency->m <= (int) 2.487e8))
|
1550 |
|
|
{
|
1551 |
|
|
freq = ((frequency->m / 10000) - 24000L) / 5;
|
1552 |
|
|
}
|
1553 |
|
|
|
1554 |
|
|
/* Setting by channel (same as wfreqsel) */
|
1555 |
|
|
/* Warning : each channel is 22MHz wide, so some of the channels
|
1556 |
|
|
* will interfere... */
|
1557 |
|
|
if((frequency->e == 0) &&
|
1558 |
|
|
(frequency->m >= 0) && (frequency->m < BAND_NUM))
|
1559 |
|
|
{
|
1560 |
|
|
/* Get frequency offset. */
|
1561 |
|
|
freq = channel_bands[frequency->m] >> 1;
|
1562 |
|
|
}
|
1563 |
|
|
|
1564 |
|
|
/* Verify if the frequency is allowed */
|
1565 |
|
|
if(freq != 0L)
|
1566 |
|
|
{
|
1567 |
|
|
u_short table[10]; /* Authorized frequency table */
|
1568 |
|
|
|
1569 |
|
|
/* Read the frequency table */
|
1570 |
|
|
fee_read(base, 0x71 /* frequency table */,
|
1571 |
|
|
table, 10);
|
1572 |
|
|
|
1573 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
1574 |
|
|
printk(KERN_DEBUG "Frequency table :");
|
1575 |
|
|
for(i = 0; i < 10; i++)
|
1576 |
|
|
{
|
1577 |
|
|
printk(" %04X",
|
1578 |
|
|
table[i]);
|
1579 |
|
|
}
|
1580 |
|
|
printk("\n");
|
1581 |
|
|
#endif
|
1582 |
|
|
|
1583 |
|
|
/* Look in the table if the frequency is allowed */
|
1584 |
|
|
if(!(table[9 - ((freq - 24) / 16)] &
|
1585 |
|
|
(1 << ((freq - 24) % 16))))
|
1586 |
|
|
return -EINVAL; /* not allowed */
|
1587 |
|
|
}
|
1588 |
|
|
else
|
1589 |
|
|
return -EINVAL;
|
1590 |
|
|
|
1591 |
|
|
/* If we get a usable frequency */
|
1592 |
|
|
if(freq != 0L)
|
1593 |
|
|
{
|
1594 |
|
|
unsigned short area[16];
|
1595 |
|
|
unsigned short dac[2];
|
1596 |
|
|
unsigned short area_verify[16];
|
1597 |
|
|
unsigned short dac_verify[2];
|
1598 |
|
|
/* Corresponding gain (in the power adjust value table)
|
1599 |
|
|
* see AT&T Wavelan Data Manual, REF 407-024689/E, page 3-8
|
1600 |
|
|
* & WCIN062D.DOC, page 6.2.9 */
|
1601 |
|
|
unsigned short power_limit[] = { 40, 80, 120, 160, 0 };
|
1602 |
|
|
int power_band = 0; /* Selected band */
|
1603 |
|
|
unsigned short power_adjust; /* Correct value */
|
1604 |
|
|
|
1605 |
|
|
/* Search for the gain */
|
1606 |
|
|
power_band = 0;
|
1607 |
|
|
while((freq > power_limit[power_band]) &&
|
1608 |
|
|
(power_limit[++power_band] != 0))
|
1609 |
|
|
;
|
1610 |
|
|
|
1611 |
|
|
/* Read the first area */
|
1612 |
|
|
fee_read(base, 0x00,
|
1613 |
|
|
area, 16);
|
1614 |
|
|
|
1615 |
|
|
/* Read the DAC */
|
1616 |
|
|
fee_read(base, 0x60,
|
1617 |
|
|
dac, 2);
|
1618 |
|
|
|
1619 |
|
|
/* Read the new power adjust value */
|
1620 |
|
|
fee_read(base, 0x6B - (power_band >> 1),
|
1621 |
|
|
&power_adjust, 1);
|
1622 |
|
|
if(power_band & 0x1)
|
1623 |
|
|
power_adjust >>= 8;
|
1624 |
|
|
else
|
1625 |
|
|
power_adjust &= 0xFF;
|
1626 |
|
|
|
1627 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
1628 |
|
|
printk(KERN_DEBUG "Wavelan EEprom Area 1 :");
|
1629 |
|
|
for(i = 0; i < 16; i++)
|
1630 |
|
|
{
|
1631 |
|
|
printk(" %04X",
|
1632 |
|
|
area[i]);
|
1633 |
|
|
}
|
1634 |
|
|
printk("\n");
|
1635 |
|
|
|
1636 |
|
|
printk(KERN_DEBUG "Wavelan EEprom DAC : %04X %04X\n",
|
1637 |
|
|
dac[0], dac[1]);
|
1638 |
|
|
#endif
|
1639 |
|
|
|
1640 |
|
|
/* Frequency offset (for info only...) */
|
1641 |
|
|
area[0] = ((freq << 5) & 0xFFE0) | (area[0] & 0x1F);
|
1642 |
|
|
|
1643 |
|
|
/* Receiver Principle main divider coefficient */
|
1644 |
|
|
area[3] = (freq >> 1) + 2400L - 352L;
|
1645 |
|
|
area[2] = ((freq & 0x1) << 4) | (area[2] & 0xFFEF);
|
1646 |
|
|
|
1647 |
|
|
/* Transmitter Main divider coefficient */
|
1648 |
|
|
area[13] = (freq >> 1) + 2400L;
|
1649 |
|
|
area[12] = ((freq & 0x1) << 4) | (area[2] & 0xFFEF);
|
1650 |
|
|
|
1651 |
|
|
/* Others part of the area are flags, bit streams or unused... */
|
1652 |
|
|
|
1653 |
|
|
/* Set the value in the DAC */
|
1654 |
|
|
dac[1] = ((power_adjust >> 1) & 0x7F) | (dac[1] & 0xFF80);
|
1655 |
|
|
dac[0] = ((power_adjust & 0x1) << 4) | (dac[0] & 0xFFEF);
|
1656 |
|
|
|
1657 |
|
|
/* Write the first area */
|
1658 |
|
|
fee_write(base, 0x00,
|
1659 |
|
|
area, 16);
|
1660 |
|
|
|
1661 |
|
|
/* Write the DAC */
|
1662 |
|
|
fee_write(base, 0x60,
|
1663 |
|
|
dac, 2);
|
1664 |
|
|
|
1665 |
|
|
/* We now should verify here that the EEprom writing was ok */
|
1666 |
|
|
|
1667 |
|
|
/* ReRead the first area */
|
1668 |
|
|
fee_read(base, 0x00,
|
1669 |
|
|
area_verify, 16);
|
1670 |
|
|
|
1671 |
|
|
/* ReRead the DAC */
|
1672 |
|
|
fee_read(base, 0x60,
|
1673 |
|
|
dac_verify, 2);
|
1674 |
|
|
|
1675 |
|
|
/* Compare */
|
1676 |
|
|
if(memcmp(area, area_verify, 16 * 2) ||
|
1677 |
|
|
memcmp(dac, dac_verify, 2 * 2))
|
1678 |
|
|
{
|
1679 |
|
|
#ifdef DEBUG_IOCTL_ERROR
|
1680 |
|
|
printk(KERN_INFO "Wavelan: wv_set_frequency : unable to write new frequency to EEprom (?)\n");
|
1681 |
|
|
#endif
|
1682 |
|
|
return -EOPNOTSUPP;
|
1683 |
|
|
}
|
1684 |
|
|
|
1685 |
|
|
/* We must download the frequency parameters to the
|
1686 |
|
|
* synthetisers (from the EEprom - area 1)
|
1687 |
|
|
* Note : as the EEprom is auto decremented, we set the end
|
1688 |
|
|
* if the area... */
|
1689 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), 0x0F);
|
1690 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl),
|
1691 |
|
|
MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD);
|
1692 |
|
|
|
1693 |
|
|
/* Wait until the download is finished */
|
1694 |
|
|
fee_wait(base, 100, 100);
|
1695 |
|
|
|
1696 |
|
|
/* We must now download the power adjust value (gain) to
|
1697 |
|
|
* the synthetisers (from the EEprom - area 7 - DAC) */
|
1698 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_addr), 0x61);
|
1699 |
|
|
mmc_out(base, mmwoff(0, mmw_fee_ctrl),
|
1700 |
|
|
MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD);
|
1701 |
|
|
|
1702 |
|
|
/* Wait until the download is finished */
|
1703 |
|
|
fee_wait(base, 100, 100);
|
1704 |
|
|
|
1705 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
1706 |
|
|
/* Verification of what we have done... */
|
1707 |
|
|
|
1708 |
|
|
printk(KERN_DEBUG "Wavelan EEprom Area 1 :");
|
1709 |
|
|
for(i = 0; i < 16; i++)
|
1710 |
|
|
{
|
1711 |
|
|
printk(" %04X",
|
1712 |
|
|
area_verify[i]);
|
1713 |
|
|
}
|
1714 |
|
|
printk("\n");
|
1715 |
|
|
|
1716 |
|
|
printk(KERN_DEBUG "Wavelan EEprom DAC : %04X %04X\n",
|
1717 |
|
|
dac_verify[0], dac_verify[1]);
|
1718 |
|
|
#endif
|
1719 |
|
|
|
1720 |
|
|
return 0;
|
1721 |
|
|
}
|
1722 |
|
|
else
|
1723 |
|
|
return -EINVAL; /* Bah, never get there... */
|
1724 |
|
|
}
|
1725 |
|
|
|
1726 |
|
|
/*------------------------------------------------------------------*/
|
1727 |
|
|
/*
|
1728 |
|
|
* Give the list of available frequencies
|
1729 |
|
|
*/
|
1730 |
|
|
static inline int
|
1731 |
|
|
wv_frequency_list(u_long base, /* i/o port of the card */
|
1732 |
|
|
iw_freq * list, /* List of frequency to fill */
|
1733 |
|
|
int max) /* Maximum number of frequencies */
|
1734 |
|
|
{
|
1735 |
|
|
u_short table[10]; /* Authorized frequency table */
|
1736 |
|
|
long freq = 0L; /* offset to 2.4 GHz in .5 MHz + 12 MHz */
|
1737 |
|
|
int i; /* index in the table */
|
1738 |
|
|
const int BAND_NUM = 10; /* Number of bands */
|
1739 |
|
|
int c = 0; /* Channel number */
|
1740 |
|
|
|
1741 |
|
|
/* Read the frequency table */
|
1742 |
|
|
fee_read(base, 0x71 /* frequency table */,
|
1743 |
|
|
table, 10);
|
1744 |
|
|
|
1745 |
|
|
/* Look all frequencies */
|
1746 |
|
|
i = 0;
|
1747 |
|
|
for(freq = 0; freq < 150; freq++)
|
1748 |
|
|
/* Look in the table if the frequency is allowed */
|
1749 |
|
|
if(table[9 - (freq / 16)] & (1 << (freq % 16)))
|
1750 |
|
|
{
|
1751 |
|
|
/* Compute approximate channel number */
|
1752 |
|
|
while((((channel_bands[c] >> 1) - 24) < freq) &&
|
1753 |
|
|
(c < BAND_NUM))
|
1754 |
|
|
c++;
|
1755 |
|
|
list[i].i = c; /* Set the list index */
|
1756 |
|
|
|
1757 |
|
|
/* put in the list */
|
1758 |
|
|
list[i].m = (((freq + 24) * 5) + 24000L) * 10000;
|
1759 |
|
|
list[i++].e = 1;
|
1760 |
|
|
|
1761 |
|
|
/* Check number */
|
1762 |
|
|
if(i >= max)
|
1763 |
|
|
return(i);
|
1764 |
|
|
}
|
1765 |
|
|
|
1766 |
|
|
return(i);
|
1767 |
|
|
}
|
1768 |
|
|
|
1769 |
|
|
#ifdef IW_WIRELESS_SPY
|
1770 |
|
|
/*------------------------------------------------------------------*/
|
1771 |
|
|
/*
|
1772 |
|
|
* Gather wireless spy statistics : for each packet, compare the source
|
1773 |
|
|
* address with out list, and if match, get the stats...
|
1774 |
|
|
* Sorry, but this function really need wireless extensions...
|
1775 |
|
|
*/
|
1776 |
|
|
static inline void
|
1777 |
|
|
wl_spy_gather(struct net_device * dev,
|
1778 |
|
|
u_char * mac, /* MAC address */
|
1779 |
|
|
u_char * stats) /* Statistics to gather */
|
1780 |
|
|
{
|
1781 |
|
|
struct iw_quality wstats;
|
1782 |
|
|
|
1783 |
|
|
wstats.qual = stats[2] & MMR_SGNL_QUAL;
|
1784 |
|
|
wstats.level = stats[0] & MMR_SIGNAL_LVL;
|
1785 |
|
|
wstats.noise = stats[1] & MMR_SILENCE_LVL;
|
1786 |
|
|
wstats.updated = 0x7;
|
1787 |
|
|
|
1788 |
|
|
/* Update spy records */
|
1789 |
|
|
wireless_spy_update(dev, mac, &wstats);
|
1790 |
|
|
}
|
1791 |
|
|
#endif /* IW_WIRELESS_SPY */
|
1792 |
|
|
|
1793 |
|
|
#ifdef HISTOGRAM
|
1794 |
|
|
/*------------------------------------------------------------------*/
|
1795 |
|
|
/*
|
1796 |
|
|
* This function calculate an histogram on the signal level.
|
1797 |
|
|
* As the noise is quite constant, it's like doing it on the SNR.
|
1798 |
|
|
* We have defined a set of interval (lp->his_range), and each time
|
1799 |
|
|
* the level goes in that interval, we increment the count (lp->his_sum).
|
1800 |
|
|
* With this histogram you may detect if one wavelan is really weak,
|
1801 |
|
|
* or you may also calculate the mean and standard deviation of the level...
|
1802 |
|
|
*/
|
1803 |
|
|
static inline void
|
1804 |
|
|
wl_his_gather(struct net_device * dev,
|
1805 |
|
|
u_char * stats) /* Statistics to gather */
|
1806 |
|
|
{
|
1807 |
|
|
net_local * lp = netdev_priv(dev);
|
1808 |
|
|
u_char level = stats[0] & MMR_SIGNAL_LVL;
|
1809 |
|
|
int i;
|
1810 |
|
|
|
1811 |
|
|
/* Find the correct interval */
|
1812 |
|
|
i = 0;
|
1813 |
|
|
while((i < (lp->his_number - 1)) && (level >= lp->his_range[i++]))
|
1814 |
|
|
;
|
1815 |
|
|
|
1816 |
|
|
/* Increment interval counter */
|
1817 |
|
|
(lp->his_sum[i])++;
|
1818 |
|
|
}
|
1819 |
|
|
#endif /* HISTOGRAM */
|
1820 |
|
|
|
1821 |
|
|
static void wl_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
|
1822 |
|
|
{
|
1823 |
|
|
strncpy(info->driver, "wavelan_cs", sizeof(info->driver)-1);
|
1824 |
|
|
}
|
1825 |
|
|
|
1826 |
|
|
static const struct ethtool_ops ops = {
|
1827 |
|
|
.get_drvinfo = wl_get_drvinfo
|
1828 |
|
|
};
|
1829 |
|
|
|
1830 |
|
|
/*------------------------------------------------------------------*/
|
1831 |
|
|
/*
|
1832 |
|
|
* Wireless Handler : get protocol name
|
1833 |
|
|
*/
|
1834 |
|
|
static int wavelan_get_name(struct net_device *dev,
|
1835 |
|
|
struct iw_request_info *info,
|
1836 |
|
|
union iwreq_data *wrqu,
|
1837 |
|
|
char *extra)
|
1838 |
|
|
{
|
1839 |
|
|
strcpy(wrqu->name, "WaveLAN");
|
1840 |
|
|
return 0;
|
1841 |
|
|
}
|
1842 |
|
|
|
1843 |
|
|
/*------------------------------------------------------------------*/
|
1844 |
|
|
/*
|
1845 |
|
|
* Wireless Handler : set NWID
|
1846 |
|
|
*/
|
1847 |
|
|
static int wavelan_set_nwid(struct net_device *dev,
|
1848 |
|
|
struct iw_request_info *info,
|
1849 |
|
|
union iwreq_data *wrqu,
|
1850 |
|
|
char *extra)
|
1851 |
|
|
{
|
1852 |
|
|
kio_addr_t base = dev->base_addr;
|
1853 |
|
|
net_local *lp = netdev_priv(dev);
|
1854 |
|
|
psa_t psa;
|
1855 |
|
|
mm_t m;
|
1856 |
|
|
unsigned long flags;
|
1857 |
|
|
int ret = 0;
|
1858 |
|
|
|
1859 |
|
|
/* Disable interrupts and save flags. */
|
1860 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
1861 |
|
|
|
1862 |
|
|
/* Set NWID in WaveLAN. */
|
1863 |
|
|
if (!wrqu->nwid.disabled) {
|
1864 |
|
|
/* Set NWID in psa */
|
1865 |
|
|
psa.psa_nwid[0] = (wrqu->nwid.value & 0xFF00) >> 8;
|
1866 |
|
|
psa.psa_nwid[1] = wrqu->nwid.value & 0xFF;
|
1867 |
|
|
psa.psa_nwid_select = 0x01;
|
1868 |
|
|
psa_write(dev,
|
1869 |
|
|
(char *) psa.psa_nwid - (char *) &psa,
|
1870 |
|
|
(unsigned char *) psa.psa_nwid, 3);
|
1871 |
|
|
|
1872 |
|
|
/* Set NWID in mmc. */
|
1873 |
|
|
m.w.mmw_netw_id_l = psa.psa_nwid[1];
|
1874 |
|
|
m.w.mmw_netw_id_h = psa.psa_nwid[0];
|
1875 |
|
|
mmc_write(base,
|
1876 |
|
|
(char *) &m.w.mmw_netw_id_l -
|
1877 |
|
|
(char *) &m,
|
1878 |
|
|
(unsigned char *) &m.w.mmw_netw_id_l, 2);
|
1879 |
|
|
mmc_out(base, mmwoff(0, mmw_loopt_sel), 0x00);
|
1880 |
|
|
} else {
|
1881 |
|
|
/* Disable NWID in the psa. */
|
1882 |
|
|
psa.psa_nwid_select = 0x00;
|
1883 |
|
|
psa_write(dev,
|
1884 |
|
|
(char *) &psa.psa_nwid_select -
|
1885 |
|
|
(char *) &psa,
|
1886 |
|
|
(unsigned char *) &psa.psa_nwid_select,
|
1887 |
|
|
1);
|
1888 |
|
|
|
1889 |
|
|
/* Disable NWID in the mmc (no filtering). */
|
1890 |
|
|
mmc_out(base, mmwoff(0, mmw_loopt_sel),
|
1891 |
|
|
MMW_LOOPT_SEL_DIS_NWID);
|
1892 |
|
|
}
|
1893 |
|
|
/* update the Wavelan checksum */
|
1894 |
|
|
update_psa_checksum(dev);
|
1895 |
|
|
|
1896 |
|
|
/* Enable interrupts and restore flags. */
|
1897 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
1898 |
|
|
|
1899 |
|
|
return ret;
|
1900 |
|
|
}
|
1901 |
|
|
|
1902 |
|
|
/*------------------------------------------------------------------*/
|
1903 |
|
|
/*
|
1904 |
|
|
* Wireless Handler : get NWID
|
1905 |
|
|
*/
|
1906 |
|
|
static int wavelan_get_nwid(struct net_device *dev,
|
1907 |
|
|
struct iw_request_info *info,
|
1908 |
|
|
union iwreq_data *wrqu,
|
1909 |
|
|
char *extra)
|
1910 |
|
|
{
|
1911 |
|
|
net_local *lp = netdev_priv(dev);
|
1912 |
|
|
psa_t psa;
|
1913 |
|
|
unsigned long flags;
|
1914 |
|
|
int ret = 0;
|
1915 |
|
|
|
1916 |
|
|
/* Disable interrupts and save flags. */
|
1917 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
1918 |
|
|
|
1919 |
|
|
/* Read the NWID. */
|
1920 |
|
|
psa_read(dev,
|
1921 |
|
|
(char *) psa.psa_nwid - (char *) &psa,
|
1922 |
|
|
(unsigned char *) psa.psa_nwid, 3);
|
1923 |
|
|
wrqu->nwid.value = (psa.psa_nwid[0] << 8) + psa.psa_nwid[1];
|
1924 |
|
|
wrqu->nwid.disabled = !(psa.psa_nwid_select);
|
1925 |
|
|
wrqu->nwid.fixed = 1; /* Superfluous */
|
1926 |
|
|
|
1927 |
|
|
/* Enable interrupts and restore flags. */
|
1928 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
1929 |
|
|
|
1930 |
|
|
return ret;
|
1931 |
|
|
}
|
1932 |
|
|
|
1933 |
|
|
/*------------------------------------------------------------------*/
|
1934 |
|
|
/*
|
1935 |
|
|
* Wireless Handler : set frequency
|
1936 |
|
|
*/
|
1937 |
|
|
static int wavelan_set_freq(struct net_device *dev,
|
1938 |
|
|
struct iw_request_info *info,
|
1939 |
|
|
union iwreq_data *wrqu,
|
1940 |
|
|
char *extra)
|
1941 |
|
|
{
|
1942 |
|
|
kio_addr_t base = dev->base_addr;
|
1943 |
|
|
net_local *lp = netdev_priv(dev);
|
1944 |
|
|
unsigned long flags;
|
1945 |
|
|
int ret;
|
1946 |
|
|
|
1947 |
|
|
/* Disable interrupts and save flags. */
|
1948 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
1949 |
|
|
|
1950 |
|
|
/* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
|
1951 |
|
|
if (!(mmc_in(base, mmroff(0, mmr_fee_status)) &
|
1952 |
|
|
(MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY)))
|
1953 |
|
|
ret = wv_set_frequency(base, &(wrqu->freq));
|
1954 |
|
|
else
|
1955 |
|
|
ret = -EOPNOTSUPP;
|
1956 |
|
|
|
1957 |
|
|
/* Enable interrupts and restore flags. */
|
1958 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
1959 |
|
|
|
1960 |
|
|
return ret;
|
1961 |
|
|
}
|
1962 |
|
|
|
1963 |
|
|
/*------------------------------------------------------------------*/
|
1964 |
|
|
/*
|
1965 |
|
|
* Wireless Handler : get frequency
|
1966 |
|
|
*/
|
1967 |
|
|
static int wavelan_get_freq(struct net_device *dev,
|
1968 |
|
|
struct iw_request_info *info,
|
1969 |
|
|
union iwreq_data *wrqu,
|
1970 |
|
|
char *extra)
|
1971 |
|
|
{
|
1972 |
|
|
kio_addr_t base = dev->base_addr;
|
1973 |
|
|
net_local *lp = netdev_priv(dev);
|
1974 |
|
|
psa_t psa;
|
1975 |
|
|
unsigned long flags;
|
1976 |
|
|
int ret = 0;
|
1977 |
|
|
|
1978 |
|
|
/* Disable interrupts and save flags. */
|
1979 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
1980 |
|
|
|
1981 |
|
|
/* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable).
|
1982 |
|
|
* Does it work for everybody, especially old cards? */
|
1983 |
|
|
if (!(mmc_in(base, mmroff(0, mmr_fee_status)) &
|
1984 |
|
|
(MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
|
1985 |
|
|
unsigned short freq;
|
1986 |
|
|
|
1987 |
|
|
/* Ask the EEPROM to read the frequency from the first area. */
|
1988 |
|
|
fee_read(base, 0x00, &freq, 1);
|
1989 |
|
|
wrqu->freq.m = ((freq >> 5) * 5 + 24000L) * 10000;
|
1990 |
|
|
wrqu->freq.e = 1;
|
1991 |
|
|
} else {
|
1992 |
|
|
psa_read(dev,
|
1993 |
|
|
(char *) &psa.psa_subband - (char *) &psa,
|
1994 |
|
|
(unsigned char *) &psa.psa_subband, 1);
|
1995 |
|
|
|
1996 |
|
|
if (psa.psa_subband <= 4) {
|
1997 |
|
|
wrqu->freq.m = fixed_bands[psa.psa_subband];
|
1998 |
|
|
wrqu->freq.e = (psa.psa_subband != 0);
|
1999 |
|
|
} else
|
2000 |
|
|
ret = -EOPNOTSUPP;
|
2001 |
|
|
}
|
2002 |
|
|
|
2003 |
|
|
/* Enable interrupts and restore flags. */
|
2004 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2005 |
|
|
|
2006 |
|
|
return ret;
|
2007 |
|
|
}
|
2008 |
|
|
|
2009 |
|
|
/*------------------------------------------------------------------*/
|
2010 |
|
|
/*
|
2011 |
|
|
* Wireless Handler : set level threshold
|
2012 |
|
|
*/
|
2013 |
|
|
static int wavelan_set_sens(struct net_device *dev,
|
2014 |
|
|
struct iw_request_info *info,
|
2015 |
|
|
union iwreq_data *wrqu,
|
2016 |
|
|
char *extra)
|
2017 |
|
|
{
|
2018 |
|
|
kio_addr_t base = dev->base_addr;
|
2019 |
|
|
net_local *lp = netdev_priv(dev);
|
2020 |
|
|
psa_t psa;
|
2021 |
|
|
unsigned long flags;
|
2022 |
|
|
int ret = 0;
|
2023 |
|
|
|
2024 |
|
|
/* Disable interrupts and save flags. */
|
2025 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2026 |
|
|
|
2027 |
|
|
/* Set the level threshold. */
|
2028 |
|
|
/* We should complain loudly if wrqu->sens.fixed = 0, because we
|
2029 |
|
|
* can't set auto mode... */
|
2030 |
|
|
psa.psa_thr_pre_set = wrqu->sens.value & 0x3F;
|
2031 |
|
|
psa_write(dev,
|
2032 |
|
|
(char *) &psa.psa_thr_pre_set - (char *) &psa,
|
2033 |
|
|
(unsigned char *) &psa.psa_thr_pre_set, 1);
|
2034 |
|
|
/* update the Wavelan checksum */
|
2035 |
|
|
update_psa_checksum(dev);
|
2036 |
|
|
mmc_out(base, mmwoff(0, mmw_thr_pre_set),
|
2037 |
|
|
psa.psa_thr_pre_set);
|
2038 |
|
|
|
2039 |
|
|
/* Enable interrupts and restore flags. */
|
2040 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2041 |
|
|
|
2042 |
|
|
return ret;
|
2043 |
|
|
}
|
2044 |
|
|
|
2045 |
|
|
/*------------------------------------------------------------------*/
|
2046 |
|
|
/*
|
2047 |
|
|
* Wireless Handler : get level threshold
|
2048 |
|
|
*/
|
2049 |
|
|
static int wavelan_get_sens(struct net_device *dev,
|
2050 |
|
|
struct iw_request_info *info,
|
2051 |
|
|
union iwreq_data *wrqu,
|
2052 |
|
|
char *extra)
|
2053 |
|
|
{
|
2054 |
|
|
net_local *lp = netdev_priv(dev);
|
2055 |
|
|
psa_t psa;
|
2056 |
|
|
unsigned long flags;
|
2057 |
|
|
int ret = 0;
|
2058 |
|
|
|
2059 |
|
|
/* Disable interrupts and save flags. */
|
2060 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2061 |
|
|
|
2062 |
|
|
/* Read the level threshold. */
|
2063 |
|
|
psa_read(dev,
|
2064 |
|
|
(char *) &psa.psa_thr_pre_set - (char *) &psa,
|
2065 |
|
|
(unsigned char *) &psa.psa_thr_pre_set, 1);
|
2066 |
|
|
wrqu->sens.value = psa.psa_thr_pre_set & 0x3F;
|
2067 |
|
|
wrqu->sens.fixed = 1;
|
2068 |
|
|
|
2069 |
|
|
/* Enable interrupts and restore flags. */
|
2070 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2071 |
|
|
|
2072 |
|
|
return ret;
|
2073 |
|
|
}
|
2074 |
|
|
|
2075 |
|
|
/*------------------------------------------------------------------*/
|
2076 |
|
|
/*
|
2077 |
|
|
* Wireless Handler : set encryption key
|
2078 |
|
|
*/
|
2079 |
|
|
static int wavelan_set_encode(struct net_device *dev,
|
2080 |
|
|
struct iw_request_info *info,
|
2081 |
|
|
union iwreq_data *wrqu,
|
2082 |
|
|
char *extra)
|
2083 |
|
|
{
|
2084 |
|
|
kio_addr_t base = dev->base_addr;
|
2085 |
|
|
net_local *lp = netdev_priv(dev);
|
2086 |
|
|
unsigned long flags;
|
2087 |
|
|
psa_t psa;
|
2088 |
|
|
int ret = 0;
|
2089 |
|
|
|
2090 |
|
|
/* Disable interrupts and save flags. */
|
2091 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2092 |
|
|
|
2093 |
|
|
/* Check if capable of encryption */
|
2094 |
|
|
if (!mmc_encr(base)) {
|
2095 |
|
|
ret = -EOPNOTSUPP;
|
2096 |
|
|
}
|
2097 |
|
|
|
2098 |
|
|
/* Check the size of the key */
|
2099 |
|
|
if((wrqu->encoding.length != 8) && (wrqu->encoding.length != 0)) {
|
2100 |
|
|
ret = -EINVAL;
|
2101 |
|
|
}
|
2102 |
|
|
|
2103 |
|
|
if(!ret) {
|
2104 |
|
|
/* Basic checking... */
|
2105 |
|
|
if (wrqu->encoding.length == 8) {
|
2106 |
|
|
/* Copy the key in the driver */
|
2107 |
|
|
memcpy(psa.psa_encryption_key, extra,
|
2108 |
|
|
wrqu->encoding.length);
|
2109 |
|
|
psa.psa_encryption_select = 1;
|
2110 |
|
|
|
2111 |
|
|
psa_write(dev,
|
2112 |
|
|
(char *) &psa.psa_encryption_select -
|
2113 |
|
|
(char *) &psa,
|
2114 |
|
|
(unsigned char *) &psa.
|
2115 |
|
|
psa_encryption_select, 8 + 1);
|
2116 |
|
|
|
2117 |
|
|
mmc_out(base, mmwoff(0, mmw_encr_enable),
|
2118 |
|
|
MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE);
|
2119 |
|
|
mmc_write(base, mmwoff(0, mmw_encr_key),
|
2120 |
|
|
(unsigned char *) &psa.
|
2121 |
|
|
psa_encryption_key, 8);
|
2122 |
|
|
}
|
2123 |
|
|
|
2124 |
|
|
/* disable encryption */
|
2125 |
|
|
if (wrqu->encoding.flags & IW_ENCODE_DISABLED) {
|
2126 |
|
|
psa.psa_encryption_select = 0;
|
2127 |
|
|
psa_write(dev,
|
2128 |
|
|
(char *) &psa.psa_encryption_select -
|
2129 |
|
|
(char *) &psa,
|
2130 |
|
|
(unsigned char *) &psa.
|
2131 |
|
|
psa_encryption_select, 1);
|
2132 |
|
|
|
2133 |
|
|
mmc_out(base, mmwoff(0, mmw_encr_enable), 0);
|
2134 |
|
|
}
|
2135 |
|
|
/* update the Wavelan checksum */
|
2136 |
|
|
update_psa_checksum(dev);
|
2137 |
|
|
}
|
2138 |
|
|
|
2139 |
|
|
/* Enable interrupts and restore flags. */
|
2140 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2141 |
|
|
|
2142 |
|
|
return ret;
|
2143 |
|
|
}
|
2144 |
|
|
|
2145 |
|
|
/*------------------------------------------------------------------*/
|
2146 |
|
|
/*
|
2147 |
|
|
* Wireless Handler : get encryption key
|
2148 |
|
|
*/
|
2149 |
|
|
static int wavelan_get_encode(struct net_device *dev,
|
2150 |
|
|
struct iw_request_info *info,
|
2151 |
|
|
union iwreq_data *wrqu,
|
2152 |
|
|
char *extra)
|
2153 |
|
|
{
|
2154 |
|
|
kio_addr_t base = dev->base_addr;
|
2155 |
|
|
net_local *lp = netdev_priv(dev);
|
2156 |
|
|
psa_t psa;
|
2157 |
|
|
unsigned long flags;
|
2158 |
|
|
int ret = 0;
|
2159 |
|
|
|
2160 |
|
|
/* Disable interrupts and save flags. */
|
2161 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2162 |
|
|
|
2163 |
|
|
/* Check if encryption is available */
|
2164 |
|
|
if (!mmc_encr(base)) {
|
2165 |
|
|
ret = -EOPNOTSUPP;
|
2166 |
|
|
} else {
|
2167 |
|
|
/* Read the encryption key */
|
2168 |
|
|
psa_read(dev,
|
2169 |
|
|
(char *) &psa.psa_encryption_select -
|
2170 |
|
|
(char *) &psa,
|
2171 |
|
|
(unsigned char *) &psa.
|
2172 |
|
|
psa_encryption_select, 1 + 8);
|
2173 |
|
|
|
2174 |
|
|
/* encryption is enabled ? */
|
2175 |
|
|
if (psa.psa_encryption_select)
|
2176 |
|
|
wrqu->encoding.flags = IW_ENCODE_ENABLED;
|
2177 |
|
|
else
|
2178 |
|
|
wrqu->encoding.flags = IW_ENCODE_DISABLED;
|
2179 |
|
|
wrqu->encoding.flags |= mmc_encr(base);
|
2180 |
|
|
|
2181 |
|
|
/* Copy the key to the user buffer */
|
2182 |
|
|
wrqu->encoding.length = 8;
|
2183 |
|
|
memcpy(extra, psa.psa_encryption_key, wrqu->encoding.length);
|
2184 |
|
|
}
|
2185 |
|
|
|
2186 |
|
|
/* Enable interrupts and restore flags. */
|
2187 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2188 |
|
|
|
2189 |
|
|
return ret;
|
2190 |
|
|
}
|
2191 |
|
|
|
2192 |
|
|
#ifdef WAVELAN_ROAMING_EXT
|
2193 |
|
|
/*------------------------------------------------------------------*/
|
2194 |
|
|
/*
|
2195 |
|
|
* Wireless Handler : set ESSID (domain)
|
2196 |
|
|
*/
|
2197 |
|
|
static int wavelan_set_essid(struct net_device *dev,
|
2198 |
|
|
struct iw_request_info *info,
|
2199 |
|
|
union iwreq_data *wrqu,
|
2200 |
|
|
char *extra)
|
2201 |
|
|
{
|
2202 |
|
|
net_local *lp = netdev_priv(dev);
|
2203 |
|
|
unsigned long flags;
|
2204 |
|
|
int ret = 0;
|
2205 |
|
|
|
2206 |
|
|
/* Disable interrupts and save flags. */
|
2207 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2208 |
|
|
|
2209 |
|
|
/* Check if disable */
|
2210 |
|
|
if(wrqu->data.flags == 0)
|
2211 |
|
|
lp->filter_domains = 0;
|
2212 |
|
|
else {
|
2213 |
|
|
char essid[IW_ESSID_MAX_SIZE + 1];
|
2214 |
|
|
char * endp;
|
2215 |
|
|
|
2216 |
|
|
/* Terminate the string */
|
2217 |
|
|
memcpy(essid, extra, wrqu->data.length);
|
2218 |
|
|
essid[IW_ESSID_MAX_SIZE] = '\0';
|
2219 |
|
|
|
2220 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
2221 |
|
|
printk(KERN_DEBUG "SetEssid : ``%s''\n", essid);
|
2222 |
|
|
#endif /* DEBUG_IOCTL_INFO */
|
2223 |
|
|
|
2224 |
|
|
/* Convert to a number (note : Wavelan specific) */
|
2225 |
|
|
lp->domain_id = simple_strtoul(essid, &endp, 16);
|
2226 |
|
|
/* Has it worked ? */
|
2227 |
|
|
if(endp > essid)
|
2228 |
|
|
lp->filter_domains = 1;
|
2229 |
|
|
else {
|
2230 |
|
|
lp->filter_domains = 0;
|
2231 |
|
|
ret = -EINVAL;
|
2232 |
|
|
}
|
2233 |
|
|
}
|
2234 |
|
|
|
2235 |
|
|
/* Enable interrupts and restore flags. */
|
2236 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2237 |
|
|
|
2238 |
|
|
return ret;
|
2239 |
|
|
}
|
2240 |
|
|
|
2241 |
|
|
/*------------------------------------------------------------------*/
|
2242 |
|
|
/*
|
2243 |
|
|
* Wireless Handler : get ESSID (domain)
|
2244 |
|
|
*/
|
2245 |
|
|
static int wavelan_get_essid(struct net_device *dev,
|
2246 |
|
|
struct iw_request_info *info,
|
2247 |
|
|
union iwreq_data *wrqu,
|
2248 |
|
|
char *extra)
|
2249 |
|
|
{
|
2250 |
|
|
net_local *lp = netdev_priv(dev);
|
2251 |
|
|
|
2252 |
|
|
/* Is the domain ID active ? */
|
2253 |
|
|
wrqu->data.flags = lp->filter_domains;
|
2254 |
|
|
|
2255 |
|
|
/* Copy Domain ID into a string (Wavelan specific) */
|
2256 |
|
|
/* Sound crazy, be we can't have a snprintf in the kernel !!! */
|
2257 |
|
|
sprintf(extra, "%lX", lp->domain_id);
|
2258 |
|
|
extra[IW_ESSID_MAX_SIZE] = '\0';
|
2259 |
|
|
|
2260 |
|
|
/* Set the length */
|
2261 |
|
|
wrqu->data.length = strlen(extra);
|
2262 |
|
|
|
2263 |
|
|
return 0;
|
2264 |
|
|
}
|
2265 |
|
|
|
2266 |
|
|
/*------------------------------------------------------------------*/
|
2267 |
|
|
/*
|
2268 |
|
|
* Wireless Handler : set AP address
|
2269 |
|
|
*/
|
2270 |
|
|
static int wavelan_set_wap(struct net_device *dev,
|
2271 |
|
|
struct iw_request_info *info,
|
2272 |
|
|
union iwreq_data *wrqu,
|
2273 |
|
|
char *extra)
|
2274 |
|
|
{
|
2275 |
|
|
#ifdef DEBUG_IOCTL_INFO
|
2276 |
|
|
printk(KERN_DEBUG "Set AP to : %02X:%02X:%02X:%02X:%02X:%02X\n",
|
2277 |
|
|
wrqu->ap_addr.sa_data[0],
|
2278 |
|
|
wrqu->ap_addr.sa_data[1],
|
2279 |
|
|
wrqu->ap_addr.sa_data[2],
|
2280 |
|
|
wrqu->ap_addr.sa_data[3],
|
2281 |
|
|
wrqu->ap_addr.sa_data[4],
|
2282 |
|
|
wrqu->ap_addr.sa_data[5]);
|
2283 |
|
|
#endif /* DEBUG_IOCTL_INFO */
|
2284 |
|
|
|
2285 |
|
|
return -EOPNOTSUPP;
|
2286 |
|
|
}
|
2287 |
|
|
|
2288 |
|
|
/*------------------------------------------------------------------*/
|
2289 |
|
|
/*
|
2290 |
|
|
* Wireless Handler : get AP address
|
2291 |
|
|
*/
|
2292 |
|
|
static int wavelan_get_wap(struct net_device *dev,
|
2293 |
|
|
struct iw_request_info *info,
|
2294 |
|
|
union iwreq_data *wrqu,
|
2295 |
|
|
char *extra)
|
2296 |
|
|
{
|
2297 |
|
|
/* Should get the real McCoy instead of own Ethernet address */
|
2298 |
|
|
memcpy(wrqu->ap_addr.sa_data, dev->dev_addr, WAVELAN_ADDR_SIZE);
|
2299 |
|
|
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
|
2300 |
|
|
|
2301 |
|
|
return -EOPNOTSUPP;
|
2302 |
|
|
}
|
2303 |
|
|
#endif /* WAVELAN_ROAMING_EXT */
|
2304 |
|
|
|
2305 |
|
|
#ifdef WAVELAN_ROAMING
|
2306 |
|
|
/*------------------------------------------------------------------*/
|
2307 |
|
|
/*
|
2308 |
|
|
* Wireless Handler : set mode
|
2309 |
|
|
*/
|
2310 |
|
|
static int wavelan_set_mode(struct net_device *dev,
|
2311 |
|
|
struct iw_request_info *info,
|
2312 |
|
|
union iwreq_data *wrqu,
|
2313 |
|
|
char *extra)
|
2314 |
|
|
{
|
2315 |
|
|
net_local *lp = netdev_priv(dev);
|
2316 |
|
|
unsigned long flags;
|
2317 |
|
|
int ret = 0;
|
2318 |
|
|
|
2319 |
|
|
/* Disable interrupts and save flags. */
|
2320 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2321 |
|
|
|
2322 |
|
|
/* Check mode */
|
2323 |
|
|
switch(wrqu->mode) {
|
2324 |
|
|
case IW_MODE_ADHOC:
|
2325 |
|
|
if(do_roaming) {
|
2326 |
|
|
wv_roam_cleanup(dev);
|
2327 |
|
|
do_roaming = 0;
|
2328 |
|
|
}
|
2329 |
|
|
break;
|
2330 |
|
|
case IW_MODE_INFRA:
|
2331 |
|
|
if(!do_roaming) {
|
2332 |
|
|
wv_roam_init(dev);
|
2333 |
|
|
do_roaming = 1;
|
2334 |
|
|
}
|
2335 |
|
|
break;
|
2336 |
|
|
default:
|
2337 |
|
|
ret = -EINVAL;
|
2338 |
|
|
}
|
2339 |
|
|
|
2340 |
|
|
/* Enable interrupts and restore flags. */
|
2341 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2342 |
|
|
|
2343 |
|
|
return ret;
|
2344 |
|
|
}
|
2345 |
|
|
|
2346 |
|
|
/*------------------------------------------------------------------*/
|
2347 |
|
|
/*
|
2348 |
|
|
* Wireless Handler : get mode
|
2349 |
|
|
*/
|
2350 |
|
|
static int wavelan_get_mode(struct net_device *dev,
|
2351 |
|
|
struct iw_request_info *info,
|
2352 |
|
|
union iwreq_data *wrqu,
|
2353 |
|
|
char *extra)
|
2354 |
|
|
{
|
2355 |
|
|
if(do_roaming)
|
2356 |
|
|
wrqu->mode = IW_MODE_INFRA;
|
2357 |
|
|
else
|
2358 |
|
|
wrqu->mode = IW_MODE_ADHOC;
|
2359 |
|
|
|
2360 |
|
|
return 0;
|
2361 |
|
|
}
|
2362 |
|
|
#endif /* WAVELAN_ROAMING */
|
2363 |
|
|
|
2364 |
|
|
/*------------------------------------------------------------------*/
|
2365 |
|
|
/*
|
2366 |
|
|
* Wireless Handler : get range info
|
2367 |
|
|
*/
|
2368 |
|
|
static int wavelan_get_range(struct net_device *dev,
|
2369 |
|
|
struct iw_request_info *info,
|
2370 |
|
|
union iwreq_data *wrqu,
|
2371 |
|
|
char *extra)
|
2372 |
|
|
{
|
2373 |
|
|
kio_addr_t base = dev->base_addr;
|
2374 |
|
|
net_local *lp = netdev_priv(dev);
|
2375 |
|
|
struct iw_range *range = (struct iw_range *) extra;
|
2376 |
|
|
unsigned long flags;
|
2377 |
|
|
int ret = 0;
|
2378 |
|
|
|
2379 |
|
|
/* Set the length (very important for backward compatibility) */
|
2380 |
|
|
wrqu->data.length = sizeof(struct iw_range);
|
2381 |
|
|
|
2382 |
|
|
/* Set all the info we don't care or don't know about to zero */
|
2383 |
|
|
memset(range, 0, sizeof(struct iw_range));
|
2384 |
|
|
|
2385 |
|
|
/* Set the Wireless Extension versions */
|
2386 |
|
|
range->we_version_compiled = WIRELESS_EXT;
|
2387 |
|
|
range->we_version_source = 9;
|
2388 |
|
|
|
2389 |
|
|
/* Set information in the range struct. */
|
2390 |
|
|
range->throughput = 1.4 * 1000 * 1000; /* don't argue on this ! */
|
2391 |
|
|
range->min_nwid = 0x0000;
|
2392 |
|
|
range->max_nwid = 0xFFFF;
|
2393 |
|
|
|
2394 |
|
|
range->sensitivity = 0x3F;
|
2395 |
|
|
range->max_qual.qual = MMR_SGNL_QUAL;
|
2396 |
|
|
range->max_qual.level = MMR_SIGNAL_LVL;
|
2397 |
|
|
range->max_qual.noise = MMR_SILENCE_LVL;
|
2398 |
|
|
range->avg_qual.qual = MMR_SGNL_QUAL; /* Always max */
|
2399 |
|
|
/* Need to get better values for those two */
|
2400 |
|
|
range->avg_qual.level = 30;
|
2401 |
|
|
range->avg_qual.noise = 8;
|
2402 |
|
|
|
2403 |
|
|
range->num_bitrates = 1;
|
2404 |
|
|
range->bitrate[0] = 2000000; /* 2 Mb/s */
|
2405 |
|
|
|
2406 |
|
|
/* Event capability (kernel + driver) */
|
2407 |
|
|
range->event_capa[0] = (IW_EVENT_CAPA_MASK(0x8B02) |
|
2408 |
|
|
IW_EVENT_CAPA_MASK(0x8B04) |
|
2409 |
|
|
IW_EVENT_CAPA_MASK(0x8B06));
|
2410 |
|
|
range->event_capa[1] = IW_EVENT_CAPA_K_1;
|
2411 |
|
|
|
2412 |
|
|
/* Disable interrupts and save flags. */
|
2413 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2414 |
|
|
|
2415 |
|
|
/* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
|
2416 |
|
|
if (!(mmc_in(base, mmroff(0, mmr_fee_status)) &
|
2417 |
|
|
(MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
|
2418 |
|
|
range->num_channels = 10;
|
2419 |
|
|
range->num_frequency = wv_frequency_list(base, range->freq,
|
2420 |
|
|
IW_MAX_FREQUENCIES);
|
2421 |
|
|
} else
|
2422 |
|
|
range->num_channels = range->num_frequency = 0;
|
2423 |
|
|
|
2424 |
|
|
/* Encryption supported ? */
|
2425 |
|
|
if (mmc_encr(base)) {
|
2426 |
|
|
range->encoding_size[0] = 8; /* DES = 64 bits key */
|
2427 |
|
|
range->num_encoding_sizes = 1;
|
2428 |
|
|
range->max_encoding_tokens = 1; /* Only one key possible */
|
2429 |
|
|
} else {
|
2430 |
|
|
range->num_encoding_sizes = 0;
|
2431 |
|
|
range->max_encoding_tokens = 0;
|
2432 |
|
|
}
|
2433 |
|
|
|
2434 |
|
|
/* Enable interrupts and restore flags. */
|
2435 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2436 |
|
|
|
2437 |
|
|
return ret;
|
2438 |
|
|
}
|
2439 |
|
|
|
2440 |
|
|
/*------------------------------------------------------------------*/
|
2441 |
|
|
/*
|
2442 |
|
|
* Wireless Private Handler : set quality threshold
|
2443 |
|
|
*/
|
2444 |
|
|
static int wavelan_set_qthr(struct net_device *dev,
|
2445 |
|
|
struct iw_request_info *info,
|
2446 |
|
|
union iwreq_data *wrqu,
|
2447 |
|
|
char *extra)
|
2448 |
|
|
{
|
2449 |
|
|
kio_addr_t base = dev->base_addr;
|
2450 |
|
|
net_local *lp = netdev_priv(dev);
|
2451 |
|
|
psa_t psa;
|
2452 |
|
|
unsigned long flags;
|
2453 |
|
|
|
2454 |
|
|
/* Disable interrupts and save flags. */
|
2455 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2456 |
|
|
|
2457 |
|
|
psa.psa_quality_thr = *(extra) & 0x0F;
|
2458 |
|
|
psa_write(dev,
|
2459 |
|
|
(char *) &psa.psa_quality_thr - (char *) &psa,
|
2460 |
|
|
(unsigned char *) &psa.psa_quality_thr, 1);
|
2461 |
|
|
/* update the Wavelan checksum */
|
2462 |
|
|
update_psa_checksum(dev);
|
2463 |
|
|
mmc_out(base, mmwoff(0, mmw_quality_thr),
|
2464 |
|
|
psa.psa_quality_thr);
|
2465 |
|
|
|
2466 |
|
|
/* Enable interrupts and restore flags. */
|
2467 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2468 |
|
|
|
2469 |
|
|
return 0;
|
2470 |
|
|
}
|
2471 |
|
|
|
2472 |
|
|
/*------------------------------------------------------------------*/
|
2473 |
|
|
/*
|
2474 |
|
|
* Wireless Private Handler : get quality threshold
|
2475 |
|
|
*/
|
2476 |
|
|
static int wavelan_get_qthr(struct net_device *dev,
|
2477 |
|
|
struct iw_request_info *info,
|
2478 |
|
|
union iwreq_data *wrqu,
|
2479 |
|
|
char *extra)
|
2480 |
|
|
{
|
2481 |
|
|
net_local *lp = netdev_priv(dev);
|
2482 |
|
|
psa_t psa;
|
2483 |
|
|
unsigned long flags;
|
2484 |
|
|
|
2485 |
|
|
/* Disable interrupts and save flags. */
|
2486 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2487 |
|
|
|
2488 |
|
|
psa_read(dev,
|
2489 |
|
|
(char *) &psa.psa_quality_thr - (char *) &psa,
|
2490 |
|
|
(unsigned char *) &psa.psa_quality_thr, 1);
|
2491 |
|
|
*(extra) = psa.psa_quality_thr & 0x0F;
|
2492 |
|
|
|
2493 |
|
|
/* Enable interrupts and restore flags. */
|
2494 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2495 |
|
|
|
2496 |
|
|
return 0;
|
2497 |
|
|
}
|
2498 |
|
|
|
2499 |
|
|
#ifdef WAVELAN_ROAMING
|
2500 |
|
|
/*------------------------------------------------------------------*/
|
2501 |
|
|
/*
|
2502 |
|
|
* Wireless Private Handler : set roaming
|
2503 |
|
|
*/
|
2504 |
|
|
static int wavelan_set_roam(struct net_device *dev,
|
2505 |
|
|
struct iw_request_info *info,
|
2506 |
|
|
union iwreq_data *wrqu,
|
2507 |
|
|
char *extra)
|
2508 |
|
|
{
|
2509 |
|
|
net_local *lp = netdev_priv(dev);
|
2510 |
|
|
unsigned long flags;
|
2511 |
|
|
|
2512 |
|
|
/* Disable interrupts and save flags. */
|
2513 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2514 |
|
|
|
2515 |
|
|
/* Note : should check if user == root */
|
2516 |
|
|
if(do_roaming && (*extra)==0)
|
2517 |
|
|
wv_roam_cleanup(dev);
|
2518 |
|
|
else if(do_roaming==0 && (*extra)!=0)
|
2519 |
|
|
wv_roam_init(dev);
|
2520 |
|
|
|
2521 |
|
|
do_roaming = (*extra);
|
2522 |
|
|
|
2523 |
|
|
/* Enable interrupts and restore flags. */
|
2524 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2525 |
|
|
|
2526 |
|
|
return 0;
|
2527 |
|
|
}
|
2528 |
|
|
|
2529 |
|
|
/*------------------------------------------------------------------*/
|
2530 |
|
|
/*
|
2531 |
|
|
* Wireless Private Handler : get quality threshold
|
2532 |
|
|
*/
|
2533 |
|
|
static int wavelan_get_roam(struct net_device *dev,
|
2534 |
|
|
struct iw_request_info *info,
|
2535 |
|
|
union iwreq_data *wrqu,
|
2536 |
|
|
char *extra)
|
2537 |
|
|
{
|
2538 |
|
|
*(extra) = do_roaming;
|
2539 |
|
|
|
2540 |
|
|
return 0;
|
2541 |
|
|
}
|
2542 |
|
|
#endif /* WAVELAN_ROAMING */
|
2543 |
|
|
|
2544 |
|
|
#ifdef HISTOGRAM
|
2545 |
|
|
/*------------------------------------------------------------------*/
|
2546 |
|
|
/*
|
2547 |
|
|
* Wireless Private Handler : set histogram
|
2548 |
|
|
*/
|
2549 |
|
|
static int wavelan_set_histo(struct net_device *dev,
|
2550 |
|
|
struct iw_request_info *info,
|
2551 |
|
|
union iwreq_data *wrqu,
|
2552 |
|
|
char *extra)
|
2553 |
|
|
{
|
2554 |
|
|
net_local *lp = netdev_priv(dev);
|
2555 |
|
|
|
2556 |
|
|
/* Check the number of intervals. */
|
2557 |
|
|
if (wrqu->data.length > 16) {
|
2558 |
|
|
return(-E2BIG);
|
2559 |
|
|
}
|
2560 |
|
|
|
2561 |
|
|
/* Disable histo while we copy the addresses.
|
2562 |
|
|
* As we don't disable interrupts, we need to do this */
|
2563 |
|
|
lp->his_number = 0;
|
2564 |
|
|
|
2565 |
|
|
/* Are there ranges to copy? */
|
2566 |
|
|
if (wrqu->data.length > 0) {
|
2567 |
|
|
/* Copy interval ranges to the driver */
|
2568 |
|
|
memcpy(lp->his_range, extra, wrqu->data.length);
|
2569 |
|
|
|
2570 |
|
|
{
|
2571 |
|
|
int i;
|
2572 |
|
|
printk(KERN_DEBUG "Histo :");
|
2573 |
|
|
for(i = 0; i < wrqu->data.length; i++)
|
2574 |
|
|
printk(" %d", lp->his_range[i]);
|
2575 |
|
|
printk("\n");
|
2576 |
|
|
}
|
2577 |
|
|
|
2578 |
|
|
/* Reset result structure. */
|
2579 |
|
|
memset(lp->his_sum, 0x00, sizeof(long) * 16);
|
2580 |
|
|
}
|
2581 |
|
|
|
2582 |
|
|
/* Now we can set the number of ranges */
|
2583 |
|
|
lp->his_number = wrqu->data.length;
|
2584 |
|
|
|
2585 |
|
|
return(0);
|
2586 |
|
|
}
|
2587 |
|
|
|
2588 |
|
|
/*------------------------------------------------------------------*/
|
2589 |
|
|
/*
|
2590 |
|
|
* Wireless Private Handler : get histogram
|
2591 |
|
|
*/
|
2592 |
|
|
static int wavelan_get_histo(struct net_device *dev,
|
2593 |
|
|
struct iw_request_info *info,
|
2594 |
|
|
union iwreq_data *wrqu,
|
2595 |
|
|
char *extra)
|
2596 |
|
|
{
|
2597 |
|
|
net_local *lp = netdev_priv(dev);
|
2598 |
|
|
|
2599 |
|
|
/* Set the number of intervals. */
|
2600 |
|
|
wrqu->data.length = lp->his_number;
|
2601 |
|
|
|
2602 |
|
|
/* Give back the distribution statistics */
|
2603 |
|
|
if(lp->his_number > 0)
|
2604 |
|
|
memcpy(extra, lp->his_sum, sizeof(long) * lp->his_number);
|
2605 |
|
|
|
2606 |
|
|
return(0);
|
2607 |
|
|
}
|
2608 |
|
|
#endif /* HISTOGRAM */
|
2609 |
|
|
|
2610 |
|
|
/*------------------------------------------------------------------*/
|
2611 |
|
|
/*
|
2612 |
|
|
* Structures to export the Wireless Handlers
|
2613 |
|
|
*/
|
2614 |
|
|
|
2615 |
|
|
static const struct iw_priv_args wavelan_private_args[] = {
|
2616 |
|
|
/*{ cmd, set_args, get_args, name } */
|
2617 |
|
|
{ SIOCSIPQTHR, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "setqualthr" },
|
2618 |
|
|
{ SIOCGIPQTHR, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "getqualthr" },
|
2619 |
|
|
{ SIOCSIPROAM, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "setroam" },
|
2620 |
|
|
{ SIOCGIPROAM, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "getroam" },
|
2621 |
|
|
{ SIOCSIPHISTO, IW_PRIV_TYPE_BYTE | 16, 0, "sethisto" },
|
2622 |
|
|
{ SIOCGIPHISTO, 0, IW_PRIV_TYPE_INT | 16, "gethisto" },
|
2623 |
|
|
};
|
2624 |
|
|
|
2625 |
|
|
static const iw_handler wavelan_handler[] =
|
2626 |
|
|
{
|
2627 |
|
|
NULL, /* SIOCSIWNAME */
|
2628 |
|
|
wavelan_get_name, /* SIOCGIWNAME */
|
2629 |
|
|
wavelan_set_nwid, /* SIOCSIWNWID */
|
2630 |
|
|
wavelan_get_nwid, /* SIOCGIWNWID */
|
2631 |
|
|
wavelan_set_freq, /* SIOCSIWFREQ */
|
2632 |
|
|
wavelan_get_freq, /* SIOCGIWFREQ */
|
2633 |
|
|
#ifdef WAVELAN_ROAMING
|
2634 |
|
|
wavelan_set_mode, /* SIOCSIWMODE */
|
2635 |
|
|
wavelan_get_mode, /* SIOCGIWMODE */
|
2636 |
|
|
#else /* WAVELAN_ROAMING */
|
2637 |
|
|
NULL, /* SIOCSIWMODE */
|
2638 |
|
|
NULL, /* SIOCGIWMODE */
|
2639 |
|
|
#endif /* WAVELAN_ROAMING */
|
2640 |
|
|
wavelan_set_sens, /* SIOCSIWSENS */
|
2641 |
|
|
wavelan_get_sens, /* SIOCGIWSENS */
|
2642 |
|
|
NULL, /* SIOCSIWRANGE */
|
2643 |
|
|
wavelan_get_range, /* SIOCGIWRANGE */
|
2644 |
|
|
NULL, /* SIOCSIWPRIV */
|
2645 |
|
|
NULL, /* SIOCGIWPRIV */
|
2646 |
|
|
NULL, /* SIOCSIWSTATS */
|
2647 |
|
|
NULL, /* SIOCGIWSTATS */
|
2648 |
|
|
iw_handler_set_spy, /* SIOCSIWSPY */
|
2649 |
|
|
iw_handler_get_spy, /* SIOCGIWSPY */
|
2650 |
|
|
iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
|
2651 |
|
|
iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
|
2652 |
|
|
#ifdef WAVELAN_ROAMING_EXT
|
2653 |
|
|
wavelan_set_wap, /* SIOCSIWAP */
|
2654 |
|
|
wavelan_get_wap, /* SIOCGIWAP */
|
2655 |
|
|
NULL, /* -- hole -- */
|
2656 |
|
|
NULL, /* SIOCGIWAPLIST */
|
2657 |
|
|
NULL, /* -- hole -- */
|
2658 |
|
|
NULL, /* -- hole -- */
|
2659 |
|
|
wavelan_set_essid, /* SIOCSIWESSID */
|
2660 |
|
|
wavelan_get_essid, /* SIOCGIWESSID */
|
2661 |
|
|
#else /* WAVELAN_ROAMING_EXT */
|
2662 |
|
|
NULL, /* SIOCSIWAP */
|
2663 |
|
|
NULL, /* SIOCGIWAP */
|
2664 |
|
|
NULL, /* -- hole -- */
|
2665 |
|
|
NULL, /* SIOCGIWAPLIST */
|
2666 |
|
|
NULL, /* -- hole -- */
|
2667 |
|
|
NULL, /* -- hole -- */
|
2668 |
|
|
NULL, /* SIOCSIWESSID */
|
2669 |
|
|
NULL, /* SIOCGIWESSID */
|
2670 |
|
|
#endif /* WAVELAN_ROAMING_EXT */
|
2671 |
|
|
NULL, /* SIOCSIWNICKN */
|
2672 |
|
|
NULL, /* SIOCGIWNICKN */
|
2673 |
|
|
NULL, /* -- hole -- */
|
2674 |
|
|
NULL, /* -- hole -- */
|
2675 |
|
|
NULL, /* SIOCSIWRATE */
|
2676 |
|
|
NULL, /* SIOCGIWRATE */
|
2677 |
|
|
NULL, /* SIOCSIWRTS */
|
2678 |
|
|
NULL, /* SIOCGIWRTS */
|
2679 |
|
|
NULL, /* SIOCSIWFRAG */
|
2680 |
|
|
NULL, /* SIOCGIWFRAG */
|
2681 |
|
|
NULL, /* SIOCSIWTXPOW */
|
2682 |
|
|
NULL, /* SIOCGIWTXPOW */
|
2683 |
|
|
NULL, /* SIOCSIWRETRY */
|
2684 |
|
|
NULL, /* SIOCGIWRETRY */
|
2685 |
|
|
wavelan_set_encode, /* SIOCSIWENCODE */
|
2686 |
|
|
wavelan_get_encode, /* SIOCGIWENCODE */
|
2687 |
|
|
};
|
2688 |
|
|
|
2689 |
|
|
static const iw_handler wavelan_private_handler[] =
|
2690 |
|
|
{
|
2691 |
|
|
wavelan_set_qthr, /* SIOCIWFIRSTPRIV */
|
2692 |
|
|
wavelan_get_qthr, /* SIOCIWFIRSTPRIV + 1 */
|
2693 |
|
|
#ifdef WAVELAN_ROAMING
|
2694 |
|
|
wavelan_set_roam, /* SIOCIWFIRSTPRIV + 2 */
|
2695 |
|
|
wavelan_get_roam, /* SIOCIWFIRSTPRIV + 3 */
|
2696 |
|
|
#else /* WAVELAN_ROAMING */
|
2697 |
|
|
NULL, /* SIOCIWFIRSTPRIV + 2 */
|
2698 |
|
|
NULL, /* SIOCIWFIRSTPRIV + 3 */
|
2699 |
|
|
#endif /* WAVELAN_ROAMING */
|
2700 |
|
|
#ifdef HISTOGRAM
|
2701 |
|
|
wavelan_set_histo, /* SIOCIWFIRSTPRIV + 4 */
|
2702 |
|
|
wavelan_get_histo, /* SIOCIWFIRSTPRIV + 5 */
|
2703 |
|
|
#endif /* HISTOGRAM */
|
2704 |
|
|
};
|
2705 |
|
|
|
2706 |
|
|
static const struct iw_handler_def wavelan_handler_def =
|
2707 |
|
|
{
|
2708 |
|
|
.num_standard = ARRAY_SIZE(wavelan_handler),
|
2709 |
|
|
.num_private = ARRAY_SIZE(wavelan_private_handler),
|
2710 |
|
|
.num_private_args = ARRAY_SIZE(wavelan_private_args),
|
2711 |
|
|
.standard = wavelan_handler,
|
2712 |
|
|
.private = wavelan_private_handler,
|
2713 |
|
|
.private_args = wavelan_private_args,
|
2714 |
|
|
.get_wireless_stats = wavelan_get_wireless_stats,
|
2715 |
|
|
};
|
2716 |
|
|
|
2717 |
|
|
/*------------------------------------------------------------------*/
|
2718 |
|
|
/*
|
2719 |
|
|
* Get wireless statistics
|
2720 |
|
|
* Called by /proc/net/wireless...
|
2721 |
|
|
*/
|
2722 |
|
|
static iw_stats *
|
2723 |
|
|
wavelan_get_wireless_stats(struct net_device * dev)
|
2724 |
|
|
{
|
2725 |
|
|
kio_addr_t base = dev->base_addr;
|
2726 |
|
|
net_local * lp = netdev_priv(dev);
|
2727 |
|
|
mmr_t m;
|
2728 |
|
|
iw_stats * wstats;
|
2729 |
|
|
unsigned long flags;
|
2730 |
|
|
|
2731 |
|
|
#ifdef DEBUG_IOCTL_TRACE
|
2732 |
|
|
printk(KERN_DEBUG "%s: ->wavelan_get_wireless_stats()\n", dev->name);
|
2733 |
|
|
#endif
|
2734 |
|
|
|
2735 |
|
|
/* Disable interrupts & save flags */
|
2736 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
2737 |
|
|
|
2738 |
|
|
wstats = &lp->wstats;
|
2739 |
|
|
|
2740 |
|
|
/* Get data from the mmc */
|
2741 |
|
|
mmc_out(base, mmwoff(0, mmw_freeze), 1);
|
2742 |
|
|
|
2743 |
|
|
mmc_read(base, mmroff(0, mmr_dce_status), &m.mmr_dce_status, 1);
|
2744 |
|
|
mmc_read(base, mmroff(0, mmr_wrong_nwid_l), &m.mmr_wrong_nwid_l, 2);
|
2745 |
|
|
mmc_read(base, mmroff(0, mmr_thr_pre_set), &m.mmr_thr_pre_set, 4);
|
2746 |
|
|
|
2747 |
|
|
mmc_out(base, mmwoff(0, mmw_freeze), 0);
|
2748 |
|
|
|
2749 |
|
|
/* Copy data to wireless stuff */
|
2750 |
|
|
wstats->status = m.mmr_dce_status & MMR_DCE_STATUS;
|
2751 |
|
|
wstats->qual.qual = m.mmr_sgnl_qual & MMR_SGNL_QUAL;
|
2752 |
|
|
wstats->qual.level = m.mmr_signal_lvl & MMR_SIGNAL_LVL;
|
2753 |
|
|
wstats->qual.noise = m.mmr_silence_lvl & MMR_SILENCE_LVL;
|
2754 |
|
|
wstats->qual.updated = (((m.mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) >> 7) |
|
2755 |
|
|
((m.mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) >> 6) |
|
2756 |
|
|
((m.mmr_silence_lvl & MMR_SILENCE_LVL_VALID) >> 5));
|
2757 |
|
|
wstats->discard.nwid += (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
|
2758 |
|
|
wstats->discard.code = 0L;
|
2759 |
|
|
wstats->discard.misc = 0L;
|
2760 |
|
|
|
2761 |
|
|
/* ReEnable interrupts & restore flags */
|
2762 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
2763 |
|
|
|
2764 |
|
|
#ifdef DEBUG_IOCTL_TRACE
|
2765 |
|
|
printk(KERN_DEBUG "%s: <-wavelan_get_wireless_stats()\n", dev->name);
|
2766 |
|
|
#endif
|
2767 |
|
|
return &lp->wstats;
|
2768 |
|
|
}
|
2769 |
|
|
|
2770 |
|
|
/************************* PACKET RECEPTION *************************/
|
2771 |
|
|
/*
|
2772 |
|
|
* This part deal with receiving the packets.
|
2773 |
|
|
* The interrupt handler get an interrupt when a packet has been
|
2774 |
|
|
* successfully received and called this part...
|
2775 |
|
|
*/
|
2776 |
|
|
|
2777 |
|
|
/*------------------------------------------------------------------*/
|
2778 |
|
|
/*
|
2779 |
|
|
* Calculate the starting address of the frame pointed to by the receive
|
2780 |
|
|
* frame pointer and verify that the frame seem correct
|
2781 |
|
|
* (called by wv_packet_rcv())
|
2782 |
|
|
*/
|
2783 |
|
|
static inline int
|
2784 |
|
|
wv_start_of_frame(struct net_device * dev,
|
2785 |
|
|
int rfp, /* end of frame */
|
2786 |
|
|
int wrap) /* start of buffer */
|
2787 |
|
|
{
|
2788 |
|
|
kio_addr_t base = dev->base_addr;
|
2789 |
|
|
int rp;
|
2790 |
|
|
int len;
|
2791 |
|
|
|
2792 |
|
|
rp = (rfp - 5 + RX_SIZE) % RX_SIZE;
|
2793 |
|
|
outb(rp & 0xff, PIORL(base));
|
2794 |
|
|
outb(((rp >> 8) & PIORH_MASK), PIORH(base));
|
2795 |
|
|
len = inb(PIOP(base));
|
2796 |
|
|
len |= inb(PIOP(base)) << 8;
|
2797 |
|
|
|
2798 |
|
|
/* Sanity checks on size */
|
2799 |
|
|
/* Frame too big */
|
2800 |
|
|
if(len > MAXDATAZ + 100)
|
2801 |
|
|
{
|
2802 |
|
|
#ifdef DEBUG_RX_ERROR
|
2803 |
|
|
printk(KERN_INFO "%s: wv_start_of_frame: Received frame too large, rfp %d len 0x%x\n",
|
2804 |
|
|
dev->name, rfp, len);
|
2805 |
|
|
#endif
|
2806 |
|
|
return(-1);
|
2807 |
|
|
}
|
2808 |
|
|
|
2809 |
|
|
/* Frame too short */
|
2810 |
|
|
if(len < 7)
|
2811 |
|
|
{
|
2812 |
|
|
#ifdef DEBUG_RX_ERROR
|
2813 |
|
|
printk(KERN_INFO "%s: wv_start_of_frame: Received null frame, rfp %d len 0x%x\n",
|
2814 |
|
|
dev->name, rfp, len);
|
2815 |
|
|
#endif
|
2816 |
|
|
return(-1);
|
2817 |
|
|
}
|
2818 |
|
|
|
2819 |
|
|
/* Wrap around buffer */
|
2820 |
|
|
if(len > ((wrap - (rfp - len) + RX_SIZE) % RX_SIZE)) /* magic formula ! */
|
2821 |
|
|
{
|
2822 |
|
|
#ifdef DEBUG_RX_ERROR
|
2823 |
|
|
printk(KERN_INFO "%s: wv_start_of_frame: wrap around buffer, wrap %d rfp %d len 0x%x\n",
|
2824 |
|
|
dev->name, wrap, rfp, len);
|
2825 |
|
|
#endif
|
2826 |
|
|
return(-1);
|
2827 |
|
|
}
|
2828 |
|
|
|
2829 |
|
|
return((rp - len + RX_SIZE) % RX_SIZE);
|
2830 |
|
|
} /* wv_start_of_frame */
|
2831 |
|
|
|
2832 |
|
|
/*------------------------------------------------------------------*/
|
2833 |
|
|
/*
|
2834 |
|
|
* This routine does the actual copy of data (including the ethernet
|
2835 |
|
|
* header structure) from the WaveLAN card to an sk_buff chain that
|
2836 |
|
|
* will be passed up to the network interface layer. NOTE: We
|
2837 |
|
|
* currently don't handle trailer protocols (neither does the rest of
|
2838 |
|
|
* the network interface), so if that is needed, it will (at least in
|
2839 |
|
|
* part) be added here. The contents of the receive ring buffer are
|
2840 |
|
|
* copied to a message chain that is then passed to the kernel.
|
2841 |
|
|
*
|
2842 |
|
|
* Note: if any errors occur, the packet is "dropped on the floor"
|
2843 |
|
|
* (called by wv_packet_rcv())
|
2844 |
|
|
*/
|
2845 |
|
|
static inline void
|
2846 |
|
|
wv_packet_read(struct net_device * dev,
|
2847 |
|
|
int fd_p,
|
2848 |
|
|
int sksize)
|
2849 |
|
|
{
|
2850 |
|
|
net_local * lp = netdev_priv(dev);
|
2851 |
|
|
struct sk_buff * skb;
|
2852 |
|
|
|
2853 |
|
|
#ifdef DEBUG_RX_TRACE
|
2854 |
|
|
printk(KERN_DEBUG "%s: ->wv_packet_read(0x%X, %d)\n",
|
2855 |
|
|
dev->name, fd_p, sksize);
|
2856 |
|
|
#endif
|
2857 |
|
|
|
2858 |
|
|
/* Allocate some buffer for the new packet */
|
2859 |
|
|
if((skb = dev_alloc_skb(sksize+2)) == (struct sk_buff *) NULL)
|
2860 |
|
|
{
|
2861 |
|
|
#ifdef DEBUG_RX_ERROR
|
2862 |
|
|
printk(KERN_INFO "%s: wv_packet_read(): could not alloc_skb(%d, GFP_ATOMIC)\n",
|
2863 |
|
|
dev->name, sksize);
|
2864 |
|
|
#endif
|
2865 |
|
|
lp->stats.rx_dropped++;
|
2866 |
|
|
/*
|
2867 |
|
|
* Not only do we want to return here, but we also need to drop the
|
2868 |
|
|
* packet on the floor to clear the interrupt.
|
2869 |
|
|
*/
|
2870 |
|
|
return;
|
2871 |
|
|
}
|
2872 |
|
|
|
2873 |
|
|
skb_reserve(skb, 2);
|
2874 |
|
|
fd_p = read_ringbuf(dev, fd_p, (char *) skb_put(skb, sksize), sksize);
|
2875 |
|
|
skb->protocol = eth_type_trans(skb, dev);
|
2876 |
|
|
|
2877 |
|
|
#ifdef DEBUG_RX_INFO
|
2878 |
|
|
wv_packet_info(skb_mac_header(skb), sksize, dev->name, "wv_packet_read");
|
2879 |
|
|
#endif /* DEBUG_RX_INFO */
|
2880 |
|
|
|
2881 |
|
|
/* Statistics gathering & stuff associated.
|
2882 |
|
|
* It seem a bit messy with all the define, but it's really simple... */
|
2883 |
|
|
if(
|
2884 |
|
|
#ifdef IW_WIRELESS_SPY
|
2885 |
|
|
(lp->spy_data.spy_number > 0) ||
|
2886 |
|
|
#endif /* IW_WIRELESS_SPY */
|
2887 |
|
|
#ifdef HISTOGRAM
|
2888 |
|
|
(lp->his_number > 0) ||
|
2889 |
|
|
#endif /* HISTOGRAM */
|
2890 |
|
|
#ifdef WAVELAN_ROAMING
|
2891 |
|
|
(do_roaming) ||
|
2892 |
|
|
#endif /* WAVELAN_ROAMING */
|
2893 |
|
|
0)
|
2894 |
|
|
{
|
2895 |
|
|
u_char stats[3]; /* Signal level, Noise level, Signal quality */
|
2896 |
|
|
|
2897 |
|
|
/* read signal level, silence level and signal quality bytes */
|
2898 |
|
|
fd_p = read_ringbuf(dev, (fd_p + 4) % RX_SIZE + RX_BASE,
|
2899 |
|
|
stats, 3);
|
2900 |
|
|
#ifdef DEBUG_RX_INFO
|
2901 |
|
|
printk(KERN_DEBUG "%s: wv_packet_read(): Signal level %d/63, Silence level %d/63, signal quality %d/16\n",
|
2902 |
|
|
dev->name, stats[0] & 0x3F, stats[1] & 0x3F, stats[2] & 0x0F);
|
2903 |
|
|
#endif
|
2904 |
|
|
|
2905 |
|
|
#ifdef WAVELAN_ROAMING
|
2906 |
|
|
if(do_roaming)
|
2907 |
|
|
if(WAVELAN_BEACON(skb->data))
|
2908 |
|
|
wl_roam_gather(dev, skb->data, stats);
|
2909 |
|
|
#endif /* WAVELAN_ROAMING */
|
2910 |
|
|
|
2911 |
|
|
#ifdef WIRELESS_SPY
|
2912 |
|
|
wl_spy_gather(dev, skb_mac_header(skb) + WAVELAN_ADDR_SIZE, stats);
|
2913 |
|
|
#endif /* WIRELESS_SPY */
|
2914 |
|
|
#ifdef HISTOGRAM
|
2915 |
|
|
wl_his_gather(dev, stats);
|
2916 |
|
|
#endif /* HISTOGRAM */
|
2917 |
|
|
}
|
2918 |
|
|
|
2919 |
|
|
/*
|
2920 |
|
|
* Hand the packet to the Network Module
|
2921 |
|
|
*/
|
2922 |
|
|
netif_rx(skb);
|
2923 |
|
|
|
2924 |
|
|
/* Keep stats up to date */
|
2925 |
|
|
dev->last_rx = jiffies;
|
2926 |
|
|
lp->stats.rx_packets++;
|
2927 |
|
|
lp->stats.rx_bytes += sksize;
|
2928 |
|
|
|
2929 |
|
|
#ifdef DEBUG_RX_TRACE
|
2930 |
|
|
printk(KERN_DEBUG "%s: <-wv_packet_read()\n", dev->name);
|
2931 |
|
|
#endif
|
2932 |
|
|
return;
|
2933 |
|
|
}
|
2934 |
|
|
|
2935 |
|
|
/*------------------------------------------------------------------*/
|
2936 |
|
|
/*
|
2937 |
|
|
* This routine is called by the interrupt handler to initiate a
|
2938 |
|
|
* packet transfer from the card to the network interface layer above
|
2939 |
|
|
* this driver. This routine checks if a buffer has been successfully
|
2940 |
|
|
* received by the WaveLAN card. If so, the routine wv_packet_read is
|
2941 |
|
|
* called to do the actual transfer of the card's data including the
|
2942 |
|
|
* ethernet header into a packet consisting of an sk_buff chain.
|
2943 |
|
|
* (called by wavelan_interrupt())
|
2944 |
|
|
* Note : the spinlock is already grabbed for us and irq are disabled.
|
2945 |
|
|
*/
|
2946 |
|
|
static inline void
|
2947 |
|
|
wv_packet_rcv(struct net_device * dev)
|
2948 |
|
|
{
|
2949 |
|
|
kio_addr_t base = dev->base_addr;
|
2950 |
|
|
net_local * lp = netdev_priv(dev);
|
2951 |
|
|
int newrfp;
|
2952 |
|
|
int rp;
|
2953 |
|
|
int len;
|
2954 |
|
|
int f_start;
|
2955 |
|
|
int status;
|
2956 |
|
|
int i593_rfp;
|
2957 |
|
|
int stat_ptr;
|
2958 |
|
|
u_char c[4];
|
2959 |
|
|
|
2960 |
|
|
#ifdef DEBUG_RX_TRACE
|
2961 |
|
|
printk(KERN_DEBUG "%s: ->wv_packet_rcv()\n", dev->name);
|
2962 |
|
|
#endif
|
2963 |
|
|
|
2964 |
|
|
/* Get the new receive frame pointer from the i82593 chip */
|
2965 |
|
|
outb(CR0_STATUS_2 | OP0_NOP, LCCR(base));
|
2966 |
|
|
i593_rfp = inb(LCSR(base));
|
2967 |
|
|
i593_rfp |= inb(LCSR(base)) << 8;
|
2968 |
|
|
i593_rfp %= RX_SIZE;
|
2969 |
|
|
|
2970 |
|
|
/* Get the new receive frame pointer from the WaveLAN card.
|
2971 |
|
|
* It is 3 bytes more than the increment of the i82593 receive
|
2972 |
|
|
* frame pointer, for each packet. This is because it includes the
|
2973 |
|
|
* 3 roaming bytes added by the mmc.
|
2974 |
|
|
*/
|
2975 |
|
|
newrfp = inb(RPLL(base));
|
2976 |
|
|
newrfp |= inb(RPLH(base)) << 8;
|
2977 |
|
|
newrfp %= RX_SIZE;
|
2978 |
|
|
|
2979 |
|
|
#ifdef DEBUG_RX_INFO
|
2980 |
|
|
printk(KERN_DEBUG "%s: wv_packet_rcv(): i593_rfp %d stop %d newrfp %d lp->rfp %d\n",
|
2981 |
|
|
dev->name, i593_rfp, lp->stop, newrfp, lp->rfp);
|
2982 |
|
|
#endif
|
2983 |
|
|
|
2984 |
|
|
#ifdef DEBUG_RX_ERROR
|
2985 |
|
|
/* If no new frame pointer... */
|
2986 |
|
|
if(lp->overrunning || newrfp == lp->rfp)
|
2987 |
|
|
printk(KERN_INFO "%s: wv_packet_rcv(): no new frame: i593_rfp %d stop %d newrfp %d lp->rfp %d\n",
|
2988 |
|
|
dev->name, i593_rfp, lp->stop, newrfp, lp->rfp);
|
2989 |
|
|
#endif
|
2990 |
|
|
|
2991 |
|
|
/* Read all frames (packets) received */
|
2992 |
|
|
while(newrfp != lp->rfp)
|
2993 |
|
|
{
|
2994 |
|
|
/* A frame is composed of the packet, followed by a status word,
|
2995 |
|
|
* the length of the frame (word) and the mmc info (SNR & qual).
|
2996 |
|
|
* It's because the length is at the end that we can only scan
|
2997 |
|
|
* frames backward. */
|
2998 |
|
|
|
2999 |
|
|
/* Find the first frame by skipping backwards over the frames */
|
3000 |
|
|
rp = newrfp; /* End of last frame */
|
3001 |
|
|
while(((f_start = wv_start_of_frame(dev, rp, newrfp)) != lp->rfp) &&
|
3002 |
|
|
(f_start != -1))
|
3003 |
|
|
rp = f_start;
|
3004 |
|
|
|
3005 |
|
|
/* If we had a problem */
|
3006 |
|
|
if(f_start == -1)
|
3007 |
|
|
{
|
3008 |
|
|
#ifdef DEBUG_RX_ERROR
|
3009 |
|
|
printk(KERN_INFO "wavelan_cs: cannot find start of frame ");
|
3010 |
|
|
printk(" i593_rfp %d stop %d newrfp %d lp->rfp %d\n",
|
3011 |
|
|
i593_rfp, lp->stop, newrfp, lp->rfp);
|
3012 |
|
|
#endif
|
3013 |
|
|
lp->rfp = rp; /* Get to the last usable frame */
|
3014 |
|
|
continue;
|
3015 |
|
|
}
|
3016 |
|
|
|
3017 |
|
|
/* f_start point to the beggining of the first frame received
|
3018 |
|
|
* and rp to the beggining of the next one */
|
3019 |
|
|
|
3020 |
|
|
/* Read status & length of the frame */
|
3021 |
|
|
stat_ptr = (rp - 7 + RX_SIZE) % RX_SIZE;
|
3022 |
|
|
stat_ptr = read_ringbuf(dev, stat_ptr, c, 4);
|
3023 |
|
|
status = c[0] | (c[1] << 8);
|
3024 |
|
|
len = c[2] | (c[3] << 8);
|
3025 |
|
|
|
3026 |
|
|
/* Check status */
|
3027 |
|
|
if((status & RX_RCV_OK) != RX_RCV_OK)
|
3028 |
|
|
{
|
3029 |
|
|
lp->stats.rx_errors++;
|
3030 |
|
|
if(status & RX_NO_SFD)
|
3031 |
|
|
lp->stats.rx_frame_errors++;
|
3032 |
|
|
if(status & RX_CRC_ERR)
|
3033 |
|
|
lp->stats.rx_crc_errors++;
|
3034 |
|
|
if(status & RX_OVRRUN)
|
3035 |
|
|
lp->stats.rx_over_errors++;
|
3036 |
|
|
|
3037 |
|
|
#ifdef DEBUG_RX_FAIL
|
3038 |
|
|
printk(KERN_DEBUG "%s: wv_packet_rcv(): packet not received ok, status = 0x%x\n",
|
3039 |
|
|
dev->name, status);
|
3040 |
|
|
#endif
|
3041 |
|
|
}
|
3042 |
|
|
else
|
3043 |
|
|
/* Read the packet and transmit to Linux */
|
3044 |
|
|
wv_packet_read(dev, f_start, len - 2);
|
3045 |
|
|
|
3046 |
|
|
/* One frame has been processed, skip it */
|
3047 |
|
|
lp->rfp = rp;
|
3048 |
|
|
}
|
3049 |
|
|
|
3050 |
|
|
/*
|
3051 |
|
|
* Update the frame stop register, but set it to less than
|
3052 |
|
|
* the full 8K to allow space for 3 bytes of signal strength
|
3053 |
|
|
* per packet.
|
3054 |
|
|
*/
|
3055 |
|
|
lp->stop = (i593_rfp + RX_SIZE - ((RX_SIZE / 64) * 3)) % RX_SIZE;
|
3056 |
|
|
outb(OP0_SWIT_TO_PORT_1 | CR0_CHNL, LCCR(base));
|
3057 |
|
|
outb(CR1_STOP_REG_UPDATE | (lp->stop >> RX_SIZE_SHIFT), LCCR(base));
|
3058 |
|
|
outb(OP1_SWIT_TO_PORT_0, LCCR(base));
|
3059 |
|
|
|
3060 |
|
|
#ifdef DEBUG_RX_TRACE
|
3061 |
|
|
printk(KERN_DEBUG "%s: <-wv_packet_rcv()\n", dev->name);
|
3062 |
|
|
#endif
|
3063 |
|
|
}
|
3064 |
|
|
|
3065 |
|
|
/*********************** PACKET TRANSMISSION ***********************/
|
3066 |
|
|
/*
|
3067 |
|
|
* This part deal with sending packet through the wavelan
|
3068 |
|
|
* We copy the packet to the send buffer and then issue the send
|
3069 |
|
|
* command to the i82593. The result of this operation will be
|
3070 |
|
|
* checked in wavelan_interrupt()
|
3071 |
|
|
*/
|
3072 |
|
|
|
3073 |
|
|
/*------------------------------------------------------------------*/
|
3074 |
|
|
/*
|
3075 |
|
|
* This routine fills in the appropriate registers and memory
|
3076 |
|
|
* locations on the WaveLAN card and starts the card off on
|
3077 |
|
|
* the transmit.
|
3078 |
|
|
* (called in wavelan_packet_xmit())
|
3079 |
|
|
*/
|
3080 |
|
|
static inline void
|
3081 |
|
|
wv_packet_write(struct net_device * dev,
|
3082 |
|
|
void * buf,
|
3083 |
|
|
short length)
|
3084 |
|
|
{
|
3085 |
|
|
net_local * lp = netdev_priv(dev);
|
3086 |
|
|
kio_addr_t base = dev->base_addr;
|
3087 |
|
|
unsigned long flags;
|
3088 |
|
|
int clen = length;
|
3089 |
|
|
register u_short xmtdata_base = TX_BASE;
|
3090 |
|
|
|
3091 |
|
|
#ifdef DEBUG_TX_TRACE
|
3092 |
|
|
printk(KERN_DEBUG "%s: ->wv_packet_write(%d)\n", dev->name, length);
|
3093 |
|
|
#endif
|
3094 |
|
|
|
3095 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
3096 |
|
|
|
3097 |
|
|
/* Write the length of data buffer followed by the buffer */
|
3098 |
|
|
outb(xmtdata_base & 0xff, PIORL(base));
|
3099 |
|
|
outb(((xmtdata_base >> 8) & PIORH_MASK) | PIORH_SEL_TX, PIORH(base));
|
3100 |
|
|
outb(clen & 0xff, PIOP(base)); /* lsb */
|
3101 |
|
|
outb(clen >> 8, PIOP(base)); /* msb */
|
3102 |
|
|
|
3103 |
|
|
/* Send the data */
|
3104 |
|
|
outsb(PIOP(base), buf, clen);
|
3105 |
|
|
|
3106 |
|
|
/* Indicate end of transmit chain */
|
3107 |
|
|
outb(OP0_NOP, PIOP(base));
|
3108 |
|
|
/* josullvn@cs.cmu.edu: need to send a second NOP for alignment... */
|
3109 |
|
|
outb(OP0_NOP, PIOP(base));
|
3110 |
|
|
|
3111 |
|
|
/* Reset the transmit DMA pointer */
|
3112 |
|
|
hacr_write_slow(base, HACR_PWR_STAT | HACR_TX_DMA_RESET);
|
3113 |
|
|
hacr_write(base, HACR_DEFAULT);
|
3114 |
|
|
/* Send the transmit command */
|
3115 |
|
|
wv_82593_cmd(dev, "wv_packet_write(): transmit",
|
3116 |
|
|
OP0_TRANSMIT, SR0_NO_RESULT);
|
3117 |
|
|
|
3118 |
|
|
/* Make sure the watchdog will keep quiet for a while */
|
3119 |
|
|
dev->trans_start = jiffies;
|
3120 |
|
|
|
3121 |
|
|
/* Keep stats up to date */
|
3122 |
|
|
lp->stats.tx_bytes += length;
|
3123 |
|
|
|
3124 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
3125 |
|
|
|
3126 |
|
|
#ifdef DEBUG_TX_INFO
|
3127 |
|
|
wv_packet_info((u_char *) buf, length, dev->name, "wv_packet_write");
|
3128 |
|
|
#endif /* DEBUG_TX_INFO */
|
3129 |
|
|
|
3130 |
|
|
#ifdef DEBUG_TX_TRACE
|
3131 |
|
|
printk(KERN_DEBUG "%s: <-wv_packet_write()\n", dev->name);
|
3132 |
|
|
#endif
|
3133 |
|
|
}
|
3134 |
|
|
|
3135 |
|
|
/*------------------------------------------------------------------*/
|
3136 |
|
|
/*
|
3137 |
|
|
* This routine is called when we want to send a packet (NET3 callback)
|
3138 |
|
|
* In this routine, we check if the harware is ready to accept
|
3139 |
|
|
* the packet. We also prevent reentrance. Then, we call the function
|
3140 |
|
|
* to send the packet...
|
3141 |
|
|
*/
|
3142 |
|
|
static int
|
3143 |
|
|
wavelan_packet_xmit(struct sk_buff * skb,
|
3144 |
|
|
struct net_device * dev)
|
3145 |
|
|
{
|
3146 |
|
|
net_local * lp = netdev_priv(dev);
|
3147 |
|
|
unsigned long flags;
|
3148 |
|
|
|
3149 |
|
|
#ifdef DEBUG_TX_TRACE
|
3150 |
|
|
printk(KERN_DEBUG "%s: ->wavelan_packet_xmit(0x%X)\n", dev->name,
|
3151 |
|
|
(unsigned) skb);
|
3152 |
|
|
#endif
|
3153 |
|
|
|
3154 |
|
|
/*
|
3155 |
|
|
* Block a timer-based transmit from overlapping a previous transmit.
|
3156 |
|
|
* In other words, prevent reentering this routine.
|
3157 |
|
|
*/
|
3158 |
|
|
netif_stop_queue(dev);
|
3159 |
|
|
|
3160 |
|
|
/* If somebody has asked to reconfigure the controller,
|
3161 |
|
|
* we can do it now */
|
3162 |
|
|
if(lp->reconfig_82593)
|
3163 |
|
|
{
|
3164 |
|
|
spin_lock_irqsave(&lp->spinlock, flags); /* Disable interrupts */
|
3165 |
|
|
wv_82593_config(dev);
|
3166 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags); /* Re-enable interrupts */
|
3167 |
|
|
/* Note : the configure procedure was totally synchronous,
|
3168 |
|
|
* so the Tx buffer is now free */
|
3169 |
|
|
}
|
3170 |
|
|
|
3171 |
|
|
#ifdef DEBUG_TX_ERROR
|
3172 |
|
|
if (skb->next)
|
3173 |
|
|
printk(KERN_INFO "skb has next\n");
|
3174 |
|
|
#endif
|
3175 |
|
|
|
3176 |
|
|
/* Check if we need some padding */
|
3177 |
|
|
/* Note : on wireless the propagation time is in the order of 1us,
|
3178 |
|
|
* and we don't have the Ethernet specific requirement of beeing
|
3179 |
|
|
* able to detect collisions, therefore in theory we don't really
|
3180 |
|
|
* need to pad. Jean II */
|
3181 |
|
|
if (skb_padto(skb, ETH_ZLEN))
|
3182 |
|
|
return 0;
|
3183 |
|
|
|
3184 |
|
|
wv_packet_write(dev, skb->data, skb->len);
|
3185 |
|
|
|
3186 |
|
|
dev_kfree_skb(skb);
|
3187 |
|
|
|
3188 |
|
|
#ifdef DEBUG_TX_TRACE
|
3189 |
|
|
printk(KERN_DEBUG "%s: <-wavelan_packet_xmit()\n", dev->name);
|
3190 |
|
|
#endif
|
3191 |
|
|
return(0);
|
3192 |
|
|
}
|
3193 |
|
|
|
3194 |
|
|
/********************** HARDWARE CONFIGURATION **********************/
|
3195 |
|
|
/*
|
3196 |
|
|
* This part do the real job of starting and configuring the hardware.
|
3197 |
|
|
*/
|
3198 |
|
|
|
3199 |
|
|
/*------------------------------------------------------------------*/
|
3200 |
|
|
/*
|
3201 |
|
|
* Routine to initialize the Modem Management Controller.
|
3202 |
|
|
* (called by wv_hw_config())
|
3203 |
|
|
*/
|
3204 |
|
|
static inline int
|
3205 |
|
|
wv_mmc_init(struct net_device * dev)
|
3206 |
|
|
{
|
3207 |
|
|
kio_addr_t base = dev->base_addr;
|
3208 |
|
|
psa_t psa;
|
3209 |
|
|
mmw_t m;
|
3210 |
|
|
int configured;
|
3211 |
|
|
int i; /* Loop counter */
|
3212 |
|
|
|
3213 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3214 |
|
|
printk(KERN_DEBUG "%s: ->wv_mmc_init()\n", dev->name);
|
3215 |
|
|
#endif
|
3216 |
|
|
|
3217 |
|
|
/* Read the parameter storage area */
|
3218 |
|
|
psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa));
|
3219 |
|
|
|
3220 |
|
|
/*
|
3221 |
|
|
* Check the first three octets of the MAC addr for the manufacturer's code.
|
3222 |
|
|
* Note: If you get the error message below, you've got a
|
3223 |
|
|
* non-NCR/AT&T/Lucent PCMCIA cards, see wavelan_cs.h for detail on
|
3224 |
|
|
* how to configure your card...
|
3225 |
|
|
*/
|
3226 |
|
|
for(i = 0; i < (sizeof(MAC_ADDRESSES) / sizeof(char) / 3); i++)
|
3227 |
|
|
if((psa.psa_univ_mac_addr[0] == MAC_ADDRESSES[i][0]) &&
|
3228 |
|
|
(psa.psa_univ_mac_addr[1] == MAC_ADDRESSES[i][1]) &&
|
3229 |
|
|
(psa.psa_univ_mac_addr[2] == MAC_ADDRESSES[i][2]))
|
3230 |
|
|
break;
|
3231 |
|
|
|
3232 |
|
|
/* If we have not found it... */
|
3233 |
|
|
if(i == (sizeof(MAC_ADDRESSES) / sizeof(char) / 3))
|
3234 |
|
|
{
|
3235 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
3236 |
|
|
printk(KERN_WARNING "%s: wv_mmc_init(): Invalid MAC address: %02X:%02X:%02X:...\n",
|
3237 |
|
|
dev->name, psa.psa_univ_mac_addr[0],
|
3238 |
|
|
psa.psa_univ_mac_addr[1], psa.psa_univ_mac_addr[2]);
|
3239 |
|
|
#endif
|
3240 |
|
|
return FALSE;
|
3241 |
|
|
}
|
3242 |
|
|
|
3243 |
|
|
/* Get the MAC address */
|
3244 |
|
|
memcpy(&dev->dev_addr[0], &psa.psa_univ_mac_addr[0], WAVELAN_ADDR_SIZE);
|
3245 |
|
|
|
3246 |
|
|
#ifdef USE_PSA_CONFIG
|
3247 |
|
|
configured = psa.psa_conf_status & 1;
|
3248 |
|
|
#else
|
3249 |
|
|
configured = 0;
|
3250 |
|
|
#endif
|
3251 |
|
|
|
3252 |
|
|
/* Is the PSA is not configured */
|
3253 |
|
|
if(!configured)
|
3254 |
|
|
{
|
3255 |
|
|
/* User will be able to configure NWID after (with iwconfig) */
|
3256 |
|
|
psa.psa_nwid[0] = 0;
|
3257 |
|
|
psa.psa_nwid[1] = 0;
|
3258 |
|
|
|
3259 |
|
|
/* As NWID is not set : no NWID checking */
|
3260 |
|
|
psa.psa_nwid_select = 0;
|
3261 |
|
|
|
3262 |
|
|
/* Disable encryption */
|
3263 |
|
|
psa.psa_encryption_select = 0;
|
3264 |
|
|
|
3265 |
|
|
/* Set to standard values
|
3266 |
|
|
* 0x04 for AT,
|
3267 |
|
|
* 0x01 for MCA,
|
3268 |
|
|
* 0x04 for PCMCIA and 2.00 card (AT&T 407-024689/E document)
|
3269 |
|
|
*/
|
3270 |
|
|
if (psa.psa_comp_number & 1)
|
3271 |
|
|
psa.psa_thr_pre_set = 0x01;
|
3272 |
|
|
else
|
3273 |
|
|
psa.psa_thr_pre_set = 0x04;
|
3274 |
|
|
psa.psa_quality_thr = 0x03;
|
3275 |
|
|
|
3276 |
|
|
/* It is configured */
|
3277 |
|
|
psa.psa_conf_status |= 1;
|
3278 |
|
|
|
3279 |
|
|
#ifdef USE_PSA_CONFIG
|
3280 |
|
|
/* Write the psa */
|
3281 |
|
|
psa_write(dev, (char *)psa.psa_nwid - (char *)&psa,
|
3282 |
|
|
(unsigned char *)psa.psa_nwid, 4);
|
3283 |
|
|
psa_write(dev, (char *)&psa.psa_thr_pre_set - (char *)&psa,
|
3284 |
|
|
(unsigned char *)&psa.psa_thr_pre_set, 1);
|
3285 |
|
|
psa_write(dev, (char *)&psa.psa_quality_thr - (char *)&psa,
|
3286 |
|
|
(unsigned char *)&psa.psa_quality_thr, 1);
|
3287 |
|
|
psa_write(dev, (char *)&psa.psa_conf_status - (char *)&psa,
|
3288 |
|
|
(unsigned char *)&psa.psa_conf_status, 1);
|
3289 |
|
|
/* update the Wavelan checksum */
|
3290 |
|
|
update_psa_checksum(dev);
|
3291 |
|
|
#endif /* USE_PSA_CONFIG */
|
3292 |
|
|
}
|
3293 |
|
|
|
3294 |
|
|
/* Zero the mmc structure */
|
3295 |
|
|
memset(&m, 0x00, sizeof(m));
|
3296 |
|
|
|
3297 |
|
|
/* Copy PSA info to the mmc */
|
3298 |
|
|
m.mmw_netw_id_l = psa.psa_nwid[1];
|
3299 |
|
|
m.mmw_netw_id_h = psa.psa_nwid[0];
|
3300 |
|
|
|
3301 |
|
|
if(psa.psa_nwid_select & 1)
|
3302 |
|
|
m.mmw_loopt_sel = 0x00;
|
3303 |
|
|
else
|
3304 |
|
|
m.mmw_loopt_sel = MMW_LOOPT_SEL_DIS_NWID;
|
3305 |
|
|
|
3306 |
|
|
memcpy(&m.mmw_encr_key, &psa.psa_encryption_key,
|
3307 |
|
|
sizeof(m.mmw_encr_key));
|
3308 |
|
|
|
3309 |
|
|
if(psa.psa_encryption_select)
|
3310 |
|
|
m.mmw_encr_enable = MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE;
|
3311 |
|
|
else
|
3312 |
|
|
m.mmw_encr_enable = 0;
|
3313 |
|
|
|
3314 |
|
|
m.mmw_thr_pre_set = psa.psa_thr_pre_set & 0x3F;
|
3315 |
|
|
m.mmw_quality_thr = psa.psa_quality_thr & 0x0F;
|
3316 |
|
|
|
3317 |
|
|
/*
|
3318 |
|
|
* Set default modem control parameters.
|
3319 |
|
|
* See NCR document 407-0024326 Rev. A.
|
3320 |
|
|
*/
|
3321 |
|
|
m.mmw_jabber_enable = 0x01;
|
3322 |
|
|
m.mmw_anten_sel = MMW_ANTEN_SEL_ALG_EN;
|
3323 |
|
|
m.mmw_ifs = 0x20;
|
3324 |
|
|
m.mmw_mod_delay = 0x04;
|
3325 |
|
|
m.mmw_jam_time = 0x38;
|
3326 |
|
|
|
3327 |
|
|
m.mmw_des_io_invert = 0;
|
3328 |
|
|
m.mmw_freeze = 0;
|
3329 |
|
|
m.mmw_decay_prm = 0;
|
3330 |
|
|
m.mmw_decay_updat_prm = 0;
|
3331 |
|
|
|
3332 |
|
|
/* Write all info to mmc */
|
3333 |
|
|
mmc_write(base, 0, (u_char *)&m, sizeof(m));
|
3334 |
|
|
|
3335 |
|
|
/* The following code start the modem of the 2.00 frequency
|
3336 |
|
|
* selectable cards at power on. It's not strictly needed for the
|
3337 |
|
|
* following boots...
|
3338 |
|
|
* The original patch was by Joe Finney for the PCMCIA driver, but
|
3339 |
|
|
* I've cleaned it a bit and add documentation.
|
3340 |
|
|
* Thanks to Loeke Brederveld from Lucent for the info.
|
3341 |
|
|
*/
|
3342 |
|
|
|
3343 |
|
|
/* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable)
|
3344 |
|
|
* (does it work for everybody ? - especially old cards...) */
|
3345 |
|
|
/* Note : WFREQSEL verify that it is able to read from EEprom
|
3346 |
|
|
* a sensible frequency (address 0x00) + that MMR_FEE_STATUS_ID
|
3347 |
|
|
* is 0xA (Xilinx version) or 0xB (Ariadne version).
|
3348 |
|
|
* My test is more crude but do work... */
|
3349 |
|
|
if(!(mmc_in(base, mmroff(0, mmr_fee_status)) &
|
3350 |
|
|
(MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY)))
|
3351 |
|
|
{
|
3352 |
|
|
/* We must download the frequency parameters to the
|
3353 |
|
|
* synthetisers (from the EEprom - area 1)
|
3354 |
|
|
* Note : as the EEprom is auto decremented, we set the end
|
3355 |
|
|
* if the area... */
|
3356 |
|
|
m.mmw_fee_addr = 0x0F;
|
3357 |
|
|
m.mmw_fee_ctrl = MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD;
|
3358 |
|
|
mmc_write(base, (char *)&m.mmw_fee_ctrl - (char *)&m,
|
3359 |
|
|
(unsigned char *)&m.mmw_fee_ctrl, 2);
|
3360 |
|
|
|
3361 |
|
|
/* Wait until the download is finished */
|
3362 |
|
|
fee_wait(base, 100, 100);
|
3363 |
|
|
|
3364 |
|
|
#ifdef DEBUG_CONFIG_INFO
|
3365 |
|
|
/* The frequency was in the last word downloaded... */
|
3366 |
|
|
mmc_read(base, (char *)&m.mmw_fee_data_l - (char *)&m,
|
3367 |
|
|
(unsigned char *)&m.mmw_fee_data_l, 2);
|
3368 |
|
|
|
3369 |
|
|
/* Print some info for the user */
|
3370 |
|
|
printk(KERN_DEBUG "%s: Wavelan 2.00 recognised (frequency select) : Current frequency = %ld\n",
|
3371 |
|
|
dev->name,
|
3372 |
|
|
((m.mmw_fee_data_h << 4) |
|
3373 |
|
|
(m.mmw_fee_data_l >> 4)) * 5 / 2 + 24000L);
|
3374 |
|
|
#endif
|
3375 |
|
|
|
3376 |
|
|
/* We must now download the power adjust value (gain) to
|
3377 |
|
|
* the synthetisers (from the EEprom - area 7 - DAC) */
|
3378 |
|
|
m.mmw_fee_addr = 0x61;
|
3379 |
|
|
m.mmw_fee_ctrl = MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD;
|
3380 |
|
|
mmc_write(base, (char *)&m.mmw_fee_ctrl - (char *)&m,
|
3381 |
|
|
(unsigned char *)&m.mmw_fee_ctrl, 2);
|
3382 |
|
|
|
3383 |
|
|
/* Wait until the download is finished */
|
3384 |
|
|
} /* if 2.00 card */
|
3385 |
|
|
|
3386 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3387 |
|
|
printk(KERN_DEBUG "%s: <-wv_mmc_init()\n", dev->name);
|
3388 |
|
|
#endif
|
3389 |
|
|
return TRUE;
|
3390 |
|
|
}
|
3391 |
|
|
|
3392 |
|
|
/*------------------------------------------------------------------*/
|
3393 |
|
|
/*
|
3394 |
|
|
* Routine to gracefully turn off reception, and wait for any commands
|
3395 |
|
|
* to complete.
|
3396 |
|
|
* (called in wv_ru_start() and wavelan_close() and wavelan_event())
|
3397 |
|
|
*/
|
3398 |
|
|
static int
|
3399 |
|
|
wv_ru_stop(struct net_device * dev)
|
3400 |
|
|
{
|
3401 |
|
|
kio_addr_t base = dev->base_addr;
|
3402 |
|
|
net_local * lp = netdev_priv(dev);
|
3403 |
|
|
unsigned long flags;
|
3404 |
|
|
int status;
|
3405 |
|
|
int spin;
|
3406 |
|
|
|
3407 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3408 |
|
|
printk(KERN_DEBUG "%s: ->wv_ru_stop()\n", dev->name);
|
3409 |
|
|
#endif
|
3410 |
|
|
|
3411 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
3412 |
|
|
|
3413 |
|
|
/* First, send the LAN controller a stop receive command */
|
3414 |
|
|
wv_82593_cmd(dev, "wv_graceful_shutdown(): stop-rcv",
|
3415 |
|
|
OP0_STOP_RCV, SR0_NO_RESULT);
|
3416 |
|
|
|
3417 |
|
|
/* Then, spin until the receive unit goes idle */
|
3418 |
|
|
spin = 300;
|
3419 |
|
|
do
|
3420 |
|
|
{
|
3421 |
|
|
udelay(10);
|
3422 |
|
|
outb(OP0_NOP | CR0_STATUS_3, LCCR(base));
|
3423 |
|
|
status = inb(LCSR(base));
|
3424 |
|
|
}
|
3425 |
|
|
while(((status & SR3_RCV_STATE_MASK) != SR3_RCV_IDLE) && (spin-- > 0));
|
3426 |
|
|
|
3427 |
|
|
/* Now, spin until the chip finishes executing its current command */
|
3428 |
|
|
do
|
3429 |
|
|
{
|
3430 |
|
|
udelay(10);
|
3431 |
|
|
outb(OP0_NOP | CR0_STATUS_3, LCCR(base));
|
3432 |
|
|
status = inb(LCSR(base));
|
3433 |
|
|
}
|
3434 |
|
|
while(((status & SR3_EXEC_STATE_MASK) != SR3_EXEC_IDLE) && (spin-- > 0));
|
3435 |
|
|
|
3436 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
3437 |
|
|
|
3438 |
|
|
/* If there was a problem */
|
3439 |
|
|
if(spin <= 0)
|
3440 |
|
|
{
|
3441 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
3442 |
|
|
printk(KERN_INFO "%s: wv_ru_stop(): The chip doesn't want to stop...\n",
|
3443 |
|
|
dev->name);
|
3444 |
|
|
#endif
|
3445 |
|
|
return FALSE;
|
3446 |
|
|
}
|
3447 |
|
|
|
3448 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3449 |
|
|
printk(KERN_DEBUG "%s: <-wv_ru_stop()\n", dev->name);
|
3450 |
|
|
#endif
|
3451 |
|
|
return TRUE;
|
3452 |
|
|
} /* wv_ru_stop */
|
3453 |
|
|
|
3454 |
|
|
/*------------------------------------------------------------------*/
|
3455 |
|
|
/*
|
3456 |
|
|
* This routine starts the receive unit running. First, it checks if
|
3457 |
|
|
* the card is actually ready. Then the card is instructed to receive
|
3458 |
|
|
* packets again.
|
3459 |
|
|
* (called in wv_hw_reset() & wavelan_open())
|
3460 |
|
|
*/
|
3461 |
|
|
static int
|
3462 |
|
|
wv_ru_start(struct net_device * dev)
|
3463 |
|
|
{
|
3464 |
|
|
kio_addr_t base = dev->base_addr;
|
3465 |
|
|
net_local * lp = netdev_priv(dev);
|
3466 |
|
|
unsigned long flags;
|
3467 |
|
|
|
3468 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3469 |
|
|
printk(KERN_DEBUG "%s: ->wv_ru_start()\n", dev->name);
|
3470 |
|
|
#endif
|
3471 |
|
|
|
3472 |
|
|
/*
|
3473 |
|
|
* We need to start from a quiescent state. To do so, we could check
|
3474 |
|
|
* if the card is already running, but instead we just try to shut
|
3475 |
|
|
* it down. First, we disable reception (in case it was already enabled).
|
3476 |
|
|
*/
|
3477 |
|
|
if(!wv_ru_stop(dev))
|
3478 |
|
|
return FALSE;
|
3479 |
|
|
|
3480 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
3481 |
|
|
|
3482 |
|
|
/* Now we know that no command is being executed. */
|
3483 |
|
|
|
3484 |
|
|
/* Set the receive frame pointer and stop pointer */
|
3485 |
|
|
lp->rfp = 0;
|
3486 |
|
|
outb(OP0_SWIT_TO_PORT_1 | CR0_CHNL, LCCR(base));
|
3487 |
|
|
|
3488 |
|
|
/* Reset ring management. This sets the receive frame pointer to 1 */
|
3489 |
|
|
outb(OP1_RESET_RING_MNGMT, LCCR(base));
|
3490 |
|
|
|
3491 |
|
|
#if 0
|
3492 |
|
|
/* XXX the i82593 manual page 6-4 seems to indicate that the stop register
|
3493 |
|
|
should be set as below */
|
3494 |
|
|
/* outb(CR1_STOP_REG_UPDATE|((RX_SIZE - 0x40)>> RX_SIZE_SHIFT),LCCR(base));*/
|
3495 |
|
|
#elif 0
|
3496 |
|
|
/* but I set it 0 instead */
|
3497 |
|
|
lp->stop = 0;
|
3498 |
|
|
#else
|
3499 |
|
|
/* but I set it to 3 bytes per packet less than 8K */
|
3500 |
|
|
lp->stop = (0 + RX_SIZE - ((RX_SIZE / 64) * 3)) % RX_SIZE;
|
3501 |
|
|
#endif
|
3502 |
|
|
outb(CR1_STOP_REG_UPDATE | (lp->stop >> RX_SIZE_SHIFT), LCCR(base));
|
3503 |
|
|
outb(OP1_INT_ENABLE, LCCR(base));
|
3504 |
|
|
outb(OP1_SWIT_TO_PORT_0, LCCR(base));
|
3505 |
|
|
|
3506 |
|
|
/* Reset receive DMA pointer */
|
3507 |
|
|
hacr_write_slow(base, HACR_PWR_STAT | HACR_TX_DMA_RESET);
|
3508 |
|
|
hacr_write_slow(base, HACR_DEFAULT);
|
3509 |
|
|
|
3510 |
|
|
/* Receive DMA on channel 1 */
|
3511 |
|
|
wv_82593_cmd(dev, "wv_ru_start(): rcv-enable",
|
3512 |
|
|
CR0_CHNL | OP0_RCV_ENABLE, SR0_NO_RESULT);
|
3513 |
|
|
|
3514 |
|
|
#ifdef DEBUG_I82593_SHOW
|
3515 |
|
|
{
|
3516 |
|
|
int status;
|
3517 |
|
|
int opri;
|
3518 |
|
|
int spin = 10000;
|
3519 |
|
|
|
3520 |
|
|
/* spin until the chip starts receiving */
|
3521 |
|
|
do
|
3522 |
|
|
{
|
3523 |
|
|
outb(OP0_NOP | CR0_STATUS_3, LCCR(base));
|
3524 |
|
|
status = inb(LCSR(base));
|
3525 |
|
|
if(spin-- <= 0)
|
3526 |
|
|
break;
|
3527 |
|
|
}
|
3528 |
|
|
while(((status & SR3_RCV_STATE_MASK) != SR3_RCV_ACTIVE) &&
|
3529 |
|
|
((status & SR3_RCV_STATE_MASK) != SR3_RCV_READY));
|
3530 |
|
|
printk(KERN_DEBUG "rcv status is 0x%x [i:%d]\n",
|
3531 |
|
|
(status & SR3_RCV_STATE_MASK), i);
|
3532 |
|
|
}
|
3533 |
|
|
#endif
|
3534 |
|
|
|
3535 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
3536 |
|
|
|
3537 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3538 |
|
|
printk(KERN_DEBUG "%s: <-wv_ru_start()\n", dev->name);
|
3539 |
|
|
#endif
|
3540 |
|
|
return TRUE;
|
3541 |
|
|
}
|
3542 |
|
|
|
3543 |
|
|
/*------------------------------------------------------------------*/
|
3544 |
|
|
/*
|
3545 |
|
|
* This routine does a standard config of the WaveLAN controller (i82593).
|
3546 |
|
|
* In the ISA driver, this is integrated in wavelan_hardware_reset()
|
3547 |
|
|
* (called by wv_hw_config(), wv_82593_reconfig() & wavelan_packet_xmit())
|
3548 |
|
|
*/
|
3549 |
|
|
static int
|
3550 |
|
|
wv_82593_config(struct net_device * dev)
|
3551 |
|
|
{
|
3552 |
|
|
kio_addr_t base = dev->base_addr;
|
3553 |
|
|
net_local * lp = netdev_priv(dev);
|
3554 |
|
|
struct i82593_conf_block cfblk;
|
3555 |
|
|
int ret = TRUE;
|
3556 |
|
|
|
3557 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3558 |
|
|
printk(KERN_DEBUG "%s: ->wv_82593_config()\n", dev->name);
|
3559 |
|
|
#endif
|
3560 |
|
|
|
3561 |
|
|
/* Create & fill i82593 config block
|
3562 |
|
|
*
|
3563 |
|
|
* Now conform to Wavelan document WCIN085B
|
3564 |
|
|
*/
|
3565 |
|
|
memset(&cfblk, 0x00, sizeof(struct i82593_conf_block));
|
3566 |
|
|
cfblk.d6mod = FALSE; /* Run in i82593 advanced mode */
|
3567 |
|
|
cfblk.fifo_limit = 5; /* = 56 B rx and 40 B tx fifo thresholds */
|
3568 |
|
|
cfblk.forgnesi = FALSE; /* 0=82C501, 1=AMD7992B compatibility */
|
3569 |
|
|
cfblk.fifo_32 = 1;
|
3570 |
|
|
cfblk.throttle_enb = FALSE;
|
3571 |
|
|
cfblk.contin = TRUE; /* enable continuous mode */
|
3572 |
|
|
cfblk.cntrxint = FALSE; /* enable continuous mode receive interrupts */
|
3573 |
|
|
cfblk.addr_len = WAVELAN_ADDR_SIZE;
|
3574 |
|
|
cfblk.acloc = TRUE; /* Disable source addr insertion by i82593 */
|
3575 |
|
|
cfblk.preamb_len = 0; /* 2 bytes preamble (SFD) */
|
3576 |
|
|
cfblk.loopback = FALSE;
|
3577 |
|
|
cfblk.lin_prio = 0; /* conform to 802.3 backoff algorithm */
|
3578 |
|
|
cfblk.exp_prio = 5; /* conform to 802.3 backoff algorithm */
|
3579 |
|
|
cfblk.bof_met = 1; /* conform to 802.3 backoff algorithm */
|
3580 |
|
|
cfblk.ifrm_spc = 0x20 >> 4; /* 32 bit times interframe spacing */
|
3581 |
|
|
cfblk.slottim_low = 0x20 >> 5; /* 32 bit times slot time */
|
3582 |
|
|
cfblk.slottim_hi = 0x0;
|
3583 |
|
|
cfblk.max_retr = 15;
|
3584 |
|
|
cfblk.prmisc = ((lp->promiscuous) ? TRUE: FALSE); /* Promiscuous mode */
|
3585 |
|
|
cfblk.bc_dis = FALSE; /* Enable broadcast reception */
|
3586 |
|
|
cfblk.crs_1 = TRUE; /* Transmit without carrier sense */
|
3587 |
|
|
cfblk.nocrc_ins = FALSE; /* i82593 generates CRC */
|
3588 |
|
|
cfblk.crc_1632 = FALSE; /* 32-bit Autodin-II CRC */
|
3589 |
|
|
cfblk.crs_cdt = FALSE; /* CD not to be interpreted as CS */
|
3590 |
|
|
cfblk.cs_filter = 0; /* CS is recognized immediately */
|
3591 |
|
|
cfblk.crs_src = FALSE; /* External carrier sense */
|
3592 |
|
|
cfblk.cd_filter = 0; /* CD is recognized immediately */
|
3593 |
|
|
cfblk.min_fr_len = ETH_ZLEN >> 2; /* Minimum frame length 64 bytes */
|
3594 |
|
|
cfblk.lng_typ = FALSE; /* Length field > 1500 = type field */
|
3595 |
|
|
cfblk.lng_fld = TRUE; /* Disable 802.3 length field check */
|
3596 |
|
|
cfblk.rxcrc_xf = TRUE; /* Don't transfer CRC to memory */
|
3597 |
|
|
cfblk.artx = TRUE; /* Disable automatic retransmission */
|
3598 |
|
|
cfblk.sarec = TRUE; /* Disable source addr trig of CD */
|
3599 |
|
|
cfblk.tx_jabber = TRUE; /* Disable jabber jam sequence */
|
3600 |
|
|
cfblk.hash_1 = FALSE; /* Use bits 0-5 in mc address hash */
|
3601 |
|
|
cfblk.lbpkpol = TRUE; /* Loopback pin active high */
|
3602 |
|
|
cfblk.fdx = FALSE; /* Disable full duplex operation */
|
3603 |
|
|
cfblk.dummy_6 = 0x3f; /* all ones */
|
3604 |
|
|
cfblk.mult_ia = FALSE; /* No multiple individual addresses */
|
3605 |
|
|
cfblk.dis_bof = FALSE; /* Disable the backoff algorithm ?! */
|
3606 |
|
|
cfblk.dummy_1 = TRUE; /* set to 1 */
|
3607 |
|
|
cfblk.tx_ifs_retrig = 3; /* Hmm... Disabled */
|
3608 |
|
|
#ifdef MULTICAST_ALL
|
3609 |
|
|
cfblk.mc_all = (lp->allmulticast ? TRUE: FALSE); /* Allow all multicasts */
|
3610 |
|
|
#else
|
3611 |
|
|
cfblk.mc_all = FALSE; /* No multicast all mode */
|
3612 |
|
|
#endif
|
3613 |
|
|
cfblk.rcv_mon = 0; /* Monitor mode disabled */
|
3614 |
|
|
cfblk.frag_acpt = TRUE; /* Do not accept fragments */
|
3615 |
|
|
cfblk.tstrttrs = FALSE; /* No start transmission threshold */
|
3616 |
|
|
cfblk.fretx = TRUE; /* FIFO automatic retransmission */
|
3617 |
|
|
cfblk.syncrqs = FALSE; /* Synchronous DRQ deassertion... */
|
3618 |
|
|
cfblk.sttlen = TRUE; /* 6 byte status registers */
|
3619 |
|
|
cfblk.rx_eop = TRUE; /* Signal EOP on packet reception */
|
3620 |
|
|
cfblk.tx_eop = TRUE; /* Signal EOP on packet transmission */
|
3621 |
|
|
cfblk.rbuf_size = RX_SIZE>>11; /* Set receive buffer size */
|
3622 |
|
|
cfblk.rcvstop = TRUE; /* Enable Receive Stop Register */
|
3623 |
|
|
|
3624 |
|
|
#ifdef DEBUG_I82593_SHOW
|
3625 |
|
|
{
|
3626 |
|
|
u_char *c = (u_char *) &cfblk;
|
3627 |
|
|
int i;
|
3628 |
|
|
printk(KERN_DEBUG "wavelan_cs: config block:");
|
3629 |
|
|
for(i = 0; i < sizeof(struct i82593_conf_block); i++,c++)
|
3630 |
|
|
{
|
3631 |
|
|
if((i % 16) == 0) printk("\n" KERN_DEBUG);
|
3632 |
|
|
printk("%02x ", *c);
|
3633 |
|
|
}
|
3634 |
|
|
printk("\n");
|
3635 |
|
|
}
|
3636 |
|
|
#endif
|
3637 |
|
|
|
3638 |
|
|
/* Copy the config block to the i82593 */
|
3639 |
|
|
outb(TX_BASE & 0xff, PIORL(base));
|
3640 |
|
|
outb(((TX_BASE >> 8) & PIORH_MASK) | PIORH_SEL_TX, PIORH(base));
|
3641 |
|
|
outb(sizeof(struct i82593_conf_block) & 0xff, PIOP(base)); /* lsb */
|
3642 |
|
|
outb(sizeof(struct i82593_conf_block) >> 8, PIOP(base)); /* msb */
|
3643 |
|
|
outsb(PIOP(base), (char *) &cfblk, sizeof(struct i82593_conf_block));
|
3644 |
|
|
|
3645 |
|
|
/* reset transmit DMA pointer */
|
3646 |
|
|
hacr_write_slow(base, HACR_PWR_STAT | HACR_TX_DMA_RESET);
|
3647 |
|
|
hacr_write(base, HACR_DEFAULT);
|
3648 |
|
|
if(!wv_82593_cmd(dev, "wv_82593_config(): configure",
|
3649 |
|
|
OP0_CONFIGURE, SR0_CONFIGURE_DONE))
|
3650 |
|
|
ret = FALSE;
|
3651 |
|
|
|
3652 |
|
|
/* Initialize adapter's ethernet MAC address */
|
3653 |
|
|
outb(TX_BASE & 0xff, PIORL(base));
|
3654 |
|
|
outb(((TX_BASE >> 8) & PIORH_MASK) | PIORH_SEL_TX, PIORH(base));
|
3655 |
|
|
outb(WAVELAN_ADDR_SIZE, PIOP(base)); /* byte count lsb */
|
3656 |
|
|
outb(0, PIOP(base)); /* byte count msb */
|
3657 |
|
|
outsb(PIOP(base), &dev->dev_addr[0], WAVELAN_ADDR_SIZE);
|
3658 |
|
|
|
3659 |
|
|
/* reset transmit DMA pointer */
|
3660 |
|
|
hacr_write_slow(base, HACR_PWR_STAT | HACR_TX_DMA_RESET);
|
3661 |
|
|
hacr_write(base, HACR_DEFAULT);
|
3662 |
|
|
if(!wv_82593_cmd(dev, "wv_82593_config(): ia-setup",
|
3663 |
|
|
OP0_IA_SETUP, SR0_IA_SETUP_DONE))
|
3664 |
|
|
ret = FALSE;
|
3665 |
|
|
|
3666 |
|
|
#ifdef WAVELAN_ROAMING
|
3667 |
|
|
/* If roaming is enabled, join the "Beacon Request" multicast group... */
|
3668 |
|
|
/* But only if it's not in there already! */
|
3669 |
|
|
if(do_roaming)
|
3670 |
|
|
dev_mc_add(dev,WAVELAN_BEACON_ADDRESS, WAVELAN_ADDR_SIZE, 1);
|
3671 |
|
|
#endif /* WAVELAN_ROAMING */
|
3672 |
|
|
|
3673 |
|
|
/* If any multicast address to set */
|
3674 |
|
|
if(lp->mc_count)
|
3675 |
|
|
{
|
3676 |
|
|
struct dev_mc_list * dmi;
|
3677 |
|
|
int addrs_len = WAVELAN_ADDR_SIZE * lp->mc_count;
|
3678 |
|
|
|
3679 |
|
|
#ifdef DEBUG_CONFIG_INFO
|
3680 |
|
|
DECLARE_MAC_BUF(mac);
|
3681 |
|
|
printk(KERN_DEBUG "%s: wv_hw_config(): set %d multicast addresses:\n",
|
3682 |
|
|
dev->name, lp->mc_count);
|
3683 |
|
|
for(dmi=dev->mc_list; dmi; dmi=dmi->next)
|
3684 |
|
|
printk(KERN_DEBUG " %s\n",
|
3685 |
|
|
print_mac(mac, dmi->dmi_addr));
|
3686 |
|
|
#endif
|
3687 |
|
|
|
3688 |
|
|
/* Initialize adapter's ethernet multicast addresses */
|
3689 |
|
|
outb(TX_BASE & 0xff, PIORL(base));
|
3690 |
|
|
outb(((TX_BASE >> 8) & PIORH_MASK) | PIORH_SEL_TX, PIORH(base));
|
3691 |
|
|
outb(addrs_len & 0xff, PIOP(base)); /* byte count lsb */
|
3692 |
|
|
outb((addrs_len >> 8), PIOP(base)); /* byte count msb */
|
3693 |
|
|
for(dmi=dev->mc_list; dmi; dmi=dmi->next)
|
3694 |
|
|
outsb(PIOP(base), dmi->dmi_addr, dmi->dmi_addrlen);
|
3695 |
|
|
|
3696 |
|
|
/* reset transmit DMA pointer */
|
3697 |
|
|
hacr_write_slow(base, HACR_PWR_STAT | HACR_TX_DMA_RESET);
|
3698 |
|
|
hacr_write(base, HACR_DEFAULT);
|
3699 |
|
|
if(!wv_82593_cmd(dev, "wv_82593_config(): mc-setup",
|
3700 |
|
|
OP0_MC_SETUP, SR0_MC_SETUP_DONE))
|
3701 |
|
|
ret = FALSE;
|
3702 |
|
|
lp->mc_count = dev->mc_count; /* remember to avoid repeated reset */
|
3703 |
|
|
}
|
3704 |
|
|
|
3705 |
|
|
/* Job done, clear the flag */
|
3706 |
|
|
lp->reconfig_82593 = FALSE;
|
3707 |
|
|
|
3708 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3709 |
|
|
printk(KERN_DEBUG "%s: <-wv_82593_config()\n", dev->name);
|
3710 |
|
|
#endif
|
3711 |
|
|
return(ret);
|
3712 |
|
|
}
|
3713 |
|
|
|
3714 |
|
|
/*------------------------------------------------------------------*/
|
3715 |
|
|
/*
|
3716 |
|
|
* Read the Access Configuration Register, perform a software reset,
|
3717 |
|
|
* and then re-enable the card's software.
|
3718 |
|
|
*
|
3719 |
|
|
* If I understand correctly : reset the pcmcia interface of the
|
3720 |
|
|
* wavelan.
|
3721 |
|
|
* (called by wv_config())
|
3722 |
|
|
*/
|
3723 |
|
|
static inline int
|
3724 |
|
|
wv_pcmcia_reset(struct net_device * dev)
|
3725 |
|
|
{
|
3726 |
|
|
int i;
|
3727 |
|
|
conf_reg_t reg = { 0, CS_READ, CISREG_COR, 0 };
|
3728 |
|
|
struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link;
|
3729 |
|
|
|
3730 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3731 |
|
|
printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name);
|
3732 |
|
|
#endif
|
3733 |
|
|
|
3734 |
|
|
i = pcmcia_access_configuration_register(link, ®);
|
3735 |
|
|
if(i != CS_SUCCESS)
|
3736 |
|
|
{
|
3737 |
|
|
cs_error(link, AccessConfigurationRegister, i);
|
3738 |
|
|
return FALSE;
|
3739 |
|
|
}
|
3740 |
|
|
|
3741 |
|
|
#ifdef DEBUG_CONFIG_INFO
|
3742 |
|
|
printk(KERN_DEBUG "%s: wavelan_pcmcia_reset(): Config reg is 0x%x\n",
|
3743 |
|
|
dev->name, (u_int) reg.Value);
|
3744 |
|
|
#endif
|
3745 |
|
|
|
3746 |
|
|
reg.Action = CS_WRITE;
|
3747 |
|
|
reg.Value = reg.Value | COR_SW_RESET;
|
3748 |
|
|
i = pcmcia_access_configuration_register(link, ®);
|
3749 |
|
|
if(i != CS_SUCCESS)
|
3750 |
|
|
{
|
3751 |
|
|
cs_error(link, AccessConfigurationRegister, i);
|
3752 |
|
|
return FALSE;
|
3753 |
|
|
}
|
3754 |
|
|
|
3755 |
|
|
reg.Action = CS_WRITE;
|
3756 |
|
|
reg.Value = COR_LEVEL_IRQ | COR_CONFIG;
|
3757 |
|
|
i = pcmcia_access_configuration_register(link, ®);
|
3758 |
|
|
if(i != CS_SUCCESS)
|
3759 |
|
|
{
|
3760 |
|
|
cs_error(link, AccessConfigurationRegister, i);
|
3761 |
|
|
return FALSE;
|
3762 |
|
|
}
|
3763 |
|
|
|
3764 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3765 |
|
|
printk(KERN_DEBUG "%s: <-wv_pcmcia_reset()\n", dev->name);
|
3766 |
|
|
#endif
|
3767 |
|
|
return TRUE;
|
3768 |
|
|
}
|
3769 |
|
|
|
3770 |
|
|
/*------------------------------------------------------------------*/
|
3771 |
|
|
/*
|
3772 |
|
|
* wavelan_hw_config() is called after a CARD_INSERTION event is
|
3773 |
|
|
* received, to configure the wavelan hardware.
|
3774 |
|
|
* Note that the reception will be enabled in wavelan->open(), so the
|
3775 |
|
|
* device is configured but idle...
|
3776 |
|
|
* Performs the following actions:
|
3777 |
|
|
* 1. A pcmcia software reset (using wv_pcmcia_reset())
|
3778 |
|
|
* 2. A power reset (reset DMA)
|
3779 |
|
|
* 3. Reset the LAN controller
|
3780 |
|
|
* 4. Initialize the radio modem (using wv_mmc_init)
|
3781 |
|
|
* 5. Configure LAN controller (using wv_82593_config)
|
3782 |
|
|
* 6. Perform a diagnostic on the LAN controller
|
3783 |
|
|
* (called by wavelan_event() & wv_hw_reset())
|
3784 |
|
|
*/
|
3785 |
|
|
static int
|
3786 |
|
|
wv_hw_config(struct net_device * dev)
|
3787 |
|
|
{
|
3788 |
|
|
net_local * lp = netdev_priv(dev);
|
3789 |
|
|
kio_addr_t base = dev->base_addr;
|
3790 |
|
|
unsigned long flags;
|
3791 |
|
|
int ret = FALSE;
|
3792 |
|
|
|
3793 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3794 |
|
|
printk(KERN_DEBUG "%s: ->wv_hw_config()\n", dev->name);
|
3795 |
|
|
#endif
|
3796 |
|
|
|
3797 |
|
|
#ifdef STRUCT_CHECK
|
3798 |
|
|
if(wv_structuct_check() != (char *) NULL)
|
3799 |
|
|
{
|
3800 |
|
|
printk(KERN_WARNING "%s: wv_hw_config: structure/compiler botch: \"%s\"\n",
|
3801 |
|
|
dev->name, wv_structuct_check());
|
3802 |
|
|
return FALSE;
|
3803 |
|
|
}
|
3804 |
|
|
#endif /* STRUCT_CHECK == 1 */
|
3805 |
|
|
|
3806 |
|
|
/* Reset the pcmcia interface */
|
3807 |
|
|
if(wv_pcmcia_reset(dev) == FALSE)
|
3808 |
|
|
return FALSE;
|
3809 |
|
|
|
3810 |
|
|
/* Disable interrupts */
|
3811 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
3812 |
|
|
|
3813 |
|
|
/* Disguised goto ;-) */
|
3814 |
|
|
do
|
3815 |
|
|
{
|
3816 |
|
|
/* Power UP the module + reset the modem + reset host adapter
|
3817 |
|
|
* (in fact, reset DMA channels) */
|
3818 |
|
|
hacr_write_slow(base, HACR_RESET);
|
3819 |
|
|
hacr_write(base, HACR_DEFAULT);
|
3820 |
|
|
|
3821 |
|
|
/* Check if the module has been powered up... */
|
3822 |
|
|
if(hasr_read(base) & HASR_NO_CLK)
|
3823 |
|
|
{
|
3824 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
3825 |
|
|
printk(KERN_WARNING "%s: wv_hw_config(): modem not connected or not a wavelan card\n",
|
3826 |
|
|
dev->name);
|
3827 |
|
|
#endif
|
3828 |
|
|
break;
|
3829 |
|
|
}
|
3830 |
|
|
|
3831 |
|
|
/* initialize the modem */
|
3832 |
|
|
if(wv_mmc_init(dev) == FALSE)
|
3833 |
|
|
{
|
3834 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
3835 |
|
|
printk(KERN_WARNING "%s: wv_hw_config(): Can't configure the modem\n",
|
3836 |
|
|
dev->name);
|
3837 |
|
|
#endif
|
3838 |
|
|
break;
|
3839 |
|
|
}
|
3840 |
|
|
|
3841 |
|
|
/* reset the LAN controller (i82593) */
|
3842 |
|
|
outb(OP0_RESET, LCCR(base));
|
3843 |
|
|
mdelay(1); /* A bit crude ! */
|
3844 |
|
|
|
3845 |
|
|
/* Initialize the LAN controller */
|
3846 |
|
|
if(wv_82593_config(dev) == FALSE)
|
3847 |
|
|
{
|
3848 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
3849 |
|
|
printk(KERN_INFO "%s: wv_hw_config(): i82593 init failed\n",
|
3850 |
|
|
dev->name);
|
3851 |
|
|
#endif
|
3852 |
|
|
break;
|
3853 |
|
|
}
|
3854 |
|
|
|
3855 |
|
|
/* Diagnostic */
|
3856 |
|
|
if(wv_diag(dev) == FALSE)
|
3857 |
|
|
{
|
3858 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
3859 |
|
|
printk(KERN_INFO "%s: wv_hw_config(): i82593 diagnostic failed\n",
|
3860 |
|
|
dev->name);
|
3861 |
|
|
#endif
|
3862 |
|
|
break;
|
3863 |
|
|
}
|
3864 |
|
|
|
3865 |
|
|
/*
|
3866 |
|
|
* insert code for loopback test here
|
3867 |
|
|
*/
|
3868 |
|
|
|
3869 |
|
|
/* The device is now configured */
|
3870 |
|
|
lp->configured = 1;
|
3871 |
|
|
ret = TRUE;
|
3872 |
|
|
}
|
3873 |
|
|
while(0);
|
3874 |
|
|
|
3875 |
|
|
/* Re-enable interrupts */
|
3876 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
3877 |
|
|
|
3878 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3879 |
|
|
printk(KERN_DEBUG "%s: <-wv_hw_config()\n", dev->name);
|
3880 |
|
|
#endif
|
3881 |
|
|
return(ret);
|
3882 |
|
|
}
|
3883 |
|
|
|
3884 |
|
|
/*------------------------------------------------------------------*/
|
3885 |
|
|
/*
|
3886 |
|
|
* Totally reset the wavelan and restart it.
|
3887 |
|
|
* Performs the following actions:
|
3888 |
|
|
* 1. Call wv_hw_config()
|
3889 |
|
|
* 2. Start the LAN controller's receive unit
|
3890 |
|
|
* (called by wavelan_event(), wavelan_watchdog() and wavelan_open())
|
3891 |
|
|
*/
|
3892 |
|
|
static inline void
|
3893 |
|
|
wv_hw_reset(struct net_device * dev)
|
3894 |
|
|
{
|
3895 |
|
|
net_local * lp = netdev_priv(dev);
|
3896 |
|
|
|
3897 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3898 |
|
|
printk(KERN_DEBUG "%s: ->wv_hw_reset()\n", dev->name);
|
3899 |
|
|
#endif
|
3900 |
|
|
|
3901 |
|
|
lp->nresets++;
|
3902 |
|
|
lp->configured = 0;
|
3903 |
|
|
|
3904 |
|
|
/* Call wv_hw_config() for most of the reset & init stuff */
|
3905 |
|
|
if(wv_hw_config(dev) == FALSE)
|
3906 |
|
|
return;
|
3907 |
|
|
|
3908 |
|
|
/* start receive unit */
|
3909 |
|
|
wv_ru_start(dev);
|
3910 |
|
|
|
3911 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3912 |
|
|
printk(KERN_DEBUG "%s: <-wv_hw_reset()\n", dev->name);
|
3913 |
|
|
#endif
|
3914 |
|
|
}
|
3915 |
|
|
|
3916 |
|
|
/*------------------------------------------------------------------*/
|
3917 |
|
|
/*
|
3918 |
|
|
* wv_pcmcia_config() is called after a CARD_INSERTION event is
|
3919 |
|
|
* received, to configure the PCMCIA socket, and to make the ethernet
|
3920 |
|
|
* device available to the system.
|
3921 |
|
|
* (called by wavelan_event())
|
3922 |
|
|
*/
|
3923 |
|
|
static inline int
|
3924 |
|
|
wv_pcmcia_config(struct pcmcia_device * link)
|
3925 |
|
|
{
|
3926 |
|
|
struct net_device * dev = (struct net_device *) link->priv;
|
3927 |
|
|
int i;
|
3928 |
|
|
win_req_t req;
|
3929 |
|
|
memreq_t mem;
|
3930 |
|
|
net_local * lp = netdev_priv(dev);
|
3931 |
|
|
|
3932 |
|
|
|
3933 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
3934 |
|
|
printk(KERN_DEBUG "->wv_pcmcia_config(0x%p)\n", link);
|
3935 |
|
|
#endif
|
3936 |
|
|
|
3937 |
|
|
do
|
3938 |
|
|
{
|
3939 |
|
|
i = pcmcia_request_io(link, &link->io);
|
3940 |
|
|
if(i != CS_SUCCESS)
|
3941 |
|
|
{
|
3942 |
|
|
cs_error(link, RequestIO, i);
|
3943 |
|
|
break;
|
3944 |
|
|
}
|
3945 |
|
|
|
3946 |
|
|
/*
|
3947 |
|
|
* Now allocate an interrupt line. Note that this does not
|
3948 |
|
|
* actually assign a handler to the interrupt.
|
3949 |
|
|
*/
|
3950 |
|
|
i = pcmcia_request_irq(link, &link->irq);
|
3951 |
|
|
if(i != CS_SUCCESS)
|
3952 |
|
|
{
|
3953 |
|
|
cs_error(link, RequestIRQ, i);
|
3954 |
|
|
break;
|
3955 |
|
|
}
|
3956 |
|
|
|
3957 |
|
|
/*
|
3958 |
|
|
* This actually configures the PCMCIA socket -- setting up
|
3959 |
|
|
* the I/O windows and the interrupt mapping.
|
3960 |
|
|
*/
|
3961 |
|
|
link->conf.ConfigIndex = 1;
|
3962 |
|
|
i = pcmcia_request_configuration(link, &link->conf);
|
3963 |
|
|
if(i != CS_SUCCESS)
|
3964 |
|
|
{
|
3965 |
|
|
cs_error(link, RequestConfiguration, i);
|
3966 |
|
|
break;
|
3967 |
|
|
}
|
3968 |
|
|
|
3969 |
|
|
/*
|
3970 |
|
|
* Allocate a small memory window. Note that the struct pcmcia_device
|
3971 |
|
|
* structure provides space for one window handle -- if your
|
3972 |
|
|
* device needs several windows, you'll need to keep track of
|
3973 |
|
|
* the handles in your private data structure, link->priv.
|
3974 |
|
|
*/
|
3975 |
|
|
req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
|
3976 |
|
|
req.Base = req.Size = 0;
|
3977 |
|
|
req.AccessSpeed = mem_speed;
|
3978 |
|
|
i = pcmcia_request_window(&link, &req, &link->win);
|
3979 |
|
|
if(i != CS_SUCCESS)
|
3980 |
|
|
{
|
3981 |
|
|
cs_error(link, RequestWindow, i);
|
3982 |
|
|
break;
|
3983 |
|
|
}
|
3984 |
|
|
|
3985 |
|
|
lp->mem = ioremap(req.Base, req.Size);
|
3986 |
|
|
dev->mem_start = (u_long)lp->mem;
|
3987 |
|
|
dev->mem_end = dev->mem_start + req.Size;
|
3988 |
|
|
|
3989 |
|
|
mem.CardOffset = 0; mem.Page = 0;
|
3990 |
|
|
i = pcmcia_map_mem_page(link->win, &mem);
|
3991 |
|
|
if(i != CS_SUCCESS)
|
3992 |
|
|
{
|
3993 |
|
|
cs_error(link, MapMemPage, i);
|
3994 |
|
|
break;
|
3995 |
|
|
}
|
3996 |
|
|
|
3997 |
|
|
/* Feed device with this info... */
|
3998 |
|
|
dev->irq = link->irq.AssignedIRQ;
|
3999 |
|
|
dev->base_addr = link->io.BasePort1;
|
4000 |
|
|
netif_start_queue(dev);
|
4001 |
|
|
|
4002 |
|
|
#ifdef DEBUG_CONFIG_INFO
|
4003 |
|
|
printk(KERN_DEBUG "wv_pcmcia_config: MEMSTART %p IRQ %d IOPORT 0x%x\n",
|
4004 |
|
|
lp->mem, dev->irq, (u_int) dev->base_addr);
|
4005 |
|
|
#endif
|
4006 |
|
|
|
4007 |
|
|
SET_NETDEV_DEV(dev, &handle_to_dev(link));
|
4008 |
|
|
i = register_netdev(dev);
|
4009 |
|
|
if(i != 0)
|
4010 |
|
|
{
|
4011 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
4012 |
|
|
printk(KERN_INFO "wv_pcmcia_config(): register_netdev() failed\n");
|
4013 |
|
|
#endif
|
4014 |
|
|
break;
|
4015 |
|
|
}
|
4016 |
|
|
}
|
4017 |
|
|
while(0); /* Humm... Disguised goto !!! */
|
4018 |
|
|
|
4019 |
|
|
/* If any step failed, release any partially configured state */
|
4020 |
|
|
if(i != 0)
|
4021 |
|
|
{
|
4022 |
|
|
wv_pcmcia_release(link);
|
4023 |
|
|
return FALSE;
|
4024 |
|
|
}
|
4025 |
|
|
|
4026 |
|
|
strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name);
|
4027 |
|
|
link->dev_node = &((net_local *) netdev_priv(dev))->node;
|
4028 |
|
|
|
4029 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
4030 |
|
|
printk(KERN_DEBUG "<-wv_pcmcia_config()\n");
|
4031 |
|
|
#endif
|
4032 |
|
|
return TRUE;
|
4033 |
|
|
}
|
4034 |
|
|
|
4035 |
|
|
/*------------------------------------------------------------------*/
|
4036 |
|
|
/*
|
4037 |
|
|
* After a card is removed, wv_pcmcia_release() will unregister the net
|
4038 |
|
|
* device, and release the PCMCIA configuration. If the device is
|
4039 |
|
|
* still open, this will be postponed until it is closed.
|
4040 |
|
|
*/
|
4041 |
|
|
static void
|
4042 |
|
|
wv_pcmcia_release(struct pcmcia_device *link)
|
4043 |
|
|
{
|
4044 |
|
|
struct net_device * dev = (struct net_device *) link->priv;
|
4045 |
|
|
net_local * lp = netdev_priv(dev);
|
4046 |
|
|
|
4047 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
4048 |
|
|
printk(KERN_DEBUG "%s: -> wv_pcmcia_release(0x%p)\n", dev->name, link);
|
4049 |
|
|
#endif
|
4050 |
|
|
|
4051 |
|
|
iounmap(lp->mem);
|
4052 |
|
|
pcmcia_disable_device(link);
|
4053 |
|
|
|
4054 |
|
|
#ifdef DEBUG_CONFIG_TRACE
|
4055 |
|
|
printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name);
|
4056 |
|
|
#endif
|
4057 |
|
|
}
|
4058 |
|
|
|
4059 |
|
|
/************************ INTERRUPT HANDLING ************************/
|
4060 |
|
|
|
4061 |
|
|
/*
|
4062 |
|
|
* This function is the interrupt handler for the WaveLAN card. This
|
4063 |
|
|
* routine will be called whenever:
|
4064 |
|
|
* 1. A packet is received.
|
4065 |
|
|
* 2. A packet has successfully been transferred and the unit is
|
4066 |
|
|
* ready to transmit another packet.
|
4067 |
|
|
* 3. A command has completed execution.
|
4068 |
|
|
*/
|
4069 |
|
|
static irqreturn_t
|
4070 |
|
|
wavelan_interrupt(int irq,
|
4071 |
|
|
void * dev_id)
|
4072 |
|
|
{
|
4073 |
|
|
struct net_device * dev = dev_id;
|
4074 |
|
|
net_local * lp;
|
4075 |
|
|
kio_addr_t base;
|
4076 |
|
|
int status0;
|
4077 |
|
|
u_int tx_status;
|
4078 |
|
|
|
4079 |
|
|
#ifdef DEBUG_INTERRUPT_TRACE
|
4080 |
|
|
printk(KERN_DEBUG "%s: ->wavelan_interrupt()\n", dev->name);
|
4081 |
|
|
#endif
|
4082 |
|
|
|
4083 |
|
|
lp = netdev_priv(dev);
|
4084 |
|
|
base = dev->base_addr;
|
4085 |
|
|
|
4086 |
|
|
#ifdef DEBUG_INTERRUPT_INFO
|
4087 |
|
|
/* Check state of our spinlock (it should be cleared) */
|
4088 |
|
|
if(spin_is_locked(&lp->spinlock))
|
4089 |
|
|
printk(KERN_DEBUG
|
4090 |
|
|
"%s: wavelan_interrupt(): spinlock is already locked !!!\n",
|
4091 |
|
|
dev->name);
|
4092 |
|
|
#endif
|
4093 |
|
|
|
4094 |
|
|
/* Prevent reentrancy. We need to do that because we may have
|
4095 |
|
|
* multiple interrupt handler running concurently.
|
4096 |
|
|
* It is safe because interrupts are disabled before aquiring
|
4097 |
|
|
* the spinlock. */
|
4098 |
|
|
spin_lock(&lp->spinlock);
|
4099 |
|
|
|
4100 |
|
|
/* Treat all pending interrupts */
|
4101 |
|
|
while(1)
|
4102 |
|
|
{
|
4103 |
|
|
/* ---------------- INTERRUPT CHECKING ---------------- */
|
4104 |
|
|
/*
|
4105 |
|
|
* Look for the interrupt and verify the validity
|
4106 |
|
|
*/
|
4107 |
|
|
outb(CR0_STATUS_0 | OP0_NOP, LCCR(base));
|
4108 |
|
|
status0 = inb(LCSR(base));
|
4109 |
|
|
|
4110 |
|
|
#ifdef DEBUG_INTERRUPT_INFO
|
4111 |
|
|
printk(KERN_DEBUG "status0 0x%x [%s => 0x%x]", status0,
|
4112 |
|
|
(status0&SR0_INTERRUPT)?"int":"no int",status0&~SR0_INTERRUPT);
|
4113 |
|
|
if(status0&SR0_INTERRUPT)
|
4114 |
|
|
{
|
4115 |
|
|
printk(" [%s => %d]\n", (status0 & SR0_CHNL) ? "chnl" :
|
4116 |
|
|
((status0 & SR0_EXECUTION) ? "cmd" :
|
4117 |
|
|
((status0 & SR0_RECEPTION) ? "recv" : "unknown")),
|
4118 |
|
|
(status0 & SR0_EVENT_MASK));
|
4119 |
|
|
}
|
4120 |
|
|
else
|
4121 |
|
|
printk("\n");
|
4122 |
|
|
#endif
|
4123 |
|
|
|
4124 |
|
|
/* Return if no actual interrupt from i82593 (normal exit) */
|
4125 |
|
|
if(!(status0 & SR0_INTERRUPT))
|
4126 |
|
|
break;
|
4127 |
|
|
|
4128 |
|
|
/* If interrupt is both Rx and Tx or none...
|
4129 |
|
|
* This code in fact is there to catch the spurious interrupt
|
4130 |
|
|
* when you remove the wavelan pcmcia card from the socket */
|
4131 |
|
|
if(((status0 & SR0_BOTH_RX_TX) == SR0_BOTH_RX_TX) ||
|
4132 |
|
|
((status0 & SR0_BOTH_RX_TX) == 0x0))
|
4133 |
|
|
{
|
4134 |
|
|
#ifdef DEBUG_INTERRUPT_INFO
|
4135 |
|
|
printk(KERN_INFO "%s: wv_interrupt(): bogus interrupt (or from dead card) : %X\n",
|
4136 |
|
|
dev->name, status0);
|
4137 |
|
|
#endif
|
4138 |
|
|
/* Acknowledge the interrupt */
|
4139 |
|
|
outb(CR0_INT_ACK | OP0_NOP, LCCR(base));
|
4140 |
|
|
break;
|
4141 |
|
|
}
|
4142 |
|
|
|
4143 |
|
|
/* ----------------- RECEIVING PACKET ----------------- */
|
4144 |
|
|
/*
|
4145 |
|
|
* When the wavelan signal the reception of a new packet,
|
4146 |
|
|
* we call wv_packet_rcv() to copy if from the buffer and
|
4147 |
|
|
* send it to NET3
|
4148 |
|
|
*/
|
4149 |
|
|
if(status0 & SR0_RECEPTION)
|
4150 |
|
|
{
|
4151 |
|
|
#ifdef DEBUG_INTERRUPT_INFO
|
4152 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): receive\n", dev->name);
|
4153 |
|
|
#endif
|
4154 |
|
|
|
4155 |
|
|
if((status0 & SR0_EVENT_MASK) == SR0_STOP_REG_HIT)
|
4156 |
|
|
{
|
4157 |
|
|
#ifdef DEBUG_INTERRUPT_ERROR
|
4158 |
|
|
printk(KERN_INFO "%s: wv_interrupt(): receive buffer overflow\n",
|
4159 |
|
|
dev->name);
|
4160 |
|
|
#endif
|
4161 |
|
|
lp->stats.rx_over_errors++;
|
4162 |
|
|
lp->overrunning = 1;
|
4163 |
|
|
}
|
4164 |
|
|
|
4165 |
|
|
/* Get the packet */
|
4166 |
|
|
wv_packet_rcv(dev);
|
4167 |
|
|
lp->overrunning = 0;
|
4168 |
|
|
|
4169 |
|
|
/* Acknowledge the interrupt */
|
4170 |
|
|
outb(CR0_INT_ACK | OP0_NOP, LCCR(base));
|
4171 |
|
|
continue;
|
4172 |
|
|
}
|
4173 |
|
|
|
4174 |
|
|
/* ---------------- COMMAND COMPLETION ---------------- */
|
4175 |
|
|
/*
|
4176 |
|
|
* Interrupts issued when the i82593 has completed a command.
|
4177 |
|
|
* Most likely : transmission done
|
4178 |
|
|
*/
|
4179 |
|
|
|
4180 |
|
|
/* If a transmission has been done */
|
4181 |
|
|
if((status0 & SR0_EVENT_MASK) == SR0_TRANSMIT_DONE ||
|
4182 |
|
|
(status0 & SR0_EVENT_MASK) == SR0_RETRANSMIT_DONE ||
|
4183 |
|
|
(status0 & SR0_EVENT_MASK) == SR0_TRANSMIT_NO_CRC_DONE)
|
4184 |
|
|
{
|
4185 |
|
|
#ifdef DEBUG_TX_ERROR
|
4186 |
|
|
if((status0 & SR0_EVENT_MASK) == SR0_TRANSMIT_NO_CRC_DONE)
|
4187 |
|
|
printk(KERN_INFO "%s: wv_interrupt(): packet transmitted without CRC.\n",
|
4188 |
|
|
dev->name);
|
4189 |
|
|
#endif
|
4190 |
|
|
|
4191 |
|
|
/* Get transmission status */
|
4192 |
|
|
tx_status = inb(LCSR(base));
|
4193 |
|
|
tx_status |= (inb(LCSR(base)) << 8);
|
4194 |
|
|
#ifdef DEBUG_INTERRUPT_INFO
|
4195 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): transmission done\n",
|
4196 |
|
|
dev->name);
|
4197 |
|
|
{
|
4198 |
|
|
u_int rcv_bytes;
|
4199 |
|
|
u_char status3;
|
4200 |
|
|
rcv_bytes = inb(LCSR(base));
|
4201 |
|
|
rcv_bytes |= (inb(LCSR(base)) << 8);
|
4202 |
|
|
status3 = inb(LCSR(base));
|
4203 |
|
|
printk(KERN_DEBUG "tx_status 0x%02x rcv_bytes 0x%02x status3 0x%x\n",
|
4204 |
|
|
tx_status, rcv_bytes, (u_int) status3);
|
4205 |
|
|
}
|
4206 |
|
|
#endif
|
4207 |
|
|
/* Check for possible errors */
|
4208 |
|
|
if((tx_status & TX_OK) != TX_OK)
|
4209 |
|
|
{
|
4210 |
|
|
lp->stats.tx_errors++;
|
4211 |
|
|
|
4212 |
|
|
if(tx_status & TX_FRTL)
|
4213 |
|
|
{
|
4214 |
|
|
#ifdef DEBUG_TX_ERROR
|
4215 |
|
|
printk(KERN_INFO "%s: wv_interrupt(): frame too long\n",
|
4216 |
|
|
dev->name);
|
4217 |
|
|
#endif
|
4218 |
|
|
}
|
4219 |
|
|
if(tx_status & TX_UND_RUN)
|
4220 |
|
|
{
|
4221 |
|
|
#ifdef DEBUG_TX_FAIL
|
4222 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): DMA underrun\n",
|
4223 |
|
|
dev->name);
|
4224 |
|
|
#endif
|
4225 |
|
|
lp->stats.tx_aborted_errors++;
|
4226 |
|
|
}
|
4227 |
|
|
if(tx_status & TX_LOST_CTS)
|
4228 |
|
|
{
|
4229 |
|
|
#ifdef DEBUG_TX_FAIL
|
4230 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): no CTS\n", dev->name);
|
4231 |
|
|
#endif
|
4232 |
|
|
lp->stats.tx_carrier_errors++;
|
4233 |
|
|
}
|
4234 |
|
|
if(tx_status & TX_LOST_CRS)
|
4235 |
|
|
{
|
4236 |
|
|
#ifdef DEBUG_TX_FAIL
|
4237 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): no carrier\n",
|
4238 |
|
|
dev->name);
|
4239 |
|
|
#endif
|
4240 |
|
|
lp->stats.tx_carrier_errors++;
|
4241 |
|
|
}
|
4242 |
|
|
if(tx_status & TX_HRT_BEAT)
|
4243 |
|
|
{
|
4244 |
|
|
#ifdef DEBUG_TX_FAIL
|
4245 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): heart beat\n", dev->name);
|
4246 |
|
|
#endif
|
4247 |
|
|
lp->stats.tx_heartbeat_errors++;
|
4248 |
|
|
}
|
4249 |
|
|
if(tx_status & TX_DEFER)
|
4250 |
|
|
{
|
4251 |
|
|
#ifdef DEBUG_TX_FAIL
|
4252 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): channel jammed\n",
|
4253 |
|
|
dev->name);
|
4254 |
|
|
#endif
|
4255 |
|
|
}
|
4256 |
|
|
/* Ignore late collisions since they're more likely to happen
|
4257 |
|
|
* here (the WaveLAN design prevents the LAN controller from
|
4258 |
|
|
* receiving while it is transmitting). We take action only when
|
4259 |
|
|
* the maximum retransmit attempts is exceeded.
|
4260 |
|
|
*/
|
4261 |
|
|
if(tx_status & TX_COLL)
|
4262 |
|
|
{
|
4263 |
|
|
if(tx_status & TX_MAX_COL)
|
4264 |
|
|
{
|
4265 |
|
|
#ifdef DEBUG_TX_FAIL
|
4266 |
|
|
printk(KERN_DEBUG "%s: wv_interrupt(): channel congestion\n",
|
4267 |
|
|
dev->name);
|
4268 |
|
|
#endif
|
4269 |
|
|
if(!(tx_status & TX_NCOL_MASK))
|
4270 |
|
|
{
|
4271 |
|
|
lp->stats.collisions += 0x10;
|
4272 |
|
|
}
|
4273 |
|
|
}
|
4274 |
|
|
}
|
4275 |
|
|
} /* if(!(tx_status & TX_OK)) */
|
4276 |
|
|
|
4277 |
|
|
lp->stats.collisions += (tx_status & TX_NCOL_MASK);
|
4278 |
|
|
lp->stats.tx_packets++;
|
4279 |
|
|
|
4280 |
|
|
netif_wake_queue(dev);
|
4281 |
|
|
outb(CR0_INT_ACK | OP0_NOP, LCCR(base)); /* Acknowledge the interrupt */
|
4282 |
|
|
}
|
4283 |
|
|
else /* if interrupt = transmit done or retransmit done */
|
4284 |
|
|
{
|
4285 |
|
|
#ifdef DEBUG_INTERRUPT_ERROR
|
4286 |
|
|
printk(KERN_INFO "wavelan_cs: unknown interrupt, status0 = %02x\n",
|
4287 |
|
|
status0);
|
4288 |
|
|
#endif
|
4289 |
|
|
outb(CR0_INT_ACK | OP0_NOP, LCCR(base)); /* Acknowledge the interrupt */
|
4290 |
|
|
}
|
4291 |
|
|
} /* while(1) */
|
4292 |
|
|
|
4293 |
|
|
spin_unlock(&lp->spinlock);
|
4294 |
|
|
|
4295 |
|
|
#ifdef DEBUG_INTERRUPT_TRACE
|
4296 |
|
|
printk(KERN_DEBUG "%s: <-wavelan_interrupt()\n", dev->name);
|
4297 |
|
|
#endif
|
4298 |
|
|
|
4299 |
|
|
/* We always return IRQ_HANDLED, because we will receive empty
|
4300 |
|
|
* interrupts under normal operations. Anyway, it doesn't matter
|
4301 |
|
|
* as we are dealing with an ISA interrupt that can't be shared.
|
4302 |
|
|
*
|
4303 |
|
|
* Explanation : under heavy receive, the following happens :
|
4304 |
|
|
* ->wavelan_interrupt()
|
4305 |
|
|
* (status0 & SR0_INTERRUPT) != 0
|
4306 |
|
|
* ->wv_packet_rcv()
|
4307 |
|
|
* (status0 & SR0_INTERRUPT) != 0
|
4308 |
|
|
* ->wv_packet_rcv()
|
4309 |
|
|
* (status0 & SR0_INTERRUPT) == 0 // i.e. no more event
|
4310 |
|
|
* <-wavelan_interrupt()
|
4311 |
|
|
* ->wavelan_interrupt()
|
4312 |
|
|
* (status0 & SR0_INTERRUPT) == 0 // i.e. empty interrupt
|
4313 |
|
|
* <-wavelan_interrupt()
|
4314 |
|
|
* Jean II */
|
4315 |
|
|
return IRQ_HANDLED;
|
4316 |
|
|
} /* wv_interrupt */
|
4317 |
|
|
|
4318 |
|
|
/*------------------------------------------------------------------*/
|
4319 |
|
|
/*
|
4320 |
|
|
* Watchdog: when we start a transmission, a timer is set for us in the
|
4321 |
|
|
* kernel. If the transmission completes, this timer is disabled. If
|
4322 |
|
|
* the timer expires, we are called and we try to unlock the hardware.
|
4323 |
|
|
*
|
4324 |
|
|
* Note : This watchdog is move clever than the one in the ISA driver,
|
4325 |
|
|
* because it try to abort the current command before reseting
|
4326 |
|
|
* everything...
|
4327 |
|
|
* On the other hand, it's a bit simpler, because we don't have to
|
4328 |
|
|
* deal with the multiple Tx buffers...
|
4329 |
|
|
*/
|
4330 |
|
|
static void
|
4331 |
|
|
wavelan_watchdog(struct net_device * dev)
|
4332 |
|
|
{
|
4333 |
|
|
net_local * lp = netdev_priv(dev);
|
4334 |
|
|
kio_addr_t base = dev->base_addr;
|
4335 |
|
|
unsigned long flags;
|
4336 |
|
|
int aborted = FALSE;
|
4337 |
|
|
|
4338 |
|
|
#ifdef DEBUG_INTERRUPT_TRACE
|
4339 |
|
|
printk(KERN_DEBUG "%s: ->wavelan_watchdog()\n", dev->name);
|
4340 |
|
|
#endif
|
4341 |
|
|
|
4342 |
|
|
#ifdef DEBUG_INTERRUPT_ERROR
|
4343 |
|
|
printk(KERN_INFO "%s: wavelan_watchdog: watchdog timer expired\n",
|
4344 |
|
|
dev->name);
|
4345 |
|
|
#endif
|
4346 |
|
|
|
4347 |
|
|
spin_lock_irqsave(&lp->spinlock, flags);
|
4348 |
|
|
|
4349 |
|
|
/* Ask to abort the current command */
|
4350 |
|
|
outb(OP0_ABORT, LCCR(base));
|
4351 |
|
|
|
4352 |
|
|
/* Wait for the end of the command (a bit hackish) */
|
4353 |
|
|
if(wv_82593_cmd(dev, "wavelan_watchdog(): abort",
|
4354 |
|
|
OP0_NOP | CR0_STATUS_3, SR0_EXECUTION_ABORTED))
|
4355 |
|
|
aborted = TRUE;
|
4356 |
|
|
|
4357 |
|
|
/* Release spinlock here so that wv_hw_reset() can grab it */
|
4358 |
|
|
spin_unlock_irqrestore(&lp->spinlock, flags);
|
4359 |
|
|
|
4360 |
|
|
/* Check if we were successful in aborting it */
|
4361 |
|
|
if(!aborted)
|
4362 |
|
|
{
|
4363 |
|
|
/* It seem that it wasn't enough */
|
4364 |
|
|
#ifdef DEBUG_INTERRUPT_ERROR
|
4365 |
|
|
printk(KERN_INFO "%s: wavelan_watchdog: abort failed, trying reset\n",
|
4366 |
|
|
dev->name);
|
4367 |
|
|
#endif
|
4368 |
|
|
wv_hw_reset(dev);
|
4369 |
|
|
}
|
4370 |
|
|
|
4371 |
|
|
#ifdef DEBUG_PSA_SHOW
|
4372 |
|
|
{
|
4373 |
|
|
psa_t psa;
|
4374 |
|
|
psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa));
|
4375 |
|
|
wv_psa_show(&psa);
|
4376 |
|
|
}
|
4377 |
|
|
#endif
|
4378 |
|
|
#ifdef DEBUG_MMC_SHOW
|
4379 |
|
|
wv_mmc_show(dev);
|
4380 |
|
|
#endif
|
4381 |
|
|
#ifdef DEBUG_I82593_SHOW
|
4382 |
|
|
wv_ru_show(dev);
|
4383 |
|
|
#endif
|
4384 |
|
|
|
4385 |
|
|
/* We are no more waiting for something... */
|
4386 |
|
|
netif_wake_queue(dev);
|
4387 |
|
|
|
4388 |
|
|
#ifdef DEBUG_INTERRUPT_TRACE
|
4389 |
|
|
printk(KERN_DEBUG "%s: <-wavelan_watchdog()\n", dev->name);
|
4390 |
|
|
#endif
|
4391 |
|
|
}
|
4392 |
|
|
|
4393 |
|
|
/********************* CONFIGURATION CALLBACKS *********************/
|
4394 |
|
|
/*
|
4395 |
|
|
* Here are the functions called by the pcmcia package (cardmgr) and
|
4396 |
|
|
* linux networking (NET3) for initialization, configuration and
|
4397 |
|
|
* deinstallations of the Wavelan Pcmcia Hardware.
|
4398 |
|
|
*/
|
4399 |
|
|
|
4400 |
|
|
/*------------------------------------------------------------------*/
|
4401 |
|
|
/*
|
4402 |
|
|
* Configure and start up the WaveLAN PCMCIA adaptor.
|
4403 |
|
|
* Called by NET3 when it "open" the device.
|
4404 |
|
|
*/
|
4405 |
|
|
static int
|
4406 |
|
|
wavelan_open(struct net_device * dev)
|
4407 |
|
|
{
|
4408 |
|
|
net_local * lp = netdev_priv(dev);
|
4409 |
|
|
struct pcmcia_device * link = lp->link;
|
4410 |
|
|
kio_addr_t base = dev->base_addr;
|
4411 |
|
|
|
4412 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4413 |
|
|
printk(KERN_DEBUG "%s: ->wavelan_open(dev=0x%x)\n", dev->name,
|
4414 |
|
|
(unsigned int) dev);
|
4415 |
|
|
#endif
|
4416 |
|
|
|
4417 |
|
|
/* Check if the modem is powered up (wavelan_close() power it down */
|
4418 |
|
|
if(hasr_read(base) & HASR_NO_CLK)
|
4419 |
|
|
{
|
4420 |
|
|
/* Power up (power up time is 250us) */
|
4421 |
|
|
hacr_write(base, HACR_DEFAULT);
|
4422 |
|
|
|
4423 |
|
|
/* Check if the module has been powered up... */
|
4424 |
|
|
if(hasr_read(base) & HASR_NO_CLK)
|
4425 |
|
|
{
|
4426 |
|
|
#ifdef DEBUG_CONFIG_ERRORS
|
4427 |
|
|
printk(KERN_WARNING "%s: wavelan_open(): modem not connected\n",
|
4428 |
|
|
dev->name);
|
4429 |
|
|
#endif
|
4430 |
|
|
return FALSE;
|
4431 |
|
|
}
|
4432 |
|
|
}
|
4433 |
|
|
|
4434 |
|
|
/* Start reception and declare the driver ready */
|
4435 |
|
|
if(!lp->configured)
|
4436 |
|
|
return FALSE;
|
4437 |
|
|
if(!wv_ru_start(dev))
|
4438 |
|
|
wv_hw_reset(dev); /* If problem : reset */
|
4439 |
|
|
netif_start_queue(dev);
|
4440 |
|
|
|
4441 |
|
|
/* Mark the device as used */
|
4442 |
|
|
link->open++;
|
4443 |
|
|
|
4444 |
|
|
#ifdef WAVELAN_ROAMING
|
4445 |
|
|
if(do_roaming)
|
4446 |
|
|
wv_roam_init(dev);
|
4447 |
|
|
#endif /* WAVELAN_ROAMING */
|
4448 |
|
|
|
4449 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4450 |
|
|
printk(KERN_DEBUG "%s: <-wavelan_open()\n", dev->name);
|
4451 |
|
|
#endif
|
4452 |
|
|
return 0;
|
4453 |
|
|
}
|
4454 |
|
|
|
4455 |
|
|
/*------------------------------------------------------------------*/
|
4456 |
|
|
/*
|
4457 |
|
|
* Shutdown the WaveLAN PCMCIA adaptor.
|
4458 |
|
|
* Called by NET3 when it "close" the device.
|
4459 |
|
|
*/
|
4460 |
|
|
static int
|
4461 |
|
|
wavelan_close(struct net_device * dev)
|
4462 |
|
|
{
|
4463 |
|
|
struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link;
|
4464 |
|
|
kio_addr_t base = dev->base_addr;
|
4465 |
|
|
|
4466 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4467 |
|
|
printk(KERN_DEBUG "%s: ->wavelan_close(dev=0x%x)\n", dev->name,
|
4468 |
|
|
(unsigned int) dev);
|
4469 |
|
|
#endif
|
4470 |
|
|
|
4471 |
|
|
/* If the device isn't open, then nothing to do */
|
4472 |
|
|
if(!link->open)
|
4473 |
|
|
{
|
4474 |
|
|
#ifdef DEBUG_CONFIG_INFO
|
4475 |
|
|
printk(KERN_DEBUG "%s: wavelan_close(): device not open\n", dev->name);
|
4476 |
|
|
#endif
|
4477 |
|
|
return 0;
|
4478 |
|
|
}
|
4479 |
|
|
|
4480 |
|
|
#ifdef WAVELAN_ROAMING
|
4481 |
|
|
/* Cleanup of roaming stuff... */
|
4482 |
|
|
if(do_roaming)
|
4483 |
|
|
wv_roam_cleanup(dev);
|
4484 |
|
|
#endif /* WAVELAN_ROAMING */
|
4485 |
|
|
|
4486 |
|
|
link->open--;
|
4487 |
|
|
|
4488 |
|
|
/* If the card is still present */
|
4489 |
|
|
if(netif_running(dev))
|
4490 |
|
|
{
|
4491 |
|
|
netif_stop_queue(dev);
|
4492 |
|
|
|
4493 |
|
|
/* Stop receiving new messages and wait end of transmission */
|
4494 |
|
|
wv_ru_stop(dev);
|
4495 |
|
|
|
4496 |
|
|
/* Power down the module */
|
4497 |
|
|
hacr_write(base, HACR_DEFAULT & (~HACR_PWR_STAT));
|
4498 |
|
|
}
|
4499 |
|
|
|
4500 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4501 |
|
|
printk(KERN_DEBUG "%s: <-wavelan_close()\n", dev->name);
|
4502 |
|
|
#endif
|
4503 |
|
|
return 0;
|
4504 |
|
|
}
|
4505 |
|
|
|
4506 |
|
|
/*------------------------------------------------------------------*/
|
4507 |
|
|
/*
|
4508 |
|
|
* wavelan_attach() creates an "instance" of the driver, allocating
|
4509 |
|
|
* local data structures for one device (one interface). The device
|
4510 |
|
|
* is registered with Card Services.
|
4511 |
|
|
*
|
4512 |
|
|
* The dev_link structure is initialized, but we don't actually
|
4513 |
|
|
* configure the card at this point -- we wait until we receive a
|
4514 |
|
|
* card insertion event.
|
4515 |
|
|
*/
|
4516 |
|
|
static int
|
4517 |
|
|
wavelan_probe(struct pcmcia_device *p_dev)
|
4518 |
|
|
{
|
4519 |
|
|
struct net_device * dev; /* Interface generic data */
|
4520 |
|
|
net_local * lp; /* Interface specific data */
|
4521 |
|
|
int ret;
|
4522 |
|
|
|
4523 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4524 |
|
|
printk(KERN_DEBUG "-> wavelan_attach()\n");
|
4525 |
|
|
#endif
|
4526 |
|
|
|
4527 |
|
|
/* The io structure describes IO port mapping */
|
4528 |
|
|
p_dev->io.NumPorts1 = 8;
|
4529 |
|
|
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
|
4530 |
|
|
p_dev->io.IOAddrLines = 3;
|
4531 |
|
|
|
4532 |
|
|
/* Interrupt setup */
|
4533 |
|
|
p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
|
4534 |
|
|
p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
|
4535 |
|
|
p_dev->irq.Handler = wavelan_interrupt;
|
4536 |
|
|
|
4537 |
|
|
/* General socket configuration */
|
4538 |
|
|
p_dev->conf.Attributes = CONF_ENABLE_IRQ;
|
4539 |
|
|
p_dev->conf.IntType = INT_MEMORY_AND_IO;
|
4540 |
|
|
|
4541 |
|
|
/* Allocate the generic data structure */
|
4542 |
|
|
dev = alloc_etherdev(sizeof(net_local));
|
4543 |
|
|
if (!dev)
|
4544 |
|
|
return -ENOMEM;
|
4545 |
|
|
|
4546 |
|
|
p_dev->priv = p_dev->irq.Instance = dev;
|
4547 |
|
|
|
4548 |
|
|
lp = netdev_priv(dev);
|
4549 |
|
|
|
4550 |
|
|
/* Init specific data */
|
4551 |
|
|
lp->configured = 0;
|
4552 |
|
|
lp->reconfig_82593 = FALSE;
|
4553 |
|
|
lp->nresets = 0;
|
4554 |
|
|
/* Multicast stuff */
|
4555 |
|
|
lp->promiscuous = 0;
|
4556 |
|
|
lp->allmulticast = 0;
|
4557 |
|
|
lp->mc_count = 0;
|
4558 |
|
|
|
4559 |
|
|
/* Init spinlock */
|
4560 |
|
|
spin_lock_init(&lp->spinlock);
|
4561 |
|
|
|
4562 |
|
|
/* back links */
|
4563 |
|
|
lp->dev = dev;
|
4564 |
|
|
|
4565 |
|
|
/* wavelan NET3 callbacks */
|
4566 |
|
|
dev->open = &wavelan_open;
|
4567 |
|
|
dev->stop = &wavelan_close;
|
4568 |
|
|
dev->hard_start_xmit = &wavelan_packet_xmit;
|
4569 |
|
|
dev->get_stats = &wavelan_get_stats;
|
4570 |
|
|
dev->set_multicast_list = &wavelan_set_multicast_list;
|
4571 |
|
|
#ifdef SET_MAC_ADDRESS
|
4572 |
|
|
dev->set_mac_address = &wavelan_set_mac_address;
|
4573 |
|
|
#endif /* SET_MAC_ADDRESS */
|
4574 |
|
|
|
4575 |
|
|
/* Set the watchdog timer */
|
4576 |
|
|
dev->tx_timeout = &wavelan_watchdog;
|
4577 |
|
|
dev->watchdog_timeo = WATCHDOG_JIFFIES;
|
4578 |
|
|
SET_ETHTOOL_OPS(dev, &ops);
|
4579 |
|
|
|
4580 |
|
|
dev->wireless_handlers = &wavelan_handler_def;
|
4581 |
|
|
lp->wireless_data.spy_data = &lp->spy_data;
|
4582 |
|
|
dev->wireless_data = &lp->wireless_data;
|
4583 |
|
|
|
4584 |
|
|
/* Other specific data */
|
4585 |
|
|
dev->mtu = WAVELAN_MTU;
|
4586 |
|
|
|
4587 |
|
|
ret = wv_pcmcia_config(p_dev);
|
4588 |
|
|
if (ret)
|
4589 |
|
|
return ret;
|
4590 |
|
|
|
4591 |
|
|
ret = wv_hw_config(dev);
|
4592 |
|
|
if (ret) {
|
4593 |
|
|
dev->irq = 0;
|
4594 |
|
|
pcmcia_disable_device(p_dev);
|
4595 |
|
|
return ret;
|
4596 |
|
|
}
|
4597 |
|
|
|
4598 |
|
|
wv_init_info(dev);
|
4599 |
|
|
|
4600 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4601 |
|
|
printk(KERN_DEBUG "<- wavelan_attach()\n");
|
4602 |
|
|
#endif
|
4603 |
|
|
|
4604 |
|
|
return 0;
|
4605 |
|
|
}
|
4606 |
|
|
|
4607 |
|
|
/*------------------------------------------------------------------*/
|
4608 |
|
|
/*
|
4609 |
|
|
* This deletes a driver "instance". The device is de-registered with
|
4610 |
|
|
* Card Services. If it has been released, all local data structures
|
4611 |
|
|
* are freed. Otherwise, the structures will be freed when the device
|
4612 |
|
|
* is released.
|
4613 |
|
|
*/
|
4614 |
|
|
static void
|
4615 |
|
|
wavelan_detach(struct pcmcia_device *link)
|
4616 |
|
|
{
|
4617 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4618 |
|
|
printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link);
|
4619 |
|
|
#endif
|
4620 |
|
|
|
4621 |
|
|
/* Some others haven't done their job : give them another chance */
|
4622 |
|
|
wv_pcmcia_release(link);
|
4623 |
|
|
|
4624 |
|
|
/* Free pieces */
|
4625 |
|
|
if(link->priv)
|
4626 |
|
|
{
|
4627 |
|
|
struct net_device * dev = (struct net_device *) link->priv;
|
4628 |
|
|
|
4629 |
|
|
/* Remove ourselves from the kernel list of ethernet devices */
|
4630 |
|
|
/* Warning : can't be called from interrupt, timer or wavelan_close() */
|
4631 |
|
|
if (link->dev_node)
|
4632 |
|
|
unregister_netdev(dev);
|
4633 |
|
|
link->dev_node = NULL;
|
4634 |
|
|
((net_local *)netdev_priv(dev))->link = NULL;
|
4635 |
|
|
((net_local *)netdev_priv(dev))->dev = NULL;
|
4636 |
|
|
free_netdev(dev);
|
4637 |
|
|
}
|
4638 |
|
|
|
4639 |
|
|
#ifdef DEBUG_CALLBACK_TRACE
|
4640 |
|
|
printk(KERN_DEBUG "<- wavelan_detach()\n");
|
4641 |
|
|
#endif
|
4642 |
|
|
}
|
4643 |
|
|
|
4644 |
|
|
static int wavelan_suspend(struct pcmcia_device *link)
|
4645 |
|
|
{
|
4646 |
|
|
struct net_device * dev = (struct net_device *) link->priv;
|
4647 |
|
|
|
4648 |
|
|
/* NB: wavelan_close will be called, but too late, so we are
|
4649 |
|
|
* obliged to close nicely the wavelan here. David, could you
|
4650 |
|
|
* close the device before suspending them ? And, by the way,
|
4651 |
|
|
* could you, on resume, add a "route add -net ..." after the
|
4652 |
|
|
* ifconfig up ? Thanks... */
|
4653 |
|
|
|
4654 |
|
|
/* Stop receiving new messages and wait end of transmission */
|
4655 |
|
|
wv_ru_stop(dev);
|
4656 |
|
|
|
4657 |
|
|
if (link->open)
|
4658 |
|
|
netif_device_detach(dev);
|
4659 |
|
|
|
4660 |
|
|
/* Power down the module */
|
4661 |
|
|
hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT));
|
4662 |
|
|
|
4663 |
|
|
return 0;
|
4664 |
|
|
}
|
4665 |
|
|
|
4666 |
|
|
static int wavelan_resume(struct pcmcia_device *link)
|
4667 |
|
|
{
|
4668 |
|
|
struct net_device * dev = (struct net_device *) link->priv;
|
4669 |
|
|
|
4670 |
|
|
if (link->open) {
|
4671 |
|
|
wv_hw_reset(dev);
|
4672 |
|
|
netif_device_attach(dev);
|
4673 |
|
|
}
|
4674 |
|
|
|
4675 |
|
|
return 0;
|
4676 |
|
|
}
|
4677 |
|
|
|
4678 |
|
|
|
4679 |
|
|
static struct pcmcia_device_id wavelan_ids[] = {
|
4680 |
|
|
PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975),
|
4681 |
|
|
PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06),
|
4682 |
|
|
PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/PCMCIA", 0x23eb9949, 0x1bc50975),
|
4683 |
|
|
PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/PCMCIA", 0x24358cd4, 0x1bc50975),
|
4684 |
|
|
PCMCIA_DEVICE_NULL,
|
4685 |
|
|
};
|
4686 |
|
|
MODULE_DEVICE_TABLE(pcmcia, wavelan_ids);
|
4687 |
|
|
|
4688 |
|
|
static struct pcmcia_driver wavelan_driver = {
|
4689 |
|
|
.owner = THIS_MODULE,
|
4690 |
|
|
.drv = {
|
4691 |
|
|
.name = "wavelan_cs",
|
4692 |
|
|
},
|
4693 |
|
|
.probe = wavelan_probe,
|
4694 |
|
|
.remove = wavelan_detach,
|
4695 |
|
|
.id_table = wavelan_ids,
|
4696 |
|
|
.suspend = wavelan_suspend,
|
4697 |
|
|
.resume = wavelan_resume,
|
4698 |
|
|
};
|
4699 |
|
|
|
4700 |
|
|
static int __init
|
4701 |
|
|
init_wavelan_cs(void)
|
4702 |
|
|
{
|
4703 |
|
|
return pcmcia_register_driver(&wavelan_driver);
|
4704 |
|
|
}
|
4705 |
|
|
|
4706 |
|
|
static void __exit
|
4707 |
|
|
exit_wavelan_cs(void)
|
4708 |
|
|
{
|
4709 |
|
|
pcmcia_unregister_driver(&wavelan_driver);
|
4710 |
|
|
}
|
4711 |
|
|
|
4712 |
|
|
module_init(init_wavelan_cs);
|
4713 |
|
|
module_exit(exit_wavelan_cs);
|