blob: f2ee7c238a4544d112e63c6c57a283dd7474c579 [file] [log] [blame]
FUJITA Tomonori97f78752006-11-16 19:24:16 +09001/*
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 Tomonori2c47f9e2007-07-11 15:08:17 +090026#define TGT_UEVENT_CMD_RSP 0x0001
27#define TGT_UEVENT_IT_NEXUS_RSP 0x0002
28#define TGT_UEVENT_TSK_MGMT_RSP 0x0003
FUJITA Tomonori97f78752006-11-16 19:24:16 +090029
30/* kernel -> user */
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090031#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 Tomonori97f78752006-11-16 19:24:16 +090035
36struct 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
43struct tgt_event {
44 struct tgt_event_hdr hdr;
45
46 union {
47 /* user-> kernel */
48 struct {
49 int host_no;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090050 int result;
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090051 aligned_u64 itn_id;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090052 aligned_u64 tag;
FUJITA Tomonoribc7e3802007-03-03 09:55:54 +090053 aligned_u64 uaddr;
54 aligned_u64 sense_uaddr;
55 uint32_t len;
56 uint32_t sense_len;
57 uint8_t rw;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090058 } cmd_rsp;
59 struct {
60 int host_no;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090061 int result;
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090062 aligned_u64 itn_id;
63 aligned_u64 mid;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090064 } tsk_mgmt_rsp;
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090065 struct {
66 __s32 host_no;
67 __s32 result;
68 aligned_u64 itn_id;
69 __u32 function;
70 } it_nexus_rsp;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090071
72 /* kernel -> user */
73 struct {
74 int host_no;
75 uint32_t data_len;
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090076 aligned_u64 itn_id;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090077 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 Tomonori97f78752006-11-16 19:24:16 +090084 int result;
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090085 aligned_u64 itn_id;
86 aligned_u64 tag;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090087 } cmd_done;
88 struct {
89 int host_no;
90 int function;
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090091 aligned_u64 itn_id;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090092 aligned_u64 tag;
93 uint8_t lun[8];
94 aligned_u64 mid;
95 } tsk_mgmt_req;
FUJITA Tomonori2c47f9e2007-07-11 15:08:17 +090096 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 Tomonori97f78752006-11-16 19:24:16 +0900103 } p;
104} __attribute__ ((aligned (sizeof(uint64_t))));
105
106#define TGT_RING_SIZE (1UL << 16)
FUJITA Tomonori97f78752006-11-16 19:24:16 +0900107
108#endif