xref: /illumos-gate/usr/src/uts/common/sys/sbp2/impl.h (revision 2d6eb4a5)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SBP2_IMPL_H
28 #define	_SYS_SBP2_IMPL_H
29 
30 /*
31  * Serial Bus Protocol 2 (SBP-2) implementation
32  */
33 
34 #include <sys/sbp2/common.h>
35 #include <sys/sbp2/bus.h>
36 #include <sys/sbp2/driver.h>
37 #include <sys/note.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /* Config ROM parser internal structure */
44 typedef struct sbp2_cfgrom_parse_arg {
45 	sbp2_cfgrom_ent_t	*pa_dir;	/* directory to parse */
46 	sbp2_cfgrom_ent_t	*pa_pdir;	/* parent directory */
47 	sbp2_cfgrom_ent_t	*pa_ref;	/* referred entry */
48 	int			pa_depth;	/* current depth */
49 } sbp2_cfgrom_parse_arg_t;
50 
51 typedef struct sbp2_cfgrom_ent_by_key {
52 	uint8_t			kt;
53 	uint8_t			kv;
54 	int			num;
55 	sbp2_cfgrom_ent_t	*ent;
56 	int			cnt;
57 } sbp2_cfgrom_ent_by_key_t;
58 
59 _NOTE(SCHEME_PROTECTS_DATA("unique per call", { sbp2_cfgrom_ent_by_key
60     sbp2_cfgrom_parse_arg }))
61 
62 enum {
63 	SBP2_CFGROM_MAX_DEPTH	= 5,	/* max directory depth */
64 	SBP2_CFGROM_GROW_INCR	= 4,	/* entry array growth increment */
65 
66 	SBP2_MOT_MIN		= 500,	/* minimum mgt ORB timeout, in ms */
67 	SBP2_MOT_DFLT		= 2000,	/* default mgt ORB timeout, in ms */
68 	SBP2_ORB_SIZE_MIN	= 4,	/* minimum ORB size, in bytes */
69 	SBP2_ORB_SIZE_DFLT	= 32	/* default ORB size, in bytes */
70 };
71 
72 /* busops macros */
73 #define	SBP2_CSR_BASE(t)	t->t_bus->sb_csr_base
74 #define	SBP2_CFGROM_ADDR(t)	t->t_bus->sb_cfgrom_addr
75 #define	SBP2_GET_IBLOCK_COOKIE(t) \
76 	(t)->t_bus->sb_get_iblock_cookie((t)->t_bus_hdl)
77 #define	SBP2_GET_NODE_ID(t)	(t)->t_bus->sb_get_node_id((t)->t_bus_hdl)
78 #define	SBP2_ALLOC_BUF(t, buf)	(t)->t_bus->sb_alloc_buf((t)->t_bus_hdl, buf)
79 #define	SBP2_FREE_BUF(t, buf)	(t)->t_bus->sb_free_buf((t)->t_bus_hdl, buf)
80 #define	SBP2_SYNC_BUF(t, buf, offset, length, type) \
81 	(t)->t_bus->sb_sync_buf((t)->t_bus_hdl, buf, offset, length, type)
82 #define	SBP2_BUF_RD_DONE(t, buf, reqh, error) \
83 	(t)->t_bus->sb_buf_rd_done((t)->t_bus_hdl, buf, reqh, error)
84 #define	SBP2_BUF_WR_DONE(t, buf, reqh, error) \
85 	(t)->t_bus->sb_buf_wr_done((t)->t_bus_hdl, buf, reqh, error)
86 #define	SBP2_ALLOC_CMD(t, cmdp, f) \
87 	(t)->t_bus->sb_alloc_cmd((t)->t_bus_hdl, cmdp, f)
88 #define	SBP2_FREE_CMD(t, cmd) \
89 	(t)->t_bus->sb_free_cmd((t)->t_bus_hdl, cmd)
90 #define	SBP2_RQ(t, cmd, addr, q, berr) \
91 	(t)->t_bus->sb_rq((t)->t_bus_hdl, cmd, addr, q, berr)
92 #define	SBP2_RB(t, cmd, addr, bp, len, berr) \
93 	(t)->t_bus->sb_rb((t)->t_bus_hdl, cmd, addr, bp, len, berr)
94 #define	SBP2_WQ(t, cmd, addr, q, berr) \
95 	(t)->t_bus->sb_wq((t)->t_bus_hdl, cmd, addr, q, berr)
96 #define	SBP2_WB(t, cmd, addr, bp, len, berr) \
97 	(t)->t_bus->sb_wb((t)->t_bus_hdl, cmd, addr, bp, len, berr)
98 
99 int	sbp2_cfgrom_parse(sbp2_tgt_t *, sbp2_cfgrom_t *);
100 void	sbp2_cfgrom_free(sbp2_tgt_t *, sbp2_cfgrom_t *);
101 
102 #ifdef	__cplusplus
103 }
104 #endif
105 
106 #endif	/* _SYS_SBP2_IMPL_H */
107