/*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>4445enum {46SRP_LOGIN_REQ = 0x00,47SRP_TSK_MGMT = 0x01,48SRP_CMD = 0x02,49SRP_I_LOGOUT = 0x03,50SRP_LOGIN_RSP = 0xc0,51SRP_RSP = 0xc1,52SRP_LOGIN_REJ = 0xc2,53SRP_T_LOGOUT = 0x80,54SRP_CRED_REQ = 0x81,55SRP_AER_REQ = 0x82,56SRP_CRED_RSP = 0x41,57SRP_AER_RSP = 0x4258};5960enum {61SRP_BUF_FORMAT_DIRECT = 1 << 1,62SRP_BUF_FORMAT_INDIRECT = 1 << 263};6465enum {66SRP_NO_DATA_DESC = 0,67SRP_DATA_DESC_DIRECT = 1,68SRP_DATA_DESC_INDIRECT = 269};7071enum {72SRP_TSK_ABORT_TASK = 0x01,73SRP_TSK_ABORT_TASK_SET = 0x02,74SRP_TSK_CLEAR_TASK_SET = 0x04,75SRP_TSK_LUN_RESET = 0x08,76SRP_TSK_CLEAR_ACA = 0x4077};7879enum srp_login_rej_reason {80SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,81SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,82SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,83SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,84SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,85SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,86SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x0001000687};8889enum {90SRP_REV10_IB_IO_CLASS = 0xff00,91SRP_REV16A_IB_IO_CLASS = 0x010092};9394struct srp_direct_buf {95__be64 va;96__be32 key;97__be32 len;98};99100/*101* We need the packed attribute because the SRP spec puts the list of102* descriptors at an offset of 20, which is not aligned to the size of103* struct srp_direct_buf. The whole structure must be packed to avoid104* having the 20-byte structure padded to 24 bytes on 64-bit architectures.105*/106struct srp_indirect_buf {107struct srp_direct_buf table_desc;108__be32 len;109struct srp_direct_buf desc_list[0];110} __attribute__((packed));111112enum {113SRP_MULTICHAN_SINGLE = 0,114SRP_MULTICHAN_MULTI = 1115};116117struct srp_login_req {118u8 opcode;119u8 reserved1[7];120u64 tag;121__be32 req_it_iu_len;122u8 reserved2[4];123__be16 req_buf_fmt;124u8 req_flags;125u8 reserved3[5];126u8 initiator_port_id[16];127u8 target_port_id[16];128};129130/*131* The SRP spec defines the size of the LOGIN_RSP structure to be 52132* bytes, so it needs to be packed to avoid having it padded to 56133* bytes on 64-bit architectures.134*/135struct srp_login_rsp {136u8 opcode;137u8 reserved1[3];138__be32 req_lim_delta;139u64 tag;140__be32 max_it_iu_len;141__be32 max_ti_iu_len;142__be16 buf_fmt;143u8 rsp_flags;144u8 reserved2[25];145} __attribute__((packed));146147struct srp_login_rej {148u8 opcode;149u8 reserved1[3];150__be32 reason;151u64 tag;152u8 reserved2[8];153__be16 buf_fmt;154u8 reserved3[6];155};156157struct srp_i_logout {158u8 opcode;159u8 reserved[7];160u64 tag;161};162163struct srp_t_logout {164u8 opcode;165u8 sol_not;166u8 reserved[2];167__be32 reason;168u64 tag;169};170171/*172* We need the packed attribute because the SRP spec only aligns the173* 8-byte LUN field to 4 bytes.174*/175struct srp_tsk_mgmt {176u8 opcode;177u8 sol_not;178u8 reserved1[6];179u64 tag;180u8 reserved2[4];181__be64 lun __attribute__((packed));182u8 reserved3[2];183u8 tsk_mgmt_func;184u8 reserved4;185u64 task_tag;186u8 reserved5[8];187};188189/*190* We need the packed attribute because the SRP spec only aligns the191* 8-byte LUN field to 4 bytes.192*/193struct srp_cmd {194u8 opcode;195u8 sol_not;196u8 reserved1[3];197u8 buf_fmt;198u8 data_out_desc_cnt;199u8 data_in_desc_cnt;200u64 tag;201u8 reserved2[4];202__be64 lun __attribute__((packed));203u8 reserved3;204u8 task_attr;205u8 reserved4;206u8 add_cdb_len;207u8 cdb[16];208u8 add_data[0];209};210211enum {212SRP_RSP_FLAG_RSPVALID = 1 << 0,213SRP_RSP_FLAG_SNSVALID = 1 << 1,214SRP_RSP_FLAG_DOOVER = 1 << 2,215SRP_RSP_FLAG_DOUNDER = 1 << 3,216SRP_RSP_FLAG_DIOVER = 1 << 4,217SRP_RSP_FLAG_DIUNDER = 1 << 5218};219220/*221* The SRP spec defines the size of the RSP structure to be 36 bytes,222* so it needs to be packed to avoid having it padded to 40 bytes on223* 64-bit architectures.224*/225struct srp_rsp {226u8 opcode;227u8 sol_not;228u8 reserved1[2];229__be32 req_lim_delta;230u64 tag;231u8 reserved2[2];232u8 flags;233u8 status;234__be32 data_out_res_cnt;235__be32 data_in_res_cnt;236__be32 sense_data_len;237__be32 resp_data_len;238u8 data[0];239} __attribute__((packed));240241struct srp_cred_req {242u8 opcode;243u8 sol_not;244u8 reserved[2];245__be32 req_lim_delta;246u64 tag;247};248249struct srp_cred_rsp {250u8 opcode;251u8 reserved[7];252u64 tag;253};254255/*256* The SRP spec defines the fixed portion of the AER_REQ structure to be257* 36 bytes, so it needs to be packed to avoid having it padded to 40 bytes258* on 64-bit architectures.259*/260struct srp_aer_req {261u8 opcode;262u8 sol_not;263u8 reserved[2];264__be32 req_lim_delta;265u64 tag;266u32 reserved2;267__be64 lun;268__be32 sense_data_len;269u32 reserved3;270u8 sense_data[0];271} __attribute__((packed));272273struct srp_aer_rsp {274u8 opcode;275u8 reserved[7];276u64 tag;277};278279#endif /* SCSI_SRP_H */280281282