2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBSMP_H
2N/A#define _LIBSMP_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <sys/types.h>
2N/A#include <sys/sysmacros.h>
2N/A#include <sys/scsi/impl/usmp.h>
2N/A#include <sys/scsi/generic/smp_frames.h>
2N/A#include <libnvpair.h>
2N/A#include <stdarg.h>
2N/A
2N/A#define LIBSMP_VERSION 1
2N/A
2N/A#define SMP_TARGET_C_LONG_RESP 0x01 /* Long response (SAS-2 10.4.3.4) */
2N/A#define SMP_TARGET_C_ZONING 0x02 /* Zoning supported */
2N/A#define SMP_TARGET_C_ZG_256 0x04 /* 256 zone groups supported */
2N/A
2N/Atypedef enum smp_errno {
2N/A ESMP_NONE, /* no error */
2N/A ESMP_NOMEM, /* no memory */
2N/A ESMP_ZERO_LENGTH, /* zero-length allocation requested */
2N/A ESMP_VERSION, /* library version mismatch */
2N/A ESMP_BADTARGET, /* invalid target specification */
2N/A ESMP_BADFUNC, /* invalid SMP function */
2N/A ESMP_BADENGINE, /* engine library corrupt */
2N/A ESMP_NOENGINE, /* engine library not found */
2N/A ESMP_ENGINE_INIT, /* engine initialization failed */
2N/A ESMP_ENGINE_VER, /* engine version mismatch */
2N/A ESMP_ENGINE_BADPATH, /* engine path contains no usable components */
2N/A ESMP_BADLENGTH, /* buffer length overflow or size error */
2N/A ESMP_NEEDBUF, /* missing required buffer */
2N/A ESMP_PLUGIN, /* no plugins found */
2N/A ESMP_IO, /* I/O operation failed */
2N/A ESMP_SYS, /* system call failed */
2N/A ESMP_PERM, /* insufficient permissions */
2N/A ESMP_RANGE, /* parameter outside valid range */
2N/A ESMP_NOTSUP, /* operation not supported */
2N/A ESMP_UNKNOWN, /* error of unknown type */
2N/A ESMP_REPGEN_FAILED, /* initial report general command failed */
2N/A ESMP_MAX /* maximum libsmp errno value */
2N/A} smp_errno_t;
2N/A
2N/Atypedef struct smp_target_def {
2N/A const char *std_engine;
2N/A const void *std_def;
2N/A} smp_target_def_t;
2N/A
2N/Astruct smp_target;
2N/Atypedef struct smp_target smp_target_t;
2N/A
2N/Astruct smp_action;
2N/Atypedef struct smp_action smp_action_t;
2N/A
2N/Aextern int smp_init(int);
2N/Aextern void smp_fini(void);
2N/A
2N/Aextern smp_target_t *smp_open(const smp_target_def_t *);
2N/Aextern uint_t smp_target_getcap(const smp_target_t *);
2N/Aextern uint16_t smp_target_get_change_count(const smp_target_t *);
2N/Aextern void smp_target_set_change_count(smp_target_t *, uint16_t);
2N/Aextern uint8_t smp_target_get_number_of_phys(const smp_target_t *);
2N/Aextern uint16_t smp_target_get_exp_route_indexes(const smp_target_t *);
2N/Aextern const char *smp_target_vendor(const smp_target_t *);
2N/Aextern const char *smp_target_product(const smp_target_t *);
2N/Aextern const char *smp_target_revision(const smp_target_t *);
2N/Aextern const char *smp_target_component_vendor(const smp_target_t *);
2N/Aextern uint16_t smp_target_component_id(const smp_target_t *);
2N/Aextern uint8_t smp_target_component_revision(const smp_target_t *);
2N/Aextern void smp_target_name(const smp_target_t *, char *, size_t);
2N/Aextern uint64_t smp_target_addr(const smp_target_t *);
2N/Aextern void smp_close(smp_target_t *);
2N/A
2N/Aextern smp_errno_t smp_errno(void);
2N/Aextern smp_errno_t smp_errcode(const char *);
2N/Aextern const char *smp_errmsg(void);
2N/Aextern const char *smp_strerror(smp_errno_t);
2N/Aextern const char *smp_errname(smp_errno_t);
2N/A
2N/Aextern char *smp_trim_strdup(const char *, size_t);
2N/A
2N/Aextern smp_action_t *smp_action_alloc(smp_function_t, smp_target_t *, size_t);
2N/Aextern smp_action_t *smp_action_xalloc(smp_function_t, smp_target_t *,
2N/A void *, size_t, void *, size_t);
2N/Aextern uint32_t smp_action_get_timeout(const smp_action_t *);
2N/Aextern void smp_action_set_timeout(smp_action_t *, uint32_t);
2N/Aextern void smp_action_get_request(const smp_action_t *, void **, size_t *);
2N/Aextern void smp_action_get_response(const smp_action_t *,
2N/A smp_result_t *, void **, size_t *);
2N/Aextern int smp_exec(smp_action_t *, smp_target_t *);
2N/Aextern void smp_action_free(smp_action_t *);
2N/A
2N/Aextern nvlist_t *smp_discover(const smp_target_def_t **, size_t);
2N/Aextern nvlist_t *smp_discover_targets(smp_target_t **, size_t);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBSMP_H */