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. 23fcf3ce44SJohn Forte */ 24fcf3ce44SJohn Forte #ifndef _PORTIF_H 25fcf3ce44SJohn Forte #define _PORTIF_H 26fcf3ce44SJohn Forte 27fcf3ce44SJohn Forte /* 28fcf3ce44SJohn Forte * Definitions for stmf local ports and port providers. 29fcf3ce44SJohn Forte */ 30fcf3ce44SJohn Forte 31fcf3ce44SJohn Forte #include <sys/stmf_defines.h> 32fcf3ce44SJohn Forte 33fcf3ce44SJohn Forte #ifdef __cplusplus 34fcf3ce44SJohn Forte extern "C" { 35fcf3ce44SJohn Forte #endif 36fcf3ce44SJohn Forte 37fcf3ce44SJohn Forte typedef struct stmf_dbuf_store { 38fcf3ce44SJohn Forte void *ds_stmf_private; 39fcf3ce44SJohn Forte void *ds_port_private; 40fcf3ce44SJohn Forte 41fcf3ce44SJohn Forte stmf_data_buf_t *(*ds_alloc_data_buf)(struct scsi_task *task, 42fcf3ce44SJohn Forte uint32_t size, uint32_t *pminsize, uint32_t flags); 433fb517f7SJames Moore 44fcf3ce44SJohn Forte void (*ds_free_data_buf)( 45fcf3ce44SJohn Forte struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf); 463fb517f7SJames Moore 473fb517f7SJames Moore stmf_status_t (*ds_setup_dbuf)(struct scsi_task *task, 483fb517f7SJames Moore stmf_data_buf_t *dbuf, uint32_t flags); 493fb517f7SJames Moore 503fb517f7SJames Moore void (*ds_teardown_dbuf)( 513fb517f7SJames Moore struct stmf_dbuf_store *ds, stmf_data_buf_t *dbuf); 52fcf3ce44SJohn Forte } stmf_dbuf_store_t; 53fcf3ce44SJohn Forte 54fcf3ce44SJohn Forte #define PORTIF_REV_1 0x00010000 55fcf3ce44SJohn Forte 56fcf3ce44SJohn Forte typedef struct stmf_local_port { 57fcf3ce44SJohn Forte void *lport_stmf_private; 58fcf3ce44SJohn Forte void *lport_port_private; 59fcf3ce44SJohn Forte 60fcf3ce44SJohn Forte uint32_t lport_abort_timeout; 61fcf3ce44SJohn Forte 62fcf3ce44SJohn Forte struct scsi_devid_desc *lport_id; 63fcf3ce44SJohn Forte char *lport_alias; 64fcf3ce44SJohn Forte struct stmf_port_provider *lport_pp; 65fcf3ce44SJohn Forte struct stmf_dbuf_store *lport_ds; 66fcf3ce44SJohn Forte /* lport ops */ 67fcf3ce44SJohn Forte stmf_status_t (*lport_xfer_data)(struct scsi_task *task, 68fcf3ce44SJohn Forte struct stmf_data_buf *dbuf, uint32_t ioflags); 69fcf3ce44SJohn Forte stmf_status_t (*lport_send_status)(struct scsi_task *task, 70fcf3ce44SJohn Forte uint32_t ioflags); 71fcf3ce44SJohn Forte void (*lport_task_free)(struct scsi_task *task); 72fcf3ce44SJohn Forte stmf_status_t (*lport_abort)(struct stmf_local_port *lport, 73fcf3ce44SJohn Forte int abort_cmd, void *arg, uint32_t flags); 74fcf3ce44SJohn Forte void (*lport_task_poll)(struct scsi_task *task); 75fcf3ce44SJohn Forte void (*lport_ctl)(struct stmf_local_port *lport, 76fcf3ce44SJohn Forte int cmd, void *arg); 77fcf3ce44SJohn Forte stmf_status_t (*lport_info)(uint32_t cmd, 78fcf3ce44SJohn Forte struct stmf_local_port *lport, void *arg, uint8_t *buf, 79fcf3ce44SJohn Forte uint32_t *bufsizep); 80fcf3ce44SJohn Forte void (*lport_event_handler)( 81fcf3ce44SJohn Forte struct stmf_local_port *lport, int eventid, void *arg, 82fcf3ce44SJohn Forte uint32_t flags); 83fcf3ce44SJohn Forte } stmf_local_port_t; 84fcf3ce44SJohn Forte 85*716c1805SNattuvetty Bhavyan typedef struct stmf_remote_port { 86*716c1805SNattuvetty Bhavyan struct scsi_transport_id *rport_tptid; 87*716c1805SNattuvetty Bhavyan uint16_t rport_tptid_sz; 88*716c1805SNattuvetty Bhavyan } stmf_remote_port_t; 89*716c1805SNattuvetty Bhavyan 90*716c1805SNattuvetty Bhavyan typedef struct stmf_dflt_scsi_tptid { 91*716c1805SNattuvetty Bhavyan #if defined(_BIT_FIELDS_LTOH) 92*716c1805SNattuvetty Bhavyan uint8_t protocol_id : 4, 93*716c1805SNattuvetty Bhavyan resbits : 2, 94*716c1805SNattuvetty Bhavyan format_code : 2; 95*716c1805SNattuvetty Bhavyan #elif defined(_BIT_FIELDS_HTOL) 96*716c1805SNattuvetty Bhavyan uint8_t format_code : 2, 97*716c1805SNattuvetty Bhavyan resbits : 2, 98*716c1805SNattuvetty Bhavyan protocol_id : 4; 99*716c1805SNattuvetty Bhavyan #else 100*716c1805SNattuvetty Bhavyan #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 101*716c1805SNattuvetty Bhavyan #endif /* _BIT_FIELDS_LTOH */ 102*716c1805SNattuvetty Bhavyan uint8_t rsvbyte1; 103*716c1805SNattuvetty Bhavyan uint8_t ident_len[2]; 104*716c1805SNattuvetty Bhavyan char ident[1]; 105*716c1805SNattuvetty Bhavyan } stmf_dflt_scsi_tptid_t; 106fcf3ce44SJohn Forte /* 107fcf3ce44SJohn Forte * abort cmd 108fcf3ce44SJohn Forte */ 109fcf3ce44SJohn Forte #define STMF_LPORT_ABORT_TASK 0x40 110fcf3ce44SJohn Forte 111fcf3ce44SJohn Forte typedef struct stmf_port_provider { 112fcf3ce44SJohn Forte void *pp_stmf_private; 113fcf3ce44SJohn Forte void *pp_provider_private; 114fcf3ce44SJohn Forte 115fcf3ce44SJohn Forte uint32_t pp_portif_rev; /* Currently PORTIF_REV_1 */ 116fcf3ce44SJohn Forte int pp_instance; 117fcf3ce44SJohn Forte char *pp_name; 118fcf3ce44SJohn Forte void (*pp_cb)(struct stmf_port_provider *pp, 119fcf3ce44SJohn Forte int cmd, void *arg, uint32_t flags); 120fcf3ce44SJohn Forte } stmf_port_provider_t; 121fcf3ce44SJohn Forte 122fcf3ce44SJohn Forte #define STMF_SESSION_ID_NONE ((uint64_t)0) 123fcf3ce44SJohn Forte 124fcf3ce44SJohn Forte typedef struct stmf_scsi_session { 125fcf3ce44SJohn Forte void *ss_stmf_private; 126fcf3ce44SJohn Forte void *ss_port_private; 127fcf3ce44SJohn Forte 128fcf3ce44SJohn Forte struct scsi_devid_desc *ss_rport_id; 129fcf3ce44SJohn Forte char *ss_rport_alias; 130fcf3ce44SJohn Forte struct stmf_local_port *ss_lport; 131fcf3ce44SJohn Forte uint64_t ss_session_id; 132*716c1805SNattuvetty Bhavyan struct stmf_remote_port *ss_rport; 133fcf3ce44SJohn Forte } stmf_scsi_session_t; 134fcf3ce44SJohn Forte 135fcf3ce44SJohn Forte stmf_status_t stmf_register_port_provider(stmf_port_provider_t *pp); 136fcf3ce44SJohn Forte stmf_status_t stmf_deregister_port_provider(stmf_port_provider_t *pp); 137fcf3ce44SJohn Forte stmf_status_t stmf_register_local_port(stmf_local_port_t *lportp); 138fcf3ce44SJohn Forte stmf_status_t stmf_deregister_local_port(stmf_local_port_t *lport); 139fcf3ce44SJohn Forte stmf_status_t stmf_register_scsi_session(stmf_local_port_t *lport, 140fcf3ce44SJohn Forte stmf_scsi_session_t *ss); 141fcf3ce44SJohn Forte void stmf_deregister_scsi_session(stmf_local_port_t *lport, 142fcf3ce44SJohn Forte stmf_scsi_session_t *ss); 14345039663SJohn Forte void stmf_set_port_standby(stmf_local_port_t *lport, uint16_t rtpid); 144cd36db67SJohn Forte void stmf_set_port_alua(stmf_local_port_t *lport); 145fcf3ce44SJohn Forte 146fcf3ce44SJohn Forte #ifdef __cplusplus 147fcf3ce44SJohn Forte } 148fcf3ce44SJohn Forte #endif 149fcf3ce44SJohn Forte 150fcf3ce44SJohn Forte #endif /* _PORTIF_H */ 151