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-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
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 };
   65 
   66 /*
   67  * Some global constants
   68  */
   69 
   70 #define TX_INIT_RATE         16
   71 #define TX_INIT_MAX_RATE     64
   72 #define RX_INIT_LATENCY      64
   73 #define RX_INIT_EARLY_THRESH 64
   74 #define MIN_RX_EARLY_THRESHF   16 /* not less than ether_header */
   75 #define MIN_RX_EARLY_THRESHL   4
   76 
   77 #define EEPROMSIZE      0x40
   78 #define MAX_EEPROMBUSY  1000
   79 #define VX_LAST_TAG     0xd7
   80 #define VX_MAX_BOARDS   16
   81 #define VX_ID_PORT      0x100
   82 
   83 /*
   84  * some macros to acces long named fields
   85  */
   86 #define BASE    (sc->vx_io_addr)
   87 
   88 /*
   89  * Commands to read/write EEPROM trough EEPROM command register (Window 0,
   90  * Offset 0xa)
   91  */
   92 #define EEPROM_CMD_RD    0x0080 /* Read:  Address required (5 bits) */
   93 #define EEPROM_CMD_WR    0x0040 /* Write: Address required (5 bits) */
   94 #define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */
   95 #define EEPROM_CMD_EWEN  0x0030 /* Erase/Write Enable: No data required */
   96 
   97 #define EEPROM_BUSY             (1<<15)
   98 
   99 /*
  100  * Some short functions, worth to let them be a macro
  101  */
  102 
  103 /**************************************************************************
  104  *                                                                        *
  105  * These define the EEPROM data structure.  They are used in the probe
  106  * function to verify the existence of the adapter after having sent
  107  * the ID_Sequence.
  108  *
  109  * There are others but only the ones we use are defined here.
  110  *
  111  **************************************************************************/
  112 
  113 #define EEPROM_NODE_ADDR_0      0x0     /* Word */
  114 #define EEPROM_NODE_ADDR_1      0x1     /* Word */
  115 #define EEPROM_NODE_ADDR_2      0x2     /* Word */
  116 #define EEPROM_PROD_ID          0x3     /* 0x9[0-f]50 */
  117 #define EEPROM_MFG_ID           0x7     /* 0x6d50 */
  118 #define EEPROM_ADDR_CFG         0x8     /* Base addr */
  119 #define EEPROM_RESOURCE_CFG     0x9     /* IRQ. Bits 12-15 */
  120 #define EEPROM_OEM_ADDR_0       0xa     /* Word */
  121 #define EEPROM_OEM_ADDR_1       0xb     /* Word */
  122 #define EEPROM_OEM_ADDR_2       0xc     /* Word */
  123 #define EEPROM_SOFT_INFO_2      0xf     /* Software information 2 */
  124 
  125 #define NO_RX_OVN_ANOMALY       (1<<5)
  126 
  127 /**************************************************************************
  128  *                                                                                *
  129  * These are the registers for the 3Com 3c509 and their bit patterns when *
  130  * applicable.  They have been taken out the the "EtherLink III Parallel  *
  131  * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual *
  132  * from 3com.                                                             *
  133  *                                                                                *
  134  **************************************************************************/
  135 
  136 #define VX_COMMAND              0x0e    /* Write. BASE+0x0e is always a
  137                                          * command reg. */
  138 #define VX_STATUS               0x0e    /* Read. BASE+0x0e is always status
  139                                          * reg. */
  140 #define VX_WINDOW               0x0f    /* Read. BASE+0x0f is always window
  141                                          * reg. */
  142 /*
  143  * Window 0 registers. Setup.
  144  */
  145 /* Write */
  146 #define VX_W0_EEPROM_DATA       0x0c
  147 #define VX_W0_EEPROM_COMMAND    0x0a
  148 #define VX_W0_RESOURCE_CFG      0x08
  149 #define VX_W0_ADDRESS_CFG       0x06 
  150 #define VX_W0_CONFIG_CTRL       0x04
  151         /* Read */
  152 #define VX_W0_PRODUCT_ID        0x02
  153 #define VX_W0_MFG_ID            0x00
  154 
  155 
  156 /*
  157  * Window 1 registers. Operating Set.
  158  */
  159 /* Write */
  160 #define VX_W1_TX_PIO_WR_2       0x02
  161 #define VX_W1_TX_PIO_WR_1       0x00
  162 /* Read */
  163 #define VX_W1_FREE_TX           0x0c
  164 #define VX_W1_TX_STATUS         0x0b    /* byte */
  165 #define VX_W1_TIMER             0x0a    /* byte */
  166 #define VX_W1_RX_STATUS         0x08
  167 #define VX_W1_RX_PIO_RD_2       0x02
  168 #define VX_W1_RX_PIO_RD_1       0x00
  169 
  170 /*
  171  * Window 2 registers. Station Address Setup/Read
  172  */
  173 /* Read/Write */
  174 #define VX_W2_ADDR_5            0x05
  175 #define VX_W2_ADDR_4            0x04
  176 #define VX_W2_ADDR_3            0x03
  177 #define VX_W2_ADDR_2            0x02
  178 #define VX_W2_ADDR_1            0x01
  179 #define VX_W2_ADDR_0            0x00
  180 
  181 /*
  182  * Window 3 registers. FIFO Management.
  183  */
  184 /* Read */
  185 #define VX_W3_INTERNAL_CFG      0x00
  186 #define VX_W3_RESET_OPT         0x08
  187 #define VX_W3_FREE_TX           0x0c
  188 #define VX_W3_FREE_RX           0x0a
  189 
  190 /*
  191  * Window 4 registers. Diagnostics.
  192  */
  193 /* Read/Write */
  194 #define VX_W4_MEDIA_TYPE        0x0a
  195 #define VX_W4_CTRLR_STATUS      0x08
  196 #define VX_W4_NET_DIAG          0x06
  197 #define VX_W4_FIFO_DIAG         0x04
  198 #define VX_W4_HOST_DIAG         0x02
  199 #define VX_W4_TX_DIAG           0x00
  200 
  201 /*
  202  * Window 5 Registers.  Results and Internal status.
  203  */
  204 /* Read */
  205 #define VX_W5_READ_0_MASK       0x0c
  206 #define VX_W5_INTR_MASK         0x0a
  207 #define VX_W5_RX_FILTER         0x08
  208 #define VX_W5_RX_EARLY_THRESH   0x06
  209 #define VX_W5_TX_AVAIL_THRESH   0x02
  210 #define VX_W5_TX_START_THRESH   0x00
  211 
  212 /*
  213  * Window 6 registers. Statistics.
  214  */
  215 /* Read/Write */
  216 #define TX_TOTAL_OK             0x0c
  217 #define RX_TOTAL_OK             0x0a
  218 #define TX_DEFERRALS            0x08
  219 #define RX_FRAMES_OK            0x07
  220 #define TX_FRAMES_OK            0x06
  221 #define RX_OVERRUNS             0x05
  222 #define TX_COLLISIONS           0x04
  223 #define TX_AFTER_1_COLLISION    0x03
  224 #define TX_AFTER_X_COLLISIONS   0x02
  225 #define TX_NO_SQE               0x01
  226 #define TX_CD_LOST              0x00
  227 
  228 /****************************************
  229  *
  230  * Register definitions.
  231  *
  232  ****************************************/
  233 
  234 /*
  235  * Command register. All windows.
  236  *
  237  * 16 bit register.
  238  *     15-11:  5-bit code for command to be executed.
  239  *     10-0:   11-bit arg if any. For commands with no args;
  240  *            this can be set to anything.
  241  */
  242 #define GLOBAL_RESET            (u_short) 0x0000        /* Wait at least 1ms
  243                                                          * after issuing */
  244 #define WINDOW_SELECT           (u_short) (0x1<<11)
  245 #define START_TRANSCEIVER       (u_short) (0x2<<11)     /* Read ADDR_CFG reg to
  246                                                          * determine whether
  247                                                          * this is needed. If
  248                                                          * so; wait 800 uSec
  249                                                          * before using trans-
  250                                                          * ceiver. */
  251 #define RX_DISABLE              (u_short) (0x3<<11)     /* state disabled on
  252                                                          * power-up */
  253 #define RX_ENABLE               (u_short) (0x4<<11)
  254 #define RX_RESET                (u_short) (0x5<<11)
  255 #define RX_DISCARD_TOP_PACK     (u_short) (0x8<<11)
  256 #define TX_ENABLE               (u_short) (0x9<<11)
  257 #define TX_DISABLE              (u_short) (0xa<<11)
  258 #define TX_RESET                (u_short) (0xb<<11)
  259 #define REQ_INTR                (u_short) (0xc<<11)
  260 /*
  261  * The following C_* acknowledge the various interrupts. Some of them don't
  262  * do anything.  See the manual.
  263  */
  264 #define ACK_INTR                (u_short) (0x6800)
  265 #       define C_INTR_LATCH     (u_short) (ACK_INTR|0x1)
  266 #       define C_CARD_FAILURE   (u_short) (ACK_INTR|0x2)
  267 #       define C_TX_COMPLETE    (u_short) (ACK_INTR|0x4)
  268 #       define C_TX_AVAIL       (u_short) (ACK_INTR|0x8)
  269 #       define C_RX_COMPLETE    (u_short) (ACK_INTR|0x10)
  270 #       define C_RX_EARLY       (u_short) (ACK_INTR|0x20)
  271 #       define C_INT_RQD                (u_short) (ACK_INTR|0x40)
  272 #       define C_UPD_STATS      (u_short) (ACK_INTR|0x80)
  273 #define SET_INTR_MASK           (u_short) (0xe<<11)
  274 #define SET_RD_0_MASK           (u_short) (0xf<<11)
  275 #define SET_RX_FILTER           (u_short) (0x10<<11)
  276 #       define FIL_INDIVIDUAL   (u_short) (0x1)
  277 #       define FIL_MULTICAST     (u_short) (0x02)
  278 #       define FIL_BRDCST        (u_short) (0x04)
  279 #       define FIL_PROMISC       (u_short) (0x08)
  280 #define SET_RX_EARLY_THRESH     (u_short) (0x11<<11)
  281 #define SET_TX_AVAIL_THRESH     (u_short) (0x12<<11)
  282 #define SET_TX_START_THRESH     (u_short) (0x13<<11)
  283 #define STATS_ENABLE            (u_short) (0x15<<11)
  284 #define STATS_DISABLE           (u_short) (0x16<<11)
  285 #define STOP_TRANSCEIVER        (u_short) (0x17<<11)
  286 
  287 /*
  288  * Status register. All windows.
  289  *
  290  *     15-13:  Window number(0-7).
  291  *     12:     Command_in_progress.
  292  *     11:     reserved.
  293  *     10:     reserved.
  294  *     9:      reserved.
  295  *     8:      reserved.
  296  *     7:      Update Statistics.
  297  *     6:      Interrupt Requested.
  298  *     5:      RX Early.
  299  *     4:      RX Complete.
  300  *     3:      TX Available.
  301  *     2:      TX Complete.
  302  *     1:      Adapter Failure.
  303  *     0:      Interrupt Latch.
  304  */
  305 #define S_INTR_LATCH            (u_short) (0x1)
  306 #define S_CARD_FAILURE          (u_short) (0x2)
  307 #define S_TX_COMPLETE           (u_short) (0x4)
  308 #define S_TX_AVAIL              (u_short) (0x8)
  309 #define S_RX_COMPLETE           (u_short) (0x10)
  310 #define S_RX_EARLY              (u_short) (0x20)
  311 #define S_INT_RQD               (u_short) (0x40)
  312 #define S_UPD_STATS             (u_short) (0x80)
  313 #define S_COMMAND_IN_PROGRESS   (u_short) (0x1000)
  314 
  315 #define VX_BUSY_WAIT while (inw(BASE + VX_STATUS) & S_COMMAND_IN_PROGRESS)
  316 
  317 /* Address Config. Register.    
  318  * Window 0/Port 06
  319  */
  320 
  321 #define ACF_CONNECTOR_BITS      14  
  322 #define ACF_CONNECTOR_UTP       0
  323 #define ACF_CONNECTOR_AUI       1
  324 #define ACF_CONNECTOR_BNC       3
  325    
  326 #define INTERNAL_CONNECTOR_BITS 20
  327 #define INTERNAL_CONNECTOR_MASK 0x01700000
  328 
  329 /*
  330  * FIFO Registers. RX Status.
  331  *
  332  *     15:     Incomplete or FIFO empty.
  333  *     14:     1: Error in RX Packet   0: Incomplete or no error.
  334  *     13-11:  Type of error.
  335  *            1000 = Overrun.
  336  *            1011 = Run Packet Error.
  337  *            1100 = Alignment Error.
  338  *            1101 = CRC Error.
  339  *            1001 = Oversize Packet Error (>1514 bytes)
  340  *            0010 = Dribble Bits.
  341  *            (all other error codes, no errors.)
  342  *
  343  *     10-0:   RX Bytes (0-1514)
  344  */
  345 #define ERR_INCOMPLETE  (u_short) (0x8000)
  346 #define ERR_RX          (u_short) (0x4000)
  347 #define ERR_MASK        (u_short) (0x7800)
  348 #define ERR_OVERRUN     (u_short) (0x4000)
  349 #define ERR_RUNT        (u_short) (0x5800)
  350 #define ERR_ALIGNMENT   (u_short) (0x6000)
  351 #define ERR_CRC         (u_short) (0x6800)
  352 #define ERR_OVERSIZE    (u_short) (0x4800)
  353 #define ERR_DRIBBLE     (u_short) (0x1000)
  354 
  355 /*
  356  * TX Status. 
  357  *
  358  *   Reports the transmit status of a completed transmission. Writing this
  359  *   register pops the transmit completion stack.
  360  *
  361  *   Window 1/Port 0x0b.
  362  *
  363  *     7:      Complete
  364  *     6:      Interrupt on successful transmission requested.
  365  *     5:      Jabber Error (TP Only, TX Reset required. )
  366  *     4:      Underrun (TX Reset required. )
  367  *     3:      Maximum Collisions.
  368  *     2:      TX Status Overflow.
  369  *     1-0:    Undefined.
  370  *
  371  */
  372 #define TXS_COMPLETE            0x80
  373 #define TXS_INTR_REQ            0x40
  374 #define TXS_JABBER              0x20
  375 #define TXS_UNDERRUN            0x10
  376 #define TXS_MAX_COLLISION       0x8
  377 #define TXS_STATUS_OVERFLOW     0x4
  378 
  379 #define RS_AUI                  (1<<5)
  380 #define RS_BNC                  (1<<4)
  381 #define RS_UTP                  (1<<3)
  382 #define RS_T4                   (1<<0)
  383 #define RS_TX                   (1<<1)
  384 #define RS_FX                   (1<<2)
  385 #define RS_MII                  (1<<6)
  386 
  387 
  388 /*
  389  * FIFO Status (Window 4)
  390  *
  391  *   Supports FIFO diagnostics
  392  *
  393  *   Window 4/Port 0x04.1
  394  *
  395  *     15:      1=RX receiving (RO). Set when a packet is being received
  396  *              into the RX FIFO.
  397  *     14:      Reserved
  398  *     13:      1=RX underrun (RO). Generates Adapter Failure interrupt.
  399  *              Requires RX Reset or Global Reset command to recover.
  400  *              It is generated when you read past the end of a packet -
  401  *              reading past what has been received so far will give bad
  402  *              data.
  403  *     12:      1=RX status overrun (RO). Set when there are already 8
  404  *              packets in the RX FIFO. While this bit is set, no additional
  405  *              packets are received. Requires no action on the part of
  406  *              the host. The condition is cleared once a packet has been
  407  *              read out of the RX FIFO.
  408  *     11:      1=RX overrun (RO). Set when the RX FIFO is full (there
  409  *              may not be an overrun packet yet). While this bit is set,
  410  *              no additional packets will be received (some additional
  411  *              bytes can still be pending between the wire and the RX
  412  *              FIFO). Requires no action on the part of the host. The
  413  *              condition is cleared once a few bytes have been read out
  414  *              from the RX FIFO.
  415  *     10:      1=TX overrun (RO). Generates adapter failure interrupt.
  416  *              Requires TX Reset or Global Reset command to recover.
  417  *              Disables Transmitter.
  418  *     9-8:     Unassigned.
  419  *     7-0:     Built in self test bits for the RX and TX FIFO's.
  420  */
  421 #define FIFOS_RX_RECEIVING      (u_short) 0x8000
  422 #define FIFOS_RX_UNDERRUN       (u_short) 0x2000
  423 #define FIFOS_RX_STATUS_OVERRUN (u_short) 0x1000
  424 #define FIFOS_RX_OVERRUN        (u_short) 0x0800
  425 #define FIFOS_TX_OVERRUN        (u_short) 0x0400
  426 
  427 /*
  428  * Misc defines for various things.
  429  */
  430 #define TAG_ADAPTER                     0xd0
  431 #define ACTIVATE_ADAPTER_TO_CONFIG      0xff
  432 #define ENABLE_DRQ_IRQ                  0x0001
  433 #define MFG_ID                          0x506d  /* `TCM' */
  434 #define PROD_ID                         0x5090
  435 #define GO_WINDOW(x)            outw(BASE+VX_COMMAND, WINDOW_SELECT|(x))
  436 #define JABBER_GUARD_ENABLE     0x40
  437 #define LINKBEAT_ENABLE         0x80
  438 #define ENABLE_UTP              (JABBER_GUARD_ENABLE | LINKBEAT_ENABLE)
  439 #define DISABLE_UTP             0x0
  440 #define RX_BYTES_MASK           (u_short) (0x07ff)
  441 #define TX_INDICATE             1<<15
  442 
  443 #define VX_IOSIZE       0x20
  444 
  445 #define VX_CONNECTORS 8
  446 
  447 extern struct vx_softc *vx_softc[];
  448 extern u_long vx_count;
  449 extern struct vx_softc *vxalloc __P((int));
  450 extern void vxfree __P((struct vx_softc *));
  451 extern int vxattach __P((struct vx_softc *));
  452 extern void vxstop __P((struct vx_softc *));
  453 extern void vxintr __P((struct vx_softc *));
  454 extern int vxbusyeeprom __P((struct vx_softc *));

Cache object: 20e5062930d3924ad5bad6ef115d5458


[ 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.