12e21a3efSScott Long /*- 22e21a3efSScott Long * Copyright (c) 2006 IronPort Systems 32e21a3efSScott Long * All rights reserved. 42e21a3efSScott Long * 52e21a3efSScott Long * Redistribution and use in source and binary forms, with or without 62e21a3efSScott Long * modification, are permitted provided that the following conditions 72e21a3efSScott Long * are met: 82e21a3efSScott Long * 1. Redistributions of source code must retain the above copyright 92e21a3efSScott Long * notice, this list of conditions and the following disclaimer. 102e21a3efSScott Long * 2. Redistributions in binary form must reproduce the above copyright 112e21a3efSScott Long * notice, this list of conditions and the following disclaimer in the 122e21a3efSScott Long * documentation and/or other materials provided with the distribution. 132e21a3efSScott Long * 142e21a3efSScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 152e21a3efSScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 162e21a3efSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 172e21a3efSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 182e21a3efSScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 192e21a3efSScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 202e21a3efSScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 212e21a3efSScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 222e21a3efSScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 232e21a3efSScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 242e21a3efSScott Long * SUCH DAMAGE. 252e21a3efSScott Long */ 26610f2ef3SScott Long /*- 27610f2ef3SScott Long * Copyright (c) 2007 LSI Corp. 28610f2ef3SScott Long * Copyright (c) 2007 Rajesh Prabhakaran. 29610f2ef3SScott Long * All rights reserved. 30610f2ef3SScott Long * 31610f2ef3SScott Long * Redistribution and use in source and binary forms, with or without 32610f2ef3SScott Long * modification, are permitted provided that the following conditions 33610f2ef3SScott Long * are met: 34610f2ef3SScott Long * 1. Redistributions of source code must retain the above copyright 35610f2ef3SScott Long * notice, this list of conditions and the following disclaimer. 36610f2ef3SScott Long * 2. Redistributions in binary form must reproduce the above copyright 37610f2ef3SScott Long * notice, this list of conditions and the following disclaimer in the 38610f2ef3SScott Long * documentation and/or other materials provided with the distribution. 39610f2ef3SScott Long * 40610f2ef3SScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 41610f2ef3SScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42610f2ef3SScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43610f2ef3SScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 44610f2ef3SScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 45610f2ef3SScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 46610f2ef3SScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47610f2ef3SScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 48610f2ef3SScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49610f2ef3SScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50610f2ef3SScott Long * SUCH DAMAGE. 51610f2ef3SScott Long */ 522e21a3efSScott Long 532e21a3efSScott Long #ifndef _MFIVAR_H 542e21a3efSScott Long #define _MFIVAR_H 552e21a3efSScott Long 562e21a3efSScott Long #include <sys/cdefs.h> 572e21a3efSScott Long __FBSDID("$FreeBSD$"); 582e21a3efSScott Long 598ec5c98bSJohn Baldwin #include <sys/lock.h> 608ec5c98bSJohn Baldwin #include <sys/sx.h> 618ec5c98bSJohn Baldwin 622e21a3efSScott Long /* 632e21a3efSScott Long * SCSI structures and definitions are used from here, but no linking 642e21a3efSScott Long * requirements are made to CAM. 652e21a3efSScott Long */ 662e21a3efSScott Long #include <cam/scsi/scsi_all.h> 672e21a3efSScott Long 682e21a3efSScott Long struct mfi_hwcomms { 692e21a3efSScott Long uint32_t hw_pi; 702e21a3efSScott Long uint32_t hw_ci; 712e21a3efSScott Long uint32_t hw_reply_q[1]; 722e21a3efSScott Long }; 732e21a3efSScott Long 742e21a3efSScott Long struct mfi_softc; 75ddfae47bSScott Long struct disk; 7635ef86f2SScott Long struct ccb_hdr; 772e21a3efSScott Long 782e21a3efSScott Long struct mfi_command { 792e21a3efSScott Long TAILQ_ENTRY(mfi_command) cm_link; 805ba21ff1SScott Long time_t cm_timestamp; 812e21a3efSScott Long struct mfi_softc *cm_sc; 822e21a3efSScott Long union mfi_frame *cm_frame; 832e21a3efSScott Long uint32_t cm_frame_busaddr; 842e21a3efSScott Long struct mfi_sense *cm_sense; 852e21a3efSScott Long uint32_t cm_sense_busaddr; 862e21a3efSScott Long bus_dmamap_t cm_dmamap; 872e21a3efSScott Long union mfi_sgl *cm_sg; 882e21a3efSScott Long void *cm_data; 892e21a3efSScott Long int cm_len; 902e21a3efSScott Long int cm_total_frame_size; 912e21a3efSScott Long int cm_extra_frames; 922e21a3efSScott Long int cm_flags; 932e21a3efSScott Long #define MFI_CMD_MAPPED (1<<0) 942e21a3efSScott Long #define MFI_CMD_DATAIN (1<<1) 952e21a3efSScott Long #define MFI_CMD_DATAOUT (1<<2) 962e21a3efSScott Long #define MFI_CMD_COMPLETED (1<<3) 972e21a3efSScott Long #define MFI_CMD_POLLED (1<<4) 982e21a3efSScott Long #define MFI_ON_MFIQ_FREE (1<<5) 992e21a3efSScott Long #define MFI_ON_MFIQ_READY (1<<6) 1002e21a3efSScott Long #define MFI_ON_MFIQ_BUSY (1<<7) 1012e21a3efSScott Long #define MFI_ON_MFIQ_MASK ((1<<5)|(1<<6)|(1<<7)) 102741367d5SDoug Ambrisko int cm_aen_abort; 1032e21a3efSScott Long void (* cm_complete)(struct mfi_command *cm); 1042e21a3efSScott Long void *cm_private; 1055ba21ff1SScott Long int cm_index; 1065be25877SDoug Ambrisko int cm_error; 1072e21a3efSScott Long }; 1082e21a3efSScott Long 109ddfae47bSScott Long struct mfi_disk { 110ddfae47bSScott Long TAILQ_ENTRY(mfi_disk) ld_link; 111ddfae47bSScott Long device_t ld_dev; 1122e21a3efSScott Long int ld_id; 113ddfae47bSScott Long int ld_unit; 114ddfae47bSScott Long struct mfi_softc *ld_controller; 115ddfae47bSScott Long struct mfi_ld_info *ld_info; 116ddfae47bSScott Long struct disk *ld_disk; 117ddfae47bSScott Long int ld_flags; 118ddfae47bSScott Long #define MFI_DISK_FLAGS_OPEN 0x01 1198ec5c98bSJohn Baldwin #define MFI_DISK_FLAGS_DISABLED 0x02 1202e21a3efSScott Long }; 1212e21a3efSScott Long 122741367d5SDoug Ambrisko struct mfi_aen { 123741367d5SDoug Ambrisko TAILQ_ENTRY(mfi_aen) aen_link; 124741367d5SDoug Ambrisko struct proc *p; 125741367d5SDoug Ambrisko }; 126741367d5SDoug Ambrisko 1272e21a3efSScott Long struct mfi_softc { 1282e21a3efSScott Long device_t mfi_dev; 1292e21a3efSScott Long int mfi_flags; 1302e21a3efSScott Long #define MFI_FLAGS_SG64 (1<<0) 1312e21a3efSScott Long #define MFI_FLAGS_QFRZN (1<<1) 1322e21a3efSScott Long #define MFI_FLAGS_OPEN (1<<2) 133441f6d5dSScott Long #define MFI_FLAGS_STOP (1<<3) 134610f2ef3SScott Long #define MFI_FLAGS_1064R (1<<4) 135610f2ef3SScott Long #define MFI_FLAGS_1078 (1<<5) 136fa1e6ef4SDoug Ambrisko #define MFI_FLAGS_GEN2 (1<<6) 1372e21a3efSScott Long 1382e21a3efSScott Long struct mfi_hwcomms *mfi_comms; 1392e21a3efSScott Long TAILQ_HEAD(,mfi_command) mfi_free; 1402e21a3efSScott Long TAILQ_HEAD(,mfi_command) mfi_ready; 1412e21a3efSScott Long TAILQ_HEAD(,mfi_command) mfi_busy; 1422e21a3efSScott Long struct bio_queue_head mfi_bioq; 1432e21a3efSScott Long struct mfi_qstat mfi_qstat[MFIQ_COUNT]; 1442e21a3efSScott Long 1452e21a3efSScott Long struct resource *mfi_regs_resource; 1462e21a3efSScott Long bus_space_handle_t mfi_bhandle; 1472e21a3efSScott Long bus_space_tag_t mfi_btag; 1482e21a3efSScott Long int mfi_regs_rid; 1492e21a3efSScott Long 1502e21a3efSScott Long bus_dma_tag_t mfi_parent_dmat; 1512e21a3efSScott Long bus_dma_tag_t mfi_buffer_dmat; 1522e21a3efSScott Long 1532e21a3efSScott Long bus_dma_tag_t mfi_comms_dmat; 1542e21a3efSScott Long bus_dmamap_t mfi_comms_dmamap; 1552e21a3efSScott Long uint32_t mfi_comms_busaddr; 1562e21a3efSScott Long 1572e21a3efSScott Long bus_dma_tag_t mfi_frames_dmat; 1582e21a3efSScott Long bus_dmamap_t mfi_frames_dmamap; 1592e21a3efSScott Long uint32_t mfi_frames_busaddr; 1602e21a3efSScott Long union mfi_frame *mfi_frames; 1612e21a3efSScott Long 162741367d5SDoug Ambrisko TAILQ_HEAD(,mfi_aen) mfi_aen_pids; 163741367d5SDoug Ambrisko struct mfi_command *mfi_aen_cm; 164741367d5SDoug Ambrisko uint32_t mfi_aen_triggered; 165741367d5SDoug Ambrisko uint32_t mfi_poll_waiting; 166741367d5SDoug Ambrisko struct selinfo mfi_select; 1678ec5c98bSJohn Baldwin int mfi_delete_busy_volumes; 1688ec5c98bSJohn Baldwin int mfi_keep_deleted_volumes; 1698ec5c98bSJohn Baldwin int mfi_detaching; 170741367d5SDoug Ambrisko 1712e21a3efSScott Long bus_dma_tag_t mfi_sense_dmat; 1722e21a3efSScott Long bus_dmamap_t mfi_sense_dmamap; 1732e21a3efSScott Long uint32_t mfi_sense_busaddr; 1742e21a3efSScott Long struct mfi_sense *mfi_sense; 1752e21a3efSScott Long 1762e21a3efSScott Long struct resource *mfi_irq; 1772e21a3efSScott Long void *mfi_intr; 1782e21a3efSScott Long int mfi_irq_rid; 1792e21a3efSScott Long 1802e21a3efSScott Long struct intr_config_hook mfi_ich; 1812e21a3efSScott Long eventhandler_tag eh; 1822e21a3efSScott Long 1832e21a3efSScott Long /* 1842e21a3efSScott Long * Allocation for the command array. Used as an indexable array to 1852e21a3efSScott Long * recover completed commands. 1862e21a3efSScott Long */ 1872e21a3efSScott Long struct mfi_command *mfi_commands; 1882e21a3efSScott Long /* 1892e21a3efSScott Long * How many commands were actually allocated 1902e21a3efSScott Long */ 1912e21a3efSScott Long int mfi_total_cmds; 1922e21a3efSScott Long /* 1932e21a3efSScott Long * How many commands the firmware can handle. Also how big the reply 1942e21a3efSScott Long * queue is, minus 1. 1952e21a3efSScott Long */ 1962e21a3efSScott Long int mfi_max_fw_cmds; 1972e21a3efSScott Long /* 1982e21a3efSScott Long * How many S/G elements we'll ever actually use 1992e21a3efSScott Long */ 20078e36c27SScott Long int mfi_max_sge; 2012e21a3efSScott Long /* 2022e21a3efSScott Long * How many bytes a compound frame is, including all of the extra frames 2032e21a3efSScott Long * that are used for S/G elements. 2042e21a3efSScott Long */ 20578e36c27SScott Long int mfi_cmd_size; 2062e21a3efSScott Long /* 2072e21a3efSScott Long * How large an S/G element is. Used to calculate the number of single 2082e21a3efSScott Long * frames in a command. 2092e21a3efSScott Long */ 21078e36c27SScott Long int mfi_sge_size; 2112e21a3efSScott Long /* 2122e21a3efSScott Long * Max number of sectors that the firmware allows 2132e21a3efSScott Long */ 2142e21a3efSScott Long uint32_t mfi_max_io; 2152e21a3efSScott Long 216ddfae47bSScott Long TAILQ_HEAD(,mfi_disk) mfi_ld_tqh; 2172e21a3efSScott Long eventhandler_tag mfi_eh; 2182e21a3efSScott Long struct cdev *mfi_cdev; 2192e21a3efSScott Long 22035ef86f2SScott Long TAILQ_HEAD(, ccb_hdr) mfi_cam_ccbq; 22135ef86f2SScott Long struct mfi_command * (* mfi_cam_start)(void *); 2225ba21ff1SScott Long struct callout mfi_watchdog_callout; 2232e21a3efSScott Long struct mtx mfi_io_lock; 2248ec5c98bSJohn Baldwin struct sx mfi_config_lock; 225610f2ef3SScott Long 226610f2ef3SScott Long /* Controller type specific interfaces */ 227610f2ef3SScott Long void (*mfi_enable_intr)(struct mfi_softc *sc); 228610f2ef3SScott Long int32_t (*mfi_read_fw_status)(struct mfi_softc *sc); 229610f2ef3SScott Long int (*mfi_check_clear_intr)(struct mfi_softc *sc); 230610f2ef3SScott Long void (*mfi_issue_cmd)(struct mfi_softc *sc,uint32_t bus_add,uint32_t frame_cnt); 2312e21a3efSScott Long }; 2322e21a3efSScott Long 2332e21a3efSScott Long extern int mfi_attach(struct mfi_softc *); 2342e21a3efSScott Long extern void mfi_free(struct mfi_softc *); 2352e21a3efSScott Long extern int mfi_shutdown(struct mfi_softc *); 2362e21a3efSScott Long extern void mfi_startio(struct mfi_softc *); 2372e21a3efSScott Long extern void mfi_disk_complete(struct bio *); 2388ec5c98bSJohn Baldwin extern int mfi_disk_disable(struct mfi_disk *); 2398ec5c98bSJohn Baldwin extern void mfi_disk_enable(struct mfi_disk *); 2402e21a3efSScott Long extern int mfi_dump_blocks(struct mfi_softc *, int id, uint64_t, void *, int); 2412e21a3efSScott Long 2422e21a3efSScott Long #define MFIQ_ADD(sc, qname) \ 2432e21a3efSScott Long do { \ 2442e21a3efSScott Long struct mfi_qstat *qs; \ 2452e21a3efSScott Long \ 2462e21a3efSScott Long qs = &(sc)->mfi_qstat[qname]; \ 2472e21a3efSScott Long qs->q_length++; \ 2482e21a3efSScott Long if (qs->q_length > qs->q_max) \ 2492e21a3efSScott Long qs->q_max = qs->q_length; \ 2502e21a3efSScott Long } while (0) 2512e21a3efSScott Long 2522e21a3efSScott Long #define MFIQ_REMOVE(sc, qname) (sc)->mfi_qstat[qname].q_length-- 2532e21a3efSScott Long 2542e21a3efSScott Long #define MFIQ_INIT(sc, qname) \ 2552e21a3efSScott Long do { \ 2562e21a3efSScott Long sc->mfi_qstat[qname].q_length = 0; \ 2572e21a3efSScott Long sc->mfi_qstat[qname].q_max = 0; \ 2582e21a3efSScott Long } while (0) 2592e21a3efSScott Long 2602e21a3efSScott Long #define MFIQ_COMMAND_QUEUE(name, index) \ 2612e21a3efSScott Long static __inline void \ 2622e21a3efSScott Long mfi_initq_ ## name (struct mfi_softc *sc) \ 2632e21a3efSScott Long { \ 2642e21a3efSScott Long TAILQ_INIT(&sc->mfi_ ## name); \ 2652e21a3efSScott Long MFIQ_INIT(sc, index); \ 2662e21a3efSScott Long } \ 2672e21a3efSScott Long static __inline void \ 2682e21a3efSScott Long mfi_enqueue_ ## name (struct mfi_command *cm) \ 2692e21a3efSScott Long { \ 2702e21a3efSScott Long if ((cm->cm_flags & MFI_ON_MFIQ_MASK) != 0) { \ 2712e21a3efSScott Long printf("command %p is on another queue, " \ 2722e21a3efSScott Long "flags = %#x\n", cm, cm->cm_flags); \ 2732e21a3efSScott Long panic("command is on another queue"); \ 2742e21a3efSScott Long } \ 2752e21a3efSScott Long TAILQ_INSERT_TAIL(&cm->cm_sc->mfi_ ## name, cm, cm_link); \ 2762e21a3efSScott Long cm->cm_flags |= MFI_ON_ ## index; \ 2772e21a3efSScott Long MFIQ_ADD(cm->cm_sc, index); \ 2782e21a3efSScott Long } \ 2792e21a3efSScott Long static __inline void \ 2802e21a3efSScott Long mfi_requeue_ ## name (struct mfi_command *cm) \ 2812e21a3efSScott Long { \ 2822e21a3efSScott Long if ((cm->cm_flags & MFI_ON_MFIQ_MASK) != 0) { \ 2832e21a3efSScott Long printf("command %p is on another queue, " \ 2842e21a3efSScott Long "flags = %#x\n", cm, cm->cm_flags); \ 2852e21a3efSScott Long panic("command is on another queue"); \ 2862e21a3efSScott Long } \ 2872e21a3efSScott Long TAILQ_INSERT_HEAD(&cm->cm_sc->mfi_ ## name, cm, cm_link); \ 2882e21a3efSScott Long cm->cm_flags |= MFI_ON_ ## index; \ 2892e21a3efSScott Long MFIQ_ADD(cm->cm_sc, index); \ 2902e21a3efSScott Long } \ 2912e21a3efSScott Long static __inline struct mfi_command * \ 2922e21a3efSScott Long mfi_dequeue_ ## name (struct mfi_softc *sc) \ 2932e21a3efSScott Long { \ 2942e21a3efSScott Long struct mfi_command *cm; \ 2952e21a3efSScott Long \ 2962e21a3efSScott Long if ((cm = TAILQ_FIRST(&sc->mfi_ ## name)) != NULL) { \ 2972e21a3efSScott Long if ((cm->cm_flags & MFI_ON_ ## index) == 0) { \ 2982e21a3efSScott Long printf("command %p not in queue, " \ 2992e21a3efSScott Long "flags = %#x, bit = %#x\n", cm, \ 3002e21a3efSScott Long cm->cm_flags, MFI_ON_ ## index); \ 3012e21a3efSScott Long panic("command not in queue"); \ 3022e21a3efSScott Long } \ 3032e21a3efSScott Long TAILQ_REMOVE(&sc->mfi_ ## name, cm, cm_link); \ 3042e21a3efSScott Long cm->cm_flags &= ~MFI_ON_ ## index; \ 3052e21a3efSScott Long MFIQ_REMOVE(sc, index); \ 3062e21a3efSScott Long } \ 3072e21a3efSScott Long return (cm); \ 3082e21a3efSScott Long } \ 3092e21a3efSScott Long static __inline void \ 3102e21a3efSScott Long mfi_remove_ ## name (struct mfi_command *cm) \ 3112e21a3efSScott Long { \ 3122e21a3efSScott Long if ((cm->cm_flags & MFI_ON_ ## index) == 0) { \ 3132e21a3efSScott Long printf("command %p not in queue, flags = %#x, " \ 3142e21a3efSScott Long "bit = %#x\n", cm, cm->cm_flags, \ 3152e21a3efSScott Long MFI_ON_ ## index); \ 3162e21a3efSScott Long panic("command not in queue"); \ 3172e21a3efSScott Long } \ 3182e21a3efSScott Long TAILQ_REMOVE(&cm->cm_sc->mfi_ ## name, cm, cm_link); \ 3192e21a3efSScott Long cm->cm_flags &= ~MFI_ON_ ## index; \ 3202e21a3efSScott Long MFIQ_REMOVE(cm->cm_sc, index); \ 3212e21a3efSScott Long } \ 3222e21a3efSScott Long struct hack 3232e21a3efSScott Long 3242e21a3efSScott Long MFIQ_COMMAND_QUEUE(free, MFIQ_FREE); 3252e21a3efSScott Long MFIQ_COMMAND_QUEUE(ready, MFIQ_READY); 3262e21a3efSScott Long MFIQ_COMMAND_QUEUE(busy, MFIQ_BUSY); 3272e21a3efSScott Long 3282e21a3efSScott Long static __inline void 3292e21a3efSScott Long mfi_initq_bio(struct mfi_softc *sc) 3302e21a3efSScott Long { 3312e21a3efSScott Long bioq_init(&sc->mfi_bioq); 3322e21a3efSScott Long MFIQ_INIT(sc, MFIQ_BIO); 3332e21a3efSScott Long } 3342e21a3efSScott Long 3352e21a3efSScott Long static __inline void 3362e21a3efSScott Long mfi_enqueue_bio(struct mfi_softc *sc, struct bio *bp) 3372e21a3efSScott Long { 3382e21a3efSScott Long bioq_insert_tail(&sc->mfi_bioq, bp); 3392e21a3efSScott Long MFIQ_ADD(sc, MFIQ_BIO); 3402e21a3efSScott Long } 3412e21a3efSScott Long 3422e21a3efSScott Long static __inline struct bio * 3432e21a3efSScott Long mfi_dequeue_bio(struct mfi_softc *sc) 3442e21a3efSScott Long { 3452e21a3efSScott Long struct bio *bp; 3462e21a3efSScott Long 3472e21a3efSScott Long if ((bp = bioq_first(&sc->mfi_bioq)) != NULL) { 3482e21a3efSScott Long bioq_remove(&sc->mfi_bioq, bp); 3492e21a3efSScott Long MFIQ_REMOVE(sc, MFIQ_BIO); 3502e21a3efSScott Long } 3512e21a3efSScott Long return (bp); 3522e21a3efSScott Long } 3532e21a3efSScott Long 3542e21a3efSScott Long static __inline void 3552e21a3efSScott Long mfi_print_sense(struct mfi_softc *sc, void *sense) 3562e21a3efSScott Long { 3572e21a3efSScott Long int error, key, asc, ascq; 3582e21a3efSScott Long 3592e21a3efSScott Long scsi_extract_sense((struct scsi_sense_data *)sense, 3602e21a3efSScott Long &error, &key, &asc, &ascq); 3612e21a3efSScott Long device_printf(sc->mfi_dev, "sense error %d, sense_key %d, " 3622e21a3efSScott Long "asc %d, ascq %d\n", error, key, asc, ascq); 3632e21a3efSScott Long } 3642e21a3efSScott Long 3652e21a3efSScott Long 3662e21a3efSScott Long #define MFI_WRITE4(sc, reg, val) bus_space_write_4((sc)->mfi_btag, \ 3672e21a3efSScott Long sc->mfi_bhandle, (reg), (val)) 3682e21a3efSScott Long #define MFI_READ4(sc, reg) bus_space_read_4((sc)->mfi_btag, \ 3692e21a3efSScott Long (sc)->mfi_bhandle, (reg)) 3702e21a3efSScott Long #define MFI_WRITE2(sc, reg, val) bus_space_write_2((sc)->mfi_btag, \ 3712e21a3efSScott Long sc->mfi_bhandle, (reg), (val)) 3722e21a3efSScott Long #define MFI_READ2(sc, reg) bus_space_read_2((sc)->mfi_btag, \ 3732e21a3efSScott Long (sc)->mfi_bhandle, (reg)) 3742e21a3efSScott Long #define MFI_WRITE1(sc, reg, val) bus_space_write_1((sc)->mfi_btag, \ 3752e21a3efSScott Long sc->mfi_bhandle, (reg), (val)) 3762e21a3efSScott Long #define MFI_READ1(sc, reg) bus_space_read_1((sc)->mfi_btag, \ 3772e21a3efSScott Long (sc)->mfi_bhandle, (reg)) 3782e21a3efSScott Long 3792e21a3efSScott Long MALLOC_DECLARE(M_MFIBUF); 3802e21a3efSScott Long 3815ba21ff1SScott Long #define MFI_CMD_TIMEOUT 30 38252c9ce25SScott Long #define MFI_MAXPHYS (128 * 1024) 3835ba21ff1SScott Long 3845ba21ff1SScott Long #ifdef MFI_DEBUG 3855ba21ff1SScott Long extern void mfi_print_cmd(struct mfi_command *cm); 3865ba21ff1SScott Long extern void mfi_dump_cmds(struct mfi_softc *sc); 387441f6d5dSScott Long extern void mfi_validate_sg(struct mfi_softc *, struct mfi_command *, const char *, int ); 3885ba21ff1SScott Long #define MFI_PRINT_CMD(cm) mfi_print_cmd(cm) 389441f6d5dSScott Long #define MFI_DUMP_CMDS(sc) mfi_dump_cmds(sc) 390441f6d5dSScott Long #define MFI_VALIDATE_CMD(sc, cm) mfi_validate_sg(sc, cm, __FUNCTION__, __LINE__) 3915ba21ff1SScott Long #else 3925ba21ff1SScott Long #define MFI_PRINT_CMD(cm) 3935ba21ff1SScott Long #define MFI_DUMP_CMDS(sc) 394441f6d5dSScott Long #define MFI_VALIDATE_CMD(sc, cm) 3955ba21ff1SScott Long #endif 3965ba21ff1SScott Long 39735ef86f2SScott Long extern void mfi_release_command(struct mfi_command *cm); 39835ef86f2SScott Long 3992e21a3efSScott Long #endif /* _MFIVAR_H */ 400