6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / uts / common / sys / sodirect.h
blobf87d010f56303baa0c319ecf5b2648dfafe79afc
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
40 #ifndef _SYS_SODIRECT_H
41 #define _SYS_SODIRECT_H
44 * Sodirect ...
46 * Currently the sodirect_t uses the sockfs streamhead STREAMS Q directly,
47 * in the future when we have STREAMless sockets a sonode Q will have to
48 * be implemented however the sodirect KPI shouldn't need to change.
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
55 typedef int (*sod_enq_func)();
56 typedef void (*sod_wakeup_func)();
58 typedef struct sodirect_s {
59 uint32_t sod_state; /* State bits */
60 uint32_t sod_want; /* Pending read byte count or 0 */
61 queue_t *sod_q; /* Socket Q */
62 sod_enq_func sod_enqueue; /* Call to enqueue an mblk_t */
63 sod_wakeup_func sod_wakeup; /* Call to awkake a read()er, if any */
64 mblk_t *sod_uioafh; /* To be freed list head, or NULL */
65 mblk_t *sod_uioaft; /* To be freed list tail */
66 kmutex_t *sod_lockp; /* Pointer to the lock needed */
67 /* to protect all members */
68 uioa_t sod_uioa; /* Pending uio_t for uioa_t use */
69 } sodirect_t;
72 * sod_state bits:
75 #define SOD_DISABLED 0 /* No more sodirect */
77 #define SOD_ENABLED 0x0001 /* sodirect_t enabled */
79 #define SOD_WAKE_NOT 0x0010 /* Wakeup not needed */
80 #define SOD_WAKE_NEED 0x0020 /* Wakeup needed */
81 #define SOD_WAKE_DONE 0x0040 /* Wakeup done */
82 #define SOD_WAKE_CLR ~(SOD_WAKE_NOT|SOD_WAKE_NEED|SOD_WAKE_DONE)
85 * Usefull macros:
88 #define SOD_QSETBE(p) { \
89 queue_t *q = (p)->sod_q; \
91 ASSERT(MUTEX_HELD((p)->sod_lockp)); \
93 mutex_enter(QLOCK(q)); \
94 if (q->q_flag & QFULL) \
95 q->q_flag |= QWANTW; \
96 mutex_exit(QLOCK(q)); \
99 #define SOD_QCLRBE(p) { \
100 queue_t *q = (p)->sod_q; \
102 ASSERT(MUTEX_HELD((p)->sod_lockp)); \
104 mutex_enter(QLOCK(q)); \
105 q->q_flag &= ~QWANTW; \
106 mutex_exit(QLOCK(q)); \
109 #define SOD_QEMPTY(p) ((p)->sod_q->q_first == NULL)
110 #define SOD_QFULL(p) ((p)->sod_q->q_flag & QFULL)
111 #define SOD_QCNT(p) ((p)->sod_q->q_count)
113 #define SOD_DISABLE(p) { \
114 if ((p) != NULL) \
115 (p)->sod_state &= ~SOD_ENABLED; \
118 #define SOD_QTOSODP(q) (q)->q_stream->sd_sodirect
119 #define SOD_SOTOSODP(so) ((sonode_t *)so)->so_direct
121 #define SOD_UIOAFINI(sodp) { \
122 if ((sodp) && (sodp)->sod_uioa.uioa_state & UIOA_ENABLED) { \
123 (sodp)->sod_uioa.uioa_state &= UIOA_CLR; \
124 (sodp)->sod_uioa.uioa_state |= UIOA_FINI; \
128 struct sonode;
129 struct sodirect_s;
131 extern uio_t *sod_rcv_init(struct sonode *, int, struct uio **);
132 extern int sod_rcv_done(struct sonode *, struct uio *, struct uio *);
134 extern mblk_t *sod_uioa_mblk_init(struct sodirect_s *, mblk_t *, size_t);
135 extern void sod_uioa_so_init(struct sonode *, struct sodirect_s *,
136 struct uio *);
137 extern ssize_t sod_uioa_mblk(struct sonode *, mblk_t *);
138 extern void sod_uioa_mblk_done(struct sodirect_s *, mblk_t *);
140 extern void sod_init();
141 extern void sod_sock_init(struct sonode *, struct stdata *, sod_enq_func,
142 sod_wakeup_func, kmutex_t *);
144 #ifdef __cplusplus
146 #endif
148 #endif /* _SYS_SODIRECT_H */