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/utopia/utopia.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) 2003
    3  *      Fraunhofer Institute for Open Communication Systems (FhG Fokus).
    4  *      All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   25  * SUCH DAMAGE.
   26  *
   27  * Author: Hartmut Brandt <harti@freebsd.org>
   28  *
   29  * $FreeBSD: releng/9.0/sys/dev/utopia/utopia.h 142384 2005-02-24 16:56:36Z harti $
   30  */
   31 #ifndef _DEV_UTOPIA_UTOPIA_H
   32 #define _DEV_UTOPIA_UTOPIA_H
   33 
   34 /* Structure for user-level register formatting */
   35 struct utopia_print {
   36         uint8_t         type;   /* register type */
   37         uint8_t         reg;    /* register number */
   38         const char      *name;  /* register name */
   39         const char      *fmt;   /* format for printing */
   40 };
   41 
   42 /*
   43  * Types of registers
   44  */
   45 #define UTP_REGT_BITS           0x0     /* use printb to print */
   46 #define UTP_REGT_INT8           0x1     /* 8 bit hex number */
   47 #define UTP_REGT_INT10BITS      0x2     /* 10 bit hex number + 6 bit printb */
   48 #define UTP_REGT_INT12          0x3     /* 12 bit LE hex */
   49 #define UTP_REGT_INT16          0x4     /* 16 bit LE hex */
   50 #define UTP_REGT_INT19          0x5     /* 19 bit LE hex */
   51 #define UTP_REGT_INT20          0x6     /* 20 bit LE hex */
   52 #define UTP_REGT_INT21          0x7     /* 21 bit LE hex */
   53 #define UTP_REGT_INT18          0x8     /* 18 bit LE hex */
   54 
   55 /* number of additional registers per type */
   56 #define UTP_REG_ADD     0, 0, 1, 1, 1, 2, 2, 2, 2
   57 
   58 /* flags field */
   59 #define UTP_FL_NORESET          0x0001  /* cannot write MRESET register */
   60 #define UTP_FL_POLL_CARRIER     0x0002  /* need to poll for carrier */
   61 
   62 /* state field */
   63 #define UTP_ST_ACTIVE           0x0001  /* registers accessible */
   64 #define UTP_ST_SDH              0x0002  /* SDH or SONET */
   65 #define UTP_ST_UNASS            0x0004  /* produce unassigned cells */
   66 #define UTP_ST_NOSCRAMB         0x0008  /* no scrambling */
   67 #define UTP_ST_DETACH           0x0010  /* detaching */
   68 #define UTP_ST_ATTACHED         0x0020  /* successful attached */
   69 
   70 /* carrier field */
   71 #define UTP_CARR_UNKNOWN        0
   72 #define UTP_CARR_OK             1
   73 #define UTP_CARR_LOST           2
   74 
   75 /* loopback field */
   76 #define UTP_LOOP_NONE           0x0000
   77 #define UTP_LOOP_TIME           0x0001  /* timing source loopback */
   78 #define UTP_LOOP_DIAG           0x0002  /* diagnostic loopback */
   79 #define UTP_LOOP_LINE           0x0004  /* serial line loopback */
   80 #define UTP_LOOP_PARAL          0x0008  /* parallel diagnostic loopback */
   81 #define UTP_LOOP_TWIST          0x0010  /* twisted pair diagnostic loopback */
   82 #define UTP_LOOP_PATH           0x0020  /* diagnostic path loopback */
   83 
   84 /* type */
   85 #define UTP_TYPE_UNKNOWN        0
   86 #define UTP_TYPE_SUNI_LITE      1
   87 #define UTP_TYPE_SUNI_ULTRA     2
   88 #define UTP_TYPE_SUNI_622       3
   89 #define UTP_TYPE_IDT77105       4
   90 #define UTP_TYPE_IDT77155       5
   91 #define UTP_TYPE_CX28250        6
   92 
   93 /*
   94  * Statistics. These structures are versioned.
   95  */
   96 struct utopia_stats1 {
   97         uint32_t        version;        /* version of this statistics struct */
   98         uint32_t        fill;
   99 
  100         uint64_t        rx_sbip;        /* rx section BIP errors */
  101         uint64_t        rx_lbip;        /* rx line BIP errors */
  102         uint64_t        rx_lfebe;       /* rx line far end block errors */
  103         uint64_t        rx_pbip;        /* rx path BIP errors */
  104         uint64_t        rx_pfebe;       /* rx path far end block errors */
  105         uint64_t        rx_cells;       /* received cells */
  106         uint64_t        rx_corr;        /* correctable cell errors */
  107         uint64_t        rx_uncorr;      /* uncorrectable cell errors */
  108         uint64_t        rx_symerr;      /* symbol errors */
  109 
  110         uint64_t        tx_cells;       /* transmitted cells */
  111 };
  112 
  113 #ifdef _KERNEL
  114 
  115 #include <sys/queue.h>
  116 
  117 /*
  118  * These must be implemented by the card driver
  119  */
  120 struct utopia_methods {
  121         /* read at most n PHY registers starting at reg into val */
  122         int     (*readregs)(struct ifatm *, u_int reg, uint8_t *val, u_int *n);
  123 
  124         /* change the bits given by mask to them in val in register reg */
  125         int     (*writereg)(struct ifatm *, u_int reg, u_int mask, u_int val);
  126 };
  127 
  128 /*
  129  * Public state
  130  */
  131 struct utopia {
  132         struct ifatm    *ifatm;         /* driver data */
  133         struct ifmedia  *media;         /* driver supplied */
  134         struct mtx      *lock;          /* driver supplied */
  135         const struct utopia_methods *methods;
  136         LIST_ENTRY(utopia) link;        /* list of these structures */
  137         u_int           flags;          /* flags set by the driver */
  138         u_int           state;          /* current state */
  139         u_int           carrier;        /* carrier state */
  140         u_int           loopback;       /* loopback mode */
  141         const struct utopia_chip *chip; /* chip operations */
  142         struct utopia_stats1 stats;     /* statistics */
  143 };
  144 
  145 struct utopia_chip {
  146         /* type and name of the chip */
  147         u_int   type;
  148         const char *const name;
  149 
  150         /* number of registers */
  151         u_int   nregs;
  152 
  153         /* reset chip to known state */
  154         int     (*reset)(struct utopia *);
  155 
  156         /* set SONET/SDH mode */
  157         int     (*set_sdh)(struct utopia *, int sdh);
  158 
  159         /* set idle/unassigned cells */
  160         int     (*set_unass)(struct utopia *, int unass);
  161 
  162         /* enable/disable scrambling */
  163         int     (*set_noscramb)(struct utopia *, int noscramb);
  164 
  165         /* update carrier status */
  166         int     (*update_carrier)(struct utopia *);
  167 
  168         /* set loopback mode */
  169         int     (*set_loopback)(struct utopia *, u_int mode);
  170 
  171         /* handle interrupt */
  172         void    (*intr)(struct utopia *);
  173 
  174         /* update statistics */
  175         void    (*update_stats)(struct utopia *);
  176 };
  177 
  178 /*
  179  * These are implemented in the common utopia code
  180  */
  181 int utopia_attach(struct utopia *, struct ifatm *, struct ifmedia *,
  182     struct mtx *, struct sysctl_ctx_list *, struct sysctl_oid_list *,
  183     const struct utopia_methods *);
  184 void utopia_detach(struct utopia *);
  185 
  186 int utopia_start(struct utopia *);
  187 void utopia_stop(struct utopia *);
  188 
  189 void utopia_init_media(struct utopia *);
  190 void utopia_reset_media(struct utopia *);
  191 
  192 #define utopia_reset(S)                 ((S)->chip->reset((S)))
  193 #define utopia_set_sdh(S, SDH)          ((S)->chip->set_sdh((S), (SDH)))
  194 #define utopia_set_unass(S, U)          ((S)->chip->set_unass((S), (U)))
  195 #define utopia_set_noscramb(S, N)       ((S)->chip->set_noscramb((S), (N)))
  196 #define utopia_update_carrier(S)        ((S)->chip->update_carrier((S)))
  197 #define utopia_update_stats(S)          ((S)->chip->update_stats((S)))
  198 #define utopia_set_loopback(S, L)       ((S)->chip->set_loopback((S), (L)))
  199 #define utopia_intr(S)                  ((S)->chip->intr((S)))
  200 
  201 #endif /* _KERNEL */
  202 
  203 #endif  /* _DEV_UTOPIA_UTOPIA_H */

Cache object: 528c2de653d89c8a931c520127074f31


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