Patch from Vu Pham <vuhuong@mellanox.com>: SRP target driver

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@304 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2008-03-17 11:29:50 +00:00
parent 6993f48774
commit 240d5511be
12 changed files with 3060 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
config INFINIBAND_SRPT
tristate "InfiniBand SCSI RDMA Protocol Target Mode"
depends on INFINIBAND
---help---
Support for the SCSI RDMA Protocol Target mode over InfiniBand.
This allows you to turn a standard Linux box to native Infiniband
storage using SRP protocol.
You will also need the SCST middle level drivers from
http://scst.sf.net/
The SRP protocol is defined by the INCITS T10 technical
committee. See <http://www.t10.org/>.
+7
View File
@@ -0,0 +1,7 @@
SCST_INC_DIR := $(SUBDIRS)/../../scst/include
EXTRA_CFLAGS += -I$(SCST_INC_DIR)
EXTRA_CFLAGS += -DDEBUG -g
#EXTRA_CFLAGS += -Wextra -Wno-unused-parameter
obj-m += ib_srpt.o
+4
View File
@@ -0,0 +1,4 @@
EXTRA_CFLAGS += -Idrivers/infiniband/include
EXTRA_CFLAGS += -I/usr/local/include/scst
obj-$(CONFIG_INFINIBAND_SRPT) += ib_srpt.o
+106
View File
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2006 Mellanox Technology Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef IB_DM_MAD_H
#define IB_DM_MAD_H
#include <linux/types.h>
#include <rdma/ib_mad.h>
enum {
DM_MAD_STATUS_UNSUP_METHOD = 0x0008,
DM_MAD_STATUS_UNSUP_METHOD_ATTR = 0x000c,
DM_MAD_STATUS_INVALID_FIELD = 0x001c,
DM_MAD_STATUS_NO_IOC = 0x0100,
DM_ATTR_CLASS_PORT_INFO = 0x01,
DM_ATTR_IOU_INFO = 0x10,
DM_ATTR_IOC_PROFILE = 0x11,
DM_ATTR_SVC_ENTRIES = 0x12
};
struct ib_dm_hdr {
u8 reserved[28];
};
struct ib_dm_mad {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
struct ib_dm_hdr dm_hdr;
u8 data[IB_MGMT_DEVICE_DATA];
};
struct ib_dm_iou_info {
__be16 change_id;
u8 max_controllers;
u8 op_rom;
u8 controller_list[128];
};
struct ib_dm_ioc_profile {
__be64 guid;
__be32 vendor_id;
__be32 device_id;
__be16 device_version;
__be16 reserved1;
__be32 subsys_vendor_id;
__be32 subsys_device_id;
__be16 io_class;
__be16 io_subclass;
__be16 protocol;
__be16 protocol_version;
__be16 service_conn;
__be16 initiators_supported;
__be16 send_queue_depth;
u8 reserved2;
u8 rdma_read_depth;
__be32 send_size;
__be32 rdma_size;
u8 op_cap_mask;
u8 svc_cap_mask;
u8 num_svc_entries;
u8 reserved3[9];
u8 id_string[64];
};
struct ib_dm_svc_entry {
u8 name[40];
u64 id;
};
struct ib_dm_svc_entries {
struct ib_dm_svc_entry service_entries[4];
};
#endif
+2317
View File
File diff suppressed because it is too large Load Diff
+201
View File
@@ -0,0 +1,201 @@
/*
* Copyright (c) 2006 Mellanox Technology Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef IB_SRPT_H
#define IB_SRPT_H
#include <linux/version.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_sa.h>
#include <rdma/ib_cm.h>
#include <scsi/srp.h>
#include <scsi_tgt.h>
#include "ib_dm_mad.h"
#define SRP_SERVICE_NAME_PREFIX "SRP.T10:"
enum {
SRP_PROTOCOL = 0x0108,
SRP_PROTOCOL_VERSION = 0x0001,
SRP_IO_SUBCLASS = 0x609e,
SRP_SEND_TO_IOC = 0x01,
SRP_SEND_FROM_IOC = 0x02,
SRP_RDMA_READ_FROM_IOC = 0x08,
SRP_RDMA_WRITE_FROM_IOC = 0x20,
SRP_TSK_MGMT_SUCCESS = 0x00,
SRP_TSK_MGMT_FUNC_NOT_SUPP = 0x04,
SRP_TSK_MGMT_FAILED = 0x05,
SRP_CMD_SIMPLE_Q = 0x0,
SRP_CMD_HEAD_OF_Q = 0x1,
SRP_CMD_ORDERED_Q = 0x2,
SRP_CMD_ACA = 0x4,
SRP_LOGIN_RSP_MULTICHAN_NO_CHAN = 0x0,
SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1,
SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2,
SRPT_DEF_SG_TABLESIZE = 128,
SRPT_DEF_SG_PER_WQE = 16,
SRPT_SQ_SIZE = 128 * SRPT_DEF_SG_PER_WQE,
SRPT_RQ_SIZE = 128,
SRPT_SRQ_SIZE = 4095,
MAX_MESSAGE_SIZE = 996,
MAX_RDMA_SIZE = 65536
};
#define SRPT_OP_RECV (1 << 31)
struct rdma_iu {
u64 raddr;
u32 rkey;
struct ib_sge *sge;
u32 sge_cnt;
int mem_id;
};
struct srpt_ioctx {
int index;
void *buf;
dma_addr_t dma;
struct rdma_iu *rdma_ius;
struct srp_direct_buf *rbufs;
struct srp_direct_buf single_rbuf;
struct list_head wait_list;
struct list_head scmnd_list;
u16 n_rdma_ius;
u8 n_rdma;
u8 n_rbuf;
enum ib_wc_opcode op;
struct list_head comp_list;
struct srpt_rdma_ch *ch;
struct scst_cmd *scmnd;
u64 data_len;
};
struct srpt_mgmt_ioctx {
struct srpt_ioctx *ioctx;
struct srpt_rdma_ch *ch;
u64 tag;
};
/* channel state */
enum rdma_ch_state {
RDMA_CHANNEL_CONNECTING,
RDMA_CHANNEL_LIVE,
RDMA_CHANNEL_DISCONNECTING
};
struct srpt_rdma_ch {
struct ib_cm_id *cm_id;
struct ib_qp *qp;
struct ib_cq *cq;
struct srpt_port *sport;
u8 i_port_id[16];
u8 t_port_id[16];
atomic_t req_lim_delta;
spinlock_t spinlock;
enum rdma_ch_state state;
struct list_head list;
struct list_head cmd_wait_list;
struct list_head active_scmnd_list;
u32 active_scmnd_cnt;
struct completion scst_sess_done;
struct scst_session *scst_sess;
u8 sess_name[32];
};
struct srpt_port {
struct srpt_device *sdev;
struct ib_mad_agent *mad_agent;
u8 port;
u16 sm_lid;
u16 lid;
union ib_gid gid;
struct work_struct work;
};
struct srpt_device {
struct ib_device *device;
struct ib_pd *pd;
struct ib_mr *mr;
struct ib_srq *srq;
struct ib_cm_id *cm_id;
struct ib_device_attr dev_attr;
struct srpt_ioctx *ioctx_ring[SRPT_SRQ_SIZE];
struct list_head list;
struct list_head rch_list;
spinlock_t spinlock;
struct srpt_port port[2];
struct ib_event_handler event_handler;
struct completion scst_released;
struct class_device class_dev;
struct scst_tgt *scst_tgt;
};
/* sense code/qualifier pairs */
enum {
NO_ADD_SENSE = 0x00,
LUN_NOT_READY = 0x04,
INVALID_CDB = 0x24,
INTERNAL_TARGET_FAILURE = 0x44
};
struct sense_data {
u8 err_code;
u8 segment_number;
u8 key;
u8 info_bytes[4];
u8 addl_sense_len;
u8 cmd_info_bytes[4];
u8 addl_sense_code;
u8 addl_sense_code_qual;
u16 asc_ascq;
u8 fru_code;
u8 sense_bytes[3];
};
#endif /* IB_SRPT_H */