1fcf3ce44SJohn Forte /* 2fcf3ce44SJohn Forte * CDDL HEADER START 3fcf3ce44SJohn Forte * 4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7fcf3ce44SJohn Forte * 8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11fcf3ce44SJohn Forte * and limitations under the License. 12fcf3ce44SJohn Forte * 13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18fcf3ce44SJohn Forte * 19fcf3ce44SJohn Forte * CDDL HEADER END 20fcf3ce44SJohn Forte */ 21fcf3ce44SJohn Forte /* 223fb517f7SJames Moore * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 2309409df0SJeff Biseda * Copyright (c) 2013 by Delphix. All rights reserved. 24*61dfa509SRick McNeal * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 25fcf3ce44SJohn Forte */ 26fcf3ce44SJohn Forte #ifndef _LPIF_H 27fcf3ce44SJohn Forte #define _LPIF_H 28fcf3ce44SJohn Forte 29fcf3ce44SJohn Forte /* 30fcf3ce44SJohn Forte * Definitions for stmf LUs and lu providers. 31fcf3ce44SJohn Forte */ 32fcf3ce44SJohn Forte 33fcf3ce44SJohn Forte #include <sys/stmf_defines.h> 3445039663SJohn Forte #include <sys/stmf.h> 35fcf3ce44SJohn Forte 36fcf3ce44SJohn Forte #ifdef __cplusplus 37fcf3ce44SJohn Forte extern "C" { 38fcf3ce44SJohn Forte #endif 39fcf3ce44SJohn Forte 40fcf3ce44SJohn Forte #define LPIF_REV_1 0x00010000 4145039663SJohn Forte #define LPIF_REV_2 0x00020000 42fcf3ce44SJohn Forte 43fcf3ce44SJohn Forte typedef struct stmf_lu { 44fcf3ce44SJohn Forte void *lu_stmf_private; 45fcf3ce44SJohn Forte void *lu_provider_private; 46fcf3ce44SJohn Forte 47fcf3ce44SJohn Forte struct scsi_devid_desc *lu_id; 48fcf3ce44SJohn Forte char *lu_alias; /* optional */ 49fcf3ce44SJohn Forte struct stmf_lu_provider *lu_lp; 50fcf3ce44SJohn Forte uint32_t lu_abort_timeout; /* In seconds */ 51fcf3ce44SJohn Forte 52fcf3ce44SJohn Forte /* SAM Device Server Class */ 53fcf3ce44SJohn Forte stmf_status_t (*lu_task_alloc)(struct scsi_task *task); 54fcf3ce44SJohn Forte void (*lu_new_task)(struct scsi_task *task, 55fcf3ce44SJohn Forte struct stmf_data_buf *initial_dbuf); 56fcf3ce44SJohn Forte void (*lu_dbuf_xfer_done)(struct scsi_task *task, 57fcf3ce44SJohn Forte struct stmf_data_buf *dbuf); 58fcf3ce44SJohn Forte /* 59fcf3ce44SJohn Forte * If completion confirmation is not requested, status xfer done 60fcf3ce44SJohn Forte * is called after the transport has confirmed that status has been 61fcf3ce44SJohn Forte * sent. If completion confirmation is requested then the HBA will 62fcf3ce44SJohn Forte * request a completion confirmation from the host and upon receiving 63fcf3ce44SJohn Forte * the same, this entry point will be called. 64fcf3ce44SJohn Forte */ 65fcf3ce44SJohn Forte void (*lu_send_status_done)(struct scsi_task *task); 66fcf3ce44SJohn Forte void (*lu_task_free)(struct scsi_task *task); 67fcf3ce44SJohn Forte stmf_status_t (*lu_abort)(struct stmf_lu *lu, 68fcf3ce44SJohn Forte int abort_cmd, void *arg, uint32_t flags); 69fcf3ce44SJohn Forte void (*lu_task_poll)(struct scsi_task *task); 70fcf3ce44SJohn Forte void (*lu_ctl)(struct stmf_lu *lu, int cmd, 71fcf3ce44SJohn Forte void *arg); 72fcf3ce44SJohn Forte stmf_status_t (*lu_info)(uint32_t cmd, struct stmf_lu *lu, 73fcf3ce44SJohn Forte void *arg, uint8_t *buf, uint32_t *bufsizep); 74fcf3ce44SJohn Forte void (*lu_event_handler)(struct stmf_lu *lu, 75fcf3ce44SJohn Forte int eventid, void *arg, uint32_t flags); 7645039663SJohn Forte void *lu_proxy_reg_arg; 7745039663SJohn Forte uint32_t lu_proxy_reg_arg_len; 783fb517f7SJames Moore void (*lu_dbuf_free)(struct scsi_task *task, 793fb517f7SJames Moore struct stmf_data_buf *dbuf); 80*61dfa509SRick McNeal void (*lu_task_done)(struct scsi_task *task); 81fcf3ce44SJohn Forte } stmf_lu_t; 82fcf3ce44SJohn Forte 83fcf3ce44SJohn Forte /* 84fcf3ce44SJohn Forte * Abort cmd 85fcf3ce44SJohn Forte */ 86fcf3ce44SJohn Forte #define STMF_LU_ABORT_TASK 1 87fcf3ce44SJohn Forte #define STMF_LU_RESET_STATE 2 88fcf3ce44SJohn Forte #define STMF_LU_ITL_HANDLE_REMOVED 3 89*61dfa509SRick McNeal #define STMF_LU_SET_ABORT 4 90fcf3ce44SJohn Forte 9145039663SJohn Forte /* 9245039663SJohn Forte * Asymmetric access state 9345039663SJohn Forte */ 9445039663SJohn Forte #define STMF_LU_ACTIVE 0 9545039663SJohn Forte #define STMF_LU_STANDBY 1 9645039663SJohn Forte 9745039663SJohn Forte /* 9845039663SJohn Forte * proxy register msg types 9945039663SJohn Forte */ 10045039663SJohn Forte #define STMF_MSG_LU_REGISTER 0 10145039663SJohn Forte #define STMF_MSG_LU_ACTIVE 1 10245039663SJohn Forte #define STMF_MSG_LU_DEREGISTER 2 10345039663SJohn Forte 10445039663SJohn Forte 10545039663SJohn Forte #define STMF_PROXY_READ 1 10645039663SJohn Forte #define STMF_PROXY_WRITE 2 10745039663SJohn Forte 108fcf3ce44SJohn Forte /* 109fcf3ce44SJohn Forte * Reasons for itl handle removal. Passed in flags. 110fcf3ce44SJohn Forte */ 111fcf3ce44SJohn Forte #define STMF_ITL_REASON_MASK 0x0f 112fcf3ce44SJohn Forte #define STMF_ITL_REASON_UNKNOWN 0x0 113fcf3ce44SJohn Forte #define STMF_ITL_REASON_DEREG_REQUEST 0x1 114fcf3ce44SJohn Forte #define STMF_ITL_REASON_USER_REQUEST 0x2 115fcf3ce44SJohn Forte #define STMF_ITL_REASON_IT_NEXUS_LOSS 0x3 116fcf3ce44SJohn Forte 117fcf3ce44SJohn Forte typedef struct stmf_lu_provider { 118fcf3ce44SJohn Forte void *lp_stmf_private; 119fcf3ce44SJohn Forte void *lp_private; 120fcf3ce44SJohn Forte 12145039663SJohn Forte uint32_t lp_lpif_rev; /* Currently LPIF_REV_2 */ 122fcf3ce44SJohn Forte int lp_instance; 123fcf3ce44SJohn Forte char *lp_name; 124fcf3ce44SJohn Forte void (*lp_cb)(struct stmf_lu_provider *lp, 125fcf3ce44SJohn Forte int cmd, void *arg, uint32_t flags); 12645039663SJohn Forte uint8_t lp_alua_support; 12745039663SJohn Forte stmf_status_t (*lp_proxy_msg)(uint8_t *luid, 12845039663SJohn Forte void *proxy_reg_arg, uint32_t proxy_reg_arg_len, uint32_t type); 129fcf3ce44SJohn Forte } stmf_lu_provider_t; 130fcf3ce44SJohn Forte 131fcf3ce44SJohn Forte stmf_status_t stmf_deregister_lu_provider(stmf_lu_provider_t *lp); 132fcf3ce44SJohn Forte stmf_status_t stmf_register_lu_provider(stmf_lu_provider_t *lp); 133fcf3ce44SJohn Forte stmf_status_t stmf_register_lu(stmf_lu_t *lup); 134fcf3ce44SJohn Forte stmf_status_t stmf_deregister_lu(stmf_lu_t *lup); 13545039663SJohn Forte stmf_status_t stmf_set_lu_access(stmf_lu_t *lup, uint8_t access_state); 13645039663SJohn Forte stmf_status_t stmf_proxy_scsi_cmd(scsi_task_t *, stmf_data_buf_t *dbuf); 13745039663SJohn Forte int stmf_is_standby_port(scsi_task_t *); 138*61dfa509SRick McNeal void stmf_lu_xfer_done(struct scsi_task *task, boolean_t read, 139*61dfa509SRick McNeal hrtime_t elapsed_time); 140*61dfa509SRick McNeal boolean_t stmf_is_pgr_aptpl_always(); 141fcf3ce44SJohn Forte 142fcf3ce44SJohn Forte #ifdef __cplusplus 143fcf3ce44SJohn Forte } 144fcf3ce44SJohn Forte #endif 145fcf3ce44SJohn Forte 146fcf3ce44SJohn Forte #endif /* _LPIF_H */ 147