1ac88567aSHyon Kim /* 2ac88567aSHyon Kim * CDDL HEADER START 3ac88567aSHyon Kim * 4ac88567aSHyon Kim * The contents of this file are subject to the terms of the 5ac88567aSHyon Kim * Common Development and Distribution License (the "License"). 6ac88567aSHyon Kim * You may not use this file except in compliance with the License. 7ac88567aSHyon Kim * 8ac88567aSHyon Kim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9ac88567aSHyon Kim * or http://www.opensolaris.org/os/licensing. 10ac88567aSHyon Kim * See the License for the specific language governing permissions 11ac88567aSHyon Kim * and limitations under the License. 12ac88567aSHyon Kim * 13ac88567aSHyon Kim * When distributing Covered Code, include this CDDL HEADER in each 14ac88567aSHyon Kim * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15ac88567aSHyon Kim * If applicable, add the following below this CDDL HEADER, with the 16ac88567aSHyon Kim * fields enclosed by brackets "[]" replaced with your own identifying 17ac88567aSHyon Kim * information: Portions Copyright [yyyy] [name of copyright owner] 18ac88567aSHyon Kim * 19ac88567aSHyon Kim * CDDL HEADER END 20ac88567aSHyon Kim */ 21ac88567aSHyon Kim 22ac88567aSHyon Kim /* 23ac88567aSHyon Kim * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24ac88567aSHyon Kim */ 25ac88567aSHyon Kim 26ac88567aSHyon Kim #ifndef _LIBSMP_H 27ac88567aSHyon Kim #define _LIBSMP_H 28ac88567aSHyon Kim 29ac88567aSHyon Kim #ifdef __cplusplus 30ac88567aSHyon Kim extern "C" { 31ac88567aSHyon Kim #endif 32ac88567aSHyon Kim 33ac88567aSHyon Kim #include <sys/types.h> 34ac88567aSHyon Kim #include <sys/sysmacros.h> 35ac88567aSHyon Kim #include <sys/scsi/impl/usmp.h> 36ac88567aSHyon Kim #include <sys/scsi/generic/smp_frames.h> 37ac88567aSHyon Kim #include <libnvpair.h> 38ac88567aSHyon Kim #include <stdarg.h> 39ac88567aSHyon Kim 40ac88567aSHyon Kim #define LIBSMP_VERSION 1 41ac88567aSHyon Kim 42ac88567aSHyon Kim #define SMP_TARGET_C_LONG_RESP 0x01 /* Long response (SAS-2 10.4.3.4) */ 43ac88567aSHyon Kim #define SMP_TARGET_C_ZONING 0x02 /* Zoning supported */ 44ac88567aSHyon Kim #define SMP_TARGET_C_ZG_256 0x04 /* 256 zone groups supported */ 45ac88567aSHyon Kim 46ac88567aSHyon Kim typedef enum smp_errno { 47ac88567aSHyon Kim ESMP_NONE, /* no error */ 48ac88567aSHyon Kim ESMP_NOMEM, /* no memory */ 49ac88567aSHyon Kim ESMP_ZERO_LENGTH, /* zero-length allocation requested */ 50ac88567aSHyon Kim ESMP_VERSION, /* library version mismatch */ 51ac88567aSHyon Kim ESMP_BADTARGET, /* invalid target specification */ 52ac88567aSHyon Kim ESMP_BADFUNC, /* invalid SMP function */ 53ac88567aSHyon Kim ESMP_BADENGINE, /* engine library corrupt */ 54ac88567aSHyon Kim ESMP_NOENGINE, /* engine library not found */ 55ac88567aSHyon Kim ESMP_ENGINE_INIT, /* engine initialization failed */ 56ac88567aSHyon Kim ESMP_ENGINE_VER, /* engine version mismatch */ 57ac88567aSHyon Kim ESMP_ENGINE_BADPATH, /* engine path contains no usable components */ 58ac88567aSHyon Kim ESMP_BADLENGTH, /* buffer length overflow or size error */ 59ac88567aSHyon Kim ESMP_NEEDBUF, /* missing required buffer */ 60ac88567aSHyon Kim ESMP_PLUGIN, /* no plugins found */ 61ac88567aSHyon Kim ESMP_IO, /* I/O operation failed */ 62ac88567aSHyon Kim ESMP_SYS, /* system call failed */ 63ac88567aSHyon Kim ESMP_PERM, /* insufficient permissions */ 64ac88567aSHyon Kim ESMP_RANGE, /* parameter outside valid range */ 65ac88567aSHyon Kim ESMP_NOTSUP, /* operation not supported */ 66ac88567aSHyon Kim ESMP_UNKNOWN, /* error of unknown type */ 67ac88567aSHyon Kim ESMP_REPGEN_FAILED, /* initial report general command failed */ 68ac88567aSHyon Kim ESMP_MAX /* maximum libsmp errno value */ 69ac88567aSHyon Kim } smp_errno_t; 70ac88567aSHyon Kim 71ac88567aSHyon Kim typedef struct smp_target_def { 72ac88567aSHyon Kim const char *std_engine; 73ac88567aSHyon Kim const void *std_def; 74ac88567aSHyon Kim } smp_target_def_t; 75ac88567aSHyon Kim 76ac88567aSHyon Kim struct smp_target; 77ac88567aSHyon Kim typedef struct smp_target smp_target_t; 78ac88567aSHyon Kim 79ac88567aSHyon Kim struct smp_action; 80ac88567aSHyon Kim typedef struct smp_action smp_action_t; 81ac88567aSHyon Kim 82ac88567aSHyon Kim extern int smp_init(int); 83ac88567aSHyon Kim extern void smp_fini(void); 84ac88567aSHyon Kim 85ac88567aSHyon Kim extern smp_target_t *smp_open(const smp_target_def_t *); 86ac88567aSHyon Kim extern uint_t smp_target_getcap(const smp_target_t *); 87ac88567aSHyon Kim extern uint16_t smp_target_get_change_count(const smp_target_t *); 88ac88567aSHyon Kim extern void smp_target_set_change_count(smp_target_t *, uint16_t); 89*d0698e0dSDavid Hollister extern uint8_t smp_target_get_number_of_phys(const smp_target_t *); 90*d0698e0dSDavid Hollister extern uint16_t smp_target_get_exp_route_indexes(const smp_target_t *); 91ac88567aSHyon Kim extern const char *smp_target_vendor(const smp_target_t *); 92ac88567aSHyon Kim extern const char *smp_target_product(const smp_target_t *); 93ac88567aSHyon Kim extern const char *smp_target_revision(const smp_target_t *); 94ac88567aSHyon Kim extern const char *smp_target_component_vendor(const smp_target_t *); 95ac88567aSHyon Kim extern uint16_t smp_target_component_id(const smp_target_t *); 96ac88567aSHyon Kim extern uint8_t smp_target_component_revision(const smp_target_t *); 97ac88567aSHyon Kim extern void smp_target_name(const smp_target_t *, char *, size_t); 98ac88567aSHyon Kim extern uint64_t smp_target_addr(const smp_target_t *); 99ac88567aSHyon Kim extern void smp_close(smp_target_t *); 100ac88567aSHyon Kim 101ac88567aSHyon Kim extern smp_errno_t smp_errno(void); 102ac88567aSHyon Kim extern smp_errno_t smp_errcode(const char *); 103ac88567aSHyon Kim extern const char *smp_errmsg(void); 104ac88567aSHyon Kim extern const char *smp_strerror(smp_errno_t); 105ac88567aSHyon Kim extern const char *smp_errname(smp_errno_t); 106ac88567aSHyon Kim 107ac88567aSHyon Kim extern char *smp_trim_strdup(const char *, size_t); 108ac88567aSHyon Kim 109ac88567aSHyon Kim extern smp_action_t *smp_action_alloc(smp_function_t, smp_target_t *, size_t); 110ac88567aSHyon Kim extern smp_action_t *smp_action_xalloc(smp_function_t, smp_target_t *, 111ac88567aSHyon Kim void *, size_t, void *, size_t); 112ac88567aSHyon Kim extern uint32_t smp_action_get_timeout(const smp_action_t *); 113ac88567aSHyon Kim extern void smp_action_set_timeout(smp_action_t *, uint32_t); 114ac88567aSHyon Kim extern void smp_action_get_request(const smp_action_t *, void **, size_t *); 115ac88567aSHyon Kim extern void smp_action_get_response(const smp_action_t *, 116ac88567aSHyon Kim smp_result_t *, void **, size_t *); 117ac88567aSHyon Kim extern int smp_exec(smp_action_t *, smp_target_t *); 118ac88567aSHyon Kim extern void smp_action_free(smp_action_t *); 119ac88567aSHyon Kim 120ac88567aSHyon Kim extern nvlist_t *smp_discover(const smp_target_def_t **, size_t); 121ac88567aSHyon Kim extern nvlist_t *smp_discover_targets(smp_target_t **, size_t); 122ac88567aSHyon Kim 123ac88567aSHyon Kim #ifdef __cplusplus 124ac88567aSHyon Kim } 125ac88567aSHyon Kim #endif 126ac88567aSHyon Kim 127ac88567aSHyon Kim #endif /* _LIBSMP_H */ 128