Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wan: remove sbni/granch driver

The driver was merged in 1999 and has only ever seen treewide cleanups
since then, with no indication whatsoever that anyone has actually
had access to hardware for testing the patches.

>From the information in the link below, it appears that the hardware
is for some leased line system in Russia that has since been
discontinued, and useless without any remote end to connect to.

As the driver still feels like a Linux-2.2 era artifact today, it
appears that the best way forward is to just delete it.

Link: https://www.tms.ru/%D0%90%D0%B4%D0%B0%D0%BF%D1%82%D0%B5%D1%80_%D0%B4%D0%BB%D1%8F_%D0%B2%D1%8B%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%BD%D1%8B%D1%85_%D0%BB%D0%B8%D0%BD%D0%B8%D0%B9_Granch_SBNI12-10
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Arnd Bergmann and committed by
David S. Miller
72bcad53 db3db1f4

-1823
-2
Documentation/admin-guide/kernel-parameters.txt
··· 4945 4945 sa1100ir [NET] 4946 4946 See drivers/net/irda/sa1100_ir.c. 4947 4947 4948 - sbni= [NET] Granch SBNI12 leased line adapter 4949 - 4950 4948 sched_verbose [KNL] Enables verbose scheduler debug messages. 4951 4949 4952 4950 schedstats= [KNL,X86] Enable or disable scheduled statistics.
-4
drivers/net/Space.c
··· 247 247 { 248 248 int num; 249 249 250 - #ifdef CONFIG_SBNI 251 - for (num = 0; num < 8; ++num) 252 - sbni_probe(num); 253 - #endif 254 250 for (num = 0; num < 8; ++num) 255 251 ethif_probe2(num); 256 252
-27
drivers/net/wan/Kconfig
··· 313 313 To compile this driver as a module, choose M here: the 314 314 module will be called lapbether. 315 315 316 - If unsure, say N. 317 - 318 - config SBNI 319 - tristate "Granch SBNI12 Leased Line adapter support" 320 - depends on X86 321 - help 322 - Driver for ISA SBNI12-xx cards which are low cost alternatives to 323 - leased line modems. 324 - 325 - You can find more information and last versions of drivers and 326 - utilities at <http://www.granch.ru/>. If you have any question you 327 - can send email to <sbni@granch.ru>. 328 - 329 - To compile this driver as a module, choose M here: the 330 - module will be called sbni. 331 - 332 - If unsure, say N. 333 - 334 - config SBNI_MULTILINE 335 - bool "Multiple line feature support" 336 - depends on SBNI 337 - help 338 - Schedule traffic for some parallel lines, via SBNI12 adapters. 339 - 340 - If you have two computers connected with two parallel lines it's 341 - possible to increase transfer rate nearly twice. You should have 342 - a program named 'sbniconfig' to configure adapters. 343 316 344 317 If unsure, say N. 345 318
-1
drivers/net/wan/Makefile
··· 22 22 obj-$(CONFIG_LANMEDIA) += lmc/ 23 23 24 24 obj-$(CONFIG_LAPBETHER) += lapbether.o 25 - obj-$(CONFIG_SBNI) += sbni.o 26 25 obj-$(CONFIG_N2) += n2.o 27 26 obj-$(CONFIG_C101) += c101.o 28 27 obj-$(CONFIG_WANXL) += wanxl.o
-1639
drivers/net/wan/sbni.c
··· 1 - /* sbni.c: Granch SBNI12 leased line adapters driver for linux 2 - * 3 - * Written 2001 by Denis I.Timofeev (timofeev@granch.ru) 4 - * 5 - * Previous versions were written by Yaroslav Polyakov, 6 - * Alexey Zverev and Max Khon. 7 - * 8 - * Driver supports SBNI12-02,-04,-05,-10,-11 cards, single and 9 - * double-channel, PCI and ISA modifications. 10 - * More info and useful utilities to work with SBNI12 cards you can find 11 - * at http://www.granch.com (English) or http://www.granch.ru (Russian) 12 - * 13 - * This software may be used and distributed according to the terms 14 - * of the GNU General Public License. 15 - * 16 - * 17 - * 5.0.1 Jun 22 2001 18 - * - Fixed bug in probe 19 - * 5.0.0 Jun 06 2001 20 - * - Driver was completely redesigned by Denis I.Timofeev, 21 - * - now PCI/Dual, ISA/Dual (with single interrupt line) models are 22 - * - supported 23 - * 3.3.0 Thu Feb 24 21:30:28 NOVT 2000 24 - * - PCI cards support 25 - * 3.2.0 Mon Dec 13 22:26:53 NOVT 1999 26 - * - Completely rebuilt all the packet storage system 27 - * - to work in Ethernet-like style. 28 - * 3.1.1 just fixed some bugs (5 aug 1999) 29 - * 3.1.0 added balancing feature (26 apr 1999) 30 - * 3.0.1 just fixed some bugs (14 apr 1999). 31 - * 3.0.0 Initial Revision, Yaroslav Polyakov (24 Feb 1999) 32 - * - added pre-calculation for CRC, fixed bug with "len-2" frames, 33 - * - removed outbound fragmentation (MTU=1000), written CRC-calculation 34 - * - on asm, added work with hard_headers and now we have our own cache 35 - * - for them, optionally supported word-interchange on some chipsets, 36 - * 37 - * Known problem: this driver wasn't tested on multiprocessor machine. 38 - */ 39 - 40 - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 41 - 42 - #include <linux/module.h> 43 - #include <linux/kernel.h> 44 - #include <linux/ptrace.h> 45 - #include <linux/fcntl.h> 46 - #include <linux/ioport.h> 47 - #include <linux/interrupt.h> 48 - #include <linux/string.h> 49 - #include <linux/errno.h> 50 - #include <linux/netdevice.h> 51 - #include <linux/etherdevice.h> 52 - #include <linux/pci.h> 53 - #include <linux/skbuff.h> 54 - #include <linux/timer.h> 55 - #include <linux/init.h> 56 - #include <linux/delay.h> 57 - 58 - #include <net/net_namespace.h> 59 - #include <net/arp.h> 60 - #include <net/Space.h> 61 - 62 - #include <asm/io.h> 63 - #include <asm/types.h> 64 - #include <asm/byteorder.h> 65 - #include <asm/irq.h> 66 - #include <linux/uaccess.h> 67 - 68 - #include "sbni.h" 69 - 70 - /* device private data */ 71 - 72 - struct net_local { 73 - struct timer_list watchdog; 74 - struct net_device *watchdog_dev; 75 - 76 - spinlock_t lock; 77 - struct sk_buff *rx_buf_p; /* receive buffer ptr */ 78 - struct sk_buff *tx_buf_p; /* transmit buffer ptr */ 79 - 80 - unsigned int framelen; /* current frame length */ 81 - unsigned int maxframe; /* maximum valid frame length */ 82 - unsigned int state; 83 - unsigned int inppos, outpos; /* positions in rx/tx buffers */ 84 - 85 - /* transmitting frame number - from frames qty to 1 */ 86 - unsigned int tx_frameno; 87 - 88 - /* expected number of next receiving frame */ 89 - unsigned int wait_frameno; 90 - 91 - /* count of failed attempts to frame send - 32 attempts do before 92 - error - while receiver tunes on opposite side of wire */ 93 - unsigned int trans_errors; 94 - 95 - /* idle time; send pong when limit exceeded */ 96 - unsigned int timer_ticks; 97 - 98 - /* fields used for receive level autoselection */ 99 - int delta_rxl; 100 - unsigned int cur_rxl_index, timeout_rxl; 101 - unsigned long cur_rxl_rcvd, prev_rxl_rcvd; 102 - 103 - struct sbni_csr1 csr1; /* current value of CSR1 */ 104 - struct sbni_in_stats in_stats; /* internal statistics */ 105 - 106 - struct net_device *second; /* for ISA/dual cards */ 107 - 108 - #ifdef CONFIG_SBNI_MULTILINE 109 - struct net_device *master; 110 - struct net_device *link; 111 - #endif 112 - }; 113 - 114 - 115 - static int sbni_card_probe( unsigned long ); 116 - static int sbni_pci_probe( struct net_device * ); 117 - static struct net_device *sbni_probe1(struct net_device *, unsigned long, int); 118 - static int sbni_open( struct net_device * ); 119 - static int sbni_close( struct net_device * ); 120 - static netdev_tx_t sbni_start_xmit(struct sk_buff *, 121 - struct net_device * ); 122 - static int sbni_siocdevprivate(struct net_device *, struct ifreq *, 123 - void __user *, int); 124 - static void set_multicast_list( struct net_device * ); 125 - 126 - static irqreturn_t sbni_interrupt( int, void * ); 127 - static void handle_channel( struct net_device * ); 128 - static int recv_frame( struct net_device * ); 129 - static void send_frame( struct net_device * ); 130 - static int upload_data( struct net_device *, 131 - unsigned, unsigned, unsigned, u32 ); 132 - static void download_data( struct net_device *, u32 * ); 133 - static void sbni_watchdog(struct timer_list *); 134 - static void interpret_ack( struct net_device *, unsigned ); 135 - static int append_frame_to_pkt( struct net_device *, unsigned, u32 ); 136 - static void indicate_pkt( struct net_device * ); 137 - static void card_start( struct net_device * ); 138 - static void prepare_to_send( struct sk_buff *, struct net_device * ); 139 - static void drop_xmit_queue( struct net_device * ); 140 - static void send_frame_header( struct net_device *, u32 * ); 141 - static int skip_tail( unsigned int, unsigned int, u32 ); 142 - static int check_fhdr( u32, u32 *, u32 *, u32 *, u32 *, u32 * ); 143 - static void change_level( struct net_device * ); 144 - static void timeout_change_level( struct net_device * ); 145 - static u32 calc_crc32( u32, u8 *, u32 ); 146 - static struct sk_buff * get_rx_buf( struct net_device * ); 147 - static int sbni_init( struct net_device * ); 148 - 149 - #ifdef CONFIG_SBNI_MULTILINE 150 - static int enslave( struct net_device *, struct net_device * ); 151 - static int emancipate( struct net_device * ); 152 - #endif 153 - 154 - static const char version[] = 155 - "Granch SBNI12 driver ver 5.0.1 Jun 22 2001 Denis I.Timofeev.\n"; 156 - 157 - static bool skip_pci_probe __initdata = false; 158 - static int scandone __initdata = 0; 159 - static int num __initdata = 0; 160 - 161 - static unsigned char rxl_tab[]; 162 - static u32 crc32tab[]; 163 - 164 - /* A list of all installed devices, for removing the driver module. */ 165 - static struct net_device *sbni_cards[ SBNI_MAX_NUM_CARDS ]; 166 - 167 - /* Lists of device's parameters */ 168 - static u32 io[ SBNI_MAX_NUM_CARDS ] __initdata = 169 - { [0 ... SBNI_MAX_NUM_CARDS-1] = -1 }; 170 - static u32 irq[ SBNI_MAX_NUM_CARDS ] __initdata; 171 - static u32 baud[ SBNI_MAX_NUM_CARDS ] __initdata; 172 - static u32 rxl[ SBNI_MAX_NUM_CARDS ] __initdata = 173 - { [0 ... SBNI_MAX_NUM_CARDS-1] = -1 }; 174 - static u32 mac[ SBNI_MAX_NUM_CARDS ] __initdata; 175 - 176 - #ifndef MODULE 177 - typedef u32 iarr[]; 178 - static iarr *dest[5] __initdata = { &io, &irq, &baud, &rxl, &mac }; 179 - #endif 180 - 181 - /* A zero-terminated list of I/O addresses to be probed on ISA bus */ 182 - static unsigned int netcard_portlist[ ] __initdata = { 183 - 0x210, 0x214, 0x220, 0x224, 0x230, 0x234, 0x240, 0x244, 0x250, 0x254, 184 - 0x260, 0x264, 0x270, 0x274, 0x280, 0x284, 0x290, 0x294, 0x2a0, 0x2a4, 185 - 0x2b0, 0x2b4, 0x2c0, 0x2c4, 0x2d0, 0x2d4, 0x2e0, 0x2e4, 0x2f0, 0x2f4, 186 - 0 }; 187 - 188 - #define NET_LOCAL_LOCK(dev) (((struct net_local *)netdev_priv(dev))->lock) 189 - 190 - /* 191 - * Look for SBNI card which addr stored in dev->base_addr, if nonzero. 192 - * Otherwise, look through PCI bus. If none PCI-card was found, scan ISA. 193 - */ 194 - 195 - static inline int __init 196 - sbni_isa_probe( struct net_device *dev ) 197 - { 198 - if( dev->base_addr > 0x1ff && 199 - request_region( dev->base_addr, SBNI_IO_EXTENT, dev->name ) && 200 - sbni_probe1( dev, dev->base_addr, dev->irq ) ) 201 - 202 - return 0; 203 - else { 204 - pr_err("base address 0x%lx is busy, or adapter is malfunctional!\n", 205 - dev->base_addr); 206 - return -ENODEV; 207 - } 208 - } 209 - 210 - static const struct net_device_ops sbni_netdev_ops = { 211 - .ndo_open = sbni_open, 212 - .ndo_stop = sbni_close, 213 - .ndo_start_xmit = sbni_start_xmit, 214 - .ndo_set_rx_mode = set_multicast_list, 215 - .ndo_siocdevprivate = sbni_siocdevprivate, 216 - .ndo_set_mac_address = eth_mac_addr, 217 - .ndo_validate_addr = eth_validate_addr, 218 - }; 219 - 220 - static void __init sbni_devsetup(struct net_device *dev) 221 - { 222 - ether_setup( dev ); 223 - dev->netdev_ops = &sbni_netdev_ops; 224 - } 225 - 226 - int __init sbni_probe(int unit) 227 - { 228 - struct net_device *dev; 229 - int err; 230 - 231 - dev = alloc_netdev(sizeof(struct net_local), "sbni", 232 - NET_NAME_UNKNOWN, sbni_devsetup); 233 - if (!dev) 234 - return -ENOMEM; 235 - 236 - dev->netdev_ops = &sbni_netdev_ops; 237 - 238 - sprintf(dev->name, "sbni%d", unit); 239 - netdev_boot_setup_check(dev); 240 - 241 - err = sbni_init(dev); 242 - if (err) { 243 - free_netdev(dev); 244 - return err; 245 - } 246 - 247 - err = register_netdev(dev); 248 - if (err) { 249 - release_region( dev->base_addr, SBNI_IO_EXTENT ); 250 - free_netdev(dev); 251 - return err; 252 - } 253 - pr_info_once("%s", version); 254 - return 0; 255 - } 256 - 257 - static int __init sbni_init(struct net_device *dev) 258 - { 259 - int i; 260 - if( dev->base_addr ) 261 - return sbni_isa_probe( dev ); 262 - /* otherwise we have to perform search our adapter */ 263 - 264 - if( io[ num ] != -1 ) { 265 - dev->base_addr = io[ num ]; 266 - dev->irq = irq[ num ]; 267 - } else if( scandone || io[ 0 ] != -1 ) { 268 - return -ENODEV; 269 - } 270 - 271 - /* if io[ num ] contains non-zero address, then that is on ISA bus */ 272 - if( dev->base_addr ) 273 - return sbni_isa_probe( dev ); 274 - 275 - /* ...otherwise - scan PCI first */ 276 - if( !skip_pci_probe && !sbni_pci_probe( dev ) ) 277 - return 0; 278 - 279 - if( io[ num ] == -1 ) { 280 - /* Auto-scan will be stopped when first ISA card were found */ 281 - scandone = 1; 282 - if( num > 0 ) 283 - return -ENODEV; 284 - } 285 - 286 - for( i = 0; netcard_portlist[ i ]; ++i ) { 287 - int ioaddr = netcard_portlist[ i ]; 288 - if( request_region( ioaddr, SBNI_IO_EXTENT, dev->name ) && 289 - sbni_probe1( dev, ioaddr, 0 )) 290 - return 0; 291 - } 292 - 293 - return -ENODEV; 294 - } 295 - 296 - 297 - static int __init 298 - sbni_pci_probe( struct net_device *dev ) 299 - { 300 - struct pci_dev *pdev = NULL; 301 - 302 - while( (pdev = pci_get_class( PCI_CLASS_NETWORK_OTHER << 8, pdev )) 303 - != NULL ) { 304 - int pci_irq_line; 305 - unsigned long pci_ioaddr; 306 - 307 - if( pdev->vendor != SBNI_PCI_VENDOR && 308 - pdev->device != SBNI_PCI_DEVICE ) 309 - continue; 310 - 311 - pci_ioaddr = pci_resource_start( pdev, 0 ); 312 - pci_irq_line = pdev->irq; 313 - 314 - /* Avoid already found cards from previous calls */ 315 - if( !request_region( pci_ioaddr, SBNI_IO_EXTENT, dev->name ) ) { 316 - if (pdev->subsystem_device != 2) 317 - continue; 318 - 319 - /* Dual adapter is present */ 320 - if (!request_region(pci_ioaddr += 4, SBNI_IO_EXTENT, 321 - dev->name ) ) 322 - continue; 323 - } 324 - 325 - if (pci_irq_line <= 0 || pci_irq_line >= nr_irqs) 326 - pr_warn( 327 - "WARNING: The PCI BIOS assigned this PCI card to IRQ %d, which is unlikely to work!.\n" 328 - "You should use the PCI BIOS setup to assign a valid IRQ line.\n", 329 - pci_irq_line ); 330 - 331 - /* avoiding re-enable dual adapters */ 332 - if( (pci_ioaddr & 7) == 0 && pci_enable_device( pdev ) ) { 333 - release_region( pci_ioaddr, SBNI_IO_EXTENT ); 334 - pci_dev_put( pdev ); 335 - return -EIO; 336 - } 337 - if( sbni_probe1( dev, pci_ioaddr, pci_irq_line ) ) { 338 - SET_NETDEV_DEV(dev, &pdev->dev); 339 - /* not the best thing to do, but this is all messed up 340 - for hotplug systems anyway... */ 341 - pci_dev_put( pdev ); 342 - return 0; 343 - } 344 - } 345 - return -ENODEV; 346 - } 347 - 348 - 349 - static struct net_device * __init 350 - sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq ) 351 - { 352 - struct net_local *nl; 353 - 354 - if( sbni_card_probe( ioaddr ) ) { 355 - release_region( ioaddr, SBNI_IO_EXTENT ); 356 - return NULL; 357 - } 358 - 359 - outb( 0, ioaddr + CSR0 ); 360 - 361 - if( irq < 2 ) { 362 - unsigned long irq_mask; 363 - 364 - irq_mask = probe_irq_on(); 365 - outb( EN_INT | TR_REQ, ioaddr + CSR0 ); 366 - outb( PR_RES, ioaddr + CSR1 ); 367 - mdelay(50); 368 - irq = probe_irq_off(irq_mask); 369 - outb( 0, ioaddr + CSR0 ); 370 - 371 - if( !irq ) { 372 - pr_err("%s: can't detect device irq!\n", dev->name); 373 - release_region( ioaddr, SBNI_IO_EXTENT ); 374 - return NULL; 375 - } 376 - } else if( irq == 2 ) 377 - irq = 9; 378 - 379 - dev->irq = irq; 380 - dev->base_addr = ioaddr; 381 - 382 - /* Fill in sbni-specific dev fields. */ 383 - nl = netdev_priv(dev); 384 - if( !nl ) { 385 - pr_err("%s: unable to get memory!\n", dev->name); 386 - release_region( ioaddr, SBNI_IO_EXTENT ); 387 - return NULL; 388 - } 389 - 390 - memset( nl, 0, sizeof(struct net_local) ); 391 - spin_lock_init( &nl->lock ); 392 - 393 - /* store MAC address (generate if that isn't known) */ 394 - *(__be16 *)dev->dev_addr = htons( 0x00ff ); 395 - *(__be32 *)(dev->dev_addr + 2) = htonl( 0x01000000 | 396 - ((mac[num] ? 397 - mac[num] : 398 - (u32)((long)netdev_priv(dev))) & 0x00ffffff)); 399 - 400 - /* store link settings (speed, receive level ) */ 401 - nl->maxframe = DEFAULT_FRAME_LEN; 402 - nl->csr1.rate = baud[ num ]; 403 - 404 - if( (nl->cur_rxl_index = rxl[ num ]) == -1 ) { 405 - /* autotune rxl */ 406 - nl->cur_rxl_index = DEF_RXL; 407 - nl->delta_rxl = DEF_RXL_DELTA; 408 - } else { 409 - nl->delta_rxl = 0; 410 - } 411 - nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index ]; 412 - if( inb( ioaddr + CSR0 ) & 0x01 ) 413 - nl->state |= FL_SLOW_MODE; 414 - 415 - pr_notice("%s: ioaddr %#lx, irq %d, MAC: 00:ff:01:%02x:%02x:%02x\n", 416 - dev->name, dev->base_addr, dev->irq, 417 - ((u8 *)dev->dev_addr)[3], 418 - ((u8 *)dev->dev_addr)[4], 419 - ((u8 *)dev->dev_addr)[5]); 420 - 421 - pr_notice("%s: speed %d", 422 - dev->name, 423 - ((nl->state & FL_SLOW_MODE) ? 500000 : 2000000) 424 - / (1 << nl->csr1.rate)); 425 - 426 - if( nl->delta_rxl == 0 ) 427 - pr_cont(", receive level 0x%x (fixed)\n", nl->cur_rxl_index); 428 - else 429 - pr_cont(", receive level (auto)\n"); 430 - 431 - #ifdef CONFIG_SBNI_MULTILINE 432 - nl->master = dev; 433 - nl->link = NULL; 434 - #endif 435 - 436 - sbni_cards[ num++ ] = dev; 437 - return dev; 438 - } 439 - 440 - /* -------------------------------------------------------------------------- */ 441 - 442 - #ifdef CONFIG_SBNI_MULTILINE 443 - 444 - static netdev_tx_t 445 - sbni_start_xmit( struct sk_buff *skb, struct net_device *dev ) 446 - { 447 - struct net_device *p; 448 - 449 - netif_stop_queue( dev ); 450 - 451 - /* Looking for idle device in the list */ 452 - for( p = dev; p; ) { 453 - struct net_local *nl = netdev_priv(p); 454 - spin_lock( &nl->lock ); 455 - if( nl->tx_buf_p || (nl->state & FL_LINE_DOWN) ) { 456 - p = nl->link; 457 - spin_unlock( &nl->lock ); 458 - } else { 459 - /* Idle dev is found */ 460 - prepare_to_send( skb, p ); 461 - spin_unlock( &nl->lock ); 462 - netif_start_queue( dev ); 463 - return NETDEV_TX_OK; 464 - } 465 - } 466 - 467 - return NETDEV_TX_BUSY; 468 - } 469 - 470 - #else /* CONFIG_SBNI_MULTILINE */ 471 - 472 - static netdev_tx_t 473 - sbni_start_xmit( struct sk_buff *skb, struct net_device *dev ) 474 - { 475 - struct net_local *nl = netdev_priv(dev); 476 - 477 - netif_stop_queue( dev ); 478 - spin_lock( &nl->lock ); 479 - 480 - prepare_to_send( skb, dev ); 481 - 482 - spin_unlock( &nl->lock ); 483 - return NETDEV_TX_OK; 484 - } 485 - 486 - #endif /* CONFIG_SBNI_MULTILINE */ 487 - 488 - /* -------------------------------------------------------------------------- */ 489 - 490 - /* interrupt handler */ 491 - 492 - /* 493 - * SBNI12D-10, -11/ISA boards within "common interrupt" mode could not 494 - * be looked as two independent single-channel devices. Every channel seems 495 - * as Ethernet interface but interrupt handler must be common. Really, first 496 - * channel ("master") driver only registers the handler. In its struct net_local 497 - * it has got pointer to "slave" channel's struct net_local and handles that's 498 - * interrupts too. 499 - * dev of successfully attached ISA SBNI boards is linked to list. 500 - * While next board driver is initialized, it scans this list. If one 501 - * has found dev with same irq and ioaddr different by 4 then it assumes 502 - * this board to be "master". 503 - */ 504 - 505 - static irqreturn_t 506 - sbni_interrupt( int irq, void *dev_id ) 507 - { 508 - struct net_device *dev = dev_id; 509 - struct net_local *nl = netdev_priv(dev); 510 - int repeat; 511 - 512 - spin_lock( &nl->lock ); 513 - if( nl->second ) 514 - spin_lock(&NET_LOCAL_LOCK(nl->second)); 515 - 516 - do { 517 - repeat = 0; 518 - if( inb( dev->base_addr + CSR0 ) & (RC_RDY | TR_RDY) ) { 519 - handle_channel( dev ); 520 - repeat = 1; 521 - } 522 - if( nl->second && /* second channel present */ 523 - (inb( nl->second->base_addr+CSR0 ) & (RC_RDY | TR_RDY)) ) { 524 - handle_channel( nl->second ); 525 - repeat = 1; 526 - } 527 - } while( repeat ); 528 - 529 - if( nl->second ) 530 - spin_unlock(&NET_LOCAL_LOCK(nl->second)); 531 - spin_unlock( &nl->lock ); 532 - return IRQ_HANDLED; 533 - } 534 - 535 - 536 - static void 537 - handle_channel( struct net_device *dev ) 538 - { 539 - struct net_local *nl = netdev_priv(dev); 540 - unsigned long ioaddr = dev->base_addr; 541 - 542 - int req_ans; 543 - unsigned char csr0; 544 - 545 - #ifdef CONFIG_SBNI_MULTILINE 546 - /* Lock the master device because we going to change its local data */ 547 - if( nl->state & FL_SLAVE ) 548 - spin_lock(&NET_LOCAL_LOCK(nl->master)); 549 - #endif 550 - 551 - outb( (inb( ioaddr + CSR0 ) & ~EN_INT) | TR_REQ, ioaddr + CSR0 ); 552 - 553 - nl->timer_ticks = CHANGE_LEVEL_START_TICKS; 554 - for(;;) { 555 - csr0 = inb( ioaddr + CSR0 ); 556 - if( ( csr0 & (RC_RDY | TR_RDY) ) == 0 ) 557 - break; 558 - 559 - req_ans = !(nl->state & FL_PREV_OK); 560 - 561 - if( csr0 & RC_RDY ) 562 - req_ans = recv_frame( dev ); 563 - 564 - /* 565 - * TR_RDY always equals 1 here because we have owned the marker, 566 - * and we set TR_REQ when disabled interrupts 567 - */ 568 - csr0 = inb( ioaddr + CSR0 ); 569 - if( !(csr0 & TR_RDY) || (csr0 & RC_RDY) ) 570 - netdev_err(dev, "internal error!\n"); 571 - 572 - /* if state & FL_NEED_RESEND != 0 then tx_frameno != 0 */ 573 - if( req_ans || nl->tx_frameno != 0 ) 574 - send_frame( dev ); 575 - else 576 - /* send marker without any data */ 577 - outb( inb( ioaddr + CSR0 ) & ~TR_REQ, ioaddr + CSR0 ); 578 - } 579 - 580 - outb( inb( ioaddr + CSR0 ) | EN_INT, ioaddr + CSR0 ); 581 - 582 - #ifdef CONFIG_SBNI_MULTILINE 583 - if( nl->state & FL_SLAVE ) 584 - spin_unlock(&NET_LOCAL_LOCK(nl->master)); 585 - #endif 586 - } 587 - 588 - 589 - /* 590 - * Routine returns 1 if it needs to acknowledge received frame. 591 - * Empty frame received without errors won't be acknowledged. 592 - */ 593 - 594 - static int 595 - recv_frame( struct net_device *dev ) 596 - { 597 - struct net_local *nl = netdev_priv(dev); 598 - unsigned long ioaddr = dev->base_addr; 599 - 600 - u32 crc = CRC32_INITIAL; 601 - 602 - unsigned framelen = 0, frameno, ack; 603 - unsigned is_first, frame_ok = 0; 604 - 605 - if( check_fhdr( ioaddr, &framelen, &frameno, &ack, &is_first, &crc ) ) { 606 - frame_ok = framelen > 4 607 - ? upload_data( dev, framelen, frameno, is_first, crc ) 608 - : skip_tail( ioaddr, framelen, crc ); 609 - if( frame_ok ) 610 - interpret_ack( dev, ack ); 611 - } 612 - 613 - outb( inb( ioaddr + CSR0 ) ^ CT_ZER, ioaddr + CSR0 ); 614 - if( frame_ok ) { 615 - nl->state |= FL_PREV_OK; 616 - if( framelen > 4 ) 617 - nl->in_stats.all_rx_number++; 618 - } else { 619 - nl->state &= ~FL_PREV_OK; 620 - change_level( dev ); 621 - nl->in_stats.all_rx_number++; 622 - nl->in_stats.bad_rx_number++; 623 - } 624 - 625 - return !frame_ok || framelen > 4; 626 - } 627 - 628 - 629 - static void 630 - send_frame( struct net_device *dev ) 631 - { 632 - struct net_local *nl = netdev_priv(dev); 633 - 634 - u32 crc = CRC32_INITIAL; 635 - 636 - if( nl->state & FL_NEED_RESEND ) { 637 - 638 - /* if frame was sended but not ACK'ed - resend it */ 639 - if( nl->trans_errors ) { 640 - --nl->trans_errors; 641 - if( nl->framelen != 0 ) 642 - nl->in_stats.resend_tx_number++; 643 - } else { 644 - /* cannot xmit with many attempts */ 645 - #ifdef CONFIG_SBNI_MULTILINE 646 - if( (nl->state & FL_SLAVE) || nl->link ) 647 - #endif 648 - nl->state |= FL_LINE_DOWN; 649 - drop_xmit_queue( dev ); 650 - goto do_send; 651 - } 652 - } else 653 - nl->trans_errors = TR_ERROR_COUNT; 654 - 655 - send_frame_header( dev, &crc ); 656 - nl->state |= FL_NEED_RESEND; 657 - /* 658 - * FL_NEED_RESEND will be cleared after ACK, but if empty 659 - * frame sended then in prepare_to_send next frame 660 - */ 661 - 662 - 663 - if( nl->framelen ) { 664 - download_data( dev, &crc ); 665 - nl->in_stats.all_tx_number++; 666 - nl->state |= FL_WAIT_ACK; 667 - } 668 - 669 - outsb( dev->base_addr + DAT, (u8 *)&crc, sizeof crc ); 670 - 671 - do_send: 672 - outb( inb( dev->base_addr + CSR0 ) & ~TR_REQ, dev->base_addr + CSR0 ); 673 - 674 - if( nl->tx_frameno ) 675 - /* next frame exists - we request card to send it */ 676 - outb( inb( dev->base_addr + CSR0 ) | TR_REQ, 677 - dev->base_addr + CSR0 ); 678 - } 679 - 680 - 681 - /* 682 - * Write the frame data into adapter's buffer memory, and calculate CRC. 683 - * Do padding if necessary. 684 - */ 685 - 686 - static void 687 - download_data( struct net_device *dev, u32 *crc_p ) 688 - { 689 - struct net_local *nl = netdev_priv(dev); 690 - struct sk_buff *skb = nl->tx_buf_p; 691 - 692 - unsigned len = min_t(unsigned int, skb->len - nl->outpos, nl->framelen); 693 - 694 - outsb( dev->base_addr + DAT, skb->data + nl->outpos, len ); 695 - *crc_p = calc_crc32( *crc_p, skb->data + nl->outpos, len ); 696 - 697 - /* if packet too short we should write some more bytes to pad */ 698 - for( len = nl->framelen - len; len--; ) { 699 - outb( 0, dev->base_addr + DAT ); 700 - *crc_p = CRC32( 0, *crc_p ); 701 - } 702 - } 703 - 704 - 705 - static int 706 - upload_data( struct net_device *dev, unsigned framelen, unsigned frameno, 707 - unsigned is_first, u32 crc ) 708 - { 709 - struct net_local *nl = netdev_priv(dev); 710 - 711 - int frame_ok; 712 - 713 - if( is_first ) { 714 - nl->wait_frameno = frameno; 715 - nl->inppos = 0; 716 - } 717 - 718 - if( nl->wait_frameno == frameno ) { 719 - 720 - if( nl->inppos + framelen <= ETHER_MAX_LEN ) 721 - frame_ok = append_frame_to_pkt( dev, framelen, crc ); 722 - 723 - /* 724 - * if CRC is right but framelen incorrect then transmitter 725 - * error was occurred... drop entire packet 726 - */ 727 - else if( (frame_ok = skip_tail( dev->base_addr, framelen, crc )) 728 - != 0 ) { 729 - nl->wait_frameno = 0; 730 - nl->inppos = 0; 731 - #ifdef CONFIG_SBNI_MULTILINE 732 - nl->master->stats.rx_errors++; 733 - nl->master->stats.rx_missed_errors++; 734 - #else 735 - dev->stats.rx_errors++; 736 - dev->stats.rx_missed_errors++; 737 - #endif 738 - } 739 - /* now skip all frames until is_first != 0 */ 740 - } else 741 - frame_ok = skip_tail( dev->base_addr, framelen, crc ); 742 - 743 - if( is_first && !frame_ok ) { 744 - /* 745 - * Frame has been broken, but we had already stored 746 - * is_first... Drop entire packet. 747 - */ 748 - nl->wait_frameno = 0; 749 - #ifdef CONFIG_SBNI_MULTILINE 750 - nl->master->stats.rx_errors++; 751 - nl->master->stats.rx_crc_errors++; 752 - #else 753 - dev->stats.rx_errors++; 754 - dev->stats.rx_crc_errors++; 755 - #endif 756 - } 757 - 758 - return frame_ok; 759 - } 760 - 761 - 762 - static inline void 763 - send_complete( struct net_device *dev ) 764 - { 765 - struct net_local *nl = netdev_priv(dev); 766 - 767 - #ifdef CONFIG_SBNI_MULTILINE 768 - nl->master->stats.tx_packets++; 769 - nl->master->stats.tx_bytes += nl->tx_buf_p->len; 770 - #else 771 - dev->stats.tx_packets++; 772 - dev->stats.tx_bytes += nl->tx_buf_p->len; 773 - #endif 774 - dev_consume_skb_irq(nl->tx_buf_p); 775 - 776 - nl->tx_buf_p = NULL; 777 - 778 - nl->outpos = 0; 779 - nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND); 780 - nl->framelen = 0; 781 - } 782 - 783 - 784 - static void 785 - interpret_ack( struct net_device *dev, unsigned ack ) 786 - { 787 - struct net_local *nl = netdev_priv(dev); 788 - 789 - if( ack == FRAME_SENT_OK ) { 790 - nl->state &= ~FL_NEED_RESEND; 791 - 792 - if( nl->state & FL_WAIT_ACK ) { 793 - nl->outpos += nl->framelen; 794 - 795 - if( --nl->tx_frameno ) { 796 - nl->framelen = min_t(unsigned int, 797 - nl->maxframe, 798 - nl->tx_buf_p->len - nl->outpos); 799 - } else { 800 - send_complete( dev ); 801 - #ifdef CONFIG_SBNI_MULTILINE 802 - netif_wake_queue( nl->master ); 803 - #else 804 - netif_wake_queue( dev ); 805 - #endif 806 - } 807 - } 808 - } 809 - 810 - nl->state &= ~FL_WAIT_ACK; 811 - } 812 - 813 - 814 - /* 815 - * Glue received frame with previous fragments of packet. 816 - * Indicate packet when last frame would be accepted. 817 - */ 818 - 819 - static int 820 - append_frame_to_pkt( struct net_device *dev, unsigned framelen, u32 crc ) 821 - { 822 - struct net_local *nl = netdev_priv(dev); 823 - 824 - u8 *p; 825 - 826 - if( nl->inppos + framelen > ETHER_MAX_LEN ) 827 - return 0; 828 - 829 - if( !nl->rx_buf_p && !(nl->rx_buf_p = get_rx_buf( dev )) ) 830 - return 0; 831 - 832 - p = nl->rx_buf_p->data + nl->inppos; 833 - insb( dev->base_addr + DAT, p, framelen ); 834 - if( calc_crc32( crc, p, framelen ) != CRC32_REMAINDER ) 835 - return 0; 836 - 837 - nl->inppos += framelen - 4; 838 - if( --nl->wait_frameno == 0 ) /* last frame received */ 839 - indicate_pkt( dev ); 840 - 841 - return 1; 842 - } 843 - 844 - 845 - /* 846 - * Prepare to start output on adapter. 847 - * Transmitter will be actually activated when marker is accepted. 848 - */ 849 - 850 - static void 851 - prepare_to_send( struct sk_buff *skb, struct net_device *dev ) 852 - { 853 - struct net_local *nl = netdev_priv(dev); 854 - 855 - unsigned int len; 856 - 857 - /* nl->tx_buf_p == NULL here! */ 858 - if( nl->tx_buf_p ) 859 - netdev_err(dev, "memory leak!\n"); 860 - 861 - nl->outpos = 0; 862 - nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND); 863 - 864 - len = skb->len; 865 - if( len < SBNI_MIN_LEN ) 866 - len = SBNI_MIN_LEN; 867 - 868 - nl->tx_buf_p = skb; 869 - nl->tx_frameno = DIV_ROUND_UP(len, nl->maxframe); 870 - nl->framelen = len < nl->maxframe ? len : nl->maxframe; 871 - 872 - outb( inb( dev->base_addr + CSR0 ) | TR_REQ, dev->base_addr + CSR0 ); 873 - #ifdef CONFIG_SBNI_MULTILINE 874 - netif_trans_update(nl->master); 875 - #else 876 - netif_trans_update(dev); 877 - #endif 878 - } 879 - 880 - 881 - static void 882 - drop_xmit_queue( struct net_device *dev ) 883 - { 884 - struct net_local *nl = netdev_priv(dev); 885 - 886 - if( nl->tx_buf_p ) { 887 - dev_kfree_skb_any( nl->tx_buf_p ); 888 - nl->tx_buf_p = NULL; 889 - #ifdef CONFIG_SBNI_MULTILINE 890 - nl->master->stats.tx_errors++; 891 - nl->master->stats.tx_carrier_errors++; 892 - #else 893 - dev->stats.tx_errors++; 894 - dev->stats.tx_carrier_errors++; 895 - #endif 896 - } 897 - 898 - nl->tx_frameno = 0; 899 - nl->framelen = 0; 900 - nl->outpos = 0; 901 - nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND); 902 - #ifdef CONFIG_SBNI_MULTILINE 903 - netif_start_queue( nl->master ); 904 - netif_trans_update(nl->master); 905 - #else 906 - netif_start_queue( dev ); 907 - netif_trans_update(dev); 908 - #endif 909 - } 910 - 911 - 912 - static void 913 - send_frame_header( struct net_device *dev, u32 *crc_p ) 914 - { 915 - struct net_local *nl = netdev_priv(dev); 916 - 917 - u32 crc = *crc_p; 918 - u32 len_field = nl->framelen + 6; /* CRC + frameno + reserved */ 919 - u8 value; 920 - 921 - if( nl->state & FL_NEED_RESEND ) 922 - len_field |= FRAME_RETRY; /* non-first attempt... */ 923 - 924 - if( nl->outpos == 0 ) 925 - len_field |= FRAME_FIRST; 926 - 927 - len_field |= (nl->state & FL_PREV_OK) ? FRAME_SENT_OK : FRAME_SENT_BAD; 928 - outb( SBNI_SIG, dev->base_addr + DAT ); 929 - 930 - value = (u8) len_field; 931 - outb( value, dev->base_addr + DAT ); 932 - crc = CRC32( value, crc ); 933 - value = (u8) (len_field >> 8); 934 - outb( value, dev->base_addr + DAT ); 935 - crc = CRC32( value, crc ); 936 - 937 - outb( nl->tx_frameno, dev->base_addr + DAT ); 938 - crc = CRC32( nl->tx_frameno, crc ); 939 - outb( 0, dev->base_addr + DAT ); 940 - crc = CRC32( 0, crc ); 941 - *crc_p = crc; 942 - } 943 - 944 - 945 - /* 946 - * if frame tail not needed (incorrect number or received twice), 947 - * it won't store, but CRC will be calculated 948 - */ 949 - 950 - static int 951 - skip_tail( unsigned int ioaddr, unsigned int tail_len, u32 crc ) 952 - { 953 - while( tail_len-- ) 954 - crc = CRC32( inb( ioaddr + DAT ), crc ); 955 - 956 - return crc == CRC32_REMAINDER; 957 - } 958 - 959 - 960 - /* 961 - * Preliminary checks if frame header is correct, calculates its CRC 962 - * and split it to simple fields 963 - */ 964 - 965 - static int 966 - check_fhdr( u32 ioaddr, u32 *framelen, u32 *frameno, u32 *ack, 967 - u32 *is_first, u32 *crc_p ) 968 - { 969 - u32 crc = *crc_p; 970 - u8 value; 971 - 972 - if( inb( ioaddr + DAT ) != SBNI_SIG ) 973 - return 0; 974 - 975 - value = inb( ioaddr + DAT ); 976 - *framelen = (u32)value; 977 - crc = CRC32( value, crc ); 978 - value = inb( ioaddr + DAT ); 979 - *framelen |= ((u32)value) << 8; 980 - crc = CRC32( value, crc ); 981 - 982 - *ack = *framelen & FRAME_ACK_MASK; 983 - *is_first = (*framelen & FRAME_FIRST) != 0; 984 - 985 - if( (*framelen &= FRAME_LEN_MASK) < 6 || 986 - *framelen > SBNI_MAX_FRAME - 3 ) 987 - return 0; 988 - 989 - value = inb( ioaddr + DAT ); 990 - *frameno = (u32)value; 991 - crc = CRC32( value, crc ); 992 - 993 - crc = CRC32( inb( ioaddr + DAT ), crc ); /* reserved byte */ 994 - *framelen -= 2; 995 - 996 - *crc_p = crc; 997 - return 1; 998 - } 999 - 1000 - 1001 - static struct sk_buff * 1002 - get_rx_buf( struct net_device *dev ) 1003 - { 1004 - /* +2 is to compensate for the alignment fixup below */ 1005 - struct sk_buff *skb = dev_alloc_skb( ETHER_MAX_LEN + 2 ); 1006 - if( !skb ) 1007 - return NULL; 1008 - 1009 - skb_reserve( skb, 2 ); /* Align IP on longword boundaries */ 1010 - return skb; 1011 - } 1012 - 1013 - 1014 - static void 1015 - indicate_pkt( struct net_device *dev ) 1016 - { 1017 - struct net_local *nl = netdev_priv(dev); 1018 - struct sk_buff *skb = nl->rx_buf_p; 1019 - 1020 - skb_put( skb, nl->inppos ); 1021 - 1022 - #ifdef CONFIG_SBNI_MULTILINE 1023 - skb->protocol = eth_type_trans( skb, nl->master ); 1024 - netif_rx( skb ); 1025 - ++nl->master->stats.rx_packets; 1026 - nl->master->stats.rx_bytes += nl->inppos; 1027 - #else 1028 - skb->protocol = eth_type_trans( skb, dev ); 1029 - netif_rx( skb ); 1030 - ++dev->stats.rx_packets; 1031 - dev->stats.rx_bytes += nl->inppos; 1032 - #endif 1033 - nl->rx_buf_p = NULL; /* protocol driver will clear this sk_buff */ 1034 - } 1035 - 1036 - 1037 - /* -------------------------------------------------------------------------- */ 1038 - 1039 - /* 1040 - * Routine checks periodically wire activity and regenerates marker if 1041 - * connect was inactive for a long time. 1042 - */ 1043 - 1044 - static void 1045 - sbni_watchdog(struct timer_list *t) 1046 - { 1047 - struct net_local *nl = from_timer(nl, t, watchdog); 1048 - struct net_device *dev = nl->watchdog_dev; 1049 - unsigned long flags; 1050 - unsigned char csr0; 1051 - 1052 - spin_lock_irqsave( &nl->lock, flags ); 1053 - 1054 - csr0 = inb( dev->base_addr + CSR0 ); 1055 - if( csr0 & RC_CHK ) { 1056 - 1057 - if( nl->timer_ticks ) { 1058 - if( csr0 & (RC_RDY | BU_EMP) ) 1059 - /* receiving not active */ 1060 - nl->timer_ticks--; 1061 - } else { 1062 - nl->in_stats.timeout_number++; 1063 - if( nl->delta_rxl ) 1064 - timeout_change_level( dev ); 1065 - 1066 - outb( *(u_char *)&nl->csr1 | PR_RES, 1067 - dev->base_addr + CSR1 ); 1068 - csr0 = inb( dev->base_addr + CSR0 ); 1069 - } 1070 - } else 1071 - nl->state &= ~FL_LINE_DOWN; 1072 - 1073 - outb( csr0 | RC_CHK, dev->base_addr + CSR0 ); 1074 - 1075 - mod_timer(t, jiffies + SBNI_TIMEOUT); 1076 - 1077 - spin_unlock_irqrestore( &nl->lock, flags ); 1078 - } 1079 - 1080 - 1081 - static unsigned char rxl_tab[] = { 1082 - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x08, 1083 - 0x0a, 0x0c, 0x0f, 0x16, 0x18, 0x1a, 0x1c, 0x1f 1084 - }; 1085 - 1086 - #define SIZE_OF_TIMEOUT_RXL_TAB 4 1087 - static unsigned char timeout_rxl_tab[] = { 1088 - 0x03, 0x05, 0x08, 0x0b 1089 - }; 1090 - 1091 - /* -------------------------------------------------------------------------- */ 1092 - 1093 - static void 1094 - card_start( struct net_device *dev ) 1095 - { 1096 - struct net_local *nl = netdev_priv(dev); 1097 - 1098 - nl->timer_ticks = CHANGE_LEVEL_START_TICKS; 1099 - nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND); 1100 - nl->state |= FL_PREV_OK; 1101 - 1102 - nl->inppos = nl->outpos = 0; 1103 - nl->wait_frameno = 0; 1104 - nl->tx_frameno = 0; 1105 - nl->framelen = 0; 1106 - 1107 - outb( *(u_char *)&nl->csr1 | PR_RES, dev->base_addr + CSR1 ); 1108 - outb( EN_INT, dev->base_addr + CSR0 ); 1109 - } 1110 - 1111 - /* -------------------------------------------------------------------------- */ 1112 - 1113 - /* Receive level auto-selection */ 1114 - 1115 - static void 1116 - change_level( struct net_device *dev ) 1117 - { 1118 - struct net_local *nl = netdev_priv(dev); 1119 - 1120 - if( nl->delta_rxl == 0 ) /* do not auto-negotiate RxL */ 1121 - return; 1122 - 1123 - if( nl->cur_rxl_index == 0 ) 1124 - nl->delta_rxl = 1; 1125 - else if( nl->cur_rxl_index == 15 ) 1126 - nl->delta_rxl = -1; 1127 - else if( nl->cur_rxl_rcvd < nl->prev_rxl_rcvd ) 1128 - nl->delta_rxl = -nl->delta_rxl; 1129 - 1130 - nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index += nl->delta_rxl ]; 1131 - inb( dev->base_addr + CSR0 ); /* needs for PCI cards */ 1132 - outb( *(u8 *)&nl->csr1, dev->base_addr + CSR1 ); 1133 - 1134 - nl->prev_rxl_rcvd = nl->cur_rxl_rcvd; 1135 - nl->cur_rxl_rcvd = 0; 1136 - } 1137 - 1138 - 1139 - static void 1140 - timeout_change_level( struct net_device *dev ) 1141 - { 1142 - struct net_local *nl = netdev_priv(dev); 1143 - 1144 - nl->cur_rxl_index = timeout_rxl_tab[ nl->timeout_rxl ]; 1145 - if( ++nl->timeout_rxl >= 4 ) 1146 - nl->timeout_rxl = 0; 1147 - 1148 - nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index ]; 1149 - inb( dev->base_addr + CSR0 ); 1150 - outb( *(unsigned char *)&nl->csr1, dev->base_addr + CSR1 ); 1151 - 1152 - nl->prev_rxl_rcvd = nl->cur_rxl_rcvd; 1153 - nl->cur_rxl_rcvd = 0; 1154 - } 1155 - 1156 - /* -------------------------------------------------------------------------- */ 1157 - 1158 - /* 1159 - * Open/initialize the board. 1160 - */ 1161 - 1162 - static int 1163 - sbni_open( struct net_device *dev ) 1164 - { 1165 - struct net_local *nl = netdev_priv(dev); 1166 - struct timer_list *w = &nl->watchdog; 1167 - 1168 - /* 1169 - * For double ISA adapters within "common irq" mode, we have to 1170 - * determine whether primary or secondary channel is initialized, 1171 - * and set the irq handler only in first case. 1172 - */ 1173 - if( dev->base_addr < 0x400 ) { /* ISA only */ 1174 - struct net_device **p = sbni_cards; 1175 - for( ; *p && p < sbni_cards + SBNI_MAX_NUM_CARDS; ++p ) 1176 - if( (*p)->irq == dev->irq && 1177 - ((*p)->base_addr == dev->base_addr + 4 || 1178 - (*p)->base_addr == dev->base_addr - 4) && 1179 - (*p)->flags & IFF_UP ) { 1180 - 1181 - ((struct net_local *) (netdev_priv(*p))) 1182 - ->second = dev; 1183 - netdev_notice(dev, "using shared irq with %s\n", 1184 - (*p)->name); 1185 - nl->state |= FL_SECONDARY; 1186 - goto handler_attached; 1187 - } 1188 - } 1189 - 1190 - if( request_irq(dev->irq, sbni_interrupt, IRQF_SHARED, dev->name, dev) ) { 1191 - netdev_err(dev, "unable to get IRQ %d\n", dev->irq); 1192 - return -EAGAIN; 1193 - } 1194 - 1195 - handler_attached: 1196 - 1197 - spin_lock( &nl->lock ); 1198 - memset( &dev->stats, 0, sizeof(struct net_device_stats) ); 1199 - memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) ); 1200 - 1201 - card_start( dev ); 1202 - 1203 - netif_start_queue( dev ); 1204 - 1205 - /* set timer watchdog */ 1206 - nl->watchdog_dev = dev; 1207 - timer_setup(w, sbni_watchdog, 0); 1208 - w->expires = jiffies + SBNI_TIMEOUT; 1209 - add_timer( w ); 1210 - 1211 - spin_unlock( &nl->lock ); 1212 - return 0; 1213 - } 1214 - 1215 - 1216 - static int 1217 - sbni_close( struct net_device *dev ) 1218 - { 1219 - struct net_local *nl = netdev_priv(dev); 1220 - 1221 - if( nl->second && nl->second->flags & IFF_UP ) { 1222 - netdev_notice(dev, "Secondary channel (%s) is active!\n", 1223 - nl->second->name); 1224 - return -EBUSY; 1225 - } 1226 - 1227 - #ifdef CONFIG_SBNI_MULTILINE 1228 - if( nl->state & FL_SLAVE ) 1229 - emancipate( dev ); 1230 - else 1231 - while( nl->link ) /* it's master device! */ 1232 - emancipate( nl->link ); 1233 - #endif 1234 - 1235 - spin_lock( &nl->lock ); 1236 - 1237 - nl->second = NULL; 1238 - drop_xmit_queue( dev ); 1239 - netif_stop_queue( dev ); 1240 - 1241 - del_timer( &nl->watchdog ); 1242 - 1243 - outb( 0, dev->base_addr + CSR0 ); 1244 - 1245 - if( !(nl->state & FL_SECONDARY) ) 1246 - free_irq( dev->irq, dev ); 1247 - nl->state &= FL_SECONDARY; 1248 - 1249 - spin_unlock( &nl->lock ); 1250 - return 0; 1251 - } 1252 - 1253 - 1254 - /* 1255 - Valid combinations in CSR0 (for probing): 1256 - 1257 - VALID_DECODER 0000,0011,1011,1010 1258 - 1259 - ; 0 ; - 1260 - TR_REQ ; 1 ; + 1261 - TR_RDY ; 2 ; - 1262 - TR_RDY TR_REQ ; 3 ; + 1263 - BU_EMP ; 4 ; + 1264 - BU_EMP TR_REQ ; 5 ; + 1265 - BU_EMP TR_RDY ; 6 ; - 1266 - BU_EMP TR_RDY TR_REQ ; 7 ; + 1267 - RC_RDY ; 8 ; + 1268 - RC_RDY TR_REQ ; 9 ; + 1269 - RC_RDY TR_RDY ; 10 ; - 1270 - RC_RDY TR_RDY TR_REQ ; 11 ; - 1271 - RC_RDY BU_EMP ; 12 ; - 1272 - RC_RDY BU_EMP TR_REQ ; 13 ; - 1273 - RC_RDY BU_EMP TR_RDY ; 14 ; - 1274 - RC_RDY BU_EMP TR_RDY TR_REQ ; 15 ; - 1275 - */ 1276 - 1277 - #define VALID_DECODER (2 + 8 + 0x10 + 0x20 + 0x80 + 0x100 + 0x200) 1278 - 1279 - 1280 - static int 1281 - sbni_card_probe( unsigned long ioaddr ) 1282 - { 1283 - unsigned char csr0; 1284 - 1285 - csr0 = inb( ioaddr + CSR0 ); 1286 - if( csr0 != 0xff && csr0 != 0x00 ) { 1287 - csr0 &= ~EN_INT; 1288 - if( csr0 & BU_EMP ) 1289 - csr0 |= EN_INT; 1290 - 1291 - if( VALID_DECODER & (1 << (csr0 >> 4)) ) 1292 - return 0; 1293 - } 1294 - 1295 - return -ENODEV; 1296 - } 1297 - 1298 - /* -------------------------------------------------------------------------- */ 1299 - 1300 - static int 1301 - sbni_siocdevprivate(struct net_device *dev, struct ifreq *ifr, void __user *data, int cmd) 1302 - { 1303 - struct net_local *nl = netdev_priv(dev); 1304 - struct sbni_flags flags; 1305 - int error = 0; 1306 - 1307 - #ifdef CONFIG_SBNI_MULTILINE 1308 - struct net_device *slave_dev; 1309 - char slave_name[ 8 ]; 1310 - #endif 1311 - 1312 - switch( cmd ) { 1313 - case SIOCDEVGETINSTATS : 1314 - if (copy_to_user(data, &nl->in_stats, 1315 - sizeof(struct sbni_in_stats))) 1316 - error = -EFAULT; 1317 - break; 1318 - 1319 - case SIOCDEVRESINSTATS : 1320 - if (!capable(CAP_NET_ADMIN)) 1321 - return -EPERM; 1322 - memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) ); 1323 - break; 1324 - 1325 - case SIOCDEVGHWSTATE : 1326 - flags.mac_addr = *(u32 *)(dev->dev_addr + 3); 1327 - flags.rate = nl->csr1.rate; 1328 - flags.slow_mode = (nl->state & FL_SLOW_MODE) != 0; 1329 - flags.rxl = nl->cur_rxl_index; 1330 - flags.fixed_rxl = nl->delta_rxl == 0; 1331 - 1332 - if (copy_to_user(data, &flags, sizeof(flags))) 1333 - error = -EFAULT; 1334 - break; 1335 - 1336 - case SIOCDEVSHWSTATE : 1337 - if (!capable(CAP_NET_ADMIN)) 1338 - return -EPERM; 1339 - 1340 - spin_lock( &nl->lock ); 1341 - flags = *(struct sbni_flags*) &ifr->ifr_ifru; 1342 - if( flags.fixed_rxl ) { 1343 - nl->delta_rxl = 0; 1344 - nl->cur_rxl_index = flags.rxl; 1345 - } else { 1346 - nl->delta_rxl = DEF_RXL_DELTA; 1347 - nl->cur_rxl_index = DEF_RXL; 1348 - } 1349 - 1350 - nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index ]; 1351 - nl->csr1.rate = flags.rate; 1352 - outb( *(u8 *)&nl->csr1 | PR_RES, dev->base_addr + CSR1 ); 1353 - spin_unlock( &nl->lock ); 1354 - break; 1355 - 1356 - #ifdef CONFIG_SBNI_MULTILINE 1357 - 1358 - case SIOCDEVENSLAVE : 1359 - if (!capable(CAP_NET_ADMIN)) 1360 - return -EPERM; 1361 - 1362 - if (copy_from_user(slave_name, data, sizeof(slave_name))) 1363 - return -EFAULT; 1364 - slave_dev = dev_get_by_name(&init_net, slave_name ); 1365 - if( !slave_dev || !(slave_dev->flags & IFF_UP) ) { 1366 - netdev_err(dev, "trying to enslave non-active device %s\n", 1367 - slave_name); 1368 - if (slave_dev) 1369 - dev_put(slave_dev); 1370 - return -EPERM; 1371 - } 1372 - 1373 - return enslave( dev, slave_dev ); 1374 - 1375 - case SIOCDEVEMANSIPATE : 1376 - if (!capable(CAP_NET_ADMIN)) 1377 - return -EPERM; 1378 - 1379 - return emancipate( dev ); 1380 - 1381 - #endif /* CONFIG_SBNI_MULTILINE */ 1382 - 1383 - default : 1384 - return -EOPNOTSUPP; 1385 - } 1386 - 1387 - return error; 1388 - } 1389 - 1390 - 1391 - #ifdef CONFIG_SBNI_MULTILINE 1392 - 1393 - static int 1394 - enslave( struct net_device *dev, struct net_device *slave_dev ) 1395 - { 1396 - struct net_local *nl = netdev_priv(dev); 1397 - struct net_local *snl = netdev_priv(slave_dev); 1398 - 1399 - if( nl->state & FL_SLAVE ) /* This isn't master or free device */ 1400 - return -EBUSY; 1401 - 1402 - if( snl->state & FL_SLAVE ) /* That was already enslaved */ 1403 - return -EBUSY; 1404 - 1405 - spin_lock( &nl->lock ); 1406 - spin_lock( &snl->lock ); 1407 - 1408 - /* append to list */ 1409 - snl->link = nl->link; 1410 - nl->link = slave_dev; 1411 - snl->master = dev; 1412 - snl->state |= FL_SLAVE; 1413 - 1414 - /* Summary statistics of MultiLine operation will be stored 1415 - in master's counters */ 1416 - memset( &slave_dev->stats, 0, sizeof(struct net_device_stats) ); 1417 - netif_stop_queue( slave_dev ); 1418 - netif_wake_queue( dev ); /* Now we are able to transmit */ 1419 - 1420 - spin_unlock( &snl->lock ); 1421 - spin_unlock( &nl->lock ); 1422 - netdev_notice(dev, "slave device (%s) attached\n", slave_dev->name); 1423 - return 0; 1424 - } 1425 - 1426 - 1427 - static int 1428 - emancipate( struct net_device *dev ) 1429 - { 1430 - struct net_local *snl = netdev_priv(dev); 1431 - struct net_device *p = snl->master; 1432 - struct net_local *nl = netdev_priv(p); 1433 - 1434 - if( !(snl->state & FL_SLAVE) ) 1435 - return -EINVAL; 1436 - 1437 - spin_lock( &nl->lock ); 1438 - spin_lock( &snl->lock ); 1439 - drop_xmit_queue( dev ); 1440 - 1441 - /* exclude from list */ 1442 - for(;;) { /* must be in list */ 1443 - struct net_local *t = netdev_priv(p); 1444 - if( t->link == dev ) { 1445 - t->link = snl->link; 1446 - break; 1447 - } 1448 - p = t->link; 1449 - } 1450 - 1451 - snl->link = NULL; 1452 - snl->master = dev; 1453 - snl->state &= ~FL_SLAVE; 1454 - 1455 - netif_start_queue( dev ); 1456 - 1457 - spin_unlock( &snl->lock ); 1458 - spin_unlock( &nl->lock ); 1459 - 1460 - dev_put( dev ); 1461 - return 0; 1462 - } 1463 - 1464 - #endif 1465 - 1466 - static void 1467 - set_multicast_list( struct net_device *dev ) 1468 - { 1469 - return; /* sbni always operate in promiscuos mode */ 1470 - } 1471 - 1472 - 1473 - #ifdef MODULE 1474 - module_param_hw_array(io, int, ioport, NULL, 0); 1475 - module_param_hw_array(irq, int, irq, NULL, 0); 1476 - module_param_array(baud, int, NULL, 0); 1477 - module_param_array(rxl, int, NULL, 0); 1478 - module_param_array(mac, int, NULL, 0); 1479 - module_param(skip_pci_probe, bool, 0); 1480 - 1481 - MODULE_LICENSE("GPL"); 1482 - 1483 - 1484 - int __init init_module( void ) 1485 - { 1486 - struct net_device *dev; 1487 - int err; 1488 - 1489 - while( num < SBNI_MAX_NUM_CARDS ) { 1490 - dev = alloc_netdev(sizeof(struct net_local), "sbni%d", 1491 - NET_NAME_UNKNOWN, sbni_devsetup); 1492 - if( !dev) 1493 - break; 1494 - 1495 - sprintf( dev->name, "sbni%d", num ); 1496 - 1497 - err = sbni_init(dev); 1498 - if (err) { 1499 - free_netdev(dev); 1500 - break; 1501 - } 1502 - 1503 - if( register_netdev( dev ) ) { 1504 - release_region( dev->base_addr, SBNI_IO_EXTENT ); 1505 - free_netdev( dev ); 1506 - break; 1507 - } 1508 - } 1509 - 1510 - return *sbni_cards ? 0 : -ENODEV; 1511 - } 1512 - 1513 - void 1514 - cleanup_module(void) 1515 - { 1516 - int i; 1517 - 1518 - for (i = 0; i < SBNI_MAX_NUM_CARDS; ++i) { 1519 - struct net_device *dev = sbni_cards[i]; 1520 - if (dev != NULL) { 1521 - unregister_netdev(dev); 1522 - release_region(dev->base_addr, SBNI_IO_EXTENT); 1523 - free_netdev(dev); 1524 - } 1525 - } 1526 - } 1527 - 1528 - #else /* MODULE */ 1529 - 1530 - static int __init 1531 - sbni_setup( char *p ) 1532 - { 1533 - int n, parm; 1534 - 1535 - if( *p++ != '(' ) 1536 - goto bad_param; 1537 - 1538 - for( n = 0, parm = 0; *p && n < 8; ) { 1539 - (*dest[ parm ])[ n ] = simple_strtoul( p, &p, 0 ); 1540 - if( !*p || *p == ')' ) 1541 - return 1; 1542 - if( *p == ';' ) { 1543 - ++p; 1544 - ++n; 1545 - parm = 0; 1546 - } else if( *p++ != ',' ) { 1547 - break; 1548 - } else { 1549 - if( ++parm >= 5 ) 1550 - break; 1551 - } 1552 - } 1553 - bad_param: 1554 - pr_err("Error in sbni kernel parameter!\n"); 1555 - return 0; 1556 - } 1557 - 1558 - __setup( "sbni=", sbni_setup ); 1559 - 1560 - #endif /* MODULE */ 1561 - 1562 - /* -------------------------------------------------------------------------- */ 1563 - 1564 - static u32 1565 - calc_crc32( u32 crc, u8 *p, u32 len ) 1566 - { 1567 - while( len-- ) 1568 - crc = CRC32( *p++, crc ); 1569 - 1570 - return crc; 1571 - } 1572 - 1573 - static u32 crc32tab[] __attribute__ ((aligned(8))) = { 1574 - 0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37, 1575 - 0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E, 1576 - 0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605, 1577 - 0xDBB4A3A6, 0xACB39330, 0x35BAC28A, 0x42BDF21C, 1578 - 0xCFB5FFE9, 0xB8B2CF7F, 0x21BB9EC5, 0x56BCAE53, 1579 - 0xC8D83BF0, 0xBFDF0B66, 0x26D65ADC, 0x51D16A4A, 1580 - 0xC16E77DB, 0xB669474D, 0x2F6016F7, 0x58672661, 1581 - 0xC603B3C2, 0xB1048354, 0x280DD2EE, 0x5F0AE278, 1582 - 0xE96CCF45, 0x9E6BFFD3, 0x0762AE69, 0x70659EFF, 1583 - 0xEE010B5C, 0x99063BCA, 0x000F6A70, 0x77085AE6, 1584 - 0xE7B74777, 0x90B077E1, 0x09B9265B, 0x7EBE16CD, 1585 - 0xE0DA836E, 0x97DDB3F8, 0x0ED4E242, 0x79D3D2D4, 1586 - 0xF4DBDF21, 0x83DCEFB7, 0x1AD5BE0D, 0x6DD28E9B, 1587 - 0xF3B61B38, 0x84B12BAE, 0x1DB87A14, 0x6ABF4A82, 1588 - 0xFA005713, 0x8D076785, 0x140E363F, 0x630906A9, 1589 - 0xFD6D930A, 0x8A6AA39C, 0x1363F226, 0x6464C2B0, 1590 - 0xA4DEAE1D, 0xD3D99E8B, 0x4AD0CF31, 0x3DD7FFA7, 1591 - 0xA3B36A04, 0xD4B45A92, 0x4DBD0B28, 0x3ABA3BBE, 1592 - 0xAA05262F, 0xDD0216B9, 0x440B4703, 0x330C7795, 1593 - 0xAD68E236, 0xDA6FD2A0, 0x4366831A, 0x3461B38C, 1594 - 0xB969BE79, 0xCE6E8EEF, 0x5767DF55, 0x2060EFC3, 1595 - 0xBE047A60, 0xC9034AF6, 0x500A1B4C, 0x270D2BDA, 1596 - 0xB7B2364B, 0xC0B506DD, 0x59BC5767, 0x2EBB67F1, 1597 - 0xB0DFF252, 0xC7D8C2C4, 0x5ED1937E, 0x29D6A3E8, 1598 - 0x9FB08ED5, 0xE8B7BE43, 0x71BEEFF9, 0x06B9DF6F, 1599 - 0x98DD4ACC, 0xEFDA7A5A, 0x76D32BE0, 0x01D41B76, 1600 - 0x916B06E7, 0xE66C3671, 0x7F6567CB, 0x0862575D, 1601 - 0x9606C2FE, 0xE101F268, 0x7808A3D2, 0x0F0F9344, 1602 - 0x82079EB1, 0xF500AE27, 0x6C09FF9D, 0x1B0ECF0B, 1603 - 0x856A5AA8, 0xF26D6A3E, 0x6B643B84, 0x1C630B12, 1604 - 0x8CDC1683, 0xFBDB2615, 0x62D277AF, 0x15D54739, 1605 - 0x8BB1D29A, 0xFCB6E20C, 0x65BFB3B6, 0x12B88320, 1606 - 0x3FBA6CAD, 0x48BD5C3B, 0xD1B40D81, 0xA6B33D17, 1607 - 0x38D7A8B4, 0x4FD09822, 0xD6D9C998, 0xA1DEF90E, 1608 - 0x3161E49F, 0x4666D409, 0xDF6F85B3, 0xA868B525, 1609 - 0x360C2086, 0x410B1010, 0xD80241AA, 0xAF05713C, 1610 - 0x220D7CC9, 0x550A4C5F, 0xCC031DE5, 0xBB042D73, 1611 - 0x2560B8D0, 0x52678846, 0xCB6ED9FC, 0xBC69E96A, 1612 - 0x2CD6F4FB, 0x5BD1C46D, 0xC2D895D7, 0xB5DFA541, 1613 - 0x2BBB30E2, 0x5CBC0074, 0xC5B551CE, 0xB2B26158, 1614 - 0x04D44C65, 0x73D37CF3, 0xEADA2D49, 0x9DDD1DDF, 1615 - 0x03B9887C, 0x74BEB8EA, 0xEDB7E950, 0x9AB0D9C6, 1616 - 0x0A0FC457, 0x7D08F4C1, 0xE401A57B, 0x930695ED, 1617 - 0x0D62004E, 0x7A6530D8, 0xE36C6162, 0x946B51F4, 1618 - 0x19635C01, 0x6E646C97, 0xF76D3D2D, 0x806A0DBB, 1619 - 0x1E0E9818, 0x6909A88E, 0xF000F934, 0x8707C9A2, 1620 - 0x17B8D433, 0x60BFE4A5, 0xF9B6B51F, 0x8EB18589, 1621 - 0x10D5102A, 0x67D220BC, 0xFEDB7106, 0x89DC4190, 1622 - 0x49662D3D, 0x3E611DAB, 0xA7684C11, 0xD06F7C87, 1623 - 0x4E0BE924, 0x390CD9B2, 0xA0058808, 0xD702B89E, 1624 - 0x47BDA50F, 0x30BA9599, 0xA9B3C423, 0xDEB4F4B5, 1625 - 0x40D06116, 0x37D75180, 0xAEDE003A, 0xD9D930AC, 1626 - 0x54D13D59, 0x23D60DCF, 0xBADF5C75, 0xCDD86CE3, 1627 - 0x53BCF940, 0x24BBC9D6, 0xBDB2986C, 0xCAB5A8FA, 1628 - 0x5A0AB56B, 0x2D0D85FD, 0xB404D447, 0xC303E4D1, 1629 - 0x5D677172, 0x2A6041E4, 0xB369105E, 0xC46E20C8, 1630 - 0x72080DF5, 0x050F3D63, 0x9C066CD9, 0xEB015C4F, 1631 - 0x7565C9EC, 0x0262F97A, 0x9B6BA8C0, 0xEC6C9856, 1632 - 0x7CD385C7, 0x0BD4B551, 0x92DDE4EB, 0xE5DAD47D, 1633 - 0x7BBE41DE, 0x0CB97148, 0x95B020F2, 0xE2B71064, 1634 - 0x6FBF1D91, 0x18B82D07, 0x81B17CBD, 0xF6B64C2B, 1635 - 0x68D2D988, 0x1FD5E91E, 0x86DCB8A4, 0xF1DB8832, 1636 - 0x616495A3, 0x1663A535, 0x8F6AF48F, 0xF86DC419, 1637 - 0x660951BA, 0x110E612C, 0x88073096, 0xFF000000 1638 - }; 1639 -
-147
drivers/net/wan/sbni.h
··· 1 - /* sbni.h: definitions for a Granch SBNI12 driver, version 5.0.0 2 - * Written 2001 Denis I.Timofeev (timofeev@granch.ru) 3 - * This file is distributed under the GNU GPL 4 - */ 5 - 6 - #ifndef SBNI_H 7 - #define SBNI_H 8 - 9 - #ifdef SBNI_DEBUG 10 - #define DP( A ) A 11 - #else 12 - #define DP( A ) 13 - #endif 14 - 15 - 16 - /* We don't have official vendor id yet... */ 17 - #define SBNI_PCI_VENDOR 0x55 18 - #define SBNI_PCI_DEVICE 0x9f 19 - 20 - #define ISA_MODE 0x00 21 - #define PCI_MODE 0x01 22 - 23 - #define SBNI_IO_EXTENT 4 24 - 25 - enum sbni_reg { 26 - CSR0 = 0, 27 - CSR1 = 1, 28 - DAT = 2 29 - }; 30 - 31 - /* CSR0 mapping */ 32 - enum { 33 - BU_EMP = 0x02, 34 - RC_CHK = 0x04, 35 - CT_ZER = 0x08, 36 - TR_REQ = 0x10, 37 - TR_RDY = 0x20, 38 - EN_INT = 0x40, 39 - RC_RDY = 0x80 40 - }; 41 - 42 - 43 - /* CSR1 mapping */ 44 - #define PR_RES 0x80 45 - 46 - struct sbni_csr1 { 47 - #ifdef __LITTLE_ENDIAN_BITFIELD 48 - u8 rxl : 5; 49 - u8 rate : 2; 50 - u8 : 1; 51 - #else 52 - u8 : 1; 53 - u8 rate : 2; 54 - u8 rxl : 5; 55 - #endif 56 - }; 57 - 58 - /* fields in frame header */ 59 - #define FRAME_ACK_MASK (unsigned short)0x7000 60 - #define FRAME_LEN_MASK (unsigned short)0x03FF 61 - #define FRAME_FIRST (unsigned short)0x8000 62 - #define FRAME_RETRY (unsigned short)0x0800 63 - 64 - #define FRAME_SENT_BAD (unsigned short)0x4000 65 - #define FRAME_SENT_OK (unsigned short)0x3000 66 - 67 - 68 - /* state flags */ 69 - enum { 70 - FL_WAIT_ACK = 0x01, 71 - FL_NEED_RESEND = 0x02, 72 - FL_PREV_OK = 0x04, 73 - FL_SLOW_MODE = 0x08, 74 - FL_SECONDARY = 0x10, 75 - #ifdef CONFIG_SBNI_MULTILINE 76 - FL_SLAVE = 0x20, 77 - #endif 78 - FL_LINE_DOWN = 0x40 79 - }; 80 - 81 - 82 - enum { 83 - DEFAULT_IOBASEADDR = 0x210, 84 - DEFAULT_INTERRUPTNUMBER = 5, 85 - DEFAULT_RATE = 0, 86 - DEFAULT_FRAME_LEN = 1012 87 - }; 88 - 89 - #define DEF_RXL_DELTA -1 90 - #define DEF_RXL 0xf 91 - 92 - #define SBNI_SIG 0x5a 93 - 94 - #define SBNI_MIN_LEN 60 /* Shortest Ethernet frame without FCS */ 95 - #define SBNI_MAX_FRAME 1023 96 - #define ETHER_MAX_LEN 1518 97 - 98 - #define SBNI_TIMEOUT (HZ/10) 99 - 100 - #define TR_ERROR_COUNT 32 101 - #define CHANGE_LEVEL_START_TICKS 4 102 - 103 - #define SBNI_MAX_NUM_CARDS 16 104 - 105 - /* internal SBNI-specific statistics */ 106 - struct sbni_in_stats { 107 - u32 all_rx_number; 108 - u32 bad_rx_number; 109 - u32 timeout_number; 110 - u32 all_tx_number; 111 - u32 resend_tx_number; 112 - }; 113 - 114 - /* SBNI ioctl params */ 115 - #define SIOCDEVGETINSTATS SIOCDEVPRIVATE 116 - #define SIOCDEVRESINSTATS SIOCDEVPRIVATE+1 117 - #define SIOCDEVGHWSTATE SIOCDEVPRIVATE+2 118 - #define SIOCDEVSHWSTATE SIOCDEVPRIVATE+3 119 - #define SIOCDEVENSLAVE SIOCDEVPRIVATE+4 120 - #define SIOCDEVEMANSIPATE SIOCDEVPRIVATE+5 121 - 122 - 123 - /* data packet for SIOCDEVGHWSTATE/SIOCDEVSHWSTATE ioctl requests */ 124 - struct sbni_flags { 125 - u32 rxl : 4; 126 - u32 rate : 2; 127 - u32 fixed_rxl : 1; 128 - u32 slow_mode : 1; 129 - u32 mac_addr : 24; 130 - }; 131 - 132 - /* 133 - * CRC-32 stuff 134 - */ 135 - #define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00FFFFFF)) 136 - /* CRC generator 0xEDB88320 */ 137 - /* CRC remainder 0x2144DF1C */ 138 - /* CRC initial value 0x00000000 */ 139 - #define CRC32_REMAINDER 0x2144DF1C 140 - #define CRC32_INITIAL 0x00000000 141 - 142 - #ifndef __initdata 143 - #define __initdata 144 - #endif 145 - 146 - #endif 147 -
-3
include/net/Space.h
··· 18 18 19 19 /* Fibre Channel adapters */ 20 20 int iph5526_probe(struct net_device *dev); 21 - 22 - /* SBNI adapters */ 23 - int sbni_probe(int unit);