/*1* Copyright (c) 2005 Cisco Systems. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*31* $Id$32*/3334#ifndef SCSI_SRP_H35#define SCSI_SRP_H3637/*38* Structures and constants for the SCSI RDMA Protocol (SRP) as39* defined by the INCITS T10 committee. This file was written using40* draft Revision 16a of the SRP standard.41*/4243#include <linux/types.h>44#include <scsi/scsi.h>4546enum {47SRP_LOGIN_REQ = 0x00,48SRP_TSK_MGMT = 0x01,49SRP_CMD = 0x02,50SRP_I_LOGOUT = 0x03,51SRP_LOGIN_RSP = 0xc0,52SRP_RSP = 0xc1,53SRP_LOGIN_REJ = 0xc2,54SRP_T_LOGOUT = 0x80,55SRP_CRED_REQ = 0x81,56SRP_AER_REQ = 0x82,57SRP_CRED_RSP = 0x41,58SRP_AER_RSP = 0x4259};6061enum {62SRP_BUF_FORMAT_DIRECT = 1 << 1,63SRP_BUF_FORMAT_INDIRECT = 1 << 264};6566enum {67SRP_NO_DATA_DESC = 0,68SRP_DATA_DESC_DIRECT = 1,69SRP_DATA_DESC_INDIRECT = 2,70SRP_DATA_DESC_IMM = 3, /* new in SRP2 */71};7273enum {74SRP_TSK_ABORT_TASK = 0x01,75SRP_TSK_ABORT_TASK_SET = 0x02,76SRP_TSK_CLEAR_TASK_SET = 0x04,77SRP_TSK_LUN_RESET = 0x08,78SRP_TSK_CLEAR_ACA = 0x4079};8081enum srp_login_rej_reason {82SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,83SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,84SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,85SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,86SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,87SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,88SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x0001000689};9091enum {92SRP_REV10_IB_IO_CLASS = 0xff00,93SRP_REV16A_IB_IO_CLASS = 0x010094};9596struct srp_direct_buf {97__be64 va;98__be32 key;99__be32 len;100};101102/*103* We need the packed attribute because the SRP spec puts the list of104* descriptors at an offset of 20, which is not aligned to the size of105* struct srp_direct_buf. The whole structure must be packed to avoid106* having the 20-byte structure padded to 24 bytes on 64-bit architectures.107*/108struct srp_indirect_buf {109struct srp_direct_buf table_desc __packed __aligned(4);110__be32 len;111struct srp_direct_buf desc_list[] __packed __aligned(4);112};113114/* Immediate data buffer descriptor as defined in SRP2. */115struct srp_imm_buf {116__be32 len;117};118119/* srp_login_req.flags */120enum {121SRP_MULTICHAN_SINGLE = 0,122SRP_MULTICHAN_MULTI = 1,123SRP_IMMED_REQUESTED = 0x80, /* new in SRP2 */124};125126struct srp_login_req {127u8 opcode;128u8 reserved1[7];129u64 tag;130__be32 req_it_iu_len;131u8 reserved2[4];132__be16 req_buf_fmt;133u8 req_flags;134u8 reserved3[1];135__be16 imm_data_offset; /* new in SRP2 */136u8 reserved4[2];137u8 initiator_port_id[16];138u8 target_port_id[16];139};140141/**142* struct srp_login_req_rdma - RDMA/CM login parameters.143*144* RDMA/CM over InfiniBand can only carry 92 - 36 = 56 bytes of private145* data. The %srp_login_req_rdma structure contains the same information as146* %srp_login_req but with the reserved data removed.147*/148struct srp_login_req_rdma {149u64 tag;150__be16 req_buf_fmt;151u8 req_flags;152u8 opcode;153__be32 req_it_iu_len;154u8 initiator_port_id[16];155u8 target_port_id[16];156__be16 imm_data_offset;157u8 reserved[6];158};159160/* srp_login_rsp.rsp_flags */161enum {162SRP_LOGIN_RSP_MULTICHAN_NO_CHAN = 0x0,163SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1,164SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2,165SRP_LOGIN_RSP_IMMED_SUPP = 0x80, /* new in SRP2 */166};167168/*169* The SRP spec defines the size of the LOGIN_RSP structure to be 52170* bytes, so it needs to be packed to avoid having it padded to 56171* bytes on 64-bit architectures.172*/173struct srp_login_rsp {174u8 opcode;175u8 reserved1[3];176__be32 req_lim_delta;177u64 tag __packed __aligned(4);178__be32 max_it_iu_len;179__be32 max_ti_iu_len;180__be16 buf_fmt;181u8 rsp_flags;182u8 reserved2[25];183};184185struct srp_login_rej {186u8 opcode;187u8 reserved1[3];188__be32 reason;189u64 tag;190u8 reserved2[8];191__be16 buf_fmt;192u8 reserved3[6];193};194195struct srp_i_logout {196u8 opcode;197u8 reserved[7];198u64 tag;199};200201struct srp_t_logout {202u8 opcode;203u8 sol_not;204u8 reserved[2];205__be32 reason;206u64 tag;207};208209struct srp_tsk_mgmt {210u8 opcode;211u8 sol_not;212u8 reserved1[6];213u64 tag;214u8 reserved2[4];215struct scsi_lun lun;216u8 reserved3[2];217u8 tsk_mgmt_func;218u8 reserved4;219u64 task_tag;220u8 reserved5[8];221};222223struct srp_cmd {224u8 opcode;225u8 sol_not;226u8 reserved1[3];227u8 buf_fmt;228u8 data_out_desc_cnt;229u8 data_in_desc_cnt;230u64 tag;231u8 reserved2[4];232struct scsi_lun lun;233u8 reserved3;234u8 task_attr;235u8 reserved4;236u8 add_cdb_len;237u8 cdb[16];238u8 add_data[];239};240241enum {242SRP_RSP_FLAG_RSPVALID = 1 << 0,243SRP_RSP_FLAG_SNSVALID = 1 << 1,244SRP_RSP_FLAG_DOOVER = 1 << 2,245SRP_RSP_FLAG_DOUNDER = 1 << 3,246SRP_RSP_FLAG_DIOVER = 1 << 4,247SRP_RSP_FLAG_DIUNDER = 1 << 5248};249250/*251* The SRP spec defines the size of the RSP structure to be 36 bytes,252* so it needs to be packed to avoid having it padded to 40 bytes on253* 64-bit architectures.254*/255struct srp_rsp {256u8 opcode;257u8 sol_not;258u8 reserved1[2];259__be32 req_lim_delta;260u64 tag __packed __aligned(4);261u8 reserved2[2];262u8 flags;263u8 status;264__be32 data_out_res_cnt;265__be32 data_in_res_cnt;266__be32 sense_data_len;267__be32 resp_data_len;268u8 data[];269};270271struct srp_cred_req {272u8 opcode;273u8 sol_not;274u8 reserved[2];275__be32 req_lim_delta;276u64 tag;277};278279struct srp_cred_rsp {280u8 opcode;281u8 reserved[7];282u64 tag;283};284285/*286* The SRP spec defines the fixed portion of the AER_REQ structure to be287* 36 bytes, so it needs to be packed to avoid having it padded to 40 bytes288* on 64-bit architectures.289*/290struct srp_aer_req {291u8 opcode;292u8 sol_not;293u8 reserved[2];294__be32 req_lim_delta;295u64 tag __packed __aligned(4);296u32 reserved2;297struct scsi_lun lun;298__be32 sense_data_len;299u32 reserved3;300u8 sense_data[];301};302303struct srp_aer_rsp {304u8 opcode;305u8 reserved[7];306u64 tag;307};308309#endif /* SCSI_SRP_H */310311312