root/drivers/net/hp100.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. hp100_probe
  2. hp100_probe1
  3. hp100_open
  4. hp100_close
  5. hp100_start_xmit
  6. hp100_rx
  7. hp100_get_stats
  8. hp100_update_stats
  9. hp100_clear_stats
  10. hp100_set_multicast_list
  11. hp100_interrupt
  12. hp100_start_interface
  13. hp100_stop_interface
  14. hp100_load_eeprom
  15. hp100_sense_lan
  16. hp100_down_vg_link
  17. hp100_login_to_vg_hub
  18. init_module
  19. cleanup_module

   1 /*
   2  * hp100.c: Hewlett Packard HP10/100VG ANY LAN ethernet driver for Linux.
   3  *
   4  * Author:  Jaroslav Kysela, <perex@pf.jcu.cz>
   5  *
   6  * Supports only the following Hewlett Packard cards:
   7  *
   8  *      HP J2577        10/100 EISA card with REVA Cascade chip
   9  *      HP J2573        10/100 ISA card with REVA Cascade chip
  10  *      HP 27248B       10 only EISA card with Cascade chip
  11  *      HP J2577        10/100 EISA card with Cascade chip
  12  *      HP J2573        10/100 ISA card with Cascade chip
  13  *      HP J2585        10/100 PCI card
  14  *
  15  * Other ATT2MD01 Chip based boards might be supported in the future
  16  * (there are some minor changes needed).
  17  *
  18  * This driver is based on the 'hpfepkt' crynwr packet driver.
  19  *
  20  * This source/code is public free; you can distribute it and/or modify 
  21  * it under terms of the GNU General Public License (published by the
  22  * Free Software Foundation) either version two of this License, or any 
  23  * later version.
  24  * ----------------------------------------------------------------------------
  25  *
  26  * Note: Some routines (interrupt handling, transmit) assumes that  
  27  *       there is the PERFORMANCE page selected...
  28  *
  29  * ----------------------------------------------------------------------------
  30  *
  31  * If you are going to use the module version of this driver, you may
  32  * change this values at the "insert time" :
  33  *
  34  *   Variable                   Description
  35  *
  36  *   hp100_rx_ratio             Range 1-99 - onboard memory used for RX
  37  *                              packets in %.
  38  *   hp100_priority_tx          If this variable is nonzero - all outgoing
  39  *                              packets will be transmitted as priority.
  40  *   hp100_port                 Adapter port (for example 0x380).
  41  *
  42  * ----------------------------------------------------------------------------
  43  * MY BEST REGARDS GOING TO:
  44  *
  45  * IPEX s.r.o which lend me two HP J2573 cards and
  46  * the HP AdvanceStack 100VG Hub-15 for debugging.
  47  *
  48  * Russel Nellson <nelson@crynwr.com> for help with obtaining sources
  49  * of the 'hpfepkt' packet driver.
  50  *
  51  * Also thanks to Abacus Electric s.r.o which let me to use their 
  52  * motherboard for my second computer.
  53  *
  54  * ----------------------------------------------------------------------------
  55  *
  56  * TO DO:
  57  * ======
  58  *       - ioctl handling - some runtime setup things
  59  *       - 100Mb/s Voice Grade AnyLAN network adapter/hub services support
  60  *              - 802.5 frames
  61  *              - promiscuous mode
  62  *              - bridge mode
  63  *              - cascaded repeater mode
  64  *              - 100Mbit MAC
  65  *
  66  * Revision history:
  67  * =================
  68  * 
  69  *    Version   Date        Description
  70  *
  71  *      0.1     14-May-95   Initial writing. ALPHA code was released.
  72  *                          Only HP J2573 on 10Mb/s (two machines) tested.
  73  *      0.11    14-Jun-95   Reset interface bug fixed?
  74  *                          Little bug in hp100_close function fixed.
  75  *                          100Mb/s connection debugged.
  76  *      0.12    14-Jul-95   Link down is now handled better.
  77  *      0.20    01-Aug-95   Added PCI support for HP J2585A card.
  78  *                          Statistics bug fixed.
  79  *      0.21    04-Aug-95   Memory mapped access support for PCI card.
  80  *                          Added priority transmit support for 100Mb/s
  81  *                          Voice Grade AnyLAN network.
  82  *
  83  */
  84 
  85 #include <linux/module.h>
  86 
  87 #include <linux/kernel.h>
  88 #include <linux/sched.h>
  89 #include <linux/string.h>
  90 #include <linux/errno.h>
  91 #include <linux/ioport.h>
  92 #include <linux/malloc.h>
  93 #include <linux/interrupt.h>
  94 #include <linux/pci.h>
  95 #include <linux/bios32.h>
  96 #include <asm/bitops.h>
  97 #include <asm/io.h>
  98 
  99 #include <linux/netdevice.h>
 100 #include <linux/etherdevice.h>
 101 #include <linux/skbuff.h>
 102 
 103 #include <linux/types.h>
 104 #include <linux/config.h>       /* for CONFIG_PCI */
 105 
 106 #include "hp100.h"
 107 
 108 /*
 109  *  defines
 110  */
 111 
 112 #define HP100_BUS_ISA           0
 113 #define HP100_BUS_EISA          1
 114 #define HP100_BUS_PCI           2
 115 
 116 #define HP100_REGION_SIZE       0x20
 117 
 118 #define HP100_MAX_PACKET_SIZE   (1536+4)
 119 #define HP100_MIN_PACKET_SIZE   60
 120 
 121 #ifndef HP100_DEFAULT_RX_RATIO
 122 /* default - 65% onboard memory on the card are used for RX packets */
 123 #define HP100_DEFAULT_RX_RATIO  65
 124 #endif
 125 
 126 #ifndef HP100_DEFAULT_PRIORITY_TX
 127 /* default - don't enable transmit outgoing packets as priority */
 128 #define HP100_DEFAULT_PRIORITY_TX 0
 129 #endif
 130 
 131 /*
 132  *  structures
 133  */
 134 
 135 struct hp100_eisa_id {
 136   u_int id;
 137   const char *name;
 138   u_char bus;
 139 };
 140 
 141 struct hp100_private {
 142   struct hp100_eisa_id *id;
 143   u_short soft_model;
 144   u_int memory_size;
 145   u_short rx_ratio;                 /* 1 - 99 */
 146   u_short priority_tx;              /* != 0 - priority tx */
 147   short mem_mapped;                 /* memory mapped access */
 148   u_char *mem_ptr_virt;             /* virtual memory mapped area, maybe NULL */
 149   u_char *mem_ptr_phys;             /* physical memory mapped area */
 150   short lan_type;                   /* 10Mb/s, 100Mb/s or -1 (error) */
 151   int hub_status;                   /* login to hub was successfull? */
 152   u_char mac1_mode;
 153   u_char mac2_mode;
 154   struct enet_statistics stats;
 155 };
 156 
 157 /*
 158  *  variables
 159  */
 160  
 161 static struct hp100_eisa_id hp100_eisa_ids[] = {
 162 
 163   /* 10/100 EISA card with REVA Cascade chip */
 164   { 0x080F1F022, "HP J2577 rev A", HP100_BUS_EISA }, 
 165 
 166   /* 10/100 ISA card with REVA Cascade chip */
 167   { 0x050F1F022, "HP J2573 rev A", HP100_BUS_ISA },
 168 
 169   /* 10 only EISA card with Cascade chip */
 170   { 0x02019F022, "HP 27248B",      HP100_BUS_EISA }, 
 171 
 172   /* 10/100 EISA card with Cascade chip */
 173   { 0x04019F022, "HP J2577",       HP100_BUS_EISA },
 174 
 175   /* 10/100 ISA card with Cascade chip */
 176   { 0x05019F022, "HP J2573",       HP100_BUS_ISA },
 177 
 178   /* 10/100 PCI card */
 179   /* Note: ID for this card is same as PCI vendor/device numbers. */
 180   { 0x01030103c, "HP J2585",       HP100_BUS_PCI },
 181 };
 182 
 183 int hp100_rx_ratio = HP100_DEFAULT_RX_RATIO;
 184 int hp100_priority_tx = HP100_DEFAULT_PRIORITY_TX;
 185 
 186 /*
 187  *  prototypes
 188  */
 189 
 190 static int hp100_probe1( struct device *dev, int ioaddr, int bus );
 191 static int hp100_open( struct device *dev );
 192 static int hp100_close( struct device *dev );
 193 static int hp100_start_xmit( struct sk_buff *skb, struct device *dev );
 194 static void hp100_rx( struct device *dev );
 195 static struct enet_statistics *hp100_get_stats( struct device *dev );
 196 static void hp100_update_stats( struct device *dev );
 197 static void hp100_clear_stats( int ioaddr );
 198 static void hp100_set_multicast_list( struct device *dev);
 199 static void hp100_interrupt( int irq, struct pt_regs *regs );
 200 
 201 static void hp100_start_interface( struct device *dev );
 202 static void hp100_stop_interface( struct device *dev );
 203 static void hp100_load_eeprom( struct device *dev );
 204 static int hp100_sense_lan( struct device *dev );
 205 static int hp100_login_to_vg_hub( struct device *dev );
 206 static int hp100_down_vg_link( struct device *dev );
 207 
 208 /*
 209  *  probe functions
 210  */
 211  
 212 int hp100_probe( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 213 {
 214   int base_addr = dev ? dev -> base_addr : 0;
 215   int ioaddr;
 216 #ifdef CONFIG_PCI
 217   int pci_start_index = 0;
 218 #endif
 219 
 220   if ( base_addr > 0xff )       /* Check a single specified location. */
 221     {
 222       if ( check_region( base_addr, HP100_REGION_SIZE ) ) return -EINVAL;
 223       if ( base_addr < 0x400 )
 224         return hp100_probe1( dev, base_addr, HP100_BUS_ISA );
 225        else
 226         return hp100_probe1( dev, base_addr, HP100_BUS_EISA );
 227     }
 228    else 
 229 #ifdef CONFIG_PCI
 230   if ( base_addr > 0 && base_addr < 8 + 1 )
 231     pci_start_index = 0x100 | ( base_addr - 1 );
 232    else
 233 #endif
 234     if ( base_addr != 0 ) return -ENXIO;
 235 
 236   /* at first - scan PCI bus(es) */
 237   
 238 #ifdef CONFIG_PCI
 239   if ( pcibios_present() )
 240     {
 241       int pci_index;
 242       
 243 #ifdef HP100_DEBUG_PCI
 244       printk( "hp100: PCI BIOS is present, checking for devices..\n" );
 245 #endif
 246       for ( pci_index = pci_start_index & 7; pci_index < 8; pci_index++ )
 247         {
 248           u_char pci_bus, pci_device_fn;
 249           u_short pci_command;
 250           
 251           if ( pcibios_find_device( PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585A,
 252                                     pci_index, &pci_bus,
 253                                     &pci_device_fn ) != 0 ) break;
 254           pcibios_read_config_dword( pci_bus, pci_device_fn,
 255                                      PCI_BASE_ADDRESS_0, &ioaddr );
 256                                          
 257           ioaddr &= ~3;         /* remove I/O space marker in bit 0. */
 258               
 259           if ( check_region( ioaddr, HP100_REGION_SIZE ) ) continue;
 260               
 261           pcibios_read_config_word( pci_bus, pci_device_fn,
 262                                     PCI_COMMAND, &pci_command );
 263           if ( !( pci_command & PCI_COMMAND_MASTER ) )
 264             {
 265 #ifdef HP100_DEBUG_PCI
 266               printk( "hp100: PCI Master Bit has not been set. Setting...\n" );
 267 #endif
 268               pci_command |= PCI_COMMAND_MASTER;
 269               pcibios_write_config_word( pci_bus, pci_device_fn,
 270                                          PCI_COMMAND, pci_command );
 271             }
 272 #ifdef HP100_DEBUG_PCI
 273           printk( "hp100: PCI adapter found at 0x%x\n", ioaddr );
 274 #endif
 275           if ( hp100_probe1( dev, ioaddr, HP100_BUS_PCI ) == 0 ) return 0;
 276         }
 277     }
 278   if ( pci_start_index > 0 ) return -ENODEV;
 279 #endif /* CONFIG_PCI */
 280          
 281   /* at second - probe all EISA possible port regions (if EISA bus present) */
 282   
 283   for ( ioaddr = 0x1c38; EISA_bus && ioaddr < 0x10000; ioaddr += 0x400 )
 284     {
 285       if ( check_region( ioaddr, HP100_REGION_SIZE ) ) continue;
 286       if ( hp100_probe1( dev, ioaddr, HP100_BUS_EISA ) == 0 ) return 0;
 287     }
 288          
 289   /* at third - probe all ISA possible port regions */
 290          
 291   for ( ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x20 )
 292     {
 293       if ( check_region( ioaddr, HP100_REGION_SIZE ) ) continue;
 294       if ( hp100_probe1( dev, ioaddr, HP100_BUS_ISA ) == 0 ) return 0;
 295     }
 296                                                                             
 297   return -ENODEV;
 298 }
 299 
 300 static int hp100_probe1( struct device *dev, int ioaddr, int bus )
     /* [previous][next][first][last][top][bottom][index][help] */
 301 {
 302   int i;
 303   u_char uc, uc_1;
 304   u_int eisa_id;
 305   short mem_mapped;
 306   u_char *mem_ptr_phys, *mem_ptr_virt;
 307   struct hp100_private *lp;
 308   struct hp100_eisa_id *eid;
 309 
 310   if ( dev == NULL )
 311     {
 312 #ifdef HP100_DEBUG
 313       printk( "hp100_probe1: dev == NULL ?\n" );
 314 #endif
 315       return EIO;
 316     }
 317 
 318   if ( bus != HP100_BUS_PCI )           /* don't check PCI cards again */
 319     if ( inb( ioaddr + 0 ) != HP100_HW_ID_0 ||
 320          inb( ioaddr + 1 ) != HP100_HW_ID_1 ||
 321          ( inb( ioaddr + 2 ) & 0xf0 ) != HP100_HW_ID_2_REVA ||
 322          inb( ioaddr + 3 ) != HP100_HW_ID_3 ) 
 323        return -ENODEV;
 324 
 325   dev -> base_addr = ioaddr;
 326 
 327 #ifdef HP100_DEBUG_PROBE1
 328   printk( "hp100_probe1: card found at port 0x%x\n", ioaddr );
 329 #endif
 330 
 331   hp100_page( ID_MAC_ADDR );
 332   for ( i = uc = eisa_id = 0; i < 4; i++ )
 333     {
 334       eisa_id >>= 8;
 335       uc_1 = hp100_inb( BOARD_ID + i );
 336       eisa_id |= uc_1 << 24;
 337       uc += uc_1;
 338     }
 339   uc += hp100_inb( BOARD_ID + 4 );
 340 
 341 #ifdef HP100_DEBUG_PROBE1
 342   printk( "hp100_probe1: EISA ID = 0x%08x  checksum = 0x%02x\n", eisa_id, uc );
 343 #endif
 344 
 345   if ( uc != 0xff )             /* bad checksum? */
 346     {
 347       printk( "hp100_probe: bad EISA ID checksum at base port 0x%x\n", ioaddr );
 348       return -ENODEV;
 349     }  
 350 
 351   for ( i = 0; i < sizeof( hp100_eisa_ids ) / sizeof( struct hp100_eisa_id ); i++ )
 352     if ( ( hp100_eisa_ids[ i ].id & 0xf0ffffff ) == ( eisa_id & 0xf0ffffff ) )
 353       break;
 354   if ( i >= sizeof( hp100_eisa_ids ) / sizeof( struct hp100_eisa_id ) )
 355     {
 356       printk( "hp100_probe1: card at port 0x%x isn't known (id = 0x%x)\n", ioaddr, eisa_id );
 357       return -ENODEV;
 358     }
 359   eid = &hp100_eisa_ids[ i ];
 360   if ( ( eid -> id & 0x0f000000 ) < ( eisa_id & 0x0f000000 ) )
 361     {
 362       printk( "hp100_probe1: newer version of card %s at port 0x%x - unsupported\n", 
 363         eid -> name, ioaddr );
 364       return -ENODEV;
 365     }
 366 
 367   for ( i = uc = 0; i < 7; i++ )
 368     uc += hp100_inb( LAN_ADDR + i );
 369   if ( uc != 0xff )
 370     {
 371       printk( "hp100_probe1: bad lan address checksum (card %s at port 0x%x)\n", 
 372         eid -> name, ioaddr );
 373       return -EIO;
 374     }
 375 
 376 #ifndef HP100_IO_MAPPED
 377   hp100_page( HW_MAP );
 378   mem_mapped = ( hp100_inw( OPTION_LSW ) & 
 379                  ( HP100_MEM_EN | HP100_BM_WRITE | HP100_BM_READ ) ) != 0;
 380   mem_ptr_phys = mem_ptr_virt = NULL;
 381   if ( mem_mapped )
 382     {
 383       mem_ptr_phys = (u_char *)( hp100_inw( MEM_MAP_LSW ) | 
 384                                ( hp100_inw( MEM_MAP_MSW ) << 16 ) );
 385       (u_int)mem_ptr_phys &= ~0x1fff;   /* 8k aligment */
 386       if ( bus == HP100_BUS_ISA && ( (u_long)mem_ptr_phys & ~0xfffff ) != 0 )
 387         {
 388           mem_ptr_phys = NULL;
 389           mem_mapped = 0;
 390         }
 391       if ( mem_mapped && bus == HP100_BUS_PCI )
 392         {
 393           if ( ( mem_ptr_virt = vremap( (u_long)mem_ptr_phys, 0x2000 ) ) == NULL )
 394             {
 395               printk( "hp100: vremap for high PCI memory at 0x%lx failed\n", (u_long)mem_ptr_phys );
 396               mem_ptr_phys = NULL;
 397               mem_mapped = 0;
 398             }
 399         }
 400     }
 401 #else
 402   mem_mapped = 0;
 403   mem_ptr_phys = mem_ptr_virt = NULL;
 404 #endif
 405 
 406   if ( ( dev -> priv = kmalloc( sizeof( struct hp100_private ), GFP_KERNEL ) ) == NULL )
 407     return -ENOMEM;
 408   memset( dev -> priv, 0, sizeof( struct hp100_private ) );
 409 
 410   lp = (struct hp100_private *)dev -> priv;
 411   lp -> id = eid;
 412   lp -> mem_mapped = mem_mapped;
 413   lp -> mem_ptr_phys = mem_ptr_phys;
 414   lp -> mem_ptr_virt = mem_ptr_virt;
 415   hp100_page( ID_MAC_ADDR );
 416   lp -> soft_model = hp100_inb( SOFT_MODEL );
 417   lp -> mac1_mode = HP100_MAC1MODE3;
 418   lp -> mac2_mode = HP100_MAC2MODE3;
 419   
 420   dev -> base_addr = ioaddr;
 421   hp100_page( HW_MAP );
 422   dev -> irq = hp100_inb( IRQ_CHANNEL ) & HP100_IRQ_MASK;
 423   if ( dev -> irq == 2 ) dev -> irq = 9;
 424   lp -> memory_size = 0x200 << ( ( hp100_inb( SRAM ) & 0xe0 ) >> 5 );
 425   lp -> rx_ratio = hp100_rx_ratio;
 426 
 427   dev -> open = hp100_open;
 428   dev -> stop = hp100_close;
 429   dev -> hard_start_xmit = hp100_start_xmit;
 430   dev -> get_stats = hp100_get_stats;
 431   dev -> set_multicast_list = &hp100_set_multicast_list;
 432 
 433   request_region( dev -> base_addr, HP100_REGION_SIZE, eid -> name );
 434 
 435   hp100_page( ID_MAC_ADDR );
 436   for ( i = uc = 0; i < 6; i++ )
 437     dev -> dev_addr[ i ] = hp100_inb( LAN_ADDR + i );
 438 
 439   hp100_clear_stats( ioaddr );
 440 
 441   ether_setup( dev );
 442 
 443   lp -> lan_type = hp100_sense_lan( dev );
 444      
 445   printk( "%s: %s at 0x%x, IRQ %d, ",
 446     dev -> name, lp -> id -> name, ioaddr, dev -> irq );
 447   switch ( bus ) {
 448     case HP100_BUS_EISA: printk( "EISA" ); break;
 449     case HP100_BUS_PCI:  printk( "PCI" );  break;
 450     default:             printk( "ISA" );  break;
 451   }
 452   printk( " bus, %dk SRAM (rx/tx %d%%).\n",
 453     lp -> memory_size >> ( 10 - 4 ), lp -> rx_ratio );
 454   if ( mem_mapped )
 455     {
 456       printk( "%s: Memory area at 0x%lx-0x%lx",
 457                 dev -> name, (u_long)mem_ptr_phys, (u_long)mem_ptr_phys + 0x1fff );
 458       if ( mem_ptr_virt )
 459         printk( " (virtual base 0x%lx)", (u_long)mem_ptr_virt );
 460       printk( ".\n" );
 461     }
 462   printk( "%s: ", dev -> name );
 463   if ( lp -> lan_type != HP100_LAN_ERR )
 464     printk( "Adapter is attached to " );
 465   switch ( lp -> lan_type ) {
 466     case HP100_LAN_100:
 467       printk( "100Mb/s Voice Grade AnyLAN network.\n" );
 468       break;
 469     case HP100_LAN_10:
 470       printk( "10Mb/s network.\n" );
 471       break;
 472     default:
 473       printk( "Warning! Link down.\n" );
 474   }
 475                 
 476   hp100_stop_interface( dev );
 477   
 478   return 0;
 479 }
 480 
 481 /*
 482  *  open/close functions
 483  */
 484 
 485 static int hp100_open( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 486 {
 487   int i;
 488   int ioaddr = dev -> base_addr;
 489   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
 490 
 491   if ( request_irq( dev -> irq, hp100_interrupt, SA_INTERRUPT, lp -> id -> name ) )
 492     {
 493       printk( "%s: unable to get IRQ %d\n", dev -> name, dev -> irq );
 494       return -EAGAIN;
 495     }
 496   irq2dev_map[ dev -> irq ] = dev;
 497 
 498   MOD_INC_USE_COUNT;
 499   
 500   dev -> tbusy = 0;
 501   dev -> trans_start = jiffies;
 502   dev -> interrupt = 0;
 503   dev -> start = 1;
 504 
 505   lp -> lan_type = hp100_sense_lan( dev );
 506   lp -> mac1_mode = HP100_MAC1MODE3;
 507   lp -> mac2_mode = HP100_MAC2MODE3;
 508   
 509   hp100_page( MAC_CTRL );
 510   hp100_orw( HP100_LINK_BEAT_DIS | HP100_RESET_LB, LAN_CFG_10 );
 511 
 512   hp100_stop_interface( dev );
 513   hp100_load_eeprom( dev );
 514 
 515   hp100_outw( HP100_MMAP_DIS | HP100_SET_HB | 
 516               HP100_IO_EN | HP100_SET_LB, OPTION_LSW );
 517   hp100_outw( HP100_DEBUG_EN | HP100_RX_HDR | HP100_EE_EN | HP100_RESET_HB |
 518               HP100_FAKE_INT | HP100_RESET_LB, OPTION_LSW );
 519   hp100_outw( HP100_ADV_NXT_PKT | HP100_TX_CMD | HP100_RESET_LB |
 520                 HP100_PRIORITY_TX | ( hp100_priority_tx ? HP100_SET_HB : HP100_RESET_HB ),
 521               OPTION_MSW );
 522                                         
 523   hp100_page( MAC_ADDRESS );
 524   for ( i = 0; i < 6; i++ )
 525     hp100_outb( dev -> dev_addr[ i ], MAC_ADDR + i );
 526   for ( i = 0; i < 8; i++ )             /* setup multicast filter to receive all */
 527     hp100_outb( 0xff, HASH_BYTE0 + i );
 528   hp100_page( PERFORMANCE );
 529   hp100_outw( 0xfefe, IRQ_MASK );       /* mask off all ints */
 530   hp100_outw( 0xffff, IRQ_STATUS );     /* ack IRQ */
 531   hp100_outw( (HP100_RX_PACKET | HP100_RX_ERROR | HP100_SET_HB) |
 532               (HP100_TX_ERROR | HP100_SET_LB ), IRQ_MASK );
 533                                         /* and enable few */
 534   hp100_reset_card();
 535   hp100_page( MMU_CFG );
 536   hp100_outw( ( lp -> memory_size * lp -> rx_ratio ) / 100, RX_MEM_STOP );
 537   hp100_outw( lp -> memory_size - 1, TX_MEM_STOP );
 538   hp100_unreset_card();
 539 
 540   if ( lp -> lan_type == HP100_LAN_100 )
 541     lp -> hub_status = hp100_login_to_vg_hub( dev );
 542 
 543   hp100_start_interface( dev );
 544 
 545   return 0;
 546 }
 547 
 548 static int hp100_close( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 549 {
 550   int ioaddr = dev -> base_addr;
 551   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
 552 
 553   hp100_page( PERFORMANCE );
 554   hp100_outw( 0xfefe, IRQ_MASK );               /* mask off all IRQs */
 555 
 556   hp100_stop_interface( dev );
 557 
 558   if ( lp -> lan_type == HP100_LAN_100 )        /* relogin */
 559     hp100_login_to_vg_hub( dev );
 560 
 561   dev -> tbusy = 1;
 562   dev -> start = 0;
 563 
 564   free_irq( dev -> irq );
 565   irq2dev_map[ dev -> irq ] = NULL;
 566   MOD_DEC_USE_COUNT;
 567   return 0;
 568 }
 569 
 570 /* 
 571  *  transmit
 572  */
 573 
 574 static int hp100_start_xmit( struct sk_buff *skb, struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 575 {
 576   int i, ok_flag;
 577   int ioaddr = dev -> base_addr;
 578   u_short val;
 579   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
 580 
 581   if ( lp -> lan_type < 0 )
 582     {
 583       hp100_stop_interface( dev );
 584       if ( ( lp -> lan_type = hp100_sense_lan( dev ) ) < 0 )
 585         {
 586           printk( "%s: no connection found - check wire\n", dev -> name );
 587           hp100_start_interface( dev ); /* 10Mb/s RX packets maybe handled */
 588           return -EIO;
 589         }
 590       if ( lp -> lan_type == HP100_LAN_100 )
 591         lp -> hub_status = hp100_login_to_vg_hub( dev );
 592       hp100_start_interface( dev );
 593     }
 594   
 595   if ( ( i = ( hp100_inl( TX_MEM_FREE ) & ~0x7fffffff ) ) < skb -> len + 16 )
 596     {
 597 #ifdef HP100_DEBUG
 598       printk( "hp100_start_xmit: rx free mem = 0x%x\n", i );
 599 #endif
 600       if ( jiffies - dev -> trans_start < 2 * HZ ) return -EAGAIN;
 601       if ( lp -> lan_type == HP100_LAN_100 && lp -> hub_status < 0 )
 602                                 /* 100Mb/s adapter isn't connected to hub */
 603         {
 604           printk( "%s: login to 100Mb/s hub retry\n", dev -> name );
 605           hp100_stop_interface( dev );
 606           lp -> hub_status = hp100_login_to_vg_hub( dev );
 607           hp100_start_interface( dev );
 608         }
 609        else
 610         {
 611           hp100_ints_off();
 612           i = hp100_sense_lan( dev );
 613           hp100_page( PERFORMANCE );
 614           hp100_ints_on();
 615           if ( i == HP100_LAN_ERR )
 616             printk( "%s: link down detected\n", dev -> name );
 617            else
 618           if ( lp -> lan_type != i )
 619             {
 620               /* it's very heavy - all network setting must be changed!!! */
 621               printk( "%s: cable change 10Mb/s <-> 100Mb/s detected\n", dev -> name );
 622               lp -> lan_type = i;
 623               hp100_stop_interface( dev );
 624               if ( lp -> lan_type == HP100_LAN_100 )
 625                 lp -> hub_status = hp100_login_to_vg_hub( dev );
 626               hp100_start_interface( dev );
 627             }
 628            else
 629             {
 630               printk( "%s: interface reset\n", dev -> name );
 631               hp100_stop_interface( dev );
 632               hp100_start_interface( dev );
 633             }
 634         }
 635       dev -> trans_start = jiffies;
 636       return -EAGAIN;
 637     }
 638     
 639   if ( skb == NULL )
 640     {
 641       dev_tint( dev );
 642       return 0;
 643     }
 644     
 645   if ( skb -> len <= 0 ) return 0;
 646 
 647   for ( i = 0; i < 6000 && ( hp100_inw( OPTION_MSW ) & HP100_TX_CMD ); i++ )
 648     {
 649 #ifdef HP100_DEBUG_TX
 650       printk( "hp100_start_xmit: busy\n" );
 651 #endif    
 652     }
 653 
 654   hp100_ints_off();
 655   val = hp100_inw( IRQ_STATUS );
 656   hp100_outw( val & HP100_TX_COMPLETE, IRQ_STATUS );
 657 #ifdef HP100_DEBUG_TX
 658   printk( "hp100_start_xmit: irq_status = 0x%x, len = %d\n", val, (int)skb -> len );
 659 #endif
 660   ok_flag = skb -> len >= HP100_MIN_PACKET_SIZE;
 661   i = ok_flag ? skb -> len : HP100_MIN_PACKET_SIZE;
 662   hp100_outw( i, DATA32 );              /* length to memory manager */
 663   hp100_outw( i, FRAGMENT_LEN );
 664   if ( lp -> mem_mapped )
 665     {
 666       if ( lp -> mem_ptr_virt )
 667         {
 668           memcpy( lp -> mem_ptr_virt, skb -> data, skb -> len );
 669           if ( !ok_flag )
 670             memset( lp -> mem_ptr_virt, 0, HP100_MIN_PACKET_SIZE - skb -> len );
 671         }
 672        else
 673         {
 674           memcpy_toio( lp -> mem_ptr_phys, skb -> data, skb -> len );
 675           if ( !ok_flag )
 676             memset_io( lp -> mem_ptr_phys, 0, HP100_MIN_PACKET_SIZE - skb -> len );
 677         }
 678     }
 679    else
 680     {
 681       outsl( ioaddr + HP100_REG_DATA32, skb -> data, ( skb -> len + 3 ) >> 2 );
 682       if ( !ok_flag )
 683         for ( i = ( skb -> len + 3 ) & ~3; i < HP100_MIN_PACKET_SIZE; i += 4 )
 684           hp100_outl( 0, DATA32 );
 685     }
 686   hp100_outw( HP100_TX_CMD | HP100_SET_LB, OPTION_MSW ); /* send packet */
 687   lp -> stats.tx_packets++;
 688   dev -> trans_start = jiffies;
 689   hp100_ints_on();
 690 
 691   dev_kfree_skb( skb, FREE_WRITE );
 692 
 693 #ifdef HP100_DEBUG_TX
 694   printk( "hp100_start_xmit: end\n" );
 695 #endif
 696 
 697   return 0;
 698 }
 699 
 700 /*
 701  *  receive - called from interrupt handler
 702  */
 703 
 704 static void hp100_rx( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 705 {
 706   int packets, pkt_len;
 707   int ioaddr = dev -> base_addr;
 708   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
 709   u_int header;
 710   struct sk_buff *skb;
 711 
 712 #if 0
 713   if ( lp -> lan_type < 0 )
 714     {
 715       if ( ( lp -> lan_type = hp100_sense_lan( dev ) ) == HP100_LAN_100 )
 716         lp -> hub_status = hp100_login_to_vg_hub( dev );
 717       hp100_page( PERFORMANCE );
 718     }
 719 #endif
 720   
 721   packets = hp100_inb( RX_PKT_CNT );
 722 #ifdef HP100_DEBUG
 723   if ( packets > 1 )
 724     printk( "hp100_rx: waiting packets = %d\n", packets );
 725 #endif
 726   while ( packets-- > 0 )
 727     {
 728       for ( pkt_len = 0; pkt_len < 6000 && ( hp100_inw( OPTION_MSW ) & HP100_ADV_NXT_PKT ); pkt_len++ )
 729         {
 730 #ifdef HP100_DEBUG_TX
 731           printk( "hp100_rx: busy, remaining packets = %d\n", packets );
 732 #endif    
 733         }
 734       if ( lp -> mem_mapped )
 735         {
 736           if ( lp -> mem_ptr_virt )
 737             header = *(__u32 *)lp -> mem_ptr_virt;
 738            else
 739             header = readl( lp -> mem_ptr_phys );
 740         }
 741        else
 742         header = hp100_inl( DATA32 );
 743       pkt_len = header & HP100_PKT_LEN_MASK;
 744 #ifdef HP100_DEBUG_RX
 745       printk( "hp100_rx: new packet - length = %d, errors = 0x%x, dest = 0x%x\n",
 746         header & HP100_PKT_LEN_MASK, ( header >> 16 ) & 0xfff8, ( header >> 16 ) & 7 );
 747 #endif
 748       /*
 749        * NOTE! This (and the skb_put() below) depends on the skb-functions
 750        * allocating more than asked (notably, aligning the request up to
 751        * the next 16-byte length).
 752        */
 753       skb = dev_alloc_skb( pkt_len );
 754       if ( skb == NULL )
 755         {
 756 #ifdef HP100_DEBUG
 757           printk( "hp100_rx: couldn't allocate a sk_buff of size %d\n", pkt_len );
 758 #endif
 759           lp -> stats.rx_dropped++;
 760         }
 761        else
 762         {
 763           u_char *ptr;
 764         
 765           skb -> dev = dev;
 766           ptr = (u_char *)skb_put( skb, pkt_len );
 767           if ( lp -> mem_mapped )
 768             {
 769               if ( lp -> mem_ptr_virt )
 770                 memcpy( ptr, lp -> mem_ptr_virt, ( pkt_len + 3 ) & ~3 );
 771                else
 772                 memcpy_fromio( ptr, lp -> mem_ptr_phys, ( pkt_len + 3 ) & ~3 );
 773             }
 774            else
 775             insl( ioaddr + HP100_REG_DATA32, ptr, ( pkt_len + 3 ) >> 2 );
 776           skb -> protocol = eth_type_trans( skb, dev );
 777           netif_rx( skb );
 778           lp -> stats.rx_packets++;
 779 #ifdef HP100_DEBUG_RX
 780           printk( "rx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
 781                 ptr[ 0 ], ptr[ 1 ], ptr[ 2 ], ptr[ 3 ], ptr[ 4 ], ptr[ 5 ],
 782                 ptr[ 6 ], ptr[ 7 ], ptr[ 8 ], ptr[ 9 ], ptr[ 10 ], ptr[ 11 ] );
 783 #endif
 784         }
 785       hp100_outw( HP100_ADV_NXT_PKT | HP100_SET_LB, OPTION_MSW );
 786       switch ( header & 0x00070000 ) {
 787         case (HP100_MULTI_ADDR_HASH<<16):
 788         case (HP100_MULTI_ADDR_NO_HASH<<16):
 789           lp -> stats.multicast++; break;
 790       }
 791     }
 792 #ifdef HP100_DEBUG_RX
 793    printk( "hp100_rx: end\n" );
 794 #endif
 795 }
 796 
 797 /*
 798  *  statistics
 799  */
 800  
 801 static struct enet_statistics *hp100_get_stats( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 802 {
 803   int ioaddr = dev -> base_addr;
 804 
 805   hp100_ints_off();
 806   hp100_update_stats( dev );
 807   hp100_ints_on();
 808   return &((struct hp100_private *)dev -> priv) -> stats;
 809 }
 810 
 811 static void hp100_update_stats( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 812 {
 813   int ioaddr = dev -> base_addr;
 814   u_short val;
 815   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
 816          
 817   hp100_page( MAC_CTRL );               /* get all statistics bytes */
 818   val = hp100_inw( DROPPED ) & 0x0fff;
 819   lp -> stats.rx_errors += val;
 820   lp -> stats.rx_over_errors += val;
 821   val = hp100_inb( CRC );
 822   lp -> stats.rx_errors += val;
 823   lp -> stats.rx_crc_errors += val;
 824   val = hp100_inb( ABORT );
 825   lp -> stats.tx_errors += val;
 826   lp -> stats.tx_aborted_errors += val;
 827   hp100_page( PERFORMANCE );
 828 }
 829 
 830 static void hp100_clear_stats( int ioaddr )
     /* [previous][next][first][last][top][bottom][index][help] */
 831 {
 832   cli();
 833   hp100_page( MAC_CTRL );               /* get all statistics bytes */
 834   hp100_inw( DROPPED );
 835   hp100_inb( CRC );
 836   hp100_inb( ABORT );
 837   hp100_page( PERFORMANCE );
 838   sti();
 839 }
 840 
 841 /*
 842  *  multicast setup
 843  */
 844 
 845 /*
 846  *  Set or clear the multicast filter for this adapter.
 847  */
 848                                                           
 849 static void hp100_set_multicast_list( struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 850 {
 851   int ioaddr = dev -> base_addr;
 852   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
 853 
 854 #ifdef HP100_DEBUG_MULTI
 855   printk( "hp100_set_multicast_list: num_addrs = %d\n", dev->mc_count);
 856 #endif
 857   cli();
 858   hp100_ints_off();
 859   hp100_page( MAC_CTRL );
 860   hp100_andb( ~(HP100_RX_EN | HP100_TX_EN), MAC_CFG_1 );        /* stop rx/tx */
 861 
 862   if ( dev->flags&IFF_PROMISC)
 863     {
 864       lp -> mac2_mode = HP100_MAC2MODE6;  /* promiscuous mode, all good */
 865       lp -> mac1_mode = HP100_MAC1MODE6;  /* packets on the net */
 866     }
 867    else
 868   if ( dev->mc_count || dev->flags&IFF_ALLMULTI )
 869     {
 870       lp -> mac2_mode = HP100_MAC2MODE5;  /* multicast mode, packets for me */
 871       lp -> mac1_mode = HP100_MAC1MODE5;  /* broadcasts and all multicasts */
 872     }
 873    else
 874     {
 875       lp -> mac2_mode = HP100_MAC2MODE3;  /* normal mode, packets for me */
 876       lp -> mac1_mode = HP100_MAC1MODE3;  /* and broadcasts */
 877     }
 878 
 879   hp100_outb( lp -> mac2_mode, MAC_CFG_2 );
 880   hp100_andb( HP100_MAC1MODEMASK, MAC_CFG_1 );
 881   hp100_orb( lp -> mac1_mode |
 882              HP100_RX_EN | HP100_RX_IDLE |              /* enable rx */
 883              HP100_TX_EN | HP100_TX_IDLE, MAC_CFG_1 );  /* enable tx */
 884   hp100_page( PERFORMANCE );
 885   hp100_ints_on();
 886   sti();
 887 }
 888 
 889 /*
 890  *  hardware interrupt handling
 891  */
 892 
 893 static void hp100_interrupt( int irq, struct pt_regs *regs )
     /* [previous][next][first][last][top][bottom][index][help] */
 894 {
 895   struct device *dev = (struct device *)irq2dev_map[ irq ];
 896   struct hp100_private *lp;
 897   int ioaddr;
 898   u_short val;
 899 
 900   if ( dev == NULL ) return;
 901   ioaddr = dev -> base_addr;
 902   if ( dev -> interrupt )
 903     printk( "%s: re-entering the interrupt handler\n", dev -> name );
 904   hp100_ints_off();
 905   dev -> interrupt = 1;
 906   hp100_page( PERFORMANCE );
 907   val = hp100_inw( IRQ_STATUS );
 908 #ifdef HP100_DEBUG_IRQ
 909   printk( "hp100_interrupt: irq_status = 0x%x\n", val );
 910 #endif
 911   if ( val & HP100_RX_PACKET )
 912     {
 913       hp100_rx( dev );
 914       hp100_outw( HP100_RX_PACKET, IRQ_STATUS );
 915     }
 916   if ( val & (HP100_TX_SPACE_AVAIL | HP100_TX_COMPLETE) )
 917     {
 918       hp100_outw( val & (HP100_TX_SPACE_AVAIL | HP100_TX_COMPLETE), IRQ_STATUS );
 919     }
 920   if ( val & ( HP100_TX_ERROR | HP100_RX_ERROR ) )
 921     {
 922       lp = (struct hp100_private *)dev -> priv;
 923       hp100_update_stats( dev );
 924       hp100_outw( val & (HP100_TX_ERROR | HP100_RX_ERROR), IRQ_STATUS );
 925     }
 926 #ifdef HP100_DEBUG_IRQ
 927   printk( "hp100_interrupt: end\n" );
 928 #endif
 929   dev -> interrupt = 0;
 930   hp100_ints_on();
 931 }
 932 
 933 /*
 934  *  some misc functions
 935  */
 936 
 937 static void hp100_start_interface( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 938 {
 939   int ioaddr = dev -> base_addr;
 940   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
 941 
 942   cli();
 943   hp100_unreset_card();
 944   hp100_page( MAC_CTRL );
 945   hp100_outb( lp -> mac2_mode, MAC_CFG_2 );
 946   hp100_andb( HP100_MAC1MODEMASK, MAC_CFG_1 );
 947   hp100_orb( lp -> mac1_mode |
 948              HP100_RX_EN | HP100_RX_IDLE |
 949              HP100_TX_EN | HP100_TX_IDLE, MAC_CFG_1 );
 950   hp100_page( PERFORMANCE );
 951   hp100_outw( HP100_INT_EN | HP100_SET_LB, OPTION_LSW );
 952   hp100_outw( HP100_TRI_INT | HP100_RESET_HB, OPTION_LSW );
 953   if ( lp -> mem_mapped )
 954     {
 955       /* enable memory mapping */
 956       hp100_outw( HP100_MMAP_DIS | HP100_RESET_HB, OPTION_LSW );
 957     }
 958   sti();
 959 } 
 960 
 961 static void hp100_stop_interface( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 962 {
 963   int ioaddr = dev -> base_addr;
 964   u_short val;
 965 
 966   hp100_outw( HP100_INT_EN | HP100_RESET_LB | 
 967               HP100_TRI_INT | HP100_MMAP_DIS | HP100_SET_HB, OPTION_LSW );
 968   val = hp100_inw( OPTION_LSW );
 969   hp100_page( HW_MAP );
 970   hp100_andb( HP100_BM_SLAVE, BM );
 971   hp100_page( MAC_CTRL );
 972   hp100_andb( ~(HP100_RX_EN | HP100_TX_EN), MAC_CFG_1 );
 973   if ( !(val & HP100_HW_RST) ) return;
 974   for ( val = 0; val < 6000; val++ )
 975     if ( ( hp100_inb( MAC_CFG_1 ) & (HP100_TX_IDLE | HP100_RX_IDLE) ) ==
 976                                     (HP100_TX_IDLE | HP100_RX_IDLE) )
 977       return;
 978   printk( "%s: hp100_stop_interface - timeout\n", dev -> name );
 979 }
 980 
 981 static void hp100_load_eeprom( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 982 {
 983   int i;
 984   int ioaddr = dev -> base_addr;
 985 
 986   hp100_page( EEPROM_CTRL );
 987   hp100_andw( ~HP100_EEPROM_LOAD, EEPROM_CTRL );
 988   hp100_orw( HP100_EEPROM_LOAD, EEPROM_CTRL );
 989   for ( i = 0; i < 6000; i++ )
 990     if ( !( hp100_inw( OPTION_MSW ) & HP100_EE_LOAD ) ) return;
 991   printk( "%s: hp100_load_eeprom - timeout\n", dev -> name );
 992 }
 993 
 994 /* return values: LAN_10, LAN_100 or LAN_ERR (not connected or hub is down)... */
 995 
 996 static int hp100_sense_lan( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
 997 {
 998   int i;
 999   int ioaddr = dev -> base_addr;
1000   u_short val_VG, val_10;
1001   struct hp100_private *lp = (struct hp100_private *)dev -> priv;
1002 
1003   hp100_page( MAC_CTRL );
1004   hp100_orw( HP100_VG_RESET, LAN_CFG_VG );
1005   val_10 = hp100_inw( LAN_CFG_10 );
1006   val_VG = hp100_inw( LAN_CFG_VG );
1007 #ifdef HP100_DEBUG_SENSE
1008   printk( "hp100_sense_lan: val_VG = 0x%04x, val_10 = 0x%04x\n", val_VG, val_10 );
1009 #endif
1010   if ( val_10 & HP100_LINK_BEAT_ST ) return HP100_LAN_10;
1011   if ( lp -> id -> id == 0x02019F022 ) /* HP J27248B doesn't have 100Mb/s interface */
1012     return HP100_LAN_ERR;
1013   for ( i = 0; i < 2500; i++ )
1014     {
1015       val_VG = hp100_inw( LAN_CFG_VG );
1016       if ( val_VG & HP100_LINK_CABLE_ST ) return HP100_LAN_100;
1017     }
1018   return HP100_LAN_ERR;
1019 }
1020 
1021 static int hp100_down_vg_link( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
1022 {
1023   int ioaddr = dev -> base_addr;
1024   unsigned long time;
1025   int i;
1026 
1027   hp100_page( MAC_CTRL );
1028   for ( i = 2500; i > 0; i-- )
1029     if ( hp100_inw( LAN_CFG_VG ) & HP100_LINK_CABLE_ST ) break;
1030   if ( i <= 0 )                         /* not signal - not logout */
1031     return 0;
1032   hp100_andw( ~HP100_LINK_CMD, LAN_CFG_VG );
1033   time = jiffies + 10; 
1034   while ( time > jiffies )
1035     if ( !( hp100_inw( LAN_CFG_VG ) & ( HP100_LINK_UP_ST | 
1036                                         HP100_LINK_CABLE_ST | 
1037                                         HP100_LINK_GOOD_ST ) ) )
1038       return 0;
1039 #ifdef HP100_DEBUG
1040   printk( "hp100_down_vg_link: timeout\n" );
1041 #endif
1042   return -EIO;
1043 }
1044 
1045 static int hp100_login_to_vg_hub( struct device *dev )
     /* [previous][next][first][last][top][bottom][index][help] */
1046 {
1047   int i;
1048   int ioaddr = dev -> base_addr;
1049   u_short val;
1050   unsigned long time;  
1051 
1052   hp100_page( MAC_CTRL );
1053   hp100_orw( HP100_VG_RESET, LAN_CFG_VG );
1054   time = jiffies + ( HZ / 2 );
1055   do {
1056     if ( hp100_inw( LAN_CFG_VG ) & HP100_LINK_CABLE_ST ) break;
1057   } while ( time > jiffies );
1058   if ( time <= jiffies )
1059     {
1060 #ifdef HP100_DEBUG
1061       printk( "hp100_login_to_vg_hub: timeout for link\n" );
1062 #endif
1063       return -EIO;
1064     }
1065     
1066   if ( hp100_down_vg_link( dev ) < 0 )  /* if fail, try reset VG link */
1067     {
1068       hp100_andw( ~HP100_VG_RESET, LAN_CFG_VG );
1069       hp100_orw( HP100_VG_RESET, LAN_CFG_VG );
1070     }
1071   /* bring up link */
1072   hp100_orw( HP100_LOAD_ADDR | HP100_LINK_CMD, LAN_CFG_VG );
1073   for ( i = 2500; i > 0; i-- )
1074     if ( hp100_inw( LAN_CFG_VG ) & HP100_LINK_CABLE_ST ) break;
1075   if ( i <= 0 )
1076     {
1077 #ifdef HP100_DEBUG
1078       printk( "hp100_login_to_vg_hub: timeout for link (bring up)\n" );
1079 #endif
1080       goto down_link;
1081     }
1082 
1083   time = jiffies + ( HZ / 2 );
1084   do {   
1085     val = hp100_inw( LAN_CFG_VG );
1086     if ( ( val & ( HP100_LINK_UP_ST | HP100_LINK_GOOD_ST ) ) == 
1087                  ( HP100_LINK_UP_ST | HP100_LINK_GOOD_ST ) )
1088       return 0; /* success */
1089   } while ( time > jiffies );
1090   if ( val & HP100_LINK_GOOD_ST )
1091     printk( "%s: 100Mb cable training failed, check cable.\n", dev -> name );
1092    else
1093     printk( "%s: 100Mb node not accepted by hub, check frame type or security.\n", dev -> name );
1094 
1095 down_link:
1096   hp100_down_vg_link( dev );
1097   hp100_page( MAC_CTRL );
1098   hp100_andw( ~( HP100_LOAD_ADDR | HP100_PROM_MODE ), LAN_CFG_VG );
1099   hp100_orw( HP100_LINK_CMD, LAN_CFG_VG );
1100   return -EIO;
1101 }
1102 
1103 /*
1104  *  module section
1105  */
1106  
1107 #ifdef MODULE
1108 
1109 static int hp100_port = -1;
1110 
1111 static char devicename[9] = { 0, };
1112 static struct device dev_hp100 = {
1113         devicename, /* device name is inserted by linux/drivers/net/net_init.c */
1114         0, 0, 0, 0,
1115         0, 0,
1116         0, 0, 0, NULL, hp100_probe
1117 };
1118 
1119 int init_module( void )
     /* [previous][next][first][last][top][bottom][index][help] */
1120 {
1121   if (hp100_port == 0 && !EISA_bus)
1122     printk("HP100: You should not use auto-probing with insmod!\n");
1123   if ( hp100_port > 0 )
1124     dev_hp100.base_addr = hp100_port;
1125   if ( register_netdev( &dev_hp100 ) != 0 )
1126     return -EIO;
1127   return 0;
1128 }         
1129 
1130 void cleanup_module( void )
     /* [previous][next][first][last][top][bottom][index][help] */
1131 {
1132   unregister_netdev( &dev_hp100 );
1133   release_region( dev_hp100.base_addr, HP100_REGION_SIZE );
1134   if ( ((struct hp100_private *)dev_hp100.priv) -> mem_ptr_virt )
1135     vfree( ((struct hp100_private *)dev_hp100.priv) -> mem_ptr_virt );
1136   kfree_s( dev_hp100.priv, sizeof( struct hp100_private ) );
1137   dev_hp100.priv = NULL;
1138 }
1139 
1140 #endif

/* [previous][next][first][last][top][bottom][index][help] */