FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 1 | /* |
| 2 | * SCSI target kernel/user interface |
| 3 | * |
| 4 | * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org> |
| 5 | * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of the |
| 10 | * License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | * 02110-1301 USA |
| 21 | */ |
| 22 | #ifndef __SCSI_TARGET_IF_H |
| 23 | #define __SCSI_TARGET_IF_H |
| 24 | |
| 25 | /* user -> kernel */ |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 26 | #define TGT_UEVENT_CMD_RSP 0x0001 |
| 27 | #define TGT_UEVENT_IT_NEXUS_RSP 0x0002 |
| 28 | #define TGT_UEVENT_TSK_MGMT_RSP 0x0003 |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 29 | |
| 30 | /* kernel -> user */ |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 31 | #define TGT_KEVENT_CMD_REQ 0x1001 |
| 32 | #define TGT_KEVENT_CMD_DONE 0x1002 |
| 33 | #define TGT_KEVENT_IT_NEXUS_REQ 0x1003 |
| 34 | #define TGT_KEVENT_TSK_MGMT_REQ 0x1004 |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 35 | |
| 36 | struct tgt_event_hdr { |
| 37 | uint16_t version; |
| 38 | uint16_t status; |
| 39 | uint16_t type; |
| 40 | uint16_t len; |
| 41 | } __attribute__ ((aligned (sizeof(uint64_t)))); |
| 42 | |
| 43 | struct tgt_event { |
| 44 | struct tgt_event_hdr hdr; |
| 45 | |
| 46 | union { |
| 47 | /* user-> kernel */ |
| 48 | struct { |
| 49 | int host_no; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 50 | int result; |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 51 | aligned_u64 itn_id; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 52 | aligned_u64 tag; |
FUJITA Tomonori | bc7e380 | 2007-03-03 09:55:54 +0900 | [diff] [blame] | 53 | aligned_u64 uaddr; |
| 54 | aligned_u64 sense_uaddr; |
| 55 | uint32_t len; |
| 56 | uint32_t sense_len; |
| 57 | uint8_t rw; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 58 | } cmd_rsp; |
| 59 | struct { |
| 60 | int host_no; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 61 | int result; |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 62 | aligned_u64 itn_id; |
| 63 | aligned_u64 mid; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 64 | } tsk_mgmt_rsp; |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 65 | struct { |
| 66 | __s32 host_no; |
| 67 | __s32 result; |
| 68 | aligned_u64 itn_id; |
| 69 | __u32 function; |
| 70 | } it_nexus_rsp; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 71 | |
| 72 | /* kernel -> user */ |
| 73 | struct { |
| 74 | int host_no; |
| 75 | uint32_t data_len; |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 76 | aligned_u64 itn_id; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 77 | uint8_t scb[16]; |
| 78 | uint8_t lun[8]; |
| 79 | int attribute; |
| 80 | aligned_u64 tag; |
| 81 | } cmd_req; |
| 82 | struct { |
| 83 | int host_no; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 84 | int result; |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 85 | aligned_u64 itn_id; |
| 86 | aligned_u64 tag; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 87 | } cmd_done; |
| 88 | struct { |
| 89 | int host_no; |
| 90 | int function; |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 91 | aligned_u64 itn_id; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 92 | aligned_u64 tag; |
| 93 | uint8_t lun[8]; |
| 94 | aligned_u64 mid; |
| 95 | } tsk_mgmt_req; |
FUJITA Tomonori | 2c47f9ef | 2007-07-11 15:08:17 +0900 | [diff] [blame] | 96 | struct { |
| 97 | __s32 host_no; |
| 98 | __u32 function; |
| 99 | aligned_u64 itn_id; |
| 100 | __u32 max_cmds; |
| 101 | __u8 initiator_id[16]; |
| 102 | } it_nexus_req; |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 103 | } p; |
| 104 | } __attribute__ ((aligned (sizeof(uint64_t)))); |
| 105 | |
| 106 | #define TGT_RING_SIZE (1UL << 16) |
FUJITA Tomonori | 97f7875 | 2006-11-16 19:24:16 +0900 | [diff] [blame] | 107 | |
| 108 | #endif |