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/mlx/mlxvar.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) 1999 Michael Smith
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  *      $FreeBSD: releng/8.3/sys/dev/mlx/mlxvar.h 195534 2009-07-10 08:18:08Z scottl $
   27  */
   28 
   29 /*
   30  * Debugging levels:
   31  *  0 - quiet, only emit warnings
   32  *  1 - noisy, emit major function points and things done
   33  *  2 - extremely noisy, emit trace items in loops, etc.
   34  */
   35 #ifdef MLX_DEBUG
   36 #define debug(level, fmt, args...)      do { if (level <= MLX_DEBUG) printf("%s: " fmt "\n", __func__ , ##args); } while(0)
   37 #define debug_called(level)             do { if (level <= MLX_DEBUG) printf(__func__ ": called\n"); } while(0)
   38 #else
   39 #define debug(level, fmt, args...)
   40 #define debug_called(level)
   41 #endif
   42 
   43 /*
   44  * Regardless of the actual capacity of the controller, we will allocate space
   45  * for 64 s/g entries.  Typically controllers support 17 or 33 entries (64k or
   46  * 128k maximum transfer assuming 4k page size and non-optimal alignment), but
   47  * making that fit cleanly without crossing page boundaries requires rounding up
   48  * to the next power of two.
   49  */
   50 #define MLX_MAXPHYS     (128 * 124)
   51 #define MLX_NSEG        64
   52 
   53 #define MLX_NSLOTS      256             /* max number of command slots */
   54 
   55 #define MLX_MAXDRIVES   32              /* max number of system drives */
   56 
   57 /*
   58  * Structure describing a System Drive as attached to the controller.
   59  */
   60 struct mlx_sysdrive 
   61 {
   62     /* from MLX_CMD_ENQSYSDRIVE */
   63     u_int32_t           ms_size;
   64     int                 ms_state;
   65     int                 ms_raidlevel;
   66 
   67     /* synthetic geometry */
   68     int                 ms_cylinders;
   69     int                 ms_heads;
   70     int                 ms_sectors;
   71 
   72     /* handle for attached driver */
   73     device_t            ms_disk;
   74 };
   75 
   76 /*
   77  * Per-command control structure.
   78  */
   79 struct mlx_command 
   80 {
   81     TAILQ_ENTRY(mlx_command)    mc_link;        /* list linkage */
   82 
   83     struct mlx_softc            *mc_sc;         /* controller that owns us */
   84     u_int8_t                    mc_slot;        /* command slot we occupy */
   85     u_int16_t                   mc_status;      /* command completion status */
   86     time_t                      mc_timeout;     /* when this command expires */
   87     u_int8_t                    mc_mailbox[16]; /* command mailbox */
   88     u_int32_t                   mc_sgphys;      /* physical address of s/g array in controller space */
   89     int                         mc_nsgent;      /* number of entries in s/g map */
   90     int                         mc_flags;
   91 #define MLX_CMD_DATAIN          (1<<0)
   92 #define MLX_CMD_DATAOUT         (1<<1)
   93 #define MLX_CMD_PRIORITY        (1<<2)          /* high-priority command */
   94 
   95     void                        *mc_data;       /* data buffer */
   96     size_t                      mc_length;
   97     bus_dmamap_t                mc_dmamap;      /* DMA map for data */
   98     u_int32_t                   mc_dataphys;    /* data buffer base address controller space */
   99 
  100     void                        (* mc_complete)(struct mlx_command *mc);        /* completion handler */
  101     void                        *mc_private;    /* submitter-private data or wait channel */
  102     int                         mc_command;
  103 };
  104 
  105 /*
  106  * Per-controller structure.
  107  */
  108 struct mlx_softc 
  109 {
  110     /* bus connections */
  111     device_t            mlx_dev;
  112     struct cdev *mlx_dev_t;
  113     struct resource     *mlx_mem;       /* mailbox interface window */
  114     int                 mlx_mem_rid;
  115     int                 mlx_mem_type;
  116     bus_space_handle_t  mlx_bhandle;    /* bus space handle */
  117     bus_space_tag_t     mlx_btag;       /* bus space tag */
  118     bus_dma_tag_t       mlx_parent_dmat;/* parent DMA tag */
  119     bus_dma_tag_t       mlx_buffer_dmat;/* data buffer DMA tag */
  120     struct resource     *mlx_irq;       /* interrupt */
  121     void                *mlx_intr;      /* interrupt handle */
  122 
  123     /* scatter/gather lists and their controller-visible mappings */
  124     struct mlx_sgentry  *mlx_sgtable;   /* s/g lists */
  125     u_int32_t           mlx_sgbusaddr;  /* s/g table base address in bus space */
  126     bus_dma_tag_t       mlx_sg_dmat;    /* s/g buffer DMA tag */
  127     bus_dmamap_t        mlx_sg_dmamap;  /* map for s/g buffers */
  128     
  129     /* controller limits and features */
  130     struct mlx_enquiry2 *mlx_enq2;
  131     int                 mlx_feature;    /* controller features/quirks */
  132 #define MLX_FEAT_PAUSEWORKS     (1<<0)  /* channel pause works as expected */
  133 
  134     /* controller queues and arrays */
  135     TAILQ_HEAD(, mlx_command)   mlx_freecmds;           /* command structures available for reuse */
  136     TAILQ_HEAD(, mlx_command)   mlx_work;               /* active commands */
  137     struct mlx_command  *mlx_busycmd[MLX_NSLOTS];       /* busy commands */
  138     int                 mlx_busycmds;                   /* count of busy commands */
  139     struct mlx_sysdrive mlx_sysdrive[MLX_MAXDRIVES];    /* system drives */
  140     mlx_bioq            mlx_bioq;                       /* outstanding I/O operations */
  141     int                 mlx_waitbufs;                   /* number of bufs awaiting commands */
  142 
  143     /* controller status */
  144     int                 mlx_geom;
  145 #define MLX_GEOM_128_32         0       /* geoemetry translation modes */
  146 #define MLX_GEOM_256_63         1
  147     int                 mlx_state;
  148 #define MLX_STATE_INTEN         (1<<0)  /* interrupts have been enabled */
  149 #define MLX_STATE_SHUTDOWN      (1<<1)  /* controller is shut down */
  150 #define MLX_STATE_OPEN          (1<<2)  /* control device is open */
  151 #define MLX_STATE_SUSPEND       (1<<3)  /* controller is suspended */
  152     struct callout_handle mlx_timeout;  /* periodic status monitor */
  153     time_t              mlx_lastpoll;   /* last time_second we polled for status */
  154     u_int16_t           mlx_lastevent;  /* sequence number of the last event we recorded */
  155     int                 mlx_currevent;  /* sequence number last time we looked */
  156     int                 mlx_background; /* if != 0 rebuild or check is in progress */
  157 #define MLX_BACKGROUND_CHECK            1       /* we started a check */
  158 #define MLX_BACKGROUND_REBUILD          2       /* we started a rebuild */
  159 #define MLX_BACKGROUND_SPONTANEOUS      3       /* it just happened somehow */
  160     struct mlx_rebuild_status mlx_rebuildstat;  /* last rebuild status */
  161     struct mlx_pause    mlx_pause;      /* pending pause operation details */
  162 
  163     int                 mlx_locks;      /* reentrancy avoidance */
  164     int                 mlx_flags;
  165 #define MLX_SPINUP_REPORTED     (1<<0)  /* "spinning up drives" message displayed */
  166 #define MLX_EVENTLOG_BUSY       (1<<1)  /* currently reading event log */
  167 
  168     /* interface-specific accessor functions */
  169     int                 mlx_iftype;     /* interface protocol */
  170 #define MLX_IFTYPE_2    2
  171 #define MLX_IFTYPE_3    3
  172 #define MLX_IFTYPE_4    4
  173 #define MLX_IFTYPE_5    5
  174     int                 (* mlx_tryqueue)(struct mlx_softc *sc, struct mlx_command *mc);
  175     int                 (* mlx_findcomplete)(struct mlx_softc *sc, u_int8_t *slot, u_int16_t *status);
  176     void                (* mlx_intaction)(struct mlx_softc *sc, int action);
  177     int                 (* mlx_fw_handshake)(struct mlx_softc *sc, int *error, int *param1, int *param2);
  178 #define MLX_INTACTION_DISABLE           0
  179 #define MLX_INTACTION_ENABLE            1
  180 };
  181 
  182 /*
  183  * Simple (stupid) locks.
  184  *
  185  * Note that these are designed to avoid reentrancy, not concurrency, and will
  186  * need to be replaced with something better.
  187  */
  188 #define MLX_LOCK_COMPLETING     (1<<0)
  189 #define MLX_LOCK_STARTING       (1<<1)
  190 
  191 static __inline int
  192 mlx_lock_tas(struct mlx_softc *sc, int lock)
  193 {
  194     if ((sc)->mlx_locks & (lock))
  195         return(1);
  196     atomic_set_int(&sc->mlx_locks, lock);
  197     return(0);
  198 }
  199 
  200 static __inline void
  201 mlx_lock_clr(struct mlx_softc *sc, int lock)
  202 {
  203     atomic_clear_int(&sc->mlx_locks, lock);
  204 }
  205 
  206 /*
  207  * Interface between bus connections and driver core.
  208  */
  209 extern void             mlx_free(struct mlx_softc *sc);
  210 extern int              mlx_attach(struct mlx_softc *sc);
  211 extern void             mlx_startup(struct mlx_softc *sc);
  212 extern void             mlx_intr(void *data);
  213 extern int              mlx_detach(device_t dev);
  214 extern int              mlx_shutdown(device_t dev);
  215 extern int              mlx_suspend(device_t dev); 
  216 extern int              mlx_resume(device_t dev);
  217 extern d_open_t         mlx_open;
  218 extern d_close_t        mlx_close;
  219 extern d_ioctl_t        mlx_ioctl;
  220 
  221 extern devclass_t       mlx_devclass;
  222 extern devclass_t       mlxd_devclass;
  223 
  224 /*
  225  * Mylex System Disk driver
  226  */
  227 struct mlxd_softc 
  228 {
  229     device_t            mlxd_dev;
  230     struct mlx_softc    *mlxd_controller;
  231     struct mlx_sysdrive *mlxd_drive;
  232     struct disk         *mlxd_disk;
  233     int                 mlxd_unit;
  234     int                 mlxd_flags;
  235 #define MLXD_OPEN       (1<<0)          /* drive is open (can't shut down) */
  236 };
  237 
  238 /*
  239  * Interface between driver core and disk driver (should be using a bus?)
  240  */
  241 extern int      mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp);
  242 extern int      mlx_submit_ioctl(struct mlx_softc *sc,
  243                         struct mlx_sysdrive *drive, u_long cmd, 
  244                         caddr_t addr, int32_t flag, struct thread *td);
  245 extern void     mlxd_intr(void *data);
  246 
  247 

Cache object: 59116183ea11e778bcfaaa33b3d1ab4e


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