1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 #ifndef _PORTIF_H 25 #define _PORTIF_H 26 27 /* 28 * Definitions for stmf local ports and port providers. 29 */ 30 31 #include <sys/stmf_defines.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 typedef struct stmf_dbuf_store { 38 void *ds_stmf_private; 39 void *ds_port_private; 40 41 stmf_data_buf_t *(*ds_alloc_data_buf)(struct scsi_task *task, 42 uint32_t size, uint32_t *pminsize, uint32_t flags); 43 44 void (*ds_free_data_buf)( 45 struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf); 46 47 stmf_status_t (*ds_setup_dbuf)(struct scsi_task *task, 48 stmf_data_buf_t *dbuf, uint32_t flags); 49 50 void (*ds_teardown_dbuf)( 51 struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf); 52 } stmf_dbuf_store_t; 53 54 #define PORTIF_REV_1 0x00010000 55 56 typedef struct stmf_local_port { 57 void *lport_stmf_private; 58 void *lport_port_private; 59 60 uint32_t lport_abort_timeout; 61 62 struct scsi_devid_desc *lport_id; 63 char *lport_alias; 64 struct stmf_port_provider *lport_pp; 65 struct stmf_dbuf_store *lport_ds; 66 /* lport ops */ 67 stmf_status_t (*lport_xfer_data)(struct scsi_task *task, 68 struct stmf_data_buf *dbuf, uint32_t ioflags); 69 stmf_status_t (*lport_send_status)(struct scsi_task *task, 70 uint32_t ioflags); 71 void (*lport_task_free)(struct scsi_task *task); 72 stmf_status_t (*lport_abort)(struct stmf_local_port *lport, 73 int abort_cmd, void *arg, uint32_t flags); 74 void (*lport_task_poll)(struct scsi_task *task); 75 void (*lport_ctl)(struct stmf_local_port *lport, 76 int cmd, void *arg); 77 stmf_status_t (*lport_info)(uint32_t cmd, 78 struct stmf_local_port *lport, void *arg, uint8_t *buf, 79 uint32_t *bufsizep); 80 void (*lport_event_handler)( 81 struct stmf_local_port *lport, int eventid, void *arg, 82 uint32_t flags); 83 } stmf_local_port_t; 84 85 /* 86 * abort cmd 87 */ 88 #define STMF_LPORT_ABORT_TASK 0x40 89 90 typedef struct stmf_port_provider { 91 void *pp_stmf_private; 92 void *pp_provider_private; 93 94 uint32_t pp_portif_rev; /* Currently PORTIF_REV_1 */ 95 int pp_instance; 96 char *pp_name; 97 void (*pp_cb)(struct stmf_port_provider *pp, 98 int cmd, void *arg, uint32_t flags); 99 } stmf_port_provider_t; 100 101 #define STMF_SESSION_ID_NONE ((uint64_t)0) 102 103 typedef struct stmf_scsi_session { 104 void *ss_stmf_private; 105 void *ss_port_private; 106 107 struct scsi_devid_desc *ss_rport_id; 108 char *ss_rport_alias; 109 struct stmf_local_port *ss_lport; 110 uint64_t ss_session_id; 111 } stmf_scsi_session_t; 112 113 stmf_status_t stmf_register_port_provider(stmf_port_provider_t *pp); 114 stmf_status_t stmf_deregister_port_provider(stmf_port_provider_t *pp); 115 stmf_status_t stmf_register_local_port(stmf_local_port_t *lportp); 116 stmf_status_t stmf_deregister_local_port(stmf_local_port_t *lport); 117 stmf_status_t stmf_register_scsi_session(stmf_local_port_t *lport, 118 stmf_scsi_session_t *ss); 119 void stmf_deregister_scsi_session(stmf_local_port_t *lport, 120 stmf_scsi_session_t *ss); 121 void stmf_set_port_standby(stmf_local_port_t *lport, uint16_t rtpid); 122 void stmf_set_port_alua(stmf_local_port_t *lport); 123 124 #ifdef __cplusplus 125 } 126 #endif 127 128 #endif /* _PORTIF_H */ 129