root/drivers/net/arcnet.c

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

DEFINITIONS

This source file includes following definitions.
  1. arcnet_probe
  2. arcnet_ioprobe
  3. arcnet_memprobe
  4. arcnet_reset
  5. arcnetE_init
  6. arcnet_open
  7. arcnet_close
  8. arcnetA_send_packet
  9. arcnetA_continue_tx
  10. arcnetA_prepare_tx
  11. arcnetA_go_tx
  12. arcnetE_send_packet
  13. arcnet_interrupt
  14. arcnet_inthandler
  15. arcnet_rx
  16. arcnetA_rx
  17. arcnetE_rx
  18. arcnet_get_stats
  19. set_multicast_list
  20. arcnetA_header
  21. arcnetA_rebuild_header
  22. arcnetA_type_trans
  23. init_module
  24. cleanup_module

   1 /* arcnet.c
   2         Written 1994-95 by Avery Pennarun, derived from skeleton.c by
   3         Donald Becker.
   4 
   5         Contact Avery at: apenwarr@foxnet.net or
   6         RR #5 Pole Line Road, Thunder Bay, ON, Canada P7C 5M9
   7         
   8         **********************
   9         
  10         The original copyright was as follows:
  11 
  12         skeleton.c Written 1993 by Donald Becker.
  13         Copyright 1993 United States Government as represented by the
  14         Director, National Security Agency.  This software may only be used
  15         and distributed according to the terms of the GNU Public License as
  16         modified by SRC, incorporated herein by reference.
  17          
  18         **********************
  19 
  20         v2.00 (95/09/06)
  21           - THIS IS ONLY A SUMMARY.  The complete changelog is available
  22             from me upon request.
  23 
  24           - ARCnet RECON messages are now detected and logged.  These occur
  25             when a new computer is powered up on the network, or in a
  26             constant stream when the network cable is broken.  Thanks to
  27             Tomasz Motylewski for this.  You must have D_EXTRA enabled
  28             if you want these messages sent to syslog, otherwise they will
  29             only show up in the network statistics (/proc/net/dev).
  30           - The TX Acknowledge flag is now checked, and a log message is sent
  31             if a completed transmit is not ACK'd.  (I have yet to have this
  32             happen to me.)
  33           - Debug levels are now completely different.  See the README.
  34           - Many code cleanups, with several no-longer-necessary and some
  35             completely useless options removed.
  36           - Multiprotocol support.  You can now use the "arc0e" device to
  37             send "Ethernet-Encapsulation" packets, which are compatible with
  38             Windows for Workgroups and LAN Manager, and possibly other
  39             software.  See the README for more information.
  40           - Documentation updates and improvements.
  41           
  42         v1.02 (95/06/21)
  43           - A fix to make "exception" packets sent from Linux receivable
  44             on other systems.  (The protocol_id byte was sometimes being set
  45             incorrectly, and Linux wasn't checking it on receive so it
  46             didn't show up)
  47 
  48         v1.01 (95/03/24)
  49           - Fixed some IPX-related bugs. (Thanks to Tomasz Motylewski
  50             <motyl@tichy.ch.uj.edu.pl> for the patches to make arcnet work
  51             with dosemu!)
  52             
  53         v1.00 (95/02/15)
  54           - Initial non-alpha release.
  55         
  56          
  57         TO DO:
  58         
  59          - Test in systems with NON-ARCnet network cards, just to see if
  60            autoprobe kills anything.  Currently, we do cause some NE2000's
  61            to die.  Autoprobe is also way too slow and verbose, particularly
  62            if there ARE no ARCnet cards.
  63          - What about cards with shared memory that can be "turned off?"
  64          - NFS mount freezes after several megabytes to SOSS for DOS. 
  65            unmount/remount fixes it.  Is this arcnet-specific?  I don't know.
  66          - Add support for "old" (RFC1051) protocol arcnet, such as AmiTCP
  67            and NetBSD.  Work in Tomasz' initial support for this.
  68          - How about TCP/IP over netbios?  Or vice versa?
  69          - Some newer ARCnets support promiscuous mode, supposedly. 
  70            If someone sends me information, I'll try to implement it.
  71          - Remove excess lock variables that are probably not necessary
  72            anymore due to the changes in Linux 1.2.9.
  73          - Dump Linux 1.2 and properly use the extended 1.3.x skb functions.
  74          - Problems forwarding from arc0e to arc0 in 1.3.x? (it may be a
  75            general kernel bug, though, since I heard other people complaining
  76            about forwarding problems on ethernet cards)
  77          - D_SKB doesn't work right on 1.3.x kernels.
  78 
  79            
  80         Sources:
  81          - Crynwr arcnet.com/arcether.com packet drivers.
  82          - arcnet.c v0.00 dated 1/1/94 and apparently by
  83                 Donald Becker - it didn't work :)
  84          - skeleton.c v0.05 dated 11/16/93 by Donald Becker
  85                 (from Linux Kernel 1.1.45)
  86          - The official ARCnet data sheets (!) thanks to Ken Cornetet
  87                 <kcornete@nyx10.cs.du.edu>
  88          - RFC's 1201 and 1051 (mostly 1201) - re: ARCnet IP packets
  89          - net/inet/eth.c (from kernel 1.1.50) for header-building info...
  90          - Alternate Linux ARCnet source by V.Shergin <vsher@sao.stavropol.su>
  91          - Textual information and more alternate source from Joachim Koenig
  92                 <jojo@repas.de>
  93 */
  94 
  95 static const char *version =
  96  "arcnet.c:v2.00 95/09/06 Avery Pennarun <apenwarr@foxnet.net>\n";
  97 
  98 /**************************************************************************/
  99 
 100 /* Define this if you want to detect network reconfigurations.
 101  * They may be a real nuisance on a larger ARCnet network: but if you are
 102  * a network administrator you probably would like to count them. 
 103  * Reconfigurations will be recorded in stats.tx_carrier_errors 
 104  * (the last field of the /proc/net/dev file).
 105  *
 106  * The card sends the reconfiguration signal when it loses the connection
 107  * to the rest of its network. It is a 'Hello, is anybody there?' cry.  This
 108  * usually happens when a new computer on the network is powered on or when
 109  * the cable is broken.
 110  */
 111 #define DETECT_RECONFIGS
 112 
 113 /* Define this if you want to make sure transmitted packets are "acknowledged"
 114  * by the destination host, as long as they're not to the broadcast address.
 115  *
 116  * That way, if one segment of a split packet doesn't get through, it can
 117  * be resent immediately rather than confusing the other end.
 118  *
 119  * Disable this to return to 1.01-style behaviour, if you have problems.
 120  */
 121 #define VERIFY_ACK
 122 
 123 /* Define this if you want to make it easier to use the "call trace" when
 124  * a kernel NULL pointer assignment occurs.  Hopefully unnecessary, most of
 125  * the time.
 126  */
 127 #undef static
 128 
 129 /**************************************************************************/
 130  
 131 
 132 #include <linux/config.h>
 133 #include <linux/version.h>
 134 
 135 #ifdef MODULE
 136 #include <linux/module.h>
 137 #endif /* MODULE */
 138 
 139 
 140 /* are we Linux 1.2.x? */
 141 #if LINUX_VERSION_CODE < 0x10300
 142 #define LINUX12
 143 #endif
 144 
 145 
 146 #include <linux/kernel.h>
 147 #include <linux/sched.h>
 148 #include <linux/types.h>
 149 #include <linux/fcntl.h>
 150 #include <linux/interrupt.h>
 151 #include <linux/ptrace.h>
 152 #include <linux/ioport.h>
 153 #include <linux/in.h>
 154 #include <linux/malloc.h>
 155 #include <linux/string.h>
 156 #include <linux/timer.h>
 157 #include <linux/errno.h>
 158 #include <linux/delay.h>
 159 #include <linux/if_arp.h>
 160 
 161 #include <asm/system.h>
 162 #include <asm/bitops.h>
 163 #include <asm/io.h>
 164 #include <asm/dma.h>
 165 
 166 #include <linux/netdevice.h>
 167 #include <linux/etherdevice.h>
 168 #include <linux/skbuff.h>
 169 
 170 #ifdef LINUX12
 171 #include "arp.h"
 172 #else
 173 #include <net/arp.h>
 174 #endif
 175 
 176 
 177 /* new debugging bitflags: each option can be enabled individually.
 178  *
 179  * these can be set while the driver is running by typing:
 180  *      ifconfig arc0 down metric 1xxx HOSTNAME
 181  *              where 1xx is 1000 + the debug level you want
 182  *              and HOSTNAME is your hostname/ip address
 183  * and then resetting your routes.
 184  */
 185 #define D_NORMAL        1       /* D_NORMAL  normal operational info    */
 186 #define D_INIT          2       /* D_INIT    show init/probe messages   */
 187 #define D_EXTRA         4       /* D_EXTRA   extra information          */
 188 /* debug levels past this point give LOTS of output! */
 189 #define D_DURING        8       /* D_DURING  during normal use (irq's)  */
 190 #define D_TX            16      /* D_TX      show tx packets            */
 191 #define D_RX            32      /* D_RX      show rx packets            */
 192 #define D_SKB           64      /* D_SKB     dump skb's                 */
 193 
 194 #ifndef ARCNET_DEBUG
 195 /*#define ARCNET_DEBUG D_NORMAL|D_INIT|D_EXTRA*/
 196 #define ARCNET_DEBUG D_NORMAL|D_INIT
 197 #endif
 198 int arcnet_debug = ARCNET_DEBUG;
 199 
 200 #ifndef HAVE_AUTOIRQ
 201 /* From auto_irq.c, in ioport.h for later versions. */
 202 extern void autoirq_setup(int waittime);
 203 extern int autoirq_report(int waittime);
 204 /* The map from IRQ number (as passed to the interrupt handler) to
 205    'struct device'. */
 206 extern struct device *irq2dev_map[16];
 207 #endif
 208 
 209 #ifndef HAVE_PORTRESERVE
 210 #define check_region(ioaddr, size)              0
 211 #define request_region(ioaddr, size)            do ; while (0)
 212 #endif
 213 
 214 /* macro to simplify debug checking */
 215 #define BUGLVL(x) if (arcnet_debug&(x))
 216 
 217 
 218 /* Some useful multiprotocol macros */
 219 #define TBUSY lp->adev->tbusy \
 220                 =lp->edev->tbusy
 221 #define IF_TBUSY (lp->adev->tbusy \
 222                 || lp->edev->tbusy)
 223 #define START lp->adev->start \
 224                 =lp->edev->start
 225 
 226 
 227 /* The number of low I/O ports used by the ethercard. */
 228 #define ARCNET_TOTAL_SIZE       16
 229 
 230 
 231 /* Handy defines for ARCnet specific stuff */
 232         /* COM 9026 (?) --> ARCnet register addresses */
 233 #define INTMASK (ioaddr+0)              /* writable */
 234 #define STATUS  (ioaddr+0)              /* readable */
 235 #define COMMAND (ioaddr+1)      /* writable, returns random vals on read (?) */
 236 #define RESET  (ioaddr+8)               /* software reset writable */
 237 
 238         /* Time needed for various things (in clock ticks, 1/100 sec) */
 239         /* We mostly don't bother with these - watch out. */
 240 #define RESETtime 40            /* reset */
 241 #define XMITtime 10             /* send (?) */
 242 #define ACKtime 10              /* acknowledge (?) */
 243 
 244         /* these are the max/min lengths of packet data. (including
 245          * ClientData header)
 246          * note: packet sizes 250, 251, 252 are impossible (God knows why)
 247          *  so exception packets become necessary.
 248          *
 249          * These numbers are compared with the length of the full packet,
 250          * including ClientData header.
 251          */
 252 #define MTU     253     /* normal packet max size */
 253 #define MinTU   257     /* extended packet min size */
 254 #define XMTU    508     /* extended packet max size */
 255 
 256         /* status/interrupt mask bit fields */
 257 #define TXFREEflag      0x01            /* transmitter available */
 258 #define TXACKflag       0x02            /* transmitted msg. ackd */
 259 #define RECONflag       0x04            /* system reconfigured */
 260 #define TESTflag        0x08            /* test flag */
 261 #define RESETflag       0x10            /* power-on-reset */
 262 #define RES1flag        0x20            /* unused */
 263 #define RES2flag        0x40            /* unused */
 264 #define NORXflag        0x80            /* receiver inhibited */
 265 
 266 #ifdef DETECT_RECONFIGS
 267         #define RECON_flag RECONflag
 268 #else
 269         #define RECON_flag 0
 270 #endif
 271 
 272        /* in the command register, the following bits have these meanings:
 273         *                0-2     command
 274         *                3-4     page number (for enable rcv/xmt command)
 275         *                 7      receive broadcasts
 276         */
 277 #define NOTXcmd         0x01            /* disable transmitter */
 278 #define NORXcmd         0x02            /* disable receiver */
 279 #define TXcmd           0x03            /* enable transmitter */
 280 #define RXcmd           0x04            /* enable receiver */
 281 #define CONFIGcmd       0x05            /* define configuration */
 282 #define CFLAGScmd       0x06            /* clear flags */
 283 #define TESTcmd         0x07            /* load test flags */
 284 
 285        /* flags for "clear flags" command */
 286 #define RESETclear      0x08            /* power-on-reset */
 287 #define CONFIGclear     0x10            /* system reconfigured */
 288 
 289       /* flags for "load test flags" command */
 290 #define TESTload        0x08            /* test flag (diagnostic) */
 291 
 292       /* byte deposited into first address of buffers on reset */
 293 #define TESTvalue       0321             /* that's octal for 0xD1 :) */
 294 
 295       /* for "enable receiver" command */
 296 #define RXbcasts        0x80            /* receive broadcasts */
 297 
 298       /* flags for "define configuration" command */
 299 #define NORMALconf      0x00            /* 1-249 byte packets */
 300 #define EXTconf         0x08            /* 250-504 byte packets */
 301 
 302         /* buffers (4 total) used for receive and xmit.
 303          */
 304 #define EnableReceiver()        outb(RXcmd|(recbuf<<3)|RXbcasts,COMMAND)
 305 
 306         /* RFC1201 Protocol ID's */
 307 #define ARC_P_IP        212             /* 0xD4 */
 308 #define ARC_P_ARP       213             /* 0xD5 */
 309 #define ARC_P_RARP      214             /* 0xD6 */
 310 #define ARC_P_IPX       250             /* 0xFA */
 311 
 312         /* MS LanMan/WfWg protocol */
 313 #define ARC_P_ETHER     0xE8
 314 
 315         /* Unsupported/indirectly supported protocols */
 316 #define ARC_P_LANSOFT   251             /* 0xFB */
 317 #define ARC_P_ATALK     0xDD
 318 
 319         /* these structures define the format of an arcnet packet. */
 320 #define NORMAL          0
 321 #define EXTENDED        1
 322 #define EXCEPTION       2
 323 
 324         /* the header required by the card itself */
 325 struct HardHeader
 326 {
 327         u_char  source,         /* source ARCnet - filled in automagically */
 328                 destination,    /* destination ARCnet - 0 for broadcast */
 329                 offset1,        /* offset of ClientData (256-byte packets) */
 330                 offset2;        /* offset of ClientData (512-byte packets) */
 331 };
 332 
 333         /* a complete ARCnet packet */
 334 union ArcPacket
 335 {
 336         struct HardHeader hardheader;   /* the hardware header */
 337         u_char raw[512];                /* raw packet info, incl ClientData */
 338 };
 339 
 340         /* the "client data" header - RFC-1201 information
 341          * notice that this screws up if it's not an even number of bytes
 342          * <sigh>
 343          */
 344 struct ClientData
 345 {
 346         /* data that's NOT part of real packet - we MUST get rid of it before
 347          * actually sending!!
 348          */
 349         u_char  saddr,          /* Source address - needed for IPX */
 350                 daddr;          /* Destination address */
 351         
 352         /* data that IS part of real packet */
 353         u_char  protocol_id,    /* ARC_P_IP, ARC_P_ARP, etc */
 354                 split_flag;     /* for use with split packets */
 355         u_short sequence;       /* sequence number */
 356 };
 357 #define EXTRA_CLIENTDATA (sizeof(struct ClientData)-4)
 358 
 359 
 360 /* "Incoming" is information needed for each address that could be sending
 361  * to us.  Mostly for partially-received split packets.
 362  */
 363 struct Incoming
 364 {
 365         struct sk_buff *skb;            /* packet data buffer             */
 366         unsigned char lastpacket,       /* number of last packet (from 1) */
 367                       numpackets;       /* number of packets in split     */
 368         u_short sequence;               /* sequence number of assembly    */
 369 };
 370 
 371 struct Outgoing
 372 {
 373         struct sk_buff *skb;            /* buffer from upper levels */
 374         struct ClientData *hdr;         /* clientdata of last packet */
 375         u_char *data;                   /* pointer to data in packet */
 376         short length,                   /* bytes total */
 377               dataleft,                 /* bytes left */
 378               segnum,                   /* segment being sent */
 379               numsegs,                  /* number of segments */
 380               seglen;                   /* length of segment */
 381 #ifdef VERIFY_ACK
 382         short lastload_dest,            /* can last loaded packet be acked? */
 383               lasttrans_dest;           /* can last TX'd packet be acked? */
 384 #endif
 385         
 386 };
 387 
 388 
 389 /* Information that needs to be kept for each board. */
 390 struct arcnet_local {
 391         struct enet_statistics stats;
 392         u_char arcnum;          /* arcnet number - our 8-bit address */
 393         u_short sequence;       /* sequence number (incs with each packet) */
 394         u_char recbuf,          /* receive buffer # (0 or 1) */
 395                txbuf,           /* transmit buffer # (2 or 3) */
 396                txready;         /* buffer where a packet is ready to send */
 397         short intx,             /* in TX routine? */
 398               in_txhandler,     /* in TX_IRQ handler? */
 399               sending;          /* transmit in progress? */
 400         short tx_left;          /* segments of split packet left to TX */
 401         
 402         struct timer_list timer; /* the timer interrupt struct */
 403         struct Incoming incoming[256];  /* one from each address */
 404         struct Outgoing outgoing; /* packet currently being sent */
 405         
 406         struct device *adev;    /* RFC1201 protocol device */
 407         struct device *edev;    /* Ethernet-Encap device */
 408 };
 409 
 410 
 411 /* Index to functions, as function prototypes. */
 412 extern int arcnet_probe(struct device *dev);
 413 #ifndef MODULE
 414 static int arcnet_memprobe(struct device *dev,u_char *addr);
 415 static int arcnet_ioprobe(struct device *dev, short ioaddr);
 416 #endif
 417 static int arcnetE_init(struct device *dev);
 418 
 419 static int arcnet_open(struct device *dev);
 420 static int arcnet_close(struct device *dev);
 421 static int arcnet_reset(struct device *dev);
 422 
 423 static int arcnetA_send_packet(struct sk_buff *skb, struct device *dev);
 424 static void arcnetA_continue_tx(struct device *dev);
 425 static void arcnetA_prepare_tx(struct device *dev,struct ClientData *hdr,
 426                 short length,char *data);
 427 static void arcnetA_go_tx(struct device *dev);
 428 
 429 static int arcnetE_send_packet(struct sk_buff *skb, struct device *dev);
 430 
 431 static void arcnet_interrupt(int irq,struct pt_regs *regs);
 432 static void arcnet_inthandler(struct device *dev);
 433 
 434 static void arcnet_rx(struct device *dev,int recbuf);
 435 static void arcnetA_rx(struct device *dev,struct ClientData *arcsoft,
 436         int length,u_char saddr, u_char daddr);
 437 static void arcnetE_rx(struct device *dev,u_char *arcsoft,
 438         int length,u_char saddr, u_char daddr);
 439 
 440 static struct enet_statistics *arcnet_get_stats(struct device *dev);
 441 static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
 442 
 443         /* functions for header/arp/etc building */
 444 #ifdef LINUX12
 445 int arcnetA_header(unsigned char *buff,struct device *dev,
 446                 unsigned short type,void *daddr,void *saddr,unsigned len,
 447                 struct sk_buff *skb);
 448 #else
 449 int arcnetA_header(struct sk_buff *skb,struct device *dev,
 450                 unsigned short type,void *daddr,void *saddr,unsigned len);
 451 #endif
 452 int arcnetA_rebuild_header(void *eth,struct device *dev,unsigned long raddr,
 453                 struct sk_buff *skb);
 454 unsigned short arcnetA_type_trans(struct sk_buff *skb,struct device *dev);
 455 
 456 #ifdef MODULE
 457 int  init_module(void);
 458 void cleanup_module(void);
 459 #endif
 460 
 461 #define tx_done(dev) 1
 462 
 463 #define JIFFER(time) for (delayval=0; delayval<(time*10); delayval++) \
 464                 udelay(1000);
 465                 
 466 
 467 /****************************************************************************
 468  *                                                                          *
 469  * Probe and initialization                                                 *
 470  *                                                                          *
 471  ****************************************************************************/
 472  
 473 
 474 /* Check for a network adaptor of this type, and return '0' if one exists.
 475  *  If dev->base_addr == 0, probe all likely locations.
 476  *  If dev->base_addr == 1, always return failure.
 477  *  If dev->base_addr == 2, allocate space for the device and return success
 478  *  (detachable devices only).
 479  */
 480 int
 481 arcnet_probe(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 482 {
 483 #ifndef MODULE
 484         /* I refuse to probe anything less than 0x200, because anyone using
 485          * an address like that should probably be shot.
 486          */
 487         int *port, ports[] = {/* first the suggested values! */
 488                               0x300,0x2E0,0x2F0,0x2D0,
 489                               /* ...now everything else possible. */
 490                               0x200,0x210,0x220,0x230,0x240,0x250,0x260,0x270,
 491                               0x280,0x290,0x2a0,0x2b0,0x2c0,
 492                                     0x310,0x320,0x330,0x340,0x350,0x360,0x370,
 493                               0x380,0x390,0x3a0,/* video ports, */0x3e0,0x3f0,
 494                               /* a null ends the list */
 495                               0};
 496         /* I'm not going to probe below 0xA0000 either, for similar reasons.
 497          */
 498         unsigned long *addr, addrs[] = {0xD0000,0xE0000,0xA0000,0xB0000,
 499                                         0xC0000,0xF0000,
 500                                         /* from <mdrejhon@magi.com> */
 501                                         0xE1000,
 502                                         0xDD000,0xDC000,
 503                                         0xD9000,0xD8000,0xD5000,0xD4000,0xD1000,
 504                                         0xCD000,0xCC000,
 505                                         0xC9000,0xC8000,0xC5000,0xC4000,
 506                                         /* terminator */
 507                                         0};
 508         int base_addr=dev->base_addr, status=0;
 509 #endif /* MODULE */
 510         int delayval;
 511         struct arcnet_local *lp;
 512 
 513 #if 0
 514         BUGLVL(D_NORMAL)
 515         {
 516                 printk(version);
 517                 printk("arcnet: ***\n");
 518                 printk("arcnet: * Read README.arcnet for important release notes!\n");
 519                 printk("arcnet: *\n");
 520                 printk("arcnet: * This is an ALPHA version!  (Last stable release: v2.00)  E-mail me if\n");
 521                 printk("arcnet: * you have any questions, comments, or bug reports.\n");
 522                 printk("arcnet: ***\n");
 523         }
 524 #else
 525         BUGLVL(D_INIT)
 526         {
 527                 printk(version);
 528                 printk("arcnet: ***\n");
 529                 printk("arcnet: * Read README.arcnet for important release notes!\n");
 530                 printk("arcnet: *\n");
 531                 printk("arcnet: * This version should be stable, but please e-mail\n");
 532                 printk("arcnet: * me if you have any questions or comments.\n");
 533                 printk("arcnet: ***\n");
 534         }
 535 #endif
 536 
 537         BUGLVL(D_INIT)
 538                 printk("arcnet: given: base %lXh, IRQ %Xh, shmem %lXh\n",
 539                         dev->base_addr,dev->irq,dev->mem_start);
 540                         
 541 #ifndef MODULE
 542         if (base_addr > 0x1ff)          /* Check a single specified location. */
 543                 status=arcnet_ioprobe(dev, base_addr);
 544         else if (base_addr > 0)         /* Don't probe at all. */
 545                 return ENXIO;
 546         else for (port = &ports[0]; *port; port++)
 547         {
 548                 int ioaddr = *port;
 549                 if (check_region(ioaddr, ARCNET_TOTAL_SIZE))
 550                 {
 551                         BUGLVL(D_INIT)
 552                                 printk("arcnet: Skipping %Xh because of check_region...\n",
 553                                         ioaddr);
 554                         continue;
 555                 }
 556 
 557                 status=arcnet_ioprobe(dev, ioaddr);
 558                 if (!status) break;
 559         }
 560         
 561         if (status) return status;
 562 
 563         /* ioprobe turned out okay.  Now give it a couple seconds to finish
 564          * initializing...
 565          */
 566         BUGLVL(D_INIT)
 567                 printk("arcnet: ioprobe okay!  Waiting for reset...\n");
 568         JIFFER(100);
 569 
 570         /* okay, now we have to find the shared memory area. */
 571         BUGLVL(D_INIT)
 572                 printk("arcnet: starting memory probe, given %lXh\n",
 573                         dev->mem_start);
 574         if (dev->mem_start)     /* value given - probe just that one */
 575         {
 576                 status=arcnet_memprobe(dev,(u_char *)dev->mem_start);
 577                 if (status) return status;
 578         }
 579         else                    /* no value given - probe everything */
 580         {
 581                 for (addr = &addrs[0]; *addr; addr++) {
 582                         status=arcnet_memprobe(dev,(u_char *)(*addr));
 583                         if (!status) break;
 584                 }
 585                 
 586                 if (status) return status;
 587         }
 588 #else /* MODULE */
 589         if (!dev->base_addr || !dev->irq || !dev->mem_start 
 590                 || !dev->rmem_start)
 591         {
 592                 printk("arcnet: loadable modules can't autoprobe!\n");
 593                 printk("arcnet:  try using io=, irqnum=, and shmem= on the insmod line.\n");
 594                 printk("arcnet:  you may also need num= to change the device name. (ie. num=1 for arc1)\n");
 595                 return ENODEV;
 596         }
 597 #endif
 598         /* now reserve the irq... */
 599         {       
 600                 int irqval = request_irq(dev->irq, &arcnet_interrupt, 0,
 601                         "arcnet");
 602                 if (irqval) {
 603                         printk("%s: unable to get IRQ %d (irqval=%d).\n",
 604                                 dev->name,dev->irq, irqval);
 605                         return EAGAIN;
 606                  }
 607          }
 608          
 609         /* Grab the region so we can find another board if autoIRQ fails. */
 610         request_region(dev->base_addr, ARCNET_TOTAL_SIZE,"arcnet");
 611         
 612         printk("%s: ARCnet card found at %03lXh, IRQ %d, ShMem at %lXh.\n", 
 613                 dev->name, dev->base_addr, dev->irq, dev->mem_start);
 614 
 615         /* Initialize the device structure. */
 616         dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
 617         if (dev->priv == NULL)
 618                 return -ENOMEM;
 619         memset(dev->priv, 0, sizeof(struct arcnet_local));
 620         lp=(struct arcnet_local *)(dev->priv);
 621 
 622         dev->open=arcnet_open;
 623         dev->stop=arcnet_close;
 624         dev->hard_start_xmit=arcnetA_send_packet;
 625         dev->get_stats=arcnet_get_stats;
 626 #ifdef HAVE_MULTICAST
 627         dev->set_multicast_list = &set_multicast_list;
 628 #endif
 629 
 630         /* Fill in the fields of the device structure with ethernet-generic
 631          * values.
 632          */
 633         ether_setup(dev);
 634         
 635         /* And now fill particular fields with arcnet values */
 636         dev->type=ARPHRD_ARCNET;
 637         dev->hard_header_len=sizeof(struct ClientData);
 638         BUGLVL(D_DURING)
 639                 printk("arcnet: ClientData header size is %d.\narcnet: HardHeader size is %d.\n",
 640                         sizeof(struct ClientData),sizeof(struct HardHeader));
 641 
 642                 /* since we strip EXTRA_CLIENTDATA bytes off before sending,
 643                  * we let Linux add that many bytes to the packet data...
 644                  */
 645         dev->addr_len=1;
 646         dev->broadcast[0]=0x00;
 647         
 648         BUGLVL(D_INIT) printk("arcnet: arcnet_probe: resetting card.\n");
 649         arcnet_reset(dev);
 650         JIFFER(50);
 651         BUGLVL(D_NORMAL)
 652                 printk("arcnet: We appear to be station %d (%02Xh)\n",
 653                         lp->arcnum,lp->arcnum);
 654         if (lp->arcnum==0)
 655                 printk("arcnet: WARNING!  Station address 0 is reserved for broadcasts!\n");
 656         if (lp->arcnum==255)
 657                 printk("arcnet: WARNING!  Station address 255 may confuse DOS networking programs!\n");
 658         dev->dev_addr[0]=lp->arcnum;
 659         lp->sequence=1;
 660         lp->recbuf=0;
 661 
 662         dev->hard_header=arcnetA_header;
 663         dev->rebuild_header=arcnetA_rebuild_header;
 664         
 665         #ifdef LINUX12
 666         dev->type_trans=arcnetA_type_trans;
 667         #endif
 668 
 669         return 0;
 670 }
 671 
 672 #ifndef MODULE
 673 
 674 int arcnet_ioprobe(struct device *dev, short ioaddr)
     /* [previous][next][first][last][top][bottom][index][help] */
 675 {
 676         int delayval,airq;
 677 
 678         BUGLVL(D_INIT)
 679         {
 680                 printk("arcnet: probing address %Xh\n",ioaddr);
 681                 printk("arcnet:  status1=%Xh\n",inb(STATUS));
 682         }
 683 
 684                 
 685         /* very simple - all we have to do is reset the card, and if there's
 686          * no irq, it's not an ARCnet.  We can also kill two birds with
 687          * one stone because we detect the IRQ at the same time :)
 688          */
 689          
 690         /* reset the card by reading the reset port */
 691         inb(RESET);
 692         JIFFER(RESETtime);
 693 
 694         /* if status port is FF, there's certainly no arcnet... give up. */
 695         if (inb(STATUS)==0xFF)
 696         {
 697                 BUGLVL(D_INIT)
 698                         printk("arcnet:  probe failed.  Status port empty.\n");
 699                 return ENODEV;
 700         }
 701 
 702 #if 0
 703         /* we'll try to be reasonably sure it's an arcnet by making sure
 704          * the value of the COMMAND port changes automatically once in a
 705          * while.  I have no idea what those values ARE, but at least
 706          * they work.
 707          */
 708         {
 709                 int initval,curval;
 710                 
 711                 curval=initval=inb(COMMAND);
 712                 delayval=jiffies+5;
 713                 while (delayval>=jiffies && curval==initval)
 714                         curval=inb(COMMAND);
 715                         
 716                 if (curval==initval)
 717                 {
 718                         printk("arcnet:  probe failed.  never-changing command port (%02Xh).\n",
 719                                 initval);
 720                         return ENODEV;
 721                 }
 722         }
 723 #endif
 724 
 725         BUGLVL(D_INIT)
 726                 printk("arcnet:  status2=%Xh\n",inb(STATUS));
 727 
 728         /* now we turn the reset bit off so we can IRQ next reset... */
 729         outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
 730         if (inb(STATUS) & RESETflag) /* reset flag STILL on */
 731         {
 732                 BUGLVL(D_INIT)
 733                         printk("arcnet:  probe failed.  eternal reset flag1...(status=%Xh)\n",
 734                                 inb(STATUS));
 735                 return ENODEV;
 736         }
 737 
 738         /* set up automatic IRQ detection */
 739         autoirq_setup(0);
 740         
 741 
 742         /* if we do this, we're sure to get an IRQ since the card has
 743          * just reset and the NORXflag is on until we tell it to start
 744          * receiving.
 745          *
 746          * However, this could, theoretically, cause a lockup.  Maybe I'm just
 747          * not very good at theory! :)
 748          */
 749         outb(NORXflag,INTMASK);
 750         JIFFER(RESETtime);
 751         outb(0,INTMASK);
 752 
 753         /* and turn the reset flag back off */
 754         outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
 755 
 756         airq = autoirq_report(0);
 757         BUGLVL(D_INIT) if (airq)
 758                 printk("arcnet:  autoirq is %d\n", airq);
 759 
 760         /* if there was no autoirq AND the user hasn't set any defaults,
 761          * give up.
 762          */
 763         if (!airq && !(dev->base_addr && dev->irq))
 764         {
 765                 BUGLVL(D_INIT)
 766                         printk("arcnet:  probe failed.  no autoirq...\n");
 767                 return ENODEV;
 768         }
 769 
 770         /* otherwise we probably have a card.  Let's make sure. */
 771         
 772         if (inb(STATUS) & RESETflag) /* reset flag on */
 773         {
 774                 /* now we turn the reset bit off */
 775                 outb(CFLAGScmd|RESETclear|CONFIGclear,COMMAND);
 776         }
 777         
 778         if (inb(STATUS) & RESETflag) /* reset flag STILL on */
 779         {
 780                 BUGLVL(D_INIT)
 781                         printk("arcnet:  probe failed.  eternal reset flag...(status=%Xh)\n",
 782                                 inb(STATUS));
 783                 return ENODEV;
 784         }
 785         
 786         /* okay, we've got a real, live ARCnet on our hands. */
 787         if (!dev->base_addr) dev->base_addr=ioaddr;
 788         
 789         if (dev->irq < 2)               /* "Auto-IRQ" */
 790         {
 791                 /* we already did the autoirq above, so store the values */
 792                 dev->irq=airq;
 793         }
 794         else if (dev->irq == 2)
 795         {
 796                 BUGLVL(D_NORMAL)
 797                         printk("arcnet: IRQ2 == IRQ9, don't worry.\n");
 798                 dev->irq = 9;
 799         }
 800 
 801         BUGLVL(D_INIT)
 802                 printk("arcnet: irq and base address seem okay. (%lXh, IRQ %d)\n",
 803                         dev->base_addr,dev->irq);
 804         return 0;
 805 }
 806 
 807 
 808 /* A memory probe that is called after the card is reset.
 809  * It checks for the official TESTvalue in byte 0 and makes sure the buffer
 810  * has certain characteristics of an ARCnet.
 811  */
 812 int arcnet_memprobe(struct device *dev,u_char *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 813 {
 814         BUGLVL(D_INIT)
 815                 printk("arcnet: probing memory at %lXh\n",(u_long)addr);
 816                 
 817         dev->mem_start=0;
 818 
 819         /* ARCnet memory byte 0 is TESTvalue */
 820         if (addr[0]!=TESTvalue)
 821         {
 822                 BUGLVL(D_INIT)
 823                         printk("arcnet:  probe failed.  addr=%lXh, addr[0]=%Xh (not %Xh)\n",
 824                                 (unsigned long)addr,addr[0],TESTvalue);
 825                 return ENODEV;
 826         }
 827         
 828         /* now verify the shared memory writability */
 829         addr[0]=0x42;
 830         if (addr[0]!=0x42)
 831         {
 832                 BUGLVL(D_INIT)
 833                         printk("arcnet:  probe failed.  addr=%lXh, addr[0]=%Xh (not 42h)\n",
 834                                 (unsigned long)addr,addr[0]);
 835                 return ENODEV;
 836         }
 837 
 838         /* got it!  fill in dev */
 839         dev->mem_start=(unsigned long)addr;
 840         dev->mem_end=dev->mem_start+512*4-1;
 841         dev->rmem_start=dev->mem_start+512*0;
 842         dev->rmem_end=dev->mem_start+512*2-1;
 843 
 844         return 0;
 845 }
 846 
 847 #endif /* MODULE */
 848 
 849 
 850 int arcnet_reset(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 851 {
 852         struct arcnet_local *lp=(struct arcnet_local *)dev->priv;
 853         short ioaddr=dev->base_addr;
 854         int delayval,recbuf=lp->recbuf;
 855         u_char *cardmem;
 856         
 857         outb(0,INTMASK);        /* no IRQ's, please! */
 858         
 859         BUGLVL(D_INIT)
 860                 printk("arcnet: Resetting %s (status=%Xh)\n",
 861                         dev->name,inb(STATUS));
 862 
 863         inb(RESET);             /* Reset by reading this port */
 864         JIFFER(RESETtime);
 865 
 866         outb(CFLAGScmd|RESETclear, COMMAND); /* clear flags & end reset */
 867         outb(CFLAGScmd|CONFIGclear,COMMAND);
 868 
 869         /* after a reset, the first byte of shared mem is TESTvalue and the
 870          * second byte is our 8-bit ARCnet address.
 871          */
 872         cardmem = (u_char *) dev->mem_start;
 873         if (cardmem[0] != TESTvalue)
 874         {
 875                 BUGLVL(D_INIT)
 876                         printk("arcnet: reset failed: TESTvalue not present.\n");
 877                 return 1;
 878         }
 879         lp->arcnum=cardmem[1];  /* save address for later use */
 880         
 881         /* clear out status variables */
 882         recbuf=lp->recbuf=0;
 883         lp->txbuf=2;
 884 
 885         /* enable extended (512-byte) packets */
 886         outb(CONFIGcmd|EXTconf,COMMAND);
 887         
 888         /* clean out all the memory to make debugging make more sense :) */
 889         BUGLVL(D_DURING)
 890                 memset((void *)dev->mem_start,0x42,2048);
 891         
 892         /* and enable receive of our first packet to the first buffer */
 893         EnableReceiver();
 894 
 895         /* re-enable interrupts */
 896         outb(NORXflag|RECON_flag,INTMASK);
 897         
 898         /* done!  return success. */
 899         return 0;
 900 }
 901 
 902 static int arcnetE_init(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 903 {
 904         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
 905 
 906         ether_setup(lp->edev);
 907         dev->dev_addr[0]=0;
 908         dev->dev_addr[5]=lp->arcnum;
 909         dev->mtu=493;   /* MTU is small because of missing packet splitting */
 910         lp->edev->open=NULL;
 911         lp->edev->stop=NULL;
 912         lp->edev->hard_start_xmit=arcnetE_send_packet;
 913 
 914         BUGLVL(D_EXTRA)
 915                 printk("%s: ARCnet \"Ethernet-Encap\" protocol initialized.\n",
 916                         lp->edev->name);
 917                         
 918         return 0;
 919 }
 920 
 921 
 922 /****************************************************************************
 923  *                                                                          *
 924  * Open and close the driver                                                *
 925  *                                                                          *
 926  ****************************************************************************/
 927  
 928 
 929 /* Open/initialize the board.  This is called sometime after booting when
 930  * the 'ifconfig' program is run.
 931  *
 932  * This routine should set everything up anew at each open, even
 933  * registers that "should" only need to be set once at boot, so that
 934  * there is non-reboot way to recover if something goes wrong.
 935  */
 936 static int
 937 arcnet_open(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 938 {
 939         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
 940 
 941         if (dev->metric>=1000)
 942         {
 943                 arcnet_debug=dev->metric-1000;
 944                 printk("arcnet: debug level set to %d\n",arcnet_debug);
 945                 dev->metric=1;
 946         }
 947 
 948         BUGLVL(D_NORMAL) printk(version);
 949 
 950         irq2dev_map[dev->irq] = dev;
 951 
 952         BUGLVL(D_EXTRA) printk("arcnet: arcnet_open: resetting card.\n");
 953         
 954         /* try to reset - twice if it fails the first time */
 955         if (arcnet_reset(dev) && arcnet_reset(dev))
 956                 return -ENODEV;
 957         
 958         dev->tbusy=0;
 959         dev->interrupt=0;
 960         lp->intx=0;
 961         lp->in_txhandler=0;
 962         
 963         /* The RFC1201 driver is the default - just store */
 964         lp->adev=dev;
 965         BUGLVL(D_EXTRA)
 966                 printk("%s:  ARCnet RFC1201 protocol initialized.\n",
 967                         lp->adev->name);
 968         
 969         /* Initialize the ethernet-encap protocol driver */
 970         lp->edev=(struct device *)kmalloc(sizeof(struct device),GFP_KERNEL);
 971         if (lp->edev == NULL)
 972                 return -ENOMEM;
 973         memcpy(lp->edev,dev,sizeof(struct device));
 974         lp->edev->name=(char *)kmalloc(10,GFP_KERNEL);
 975         if (lp->edev->name == NULL) {
 976                 kfree(lp->edev);
 977                 lp->edev = NULL;
 978                 return -ENOMEM;
 979         }
 980         sprintf(lp->edev->name,"%se",dev->name);
 981         lp->edev->init=arcnetE_init;
 982         register_netdev(lp->edev);
 983 
 984         /* we're started */
 985         START=1;
 986 
 987 #ifdef MODULE
 988         MOD_INC_USE_COUNT;
 989 #endif
 990                                         
 991         return 0;
 992 }
 993 
 994 
 995 /* The inverse routine to arcnet_open - shuts down the card.
 996  */
 997 static int
 998 arcnet_close(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 999 {
1000         int ioaddr = dev->base_addr;
1001         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1002         
1003         TBUSY=1;
1004         START=0;
1005         
1006         /* Flush the Tx and disable Rx here.     */
1007 
1008         outb(0,INTMASK);        /* no IRQ's */
1009         outb(NOTXcmd,COMMAND);  /* disable transmit */
1010         outb(NORXcmd,COMMAND);  /* disable receive */
1011         
1012         /* do NOT free lp->adev!!  It's static! */
1013         lp->adev=NULL;
1014         
1015         /* free the ethernet-encap protocol device */
1016         lp->edev->start=0;
1017         lp->edev->priv=NULL;
1018         dev_close(lp->edev);
1019         unregister_netdev(lp->edev);
1020         kfree(lp->edev->name);
1021         kfree(lp->edev);
1022         lp->edev=NULL;
1023 
1024         /* Update the statistics here. */
1025 
1026 #ifdef MODULE
1027         MOD_DEC_USE_COUNT;
1028 #endif
1029 
1030         return 0;
1031 }
1032 
1033 
1034 
1035 /****************************************************************************
1036  *                                                                          *
1037  * Transmitter routines                                                     *
1038  *                                                                          *
1039  ****************************************************************************/
1040 
1041 
1042 /* Called by the kernel in order to transmit a packet.
1043  */
1044 static int
1045 arcnetA_send_packet(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
1046 {
1047         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1048         int ioaddr=dev->base_addr;
1049 
1050         lp->intx++;
1051         
1052         BUGLVL(D_DURING)
1053                 printk("arcnet: transmit requested (status=%Xh, inTX=%d)\n",
1054                         inb(STATUS),lp->intx);
1055                         
1056         if (lp->in_txhandler)
1057         {
1058                 printk("arcnet: send_packet called while in txhandler!\n");
1059                 lp->intx--;
1060                 return 1;
1061         }
1062 
1063         if (IF_TBUSY)
1064         {
1065                 /* If we get here, some higher level has decided we are broken.
1066                    There should really be a "kick me" function call instead. */
1067                 int tickssofar = jiffies - dev->trans_start;
1068                 int recbuf=lp->recbuf;
1069                 int status=inb(STATUS);
1070                 
1071                 if (tickssofar < 5) 
1072                 {
1073                         BUGLVL(D_DURING)
1074                                 printk("arcnet: premature kickme! (status=%Xh ticks=%d o.skb=%ph numsegs=%d segnum=%d\n",
1075                                         status,tickssofar,lp->outgoing.skb,
1076                                         lp->outgoing.numsegs,
1077                                         lp->outgoing.segnum);
1078                         lp->intx--;
1079                         return 1;
1080                 }
1081 
1082                 BUGLVL(D_EXTRA)
1083                         printk("arcnet: transmit timed out (status=%Xh, inTX=%d, inTXh=%d, tickssofar=%d)\n",
1084                                 status,lp->intx,lp->in_txhandler,tickssofar);
1085                                 
1086                 lp->stats.tx_errors++;
1087 
1088                 /* Try to restart the adaptor. */
1089                 /*arcnet_reset(dev);*/
1090                 
1091                 outb(0,INTMASK);
1092                 if (status&NORXflag) EnableReceiver();
1093                 if (!(status&TXFREEflag)) outb(NOTXcmd,COMMAND);
1094                 dev->trans_start = jiffies;
1095 
1096                 if (lp->outgoing.skb)
1097                 {
1098                         dev_kfree_skb(lp->outgoing.skb,FREE_WRITE);
1099                         lp->stats.tx_dropped++;
1100                 }
1101                 lp->outgoing.skb=NULL;
1102 
1103                 TBUSY=0;
1104                 lp->intx--;
1105                 /*lp->intx=0;*/
1106                 /*lp->in_txhandler=0;*/
1107                 lp->txready=0;
1108                 lp->sending=0;
1109                 mark_bh(NET_BH);
1110 
1111                 outb(NORXflag|RECON_flag,INTMASK);
1112 
1113                 return 1;
1114         }
1115 
1116         /* If some higher layer thinks we've missed a tx-done interrupt
1117            we are passed NULL. Caution: dev_tint() handles the cli()/sti()
1118            itself. */
1119         if (skb == NULL) {
1120                 BUGLVL(D_NORMAL)
1121                         printk("arcnet: tx passed null skb (status=%Xh, inTX=%d, tickssofar=%ld)\n",
1122                                 inb(STATUS),lp->intx,jiffies-dev->trans_start);
1123                 dev_tint(dev);
1124                 lp->intx--;
1125                 return 0;
1126         }
1127         
1128         if (lp->txready)        /* transmit already in progress! */
1129         {
1130                 printk("arcnet: trying to start new packet while busy! (status=%Xh)\n",
1131                         inb(STATUS));
1132                 /*printk("arcnet: marking as not ready.\n");*/
1133                 outb(0,INTMASK);
1134                 outb(NOTXcmd,COMMAND); /* abort current send */
1135                 arcnet_inthandler(dev); /* fake an interrupt */
1136                 lp->stats.tx_errors++;
1137                 lp->intx--;
1138                 lp->txready=0;  /* we definitely need this line! */
1139                 
1140                 return 1;
1141         }
1142 
1143         /* Block a timer-based transmit from overlapping.  This could better be
1144            done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
1145         if (set_bit(0, (void*)&dev->tbusy) != 0)
1146         {
1147             printk("arcnet: transmitter called with busy bit set! (status=%Xh, inTX=%d, tickssofar=%ld)\n",
1148                         inb(STATUS),lp->intx,jiffies-dev->trans_start);
1149             lp->intx--;
1150             return -EBUSY;
1151         }
1152         else {
1153                 struct Outgoing *out=&(lp->outgoing);
1154                 
1155                 TBUSY=1;
1156                 
1157                 out->length = 1 < skb->len ? skb->len : 1;
1158                 out->hdr=(struct ClientData*)skb->data;
1159                 out->skb=skb;
1160                 
1161                 BUGLVL(D_SKB)
1162                 {
1163                         short i;
1164                         for( i=0; i< skb->len; i++)
1165                         {
1166                                 if( i%16 == 0 ) printk("\n[%04hX] ",i);
1167                                 printk("%02hX ",((unsigned char*)skb->data)[i]);
1168                         }
1169                         printk("\n");
1170                 }
1171 
1172                 out->hdr->sequence=(lp->sequence++);
1173 
1174                 if (lp->txready && inb(STATUS)&TXFREEflag)
1175                         arcnetA_go_tx(dev);
1176                 
1177                 /* fits in one packet? */
1178                 if (out->length-EXTRA_CLIENTDATA<=XMTU)
1179                 {
1180                         BUGLVL(D_DURING)
1181                                 printk("arcnet: not splitting %d-byte packet. (split_flag=%d)\n",
1182                                         out->length,out->hdr->split_flag);
1183                         BUGLVL(D_EXTRA) if (out->hdr->split_flag)
1184                                 printk("arcnet: short packet has split_flag set?! (split_flag=%d)\n",
1185                                         out->hdr->split_flag);
1186                         out->numsegs=1;
1187                         out->segnum=1;
1188                         arcnetA_prepare_tx(dev,out->hdr,
1189                                 out->length-sizeof(struct ClientData),
1190                                 ((char *)skb->data)+sizeof(struct ClientData));
1191 
1192                         /* done right away */
1193                         dev_kfree_skb(out->skb,FREE_WRITE);
1194                         out->skb=NULL;
1195                                         
1196                         if (!lp->sending)
1197                         {
1198                                 arcnetA_go_tx(dev);
1199                                 
1200                                 /* inform upper layers */
1201                                 TBUSY=0;
1202                                 mark_bh(NET_BH);
1203                         }
1204                 }
1205                 else                    /* too big for one - split it */
1206                 {
1207                         int maxsegsize=XMTU-4;
1208 
1209                         out->data=(u_char *)skb->data
1210                                         + sizeof(struct ClientData);
1211                         out->dataleft=out->length-sizeof(struct ClientData);
1212                         out->numsegs=(out->dataleft+maxsegsize-1)/maxsegsize;
1213                                 
1214                         out->segnum=0;
1215                                 
1216                         BUGLVL(D_TX) printk("arcnet: packet (%d bytes) split into %d fragments:\n",
1217                                 out->length,out->numsegs);
1218 
1219                         /* if a packet waiting, launch it */
1220                         if (lp->txready && inb(STATUS)&TXFREEflag)
1221                                 arcnetA_go_tx(dev);
1222 
1223                         if (!lp->txready)
1224                         {
1225                                 /* prepare a packet, launch it and prepare
1226                                  * another.
1227                                  */
1228                                 arcnetA_continue_tx(dev);
1229                                 if (!lp->sending)
1230                                 {
1231                                         arcnetA_go_tx(dev);
1232                                         arcnetA_continue_tx(dev);
1233                                         if (!lp->sending)
1234                                                 arcnetA_go_tx(dev);
1235                                 }
1236                         }
1237                         
1238                         /* if segnum==numsegs, the transmission is finished;
1239                          * free the skb right away.
1240                          */
1241                         if (out->segnum==out->numsegs)
1242                         {
1243                                 /* transmit completed */
1244                                 out->segnum++;
1245                                 if (out->skb)
1246                                         dev_kfree_skb(out->skb,FREE_WRITE);
1247                                 out->skb=NULL;
1248                         }
1249                 }
1250         }
1251 
1252         lp->intx--;
1253         lp->stats.tx_packets++;
1254         dev->trans_start=jiffies;
1255         return 0;
1256 }
1257 
1258 /* After an RFC1201 split packet has been set up, this function calls
1259  * arcnetA_prepare_tx to load the next segment into the card.  This function
1260  * does NOT automatically call arcnetA_go_tx to allow for easier double-
1261  * buffering.
1262  */
1263 static void arcnetA_continue_tx(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
1264 {
1265         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1266         int maxsegsize=XMTU-4;
1267         struct Outgoing *out=&(lp->outgoing);
1268         
1269         if (lp->txready)
1270         {
1271                 printk("arcnet: continue_tx: called with packet in buffer!\n");
1272                 return;
1273         }
1274 
1275         if (out->segnum>=out->numsegs)
1276         {
1277                 printk("arcnet: continue_tx: building segment %d of %d!\n",
1278                         out->segnum+1,out->numsegs);
1279         }
1280 
1281         if (!out->segnum)       /* first packet */
1282                 out->hdr->split_flag=((out->numsegs-2)<<1)+1;
1283         else
1284                 out->hdr->split_flag=out->segnum<<1;
1285 
1286         out->seglen=maxsegsize;
1287         if (out->seglen>out->dataleft) out->seglen=out->dataleft;
1288                         
1289         BUGLVL(D_TX) printk("arcnet: building packet #%d (%d bytes) of %d (%d total), splitflag=%d\n",
1290                 out->segnum+1,out->seglen,out->numsegs,
1291                 out->length,out->hdr->split_flag);
1292 
1293         arcnetA_prepare_tx(dev,out->hdr,out->seglen,out->data);
1294                 
1295         out->dataleft-=out->seglen;
1296         out->data+=out->seglen;
1297         out->segnum++;
1298 }
1299 
1300 
1301 /* Given an skb, copy a packet into the ARCnet buffers for later transmission
1302  * by arcnetA_go_tx.
1303  */
1304 static void
1305 arcnetA_prepare_tx(struct device *dev,struct ClientData *hdr,short length,
     /* [previous][next][first][last][top][bottom][index][help] */
1306                 char *data)
1307 {
1308         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1309         struct ClientData *arcsoft;
1310         union ArcPacket *arcpacket = 
1311                 (union ArcPacket *)(dev->mem_start+512*(lp->txbuf^1));
1312         u_char pkttype;
1313         int offset;
1314         short daddr;
1315         
1316         lp->txbuf=lp->txbuf^1;  /* XOR with 1 to alternate between 2 and 3 */
1317         
1318         length+=4;
1319 
1320         BUGLVL(D_TX)
1321                 printk("arcnet: arcnetA_prep_tx: hdr:%ph, length:%d, data:%ph\n",
1322                         hdr,length,data);
1323 
1324         /* clean out the page to make debugging make more sense :) */
1325         BUGLVL(D_DURING)
1326                 memset((void *)dev->mem_start+lp->txbuf*512,0x42,512);
1327 
1328         daddr=arcpacket->hardheader.destination=hdr->daddr;
1329 
1330         /* load packet into shared memory */
1331         if (length<=MTU)        /* Normal (256-byte) Packet */
1332         {
1333                 pkttype=NORMAL;
1334                         
1335                 arcpacket->hardheader.offset1=offset=256-length;
1336                 arcsoft=(struct ClientData *)
1337                         (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
1338         }
1339         else if (length>=MinTU) /* Extended (512-byte) Packet */
1340         {
1341                 pkttype=EXTENDED;
1342                 
1343                 arcpacket->hardheader.offset1=0;
1344                 arcpacket->hardheader.offset2=offset=512-length;
1345                 arcsoft=(struct ClientData *)
1346                         (&arcpacket->raw[offset-EXTRA_CLIENTDATA]);
1347         }
1348         else                            /* Exception Packet */
1349         {
1350                 pkttype=EXCEPTION;
1351                 
1352                 arcpacket->hardheader.offset1=0;
1353                 arcpacket->hardheader.offset2=offset=512-length-4;
1354                 arcsoft=(struct ClientData *)
1355                         (&arcpacket->raw[offset+4-EXTRA_CLIENTDATA]);
1356                 
1357                 /* exception-specific stuff - these four bytes
1358                  * make the packet long enough to fit in a 512-byte
1359                  * frame.
1360                  */
1361                 arcpacket->raw[offset+0]=hdr->protocol_id;
1362                 arcpacket->raw[offset+1]=0xFF; /* FF flag */
1363                         arcpacket->raw[offset+2]=0xFF; /* FF padding */
1364                         arcpacket->raw[offset+3]=0xFF; /* FF padding */
1365         }
1366 
1367 
1368         /* copy the packet into ARCnet shmem
1369          *  - the first bytes of ClientData header are skipped
1370          */
1371         memcpy((u_char*)arcsoft+EXTRA_CLIENTDATA,
1372                 (u_char*)hdr+EXTRA_CLIENTDATA,4);
1373         memcpy((u_char*)arcsoft+sizeof(struct ClientData),
1374                 data,length-4);
1375                 
1376         BUGLVL(D_DURING) printk("arcnet: transmitting packet to station %02Xh (%d bytes, type=%d)\n",
1377                         daddr,length,pkttype);
1378                         
1379         BUGLVL(D_TX)
1380         {
1381                 int countx,county;
1382                 
1383                 printk("arcnet: packet dump [tx] follows:");
1384 
1385                 for (county=0; county<16+(pkttype!=NORMAL)*16; county++)
1386                 {
1387                         printk("\n[%04X] ",county*16);
1388                         for (countx=0; countx<16; countx++)
1389                                 printk("%02X ",
1390                                         arcpacket->raw[county*16+countx]);
1391                 }
1392                 
1393                 printk("\n");
1394         }
1395 
1396 #ifdef VERIFY_ACK
1397         lp->outgoing.lastload_dest=hdr->daddr;
1398 #endif
1399         lp->txready=lp->txbuf;  /* packet is ready for sending */
1400 }
1401 
1402 /* Actually start transmitting a packet that was placed in the card's
1403  * buffer by arcnetA_prepare_tx.
1404  */
1405 static void
1406 arcnetA_go_tx(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
1407 {
1408         struct arcnet_local *lp=(struct arcnet_local *)dev->priv;
1409         int ioaddr=dev->base_addr;
1410 
1411         BUGLVL(D_DURING)
1412                 printk("arcnet: go_tx: status=%Xh\n",
1413                         inb(STATUS));
1414         
1415         if (!(inb(STATUS)&TXFREEflag) || !lp->txready) return;
1416 
1417         /* start sending */
1418         outb(TXcmd|(lp->txready<<3),COMMAND);
1419 
1420         outb(TXFREEflag|NORXflag|RECON_flag,INTMASK);
1421 
1422         dev->trans_start = jiffies;
1423         lp->txready=0;
1424         lp->sending++;
1425 #ifdef VERIFY_ACK       
1426         lp->outgoing.lasttrans_dest=lp->outgoing.lastload_dest;
1427         lp->outgoing.lastload_dest=0;
1428 #endif
1429 }
1430 
1431 
1432 /* Called by the kernel in order to transmit an ethernet-type packet.
1433  */
1434 static int
1435 arcnetE_send_packet(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
1436 {
1437         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1438         
1439         BUGLVL(D_DURING)
1440                 printk("%s: in arcnetE_send_packet (skb=%p)\n",dev->name,skb);
1441 
1442         if (IF_TBUSY)
1443         {
1444                 /* If we get here, some higher level has decided we are broken.
1445                    There should really be a "kick me" function call instead. */
1446                 int tickssofar = jiffies - dev->trans_start;
1447                 if (tickssofar < 10)
1448                         return 1;
1449                 printk("%s: transmit timed out\n",dev->name);
1450                 
1451                 /* Try to restart the adaptor. */
1452                 TBUSY=0;
1453                 dev->trans_start = jiffies;
1454                 return 0;
1455         }
1456 
1457         /* If some higher layer thinks we've missed an tx-done interrupt
1458            we are passed NULL. Caution: dev_tint() handles the cli()/sti()
1459            itself. */
1460         if (skb == NULL)
1461         {
1462                 dev_tint(dev);
1463                 return 0;
1464         }
1465 
1466         /* Block a timer-based transmit from overlapping.  This could better be
1467            done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
1468         if (set_bit(0, (void*)&dev->tbusy) != 0)
1469                 printk("%s: Transmitter access conflict.\n", dev->name);
1470         else
1471         {
1472                 union ArcPacket *arcpacket = 
1473                         (union ArcPacket *)(dev->mem_start+512*(lp->txbuf^1));
1474                 u_char *arcsoft,daddr;
1475                 short offset,length=skb->len+1;
1476                 
1477                 TBUSY=1;
1478                 
1479                 if (length>XMTU)
1480                 {
1481                         printk("arcnet: MTU for %s and %s must be <= 493 for ethernet encap.\n",
1482                                 lp->adev->name,lp->edev->name);
1483                         printk("arcnet: transmit aborted.\n");
1484 
1485                         dev_kfree_skb(skb,FREE_WRITE);
1486                         return 0;
1487                 }
1488                 
1489                 BUGLVL(D_DURING)
1490                         printk("arcnet: starting tx sequence...\n");
1491 
1492                 lp->txbuf=lp->txbuf^1; /* XOR with 1 to alternate btw 2 & 3 */
1493 
1494                 /* clean out the page to make debugging make more sense :) */
1495                 BUGLVL(D_DURING)
1496                         memset((void *)dev->mem_start+lp->txbuf*512,0x42,512);
1497 
1498                 /* broadcasts have address FF:FF:FF:FF:FF:FF in etherspeak */
1499                 if (((struct ethhdr*)(skb->data))->h_dest[0] == 0xFF)
1500                         daddr=arcpacket->hardheader.destination=0;
1501                 else
1502                         daddr=arcpacket->hardheader.destination=
1503                                 ((struct ethhdr*)(skb->data))->h_dest[5];
1504 
1505                 /* load packet into shared memory */
1506                 offset=512-length;
1507                 if (length>MTU)         /* long/exception packet */
1508                 {
1509                         if (length<MinTU) offset-=3;
1510                         arcpacket->hardheader.offset1=0;
1511                         arcpacket->hardheader.offset2=offset;
1512                 }
1513                 else                    /* short packet */
1514                 {
1515                         arcpacket->hardheader.offset1=(offset-=256);
1516                 }
1517                 
1518                 BUGLVL(D_DURING)
1519                         printk("arcnet: length=%Xh, offset=%Xh, offset1=%Xh, offset2=%Xh\n",
1520                                 length,offset,arcpacket->hardheader.offset1,
1521                                 arcpacket->hardheader.offset2);
1522                 
1523                 arcsoft=&arcpacket->raw[offset];
1524                 arcsoft[0]=ARC_P_ETHER;
1525                 arcsoft++;
1526                 
1527                 /* copy the packet into ARCnet shmem
1528                  *  - the first bytes of ClientData header are skipped
1529                  */
1530                 BUGLVL(D_DURING) printk("arcnet: ready to memcpy\n");
1531                 
1532                 memcpy(arcsoft,skb->data,skb->len);
1533                         
1534                 BUGLVL(D_DURING)
1535                         printk("arcnet: transmitting packet to station %02Xh (%d bytes)\n",
1536                                 daddr,length);
1537                                 
1538                 BUGLVL(D_TX)
1539                 {
1540                         int countx,county;
1541                         
1542                         printk("arcnet: packet dump [tx] follows:");
1543 
1544                         for (county=0; county<16+(length>=240)*16; county++)
1545                         {
1546                                 printk("\n[%04X] ",county*16);
1547                                 for (countx=0; countx<16; countx++)
1548                                         printk("%02X ",
1549                                                 arcpacket->raw[county*16+countx]);
1550                         }
1551                         
1552                         printk("\n");
1553                 }
1554 
1555         #ifdef VERIFY_ACK
1556                 lp->outgoing.lastload_dest=daddr;
1557         #endif
1558                 lp->txready=lp->txbuf;  /* packet is ready for sending */
1559 
1560                 arcnetA_go_tx(dev);
1561                 dev->trans_start = jiffies;
1562         }
1563 
1564         dev_kfree_skb(skb,FREE_WRITE);
1565 
1566         return 0;
1567 }
1568 
1569 
1570 /****************************************************************************
1571  *                                                                          *
1572  * Interrupt handler                                                        *
1573  *                                                                          *
1574  ****************************************************************************/
1575 
1576 
1577 /* The typical workload of the driver:  Handle the network interface
1578  * interrupts.  This doesn't do much right now except call arcnet_inthandler,
1579  * which takes different parameters but is sometimes called from other places
1580  * as well.
1581  */
1582 static void
1583 arcnet_interrupt(int irq,struct pt_regs *regs)
     /* [previous][next][first][last][top][bottom][index][help] */
1584 {
1585         struct device *dev = (struct device *)(irq2dev_map[irq]);
1586 
1587         if (dev==NULL || !dev->start)
1588         {
1589                 BUGLVL(D_EXTRA)
1590                         printk("arcnet: irq %d for unknown device.\n", irq);
1591                 return;
1592         }
1593 
1594         arcnet_inthandler(dev);
1595 }
1596 
1597 
1598 /* The actual interrupt handler routine - handle various IRQ's generated
1599  * by the card.
1600  */
1601 static void
1602 arcnet_inthandler(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
1603 {       
1604         struct arcnet_local *lp;
1605         int ioaddr, status, boguscount = 3, didsomething;
1606         
1607         if (dev->interrupt)
1608                 printk("arcnet: DRIVER PROBLEM!  Nested arcnet interrupts!\n");
1609         
1610         dev->interrupt = 1;
1611 
1612         ioaddr = dev->base_addr;
1613         lp = (struct arcnet_local *)dev->priv;
1614 
1615         outb(0,INTMASK);
1616         sti();
1617         
1618         BUGLVL(D_DURING)
1619                 printk("arcnet: in net_interrupt (status=%Xh)\n",inb(STATUS));
1620 
1621         do
1622         {
1623                 status = inb(STATUS);
1624                 didsomething=0;
1625         
1626                 if (!dev->start)
1627                 {
1628                         BUGLVL(D_DURING)
1629                                 printk("arcnet: ARCnet not yet initialized.  irq ignored. (status=%Xh)\n",
1630                                         status);
1631                         if (!(status&NORXflag))
1632                                 outb(NORXflag|RECON_flag,INTMASK);
1633 
1634                         dev->interrupt=0;
1635                         return;
1636                 }
1637         
1638                 /* RESET flag was enabled - card is resetting and if RX
1639                  * is disabled, it's NOT because we just got a packet.
1640                  */
1641                 if (status & RESETflag)
1642                 {
1643                         outb(CFLAGScmd|RESETclear,COMMAND);
1644                         BUGLVL(D_INIT)
1645                                 printk("arcnet: reset irq (status=%Xh)\n",
1646                                         status);
1647                 }
1648 #ifdef DETECT_RECONFIGS
1649                 if (status & RECONflag)
1650                 {
1651                         outb(CFLAGScmd|CONFIGclear,COMMAND);
1652                         BUGLVL(D_EXTRA)
1653                                 printk("arcnet: Network reconfiguration detected (status=%Xh)\n",
1654                                         status);
1655                         lp->stats.tx_carrier_errors++;
1656                 }
1657 #endif
1658 
1659                 /* RX is inhibited - we must have received something. */
1660                 if (status & NORXflag)
1661                 {
1662                         int recbuf=lp->recbuf=!lp->recbuf;
1663 
1664                         BUGLVL(D_DURING)
1665                                 printk("arcnet: receive irq (status=%Xh)\n",
1666                                         status);
1667 
1668                         /* enable receive of our next packet */
1669                         EnableReceiver();
1670                 
1671                         /* Got a packet. */
1672                         arcnet_rx(dev,!recbuf);
1673                         
1674                         didsomething++;
1675                 }
1676 
1677                 /* it can only be an xmit-done irq if we're xmitting :) */
1678                 if (status&TXFREEflag && !lp->in_txhandler && lp->sending)
1679                 {
1680                         struct Outgoing *out=&(lp->outgoing);
1681                         
1682                         lp->in_txhandler++;
1683                         lp->sending--;
1684                         
1685                         BUGLVL(D_DURING)
1686                                 printk("arcnet: TX IRQ (stat=%Xh, numsegs=%d, segnum=%d, skb=%ph)\n",
1687                                         status,out->numsegs,out->segnum,out->skb);
1688                                         
1689 #ifdef VERIFY_ACK
1690                         if (!(status&TXACKflag))
1691                         {
1692                                 if (lp->outgoing.lasttrans_dest != 0)
1693                                 {
1694                                         BUGLVL(D_NORMAL)
1695                                                 printk("arcnet: transmit was not acknowledged! (status=%Xh, dest=%d)\n",
1696                                                         status,
1697                                                         lp->outgoing.lasttrans_dest);
1698                                         lp->stats.tx_errors++;
1699                                 }
1700                                 else
1701                                 {
1702                                         BUGLVL(D_DURING)
1703                                                 printk("arcnet: broadcast was not acknowledged; that's normal (status=%Xh, dest=%d)\n",
1704                                                         status,
1705                                                         lp->outgoing.lasttrans_dest);
1706                                 }
1707                         }
1708 #endif
1709                                         
1710                         /* send packet if there is one */
1711                         if (lp->txready)
1712                         {
1713                                 arcnetA_go_tx(dev);
1714                                 didsomething++;
1715                         }
1716                         
1717                         if (lp->intx)
1718                         {
1719                                 lp->in_txhandler--;
1720                                 continue;
1721                         }
1722 
1723                         if (!lp->outgoing.skb)
1724                         {
1725                                 BUGLVL(D_DURING)
1726                                         printk("arcnet: TX IRQ done: no split to continue.\n");
1727                                 
1728                                 /* inform upper layers */
1729                                 if (!lp->txready && IF_TBUSY)
1730                                 {
1731                                         TBUSY=0;
1732                                         mark_bh(NET_BH);
1733                                 }
1734                                 
1735                                 lp->in_txhandler--;
1736                                 continue;
1737                         }
1738                         
1739                         /*lp->stats.tx_packets++;*/
1740                         
1741                         /* if more than one segment, and not all segments
1742                          * are done, then continue xmit.
1743                          */
1744                         if (out->segnum<out->numsegs)
1745                                 arcnetA_continue_tx(dev);
1746                         if (lp->txready && !lp->sending)
1747                                 arcnetA_go_tx(dev);
1748 
1749                         /* if segnum==numsegs, the transmission is finished;
1750                          * free the skb.
1751                          */
1752                         if (out->segnum>=out->numsegs)
1753                         {
1754                                 /* transmit completed */
1755                                 out->segnum++;
1756                                 if (out->skb)
1757                                         dev_kfree_skb(out->skb,FREE_WRITE);
1758                                 out->skb=NULL;
1759 
1760                                 /* inform upper layers */
1761                                 if (!lp->txready && IF_TBUSY)
1762                                 {
1763                                         TBUSY=0;
1764                                         mark_bh(NET_BH);
1765                                 }
1766                         }
1767                         didsomething++;
1768                         
1769                         lp->in_txhandler--;
1770                 }
1771 
1772         } while (--boguscount && didsomething);
1773 
1774         BUGLVL(D_DURING)
1775                 printk("arcnet: net_interrupt complete (status=%Xh)\n\n",
1776                         inb(STATUS));
1777 
1778         if (dev->start && lp->sending )
1779                 outb(NORXflag|TXFREEflag|RECON_flag,INTMASK);
1780         else
1781                 outb(NORXflag|RECON_flag,INTMASK);
1782 
1783         dev->interrupt=0;
1784 }
1785 
1786 
1787 /****************************************************************************
1788  *                                                                          *
1789  * Receiver routines                                                        *
1790  *                                                                          *
1791  ****************************************************************************/
1792 
1793 
1794 /* A packet has arrived; grab it from the buffers and possibly unsplit it.
1795  * This is a generic packet receiver that calls arcnet??_rx depending on the
1796  * protocol ID found.
1797  */
1798 static void
1799 arcnet_rx(struct device *dev,int recbuf)
     /* [previous][next][first][last][top][bottom][index][help] */
1800 {
1801         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1802         int ioaddr = dev->base_addr;
1803         union ArcPacket *arcpacket=
1804                 (union ArcPacket *)(dev->mem_start+recbuf*512);
1805         u_char *arcsoft;
1806         short length,offset;
1807         u_char daddr,saddr;
1808 
1809         saddr=arcpacket->hardheader.source;
1810         daddr=arcpacket->hardheader.destination;
1811         
1812         /* if source is 0, it's a "used" packet! */
1813         if (saddr==0)
1814         {
1815                 printk("arcnet: discarding old packet. (status=%Xh)\n",
1816                         inb(STATUS));
1817                 lp->stats.rx_errors++;
1818                 return;
1819         }
1820         arcpacket->hardheader.source=0;
1821         
1822         if (arcpacket->hardheader.offset1) /* Normal Packet */
1823         {
1824                 offset=arcpacket->hardheader.offset1;
1825                 arcsoft=&arcpacket->raw[offset];
1826                 length=256-offset;
1827         }
1828         else            /* ExtendedPacket or ExceptionPacket */
1829         {
1830                 offset=arcpacket->hardheader.offset2;
1831                 arcsoft=&arcpacket->raw[offset];
1832 
1833                 length=512-offset;
1834         }
1835         
1836         BUGLVL(D_DURING)
1837                 printk("arcnet: received packet from %02Xh to %02Xh (%d bytes)\n",
1838                         saddr,daddr,length);
1839 
1840         /* call the right receiver for the protocol */
1841         switch (arcsoft[0])
1842         {
1843         case ARC_P_IP:
1844         case ARC_P_ARP:
1845         case ARC_P_RARP:
1846         case ARC_P_IPX:
1847                 arcnetA_rx(dev,(struct ClientData*)arcsoft,
1848                         length,saddr,daddr);
1849                 break;
1850         case ARC_P_ETHER:
1851                 arcnetE_rx(dev,arcsoft,length,saddr,daddr);
1852                 break;          
1853         default:
1854                 printk("arcnet: received unknown protocol %d (%Xh)\n",
1855                         arcsoft[0],arcsoft[0]);
1856                 break;
1857         }
1858 
1859         BUGLVL(D_RX)
1860         {
1861                 int countx,county;
1862                 
1863                 printk("arcnet: rx packet dump follows:");
1864 
1865                 for (county=0; county<16+(length>240)*16; county++)
1866                 {
1867                         printk("\n[%04X] ",county*16);
1868                         for (countx=0; countx<16; countx++)
1869                                 printk("%02X ",
1870                                         arcpacket->raw[county*16+countx]);
1871                 }
1872                 
1873                 printk("\n");
1874         }
1875 
1876 
1877         /* clean out the page to make debugging make more sense :) */
1878         BUGLVL(D_DURING)
1879                 memset((void *)arcpacket->raw,0x42,512);
1880 
1881 
1882         /* If any worth-while packets have been received, a mark_bh(NET_BH)
1883          * has been done by netif_rx and Linux will handle them after we
1884          * return.
1885          */
1886 }
1887 
1888 
1889 /* Packet receiver for "standard" RFC1201-style packets
1890  */
1891 static void
1892 arcnetA_rx(struct device *dev,struct ClientData *arcsoft,
     /* [previous][next][first][last][top][bottom][index][help] */
1893         int length,u_char saddr, u_char daddr)
1894 {
1895         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
1896         struct sk_buff *skb;
1897         struct ClientData *soft;
1898         
1899         BUGLVL(D_DURING)
1900                 printk("arcnet: it's an RFC1201 packet (length=%d)\n",
1901                         length);
1902                         
1903         arcsoft=(struct ClientData *)((u_char *)arcsoft-EXTRA_CLIENTDATA);
1904         length+=EXTRA_CLIENTDATA;
1905 
1906         if (arcsoft->split_flag==0xFF)  /* Exception Packet */
1907         {
1908                 BUGLVL(D_DURING)
1909                         printk("arcnet: compensating for exception packet\n");
1910 
1911                 /* skip over 4-byte junkola */
1912                 arcsoft=(struct ClientData *)
1913                         ((u_char *)arcsoft + 4);
1914                 length-=4;
1915         }
1916         
1917         if (!arcsoft->split_flag)               /* not split */
1918         {
1919                 struct Incoming *in=&lp->incoming[saddr];
1920 
1921                 BUGLVL(D_RX) printk("arcnet: incoming is not split (splitflag=%d)\n",
1922                         arcsoft->split_flag);
1923                         
1924                 if (in->skb)    /* already assembling one! */
1925                 {
1926                         BUGLVL(D_EXTRA) printk("arcnet: aborting assembly (seq=%d) for unsplit packet (splitflag=%d, seq=%d)\n",
1927                                 in->sequence,arcsoft->split_flag,
1928                                 arcsoft->sequence);
1929                         kfree_skb(in->skb,FREE_WRITE);
1930                         lp->stats.tx_dropped++;
1931                         lp->stats.rx_errors++;
1932                         in->skb=NULL;
1933                 }
1934                 
1935                 in->sequence=arcsoft->sequence;
1936 
1937                 skb = alloc_skb(length, GFP_ATOMIC);
1938                 if (skb == NULL) {
1939                         printk("arcnet: Memory squeeze, dropping packet.\n");
1940                         lp->stats.rx_dropped++;
1941                         return;
1942                 }
1943                 soft=(struct ClientData *)skb->data;
1944                 
1945                 skb->len = length;
1946                 skb->dev = dev;
1947                 
1948                 memcpy((u_char *)soft+EXTRA_CLIENTDATA,
1949                         (u_char *)arcsoft+EXTRA_CLIENTDATA,
1950                         length-EXTRA_CLIENTDATA);
1951                 soft->daddr=daddr;
1952                 soft->saddr=saddr;
1953                 
1954                 /* ARP packets have problems when sent from DOS.
1955                  * source address is always 0 on some systems!  So we take
1956                  * the hardware source addr (which is impossible to fumble)
1957                  * and insert it ourselves.
1958                  */
1959                 if (soft->protocol_id == ARC_P_ARP)
1960                 {
1961                         struct arphdr *arp=(struct arphdr *)
1962                                         ((char *)soft+sizeof(struct ClientData));
1963 
1964                         /* make sure addresses are the right length */
1965                         if (arp->ar_hln==1 && arp->ar_pln==4)
1966                         {
1967                                 char *cptr=(char *)(arp)+sizeof(struct arphdr);
1968                                 
1969                                 if (!*cptr)     /* is saddr = 00? */
1970                                 {
1971                                         BUGLVL(D_EXTRA)
1972                                                 printk("arcnet: ARP source address was 00h, set to %02Xh.\n",
1973                                                         saddr);
1974                                         *cptr=saddr;
1975                                 }
1976                                 else BUGLVL(D_DURING) 
1977                                 {
1978                                         printk("arcnet: ARP source address (%Xh) is fine.\n",
1979                                                 *cptr);
1980                                 }
1981                         }
1982                         else
1983                         {
1984                                 printk("arcnet: funny-shaped ARP packet. (%Xh, %Xh)\n",
1985                                         arp->ar_hln,arp->ar_pln);
1986                                 lp->stats.rx_frame_errors++;
1987                         }
1988                 }
1989                 
1990                 BUGLVL(D_SKB)
1991                 {
1992                     short i;
1993                         for( i=0; i< skb->len; i++)
1994                         {
1995                                 if( i%16 == 0 ) printk("\n[%04hX] ",i);
1996                                 printk("%02hX ",((unsigned char*)skb->data)[i]);
1997                         }
1998                         printk("\n");
1999                 }
2000 
2001                         #ifndef LINUX12
2002                         skb->protocol=arcnetA_type_trans(skb,dev);
2003                         #endif
2004 
2005                 netif_rx(skb);
2006                 lp->stats.rx_packets++;
2007          }
2008          else                   /* split packet */
2009          {
2010                  /* NOTE:  MSDOS ARP packet correction should only need to
2011                   * apply to unsplit packets, since ARP packets are so short.
2012                   *
2013                   * My interpretation of the RFC1201 (ARCnet) document is that
2014                   * if a packet is received out of order, the entire assembly
2015                   * process should be aborted.
2016                   *
2017                   * The RFC also mentions "it is possible for successfully
2018                   * received packets to be retransmitted."  As of 0.40 all
2019                   * previously received packets are allowed, not just the
2020                   * most recent one.
2021                   *
2022                   * We allow multiple assembly processes, one for each
2023                   * ARCnet card possible on the network.  Seems rather like
2024                   * a waste of memory.  Necessary?
2025                   */
2026                   
2027                 struct Incoming *in=&lp->incoming[saddr];
2028                 
2029                 BUGLVL(D_RX) printk("arcnet: packet is split (splitflag=%d, seq=%d)\n",
2030                         arcsoft->split_flag,in->sequence);
2031 
2032                 if (in->skb && in->sequence!=arcsoft->sequence)
2033                 {
2034                         BUGLVL(D_EXTRA) printk("arcnet: wrong seq number, aborting assembly (expected=%d, seq=%d, splitflag=%d)\n",     
2035                                 in->sequence,arcsoft->sequence,
2036                                 arcsoft->split_flag);
2037                         kfree_skb(in->skb,FREE_WRITE);
2038                         in->skb=NULL;
2039                         lp->stats.tx_dropped++;
2040                         lp->stats.rx_fifo_errors++;
2041                         in->lastpacket=in->numpackets=0;
2042                 }
2043                   
2044                 if (arcsoft->split_flag & 1)    /* first packet in split */
2045                 {
2046                         BUGLVL(D_RX) printk("arcnet: brand new splitpacket (splitflag=%d)\n",
2047                                 arcsoft->split_flag);
2048                         if (in->skb)    /* already assembling one! */
2049                         {
2050                                 BUGLVL(D_EXTRA) printk("arcnet: aborting previous (seq=%d) assembly (splitflag=%d, seq=%d)\n",
2051                                         in->sequence,arcsoft->split_flag,
2052                                         arcsoft->sequence);
2053                                 lp->stats.tx_dropped++;
2054                                 lp->stats.rx_over_errors++;
2055                                 kfree_skb(in->skb,FREE_WRITE);
2056                         }
2057 
2058                         in->sequence=arcsoft->sequence;
2059                         in->numpackets=((unsigned)arcsoft->split_flag>>1)+2;
2060                         in->lastpacket=1;
2061                         
2062                         if (in->numpackets>16)
2063                         {
2064                                 BUGLVL(D_EXTRA) printk("arcnet: incoming packet more than 16 segments; dropping. (splitflag=%d)\n",
2065                                         arcsoft->split_flag);
2066                                 lp->stats.rx_dropped++;
2067                                 return;
2068                         }
2069                 
2070                         in->skb=skb=alloc_skb(508*in->numpackets
2071                                         + sizeof(struct ClientData),
2072                                         GFP_ATOMIC);
2073                         if (skb == NULL) {
2074                                 printk("%s: (split) memory squeeze, dropping packet.\n", 
2075                                         dev->name);
2076                                 lp->stats.rx_dropped++;
2077                                 return;
2078                         }
2079                                         
2080                         /* I don't know what this is for, but it DOES avoid
2081                          * warnings...
2082                          */
2083                         skb->free=1;
2084                         
2085                         soft=(struct ClientData *)skb->data;
2086                         
2087                         skb->len=sizeof(struct ClientData);
2088                         skb->dev=dev;
2089 
2090                         memcpy((u_char *)soft+EXTRA_CLIENTDATA,
2091                                 (u_char *)arcsoft+EXTRA_CLIENTDATA,
2092                                 sizeof(struct ClientData)-EXTRA_CLIENTDATA);
2093                         soft->split_flag=0; /* final packet won't be split */
2094                 }
2095                 else                    /* not first packet */
2096                 {
2097                         int packetnum=((unsigned)arcsoft->split_flag>>1) + 1;
2098 
2099                         /* if we're not assembling, there's no point
2100                          * trying to continue.
2101                          */                     
2102                         if (!in->skb)
2103                         {
2104                                 BUGLVL(D_EXTRA) printk("arcnet: can't continue split without starting first! (splitflag=%d, seq=%d)\n",
2105                                         arcsoft->split_flag,arcsoft->sequence);
2106                                 lp->stats.rx_errors++;
2107                                 return;
2108                         }
2109 
2110                         in->lastpacket++;
2111                         if (packetnum!=in->lastpacket) /* not the right flag! */
2112                         {
2113                                 /* harmless duplicate? ignore. */
2114                                 if (packetnum<=in->lastpacket-1)
2115                                 {
2116                                         BUGLVL(D_EXTRA) printk("arcnet: duplicate splitpacket ignored! (splitflag=%d)\n",
2117                                                 arcsoft->split_flag);
2118                                         return;
2119                                 }
2120                                 
2121                                 /* "bad" duplicate, kill reassembly */
2122                                 BUGLVL(D_EXTRA) printk("arcnet: out-of-order splitpacket, reassembly (seq=%d) aborted (splitflag=%d, seq=%d)\n",        
2123                                         in->sequence,arcsoft->split_flag,
2124                                         arcsoft->sequence);
2125                                 kfree_skb(in->skb,FREE_WRITE);
2126                                 in->skb=NULL;
2127                                 lp->stats.tx_dropped++;
2128                                 lp->stats.rx_fifo_errors++;
2129                                 in->lastpacket=in->numpackets=0;
2130                                 return;
2131                         }
2132 
2133                         soft=(struct ClientData *)in->skb->data;
2134                 }
2135                 
2136                 skb=in->skb;
2137                 
2138                 memcpy(skb->data+skb->len,
2139                        (u_char *)arcsoft+sizeof(struct ClientData),
2140                        length-sizeof(struct ClientData));
2141 
2142                 skb->len+=length-sizeof(struct ClientData);
2143                 
2144                 soft->daddr=daddr;
2145                 soft->saddr=saddr;
2146                 
2147                 /* are we done? */
2148                 if (in->lastpacket == in->numpackets)
2149                 {
2150                         if (!skb || !in->skb)
2151                                 printk("arcnet: ?!? done reassembling packet, no skb? (skb=%ph, in->skb=%ph)\n",
2152                                         skb,in->skb);
2153                         in->skb=NULL;
2154                         in->lastpacket=in->numpackets=0;
2155                         
2156                         BUGLVL(D_SKB)
2157                         {
2158                             short i;
2159                                 for( i=0; i< skb->len; i++)
2160                                 {
2161                                         if( i%16 == 0 ) printk("\n[%04hX] ",i);
2162                                         printk("%02hX ",((unsigned char*)skb->data)[i]);
2163                                 }
2164                                 printk("\n");
2165                         }
2166 
2167                         
2168                                 #ifndef LINUX12
2169                                 skb->protocol=arcnetA_type_trans(skb,dev);
2170                                 #endif
2171                                 
2172                         netif_rx(skb);
2173                         lp->stats.rx_packets++;
2174                 }
2175          }
2176 }
2177 
2178 
2179 /* Packet receiver for non-standard ethernet-style packets
2180  */
2181 static void
2182 arcnetE_rx(struct device *dev,u_char *arcsoft,
     /* [previous][next][first][last][top][bottom][index][help] */
2183         int length,u_char saddr, u_char daddr)
2184 {
2185         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
2186         struct sk_buff *skb;
2187         
2188         BUGLVL(D_DURING)
2189                 printk("arcnet: it's an ethernet-encap packet (length=%d)\n",
2190                         length);
2191 
2192         skb = alloc_skb(length, GFP_ATOMIC);
2193         if (skb == NULL) {
2194                 printk("arcnet: Memory squeeze, dropping packet.\n");
2195                 lp->stats.rx_dropped++;
2196                 return;
2197         }
2198         
2199         skb->len = length;
2200         skb->dev = lp->edev;
2201         
2202         memcpy(skb->data,(u_char *)arcsoft+1,length-1);
2203 
2204         BUGLVL(D_SKB)
2205         {
2206                 short i;
2207                 printk("arcnet: rx skb dump follows:\n");
2208                 for(i=0; i<skb->len; i++)
2209                 {
2210                         if (i%16==0)
2211                                 printk("\n[%04hX] ",i);
2212                         else
2213                                 printk("%02hX ",((u_char *)skb->data)[i]);
2214                 }
2215                 printk("\n");
2216         }
2217         
2218                 #ifndef LINUX12
2219                 skb->protocol=eth_type_trans(skb,dev);
2220                 #endif
2221         
2222         netif_rx(skb);
2223         lp->stats.rx_packets++;
2224 }
2225 
2226 
2227 /****************************************************************************
2228  *                                                                          *
2229  * Miscellaneous routines                                                   *
2230  *                                                                          *
2231  ****************************************************************************/
2232 
2233 
2234 /* Get the current statistics.  This may be called with the card open or
2235  * closed.
2236  */
2237 
2238 static struct enet_statistics *
2239 arcnet_get_stats(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
2240 {
2241         struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
2242 
2243         return &lp->stats;
2244 }
2245 
2246 /* Set or clear the multicast filter for this adaptor.
2247  * num_addrs == -1      Promiscuous mode, receive all packets
2248  * num_addrs == 0       Normal mode, clear multicast list
2249  * num_addrs > 0        Multicast mode, receive normal and MC packets, and do
2250  *                      best-effort filtering.
2251  */
2252 static void
2253 set_multicast_list(struct device *dev, int num_addrs, void *addrs)
     /* [previous][next][first][last][top][bottom][index][help] */
2254 {
2255 #if 0     /* no promiscuous mode at all on most ARCnet models */
2256         struct arcnet_local *lp=(struct arcnet_local *)(dev->priv);
2257 
2258         short ioaddr = dev->base_addr;
2259         if (num_addrs) {
2260                 outw(69, ioaddr);               /* Enable promiscuous mode */
2261         } else
2262                 outw(99, ioaddr);               /* Disable promiscuous mode, use normal mode */
2263 #endif
2264 }
2265 
2266 /* Create the ARCnet ClientData header for an arbitrary protocol layer
2267  *
2268  * saddr=NULL   means use device source address (always will anyway)
2269  * daddr=NULL   means leave destination address (eg unresolved arp)
2270  */
2271 #ifdef LINUX12
2272 int arcnetA_header(unsigned char *buff,struct device *dev,
     /* [previous][next][first][last][top][bottom][index][help] */
2273                 unsigned short type,void *daddr,void *saddr,unsigned len,
2274                 struct sk_buff *skb)
2275 #else
2276 int arcnetA_header(struct sk_buff *skb,struct device *dev,
2277                 unsigned short type,void *daddr,void *saddr,unsigned len)
2278 #endif
2279 {
2280         struct ClientData *head = (struct ClientData *)
2281 #ifdef LINUX12
2282                 buff;
2283 #else
2284                 skb_push(skb,dev->hard_header_len);
2285 #endif
2286 /*      struct arcnet_local *lp=(struct arcnet_local *)(dev->priv);*/
2287 
2288         /* set the protocol ID according to RFC-1201 */
2289         switch(type)
2290         {
2291         case ETH_P_IP:
2292                 head->protocol_id=ARC_P_IP;
2293                 break;
2294         case ETH_P_ARP:
2295                 head->protocol_id=ARC_P_ARP;
2296                 break;
2297         case ETH_P_RARP:
2298                 head->protocol_id=ARC_P_RARP;
2299                 break;
2300         case ETH_P_IPX:
2301                 head->protocol_id=ARC_P_IPX;
2302                 break;
2303         case ETH_P_ATALK:
2304                 head->protocol_id=ARC_P_ATALK;
2305                 break;
2306         default:
2307                 printk("arcnet: I don't understand protocol %d (%Xh)\n",
2308                         type,type);
2309                 return 0;
2310         }       
2311 
2312         /*
2313          * Set the source hardware address.
2314          *
2315          * This is pretty pointless for most purposes, but it can help
2316          * in debugging.  saddr is stored in the ClientData header and
2317          * removed before sending the packet (since ARCnet does not allow
2318          * us to change the source address in the actual packet sent)
2319          */
2320         if(saddr)
2321                 head->saddr=((u_char*)saddr)[0];
2322         else
2323                 head->saddr=((u_char*)(dev->dev_addr))[0];
2324 
2325 #if 0
2326         /*
2327          *      Anyway, the loopback-device should never use this function... 
2328          *
2329          *      And the chances of it using the ARCnet version of it are so
2330          *      tiny that I don't think we have to worry :)
2331          */
2332         if (dev->flags & IFF_LOOPBACK) 
2333         {
2334                 head->daddr=0;
2335                 return(dev->hard_header_len);
2336         }
2337 #endif
2338 
2339         head->split_flag=0;     /* split packets are done elsewhere */
2340         head->sequence=0;       /* so are sequence numbers */
2341 
2342         /* supposedly if daddr is NULL, we should ignore it... */
2343         if(daddr)
2344         {
2345                 head->daddr=((u_char*)daddr)[0];
2346                 return dev->hard_header_len;
2347         }
2348         else
2349                 head->daddr=0;  /* better fill one in anyway */
2350                 
2351         return -dev->hard_header_len;
2352 }
2353 
2354 
2355 /* Rebuild the ARCnet ClientData header. This is called after an ARP
2356  * (or in future other address resolution) has completed on this
2357  * sk_buff. We now let ARP fill in the other fields.
2358  */
2359 int arcnetA_rebuild_header(void *buff,struct device *dev,unsigned long dst,
     /* [previous][next][first][last][top][bottom][index][help] */
2360                 struct sk_buff *skb)
2361 {
2362         struct ClientData *head = (struct ClientData *)buff;
2363 
2364         /*
2365          * Only ARP and IP are currently supported
2366          */
2367          
2368         if(head->protocol_id != ARC_P_IP) 
2369         {
2370                 printk("arcnet: I don't understand resolve type %d (%Xh) addresses!\n",
2371                         head->protocol_id,head->protocol_id);
2372                 head->daddr=0;
2373                 /*memcpy(eth->h_source, dev->dev_addr, dev->addr_len);*/
2374                 return 0;
2375         }
2376 
2377         /*
2378          * Try and get ARP to resolve the header.
2379          */
2380 #ifdef CONFIG_INET       
2381         return arp_find(&(head->daddr), dst, dev, dev->pa_addr, skb)? 1 : 0;
2382 #else
2383         return 0;       
2384 #endif  
2385 }
2386                 
2387 /* Determine a packet's protocol ID.
2388  *
2389  * With ARCnet we have to convert everything to Ethernet-style stuff.
2390  */
2391 unsigned short arcnetA_type_trans(struct sk_buff *skb,struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
2392 {
2393         struct ClientData *head = (struct ClientData *) skb->data;
2394         struct arcnet_local *lp=(struct arcnet_local *) (dev->priv);
2395 
2396 #ifndef LINUX12
2397         /* Pull off the arcnet header. */
2398         skb->mac.raw=skb->data;
2399         skb_pull(skb,dev->hard_header_len);
2400 #endif
2401         
2402         if (head->daddr==0)
2403                 skb->pkt_type=PACKET_BROADCAST;
2404         else if (dev->flags&IFF_PROMISC)
2405         {
2406                 /* if we're not sending to ourselves :) */
2407                 if (head->daddr != dev->dev_addr[0])
2408                         skb->pkt_type=PACKET_OTHERHOST;
2409         }
2410         
2411         /* now return the protocol number */
2412         switch (head->protocol_id)
2413         {
2414         case ARC_P_IP:          return htons(ETH_P_IP);
2415         case ARC_P_ARP:         return htons(ETH_P_ARP);
2416         case ARC_P_RARP:        return htons(ETH_P_RARP);
2417         case ARC_P_IPX:         return htons(ETH_P_IPX);
2418         case ARC_P_ATALK:   return htons(ETH_P_ATALK); /* untested appletalk */
2419         case ARC_P_LANSOFT: /* don't understand.  fall through. */
2420         default:
2421                 BUGLVL(D_EXTRA)
2422                         printk("arcnet: received packet of unknown protocol id %d (%Xh)\n",
2423                                 head->protocol_id,head->protocol_id);
2424                 lp->stats.rx_frame_errors++;
2425                 return 0;
2426         }
2427 
2428         return htons(ETH_P_IP);
2429 }
2430 
2431 
2432 
2433 /****************************************************************************
2434  *                                                                          *
2435  * Kernel Loadable Module Support                                           *
2436  *                                                                          *
2437  ****************************************************************************/
2438 
2439 
2440 #ifdef MODULE
2441 char kernel_version[] = UTS_RELEASE;
2442 static char devicename[9] = { 0, };
2443 static struct device thiscard = {
2444   devicename, /* device name is inserted by linux/drivers/net/net_init.c */
2445   0, 0, 0, 0,
2446   0, 0,  /* I/O address, IRQ */
2447   0, 0, 0, NULL, arcnet_probe
2448 };
2449         
2450         
2451 int io=0x0;     /* <--- EDIT THESE LINES FOR YOUR CONFIGURATION */
2452 int irqnum=0;   /* or use the insmod io= irqnum= shmem= options */
2453 int shmem=0;
2454 int num=0;      /* number of device (ie for 0 for arc0, 1 for arc1...) */
2455 
2456 int
2457 init_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
2458 {
2459         sprintf(thiscard.name,"arc%d",num);
2460 
2461         thiscard.base_addr=io;
2462 
2463         thiscard.irq=irqnum;
2464         if (thiscard.irq==2) thiscard.irq=9;
2465 
2466         if (shmem)
2467         {
2468                 thiscard.mem_start=shmem;
2469                 thiscard.mem_end=thiscard.mem_start+512*4-1;
2470                 thiscard.rmem_start=thiscard.mem_start+512*0;
2471                 thiscard.rmem_end=thiscard.mem_start+512*2-1;
2472         }
2473 
2474         if (register_netdev(&thiscard) != 0)
2475                 return -EIO;
2476         return 0;
2477 }
2478 
2479 void
2480 cleanup_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
2481 {
2482         if (MOD_IN_USE)
2483         {
2484                 printk("%s: device busy, remove delayed\n",thiscard.name);
2485         }
2486         else
2487         {
2488                 if (thiscard.start) arcnet_close(&thiscard);
2489                 if (thiscard.irq) free_irq(thiscard.irq);
2490                 if (thiscard.base_addr) release_region(thiscard.base_addr,
2491                                                 ARCNET_TOTAL_SIZE);
2492                 unregister_netdev(&thiscard);
2493                 kfree(thiscard.priv);
2494                 thiscard.priv = NULL;
2495         }
2496 }
2497 
2498 #endif /* MODULE */
2499 
2500 
2501 
2502 /*
2503  * Local variables:
2504  *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c arcnet.c"
2505  *  version-control: t
2506  *  kept-new-versions: 5
2507  *  tab-width: 8
2508  * End:
2509  */
2510 

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