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 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _ISER_XFER_H 27 #define _ISER_XFER_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <sys/types.h> 34 #include <sys/ib/ibtl/ibti.h> 35 #include <sys/ib/ibtl/ibtl_types.h> 36 #include <sys/iscsi_protocol.h> 37 38 /* 39 * iser_xfer.h 40 * Definitions and functions related to data transfer across the RC channel 41 * This includes the posting of the Hello Message, the HelloReply Message, the 42 * RC Send Message for the iSCSI Control PDU. 43 */ 44 45 /* 46 * iser_private_data_s contains parameters relating to the iSER connection and 47 * IB options support status. This data conforms to the 'iSER CM REQ Message 48 * Private Data Format' from the Annex A12 - Support for iSCSI Extensions for 49 * RDMA. 50 */ 51 #pragma pack(1) 52 typedef struct iser_private_data_s { 53 uint8_t ip_pvt[IBT_IP_HDR_PRIV_DATA_SZ]; 54 #if defined(_BIT_FIELDS_LTOH) 55 uint32_t rsvd1 :30, 56 sie :1, 57 zbvae :1; 58 #elif defined(_BIT_FIELDS_HTOL) 59 uint32_t zbvae :1, 60 sie :1, 61 rsvd1 :30; 62 #else 63 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 64 #endif /* _BIT_FIELDS_LTOH */ 65 uint8_t rsvd2[52]; 66 } iser_private_data_t; 67 68 /* iSER Message Opcodes */ 69 #define ISER_OPCODE_CTRL_TYPE_PDU 1 70 #define ISER_OPCODE_HELLO_MSG 2 71 #define ISER_OPCODE_HELLOREPLY_MSG 3 72 73 /* 74 * When ZBVA is not supported, both the initiator and the target shall use the 75 * expanded iSER header as defined in the IB Spec Table 540 for iSCSI control- 76 * type PDUs in the connection 77 */ 78 typedef struct iser_ctrl_hdr_s { 79 #if defined(_BIT_FIELDS_LTOH) 80 uint8_t rsvd1: 2, 81 rsv_flag: 1, /* RStag valid bit */ 82 wsv_flag: 1, /* WStag valid bit */ 83 opcode: 4; /* iSER opcode */ 84 uint8_t rsvd[3]; 85 #elif defined(_BIT_FIELDS_HTOL) 86 uint8_t opcode: 4, 87 wsv_flag: 1, 88 rsv_flag: 1, 89 rsvd1: 2; 90 uint8_t rsvd[3]; 91 #else 92 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 93 #endif /* _BIT_FIELDS_LTOH */ 94 uint32_t wstag; /* IB R-key for SCSI Write */ 95 uint64_t wva; /* IB VA for SCSI Write */ 96 uint32_t rstag; /* IB R-key for SCSI Read */ 97 uint64_t rva; /* IB VA for SCSI Read */ 98 } iser_ctrl_hdr_t; 99 100 /* iSER Header Format for the iSER Hello Message */ 101 typedef struct iser_hello_hdr_s { 102 #if defined(_BIT_FIELDS_LTOH) 103 uint8_t rsvd1 : 4, 104 opcode : 4; 105 uint8_t minver : 4, 106 maxver : 4; 107 #elif defined(_BIT_FIELDS_HTOL) 108 uint8_t opcode : 4, 109 rsvd1 : 4; 110 uint8_t maxver : 4, 111 minver : 4; 112 #else 113 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 114 #endif /* _BIT_FIELDS_LTOH */ 115 uint16_t iser_ird; 116 uint32_t rsvd2[2]; 117 } iser_hello_hdr_t; 118 119 /* iSER Header Format for the iSER HelloReply Message */ 120 typedef struct iser_helloreply_hdr_s { 121 #if defined(_BIT_FIELDS_LTOH) 122 uint8_t flag : 1, 123 rsvd1 : 3, 124 opcode : 4; 125 uint8_t curver : 4, 126 maxver : 4; 127 #elif defined(_BIT_FIELDS_HTOL) 128 uint8_t opcode : 4, 129 rsvd1 : 3, 130 flag : 1; 131 uint8_t maxver : 4, 132 curver : 4; 133 #else 134 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 135 #endif /* _BIT_FIELDS_LTOH */ 136 uint16_t iser_ord; 137 uint32_t rsvd2[2]; 138 } iser_helloreply_hdr_t; 139 #pragma pack() 140 141 struct iser_state_s; 142 143 int iser_xfer_hello_msg(iser_chan_t *chan); 144 145 int iser_xfer_helloreply_msg(iser_chan_t *chan); 146 147 int iser_xfer_ctrlpdu(iser_chan_t *chan, idm_pdu_t *pdu); 148 149 int iser_xfer_buf_to_ini(idm_task_t *idt, idm_buf_t *buf); 150 151 int iser_xfer_buf_from_ini(idm_task_t *idt, idm_buf_t *buf); 152 153 #ifdef __cplusplus 154 } 155 #endif 156 157 #endif /* _ISER_XFER_H */ 158