blob: 4cf9dff29a2f69e792ef91395a120448dda8673c [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 */
26#define TGT_UEVENT_CMD_RSP 0x0001
27#define TGT_UEVENT_TSK_MGMT_RSP 0x0002
28
29/* kernel -> user */
30#define TGT_KEVENT_CMD_REQ 0x1001
31#define TGT_KEVENT_CMD_DONE 0x1002
32#define TGT_KEVENT_TSK_MGMT_REQ 0x1003
33
34struct tgt_event_hdr {
35 uint16_t version;
36 uint16_t status;
37 uint16_t type;
38 uint16_t len;
39} __attribute__ ((aligned (sizeof(uint64_t))));
40
41struct tgt_event {
42 struct tgt_event_hdr hdr;
43
44 union {
45 /* user-> kernel */
46 struct {
47 int host_no;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090048 int result;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090049 aligned_u64 tag;
FUJITA Tomonoribc7e3802007-03-03 09:55:54 +090050 aligned_u64 uaddr;
51 aligned_u64 sense_uaddr;
52 uint32_t len;
53 uint32_t sense_len;
54 uint8_t rw;
FUJITA Tomonori97f78752006-11-16 19:24:16 +090055 } cmd_rsp;
56 struct {
57 int host_no;
58 aligned_u64 mid;
59 int result;
60 } tsk_mgmt_rsp;
61
62
63 /* kernel -> user */
64 struct {
65 int host_no;
66 uint32_t data_len;
67 uint8_t scb[16];
68 uint8_t lun[8];
69 int attribute;
70 aligned_u64 tag;
71 } cmd_req;
72 struct {
73 int host_no;
74 aligned_u64 tag;
75 int result;
76 } cmd_done;
77 struct {
78 int host_no;
79 int function;
80 aligned_u64 tag;
81 uint8_t lun[8];
82 aligned_u64 mid;
83 } tsk_mgmt_req;
84 } p;
85} __attribute__ ((aligned (sizeof(uint64_t))));
86
87#define TGT_RING_SIZE (1UL << 16)
FUJITA Tomonori97f78752006-11-16 19:24:16 +090088
89#endif