Blame view
drivers/net/3c527.c
42.1 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 |
/* 3c527.c: 3Com Etherlink/MC32 driver for Linux 2.4 and 2.6. * * (c) Copyright 1998 Red Hat Software Inc |
6aa20a223 drivers/net: Trim... |
4 |
* Written by Alan Cox. |
1da177e4c Linux-2.6.12-rc2 |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
* Further debugging by Carl Drougge. * Initial SMP support by Felipe W Damasio <felipewd@terra.com.br> * Heavily modified by Richard Procter <rnp@paradise.net.nz> * * Based on skeleton.c written 1993-94 by Donald Becker and ne2.c * (for the MCA stuff) written by Wim Dumon. * * Thanks to 3Com for making this possible by providing me with the * documentation. * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #define DRV_NAME "3c527" #define DRV_VERSION "0.7-SMP" #define DRV_RELDATE "2003/09/21" static const char *version = DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Procter <rnp@paradise.net.nz> "; /** * DOC: Traps for the unwary * * The diagram (Figure 1-1) and the POS summary disagree with the * "Interrupt Level" section in the manual. * |
6aa20a223 drivers/net: Trim... |
34 35 36 |
* The manual contradicts itself when describing the minimum number * buffers in the 'configure lists' command. * My card accepts a buffer config of 4/4. |
1da177e4c Linux-2.6.12-rc2 |
37 38 |
* * Setting the SAV BP bit does not save bad packets, but |
6aa20a223 drivers/net: Trim... |
39 |
* only enables RX on-card stats collection. |
1da177e4c Linux-2.6.12-rc2 |
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
* * The documentation in places seems to miss things. In actual fact * I've always eventually found everything is documented, it just * requires careful study. * * DOC: Theory Of Operation * * The 3com 3c527 is a 32bit MCA bus mastering adapter with a large * amount of on board intelligence that housekeeps a somewhat dumber * Intel NIC. For performance we want to keep the transmit queue deep * as the card can transmit packets while fetching others from main * memory by bus master DMA. Transmission and reception are driven by * circular buffer queues. * * The mailboxes can be used for controlling how the card traverses |
25985edce Fix common misspe... |
55 |
* its buffer rings, but are used only for initial setup in this |
1da177e4c Linux-2.6.12-rc2 |
56 57 58 59 60 61 62 63 64 65 66 67 |
* implementation. The exec mailbox allows a variety of commands to * be executed. Each command must complete before the next is * executed. Primarily we use the exec mailbox for controlling the * multicast lists. We have to do a certain amount of interesting * hoop jumping as the multicast list changes can occur in interrupt * state when the card has an exec command pending. We defer such * events until the command completion interrupt. * * A copy break scheme (taken from 3c59x.c) is employed whereby * received frames exceeding a configurable length are passed * directly to the higher networking layers without incuring a copy, * in what amounts to a time/space trade-off. |
6aa20a223 drivers/net: Trim... |
68 |
* |
1da177e4c Linux-2.6.12-rc2 |
69 70 71 72 73 |
* The card also keeps a large amount of statistical information * on-board. In a perfect world, these could be used safely at no * cost. However, lacking information to the contrary, processing * them without races would involve so much extra complexity as to * make it unworthwhile to do so. In the end, a hybrid SW/HW |
6aa20a223 drivers/net: Trim... |
74 |
* implementation was made necessary --- see mc32_update_stats(). |
1da177e4c Linux-2.6.12-rc2 |
75 76 |
* * DOC: Notes |
6aa20a223 drivers/net: Trim... |
77 |
* |
1da177e4c Linux-2.6.12-rc2 |
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
* It should be possible to use two or more cards, but at this stage * only by loading two copies of the same module. * * The on-board 82586 NIC has trouble receiving multiple * back-to-back frames and so is likely to drop packets from fast * senders. **/ #include <linux/module.h> #include <linux/errno.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/if_ether.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/fcntl.h> #include <linux/interrupt.h> #include <linux/mca-legacy.h> #include <linux/ioport.h> #include <linux/in.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/wait.h> #include <linux/ethtool.h> #include <linux/completion.h> #include <linux/bitops.h> |
6188e10d3 Convert asm/semap... |
107 |
#include <linux/semaphore.h> |
1da177e4c Linux-2.6.12-rc2 |
108 |
|
1da177e4c Linux-2.6.12-rc2 |
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
#include <asm/uaccess.h> #include <asm/system.h> #include <asm/io.h> #include <asm/dma.h> #include "3c527.h" MODULE_LICENSE("GPL"); /* * The name of the card. Is used for messages and in the requests for * io regions, irqs and dma channels */ static const char* cardname = DRV_NAME; /* use 0 for production, 1 for verification, >2 for debug */ #ifndef NET_DEBUG #define NET_DEBUG 2 #endif |
1da177e4c Linux-2.6.12-rc2 |
128 129 130 131 |
static unsigned int mc32_debug = NET_DEBUG; /* The number of low I/O ports used by the ethercard. */ #define MC32_IO_EXTENT 8 |
6aa20a223 drivers/net: Trim... |
132 |
/* As implemented, values must be a power-of-2 -- 4/8/16/32 */ |
1da177e4c Linux-2.6.12-rc2 |
133 134 |
#define TX_RING_LEN 32 /* Typically the card supports 37 */ #define RX_RING_LEN 8 /* " " " */ |
6aa20a223 drivers/net: Trim... |
135 136 |
/* Copy break point, see above for details. * Setting to > 1512 effectively disables this feature. */ |
1da177e4c Linux-2.6.12-rc2 |
137 138 139 |
#define RX_COPYBREAK 200 /* Value from 3c59x.c */ /* Issue the 82586 workaround command - this is for "busy lans", but |
6aa20a223 drivers/net: Trim... |
140 141 |
* basically means for all lans now days - has a performance (latency) * cost, but best set. */ |
1da177e4c Linux-2.6.12-rc2 |
142 143 144 |
static const int WORKAROUND_82586=1; /* Pointers to buffers and their on-card records */ |
6aa20a223 drivers/net: Trim... |
145 |
struct mc32_ring_desc |
1da177e4c Linux-2.6.12-rc2 |
146 |
{ |
6aa20a223 drivers/net: Trim... |
147 148 |
volatile struct skb_header *p; struct sk_buff *skb; |
1da177e4c Linux-2.6.12-rc2 |
149 150 151 |
}; /* Information that needs to be kept for each board. */ |
6aa20a223 drivers/net: Trim... |
152 |
struct mc32_local |
1da177e4c Linux-2.6.12-rc2 |
153 154 155 156 |
{ int slot; u32 base; |
1da177e4c Linux-2.6.12-rc2 |
157 158 159 160 161 162 |
volatile struct mc32_mailbox *rx_box; volatile struct mc32_mailbox *tx_box; volatile struct mc32_mailbox *exec_box; volatile struct mc32_stats *stats; /* Start of on-card statistics */ u16 tx_chain; /* Transmit list start offset */ u16 rx_chain; /* Receive list start offset */ |
6aa20a223 drivers/net: Trim... |
163 |
u16 tx_len; /* Transmit list count */ |
1da177e4c Linux-2.6.12-rc2 |
164 165 166 167 168 169 170 171 172 173 174 175 176 |
u16 rx_len; /* Receive list count */ u16 xceiver_desired_state; /* HALTED or RUNNING */ u16 cmd_nonblocking; /* Thread is uninterested in command result */ u16 mc_reload_wait; /* A multicast load request is pending */ u32 mc_list_valid; /* True when the mclist is set */ struct mc32_ring_desc tx_ring[TX_RING_LEN]; /* Host Transmit ring */ struct mc32_ring_desc rx_ring[RX_RING_LEN]; /* Host Receive ring */ atomic_t tx_count; /* buffers left */ atomic_t tx_ring_head; /* index to tx en-queue end */ u16 tx_ring_tail; /* index to tx de-queue end */ |
6aa20a223 drivers/net: Trim... |
177 |
u16 rx_ring_tail; /* index to rx de-queue end */ |
1da177e4c Linux-2.6.12-rc2 |
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
struct semaphore cmd_mutex; /* Serialises issuing of execute commands */ struct completion execution_cmd; /* Card has completed an execute command */ struct completion xceiver_cmd; /* Card has completed a tx or rx command */ }; /* The station (ethernet) address prefix, used for a sanity check. */ #define SA_ADDR0 0x02 #define SA_ADDR1 0x60 #define SA_ADDR2 0xAC struct mca_adapters_t { unsigned int id; char *name; }; static const struct mca_adapters_t mc32_adapters[] = { { 0x0041, "3COM EtherLink MC/32" }, { 0x8EF5, "IBM High Performance Lan Adapter" }, { 0x0000, NULL } }; |
6aa20a223 drivers/net: Trim... |
199 |
/* Macros for ring index manipulations */ |
1da177e4c Linux-2.6.12-rc2 |
200 201 202 203 204 205 206 207 208 209 210 |
static inline u16 next_rx(u16 rx) { return (rx+1)&(RX_RING_LEN-1); }; static inline u16 prev_rx(u16 rx) { return (rx-1)&(RX_RING_LEN-1); }; static inline u16 next_tx(u16 tx) { return (tx+1)&(TX_RING_LEN-1); }; /* Index to functions, as function prototypes. */ static int mc32_probe1(struct net_device *dev, int ioaddr); static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len); static int mc32_open(struct net_device *dev); static void mc32_timeout(struct net_device *dev); |
27a1de95a 3com: convert dri... |
211 212 |
static netdev_tx_t mc32_send_packet(struct sk_buff *skb, struct net_device *dev); |
7d12e780e IRQ: Maintain reg... |
213 |
static irqreturn_t mc32_interrupt(int irq, void *dev_id); |
1da177e4c Linux-2.6.12-rc2 |
214 215 216 217 |
static int mc32_close(struct net_device *dev); static struct net_device_stats *mc32_get_stats(struct net_device *dev); static void mc32_set_multicast_list(struct net_device *dev); static void mc32_reset_multicast_list(struct net_device *dev); |
7282d491e drivers/net: cons... |
218 |
static const struct ethtool_ops netdev_ethtool_ops; |
1da177e4c Linux-2.6.12-rc2 |
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
static void cleanup_card(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); unsigned slot = lp->slot; mca_mark_as_unused(slot); mca_set_adapter_name(slot, NULL); free_irq(dev->irq, dev); release_region(dev->base_addr, MC32_IO_EXTENT); } /** * mc32_probe - Search for supported boards * @unit: interface number to use * * Because MCA bus is a real bus and we can scan for cards we could do a * single scan for all boards here. Right now we use the passed in device * structure and scan for only one board. This needs fixing for modules * in particular. */ struct net_device *__init mc32_probe(int unit) { struct net_device *dev = alloc_etherdev(sizeof(struct mc32_local)); static int current_mca_slot = -1; int i; int err; if (!dev) return ERR_PTR(-ENOMEM); if (unit >= 0) sprintf(dev->name, "eth%d", unit); |
6aa20a223 drivers/net: Trim... |
252 |
/* Do not check any supplied i/o locations. |
1da177e4c Linux-2.6.12-rc2 |
253 |
POS registers usually don't fail :) */ |
6aa20a223 drivers/net: Trim... |
254 255 |
/* MCA cards have POS registers. Autodetecting MCA cards is extremely simple. |
1da177e4c Linux-2.6.12-rc2 |
256 257 258 |
Just search for the card. */ for(i = 0; (mc32_adapters[i].name != NULL); i++) { |
6aa20a223 drivers/net: Trim... |
259 |
current_mca_slot = |
1da177e4c Linux-2.6.12-rc2 |
260 261 262 263 264 |
mca_find_unused_adapter(mc32_adapters[i].id, 0); if(current_mca_slot != MCA_NOTFOUND) { if(!mc32_probe1(dev, current_mca_slot)) { |
6aa20a223 drivers/net: Trim... |
265 |
mca_set_adapter_name(current_mca_slot, |
1da177e4c Linux-2.6.12-rc2 |
266 267 268 269 270 271 272 273 274 275 |
mc32_adapters[i].name); mca_mark_as_used(current_mca_slot); err = register_netdev(dev); if (err) { cleanup_card(dev); free_netdev(dev); dev = ERR_PTR(err); } return dev; } |
6aa20a223 drivers/net: Trim... |
276 |
|
1da177e4c Linux-2.6.12-rc2 |
277 278 279 280 281 |
} } free_netdev(dev); return ERR_PTR(-ENODEV); } |
4394e6533 3c527: convert to... |
282 283 284 285 286 287 288 289 290 291 292 |
static const struct net_device_ops netdev_ops = { .ndo_open = mc32_open, .ndo_stop = mc32_close, .ndo_start_xmit = mc32_send_packet, .ndo_get_stats = mc32_get_stats, .ndo_set_multicast_list = mc32_set_multicast_list, .ndo_tx_timeout = mc32_timeout, .ndo_change_mtu = eth_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; |
1da177e4c Linux-2.6.12-rc2 |
293 294 295 296 297 298 299 |
/** * mc32_probe1 - Check a given slot for a board and test the card * @dev: Device structure to fill in * @slot: The MCA bus slot being used by this card * * Decode the slot data and configure the card structures. Having done this we * can reset the card and configure it. The card does a full self test cycle |
6aa20a223 drivers/net: Trim... |
300 |
* in firmware so we have to wait for it to return and post us either a |
1da177e4c Linux-2.6.12-rc2 |
301 302 303 304 305 306 307 308 309 310 |
* failure case or some addresses we use to find the board internals. */ static int __init mc32_probe1(struct net_device *dev, int slot) { static unsigned version_printed; int i, err; u8 POS; u32 base; struct mc32_local *lp = netdev_priv(dev); |
b6bc76506 drivers/net/*.c: ... |
311 |
static const u16 mca_io_bases[] = { |
1da177e4c Linux-2.6.12-rc2 |
312 313 314 315 316 |
0x7280,0x7290, 0x7680,0x7690, 0x7A80,0x7A90, 0x7E80,0x7E90 }; |
b6bc76506 drivers/net/*.c: ... |
317 |
static const u32 mca_mem_bases[] = { |
1da177e4c Linux-2.6.12-rc2 |
318 319 320 321 322 323 324 325 326 |
0x00C0000, 0x00C4000, 0x00C8000, 0x00CC000, 0x00D0000, 0x00D4000, 0x00D8000, 0x00DC000 }; |
b6bc76506 drivers/net/*.c: ... |
327 |
static const char * const failures[] = { |
1da177e4c Linux-2.6.12-rc2 |
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
"Processor instruction", "Processor data bus", "Processor data bus", "Processor data bus", "Adapter bus", "ROM checksum", "Base RAM", "Extended RAM", "82586 internal loopback", "82586 initialisation failure", "Adapter list configuration error" }; /* Time to play MCA games */ if (mc32_debug && version_printed++ == 0) |
39738e161 3c5xx: convert pr... |
344 |
pr_debug("%s", version); |
1da177e4c Linux-2.6.12-rc2 |
345 |
|
39738e161 3c5xx: convert pr... |
346 |
pr_info("%s: %s found in slot %d: ", dev->name, cardname, slot); |
1da177e4c Linux-2.6.12-rc2 |
347 348 |
POS = mca_read_stored_pos(slot, 2); |
6aa20a223 drivers/net: Trim... |
349 |
|
1da177e4c Linux-2.6.12-rc2 |
350 351 |
if(!(POS&1)) { |
39738e161 3c5xx: convert pr... |
352 353 |
pr_cont("disabled. "); |
1da177e4c Linux-2.6.12-rc2 |
354 355 356 357 358 359 |
return -ENODEV; } /* Fill in the 'dev' fields. */ dev->base_addr = mca_io_bases[(POS>>1)&7]; dev->mem_start = mca_mem_bases[(POS>>4)&7]; |
6aa20a223 drivers/net: Trim... |
360 |
|
1da177e4c Linux-2.6.12-rc2 |
361 362 363 |
POS = mca_read_stored_pos(slot, 4); if(!(POS&1)) { |
39738e161 3c5xx: convert pr... |
364 365 |
pr_cont("memory window disabled. "); |
1da177e4c Linux-2.6.12-rc2 |
366 367 368 369 |
return -ENODEV; } POS = mca_read_stored_pos(slot, 5); |
6aa20a223 drivers/net: Trim... |
370 |
|
1da177e4c Linux-2.6.12-rc2 |
371 372 373 |
i=(POS>>4)&3; if(i==3) { |
39738e161 3c5xx: convert pr... |
374 375 |
pr_cont("invalid memory window. "); |
1da177e4c Linux-2.6.12-rc2 |
376 377 |
return -ENODEV; } |
6aa20a223 drivers/net: Trim... |
378 |
|
1da177e4c Linux-2.6.12-rc2 |
379 380 |
i*=16384; i+=16384; |
6aa20a223 drivers/net: Trim... |
381 |
|
1da177e4c Linux-2.6.12-rc2 |
382 |
dev->mem_end=dev->mem_start + i; |
6aa20a223 drivers/net: Trim... |
383 |
|
1da177e4c Linux-2.6.12-rc2 |
384 |
dev->irq = ((POS>>2)&3)+9; |
6aa20a223 drivers/net: Trim... |
385 |
|
1da177e4c Linux-2.6.12-rc2 |
386 387 |
if(!request_region(dev->base_addr, MC32_IO_EXTENT, cardname)) { |
39738e161 3c5xx: convert pr... |
388 389 |
pr_cont("io 0x%3lX, which is busy. ", dev->base_addr); |
1da177e4c Linux-2.6.12-rc2 |
390 391 |
return -EBUSY; } |
39738e161 3c5xx: convert pr... |
392 393 |
pr_cont("io 0x%3lX irq %d mem 0x%lX (%dK) ", |
1da177e4c Linux-2.6.12-rc2 |
394 |
dev->base_addr, dev->irq, dev->mem_start, i/1024); |
6aa20a223 drivers/net: Trim... |
395 |
|
1da177e4c Linux-2.6.12-rc2 |
396 |
/* We ought to set the cache line size here.. */ |
6aa20a223 drivers/net: Trim... |
397 |
|
1da177e4c Linux-2.6.12-rc2 |
398 399 400 |
/* * Go PROM browsing */ |
6aa20a223 drivers/net: Trim... |
401 |
|
1da177e4c Linux-2.6.12-rc2 |
402 403 404 405 406 |
/* Retrieve and print the ethernet address. */ for (i = 0; i < 6; i++) { mca_write_pos(slot, 6, i+12); mca_write_pos(slot, 7, 0); |
6aa20a223 drivers/net: Trim... |
407 |
|
0795af572 [NET]: Introduce ... |
408 |
dev->dev_addr[i] = mca_read_pos(slot,3); |
1da177e4c Linux-2.6.12-rc2 |
409 |
} |
39738e161 3c5xx: convert pr... |
410 |
pr_info("%s: Address %pM ", dev->name, dev->dev_addr); |
0795af572 [NET]: Introduce ... |
411 |
|
1da177e4c Linux-2.6.12-rc2 |
412 413 414 415 |
mca_write_pos(slot, 6, 0); mca_write_pos(slot, 7, 0); POS = mca_read_stored_pos(slot, 4); |
6aa20a223 drivers/net: Trim... |
416 |
|
1da177e4c Linux-2.6.12-rc2 |
417 |
if(POS&2) |
39738e161 3c5xx: convert pr... |
418 419 |
pr_cont(": BNC port selected. "); |
6aa20a223 drivers/net: Trim... |
420 |
else |
39738e161 3c5xx: convert pr... |
421 422 |
pr_cont(": AUI port selected. "); |
6aa20a223 drivers/net: Trim... |
423 |
|
1da177e4c Linux-2.6.12-rc2 |
424 425 426 427 428 429 430 431 432 |
POS=inb(dev->base_addr+HOST_CTRL); POS|=HOST_CTRL_ATTN|HOST_CTRL_RESET; POS&=~HOST_CTRL_INTE; outb(POS, dev->base_addr+HOST_CTRL); /* Reset adapter */ udelay(100); /* Reset off */ POS&=~(HOST_CTRL_ATTN|HOST_CTRL_RESET); outb(POS, dev->base_addr+HOST_CTRL); |
6aa20a223 drivers/net: Trim... |
433 |
|
1da177e4c Linux-2.6.12-rc2 |
434 |
udelay(300); |
6aa20a223 drivers/net: Trim... |
435 |
|
1da177e4c Linux-2.6.12-rc2 |
436 437 438 |
/* * Grab the IRQ */ |
5d6076bb2 3c52x: remove IRQ... |
439 |
err = request_irq(dev->irq, mc32_interrupt, IRQF_SHARED, DRV_NAME, dev); |
1da177e4c Linux-2.6.12-rc2 |
440 441 |
if (err) { release_region(dev->base_addr, MC32_IO_EXTENT); |
39738e161 3c5xx: convert pr... |
442 443 |
pr_err("%s: unable to get IRQ %d. ", DRV_NAME, dev->irq); |
1da177e4c Linux-2.6.12-rc2 |
444 445 446 447 448 449 450 451 452 |
goto err_exit_ports; } memset(lp, 0, sizeof(struct mc32_local)); lp->slot = slot; i=0; base = inb(dev->base_addr); |
6aa20a223 drivers/net: Trim... |
453 |
|
1da177e4c Linux-2.6.12-rc2 |
454 455 456 457 458 |
while(base == 0xFF) { i++; if(i == 1000) { |
39738e161 3c5xx: convert pr... |
459 460 |
pr_err("%s: failed to boot adapter. ", dev->name); |
6aa20a223 drivers/net: Trim... |
461 |
err = -ENODEV; |
1da177e4c Linux-2.6.12-rc2 |
462 463 464 465 466 467 468 469 470 471 |
goto err_exit_irq; } udelay(1000); if(inb(dev->base_addr+2)&(1<<5)) base = inb(dev->base_addr); } if(base>0) { if(base < 0x0C) |
39738e161 3c5xx: convert pr... |
472 473 |
pr_err("%s: %s%s. ", dev->name, failures[base-1], |
1da177e4c Linux-2.6.12-rc2 |
474 475 |
base<0x0A?" test failure":""); else |
39738e161 3c5xx: convert pr... |
476 477 |
pr_err("%s: unknown failure %d. ", dev->name, base); |
6aa20a223 drivers/net: Trim... |
478 |
err = -ENODEV; |
1da177e4c Linux-2.6.12-rc2 |
479 480 |
goto err_exit_irq; } |
6aa20a223 drivers/net: Trim... |
481 |
|
1da177e4c Linux-2.6.12-rc2 |
482 483 484 485 |
base=0; for(i=0;i<4;i++) { int n=0; |
6aa20a223 drivers/net: Trim... |
486 |
|
1da177e4c Linux-2.6.12-rc2 |
487 488 489 490 491 492 |
while(!(inb(dev->base_addr+2)&(1<<5))) { n++; udelay(50); if(n>100) { |
39738e161 3c5xx: convert pr... |
493 494 |
pr_err("%s: mailbox read fail (%d). ", dev->name, i); |
1da177e4c Linux-2.6.12-rc2 |
495 496 497 498 499 500 501 |
err = -ENODEV; goto err_exit_irq; } } base|=(inb(dev->base_addr)<<(8*i)); } |
6aa20a223 drivers/net: Trim... |
502 |
|
1da177e4c Linux-2.6.12-rc2 |
503 |
lp->exec_box=isa_bus_to_virt(dev->mem_start+base); |
6aa20a223 drivers/net: Trim... |
504 505 |
base=lp->exec_box->data[1]<<16|lp->exec_box->data[0]; |
1da177e4c Linux-2.6.12-rc2 |
506 |
lp->base = dev->mem_start+base; |
6aa20a223 drivers/net: Trim... |
507 508 |
lp->rx_box=isa_bus_to_virt(lp->base + lp->exec_box->data[2]); |
1da177e4c Linux-2.6.12-rc2 |
509 |
lp->tx_box=isa_bus_to_virt(lp->base + lp->exec_box->data[3]); |
6aa20a223 drivers/net: Trim... |
510 |
|
1da177e4c Linux-2.6.12-rc2 |
511 512 513 514 515 |
lp->stats = isa_bus_to_virt(lp->base + lp->exec_box->data[5]); /* * Descriptor chains (card relative) */ |
6aa20a223 drivers/net: Trim... |
516 |
|
1da177e4c Linux-2.6.12-rc2 |
517 518 |
lp->tx_chain = lp->exec_box->data[8]; /* Transmit list start offset */ lp->rx_chain = lp->exec_box->data[10]; /* Receive list start offset */ |
6aa20a223 drivers/net: Trim... |
519 |
lp->tx_len = lp->exec_box->data[9]; /* Transmit list count */ |
1da177e4c Linux-2.6.12-rc2 |
520 |
lp->rx_len = lp->exec_box->data[11]; /* Receive list count */ |
50948ee81 net: 3c527: semap... |
521 |
sema_init(&lp->cmd_mutex, 0); |
1da177e4c Linux-2.6.12-rc2 |
522 523 |
init_completion(&lp->execution_cmd); init_completion(&lp->xceiver_cmd); |
6aa20a223 drivers/net: Trim... |
524 |
|
39738e161 3c5xx: convert pr... |
525 526 |
pr_info("%s: Firmware Rev %d. %d RX buffers, %d TX buffers. Base of 0x%08X. ", |
1da177e4c Linux-2.6.12-rc2 |
527 |
dev->name, lp->exec_box->data[12], lp->rx_len, lp->tx_len, lp->base); |
4394e6533 3c527: convert to... |
528 |
dev->netdev_ops = &netdev_ops; |
1da177e4c Linux-2.6.12-rc2 |
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
dev->watchdog_timeo = HZ*5; /* Board does all the work */ dev->ethtool_ops = &netdev_ethtool_ops; return 0; err_exit_irq: free_irq(dev->irq, dev); err_exit_ports: release_region(dev->base_addr, MC32_IO_EXTENT); return err; } /** * mc32_ready_poll - wait until we can feed it a command * @dev: The device to wait for |
6aa20a223 drivers/net: Trim... |
545 |
* |
1da177e4c Linux-2.6.12-rc2 |
546 547 548 549 |
* Wait until the card becomes ready to accept a command via the * command register. This tells us nothing about the completion * status of any pending commands and takes very little time at all. */ |
6aa20a223 drivers/net: Trim... |
550 |
|
1da177e4c Linux-2.6.12-rc2 |
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
static inline void mc32_ready_poll(struct net_device *dev) { int ioaddr = dev->base_addr; while(!(inb(ioaddr+HOST_STATUS)&HOST_STATUS_CRR)); } /** * mc32_command_nowait - send a command non blocking * @dev: The 3c527 to issue the command to * @cmd: The command word to write to the mailbox * @data: A data block if the command expects one * @len: Length of the data block * * Send a command from interrupt state. If there is a command * currently being executed then we return an error of -1. It * simply isn't viable to wait around as commands may be * slow. This can theoretically be starved on SMP, but it's hard * to see a realistic situation. We do not wait for the command * to complete --- we rely on the interrupt handler to tidy up * after us. */ static int mc32_command_nowait(struct net_device *dev, u16 cmd, void *data, int len) { struct mc32_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; int ret = -1; if (down_trylock(&lp->cmd_mutex) == 0) { lp->cmd_nonblocking=1; lp->exec_box->mbox=0; lp->exec_box->mbox=cmd; memcpy((void *)lp->exec_box->data, data, len); barrier(); /* the memcpy forgot the volatile so be sure */ /* Send the command */ mc32_ready_poll(dev); outb(1<<6, ioaddr+HOST_CMD); ret = 0; /* Interrupt handler will signal mutex on completion */ } return ret; } /** * mc32_command - send a command and sleep until completion * @dev: The 3c527 card to issue the command to * @cmd: The command word to write to the mailbox * @data: A data block if the command expects one * @len: Length of the data block * * Sends exec commands in a user context. This permits us to wait around * for the replies and also to wait for the command buffer to complete |
6aa20a223 drivers/net: Trim... |
610 |
* from a previous command before we execute our command. After our |
1da177e4c Linux-2.6.12-rc2 |
611 612 613 |
* command completes we will attempt any pending multicast reload * we blocked off by hogging the exec buffer. * |
6aa20a223 drivers/net: Trim... |
614 |
* You feed the card a command, you wait, it interrupts you get a |
1da177e4c Linux-2.6.12-rc2 |
615 616 617 618 |
* reply. All well and good. The complication arises because you use * commands for filter list changes which come in at bh level from things * like IPV6 group stuff. */ |
6aa20a223 drivers/net: Trim... |
619 |
|
1da177e4c Linux-2.6.12-rc2 |
620 621 622 623 624 |
static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len) { struct mc32_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; int ret = 0; |
6aa20a223 drivers/net: Trim... |
625 |
|
1da177e4c Linux-2.6.12-rc2 |
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
down(&lp->cmd_mutex); /* * My Turn */ lp->cmd_nonblocking=0; lp->exec_box->mbox=0; lp->exec_box->mbox=cmd; memcpy((void *)lp->exec_box->data, data, len); barrier(); /* the memcpy forgot the volatile so be sure */ mc32_ready_poll(dev); outb(1<<6, ioaddr+HOST_CMD); wait_for_completion(&lp->execution_cmd); |
6aa20a223 drivers/net: Trim... |
642 |
|
1da177e4c Linux-2.6.12-rc2 |
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
if(lp->exec_box->mbox&(1<<13)) ret = -1; up(&lp->cmd_mutex); /* * A multicast set got blocked - try it now */ if(lp->mc_reload_wait) { mc32_reset_multicast_list(dev); } return ret; } /** * mc32_start_transceiver - tell board to restart tx/rx * @dev: The 3c527 card to issue the command to * * This may be called from the interrupt state, where it is used |
6aa20a223 drivers/net: Trim... |
666 667 |
* to restart the rx ring if the card runs out of rx buffers. * |
1da177e4c Linux-2.6.12-rc2 |
668 669 670 671 672 673 674 675 |
* We must first check if it's ok to (re)start the transceiver. See * mc32_close for details. */ static void mc32_start_transceiver(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; |
6aa20a223 drivers/net: Trim... |
676 |
/* Ignore RX overflow on device closure */ |
1da177e4c Linux-2.6.12-rc2 |
677 |
if (lp->xceiver_desired_state==HALTED) |
6aa20a223 drivers/net: Trim... |
678 |
return; |
1da177e4c Linux-2.6.12-rc2 |
679 680 |
/* Give the card the offset to the post-EOL-bit RX descriptor */ |
6aa20a223 drivers/net: Trim... |
681 |
mc32_ready_poll(dev); |
1da177e4c Linux-2.6.12-rc2 |
682 |
lp->rx_box->mbox=0; |
6aa20a223 drivers/net: Trim... |
683 684 |
lp->rx_box->data[0]=lp->rx_ring[prev_rx(lp->rx_ring_tail)].p->next; outb(HOST_CMD_START_RX, ioaddr+HOST_CMD); |
1da177e4c Linux-2.6.12-rc2 |
685 |
|
6aa20a223 drivers/net: Trim... |
686 |
mc32_ready_poll(dev); |
1da177e4c Linux-2.6.12-rc2 |
687 |
lp->tx_box->mbox=0; |
6aa20a223 drivers/net: Trim... |
688 689 690 |
outb(HOST_CMD_RESTRT_TX, ioaddr+HOST_CMD); /* card ignores this on RX restart */ /* We are not interrupted on start completion */ |
1da177e4c Linux-2.6.12-rc2 |
691 692 693 694 695 696 697 698 699 700 701 702 703 |
} /** * mc32_halt_transceiver - tell board to stop tx/rx * @dev: The 3c527 card to issue the command to * * We issue the commands to halt the card's transceiver. In fact, * after some experimenting we now simply tell the card to * suspend. When issuing aborts occasionally odd things happened. * * We then sleep until the card has notified us that both rx and * tx have been suspended. |
6aa20a223 drivers/net: Trim... |
704 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
705 |
|
6aa20a223 drivers/net: Trim... |
706 |
static void mc32_halt_transceiver(struct net_device *dev) |
1da177e4c Linux-2.6.12-rc2 |
707 708 709 |
{ struct mc32_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; |
6aa20a223 drivers/net: Trim... |
710 |
mc32_ready_poll(dev); |
1da177e4c Linux-2.6.12-rc2 |
711 |
lp->rx_box->mbox=0; |
6aa20a223 drivers/net: Trim... |
712 |
outb(HOST_CMD_SUSPND_RX, ioaddr+HOST_CMD); |
1da177e4c Linux-2.6.12-rc2 |
713 |
wait_for_completion(&lp->xceiver_cmd); |
6aa20a223 drivers/net: Trim... |
714 |
mc32_ready_poll(dev); |
1da177e4c Linux-2.6.12-rc2 |
715 |
lp->tx_box->mbox=0; |
6aa20a223 drivers/net: Trim... |
716 |
outb(HOST_CMD_SUSPND_TX, ioaddr+HOST_CMD); |
1da177e4c Linux-2.6.12-rc2 |
717 718 719 720 721 722 723 724 |
wait_for_completion(&lp->xceiver_cmd); } /** * mc32_load_rx_ring - load the ring of receive buffers * @dev: 3c527 to build the ring for * |
421f91d21 fix typos concern... |
725 |
* This initialises the on-card and driver datastructures to |
1da177e4c Linux-2.6.12-rc2 |
726 727 728 729 730 731 |
* the point where mc32_start_transceiver() can be called. * * The card sets up the receive ring for us. We are required to use the * ring it provides, although the size of the ring is configurable. * * We allocate an sk_buff for each ring entry in turn and |
421f91d21 fix typos concern... |
732 |
* initialise its house-keeping info. At the same time, we read |
1da177e4c Linux-2.6.12-rc2 |
733 734 735 736 737 738 739 |
* each 'next' pointer in our rx_ring array. This reduces slow * shared-memory reads and makes it easy to access predecessor * descriptors. * * We then set the end-of-list bit for the last entry so that the * card will know when it has run out of buffers. */ |
6aa20a223 drivers/net: Trim... |
740 |
|
1da177e4c Linux-2.6.12-rc2 |
741 742 743 744 745 746 |
static int mc32_load_rx_ring(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); int i; u16 rx_base; volatile struct skb_header *p; |
6aa20a223 drivers/net: Trim... |
747 |
|
1da177e4c Linux-2.6.12-rc2 |
748 749 750 751 752 753 754 755 756 757 758 759 |
rx_base=lp->rx_chain; for(i=0; i<RX_RING_LEN; i++) { lp->rx_ring[i].skb=alloc_skb(1532, GFP_KERNEL); if (lp->rx_ring[i].skb==NULL) { for (;i>=0;i--) kfree_skb(lp->rx_ring[i].skb); return -ENOBUFS; } skb_reserve(lp->rx_ring[i].skb, 18); p=isa_bus_to_virt(lp->base+rx_base); |
6aa20a223 drivers/net: Trim... |
760 |
|
1da177e4c Linux-2.6.12-rc2 |
761 762 763 764 |
p->control=0; p->data=isa_virt_to_bus(lp->rx_ring[i].skb->data); p->status=0; p->length=1532; |
6aa20a223 drivers/net: Trim... |
765 766 767 |
lp->rx_ring[i].p=p; rx_base=p->next; |
1da177e4c Linux-2.6.12-rc2 |
768 769 770 771 772 773 774 |
} lp->rx_ring[i-1].p->control |= CONTROL_EOL; lp->rx_ring_tail=0; return 0; |
6aa20a223 drivers/net: Trim... |
775 |
} |
1da177e4c Linux-2.6.12-rc2 |
776 777 778 779 780 781 |
/** * mc32_flush_rx_ring - free the ring of receive buffers * @lp: Local data of 3c527 to flush the rx ring of * |
6aa20a223 drivers/net: Trim... |
782 |
* Free the buffer for each ring slot. This may be called |
1da177e4c Linux-2.6.12-rc2 |
783 784 785 786 787 788 789 |
* before mc32_load_rx_ring(), eg. on error in mc32_open(). * Requires rx skb pointers to point to a valid skb, or NULL. */ static void mc32_flush_rx_ring(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); |
6aa20a223 drivers/net: Trim... |
790 |
int i; |
1da177e4c Linux-2.6.12-rc2 |
791 |
|
6aa20a223 drivers/net: Trim... |
792 793 |
for(i=0; i < RX_RING_LEN; i++) { |
1da177e4c Linux-2.6.12-rc2 |
794 795 796 797 |
if (lp->rx_ring[i].skb) { dev_kfree_skb(lp->rx_ring[i].skb); lp->rx_ring[i].skb = NULL; } |
6aa20a223 drivers/net: Trim... |
798 799 |
lp->rx_ring[i].p=NULL; } |
1da177e4c Linux-2.6.12-rc2 |
800 801 802 803 804 805 806 |
} /** * mc32_load_tx_ring - load transmit ring * @dev: The 3c527 card to issue the command to * |
6aa20a223 drivers/net: Trim... |
807 |
* This sets up the host transmit data-structures. |
1da177e4c Linux-2.6.12-rc2 |
808 |
* |
25985edce Fix common misspe... |
809 |
* First, we obtain from the card it's current position in the tx |
1da177e4c Linux-2.6.12-rc2 |
810 811 |
* ring, so that we will know where to begin transmitting * packets. |
6aa20a223 drivers/net: Trim... |
812 |
* |
1da177e4c Linux-2.6.12-rc2 |
813 814 815 |
* Then, we read the 'next' pointers from the on-card tx ring into * our tx_ring array to reduce slow shared-mem reads. Finally, we * intitalise the tx house keeping variables. |
6aa20a223 drivers/net: Trim... |
816 817 |
* */ |
1da177e4c Linux-2.6.12-rc2 |
818 819 |
static void mc32_load_tx_ring(struct net_device *dev) |
6aa20a223 drivers/net: Trim... |
820 |
{ |
1da177e4c Linux-2.6.12-rc2 |
821 822 |
struct mc32_local *lp = netdev_priv(dev); volatile struct skb_header *p; |
6aa20a223 drivers/net: Trim... |
823 |
int i; |
1da177e4c Linux-2.6.12-rc2 |
824 |
u16 tx_base; |
6aa20a223 drivers/net: Trim... |
825 |
tx_base=lp->tx_box->data[0]; |
1da177e4c Linux-2.6.12-rc2 |
826 827 828 829 |
for(i=0 ; i<TX_RING_LEN ; i++) { p=isa_bus_to_virt(lp->base+tx_base); |
6aa20a223 drivers/net: Trim... |
830 |
lp->tx_ring[i].p=p; |
1da177e4c Linux-2.6.12-rc2 |
831 832 833 834 835 836 837 |
lp->tx_ring[i].skb=NULL; tx_base=p->next; } /* -1 so that tx_ring_head cannot "lap" tx_ring_tail */ /* see mc32_tx_ring */ |
6aa20a223 drivers/net: Trim... |
838 839 840 841 |
atomic_set(&lp->tx_count, TX_RING_LEN-1); atomic_set(&lp->tx_ring_head, 0); lp->tx_ring_tail=0; } |
1da177e4c Linux-2.6.12-rc2 |
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
/** * mc32_flush_tx_ring - free transmit ring * @lp: Local data of 3c527 to flush the tx ring of * * If the ring is non-empty, zip over the it, freeing any * allocated skb_buffs. The tx ring house-keeping variables are * then reset. Requires rx skb pointers to point to a valid skb, * or NULL. */ static void mc32_flush_tx_ring(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); int i; for (i=0; i < TX_RING_LEN; i++) { if (lp->tx_ring[i].skb) { dev_kfree_skb(lp->tx_ring[i].skb); lp->tx_ring[i].skb = NULL; } } |
6aa20a223 drivers/net: Trim... |
867 868 |
atomic_set(&lp->tx_count, 0); atomic_set(&lp->tx_ring_head, 0); |
1da177e4c Linux-2.6.12-rc2 |
869 870 |
lp->tx_ring_tail=0; } |
6aa20a223 drivers/net: Trim... |
871 |
|
1da177e4c Linux-2.6.12-rc2 |
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 |
/** * mc32_open - handle 'up' of card * @dev: device to open * * The user is trying to bring the card into ready state. This requires * a brief dialogue with the card. Firstly we enable interrupts and then * 'indications'. Without these enabled the card doesn't bother telling * us what it has done. This had me puzzled for a week. * * We configure the number of card descriptors, then load the network * address and multicast filters. Turn on the workaround mode. This * works around a bug in the 82586 - it asks the firmware to do * so. It has a performance (latency) hit but is needed on busy * [read most] lans. We load the ring with buffers then we kick it * all off. */ static int mc32_open(struct net_device *dev) { int ioaddr = dev->base_addr; struct mc32_local *lp = netdev_priv(dev); u8 one=1; u8 regs; u16 descnumbuffs[2] = {TX_RING_LEN, RX_RING_LEN}; /* * Interrupts enabled */ regs=inb(ioaddr+HOST_CTRL); regs|=HOST_CTRL_INTE; outb(regs, ioaddr+HOST_CTRL); |
6aa20a223 drivers/net: Trim... |
905 |
|
1da177e4c Linux-2.6.12-rc2 |
906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
/* * Allow ourselves to issue commands */ up(&lp->cmd_mutex); /* * Send the indications on command */ mc32_command(dev, 4, &one, 2); /* |
6aa20a223 drivers/net: Trim... |
920 |
* Poke it to make sure it's really dead. |
1da177e4c Linux-2.6.12-rc2 |
921 |
*/ |
6aa20a223 drivers/net: Trim... |
922 923 |
mc32_halt_transceiver(dev); mc32_flush_tx_ring(dev); |
1da177e4c Linux-2.6.12-rc2 |
924 |
|
6aa20a223 drivers/net: Trim... |
925 926 927 |
/* * Ask card to set up on-card descriptors to our spec */ |
1da177e4c Linux-2.6.12-rc2 |
928 |
|
6aa20a223 drivers/net: Trim... |
929 |
if(mc32_command(dev, 8, descnumbuffs, 4)) { |
39738e161 3c5xx: convert pr... |
930 931 |
pr_info("%s: %s rejected our buffer configuration! ", |
1da177e4c Linux-2.6.12-rc2 |
932 |
dev->name, cardname); |
6aa20a223 drivers/net: Trim... |
933 934 |
mc32_close(dev); return -ENOBUFS; |
1da177e4c Linux-2.6.12-rc2 |
935 |
} |
6aa20a223 drivers/net: Trim... |
936 937 938 |
/* Report new configuration */ mc32_command(dev, 6, NULL, 0); |
1da177e4c Linux-2.6.12-rc2 |
939 940 941 |
lp->tx_chain = lp->exec_box->data[8]; /* Transmit list start offset */ lp->rx_chain = lp->exec_box->data[10]; /* Receive list start offset */ |
6aa20a223 drivers/net: Trim... |
942 |
lp->tx_len = lp->exec_box->data[9]; /* Transmit list count */ |
1da177e4c Linux-2.6.12-rc2 |
943 |
lp->rx_len = lp->exec_box->data[11]; /* Receive list count */ |
6aa20a223 drivers/net: Trim... |
944 |
|
1da177e4c Linux-2.6.12-rc2 |
945 946 |
/* Set Network Address */ mc32_command(dev, 1, dev->dev_addr, 6); |
6aa20a223 drivers/net: Trim... |
947 |
|
1da177e4c Linux-2.6.12-rc2 |
948 949 |
/* Set the filters */ mc32_set_multicast_list(dev); |
6aa20a223 drivers/net: Trim... |
950 951 |
if (WORKAROUND_82586) { |
1da177e4c Linux-2.6.12-rc2 |
952 953 954 955 956 |
u16 zero_word=0; mc32_command(dev, 0x0D, &zero_word, 2); /* 82586 bug workaround on */ } mc32_load_tx_ring(dev); |
6aa20a223 drivers/net: Trim... |
957 958 |
if(mc32_load_rx_ring(dev)) |
1da177e4c Linux-2.6.12-rc2 |
959 960 961 962 963 964 |
{ mc32_close(dev); return -ENOBUFS; } lp->xceiver_desired_state = RUNNING; |
6aa20a223 drivers/net: Trim... |
965 |
|
1da177e4c Linux-2.6.12-rc2 |
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
/* And finally, set the ball rolling... */ mc32_start_transceiver(dev); netif_start_queue(dev); return 0; } /** * mc32_timeout - handle a timeout from the network layer * @dev: 3c527 that timed out * * Handle a timeout on transmit from the 3c527. This normally means * bad things as the hardware handles cable timeouts and mess for * us. * */ static void mc32_timeout(struct net_device *dev) { |
39738e161 3c5xx: convert pr... |
987 988 |
pr_warning("%s: transmit timed out? ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
/* Try to restart the adaptor. */ netif_wake_queue(dev); } /** * mc32_send_packet - queue a frame for transmit * @skb: buffer to transmit * @dev: 3c527 to send it out of * * Transmit a buffer. This normally means throwing the buffer onto * the transmit queue as the queue is quite large. If the queue is * full then we set tx_busy and return. Once the interrupt handler * gets messages telling it to reclaim transmit queue entries, we will * clear tx_busy and the kernel will start calling this again. * * We do not disable interrupts or acquire any locks; this can * run concurrently with mc32_tx_ring(), and the function itself * is serialised at a higher layer. However, similarly for the * card itself, we must ensure that we update tx_ring_head only * after we've established a valid packet on the tx ring (and * before we let the card "see" it, to prevent it racing with the * irq handler). |
6aa20a223 drivers/net: Trim... |
1012 |
* |
1da177e4c Linux-2.6.12-rc2 |
1013 |
*/ |
27a1de95a 3com: convert dri... |
1014 1015 |
static netdev_tx_t mc32_send_packet(struct sk_buff *skb, struct net_device *dev) |
1da177e4c Linux-2.6.12-rc2 |
1016 1017 1018 |
{ struct mc32_local *lp = netdev_priv(dev); u32 head = atomic_read(&lp->tx_ring_head); |
6aa20a223 drivers/net: Trim... |
1019 |
|
1da177e4c Linux-2.6.12-rc2 |
1020 1021 1022 1023 1024 |
volatile struct skb_header *p, *np; netif_stop_queue(dev); if(atomic_read(&lp->tx_count)==0) { |
5b5481402 net: use symbolic... |
1025 |
return NETDEV_TX_BUSY; |
1da177e4c Linux-2.6.12-rc2 |
1026 |
} |
5b057c6b1 [NET]: Avoid allo... |
1027 |
if (skb_padto(skb, ETH_ZLEN)) { |
1da177e4c Linux-2.6.12-rc2 |
1028 |
netif_wake_queue(dev); |
6ed106549 net: use NETDEV_T... |
1029 |
return NETDEV_TX_OK; |
1da177e4c Linux-2.6.12-rc2 |
1030 |
} |
6aa20a223 drivers/net: Trim... |
1031 |
atomic_dec(&lp->tx_count); |
1da177e4c Linux-2.6.12-rc2 |
1032 1033 1034 |
/* P is the last sending/sent buffer as a pointer */ p=lp->tx_ring[head].p; |
6aa20a223 drivers/net: Trim... |
1035 |
|
1da177e4c Linux-2.6.12-rc2 |
1036 1037 1038 |
head = next_tx(head); /* NP is the buffer we will be loading */ |
6aa20a223 drivers/net: Trim... |
1039 |
np=lp->tx_ring[head].p; |
1da177e4c Linux-2.6.12-rc2 |
1040 1041 |
/* We will need this to flush the buffer out */ lp->tx_ring[head].skb=skb; |
6aa20a223 drivers/net: Trim... |
1042 |
np->length = unlikely(skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; |
1da177e4c Linux-2.6.12-rc2 |
1043 1044 |
np->data = isa_virt_to_bus(skb->data); np->status = 0; |
6aa20a223 drivers/net: Trim... |
1045 |
np->control = CONTROL_EOP | CONTROL_EOL; |
1da177e4c Linux-2.6.12-rc2 |
1046 |
wmb(); |
6aa20a223 drivers/net: Trim... |
1047 |
|
1da177e4c Linux-2.6.12-rc2 |
1048 1049 1050 1051 |
/* * The new frame has been setup; we can now * let the interrupt handler and card "see" it */ |
6aa20a223 drivers/net: Trim... |
1052 |
atomic_set(&lp->tx_ring_head, head); |
1da177e4c Linux-2.6.12-rc2 |
1053 1054 1055 |
p->control &= ~CONTROL_EOL; netif_wake_queue(dev); |
6ed106549 net: use NETDEV_T... |
1056 |
return NETDEV_TX_OK; |
1da177e4c Linux-2.6.12-rc2 |
1057 1058 1059 1060 1061 1062 1063 |
} /** * mc32_update_stats - pull off the on board statistics * @dev: 3c527 to service * |
6aa20a223 drivers/net: Trim... |
1064 |
* |
1da177e4c Linux-2.6.12-rc2 |
1065 1066 1067 1068 1069 |
* Query and reset the on-card stats. There's the small possibility * of a race here, which would result in an underestimation of * actual errors. As such, we'd prefer to keep all our stats * collection in software. As a rule, we do. However it can't be * used for rx errors and collisions as, by default, the card discards |
6aa20a223 drivers/net: Trim... |
1070 |
* bad rx packets. |
1da177e4c Linux-2.6.12-rc2 |
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 |
* * Setting the SAV BP in the rx filter command supposedly * stops this behaviour. However, testing shows that it only seems to * enable the collation of on-card rx statistics --- the driver * never sees an RX descriptor with an error status set. * */ static void mc32_update_stats(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); |
6aa20a223 drivers/net: Trim... |
1082 |
volatile struct mc32_stats *st = lp->stats; |
1da177e4c Linux-2.6.12-rc2 |
1083 |
|
6aa20a223 drivers/net: Trim... |
1084 |
u32 rx_errors=0; |
4711c841e 3c527: use netsta... |
1085 |
rx_errors+=dev->stats.rx_crc_errors +=st->rx_crc_errors; |
1da177e4c Linux-2.6.12-rc2 |
1086 |
st->rx_crc_errors=0; |
4711c841e 3c527: use netsta... |
1087 |
rx_errors+=dev->stats.rx_fifo_errors +=st->rx_overrun_errors; |
6aa20a223 drivers/net: Trim... |
1088 |
st->rx_overrun_errors=0; |
4711c841e 3c527: use netsta... |
1089 |
rx_errors+=dev->stats.rx_frame_errors +=st->rx_alignment_errors; |
1da177e4c Linux-2.6.12-rc2 |
1090 |
st->rx_alignment_errors=0; |
4711c841e 3c527: use netsta... |
1091 |
rx_errors+=dev->stats.rx_length_errors+=st->rx_tooshort_errors; |
1da177e4c Linux-2.6.12-rc2 |
1092 |
st->rx_tooshort_errors=0; |
4711c841e 3c527: use netsta... |
1093 |
rx_errors+=dev->stats.rx_missed_errors+=st->rx_outofresource_errors; |
6aa20a223 drivers/net: Trim... |
1094 |
st->rx_outofresource_errors=0; |
4711c841e 3c527: use netsta... |
1095 |
dev->stats.rx_errors=rx_errors; |
6aa20a223 drivers/net: Trim... |
1096 |
|
1da177e4c Linux-2.6.12-rc2 |
1097 |
/* Number of packets which saw one collision */ |
4711c841e 3c527: use netsta... |
1098 |
dev->stats.collisions+=st->dataC[10]; |
6aa20a223 drivers/net: Trim... |
1099 |
st->dataC[10]=0; |
1da177e4c Linux-2.6.12-rc2 |
1100 |
|
6aa20a223 drivers/net: Trim... |
1101 |
/* Number of packets which saw 2--15 collisions */ |
4711c841e 3c527: use netsta... |
1102 |
dev->stats.collisions+=st->dataC[11]; |
6aa20a223 drivers/net: Trim... |
1103 1104 |
st->dataC[11]=0; } |
1da177e4c Linux-2.6.12-rc2 |
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 |
/** * mc32_rx_ring - process the receive ring * @dev: 3c527 that needs its receive ring processing * * * We have received one or more indications from the card that a * receive has completed. The buffer ring thus contains dirty * entries. We walk the ring by iterating over the circular rx_ring * array, starting at the next dirty buffer (which happens to be the * one we finished up at last time around). * * For each completed packet, we will either copy it and pass it up * the stack or, if the packet is near MTU sized, we allocate * another buffer and flip the old one up the stack. |
6aa20a223 drivers/net: Trim... |
1121 |
* |
1da177e4c Linux-2.6.12-rc2 |
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 |
* We must succeed in keeping a buffer on the ring. If necessary we * will toss a received packet rather than lose a ring entry. Once * the first uncompleted descriptor is found, we move the * End-Of-List bit to include the buffers just processed. * */ static void mc32_rx_ring(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); volatile struct skb_header *p; u16 rx_ring_tail; u16 rx_old_tail; int x=0; rx_old_tail = rx_ring_tail = lp->rx_ring_tail; |
6aa20a223 drivers/net: Trim... |
1138 |
|
1da177e4c Linux-2.6.12-rc2 |
1139 |
do |
6aa20a223 drivers/net: Trim... |
1140 1141 |
{ p=lp->rx_ring[rx_ring_tail].p; |
1da177e4c Linux-2.6.12-rc2 |
1142 |
|
6aa20a223 drivers/net: Trim... |
1143 |
if(!(p->status & (1<<7))) { /* Not COMPLETED */ |
1da177e4c Linux-2.6.12-rc2 |
1144 |
break; |
6aa20a223 drivers/net: Trim... |
1145 |
} |
1da177e4c Linux-2.6.12-rc2 |
1146 |
if(p->status & (1<<6)) /* COMPLETED_OK */ |
6aa20a223 drivers/net: Trim... |
1147 |
{ |
1da177e4c Linux-2.6.12-rc2 |
1148 1149 |
u16 length=p->length; |
6aa20a223 drivers/net: Trim... |
1150 1151 |
struct sk_buff *skb; struct sk_buff *newskb; |
1da177e4c Linux-2.6.12-rc2 |
1152 1153 |
/* Try to save time by avoiding a copy on big frames */ |
8e95a2026 drivers/net: Move... |
1154 1155 |
if ((length > RX_COPYBREAK) && ((newskb=dev_alloc_skb(1532)) != NULL)) |
6aa20a223 drivers/net: Trim... |
1156 |
{ |
1da177e4c Linux-2.6.12-rc2 |
1157 1158 |
skb=lp->rx_ring[rx_ring_tail].skb; skb_put(skb, length); |
6aa20a223 drivers/net: Trim... |
1159 1160 1161 1162 1163 1164 |
skb_reserve(newskb,18); lp->rx_ring[rx_ring_tail].skb=newskb; p->data=isa_virt_to_bus(newskb->data); } else |
1da177e4c Linux-2.6.12-rc2 |
1165 |
{ |
6aa20a223 drivers/net: Trim... |
1166 |
skb=dev_alloc_skb(length+2); |
1da177e4c Linux-2.6.12-rc2 |
1167 1168 |
if(skb==NULL) { |
4711c841e 3c527: use netsta... |
1169 |
dev->stats.rx_dropped++; |
6aa20a223 drivers/net: Trim... |
1170 |
goto dropped; |
1da177e4c Linux-2.6.12-rc2 |
1171 1172 1173 1174 1175 1176 |
} skb_reserve(skb,2); memcpy(skb_put(skb, length), lp->rx_ring[rx_ring_tail].skb->data, length); } |
6aa20a223 drivers/net: Trim... |
1177 1178 |
skb->protocol=eth_type_trans(skb,dev); |
4711c841e 3c527: use netsta... |
1179 1180 |
dev->stats.rx_packets++; dev->stats.rx_bytes += length; |
1da177e4c Linux-2.6.12-rc2 |
1181 1182 1183 1184 |
netif_rx(skb); } dropped: |
6aa20a223 drivers/net: Trim... |
1185 |
p->length = 1532; |
1da177e4c Linux-2.6.12-rc2 |
1186 |
p->status = 0; |
6aa20a223 drivers/net: Trim... |
1187 1188 |
rx_ring_tail=next_rx(rx_ring_tail); |
1da177e4c Linux-2.6.12-rc2 |
1189 |
} |
6aa20a223 drivers/net: Trim... |
1190 |
while(x++<48); |
1da177e4c Linux-2.6.12-rc2 |
1191 |
|
6aa20a223 drivers/net: Trim... |
1192 1193 |
/* If there was actually a frame to be processed, place the EOL bit */ /* at the descriptor prior to the one to be filled next */ |
1da177e4c Linux-2.6.12-rc2 |
1194 |
|
6aa20a223 drivers/net: Trim... |
1195 1196 1197 1198 |
if (rx_ring_tail != rx_old_tail) { lp->rx_ring[prev_rx(rx_ring_tail)].p->control |= CONTROL_EOL; lp->rx_ring[prev_rx(rx_old_tail)].p->control &= ~CONTROL_EOL; |
1da177e4c Linux-2.6.12-rc2 |
1199 |
|
6aa20a223 drivers/net: Trim... |
1200 |
lp->rx_ring_tail=rx_ring_tail; |
1da177e4c Linux-2.6.12-rc2 |
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 |
} } /** * mc32_tx_ring - process completed transmits * @dev: 3c527 that needs its transmit ring processing * * * This operates in a similar fashion to mc32_rx_ring. We iterate * over the transmit ring. For each descriptor which has been * processed by the card, we free its associated buffer and note * any errors. This continues until the transmit ring is emptied * or we reach a descriptor that hasn't yet been processed by the * card. |
6aa20a223 drivers/net: Trim... |
1216 |
* |
1da177e4c Linux-2.6.12-rc2 |
1217 |
*/ |
6aa20a223 drivers/net: Trim... |
1218 |
static void mc32_tx_ring(struct net_device *dev) |
1da177e4c Linux-2.6.12-rc2 |
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 |
{ struct mc32_local *lp = netdev_priv(dev); volatile struct skb_header *np; /* * We rely on head==tail to mean 'queue empty'. * This is why lp->tx_count=TX_RING_LEN-1: in order to prevent * tx_ring_head wrapping to tail and confusing a 'queue empty' * condition with 'queue full' */ |
6aa20a223 drivers/net: Trim... |
1229 1230 1231 |
while (lp->tx_ring_tail != atomic_read(&lp->tx_ring_head)) { u16 t; |
1da177e4c Linux-2.6.12-rc2 |
1232 |
|
6aa20a223 drivers/net: Trim... |
1233 1234 |
t=next_tx(lp->tx_ring_tail); np=lp->tx_ring[t].p; |
1da177e4c Linux-2.6.12-rc2 |
1235 |
|
6aa20a223 drivers/net: Trim... |
1236 |
if(!(np->status & (1<<7))) |
1da177e4c Linux-2.6.12-rc2 |
1237 |
{ |
6aa20a223 drivers/net: Trim... |
1238 1239 1240 |
/* Not COMPLETED */ break; } |
4711c841e 3c527: use netsta... |
1241 |
dev->stats.tx_packets++; |
1da177e4c Linux-2.6.12-rc2 |
1242 1243 |
if(!(np->status & (1<<6))) /* Not COMPLETED_OK */ { |
4711c841e 3c527: use netsta... |
1244 |
dev->stats.tx_errors++; |
1da177e4c Linux-2.6.12-rc2 |
1245 1246 1247 1248 |
switch(np->status&0x0F) { case 1: |
4711c841e 3c527: use netsta... |
1249 |
dev->stats.tx_aborted_errors++; |
6aa20a223 drivers/net: Trim... |
1250 |
break; /* Max collisions */ |
1da177e4c Linux-2.6.12-rc2 |
1251 |
case 2: |
4711c841e 3c527: use netsta... |
1252 |
dev->stats.tx_fifo_errors++; |
1da177e4c Linux-2.6.12-rc2 |
1253 1254 |
break; case 3: |
4711c841e 3c527: use netsta... |
1255 |
dev->stats.tx_carrier_errors++; |
1da177e4c Linux-2.6.12-rc2 |
1256 1257 |
break; case 4: |
4711c841e 3c527: use netsta... |
1258 |
dev->stats.tx_window_errors++; |
6aa20a223 drivers/net: Trim... |
1259 |
break; /* CTS Lost */ |
1da177e4c Linux-2.6.12-rc2 |
1260 |
case 5: |
4711c841e 3c527: use netsta... |
1261 |
dev->stats.tx_aborted_errors++; |
6aa20a223 drivers/net: Trim... |
1262 |
break; /* Transmit timeout */ |
1da177e4c Linux-2.6.12-rc2 |
1263 1264 1265 1266 1267 |
} } /* Packets are sent in order - this is basically a FIFO queue of buffers matching the card ring */ |
4711c841e 3c527: use netsta... |
1268 |
dev->stats.tx_bytes+=lp->tx_ring[t].skb->len; |
1da177e4c Linux-2.6.12-rc2 |
1269 1270 1271 1272 |
dev_kfree_skb_irq(lp->tx_ring[t].skb); lp->tx_ring[t].skb=NULL; atomic_inc(&lp->tx_count); netif_wake_queue(dev); |
6aa20a223 drivers/net: Trim... |
1273 |
lp->tx_ring_tail=t; |
1da177e4c Linux-2.6.12-rc2 |
1274 |
} |
6aa20a223 drivers/net: Trim... |
1275 |
} |
1da177e4c Linux-2.6.12-rc2 |
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 |
/** * mc32_interrupt - handle an interrupt from a 3c527 * @irq: Interrupt number * @dev_id: 3c527 that requires servicing * @regs: Registers (unused) * * * An interrupt is raised whenever the 3c527 writes to the command * register. This register contains the message it wishes to send us * packed into a single byte field. We keep reading status entries * until we have processed all the control items, but simply count * transmit and receive reports. When all reports are in we empty the * transceiver rings as appropriate. This saves the overhead of * multiple command requests. * * Because MCA is level-triggered, we shouldn't miss indications. * Therefore, we needn't ask the card to suspend interrupts within * this handler. The card receives an implicit acknowledgment of the * current interrupt when we read the command register. * */ |
7d12e780e IRQ: Maintain reg... |
1299 |
static irqreturn_t mc32_interrupt(int irq, void *dev_id) |
1da177e4c Linux-2.6.12-rc2 |
1300 1301 1302 1303 1304 |
{ struct net_device *dev = dev_id; struct mc32_local *lp; int ioaddr, status, boguscount = 0; int rx_event = 0; |
6aa20a223 drivers/net: Trim... |
1305 |
int tx_event = 0; |
1da177e4c Linux-2.6.12-rc2 |
1306 1307 1308 1309 1310 1311 1312 1313 |
ioaddr = dev->base_addr; lp = netdev_priv(dev); /* See whats cooking */ while((inb(ioaddr+HOST_STATUS)&HOST_STATUS_CWR) && boguscount++<2000) { status=inb(ioaddr+HOST_CMD); |
39738e161 3c5xx: convert pr... |
1314 1315 |
pr_debug("Status TX%d RX%d EX%d OV%d BC%d ", |
1da177e4c Linux-2.6.12-rc2 |
1316 1317 |
(status&7), (status>>3)&7, (status>>6)&1, (status>>7)&1, boguscount); |
6aa20a223 drivers/net: Trim... |
1318 |
|
1da177e4c Linux-2.6.12-rc2 |
1319 1320 1321 1322 1323 1324 |
switch(status&7) { case 0: break; case 6: /* TX fail */ case 2: /* TX ok */ |
6aa20a223 drivers/net: Trim... |
1325 |
tx_event = 1; |
1da177e4c Linux-2.6.12-rc2 |
1326 1327 1328 1329 1330 1331 |
break; case 3: /* Halt */ case 4: /* Abort */ complete(&lp->xceiver_cmd); break; default: |
39738e161 3c5xx: convert pr... |
1332 1333 |
pr_notice("%s: strange tx ack %d ", dev->name, status&7); |
1da177e4c Linux-2.6.12-rc2 |
1334 1335 1336 1337 1338 1339 1340 |
} status>>=3; switch(status&7) { case 0: break; case 2: /* RX */ |
6aa20a223 drivers/net: Trim... |
1341 |
rx_event=1; |
1da177e4c Linux-2.6.12-rc2 |
1342 1343 1344 1345 1346 1347 1348 1349 |
break; case 3: /* Halt */ case 4: /* Abort */ complete(&lp->xceiver_cmd); break; case 6: /* Out of RX buffers stat */ /* Must restart rx */ |
4711c841e 3c527: use netsta... |
1350 |
dev->stats.rx_dropped++; |
6aa20a223 drivers/net: Trim... |
1351 1352 |
mc32_rx_ring(dev); mc32_start_transceiver(dev); |
1da177e4c Linux-2.6.12-rc2 |
1353 1354 |
break; default: |
39738e161 3c5xx: convert pr... |
1355 1356 |
pr_notice("%s: strange rx ack %d ", |
6aa20a223 drivers/net: Trim... |
1357 |
dev->name, status&7); |
1da177e4c Linux-2.6.12-rc2 |
1358 1359 1360 1361 1362 1363 1364 1365 |
} status>>=3; if(status&1) { /* * No thread is waiting: we need to tidy * up ourself. */ |
6aa20a223 drivers/net: Trim... |
1366 |
|
1da177e4c Linux-2.6.12-rc2 |
1367 1368 |
if (lp->cmd_nonblocking) { up(&lp->cmd_mutex); |
6aa20a223 drivers/net: Trim... |
1369 |
if (lp->mc_reload_wait) |
1da177e4c Linux-2.6.12-rc2 |
1370 1371 1372 1373 1374 1375 1376 1377 |
mc32_reset_multicast_list(dev); } else complete(&lp->execution_cmd); } if(status&2) { /* * We get interrupted once per |
6aa20a223 drivers/net: Trim... |
1378 |
* counter that is about to overflow. |
1da177e4c Linux-2.6.12-rc2 |
1379 |
*/ |
6aa20a223 drivers/net: Trim... |
1380 |
mc32_update_stats(dev); |
1da177e4c Linux-2.6.12-rc2 |
1381 1382 1383 1384 1385 |
} } /* |
6aa20a223 drivers/net: Trim... |
1386 |
* Process the transmit and receive rings |
1da177e4c Linux-2.6.12-rc2 |
1387 |
*/ |
6aa20a223 drivers/net: Trim... |
1388 |
if(tx_event) |
1da177e4c Linux-2.6.12-rc2 |
1389 |
mc32_tx_ring(dev); |
6aa20a223 drivers/net: Trim... |
1390 1391 |
if(rx_event) |
1da177e4c Linux-2.6.12-rc2 |
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
mc32_rx_ring(dev); return IRQ_HANDLED; } /** * mc32_close - user configuring the 3c527 down * @dev: 3c527 card to shut down * * The 3c527 is a bus mastering device. We must be careful how we * shut it down. It may also be running shared interrupt so we have * to be sure to silence it properly * * We indicate that the card is closing to the rest of the * driver. Otherwise, it is possible that the card may run out * of receive buffers and restart the transceiver while we're * trying to close it. |
6aa20a223 drivers/net: Trim... |
1410 |
* |
1da177e4c Linux-2.6.12-rc2 |
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 |
* We abort any receive and transmits going on and then wait until * any pending exec commands have completed in other code threads. * In theory we can't get here while that is true, in practice I am * paranoid * * We turn off the interrupt enable for the board to be sure it can't * intefere with other devices. */ static int mc32_close(struct net_device *dev) { struct mc32_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; u8 regs; u16 one=1; |
6aa20a223 drivers/net: Trim... |
1427 |
|
1da177e4c Linux-2.6.12-rc2 |
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 |
lp->xceiver_desired_state = HALTED; netif_stop_queue(dev); /* * Send the indications on command (handy debug check) */ mc32_command(dev, 4, &one, 2); /* Shut down the transceiver */ |
6aa20a223 drivers/net: Trim... |
1438 |
mc32_halt_transceiver(dev); |
1da177e4c Linux-2.6.12-rc2 |
1439 1440 1441 |
/* Ensure we issue no more commands beyond this point */ down(&lp->cmd_mutex); |
6aa20a223 drivers/net: Trim... |
1442 1443 |
/* Ok the card is now stopping */ |
1da177e4c Linux-2.6.12-rc2 |
1444 1445 1446 1447 1448 1449 |
regs=inb(ioaddr+HOST_CTRL); regs&=~HOST_CTRL_INTE; outb(regs, ioaddr+HOST_CTRL); mc32_flush_rx_ring(dev); mc32_flush_tx_ring(dev); |
6aa20a223 drivers/net: Trim... |
1450 1451 |
mc32_update_stats(dev); |
1da177e4c Linux-2.6.12-rc2 |
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 |
return 0; } /** * mc32_get_stats - hand back stats to network layer * @dev: The 3c527 card to handle * * We've collected all the stats we can in software already. Now |
6aa20a223 drivers/net: Trim... |
1462 1463 |
* it's time to update those kept on-card and return the lot. * |
1da177e4c Linux-2.6.12-rc2 |
1464 1465 1466 1467 |
*/ static struct net_device_stats *mc32_get_stats(struct net_device *dev) { |
6aa20a223 drivers/net: Trim... |
1468 |
mc32_update_stats(dev); |
4711c841e 3c527: use netsta... |
1469 |
return &dev->stats; |
1da177e4c Linux-2.6.12-rc2 |
1470 1471 1472 1473 1474 1475 |
} /** * do_mc32_set_multicast_list - attempt to update multicasts * @dev: 3c527 device to load the list on |
6aa20a223 drivers/net: Trim... |
1476 |
* @retry: indicates this is not the first call. |
1da177e4c Linux-2.6.12-rc2 |
1477 1478 1479 1480 1481 1482 1483 |
* * * Actually set or clear the multicast filter for this adaptor. The * locking issues are handled by this routine. We have to track * state as it may take multiple calls to get the command sequence * completed. We just keep trying to schedule the loads until we * manage to process them all. |
6aa20a223 drivers/net: Trim... |
1484 |
* |
1da177e4c Linux-2.6.12-rc2 |
1485 |
* num_addrs == -1 Promiscuous mode, receive all packets |
6aa20a223 drivers/net: Trim... |
1486 |
* |
1da177e4c Linux-2.6.12-rc2 |
1487 |
* num_addrs == 0 Normal mode, clear multicast list |
1da177e4c Linux-2.6.12-rc2 |
1488 |
* |
6aa20a223 drivers/net: Trim... |
1489 1490 1491 1492 |
* num_addrs > 0 Multicast mode, receive normal and MC packets, * and do best-effort filtering. * * See mc32_update_stats() regards setting the SAV BP bit. |
1da177e4c Linux-2.6.12-rc2 |
1493 1494 1495 1496 1497 1498 |
* */ static void do_mc32_set_multicast_list(struct net_device *dev, int retry) { struct mc32_local *lp = netdev_priv(dev); |
6aa20a223 drivers/net: Trim... |
1499 |
u16 filt = (1<<2); /* Save Bad Packets, for stats purposes */ |
1da177e4c Linux-2.6.12-rc2 |
1500 |
|
c16d11853 [netdrvr] Drivers... |
1501 1502 |
if ((dev->flags&IFF_PROMISC) || (dev->flags&IFF_ALLMULTI) || |
4cd24eaf0 net: use netdev_m... |
1503 |
netdev_mc_count(dev) > 10) |
1da177e4c Linux-2.6.12-rc2 |
1504 1505 |
/* Enable promiscuous mode */ filt |= 1; |
4cd24eaf0 net: use netdev_m... |
1506 |
else if (!netdev_mc_empty(dev)) |
1da177e4c Linux-2.6.12-rc2 |
1507 1508 1509 |
{ unsigned char block[62]; unsigned char *bp; |
22bedad3c net: convert mult... |
1510 |
struct netdev_hw_addr *ha; |
6aa20a223 drivers/net: Trim... |
1511 |
|
1da177e4c Linux-2.6.12-rc2 |
1512 1513 1514 1515 1516 |
if(retry==0) lp->mc_list_valid = 0; if(!lp->mc_list_valid) { block[1]=0; |
4cd24eaf0 net: use netdev_m... |
1517 |
block[0]=netdev_mc_count(dev); |
1da177e4c Linux-2.6.12-rc2 |
1518 |
bp=block+2; |
6aa20a223 drivers/net: Trim... |
1519 |
|
22bedad3c net: convert mult... |
1520 1521 |
netdev_for_each_mc_addr(ha, dev) { memcpy(bp, ha->addr, 6); |
1da177e4c Linux-2.6.12-rc2 |
1522 |
bp+=6; |
1da177e4c Linux-2.6.12-rc2 |
1523 |
} |
4cd24eaf0 net: use netdev_m... |
1524 1525 |
if(mc32_command_nowait(dev, 2, block, 2+6*netdev_mc_count(dev))==-1) |
1da177e4c Linux-2.6.12-rc2 |
1526 1527 1528 1529 1530 1531 1532 |
{ lp->mc_reload_wait = 1; return; } lp->mc_list_valid=1; } } |
6aa20a223 drivers/net: Trim... |
1533 1534 |
if(mc32_command_nowait(dev, 0, &filt, 2)==-1) |
1da177e4c Linux-2.6.12-rc2 |
1535 1536 |
{ lp->mc_reload_wait = 1; |
6aa20a223 drivers/net: Trim... |
1537 1538 |
} else { |
1da177e4c Linux-2.6.12-rc2 |
1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 |
lp->mc_reload_wait = 0; } } /** * mc32_set_multicast_list - queue multicast list update * @dev: The 3c527 to use * * Commence loading the multicast list. This is called when the kernel * changes the lists. It will override any pending list we are trying to * load. */ static void mc32_set_multicast_list(struct net_device *dev) { do_mc32_set_multicast_list(dev,0); } /** * mc32_reset_multicast_list - reset multicast list * @dev: The 3c527 to use * * Attempt the next step in loading the multicast lists. If this attempt * fails to complete then it will be scheduled and this function called * again later from elsewhere. */ static void mc32_reset_multicast_list(struct net_device *dev) { do_mc32_set_multicast_list(dev,1); } static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strcpy(info->driver, DRV_NAME); strcpy(info->version, DRV_VERSION); sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr); } static u32 netdev_get_msglevel(struct net_device *dev) { return mc32_debug; } static void netdev_set_msglevel(struct net_device *dev, u32 level) { mc32_debug = level; } |
7282d491e drivers/net: cons... |
1590 |
static const struct ethtool_ops netdev_ethtool_ops = { |
1da177e4c Linux-2.6.12-rc2 |
1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 |
.get_drvinfo = netdev_get_drvinfo, .get_msglevel = netdev_get_msglevel, .set_msglevel = netdev_set_msglevel, }; #ifdef MODULE static struct net_device *this_device; /** * init_module - entry point * * Probe and locate a 3c527 card. This really should probe and locate * all the 3c527 cards in the machine not just one of them. Yes you can * insmod multiple modules for now but it's a hack. */ |
96e672c79 [PATCH] 3c5zz eth... |
1607 |
int __init init_module(void) |
1da177e4c Linux-2.6.12-rc2 |
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 |
{ this_device = mc32_probe(-1); if (IS_ERR(this_device)) return PTR_ERR(this_device); return 0; } /** * cleanup_module - free resources for an unload * * Unloading time. We release the MCA bus resources and the interrupt * at which point everything is ready to unload. The card must be stopped * at this point or we would not have been called. When we unload we * leave the card stopped but not totally shut down. When the card is * initialized it must be rebooted or the rings reloaded before any * transmit operations are allowed to start scribbling into memory. */ |
afc8eb46c [PATCH] trivial m... |
1625 |
void __exit cleanup_module(void) |
1da177e4c Linux-2.6.12-rc2 |
1626 1627 1628 1629 1630 1631 1632 |
{ unregister_netdev(this_device); cleanup_card(this_device); free_netdev(this_device); } #endif /* MODULE */ |