Don't use .Xo/.Xc. Fix date format.
[netbsd-mini2440.git] / external / bsd / iscsi / dist / include / osd.h
bloba764f34a47035432cf8c1be389a533f42045454d
1 /*
2 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
3 * By downloading, copying, installing or using the software you agree
4 * to this license. If you do not agree to this license, do not
5 * download, install, copy or use the software.
7 * Intel License Agreement
9 * Copyright (c) 2000, Intel Corporation
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
16 * -Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
19 * -Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
24 * -The name of Intel Corporation may not be used to endorse or
25 * promote products derived from this software without specific prior
26 * written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
35 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
41 #ifndef OSD_H
42 #define OSD_H
44 #include "config.h"
46 #include <sys/types.h>
48 #ifdef HAVE_STDINT_H
49 #include <stdint.h>
50 #endif
52 #include "iscsiutil.h"
54 #define OSD_VENDOR "NetBSD"
55 #define OSD_PRODUCT "NetBSD/Intel OSD"
56 #define OSD_VERSION 0
59 * OSD Configuration
62 #define CONFIG_OSD_CAPACITY_DFLT 1024
63 #define CONFIG_OSD_LUNS_DFLT 1
64 #define CONFIG_OSD_BASEDIR_DFLT "/tmp/iscsi_osd"
65 #define CONFIG_OSD_CDB_LEN 128
68 * OSD Service Actions
71 #define OSD_CREATE_GROUP 0x880B
72 #define OSD_REMOVE_GROUP 0x880C
73 #define OSD_CREATE 0x8802
74 #define OSD_REMOVE 0x880A
75 #define OSD_READ 0x8805
76 #define OSD_WRITE 0x8806
77 #define OSD_GET_ATTR 0x880E
78 #define OSD_SET_ATTR 0x880F
81 * OSD Arguments
84 typedef struct osd_args_t {
85 uint8_t opcode;
86 uint8_t control;
87 uint8_t security;
88 uint8_t add_cdb_len;
89 uint16_t service_action;
90 uint8_t options_byte;
91 uint8_t second_options_byte;
92 uint32_t GroupID;
93 uint64_t UserID;
94 uint32_t SessionID;
95 uint64_t length;
96 uint64_t offset;
97 uint32_t set_attributes_list_length;
98 uint32_t get_attributes_page;
99 uint32_t get_attributes_list_length;
100 uint32_t get_attributes_allocation_length;
101 } osd_args_t;
103 #define OSD_ENCAP_CDB(ARGS, CDB) \
104 (CDB)[0] = (ARGS)->opcode; \
105 (CDB)[1] = (ARGS)->control; \
106 (CDB)[6] = (ARGS)->security; \
107 (CDB)[7] = (ARGS)->add_cdb_len; \
108 *((uint16_t *)((CDB)+8)) = ISCSI_HTONS((ARGS)->service_action); \
109 (CDB)[10] = (ARGS)->options_byte; \
110 (CDB)[11] = (ARGS)->second_options_byte; \
111 *((uint32_t *)((CDB)+12)) = ISCSI_HTONL((ARGS)->GroupID); \
112 *((uint64_t *)((CDB)+16)) = ISCSI_HTONLL((ARGS)->UserID); \
113 *((uint32_t *)((CDB)+24)) = ISCSI_HTONL((ARGS)->SessionID); \
114 *((uint64_t *)((CDB)+28)) = ISCSI_HTONLL((ARGS)->length); \
115 *((uint64_t *)((CDB)+36)) = ISCSI_HTONLL((ARGS)->offset); \
116 *((uint32_t *)((CDB)+44)) = ISCSI_HTONL((ARGS)->get_attributes_page); \
117 *((uint32_t *)((CDB)+48)) = ISCSI_HTONL((ARGS)->get_attributes_list_length); \
118 *((uint32_t *)((CDB)+52)) = ISCSI_HTONL((ARGS)->get_attributes_allocation_length); \
119 *((uint32_t *)((CDB)+72)) = ISCSI_HTONL((ARGS)->set_attributes_list_length);
121 #define OSD_DECAP_CDB(CDB, EXT_CDB, ARGS) \
122 (ARGS)->opcode = (CDB)[0]; \
123 (ARGS)->control = (CDB)[1]; \
124 (ARGS)->security = (CDB)[6]; \
125 (ARGS)->add_cdb_len = (CDB)[7]; \
126 (ARGS)->service_action = ISCSI_NTOHS(*((uint16_t *)((CDB)+8))); \
127 (ARGS)->options_byte = (CDB)[10]; \
128 (ARGS)->second_options_byte = (CDB)[11]; \
129 (ARGS)->GroupID = ISCSI_NTOHL(*((uint32_t *)((CDB)+12))); \
130 (ARGS)->UserID = ISCSI_NTOHLL(*((uint64_t *)((EXT_CDB)-16+16))); \
131 (ARGS)->SessionID = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+24))); \
132 (ARGS)->length = ISCSI_NTOHLL(*((uint64_t *)((EXT_CDB)-16+28))); \
133 (ARGS)->offset = ISCSI_NTOHLL(*((uint64_t *)((EXT_CDB)-16+36))); \
134 (ARGS)->get_attributes_page = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+44))); \
135 (ARGS)->get_attributes_list_length = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+48))); \
136 (ARGS)->get_attributes_allocation_length = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+52))); \
137 (ARGS)->set_attributes_list_length = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+72)));
139 #define OSD_PRINT_CDB(CDB, EXT_CDB) \
140 PRINT("opcode = 0x%x\n", CDB[0]); \
141 PRINT("control = 0x%x\n", CDB[1]); \
142 PRINT("security = 0x%x\n", CDB[6]); \
143 PRINT("add_cdb_len = %u\n", CDB[7]); \
144 PRINT("service_action = 0x%x\n", ISCSI_NTOHS(*(uint16_t*)(CDB+8))); \
145 PRINT("options byte 1 = 0x%x\n", CDB[10]); \
146 PRINT("options byte 2 = 0x%x\n", CDB[11]); \
147 PRINT("group id = 0x%x\n", ISCSI_NTOHL(*(uint32_t*)(CDB+12))); \
148 PRINT("user id = 0x%llx\n", ISCSI_NTOHLL(*(uint64_t*)(EXT_CDB-16+16))); \
149 PRINT("session id = 0x%x\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+24))); \
150 PRINT("length = %llu\n", ISCSI_NTOHLL(*(uint64_t*)(EXT_CDB-16+28))); \
151 PRINT("offset = %llu\n", ISCSI_NTOHLL(*(uint64_t*)(EXT_CDB-16+36))); \
152 PRINT("get attr page = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+44))); \
153 PRINT("get list len = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+48))); \
154 PRINT("get alloc len = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+52))); \
155 PRINT("set list len = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+72)));
157 #endif /* OSD_H */