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
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.
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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_DMU_CTL_IMPL_H
28 #define _SYS_DMU_CTL_IMPL_H
31 #include <sys/types.h>
32 #include <sys/socket.h>
36 #define SOCKNAME "dmu_socket"
38 #define DCTL_PROTOCOL_VER 1
39 #define DCTL_MAGIC 0xdc71b1070c01dc71ll
50 DCTL_GEN_REPLY /* generic reply */
53 /* On-the-wire message */
54 typedef struct dctl_cmd {
66 struct dcmd_copy_req {
78 uint64_t size; /* used by reply to DCTL_COPYINSTR,
79 DCTL_FD_READ and DCTL_FD_WRITE */
80 int32_t rc; /* return code */
86 #define DCTL_CMD_HEADER_SIZE (sizeof(uint64_t) + sizeof(uint8_t))
89 * The following definitions are only used by the server code.
92 #define LISTEN_BACKLOG 5
94 /* Worker thread data */
95 typedef struct wthr_info {
96 list_node_t wthr_node;
98 boolean_t wthr_exit; /* termination flag */
102 /* Control socket data */
103 typedef struct dctl_sock_info {
104 pthread_mutex_t dsi_mtx;
106 struct sockaddr_un dsi_addr;
110 typedef void *thr_func_t(void *);
112 /* Thread pool data */
113 typedef struct dctl_thr_info {
114 thr_func_t *dti_thr_func;
116 pthread_mutex_t dti_mtx; /* protects the thread lists and dti_free */
117 list_t dti_list; /* list of threads in the thread pool */
118 list_t dti_join_list; /* list of threads that are waiting to be
120 int dti_free; /* number of free worker threads */
125 boolean_t dti_exit; /* global termination flag */
128 /* Messaging functions functions */
129 int dctl_read_msg(int fd, dctl_cmd_t *cmd);
130 int dctl_send_msg(int fd, dctl_cmd_t *cmd);
132 int dctl_read_data(int fd, void *ptr, size_t size);
133 int dctl_send_data(int fd, const void *ptr, size_t size);
135 /* Thread pool functions */
136 int dctl_thr_pool_create(int min_thr, int max_free_thr,
137 thr_func_t *thr_func);
138 void dctl_thr_pool_stop();
140 void dctl_thr_join();
141 void dctl_thr_die(wthr_info_t *thr);
142 void dctl_thr_rebalance(wthr_info_t *thr, boolean_t set_free);