Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
0003  *
0004  * This software is available to you under a choice of one of two
0005  * licenses.  You may choose to be licensed under the terms of the GNU
0006  * General Public License (GPL) Version 2, available from the file
0007  * COPYING in the main directory of this source tree, or the
0008  * OpenIB.org BSD license below:
0009  *
0010  *     Redistribution and use in source and binary forms, with or
0011  *     without modification, are permitted provided that the following
0012  *     conditions are met:
0013  *
0014  *      - Redistributions of source code must retain the above
0015  *        copyright notice, this list of conditions and the following
0016  *        disclaimer.
0017  *
0018  *      - Redistributions in binary form must reproduce the above
0019  *        copyright notice, this list of conditions and the following
0020  *        disclaimer in the documentation and/or other materials
0021  *        provided with the distribution.
0022  *
0023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0024  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0025  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0026  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0027  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0028  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0029  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0030  * SOFTWARE.
0031  *
0032  * $Id$
0033  */
0034 
0035 #ifndef SCSI_SRP_H
0036 #define SCSI_SRP_H
0037 
0038 /*
0039  * Structures and constants for the SCSI RDMA Protocol (SRP) as
0040  * defined by the INCITS T10 committee.  This file was written using
0041  * draft Revision 16a of the SRP standard.
0042  */
0043 
0044 #include <linux/types.h>
0045 #include <scsi/scsi.h>
0046 
0047 enum {
0048     SRP_LOGIN_REQ   = 0x00,
0049     SRP_TSK_MGMT    = 0x01,
0050     SRP_CMD     = 0x02,
0051     SRP_I_LOGOUT    = 0x03,
0052     SRP_LOGIN_RSP   = 0xc0,
0053     SRP_RSP     = 0xc1,
0054     SRP_LOGIN_REJ   = 0xc2,
0055     SRP_T_LOGOUT    = 0x80,
0056     SRP_CRED_REQ    = 0x81,
0057     SRP_AER_REQ = 0x82,
0058     SRP_CRED_RSP    = 0x41,
0059     SRP_AER_RSP = 0x42
0060 };
0061 
0062 enum {
0063     SRP_BUF_FORMAT_DIRECT   = 1 << 1,
0064     SRP_BUF_FORMAT_INDIRECT = 1 << 2
0065 };
0066 
0067 enum {
0068     SRP_NO_DATA_DESC    = 0,
0069     SRP_DATA_DESC_DIRECT    = 1,
0070     SRP_DATA_DESC_INDIRECT  = 2,
0071     SRP_DATA_DESC_IMM   = 3,    /* new in SRP2 */
0072 };
0073 
0074 enum {
0075     SRP_TSK_ABORT_TASK  = 0x01,
0076     SRP_TSK_ABORT_TASK_SET  = 0x02,
0077     SRP_TSK_CLEAR_TASK_SET  = 0x04,
0078     SRP_TSK_LUN_RESET   = 0x08,
0079     SRP_TSK_CLEAR_ACA   = 0x40
0080 };
0081 
0082 enum srp_login_rej_reason {
0083     SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL      = 0x00010000,
0084     SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES        = 0x00010001,
0085     SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE    = 0x00010002,
0086     SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL      = 0x00010003,
0087     SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT    = 0x00010004,
0088     SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED     = 0x00010005,
0089     SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED     = 0x00010006
0090 };
0091 
0092 enum {
0093     SRP_REV10_IB_IO_CLASS   = 0xff00,
0094     SRP_REV16A_IB_IO_CLASS  = 0x0100
0095 };
0096 
0097 struct srp_direct_buf {
0098     __be64  va;
0099     __be32  key;
0100     __be32  len;
0101 };
0102 
0103 /*
0104  * We need the packed attribute because the SRP spec puts the list of
0105  * descriptors at an offset of 20, which is not aligned to the size of
0106  * struct srp_direct_buf.  The whole structure must be packed to avoid
0107  * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
0108  */
0109 struct srp_indirect_buf {
0110     struct srp_direct_buf   table_desc __packed __aligned(4);
0111     __be32          len;
0112     struct srp_direct_buf   desc_list[] __packed __aligned(4);
0113 };
0114 
0115 /* Immediate data buffer descriptor as defined in SRP2. */
0116 struct srp_imm_buf {
0117     __be32  len;
0118 };
0119 
0120 /* srp_login_req.flags */
0121 enum {
0122     SRP_MULTICHAN_SINGLE = 0,
0123     SRP_MULTICHAN_MULTI  = 1,
0124     SRP_IMMED_REQUESTED  = 0x80,    /* new in SRP2 */
0125 };
0126 
0127 struct srp_login_req {
0128     u8  opcode;
0129     u8  reserved1[7];
0130     u64 tag;
0131     __be32  req_it_iu_len;
0132     u8  reserved2[4];
0133     __be16  req_buf_fmt;
0134     u8  req_flags;
0135     u8  reserved3[1];
0136     __be16  imm_data_offset;    /* new in SRP2 */
0137     u8  reserved4[2];
0138     u8  initiator_port_id[16];
0139     u8  target_port_id[16];
0140 };
0141 
0142 /**
0143  * struct srp_login_req_rdma - RDMA/CM login parameters.
0144  *
0145  * RDMA/CM over InfiniBand can only carry 92 - 36 = 56 bytes of private
0146  * data. The %srp_login_req_rdma structure contains the same information as
0147  * %srp_login_req but with the reserved data removed.
0148  */
0149 struct srp_login_req_rdma {
0150     u64 tag;
0151     __be16  req_buf_fmt;
0152     u8  req_flags;
0153     u8  opcode;
0154     __be32  req_it_iu_len;
0155     u8  initiator_port_id[16];
0156     u8  target_port_id[16];
0157     __be16  imm_data_offset;
0158     u8  reserved[6];
0159 };
0160 
0161 /* srp_login_rsp.rsp_flags */
0162 enum {
0163     SRP_LOGIN_RSP_MULTICHAN_NO_CHAN    = 0x0,
0164     SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1,
0165     SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2,
0166     SRP_LOGIN_RSP_IMMED_SUPP       = 0x80, /* new in SRP2 */
0167 };
0168 
0169 /*
0170  * The SRP spec defines the size of the LOGIN_RSP structure to be 52
0171  * bytes, so it needs to be packed to avoid having it padded to 56
0172  * bytes on 64-bit architectures.
0173  */
0174 struct srp_login_rsp {
0175     u8  opcode;
0176     u8  reserved1[3];
0177     __be32  req_lim_delta;
0178     u64 tag __packed __aligned(4);
0179     __be32  max_it_iu_len;
0180     __be32  max_ti_iu_len;
0181     __be16  buf_fmt;
0182     u8  rsp_flags;
0183     u8  reserved2[25];
0184 };
0185 
0186 struct srp_login_rej {
0187     u8  opcode;
0188     u8  reserved1[3];
0189     __be32  reason;
0190     u64 tag;
0191     u8  reserved2[8];
0192     __be16  buf_fmt;
0193     u8  reserved3[6];
0194 };
0195 
0196 struct srp_i_logout {
0197     u8  opcode;
0198     u8  reserved[7];
0199     u64 tag;
0200 };
0201 
0202 struct srp_t_logout {
0203     u8  opcode;
0204     u8  sol_not;
0205     u8  reserved[2];
0206     __be32  reason;
0207     u64 tag;
0208 };
0209 
0210 struct srp_tsk_mgmt {
0211     u8  opcode;
0212     u8  sol_not;
0213     u8  reserved1[6];
0214     u64 tag;
0215     u8  reserved2[4];
0216     struct scsi_lun lun;
0217     u8  reserved3[2];
0218     u8  tsk_mgmt_func;
0219     u8  reserved4;
0220     u64 task_tag;
0221     u8  reserved5[8];
0222 };
0223 
0224 struct srp_cmd {
0225     u8  opcode;
0226     u8  sol_not;
0227     u8  reserved1[3];
0228     u8  buf_fmt;
0229     u8  data_out_desc_cnt;
0230     u8  data_in_desc_cnt;
0231     u64 tag;
0232     u8  reserved2[4];
0233     struct scsi_lun lun;
0234     u8  reserved3;
0235     u8  task_attr;
0236     u8  reserved4;
0237     u8  add_cdb_len;
0238     u8  cdb[16];
0239     u8  add_data[];
0240 };
0241 
0242 enum {
0243     SRP_RSP_FLAG_RSPVALID = 1 << 0,
0244     SRP_RSP_FLAG_SNSVALID = 1 << 1,
0245     SRP_RSP_FLAG_DOOVER   = 1 << 2,
0246     SRP_RSP_FLAG_DOUNDER  = 1 << 3,
0247     SRP_RSP_FLAG_DIOVER   = 1 << 4,
0248     SRP_RSP_FLAG_DIUNDER  = 1 << 5
0249 };
0250 
0251 /*
0252  * The SRP spec defines the size of the RSP structure to be 36 bytes,
0253  * so it needs to be packed to avoid having it padded to 40 bytes on
0254  * 64-bit architectures.
0255  */
0256 struct srp_rsp {
0257     u8  opcode;
0258     u8  sol_not;
0259     u8  reserved1[2];
0260     __be32  req_lim_delta;
0261     u64 tag __packed __aligned(4);
0262     u8  reserved2[2];
0263     u8  flags;
0264     u8  status;
0265     __be32  data_out_res_cnt;
0266     __be32  data_in_res_cnt;
0267     __be32  sense_data_len;
0268     __be32  resp_data_len;
0269     u8  data[];
0270 };
0271 
0272 struct srp_cred_req {
0273     u8  opcode;
0274     u8  sol_not;
0275     u8  reserved[2];
0276     __be32  req_lim_delta;
0277     u64 tag;
0278 };
0279 
0280 struct srp_cred_rsp {
0281     u8  opcode;
0282     u8  reserved[7];
0283     u64 tag;
0284 };
0285 
0286 /*
0287  * The SRP spec defines the fixed portion of the AER_REQ structure to be
0288  * 36 bytes, so it needs to be packed to avoid having it padded to 40 bytes
0289  * on 64-bit architectures.
0290  */
0291 struct srp_aer_req {
0292     u8  opcode;
0293     u8  sol_not;
0294     u8  reserved[2];
0295     __be32  req_lim_delta;
0296     u64 tag __packed __aligned(4);
0297     u32 reserved2;
0298     struct scsi_lun lun;
0299     __be32  sense_data_len;
0300     u32 reserved3;
0301     u8  sense_data[];
0302 };
0303 
0304 struct srp_aer_rsp {
0305     u8  opcode;
0306     u8  reserved[7];
0307     u64 tag;
0308 };
0309 
0310 #endif /* SCSI_SRP_H */