1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_STMF_SBD_H
27 #define	_STMF_SBD_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #define	SBD_FAILURE		STMF_LU_FAILURE
34 #define	SBD_FILEIO_FAILURE	(SBD_FAILURE | STMF_FSC(1))
35 
36 /*
37  * if the function pointers to write metadata are NULL, then sbd assumes that
38  * metadata and LU data share the same store. In that case sbd sets aside
39  * some space for metadata and adjusts the LU size reported to initiators
40  * accordingly.
41  */
42 typedef	struct sbd_store {
43 	void		*sst_sbd_private;
44 	void		*sst_store_private;
45 	char		*sst_alias;
46 
47 	stmf_status_t	(*sst_online)(struct sbd_store *sst);
48 	stmf_status_t	(*sst_offline)(struct sbd_store *sst);
49 	stmf_status_t	(*sst_deregister_lu)(struct sbd_store *sst);
50 
51 	stmf_status_t	(*sst_data_read)(struct sbd_store *sst,
52 				uint64_t offset, uint64_t size, uint8_t *buf);
53 	stmf_status_t	(*sst_data_write)(struct sbd_store *sst,
54 				uint64_t offset, uint64_t size, uint8_t *buf);
55 	stmf_status_t	(*sst_data_flush)(struct sbd_store *sst);
56 
57 	stmf_status_t	(*sst_meta_read)(struct sbd_store *sst,
58 				uint64_t offset, uint64_t size, uint8_t *buf);
59 	stmf_status_t	(*sst_meta_write)(struct sbd_store *sst,
60 				uint64_t offset, uint64_t size, uint8_t *buf);
61 } sbd_store_t;
62 
63 typedef struct sst_init_data {
64 	uint64_t	sst_store_size;		/* Total size of the store */
65 
66 	/*
67 	 * This is the metadat for the store implementation itself
68 	 * that needs to be persisted.
69 	 */
70 	uint64_t	sst_store_meta_data_size;
71 
72 	/* This is returned to the caller */
73 	uint8_t		sst_guid[16];
74 
75 	uint32_t	sst_flags;
76 	uint16_t	sst_blocksize;		/* To expose to initiators */
77 } sst_init_data_t;
78 
79 /*
80  * sst_flags.
81  */
82 #define	SST_NOT_PERSISTENT	0x0001
83 #define	SST_READONLY_DATA	0x0002
84 
85 sbd_store_t *sbd_sst_alloc(uint32_t additional_size, uint32_t flags);
86 void sbd_sst_free(sbd_store_t *sst);
87 stmf_status_t sbd_create_meta(sbd_store_t *sst, sst_init_data_t *sst_idata);
88 stmf_status_t sbd_modify_meta(sbd_store_t *sst, sst_init_data_t *sst_idata);
89 stmf_status_t sbd_register_sst(sbd_store_t *sst, sst_init_data_t *sst_idata);
90 stmf_status_t sbd_deregister_sst(sbd_store_t *sst);
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif /* _STMF_SBD_H */
97