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 src/sun_nws/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 src/sun_nws/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 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _IDM_TRANSPORT_H_
  28 #define _IDM_TRANSPORT_H_
  29 
  30 #pragma ident   "@(#)idm_transport.h    1.1     08/03/26 SMI"
  31 
  32 #ifdef  __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 #include <sys/nvpair.h>
  37 
  38 #define IDM_TRANSPORT_PATHLEN   0x40
  39 
  40 /*
  41  * idm_transport_type_t
  42  * An enumerated list of the transports available to iSER.
  43  * Note that new transports should be added to the enum prior to NUM_TYPES.
  44  */
  45 typedef enum {
  46         IDM_TRANSPORT_TYPE_ISER = 0,
  47         IDM_TRANSPORT_TYPE_SOCKETS,
  48         IDM_TRANSPORT_NUM_TYPES
  49 } idm_transport_type_t;
  50 
  51 /*
  52  * idm_transport_caps_t
  53  * Encodes a set of attributes describing an IDM transport's capabilities.
  54  *      JB - do we need this?
  55  */
  56 typedef struct idm_transport_caps_s {
  57         uint32_t        flags;
  58 } idm_transport_caps_t;
  59 
  60 /*
  61  * Transport routine definitions for idm_transport_ops_t below
  62  */
  63 
  64 /* Send_Control - transmit a Control-type PDU */
  65 typedef void (transport_tx_op_t)(struct idm_conn_s *ic, struct idm_pdu_s *pdu);
  66 
  67 /* Target transport data primitives */
  68 typedef idm_status_t (transport_buf_tx_to_ini_op_t)(struct idm_task_s *idt,
  69     struct idm_buf_s *idb);
  70 typedef idm_status_t (transport_buf_rx_from_ini_op_t)(struct idm_task_s *idt,
  71     struct idm_buf_s *idb);
  72 
  73 /* Initiator transport data handlers */
  74 typedef void (transport_rx_datain_op_t)(struct idm_conn_s *ic,
  75     struct idm_pdu_s *pdu);
  76 typedef void (transport_rx_rtt_op_t)(struct idm_conn_s *ic,
  77     struct idm_pdu_s *pdu);
  78 
  79 /* Target transport Data-out handler */
  80 typedef void (transport_rx_dataout_op_t)(struct idm_conn_s *ic,
  81     struct idm_pdu_s *pdu);
  82 
  83 /* Transport-specific resource allocation and free */
  84 typedef idm_status_t (transport_alloc_conn_rsrc_op_t)(struct idm_conn_s *ic);
  85 typedef idm_status_t (transport_free_conn_rsrc_op_t)(struct idm_conn_s *ic);
  86 
  87 /* Transport driver operations enable/disable */
  88 typedef idm_status_t (transport_enable_datamover_op_t)(struct idm_conn_s *ic);
  89 typedef idm_status_t (transport_conn_terminate_op_t)(struct idm_conn_s *ic);
  90 
  91 /* Task resource cleanup */
  92 typedef idm_status_t (transport_free_task_rsrcs_op_t)(struct idm_task_s *it);
  93 
  94 /* Validate and use negotiated key value pairs */
  95 typedef idm_status_t (transport_notice_key_values_op_t)(struct idm_conn_s *ic,
  96     nvlist_t *request_nvl, nvlist_t *response_nvl, nvlist_t *negotiated_nvl);
  97 
  98 /* Transport capability probe */
  99 typedef idm_status_t (transport_conn_is_capable_op_t)(idm_conn_req_t *ic,
 100     struct idm_transport_caps_s *caps);
 101 
 102 /* Transport buffer services */
 103 typedef idm_status_t (transport_buf_setup_op_t)(struct idm_buf_s *idb);
 104 typedef void (transport_buf_teardown_op_t)(struct idm_buf_s *idb);
 105 
 106 /* Transport target context and service management services */
 107 typedef idm_status_t (transport_tgt_svc_create_op_t)(idm_svc_req_t *sr,
 108     struct idm_svc_s *is);
 109 typedef void (transport_tgt_svc_destroy_op_t)(struct idm_svc_s *is);
 110 typedef idm_status_t (transport_tgt_svc_online_op_t)(struct idm_svc_s *is);
 111 typedef void (transport_tgt_svc_offline_op_t)(struct idm_svc_s *is);
 112 
 113 /* Transport target connection establishment */
 114 typedef idm_status_t (transport_tgt_conn_connect_op_t)(struct idm_conn_s *ic);
 115 
 116 /* Transport initiator context and connection management services */
 117 typedef idm_status_t (transport_ini_conn_create_op_t)(idm_conn_req_t *cr,
 118     struct idm_conn_s *ic);
 119 typedef void (transport_ini_conn_destroy_op_t)(struct idm_conn_s *ic);
 120 typedef idm_status_t (transport_ini_conn_connect_op_t)(struct idm_conn_s *ic);
 121 typedef void (transport_ini_conn_disconnect_op_t)(struct idm_conn_s *ic);
 122 
 123 
 124 /*
 125  * idm_transport_ops_t
 126  * Encodes a set of vectors into an IDM transport driver that implement the
 127  * transport-specific Datamover operations for IDM usage. These routines are
 128  * invoked by the IDM layer to execute the transport-specific implementations
 129  * of the DataMover primitives and supporting routines.
 130  */
 131 typedef struct idm_transport_ops_s {
 132         transport_tx_op_t                       *it_tx_pdu;
 133         transport_buf_tx_to_ini_op_t            *it_buf_tx_to_ini;
 134         transport_buf_rx_from_ini_op_t          *it_buf_rx_from_ini;
 135         transport_rx_datain_op_t                *it_rx_datain;
 136         transport_rx_rtt_op_t                   *it_rx_rtt;
 137         transport_rx_dataout_op_t               *it_rx_dataout;
 138         transport_alloc_conn_rsrc_op_t          *it_alloc_conn_rsrc;
 139         transport_free_conn_rsrc_op_t           *it_free_conn_rsrc;
 140         transport_enable_datamover_op_t         *it_enable_datamover;
 141         transport_conn_terminate_op_t           *it_conn_terminate;
 142         transport_free_task_rsrcs_op_t          *it_free_task_rsrc;
 143         transport_notice_key_values_op_t        *it_notice_key_values;
 144         transport_conn_is_capable_op_t          *it_conn_is_capable;
 145         transport_buf_setup_op_t                *it_buf_setup;
 146         transport_buf_teardown_op_t             *it_buf_teardown;
 147         transport_tgt_svc_create_op_t           *it_tgt_svc_create;
 148         transport_tgt_svc_destroy_op_t          *it_tgt_svc_destroy;
 149         transport_tgt_svc_online_op_t           *it_tgt_svc_online;
 150         transport_tgt_svc_offline_op_t          *it_tgt_svc_offline;
 151         transport_tgt_conn_connect_op_t         *it_tgt_conn_connect;
 152         transport_ini_conn_create_op_t          *it_ini_conn_create;
 153         transport_ini_conn_destroy_op_t         *it_ini_conn_destroy;
 154         transport_ini_conn_connect_op_t         *it_ini_conn_connect;
 155         transport_ini_conn_disconnect_op_t      *it_ini_conn_disconnect;
 156 } idm_transport_ops_t;
 157 
 158 /*
 159  * idm_transport_t encodes all of the data related to an IDM transport
 160  * type. In addition to type and capabilities, it also stores a pointer
 161  * to the connection and transport operation implementations, and also
 162  * it stores the LDI handle.
 163  */
 164 typedef struct idm_transport_s {
 165         idm_transport_type_t    type;
 166         char                    device_path[IDM_TRANSPORT_PATHLEN];
 167         ldi_handle_t            ldi_hdl;
 168         idm_transport_ops_t     *it_ops;
 169         idm_transport_caps_t    *it_caps;
 170 } idm_transport_t;
 171 
 172 #ifdef  __cplusplus
 173 }
 174 #endif
 175 
 176 #endif /* _IDM_TRANSPORT_H_ */