The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/vx/if_vxreg.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions are
    6  * met: 1. Redistributions of source code must retain the above copyright
    7  * notice, this list of conditions and the following disclaimer. 2. The name
    8  * of the author may not be used to endorse or promote products derived from
    9  * this software without specific prior written permission
   10  *
   11  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
   12  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   13  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
   14  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   15  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
   16  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   17  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   18  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   19  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   20  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   21  *
   22  October 2, 1994
   23 
   24  Modified by: Andres Vega Garcia
   25 
   26  INRIA - Sophia Antipolis, France
   27  e-mail: avega@sophia.inria.fr
   28  finger: avega@pax.inria.fr
   29 
   30  */
   31 
   32 /*
   33  * Created from if_epreg.h by Fred Gray (fgray@rice.edu) to support the
   34  * 3c590 family.
   35  */
   36 
   37 /*
   38  *  Promiscuous mode added and interrupt logic slightly changed
   39  *  to reduce the number of adapter failures. Transceiver select
   40  *  logic changed to use value from EEPROM. Autoconfiguration
   41  *  features added.
   42  *  Done by:
   43  *          Serge Babkin
   44  *          Chelindbank (Chelyabinsk, Russia)
   45  *          babkin@hq.icb.chel.su
   46  */
   47 
   48 /*
   49  * Ethernet software status per interface.
   50  */
   51 struct vx_softc {
   52     struct arpcom arpcom;       /* Ethernet common part         */
   53     int unit;                   /* unit number */
   54     u_int vx_io_addr;           /* i/o bus address              */
   55 #define MAX_MBS  8              /* # of mbufs we keep around    */
   56     struct mbuf *mb[MAX_MBS];   /* spare mbuf storage.          */
   57     int next_mb;                /* Which mbuf to use next.      */
   58     int last_mb;                /* Last mbuf.                   */
   59     char vx_connectors;         /* Connectors on this card.     */
   60     char vx_connector;          /* Connector to use.            */
   61     short tx_start_thresh;      /* Current TX_start_thresh.     */
   62     int tx_succ_ok;             /* # packets sent in sequence   */
   63                                 /* w/o underrun                 */
   64     struct callout_handle ch;   /* Callout handle for timeouts  */
   65     int buffill_pending;
   66 };
   67 
   68 /*
   69  * Some global constants
   70  */
   71 
   72 #define TX_INIT_RATE         16
   73 #define TX_INIT_MAX_RATE     64
   74 #define RX_INIT_LATENCY      64
   75 #define RX_INIT_EARLY_THRESH 64
   76 #define MIN_RX_EARLY_THRESHF   16 /* not less than ether_header */
   77 #define MIN_RX_EARLY_THRESHL   4
   78 
   79 #define EEPROMSIZE      0x40
   80 #define MAX_EEPROMBUSY  1000
   81 #define VX_LAST_TAG     0xd7
   82 #define VX_MAX_BOARDS   16
   83 #define VX_ID_PORT      0x100
   84 
   85 /*
   86  * some macros to acces long named fields
   87  */
   88 #define BASE    (sc->vx_io_addr)
   89 
   90 /*
   91  * Commands to read/write EEPROM trough EEPROM command register (Window 0,
   92  * Offset 0xa)
   93  */
   94 #define EEPROM_CMD_RD    0x0080 /* Read:  Address required (5 bits) */
   95 #define EEPROM_CMD_WR    0x0040 /* Write: Address required (5 bits) */
   96 #define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */
   97 #define EEPROM_CMD_EWEN  0x0030 /* Erase/Write Enable: No data required */
   98 
   99 #define EEPROM_BUSY             (1<<15)
  100 
  101 /*
  102  * Some short functions, worth to let them be a macro
  103  */
  104 
  105 /**************************************************************************
  106  *                                                                        *
  107  * These define the EEPROM data structure.  They are used in the probe
  108  * function to verify the existence of the adapter after having sent
  109  * the ID_Sequence.
  110  *
  111  * There are others but only the ones we use are defined here.
  112  *
  113  **************************************************************************/
  114 
  115 #define EEPROM_NODE_ADDR_0      0x0     /* Word */
  116 #define EEPROM_NODE_ADDR_1      0x1     /* Word */
  117 #define EEPROM_NODE_ADDR_2      0x2     /* Word */
  118 #define EEPROM_PROD_ID          0x3     /* 0x9[0-f]50 */
  119 #define EEPROM_MFG_ID           0x7     /* 0x6d50 */
  120 #define EEPROM_ADDR_CFG         0x8     /* Base addr */
  121 #define EEPROM_RESOURCE_CFG     0x9     /* IRQ. Bits 12-15 */
  122 #define EEPROM_OEM_ADDR_0       0xa     /* Word */
  123 #define EEPROM_OEM_ADDR_1       0xb     /* Word */
  124 #define EEPROM_OEM_ADDR_2       0xc     /* Word */
  125 #define EEPROM_SOFT_INFO_2      0xf     /* Software information 2 */
  126 
  127 #define NO_RX_OVN_ANOMALY       (1<<5)
  128 
  129 /**************************************************************************
  130  *                                                                                *
  131  * These are the registers for the 3Com 3c509 and their bit patterns when *
  132  * applicable.  They have been taken out the the "EtherLink III Parallel  *
  133  * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual *
  134  * from 3com.                                                             *
  135  *                                                                                *
  136  **************************************************************************/
  137 
  138 #define VX_COMMAND              0x0e    /* Write. BASE+0x0e is always a
  139                                          * command reg. */
  140 #define VX_STATUS               0x0e    /* Read. BASE+0x0e is always status
  141                                          * reg. */
  142 #define VX_WINDOW               0x0f    /* Read. BASE+0x0f is always window
  143                                          * reg. */
  144 /*
  145  * Window 0 registers. Setup.
  146  */
  147 /* Write */
  148 #define VX_W0_EEPROM_DATA       0x0c
  149 #define VX_W0_EEPROM_COMMAND    0x0a
  150 #define VX_W0_RESOURCE_CFG      0x08
  151 #define VX_W0_ADDRESS_CFG       0x06 
  152 #define VX_W0_CONFIG_CTRL       0x04
  153         /* Read */
  154 #define VX_W0_PRODUCT_ID        0x02
  155 #define VX_W0_MFG_ID            0x00
  156 
  157 
  158 /*
  159  * Window 1 registers. Operating Set.
  160  */
  161 /* Write */
  162 #define VX_W1_TX_PIO_WR_2       0x02
  163 #define VX_W1_TX_PIO_WR_1       0x00
  164 /* Read */
  165 #define VX_W1_FREE_TX           0x0c
  166 #define VX_W1_TX_STATUS         0x0b    /* byte */
  167 #define VX_W1_TIMER             0x0a    /* byte */
  168 #define VX_W1_RX_STATUS         0x08
  169 #define VX_W1_RX_PIO_RD_2       0x02
  170 #define VX_W1_RX_PIO_RD_1       0x00
  171 
  172 /*
  173  * Window 2 registers. Station Address Setup/Read
  174  */
  175 /* Read/Write */
  176 #define VX_W2_ADDR_5            0x05
  177 #define VX_W2_ADDR_4            0x04
  178 #define VX_W2_ADDR_3            0x03
  179 #define VX_W2_ADDR_2            0x02
  180 #define VX_W2_ADDR_1            0x01
  181 #define VX_W2_ADDR_0            0x00
  182 
  183 /*
  184  * Window 3 registers. FIFO Management.
  185  */
  186 /* Read */
  187 #define VX_W3_INTERNAL_CFG      0x00
  188 #define VX_W3_RESET_OPT         0x08
  189 #define VX_W3_FREE_TX           0x0c
  190 #define VX_W3_FREE_RX           0x0a
  191 
  192 /*
  193  * Window 4 registers. Diagnostics.
  194  */
  195 /* Read/Write */
  196 #define VX_W4_MEDIA_TYPE        0x0a
  197 #define VX_W4_CTRLR_STATUS      0x08
  198 #define VX_W4_NET_DIAG          0x06
  199 #define VX_W4_FIFO_DIAG         0x04
  200 #define VX_W4_HOST_DIAG         0x02
  201 #define VX_W4_TX_DIAG           0x00
  202 
  203 /*
  204  * Window 5 Registers.  Results and Internal status.
  205  */
  206 /* Read */
  207 #define VX_W5_READ_0_MASK       0x0c
  208 #define VX_W5_INTR_MASK         0x0a
  209 #define VX_W5_RX_FILTER         0x08
  210 #define VX_W5_RX_EARLY_THRESH   0x06
  211 #define VX_W5_TX_AVAIL_THRESH   0x02
  212 #define VX_W5_TX_START_THRESH   0x00
  213 
  214 /*
  215  * Window 6 registers. Statistics.
  216  */
  217 /* Read/Write */
  218 #define TX_TOTAL_OK             0x0c
  219 #define RX_TOTAL_OK             0x0a
  220 #define TX_DEFERRALS            0x08
  221 #define RX_FRAMES_OK            0x07
  222 #define TX_FRAMES_OK            0x06
  223 #define RX_OVERRUNS             0x05
  224 #define TX_COLLISIONS           0x04
  225 #define TX_AFTER_1_COLLISION    0x03
  226 #define TX_AFTER_X_COLLISIONS   0x02
  227 #define TX_NO_SQE               0x01
  228 #define TX_CD_LOST              0x00
  229 
  230 /****************************************
  231  *
  232  * Register definitions.
  233  *
  234  ****************************************/
  235 
  236 /*
  237  * Command register. All windows.
  238  *
  239  * 16 bit register.
  240  *     15-11:  5-bit code for command to be executed.
  241  *     10-0:   11-bit arg if any. For commands with no args;
  242  *            this can be set to anything.
  243  */
  244 #define GLOBAL_RESET            (u_short) 0x0000        /* Wait at least 1ms
  245                                                          * after issuing */
  246 #define WINDOW_SELECT           (u_short) (0x1<<11)
  247 #define START_TRANSCEIVER       (u_short) (0x2<<11)     /* Read ADDR_CFG reg to
  248                                                          * determine whether
  249                                                          * this is needed. If
  250                                                          * so; wait 800 uSec
  251                                                          * before using trans-
  252                                                          * ceiver. */
  253 #define RX_DISABLE              (u_short) (0x3<<11)     /* state disabled on
  254                                                          * power-up */
  255 #define RX_ENABLE               (u_short) (0x4<<11)
  256 #define RX_RESET                (u_short) (0x5<<11)
  257 #define RX_DISCARD_TOP_PACK     (u_short) (0x8<<11)
  258 #define TX_ENABLE               (u_short) (0x9<<11)
  259 #define TX_DISABLE              (u_short) (0xa<<11)
  260 #define TX_RESET                (u_short) (0xb<<11)
  261 #define REQ_INTR                (u_short) (0xc<<11)
  262 /*
  263  * The following C_* acknowledge the various interrupts. Some of them don't
  264  * do anything.  See the manual.
  265  */
  266 #define ACK_INTR                (u_short) (0x6800)
  267 #       define C_INTR_LATCH     (u_short) (ACK_INTR|0x1)
  268 #       define C_CARD_FAILURE   (u_short) (ACK_INTR|0x2)
  269 #       define C_TX_COMPLETE    (u_short) (ACK_INTR|0x4)
  270 #       define C_TX_AVAIL       (u_short) (ACK_INTR|0x8)
  271 #       define C_RX_COMPLETE    (u_short) (ACK_INTR|0x10)
  272 #       define C_RX_EARLY       (u_short) (ACK_INTR|0x20)
  273 #       define C_INT_RQD                (u_short) (ACK_INTR|0x40)
  274 #       define C_UPD_STATS      (u_short) (ACK_INTR|0x80)
  275 #define SET_INTR_MASK           (u_short) (0xe<<11)
  276 #define SET_RD_0_MASK           (u_short) (0xf<<11)
  277 #define SET_RX_FILTER           (u_short) (0x10<<11)
  278 #       define FIL_INDIVIDUAL   (u_short) (0x1)
  279 #       define FIL_MULTICAST     (u_short) (0x02)
  280 #       define FIL_BRDCST        (u_short) (0x04)
  281 #       define FIL_PROMISC       (u_short) (0x08)
  282 #define SET_RX_EARLY_THRESH     (u_short) (0x11<<11)
  283 #define SET_TX_AVAIL_THRESH     (u_short) (0x12<<11)
  284 #define SET_TX_START_THRESH     (u_short) (0x13<<11)
  285 #define STATS_ENABLE            (u_short) (0x15<<11)
  286 #define STATS_DISABLE           (u_short) (0x16<<11)
  287 #define STOP_TRANSCEIVER        (u_short) (0x17<<11)
  288 
  289 /*
  290  * Status register. All windows.
  291  *
  292  *     15-13:  Window number(0-7).
  293  *     12:     Command_in_progress.
  294  *     11:     reserved.
  295  *     10:     reserved.
  296  *     9:      reserved.
  297  *     8:      reserved.
  298  *     7:      Update Statistics.
  299  *     6:      Interrupt Requested.
  300  *     5:      RX Early.
  301  *     4:      RX Complete.
  302  *     3:      TX Available.
  303  *     2:      TX Complete.
  304  *     1:      Adapter Failure.
  305  *     0:      Interrupt Latch.
  306  */
  307 #define S_INTR_LATCH            (u_short) (0x1)
  308 #define S_CARD_FAILURE          (u_short) (0x2)
  309 #define S_TX_COMPLETE           (u_short) (0x4)
  310 #define S_TX_AVAIL              (u_short) (0x8)
  311 #define S_RX_COMPLETE           (u_short) (0x10)
  312 #define S_RX_EARLY              (u_short) (0x20)
  313 #define S_INT_RQD               (u_short) (0x40)
  314 #define S_UPD_STATS             (u_short) (0x80)
  315 #define S_COMMAND_IN_PROGRESS   (u_short) (0x1000)
  316 
  317 #define VX_BUSY_WAIT while (inw(BASE + VX_STATUS) & S_COMMAND_IN_PROGRESS)
  318 
  319 /* Address Config. Register.    
  320  * Window 0/Port 06
  321  */
  322 
  323 #define ACF_CONNECTOR_BITS      14  
  324 #define ACF_CONNECTOR_UTP       0
  325 #define ACF_CONNECTOR_AUI       1
  326 #define ACF_CONNECTOR_BNC       3
  327    
  328 #define INTERNAL_CONNECTOR_BITS 20
  329 #define INTERNAL_CONNECTOR_MASK 0x01700000
  330 
  331 /*
  332  * FIFO Registers. RX Status.
  333  *
  334  *     15:     Incomplete or FIFO empty.
  335  *     14:     1: Error in RX Packet   0: Incomplete or no error.
  336  *     13-11:  Type of error.
  337  *            1000 = Overrun.
  338  *            1011 = Run Packet Error.
  339  *            1100 = Alignment Error.
  340  *            1101 = CRC Error.
  341  *            1001 = Oversize Packet Error (>1514 bytes)
  342  *            0010 = Dribble Bits.
  343  *            (all other error codes, no errors.)
  344  *
  345  *     10-0:   RX Bytes (0-1514)
  346  */
  347 #define ERR_INCOMPLETE  (u_short) (0x8000)
  348 #define ERR_RX          (u_short) (0x4000)
  349 #define ERR_MASK        (u_short) (0x7800)
  350 #define ERR_OVERRUN     (u_short) (0x4000)
  351 #define ERR_RUNT        (u_short) (0x5800)
  352 #define ERR_ALIGNMENT   (u_short) (0x6000)
  353 #define ERR_CRC         (u_short) (0x6800)
  354 #define ERR_OVERSIZE    (u_short) (0x4800)
  355 #define ERR_DRIBBLE     (u_short) (0x1000)
  356 
  357 /*
  358  * TX Status. 
  359  *
  360  *   Reports the transmit status of a completed transmission. Writing this
  361  *   register pops the transmit completion stack.
  362  *
  363  *   Window 1/Port 0x0b.
  364  *
  365  *     7:      Complete
  366  *     6:      Interrupt on successful transmission requested.
  367  *     5:      Jabber Error (TP Only, TX Reset required. )
  368  *     4:      Underrun (TX Reset required. )
  369  *     3:      Maximum Collisions.
  370  *     2:      TX Status Overflow.
  371  *     1-0:    Undefined.
  372  *
  373  */
  374 #define TXS_COMPLETE            0x80
  375 #define TXS_INTR_REQ            0x40
  376 #define TXS_JABBER              0x20
  377 #define TXS_UNDERRUN            0x10
  378 #define TXS_MAX_COLLISION       0x8
  379 #define TXS_STATUS_OVERFLOW     0x4
  380 
  381 #define RS_AUI                  (1<<5)
  382 #define RS_BNC                  (1<<4)
  383 #define RS_UTP                  (1<<3)
  384 #define RS_T4                   (1<<0)
  385 #define RS_TX                   (1<<1)
  386 #define RS_FX                   (1<<2)
  387 #define RS_MII                  (1<<6)
  388 
  389 
  390 /*
  391  * FIFO Status (Window 4)
  392  *
  393  *   Supports FIFO diagnostics
  394  *
  395  *   Window 4/Port 0x04.1
  396  *
  397  *     15:      1=RX receiving (RO). Set when a packet is being received
  398  *              into the RX FIFO.
  399  *     14:      Reserved
  400  *     13:      1=RX underrun (RO). Generates Adapter Failure interrupt.
  401  *              Requires RX Reset or Global Reset command to recover.
  402  *              It is generated when you read past the end of a packet -
  403  *              reading past what has been received so far will give bad
  404  *              data.
  405  *     12:      1=RX status overrun (RO). Set when there are already 8
  406  *              packets in the RX FIFO. While this bit is set, no additional
  407  *              packets are received. Requires no action on the part of
  408  *              the host. The condition is cleared once a packet has been
  409  *              read out of the RX FIFO.
  410  *     11:      1=RX overrun (RO). Set when the RX FIFO is full (there
  411  *              may not be an overrun packet yet). While this bit is set,
  412  *              no additional packets will be received (some additional
  413  *              bytes can still be pending between the wire and the RX
  414  *              FIFO). Requires no action on the part of the host. The
  415  *              condition is cleared once a few bytes have been read out
  416  *              from the RX FIFO.
  417  *     10:      1=TX overrun (RO). Generates adapter failure interrupt.
  418  *              Requires TX Reset or Global Reset command to recover.
  419  *              Disables Transmitter.
  420  *     9-8:     Unassigned.
  421  *     7-0:     Built in self test bits for the RX and TX FIFO's.
  422  */
  423 #define FIFOS_RX_RECEIVING      (u_short) 0x8000
  424 #define FIFOS_RX_UNDERRUN       (u_short) 0x2000
  425 #define FIFOS_RX_STATUS_OVERRUN (u_short) 0x1000
  426 #define FIFOS_RX_OVERRUN        (u_short) 0x0800
  427 #define FIFOS_TX_OVERRUN        (u_short) 0x0400
  428 
  429 /*
  430  * Misc defines for various things.
  431  */
  432 #define TAG_ADAPTER                     0xd0
  433 #define ACTIVATE_ADAPTER_TO_CONFIG      0xff
  434 #define ENABLE_DRQ_IRQ                  0x0001
  435 #define MFG_ID                          0x506d  /* `TCM' */
  436 #define PROD_ID                         0x5090
  437 #define GO_WINDOW(x)            outw(BASE+VX_COMMAND, WINDOW_SELECT|(x))
  438 #define JABBER_GUARD_ENABLE     0x40
  439 #define LINKBEAT_ENABLE         0x80
  440 #define ENABLE_UTP              (JABBER_GUARD_ENABLE | LINKBEAT_ENABLE)
  441 #define DISABLE_UTP             0x0
  442 #define RX_BYTES_MASK           (u_short) (0x07ff)
  443 #define TX_INDICATE             1<<15
  444 
  445 #define VX_IOSIZE       0x20
  446 
  447 #define VX_CONNECTORS 8
  448 
  449 extern struct vx_softc *vx_softc[];
  450 extern u_long vx_count;
  451 extern struct vx_softc *vxalloc __P((int));
  452 extern void vxfree __P((struct vx_softc *));
  453 extern int vxattach __P((struct vx_softc *));
  454 extern void vxstop __P((struct vx_softc *));
  455 extern void vxintr __P((void *));
  456 extern int vxbusyeeprom __P((struct vx_softc *));

Cache object: d10059258a9d8b1d116ecd499c26433e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.