xref: /titanic_51/usr/src/uts/common/sys/sbp2/impl.h (revision bbaa8b60dd95d714741fc474adad3cf710ef4efd)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Serial Bus Protocol 2 (SBP-2) implementation
34  */
35 
36 #include <sys/sbp2/common.h>
37 #include <sys/sbp2/bus.h>
38 #include <sys/sbp2/driver.h>
39 #include <sys/note.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 /* Config ROM parser internal structure */
46 typedef struct sbp2_cfgrom_parse_arg {
47 	sbp2_cfgrom_ent_t	*pa_dir;	/* directory to parse */
48 	sbp2_cfgrom_ent_t	*pa_pdir;	/* parent directory */
49 	sbp2_cfgrom_ent_t	*pa_ref;	/* referred entry */
50 	int			pa_depth;	/* current depth */
51 } sbp2_cfgrom_parse_arg_t;
52 
53 typedef struct sbp2_cfgrom_ent_by_key {
54 	uint8_t			kt;
55 	uint8_t			kv;
56 	int			num;
57 	sbp2_cfgrom_ent_t	*ent;
58 	int			cnt;
59 } sbp2_cfgrom_ent_by_key_t;
60 
61 _NOTE(SCHEME_PROTECTS_DATA("unique per call", { sbp2_cfgrom_ent_by_key
62     sbp2_cfgrom_parse_arg }))
63 
64 enum {
65 	SBP2_CFGROM_MAX_DEPTH	= 5,	/* max directory depth */
66 	SBP2_CFGROM_GROW_INCR	= 4,	/* entry array growth increment */
67 
68 	SBP2_MOT_MIN		= 500,	/* minimum mgt ORB timeout, in ms */
69 	SBP2_MOT_DFLT		= 2000,	/* default mgt ORB timeout, in ms */
70 	SBP2_ORB_SIZE_MIN	= 4,	/* minimum ORB size, in bytes */
71 	SBP2_ORB_SIZE_DFLT	= 32	/* default ORB size, in bytes */
72 };
73 
74 /* busops macros */
75 #define	SBP2_CSR_BASE(t)	t->t_bus->sb_csr_base
76 #define	SBP2_CFGROM_ADDR(t)	t->t_bus->sb_cfgrom_addr
77 #define	SBP2_GET_IBLOCK_COOKIE(t) \
78 	(t)->t_bus->sb_get_iblock_cookie((t)->t_bus_hdl)
79 #define	SBP2_GET_NODE_ID(t)	(t)->t_bus->sb_get_node_id((t)->t_bus_hdl)
80 #define	SBP2_ALLOC_BUF(t, buf)	(t)->t_bus->sb_alloc_buf((t)->t_bus_hdl, buf)
81 #define	SBP2_FREE_BUF(t, buf)	(t)->t_bus->sb_free_buf((t)->t_bus_hdl, buf)
82 #define	SBP2_SYNC_BUF(t, buf, offset, length, type) \
83 	(t)->t_bus->sb_sync_buf((t)->t_bus_hdl, buf, offset, length, type)
84 #define	SBP2_BUF_RD_DONE(t, buf, reqh, error) \
85 	(t)->t_bus->sb_buf_rd_done((t)->t_bus_hdl, buf, reqh, error)
86 #define	SBP2_BUF_WR_DONE(t, buf, reqh, error) \
87 	(t)->t_bus->sb_buf_wr_done((t)->t_bus_hdl, buf, reqh, error)
88 #define	SBP2_ALLOC_CMD(t, cmdp, f) \
89 	(t)->t_bus->sb_alloc_cmd((t)->t_bus_hdl, cmdp, f)
90 #define	SBP2_FREE_CMD(t, cmd) \
91 	(t)->t_bus->sb_free_cmd((t)->t_bus_hdl, cmd)
92 #define	SBP2_RQ(t, cmd, addr, q, berr) \
93 	(t)->t_bus->sb_rq((t)->t_bus_hdl, cmd, addr, q, berr)
94 #define	SBP2_RB(t, cmd, addr, bp, len, berr) \
95 	(t)->t_bus->sb_rb((t)->t_bus_hdl, cmd, addr, bp, len, berr)
96 #define	SBP2_WQ(t, cmd, addr, q, berr) \
97 	(t)->t_bus->sb_wq((t)->t_bus_hdl, cmd, addr, q, berr)
98 #define	SBP2_WB(t, cmd, addr, bp, len, berr) \
99 	(t)->t_bus->sb_wb((t)->t_bus_hdl, cmd, addr, bp, len, berr)
100 
101 int	sbp2_cfgrom_parse(sbp2_tgt_t *, sbp2_cfgrom_t *);
102 void	sbp2_cfgrom_free(sbp2_tgt_t *, sbp2_cfgrom_t *);
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 #endif	/* _SYS_SBP2_IMPL_H */
109