1 1.3 christos /* $NetBSD: linux_sg.h,v 1.3 2005/12/11 12:20:19 christos Exp $ */ 2 1.1 christos 3 1.1 christos /* 4 1.1 christos * Copyright (c) 2004 Soren S. Jorvang. All rights reserved. 5 1.1 christos * 6 1.1 christos * Redistribution and use in source and binary forms, with or without 7 1.1 christos * modification, are permitted provided that the following conditions 8 1.1 christos * are met: 9 1.1 christos * 1. Redistributions of source code must retain the above copyright 10 1.1 christos * notice, this list of conditions, and the following disclaimer. 11 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright 12 1.1 christos * notice, this list of conditions and the following disclaimer in the 13 1.1 christos * documentation and/or other materials provided with the distribution. 14 1.1 christos * 15 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 1.1 christos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 1.1 christos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 1.1 christos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 1.1 christos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 1.1 christos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 1.1 christos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 1.1 christos * SUCH DAMAGE. 26 1.1 christos */ 27 1.1 christos 28 1.1 christos #ifndef _LINUX_SG_H 29 1.1 christos #define _LINUX_SG_H 30 1.1 christos 31 1.1 christos /* sg driver version 3 */ 32 1.1 christos #define LINUX_SG_EMULATED_HOST _LINUX_IO('"', 0x03) 33 1.1 christos #define LINUX_SG_SET_TRANSFORM _LINUX_IO('"', 0x04) 34 1.1 christos #define LINUX_SG_GET_TRANSFORM _LINUX_IO('"', 0x05) 35 1.1 christos #define LINUX_SG_SET_RESERVED_SIZE _LINUX_IO('"', 0x75) 36 1.1 christos #define LINUX_SG_GET_RESERVED_SIZE _LINUX_IO('"', 0x72) 37 1.1 christos #define LINUX_SG_GET_SCSI_ID _LINUX_IO('"', 0x76) 38 1.1 christos #define LINUX_SG_SET_FORCE_LOW_DMA _LINUX_IO('"', 0x79) 39 1.1 christos #define LINUX_SG_GET_LOW_DMA _LINUX_IO('"', 0x7a) 40 1.1 christos #define LINUX_SG_SET_FORCE_PACK_ID _LINUX_IO('"', 0x7b) 41 1.1 christos #define LINUX_SG_GET_PACK_ID _LINUX_IO('"', 0x7c) 42 1.1 christos #define LINUX_SG_GET_NUM_WAITING _LINUX_IO('"', 0x7d) 43 1.1 christos #define LINUX_SG_GET_SG_TABLESIZE _LINUX_IO('"', 0x7f) 44 1.1 christos #define LINUX_SG_GET_VERSION_NUM _LINUX_IO('"', 0x82) 45 1.1 christos #define LINUX_SG_SCSI_RESET _LINUX_IO('"', 0x84) 46 1.1 christos #define LINUX_SG_IO _LINUX_IO('"', 0x85) 47 1.1 christos #define LINUX_SG_GET_REQUEST_TABLE _LINUX_IO('"', 0x86) 48 1.1 christos #define LINUX_SG_SET_KEEP_ORPHAN _LINUX_IO('"', 0x87) 49 1.1 christos #define LINUX_SG_GET_KEEP_ORPHAN _LINUX_IO('"', 0x88) 50 1.1 christos #define LINUX_SG_GET_ACCESS_COUNT _LINUX_IO('"', 0x89) 51 1.1 christos /* sg driver version 2 */ 52 1.1 christos #define LINUX_SG_SET_TIMEOUT _LINUX_IO('"', 0x01) 53 1.1 christos #define LINUX_SG_GET_TIMEOUT _LINUX_IO('"', 0x02) 54 1.1 christos #define LINUX_SG_GET_COMMAND_Q _LINUX_IO('"', 0x70) 55 1.1 christos #define LINUX_SG_SET_COMMAND_Q _LINUX_IO('"', 0x71) 56 1.1 christos #define LINUX_SG_SET_DEBUG _LINUX_IO('"', 0x7e) 57 1.1 christos #define LINUX_SG_NEXT_CMD_LEN _LINUX_IO('"', 0x83) 58 1.1 christos 59 1.1 christos 60 1.1 christos struct linux_sg_io_hdr { 61 1.1 christos int interface_id; 62 1.1 christos #define SG_DXFER_NONE -1 63 1.1 christos #define SG_DXFER_TO_DEV -2 64 1.1 christos #define SG_DXFER_FROM_DEV -3 65 1.1 christos #define SG_DXFER_TO_FROM_DEV -4 66 1.1 christos #define SG_DXFER_UNKNOWN -5 67 1.1 christos int dxfer_direction; 68 1.1 christos unsigned char cmd_len; 69 1.1 christos unsigned char mx_sb_len; 70 1.1 christos unsigned short iovec_count; 71 1.1 christos unsigned int dxfer_len; 72 1.1 christos void *dxferp; 73 1.1 christos unsigned char *cmdp; 74 1.1 christos unsigned char *sbp; 75 1.1 christos unsigned int timeout; 76 1.1 christos unsigned int flags; 77 1.1 christos int pack_id; 78 1.1 christos void *usr_ptr; 79 1.1 christos unsigned char status; 80 1.1 christos unsigned char masked_status; 81 1.1 christos unsigned char msg_status; 82 1.1 christos unsigned char sb_len_wr; 83 1.1 christos unsigned short host_status; 84 1.1 christos unsigned short driver_status; 85 1.1 christos int resid; 86 1.1 christos unsigned int duration; 87 1.1 christos unsigned int info; 88 1.1 christos }; 89 1.1 christos 90 1.1 christos #define SG_MAX_SENSE 16 91 1.1 christos 92 1.1 christos /* 93 1.1 christos * Host codes 94 1.1 christos */ 95 1.1 christos #define LINUX_DID_OK 0x00 /* OK */ 96 1.2 perry #define LINUX_DID_NO_CONNECT 0x01 /* timeout during connect */ 97 1.1 christos #define LINUX_DID_BUS_BUSY 0x02 /* timeout during command */ 98 1.1 christos #define LINUX_DID_TIME_OUT 0x03 /* other timeout */ 99 1.1 christos #define LINUX_DID_BAD_TARGET 0x04 /* bad target */ 100 1.1 christos #define LINUX_DID_ABORT 0x05 /* abort */ 101 1.1 christos #define LINUX_DID_PARITY 0x06 /* parity error */ 102 1.1 christos #define LINUX_DID_ERROR 0x07 /* internal error */ 103 1.1 christos #define LINUX_DID_RESET 0x08 /* reset by somebody */ 104 1.1 christos #define LINUX_DID_BAD_INTR 0x09 /* unexpected interrupt */ 105 1.1 christos #define LINUX_DID_PASSTHROUGH 0x0a /* passthrough */ 106 1.1 christos #define LINUX_DID_SOFT_ERROR 0x0b /* low driver wants retry */ 107 1.1 christos #define LINUX_DID_IMM_RETRY 0x0c /* retry without decreasing retrycnt */ 108 1.1 christos 109 1.1 christos /* 110 1.1 christos * Driver codes 111 1.1 christos */ 112 1.1 christos #define LINUX_DRIVER_BUSY 0x01 113 1.1 christos #define LINUX_DRIVER_SOFT 0x02 114 1.1 christos #define LINUX_DRIVER_MEDIA 0x03 115 1.1 christos #define LINUX_DRIVER_ERROR 0x04 116 1.1 christos 117 1.1 christos #define LINUX_DRIVER_INVALID 0x05 118 1.1 christos #define LINUX_DRIVER_TIMEOUT 0x06 119 1.1 christos #define LINUX_DRIVER_HARD 0x07 120 1.1 christos #define LINUX_DRIVER_SENSE 0x08 121 1.2 perry 122 1.1 christos #define LINUX_SUGGEST_RETRY 0x10 123 1.1 christos #define LINUX_SUGGEST_ABORT 0x20 124 1.1 christos #define LINUX_SUGGEST_REMAP 0x30 125 1.1 christos #define LINUX_SUGGEST_DIE 0x40 126 1.1 christos #define LINUX_SUGGEST_SENSE 0x80 127 1.1 christos #define LINUX_SUGGEST_IS_OK 0xff 128 1.2 perry 129 1.1 christos #define LINUX_DRIVER_MASK 0x0f 130 1.1 christos #define LINUX_SUGGEST_MASK 0xf0 131 1.1 christos 132 1.1 christos #endif /* !_LINUX_SG_H */ 133