diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2006-11-16 05:24:16 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-11-25 14:17:38 -0500 |
commit | 97f78759ea1cb7d27b61095582de78b8e7486e85 (patch) | |
tree | 71c5cabb1758e5ba1b3ba37b9091e653b822c3f7 /include/scsi | |
parent | 5a55c2596f55e3a60f7502d0dfcfa0d20241e5ac (diff) |
[SCSI] scsi tgt: scsi target user and kernel communication interface
The user-space daemon and tgt kernel module need bi-directional
kernel/user high-performance interface, however, mainline provides no
standard interface like that.
This patch adds shared memory interface between kernel and user spaces
like some other drivers do by using own character device. The
user-space daemon and tgt kernel module creates shared memory via mmap
and use it like ring buffer. poll (kernel to user) and write (user to
kernel) system calls are used for notification.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/scsi_tgt_if.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/include/scsi/scsi_tgt_if.h b/include/scsi/scsi_tgt_if.h new file mode 100644 index 000000000000..46d5e70d7215 --- /dev/null +++ b/include/scsi/scsi_tgt_if.h | |||
@@ -0,0 +1,90 @@ | |||
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 */ | ||
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 | |||
34 | struct 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 | |||
41 | struct tgt_event { | ||
42 | struct tgt_event_hdr hdr; | ||
43 | |||
44 | union { | ||
45 | /* user-> kernel */ | ||
46 | struct { | ||
47 | int host_no; | ||
48 | uint32_t len; | ||
49 | int result; | ||
50 | aligned_u64 uaddr; | ||
51 | uint8_t rw; | ||
52 | aligned_u64 tag; | ||
53 | } cmd_rsp; | ||
54 | struct { | ||
55 | int host_no; | ||
56 | aligned_u64 mid; | ||
57 | int result; | ||
58 | } tsk_mgmt_rsp; | ||
59 | |||
60 | |||
61 | /* kernel -> user */ | ||
62 | struct { | ||
63 | int host_no; | ||
64 | uint32_t data_len; | ||
65 | uint8_t scb[16]; | ||
66 | uint8_t lun[8]; | ||
67 | int attribute; | ||
68 | aligned_u64 tag; | ||
69 | } cmd_req; | ||
70 | struct { | ||
71 | int host_no; | ||
72 | aligned_u64 tag; | ||
73 | int result; | ||
74 | } cmd_done; | ||
75 | struct { | ||
76 | int host_no; | ||
77 | int function; | ||
78 | aligned_u64 tag; | ||
79 | uint8_t lun[8]; | ||
80 | aligned_u64 mid; | ||
81 | } tsk_mgmt_req; | ||
82 | } p; | ||
83 | } __attribute__ ((aligned (sizeof(uint64_t)))); | ||
84 | |||
85 | #define TGT_RING_SIZE (1UL << 16) | ||
86 | #define TGT_RING_PAGES (TGT_RING_SIZE >> PAGE_SHIFT) | ||
87 | #define TGT_EVENT_PER_PAGE (PAGE_SIZE / sizeof(struct tgt_event)) | ||
88 | #define TGT_MAX_EVENTS (TGT_EVENT_PER_PAGE * TGT_RING_PAGES) | ||
89 | |||
90 | #endif | ||