1 1991 heppo /* 2 1991 heppo * CDDL HEADER START 3 1991 heppo * 4 1991 heppo * The contents of this file are subject to the terms of the 5 1991 heppo * Common Development and Distribution License (the "License"). 6 1991 heppo * You may not use this file except in compliance with the License. 7 1991 heppo * 8 1991 heppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 1991 heppo * or http://www.opensolaris.org/os/licensing. 10 1991 heppo * See the License for the specific language governing permissions 11 1991 heppo * and limitations under the License. 12 1991 heppo * 13 1991 heppo * When distributing Covered Code, include this CDDL HEADER in each 14 1991 heppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 1991 heppo * If applicable, add the following below this CDDL HEADER, with the 16 1991 heppo * fields enclosed by brackets "[]" replaced with your own identifying 17 1991 heppo * information: Portions Copyright [yyyy] [name of copyright owner] 18 1991 heppo * 19 1991 heppo * CDDL HEADER END 20 1991 heppo */ 21 1991 heppo 22 1991 heppo /* 23 9889 Larry * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 1991 heppo * Use is subject to license terms. 25 1991 heppo */ 26 1991 heppo 27 1991 heppo #ifndef _VDC_H 28 1991 heppo #define _VDC_H 29 1991 heppo 30 1991 heppo /* 31 1991 heppo * Virtual disk client implementation definitions 32 1991 heppo */ 33 1991 heppo 34 1991 heppo #include <sys/sysmacros.h> 35 1991 heppo #include <sys/note.h> 36 1991 heppo 37 1991 heppo #include <sys/ldc.h> 38 1991 heppo #include <sys/vio_mailbox.h> 39 1991 heppo #include <sys/vdsk_mailbox.h> 40 1991 heppo #include <sys/vdsk_common.h> 41 1991 heppo 42 1991 heppo #ifdef __cplusplus 43 1991 heppo extern "C" { 44 1991 heppo #endif 45 1991 heppo 46 1991 heppo #define VDC_DRIVER_NAME "vdc" 47 1991 heppo 48 1991 heppo /* 49 1991 heppo * Bit-field values to indicate if parts of the vdc driver are initialised. 50 1991 heppo */ 51 1991 heppo #define VDC_SOFT_STATE 0x0001 52 1991 heppo #define VDC_LOCKS 0x0002 53 1991 heppo #define VDC_MINOR 0x0004 54 1991 heppo #define VDC_THREAD 0x0008 55 6480 narayan #define VDC_DRING_INIT 0x0010 /* The DRing was created */ 56 6480 narayan #define VDC_DRING_BOUND 0x0020 /* The DRing was bound to an LDC channel */ 57 6480 narayan #define VDC_DRING_LOCAL 0x0040 /* The local private DRing was allocated */ 58 6480 narayan #define VDC_DRING_ENTRY 0x0080 /* At least one DRing entry was initialised */ 59 1991 heppo #define VDC_DRING (VDC_DRING_INIT | VDC_DRING_BOUND | \ 60 1991 heppo VDC_DRING_LOCAL | VDC_DRING_ENTRY) 61 6480 narayan #define VDC_HANDSHAKE 0x0100 /* Indicates if a handshake is in progress */ 62 6480 narayan #define VDC_HANDSHAKE_STOP 0x0200 /* stop further handshakes */ 63 1991 heppo 64 1991 heppo /* 65 1991 heppo * Definitions of MD nodes/properties. 66 1991 heppo */ 67 1991 heppo #define VDC_MD_CHAN_NAME "channel-endpoint" 68 1991 heppo #define VDC_MD_VDEV_NAME "virtual-device" 69 4848 achartre #define VDC_MD_PORT_NAME "virtual-device-port" 70 1991 heppo #define VDC_MD_DISK_NAME "disk" 71 1991 heppo #define VDC_MD_CFG_HDL "cfg-handle" 72 4848 achartre #define VDC_MD_TIMEOUT "vdc-timeout" 73 4848 achartre #define VDC_MD_ID "id" 74 1991 heppo 75 1991 heppo /* 76 2410 lm66018 * Definition of actions to be carried out when processing the sequence ID 77 2410 lm66018 * of a message received from the vDisk server. The function verifying the 78 2410 lm66018 * sequence number checks the 'seq_num_xxx' fields in the soft state and 79 2410 lm66018 * returns whether the message should be processed (VDC_SEQ_NUM_TODO) or 80 2410 lm66018 * whether it was it was previously processed (VDC_SEQ_NUM_SKIP). 81 2410 lm66018 */ 82 2410 lm66018 #define VDC_SEQ_NUM_INVALID -1 /* Error */ 83 2410 lm66018 #define VDC_SEQ_NUM_SKIP 0 /* Request already processed */ 84 2410 lm66018 #define VDC_SEQ_NUM_TODO 1 /* Request needs processing */ 85 11004 Alexandre 86 11004 Alexandre /* 87 11004 Alexandre * Flags for virtual disk operations. 88 11004 Alexandre */ 89 11004 Alexandre #define VDC_OP_STATE_RUNNING 0x01 /* do operation in running state */ 90 11004 Alexandre #define VDC_OP_ERRCHK_BACKEND 0x02 /* check backend on error */ 91 11004 Alexandre #define VDC_OP_ERRCHK_CONFLICT 0x04 /* check resv conflict on error */ 92 11004 Alexandre 93 11004 Alexandre #define VDC_OP_ERRCHK (VDC_OP_ERRCHK_BACKEND | VDC_OP_ERRCHK_CONFLICT) 94 11004 Alexandre #define VDC_OP_NORMAL (VDC_OP_STATE_RUNNING | VDC_OP_ERRCHK) 95 2410 lm66018 96 2410 lm66018 /* 97 3078 narayan * Macros to get UNIT and PART number 98 3078 narayan */ 99 3078 narayan #define VDCUNIT_SHIFT 3 100 3078 narayan #define VDCPART_MASK 7 101 3078 narayan 102 3078 narayan #define VDCUNIT(dev) (getminor((dev)) >> VDCUNIT_SHIFT) 103 3078 narayan #define VDCPART(dev) (getminor((dev)) & VDCPART_MASK) 104 3078 narayan 105 3078 narayan /* 106 1991 heppo * Scheme to store the instance number and the slice number in the minor number. 107 3078 narayan * (NOTE: Uses the same format and definitions as the sd(7D) driver) 108 1991 heppo */ 109 3078 narayan #define VD_MAKE_DEV(instance, minor) ((instance << VDCUNIT_SHIFT) | minor) 110 9889 Larry 111 9889 Larry #define VDC_EFI_DEV_SET(dev, vdsk, ioctl) \ 112 9889 Larry VDSK_EFI_DEV_SET(dev, vdsk, ioctl, \ 113 9889 Larry (vdsk)->vdisk_bsize, (vdsk)->vdisk_size) 114 1991 heppo 115 1991 heppo /* 116 1991 heppo * variables controlling how long to wait before timing out and how many 117 1991 heppo * retries to attempt before giving up when communicating with vds. 118 2410 lm66018 * 119 2410 lm66018 * These values need to be sufficiently large so that a guest can survive 120 2410 lm66018 * the reboot of the service domain. 121 1991 heppo */ 122 2410 lm66018 #define VDC_RETRIES 10 123 1991 heppo 124 1991 heppo #define VDC_USEC_TIMEOUT_MIN (30 * MICROSEC) /* 30 sec */ 125 1991 heppo 126 2410 lm66018 /* 127 2410 lm66018 * This macro returns the number of Hz that the vdc driver should wait before 128 2410 lm66018 * a timeout is triggered. The 'timeout' parameter specifiecs the wait 129 2410 lm66018 * time in Hz. The 'mul' parameter allows for a multiplier to be 130 2410 lm66018 * specified allowing for a backoff to be implemented (e.g. using the 131 2410 lm66018 * retry number as a multiplier) where the wait time will get longer if 132 2410 lm66018 * there is no response on the previous retry. 133 2410 lm66018 */ 134 2410 lm66018 #define VD_GET_TIMEOUT_HZ(timeout, mul) \ 135 2410 lm66018 (ddi_get_lbolt() + ((timeout) * MAX(1, (mul)))) 136 1991 heppo 137 1991 heppo /* 138 1991 heppo * Macros to manipulate Descriptor Ring variables in the soft state 139 1991 heppo * structure. 140 1991 heppo */ 141 2410 lm66018 #define VDC_GET_NEXT_REQ_ID(vdc) ((vdc)->req_id++) 142 1991 heppo 143 1991 heppo #define VDC_GET_DRING_ENTRY_PTR(vdc, idx) \ 144 5365 lm66018 (vd_dring_entry_t *)(uintptr_t)((vdc)->dring_mem_info.vaddr + \ 145 2410 lm66018 (idx * (vdc)->dring_entry_size)) 146 1991 heppo 147 1991 heppo #define VDC_MARK_DRING_ENTRY_FREE(vdc, idx) \ 148 1991 heppo { \ 149 1991 heppo vd_dring_entry_t *dep = NULL; \ 150 1991 heppo ASSERT(vdc != NULL); \ 151 5365 lm66018 ASSERT(idx < vdc->dring_len); \ 152 1991 heppo ASSERT(vdc->dring_mem_info.vaddr != NULL); \ 153 5365 lm66018 dep = (vd_dring_entry_t *)(uintptr_t) \ 154 5365 lm66018 (vdc->dring_mem_info.vaddr + \ 155 1991 heppo (idx * vdc->dring_entry_size)); \ 156 1991 heppo ASSERT(dep != NULL); \ 157 1991 heppo dep->hdr.dstate = VIO_DESC_FREE; \ 158 1991 heppo } 159 1991 heppo 160 1991 heppo /* Initialise the Session ID and Sequence Num in the DRing msg */ 161 1991 heppo #define VDC_INIT_DRING_DATA_MSG_IDS(dmsg, vdc) \ 162 1991 heppo ASSERT(vdc != NULL); \ 163 1991 heppo dmsg.tag.vio_sid = vdc->session_id; \ 164 2032 lm66018 dmsg.seq_num = vdc->seq_num; 165 1991 heppo 166 1991 heppo /* 167 2793 lm66018 * The states that the read thread can be in. 168 1991 heppo */ 169 2793 lm66018 typedef enum vdc_rd_state { 170 2793 lm66018 VDC_READ_IDLE, /* idling - conn is not up */ 171 2793 lm66018 VDC_READ_WAITING, /* waiting for data */ 172 2793 lm66018 VDC_READ_PENDING, /* pending data avail for read */ 173 2793 lm66018 VDC_READ_RESET /* channel was reset - stop reads */ 174 2793 lm66018 } vdc_rd_state_t; 175 2793 lm66018 176 2793 lm66018 /* 177 2793 lm66018 * The states that the vdc-vds connection can be in. 178 2793 lm66018 */ 179 2793 lm66018 typedef enum vdc_state { 180 2793 lm66018 VDC_STATE_INIT, /* device is initialized */ 181 2793 lm66018 VDC_STATE_INIT_WAITING, /* waiting for ldc connection */ 182 2793 lm66018 VDC_STATE_NEGOTIATE, /* doing handshake negotiation */ 183 2793 lm66018 VDC_STATE_HANDLE_PENDING, /* handle requests in backup dring */ 184 11004 Alexandre VDC_STATE_FAULTED, /* multipath backend is inaccessible */ 185 11004 Alexandre VDC_STATE_FAILED, /* device is not usable */ 186 2793 lm66018 VDC_STATE_RUNNING, /* running and accepting requests */ 187 2793 lm66018 VDC_STATE_DETACH, /* detaching */ 188 2793 lm66018 VDC_STATE_RESETTING /* resetting connection with vds */ 189 2793 lm66018 } vdc_state_t; 190 11004 Alexandre 191 11004 Alexandre /* 192 11004 Alexandre * States of the service provided by a vds server 193 11004 Alexandre */ 194 11004 Alexandre typedef enum vdc_service_state { 195 11004 Alexandre VDC_SERVICE_NONE = -1, /* no state define */ 196 11004 Alexandre VDC_SERVICE_OFFLINE, /* no connection with the service */ 197 11004 Alexandre VDC_SERVICE_CONNECTED, /* connection established */ 198 11004 Alexandre VDC_SERVICE_ONLINE, /* connection and backend available */ 199 11004 Alexandre VDC_SERVICE_FAILED, /* connection failed */ 200 11004 Alexandre VDC_SERVICE_FAULTED /* connection but backend unavailable */ 201 11004 Alexandre } vdc_service_state_t; 202 2793 lm66018 203 2793 lm66018 /* 204 2793 lm66018 * The states that the vdc instance can be in. 205 2793 lm66018 */ 206 2793 lm66018 typedef enum vdc_lc_state { 207 2793 lm66018 VDC_LC_ATTACHING, /* driver is attaching */ 208 2793 lm66018 VDC_LC_ONLINE, /* driver is attached and online */ 209 2793 lm66018 VDC_LC_DETACHING /* driver is detaching */ 210 2793 lm66018 } vdc_lc_state_t; 211 1991 heppo 212 1991 heppo /* 213 1991 heppo * Local Descriptor Ring entry 214 1991 heppo * 215 1991 heppo * vdc creates a Local (private) descriptor ring the same size as the 216 1991 heppo * public descriptor ring it exports to vds. 217 1991 heppo */ 218 2793 lm66018 219 2793 lm66018 typedef enum { 220 2793 lm66018 VIO_read_dir, /* read data from server */ 221 2793 lm66018 VIO_write_dir, /* write data to server */ 222 2793 lm66018 VIO_both_dir /* transfer both in and out in same buffer */ 223 2793 lm66018 } vio_desc_direction_t; 224 2793 lm66018 225 1991 heppo typedef struct vdc_local_desc { 226 2793 lm66018 boolean_t is_free; /* local state - inuse or not */ 227 2793 lm66018 228 1991 heppo int operation; /* VD_OP_xxx to be performed */ 229 1991 heppo caddr_t addr; /* addr passed in by consumer */ 230 2793 lm66018 int slice; 231 2793 lm66018 diskaddr_t offset; /* disk offset */ 232 2793 lm66018 size_t nbytes; 233 11004 Alexandre struct buf *buf; /* buf of operation */ 234 2793 lm66018 vio_desc_direction_t dir; /* direction of transfer */ 235 11004 Alexandre int flags; /* flags of operation */ 236 2793 lm66018 237 1991 heppo caddr_t align_addr; /* used if addr non-aligned */ 238 1991 heppo ldc_mem_handle_t desc_mhdl; /* Mem handle of buf */ 239 1991 heppo vd_dring_entry_t *dep; /* public Dring Entry Pointer */ 240 2793 lm66018 241 1991 heppo } vdc_local_desc_t; 242 1991 heppo 243 1991 heppo /* 244 11004 Alexandre * I/O queue used for checking backend or failfast 245 5658 achartre */ 246 5658 achartre typedef struct vdc_io { 247 5658 achartre struct vdc_io *vio_next; /* next pending I/O in the queue */ 248 11004 Alexandre int vio_index; /* descriptor index */ 249 5658 achartre clock_t vio_qtime; /* time the I/O was queued */ 250 5658 achartre } vdc_io_t; 251 5658 achartre 252 5658 achartre /* 253 6480 narayan * Per vDisk server channel states 254 6480 narayan */ 255 6480 narayan #define VDC_LDC_INIT 0x0001 256 6480 narayan #define VDC_LDC_CB 0x0002 257 6480 narayan #define VDC_LDC_OPEN 0x0004 258 6480 narayan #define VDC_LDC (VDC_LDC_INIT | VDC_LDC_CB | VDC_LDC_OPEN) 259 6480 narayan 260 6480 narayan /* 261 6480 narayan * vDisk server information 262 6480 narayan */ 263 6480 narayan typedef struct vdc_server { 264 6480 narayan struct vdc_server *next; /* Next server */ 265 6480 narayan struct vdc *vdcp; /* Ptr to vdc struct */ 266 6480 narayan uint64_t id; /* Server port id */ 267 6480 narayan uint64_t state; /* Server state */ 268 11004 Alexandre vdc_service_state_t svc_state; /* Service state */ 269 11004 Alexandre vdc_service_state_t log_state; /* Last state logged */ 270 6480 narayan uint64_t ldc_id; /* Server LDC id */ 271 6480 narayan ldc_handle_t ldc_handle; /* Server LDC handle */ 272 6480 narayan ldc_status_t ldc_state; /* Server LDC state */ 273 6480 narayan uint64_t ctimeout; /* conn tmout (secs) */ 274 6480 narayan } vdc_server_t; 275 6480 narayan 276 6480 narayan /* 277 1991 heppo * vdc soft state structure 278 1991 heppo */ 279 1991 heppo typedef struct vdc { 280 1991 heppo 281 1991 heppo kmutex_t lock; /* protects next 2 sections of vars */ 282 2793 lm66018 kcondvar_t running_cv; /* signal when upper layers can send */ 283 2793 lm66018 kcondvar_t initwait_cv; /* signal when ldc conn is up */ 284 2793 lm66018 kcondvar_t dring_free_cv; /* signal when desc is avail */ 285 2793 lm66018 kcondvar_t membind_cv; /* signal when mem can be bound */ 286 11004 Alexandre boolean_t self_reset; /* self initiated reset */ 287 11004 Alexandre kcondvar_t io_pending_cv; /* signal on pending I/O */ 288 11004 Alexandre boolean_t io_pending; /* pending I/O */ 289 1991 heppo 290 1991 heppo int initialized; /* keeps track of what's init'ed */ 291 2793 lm66018 vdc_lc_state_t lifecycle; /* Current state of the vdc instance */ 292 2793 lm66018 293 2032 lm66018 int hshake_cnt; /* number of failed handshakes */ 294 4963 achartre uint8_t open[OTYPCNT]; /* mask of opened slices */ 295 4963 achartre uint8_t open_excl; /* mask of exclusively opened slices */ 296 4963 achartre ulong_t open_lyr[V_NUMPAR]; /* number of layered opens */ 297 2793 lm66018 int dkio_flush_pending; /* # outstanding DKIO flushes */ 298 4963 achartre int validate_pending; /* # outstanding validate request */ 299 4963 achartre vd_disk_label_t vdisk_label; /* label type of device/disk imported */ 300 7563 Prasad struct extvtoc *vtoc; /* structure to store VTOC data */ 301 4963 achartre struct dk_geom *geom; /* structure to store geometry data */ 302 5874 achartre vd_slice_t slice[V_NUMPAR]; /* logical partitions */ 303 2793 lm66018 304 2793 lm66018 kthread_t *msg_proc_thr; /* main msg processing thread */ 305 2793 lm66018 306 2793 lm66018 kmutex_t read_lock; /* lock to protect read */ 307 2793 lm66018 kcondvar_t read_cv; /* cv to wait for READ events */ 308 2793 lm66018 vdc_rd_state_t read_state; /* current read state */ 309 2793 lm66018 310 2793 lm66018 uint32_t sync_op_cnt; /* num of active sync operations */ 311 2793 lm66018 boolean_t sync_op_blocked; /* blocked waiting to do sync op */ 312 2793 lm66018 kcondvar_t sync_blocked_cv; /* cv wait for other syncs to finish */ 313 1991 heppo 314 1991 heppo uint64_t session_id; /* common ID sent with all messages */ 315 1991 heppo uint64_t seq_num; /* most recent sequence num generated */ 316 1991 heppo uint64_t seq_num_reply; /* Last seq num ACK/NACK'ed by vds */ 317 1991 heppo uint64_t req_id; /* Most recent Request ID generated */ 318 2410 lm66018 uint64_t req_id_proc; /* Last request ID processed by vdc */ 319 2793 lm66018 vdc_state_t state; /* Current disk client-server state */ 320 2410 lm66018 321 2410 lm66018 dev_info_t *dip; /* device info pointer */ 322 2410 lm66018 int instance; /* driver instance number */ 323 2793 lm66018 324 2410 lm66018 vio_ver_t ver; /* version number agreed with server */ 325 1991 heppo vd_disk_type_t vdisk_type; /* type of device/disk being imported */ 326 5365 lm66018 uint32_t vdisk_media; /* physical media type of vDisk */ 327 2531 narayan uint64_t vdisk_size; /* device size in blocks */ 328 1991 heppo uint64_t max_xfer_sz; /* maximum block size of a descriptor */ 329 9889 Larry uint64_t vdisk_bsize; /* blk size for the virtual disk */ 330 9889 Larry uint32_t vio_bmask; /* mask to check vio blk alignment */ 331 9889 Larry int vio_bshift; /* shift for vio blk conversion */ 332 5365 lm66018 uint64_t operations; /* bitmask of ops. server supports */ 333 1991 heppo struct dk_cinfo *cinfo; /* structure to store DKIOCINFO data */ 334 1991 heppo struct dk_minfo *minfo; /* structure for DKIOCGMEDIAINFO data */ 335 2531 narayan ddi_devid_t devid; /* device id */ 336 4848 achartre boolean_t ctimeout_reached; /* connection timeout has expired */ 337 1991 heppo 338 5658 achartre /* 339 5658 achartre * The ownership fields are protected by the lock mutex. The 340 5658 achartre * ownership_lock mutex is used to serialize ownership operations; 341 5658 achartre * it should be acquired before the lock mutex. 342 5658 achartre */ 343 5658 achartre kmutex_t ownership_lock; /* serialize ownership ops */ 344 5658 achartre int ownership; /* ownership status flags */ 345 5658 achartre kthread_t *ownership_thread; /* ownership thread */ 346 5658 achartre kcondvar_t ownership_cv; /* cv for ownership update */ 347 5658 achartre 348 5658 achartre /* 349 11004 Alexandre * The eio and failfast fields are protected by the lock mutex. 350 5658 achartre */ 351 11004 Alexandre kthread_t *eio_thread; /* error io thread */ 352 11004 Alexandre kcondvar_t eio_cv; /* cv for eio thread update */ 353 11004 Alexandre vdc_io_t *eio_queue; /* error io queue */ 354 5658 achartre clock_t failfast_interval; /* interval in microsecs */ 355 5658 achartre 356 6099 lm66018 /* 357 6099 lm66018 * kstats used to store I/O statistics consumed by iostat(1M). 358 6099 lm66018 * These are protected by the lock mutex. 359 6099 lm66018 */ 360 6099 lm66018 kstat_t *io_stats; 361 6099 lm66018 kstat_t *err_stats; 362 6099 lm66018 363 6480 narayan ldc_dring_handle_t dring_hdl; /* dring handle */ 364 2793 lm66018 ldc_mem_info_t dring_mem_info; /* dring information */ 365 2793 lm66018 uint_t dring_curr_idx; /* current index */ 366 2793 lm66018 uint32_t dring_len; /* dring length */ 367 2793 lm66018 uint32_t dring_max_cookies; /* dring max cookies */ 368 2793 lm66018 uint32_t dring_cookie_count; /* num cookies */ 369 2793 lm66018 uint32_t dring_entry_size; /* descriptor size */ 370 2793 lm66018 ldc_mem_cookie_t *dring_cookie; /* dring cookies */ 371 2793 lm66018 uint64_t dring_ident; /* dring ident */ 372 1991 heppo 373 2793 lm66018 uint64_t threads_pending; /* num of threads */ 374 1991 heppo 375 2793 lm66018 vdc_local_desc_t *local_dring; /* local dring */ 376 2793 lm66018 vdc_local_desc_t *local_dring_backup; /* local dring backup */ 377 2793 lm66018 int local_dring_backup_tail; /* backup dring tail */ 378 2793 lm66018 int local_dring_backup_len; /* backup dring len */ 379 1991 heppo 380 6480 narayan int num_servers; /* no. of servers */ 381 6480 narayan vdc_server_t *server_list; /* vdisk server list */ 382 6480 narayan vdc_server_t *curr_server; /* curr vdisk server */ 383 1991 heppo } vdc_t; 384 5658 achartre 385 5658 achartre /* 386 5658 achartre * Ownership status flags 387 5658 achartre */ 388 5658 achartre #define VDC_OWNERSHIP_NONE 0x00 /* no ownership wanted */ 389 5658 achartre #define VDC_OWNERSHIP_WANTED 0x01 /* ownership is wanted */ 390 5658 achartre #define VDC_OWNERSHIP_GRANTED 0x02 /* ownership has been granted */ 391 5658 achartre #define VDC_OWNERSHIP_RESET 0x04 /* ownership has been reset */ 392 5658 achartre 393 5658 achartre /* 394 5658 achartre * Reservation conflict panic message 395 5658 achartre */ 396 5658 achartre #define VDC_RESV_CONFLICT_FMT_STR "Reservation Conflict\nDisk: " 397 5658 achartre #define VDC_RESV_CONFLICT_FMT_LEN (sizeof (VDC_RESV_CONFLICT_FMT_STR)) 398 1991 heppo 399 1991 heppo /* 400 1991 heppo * Debugging macros 401 1991 heppo */ 402 1991 heppo #ifdef DEBUG 403 1991 heppo extern int vdc_msglevel; 404 2793 lm66018 extern uint64_t vdc_matchinst; 405 1991 heppo 406 2793 lm66018 #define DMSG(_vdc, err_level, format, ...) \ 407 2793 lm66018 do { \ 408 2793 lm66018 if (vdc_msglevel > err_level && \ 409 2793 lm66018 (vdc_matchinst & (1ull << (_vdc)->instance))) \ 410 2793 lm66018 cmn_err(CE_CONT, "?[%d,t@%p] %s: "format, \ 411 2793 lm66018 (_vdc)->instance, (void *)curthread, \ 412 2793 lm66018 __func__, __VA_ARGS__); \ 413 2793 lm66018 _NOTE(CONSTANTCONDITION) \ 414 2793 lm66018 } while (0); 415 2793 lm66018 416 2793 lm66018 #define DMSGX(err_level, format, ...) \ 417 2410 lm66018 do { \ 418 2410 lm66018 if (vdc_msglevel > err_level) \ 419 2793 lm66018 cmn_err(CE_CONT, "?%s: "format, __func__, __VA_ARGS__);\ 420 2410 lm66018 _NOTE(CONSTANTCONDITION) \ 421 2410 lm66018 } while (0); 422 1991 heppo 423 1991 heppo #define VDC_DUMP_DRING_MSG(dmsgp) \ 424 2793 lm66018 DMSGX(0, "sq:%lu start:%d end:%d ident:%lu\n", \ 425 1991 heppo dmsgp->seq_num, dmsgp->start_idx, \ 426 1991 heppo dmsgp->end_idx, dmsgp->dring_ident); 427 1991 heppo 428 1991 heppo #else /* !DEBUG */ 429 2410 lm66018 #define DMSG(err_level, ...) 430 2793 lm66018 #define DMSGX(err_level, format, ...) 431 1991 heppo #define VDC_DUMP_DRING_MSG(dmsgp) 432 1991 heppo 433 1991 heppo #endif /* !DEBUG */ 434 1991 heppo 435 1991 heppo #ifdef __cplusplus 436 1991 heppo } 437 1991 heppo #endif 438 1991 heppo 439 1991 heppo #endif /* _VDC_H */ 440