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/mpr/mpr_sas.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) 2011-2015 LSI Corp.
    3  * Copyright (c) 2013-2016 Avago Technologies
    4  * Copyright 2000-2020 Broadcom Inc.
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  * Broadcom Inc. (LSI) MPT-Fusion Host Adapter FreeBSD
   29  *
   30  * $FreeBSD$
   31  */
   32 
   33 struct mpr_fw_event_work;
   34 
   35 struct mprsas_lun {
   36         SLIST_ENTRY(mprsas_lun) lun_link;
   37         lun_id_t        lun_id;
   38         uint8_t         eedp_formatted;
   39         uint32_t        eedp_block_size;
   40 };
   41 
   42 struct mprsas_target {
   43         uint16_t        handle;
   44         uint8_t         linkrate;
   45         uint8_t         encl_level_valid;
   46         uint8_t         encl_level;
   47         char            connector_name[4];
   48         uint64_t        devname;
   49         uint32_t        devinfo;
   50         uint16_t        encl_handle;
   51         uint16_t        encl_slot;
   52         uint8_t         flags;
   53 #define MPRSAS_TARGET_INABORT   (1 << 0)
   54 #define MPRSAS_TARGET_INRESET   (1 << 1)
   55 #define MPRSAS_TARGET_INDIAGRESET (1 << 2)
   56 #define MPRSAS_TARGET_INREMOVAL (1 << 3)
   57 #define MPR_TARGET_FLAGS_RAID_COMPONENT (1 << 4)
   58 #define MPR_TARGET_FLAGS_VOLUME         (1 << 5)
   59 #define MPR_TARGET_IS_SATA_SSD  (1 << 6)
   60 #define MPRSAS_TARGET_TOREMOVE  (1 << 7)
   61 
   62         uint16_t        tid;
   63         SLIST_HEAD(, mprsas_lun) luns;
   64         TAILQ_HEAD(, mpr_command) commands;
   65         struct mpr_command *tm;
   66         struct mpr_command *pending_remove_tm;
   67         TAILQ_HEAD(, mpr_command) timedout_commands;
   68         uint16_t        exp_dev_handle;
   69         uint16_t        phy_num;
   70         uint64_t        sasaddr;
   71         uint16_t        parent_handle;
   72         uint64_t        parent_sasaddr;
   73         uint32_t        parent_devinfo;
   74         uint64_t        issued;
   75         uint64_t        completed;
   76         unsigned int    outstanding;
   77         unsigned int    timeouts;
   78         unsigned int    aborts;
   79         unsigned int    logical_unit_resets;
   80         unsigned int    target_resets;
   81         uint8_t         scsi_req_desc_type;
   82         uint8_t         stop_at_shutdown;
   83         uint8_t         supports_SSU;
   84         uint8_t         is_nvme;
   85         uint32_t        MDTS;
   86         uint8_t         controller_reset_timeout;
   87 };
   88 
   89 struct mprsas_softc {
   90         struct mpr_softc        *sc;
   91         u_int                   flags;
   92 #define MPRSAS_IN_DISCOVERY     (1 << 0)
   93 #define MPRSAS_IN_STARTUP       (1 << 1)
   94 #define MPRSAS_QUEUE_FROZEN     (1 << 3)
   95 #define MPRSAS_TOREMOVE         (1 << 5)
   96         u_int                   maxtargets;
   97         struct mprsas_target    *targets;
   98         struct cam_devq         *devq;
   99         struct cam_sim          *sim;
  100         struct cam_path         *path;
  101         struct intr_config_hook sas_ich;
  102         struct mpr_event_handle *mprsas_eh;
  103 
  104         u_int                   startup_refcount;
  105         struct proc             *sysctl_proc;
  106 
  107         struct taskqueue        *ev_tq;
  108         struct task             ev_task;
  109         TAILQ_HEAD(, mpr_fw_event_work) ev_queue;
  110 };
  111 
  112 MALLOC_DECLARE(M_MPRSAS);
  113 
  114 /*
  115  * Abstracted so that the driver can be backwards and forwards compatible
  116  * with future versions of CAM that will provide this functionality.
  117  */
  118 #define MPR_SET_LUN(lun, ccblun)        \
  119         mprsas_set_lun(lun, ccblun)
  120 
  121 static __inline int
  122 mprsas_set_lun(uint8_t *lun, u_int ccblun)
  123 {
  124         uint64_t *newlun;
  125 
  126         newlun = (uint64_t *)lun;
  127         *newlun = 0;
  128         if (ccblun <= 0xff) {
  129                 /* Peripheral device address method, LUN is 0 to 255 */
  130                 lun[1] = ccblun;
  131         } else if (ccblun <= 0x3fff) {
  132                 /* Flat space address method, LUN is <= 16383 */
  133                 scsi_ulto2b(ccblun, lun);
  134                 lun[0] |= 0x40;
  135         } else if (ccblun <= 0xffffff) {
  136                 /* Extended flat space address method, LUN is <= 16777215 */
  137                 scsi_ulto3b(ccblun, &lun[1]);
  138                 /* Extended Flat space address method */
  139                 lun[0] = 0xc0;
  140                 /* Length = 1, i.e. LUN is 3 bytes long */
  141                 lun[0] |= 0x10;
  142                 /* Extended Address Method */
  143                 lun[0] |= 0x02;
  144         } else {
  145                 return (EINVAL);
  146         }
  147 
  148         return (0);
  149 }
  150 
  151 static __inline void
  152 mprsas_set_ccbstatus(union ccb *ccb, int status)
  153 {
  154         ccb->ccb_h.status &= ~CAM_STATUS_MASK;
  155         ccb->ccb_h.status |= status;
  156 }
  157 
  158 static __inline int
  159 mprsas_get_ccbstatus(union ccb *ccb)
  160 {
  161         return (ccb->ccb_h.status & CAM_STATUS_MASK);
  162 }
  163 
  164 #define MPR_SET_SINGLE_LUN(req, lun)    \
  165 do {                                    \
  166         bzero((req)->LUN, 8);           \
  167         (req)->LUN[1] = lun;            \
  168 } while(0)
  169 
  170 void mprsas_rescan_target(struct mpr_softc *sc, struct mprsas_target *targ);
  171 void mprsas_discovery_end(struct mprsas_softc *sassc);
  172 void mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr_command *tm,
  173     struct mprsas_target *target, lun_id_t lun_id);
  174 void mprsas_startup_increment(struct mprsas_softc *sassc);
  175 void mprsas_startup_decrement(struct mprsas_softc *sassc);
  176 
  177 void mprsas_firmware_event_work(void *arg, int pending);
  178 int mprsas_check_id(struct mprsas_softc *sassc, int id);

Cache object: 74f4106fbd49234268c9e18a1cf23baf


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