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

View File

@@ -23,6 +23,7 @@ QLA_INI_DIR=qla2x00t
QLA_DIR=qla2x00t/qla2x00-target
LSI_DIR=mpt
USR_DIR=usr/fileio
SRP_DIR=srpt
ISCSI_DIR=iscsi-scst
#ISCSI_DISTDIR=../../../iscsi_scst_inst
@@ -58,6 +59,12 @@ help:
@echo " lsi_install : lsi target: install"
@echo " lsi_uninstall : lsi target: uninstall"
@echo ""
@echo " srpt : make SRP target"
@echo " srpt_clean : srp target: clean "
@echo " srpt_extraclean : srp target: clean + clean dependencies"
@echo " srpt_install : srp target: install"
@echo " srpt_uninstall : srp target: uninstall"
@echo ""
@echo " usr : make user space fileio_tgt target"
@echo " usr_clean : usr target: clean "
@echo " usr_extraclean : usr target: clean + clean dependencies"
@@ -76,6 +83,7 @@ all:
cd $(SCST_DIR) && $(MAKE) $@
@if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi
# @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@@ -83,6 +91,7 @@ install:
cd $(SCST_DIR) && $(MAKE) $@
@if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi
# @if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) DISTDIR=$(ISCSI_DISTDIR) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@@ -90,6 +99,7 @@ uninstall:
cd $(SCST_DIR) && $(MAKE) $@
@if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi
@if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@@ -98,6 +108,7 @@ clean:
@if [ -d $(QLA_INI_DIR) ]; then cd $(QLA_INI_DIR) && $(MAKE) $@; fi
@if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi
@if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@@ -106,6 +117,7 @@ extraclean:
@if [ -d $(QLA_INI_DIR) ]; then cd $(QLA_INI_DIR) && $(MAKE) $@; fi
@if [ -d $(QLA_DIR) ]; then cd $(QLA_DIR) && $(MAKE) $@; fi
@if [ -d $(LSI_DIR) ]; then cd $(LSI_DIR) && $(MAKE) $@; fi
@if [ -d $(SRP_DIR) ]; then cd $(SRP_DIR) && $(MAKE) $@; fi
@if [ -d $(ISCSI_DIR) ]; then cd $(ISCSI_DIR) && $(MAKE) $@; fi
@if [ -d $(USR_DIR) ]; then cd $(USR_DIR) && $(MAKE) $@; fi
@@ -171,6 +183,21 @@ lsi_clean:
lsi_extraclean:
cd $(LSI_DIR) && $(MAKE) extraclean
srpt:
cd $(SRP_DIR) && $(MAKE)
srpt_install:
cd $(SRP_DIR) && $(MAKE) install
srpt_uninstall:
cd $(SRP_DIR) && $(MAKE) uninstall
srpt_clean:
cd $(SRP_DIR) && $(MAKE) clean
srpt_extraclean:
cd $(SRP_DIR) && $(MAKE) extraclean
usr:
cd $(USR_DIR) && $(MAKE)

45
srpt/LICENSE Normal file
View File

@@ -0,0 +1,45 @@
OpenIB.org BSD license:
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.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Alternatively, this software may be distributed under the terms of the
the GNU Public License ("GPL") with platforms where the prevalant license
is the GNU Public License:
This program is free software; you can redistribute it and/or modify
it under the terms of The Version 2 GNU General Public License as published
by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

57
srpt/Makefile Normal file
View File

@@ -0,0 +1,57 @@
#
# Makefile for the Linux kernel device drivers.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (not a .c file).
#
# Note 2! The CFLAGS definitions are now in the main makefile.
SCST_DIR := $(shell pwd)/../scst/src
SUBDIRS := $(shell pwd)
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER = $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build
else
KVER = $$KERNELRELEASE
endif
else
KDIR ?= /lib/modules/$(KVER)/build
endif
all: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src modules
install: all src/ib_srpt.ko
@eval `sed -n 's/#define UTS_RELEASE /KERNELRELEASE=/p' $(KDIR)/include/linux/version.h $(KDIR)/include/linux/utsrelease.h 2>/dev/null`; \
install -vD -m 644 src/ib_srpt.ko \
$(DISTDIR)$(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra/ib_srpt.ko
-/sbin/depmod -aq $(KVER)
SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Modules.symvers 2>/dev/null)
ifneq ($(SCST_MOD_VERS),)
Modules.symvers: $(SCST_DIR)/Modules.symvers
echo $(SCST_MOD_VERS)
cp $(SCST_DIR)/Modules.symvers src/
else
.PHONY: Modules.symvers
endif
# It's renamed in 2.6.18
SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Module.symvers 2>/dev/null)
ifneq ($(SCST_MOD_VERS),)
Module.symvers: $(SCST_DIR)/Module.symvers
cp $(SCST_DIR)/Module.symvers src/
else
.PHONY: Module.symvers
endif
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src clean
rm -f src/Modules.symvers src/Module.symvers
extraclean: clean
.PHONY: all install clean extraclean

106
srpt/README Normal file
View File

@@ -0,0 +1,106 @@
SCSI RDMA Protocol (SRP) Target driver for Linux
=================================================
SRP Target driver is designed to work directly on top of OpenFabrics
OFED-1.x software stack (http://www.openfabrics.org) or Infiniband
drivers in Linux kernel tree (kernel.org). It also interfaces with
Generic SCSI target mid-level driver - SCST (http://scst.sourceforge.net)
NOTES: This SRP Target driver can only compile and work with IB driver
in Linux vanilla kernel. It does not compile and work with IB
driver in OFED-1.x packages
If you want to work with IB driver in OFED-1.x package, you should
read and follow instruction in README.ofed file
Installation
------------
$ make
$ make install
To minimize QUEUEFULL conditions, please apply scst_increase_max_tgt_cmds
patch and recompile scst
$ cd ~scst/trunk
$ patch -p0 < srpt/patches/scst_increasa_max_tgt_cmds.patch
$ make scst scst_install srpt srpt_install
How-to run
-----------
A. On srp target machine
1. Please refer to SCST's README for loading scst driver and its
dev_handlers drivers (scst_disk, scst_vdisk block or file IO mode, nullio, ...)
Example 1: working with real back-end scsi disks
a. modprobe scst
b. modprobe scst_disk
c. cat /proc/scsi_tgt/scsi_tgt
ibstor00:~ # cat /proc/scsi_tgt/scsi_tgt
Device (host:ch:id:lun or name) Device handler
0:0:0:0 dev_disk
4:0:0:0 dev_disk
5:0:0:0 dev_disk
6:0:0:0 dev_disk
7:0:0:0 dev_disk
Now you want to exclude the first scsi disk and expose the last 4 scsi disks as
IB/SRP luns for I/O
echo "add 4:0:0:0 0" >/proc/scsi_tgt/groups/Default/devices
echo "add 5:0:0:0 1" >/proc/scsi_tgt/groups/Default/devices
echo "add 6:0:0:0 2" >/proc/scsi_tgt/groups/Default/devices
echo "add 7:0:0:0 3" >/proc/scsi_tgt/groups/Default/devices
Example 2: working with VDISK FILEIO mode (using md0 device and file 10G-file)
a. modprobe scst
b. modprobe scst_vdisk
c. echo "open vdisk0 /dev/md0" > /proc/scsi_tgt/vdisk/vdisk
d. echo "open vdisk1 /10G-file" > /proc/scsi_tgt/vdisk/vdisk
e. echo "add vdisk0 0" >/proc/scsi_tgt/groups/Default/devices
f. echo "add vdisk1 1" >/proc/scsi_tgt/groups/Default/devices
Example 3: working with VDISK BLOCKIO mode (using md0 device, sda, and cciss/c1d0)
a. modprobe scst
b. modprobe scst_vdisk
c. echo "open vdisk0 /dev/md0 BLOCKIO" > /proc/scsi_tgt/vdisk/vdisk
d. echo "open vdisk1 /dev/sda BLOCKIO" > /proc/scsi_tgt/vdisk/vdisk
e. echo "open vdisk2 /dev/cciss/c1d0 BLOCKIO" > /proc/scsi_tgt/vdisk/vdisk
f. echo "add vdisk0 0" >/proc/scsi_tgt/groups/Default/devices
g. echo "add vdisk1 1" >/proc/scsi_tgt/groups/Default/devices
h. echo "add vdisk2 2" >/proc/scsi_tgt/groups/Default/devices
2. modprobe ib_srpt
B. On initiator machines you can manualy do the following steps:
1. modprobe ib_srp
2. ipsrpdm -c (to discover new SRP target)
3. echo <new target info> > /sys/class/infiniband_srp/srp-mthca0-1/add_target
4. fdisk -l (will show new discovered scsi disks)
Example:
Assume that you use port 1 of first HCA in the system ie. mthca0
[root@lab104 ~]# ibsrpdm -c -d /dev/infiniband/umad0
id_ext=0002c90200226cf4,ioc_guid=0002c90200226cf4,
dgid=fe800000000000000002c90200226cf5,pkey=ffff,service_id=0002c90200226cf4
[root@lab104 ~]# echo id_ext=0002c90200226cf4,ioc_guid=0002c90200226cf4,
dgid=fe800000000000000002c90200226cf5,pkey=ffff,service_id=0002c90200226cf4 >
/sys/class/infiniband_srp/srp-mthca0-1/add_target
OR
+ You can edit /etc/infiniband/openib.conf to load srp driver and srp HA daemon
automatically ie. set SRP_LOAD=yes, and SRPHA_ENABLE=yes
+ To set up and use high availability feature you need dm-multipath driver
and multipath tool
+ Please refer to OFED-1.x SRP's user manual for more in-details instructions
on how-to enable/use HA feature
TO DO
------
+ Stress test and stabilize the code
+ Performance tuning

165
srpt/README.ofed Normal file
View File

@@ -0,0 +1,165 @@
SCSI RDMA Protocol (SRP) Target driver for Linux
=================================================
SRP Target driver is designed to work directly on top of OpenFabrics
OFED-1.x software stack (http://www.openfabrics.org) or Infiniband
drivers in Linux kernel tree (kernel.org). It also interfaces with
Generic SCSI target mid-level driver - SCST (http://scst.sourceforge.net)
By interfacing with SCST driver we are able to work and support a lot IO
modes on real or virtual devices in the backend
1. scst_disk -- interfacing with scsi sub-system to claim and export real
scsi devices ie. disks, hardware raid volumes, tape library as SRP's luns
2. scst_vdisk -- fileio and blockio modes. This allows you to turn software raid
volumes, LVM volumes, IDE disks, and normal files into SRP's luns (required to
work with latest scst's svn tree)
3. NULLIO mode will allow you to measure the performance without sending IOs
to *real* devices
Prerequisites
-------------
1. First it is required to download and install SCST driver. Please
refer to SCST's Internet page http://scst.sourceforge.net for download
and installation instructions. You can also find SCST's design document,
svn repository development tree and utility tools for basic storage
management
a. git clone git://git.openfabrics.org/~vu/srpt_inc ~/srpt_inc
b. Checking out scst's svn development tree revision 245
svn co https://scst.svn.sourceforge.net/svnroot/scst/trunk/scst -r 245
c. cd scst
d. patch -p0 < ~/srpt_inc/scst_r245.patch
e. make and make install
2. Download/install IB low-level driver from OFED package or linux kernel tree
a. SRP target is part of OFED-1.3
or
b. Download and install OFED-1.x (x > 1) with kernel_ib development package rpm
or
c. Built and installed Infiniband driver in Linux "vanilla" kernel tree
from kernel.org
3. Download SRP target driver from openfabrics.org (needed for 2b, 2c)
git clone git://git.openfabrics.org/~vu/srpt.git ~/srpt
Installation
------------
A. For OFED-1.3
----------------
SRP target is part of ofed-1.3. Go through normal installation with srpt enable
B. Instruction to included in and built with OFED-1.2.5 development tree
-----------------------------------------------------------------------
1. cd /usr/src/ofa_kernel-1.2.5 or /usr/src/ofa_kernel-1.2.c or
~/ofa_1_2_c_kernel-200708xx-yyyy
2. patch -p1 < ~/srpt_inc/add_srpt_01.patch
3. patch -p1 < ~/srpt_inc/add_srpt_03.patch
4. patch -p1 < ~/srpt_inc/add_srpt_04.patch
5. cp -r ~/srpt drivers/infiniband/ulp/srpt
6. ./configure --with-core-mod --with-mthca-mod --without-mthca_debug-mod
--with-srp-target-mod <and any other modules/drivers as needed>
7. make and make install
C. Instruction to be included in and built with OFED-1.2 development tree
--------------------------------------------------------------------------
1. cd /usr/src/ofa_kernel-1.2 or /usr/src/ofa_kernel-1.2 or
~/ofa_1_2_kernel-200708xx-yyyy
2. patch -p1 < ~/srpt_inc/add_srpt_01.patch
3. patch -p1 < ~/srpt_inc/add_srpt_03.patch
4. patch -p1 < ~/srpt_inc/add_srpt_04.patch
5. cp -r ~/srpt drivers/infiniband/ulp/srpt
6. patch -p1 < ~/srpt_inc/add_srpt_ofed_1_2.patch
7. ./configure --with-core-mod --with-mthca-mod --without-mthca_debug-mod
--with-srp-target-mod <and any other modules/drivers as needed>
8. make and make install
D. Instruction to be included in and built with "vanilla" kernel development tree
----------------------------------------------------------------------------------
1. cd /usr/src/linux-2.6.1x
2. patch -p1 < ~/srpt_inc/add_srpt_03.patch
3. cp -r ~/srpt drivers/infiniband/ulp/srpt
4. configure and build SRP target module driver as normal
How-to run
-----------
A. On srp target machine
1. Please refer to SCST's README for loading scst driver and its
dev_handlers drivers (scst_disk, scst_vdisk block or file IO mode, nullio, ...)
Example 1: working with real back-end scsi disks
a. modprobe scst
b. modprobe scst_disk
c. cat /proc/scsi_tgt/scsi_tgt
ibstor00:~ # cat /proc/scsi_tgt/scsi_tgt
Device (host:ch:id:lun or name) Device handler
0:0:0:0 dev_disk
4:0:0:0 dev_disk
5:0:0:0 dev_disk
6:0:0:0 dev_disk
7:0:0:0 dev_disk
Now you want to exclude the first scsi disk and expose the last 4 scsi disks as
IB/SRP luns for I/O
echo "add 4:0:0:0 0" >/proc/scsi_tgt/groups/Default/devices
echo "add 5:0:0:0 1" >/proc/scsi_tgt/groups/Default/devices
echo "add 6:0:0:0 2" >/proc/scsi_tgt/groups/Default/devices
echo "add 7:0:0:0 3" >/proc/scsi_tgt/groups/Default/devices
Example 2: working with VDISK FILEIO mode (using md0 device and file 10G-file)
a. modprobe scst
b. modprobe scst_vdisk
c. echo "open vdisk0 /dev/md0" > /proc/scsi_tgt/vdisk/vdisk
d. echo "open vdisk1 /10G-file" > /proc/scsi_tgt/vdisk/vdisk
e. echo "add vdisk0 0" >/proc/scsi_tgt/groups/Default/devices
f. echo "add vdisk1 1" >/proc/scsi_tgt/groups/Default/devices
Example 3: working with VDISK BLOCKIO mode (using md0 device, sda, and cciss/c1d0)
a. modprobe scst
b. modprobe scst_vdisk
c. echo "open vdisk0 /dev/md0 BLOCKIO" > /proc/scsi_tgt/vdisk/vdisk
d. echo "open vdisk1 /dev/sda BLOCKIO" > /proc/scsi_tgt/vdisk/vdisk
e. echo "open vdisk2 /dev/cciss/c1d0 BLOCKIO" > /proc/scsi_tgt/vdisk/vdisk
f. echo "add vdisk0 0" >/proc/scsi_tgt/groups/Default/devices
g. echo "add vdisk1 1" >/proc/scsi_tgt/groups/Default/devices
h. echo "add vdisk2 2" >/proc/scsi_tgt/groups/Default/devices
2. modprobe ib_srpt
B. On initiator machines you can manualy do the following steps:
1. modprobe ib_srp
2. ipsrpdm -c (to discover new SRP target)
3. echo <new target info> > /sys/class/infiniband_srp/srp-mthca0-1/add_target
4. fdisk -l (will show new discovered scsi disks)
Example:
Assume that you use port 1 of first HCA in the system ie. mthca0
[root@lab104 ~]# ibsrpdm -c -d /dev/infiniband/umad0
id_ext=0002c90200226cf4,ioc_guid=0002c90200226cf4,
dgid=fe800000000000000002c90200226cf5,pkey=ffff,service_id=0002c90200226cf4
[root@lab104 ~]# echo id_ext=0002c90200226cf4,ioc_guid=0002c90200226cf4,
dgid=fe800000000000000002c90200226cf5,pkey=ffff,service_id=0002c90200226cf4 >
/sys/class/infiniband_srp/srp-mthca0-1/add_target
OR
+ You can edit /etc/infiniband/openib.conf to load srp driver and srp HA daemon
automatically ie. set SRP_LOAD=yes, and SRPHA_ENABLE=yes
+ To set up and use high availability feature you need dm-multipath driver
and multipath tool
+ Please refer to OFED-1.x SRP's user manual for more in-details instructions
on how-to enable/use HA feature
TO DO
------
+ Stress test and stabilize the code
+ Performance tuning

View File

@@ -0,0 +1,13 @@
Index: scst/src/scst_priv.h
===================================================================
--- scst/src/scst_priv.h (revision 303)
+++ scst/src/scst_priv.h (working copy)
@@ -110,7 +110,7 @@ extern unsigned long scst_trace_flag;
** Maximum count of uncompleted commands that an initiator could
** queue on any device. Then it will start getting TASK QUEUE FULL status.
**/
-#define SCST_MAX_TGT_DEV_COMMANDS 48
+#define SCST_MAX_TGT_DEV_COMMANDS 64
/**
** Maximum count of uncompleted commands that could be queued on any device.

12
srpt/src/Kconfig Normal file
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
srpt/src/Makefile Normal file
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

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
srpt/src/ib_dm_mad.h Normal file
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
srpt/src/ib_srpt.c Normal file

File diff suppressed because it is too large Load Diff

201
srpt/src/ib_srpt.h Normal file
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 */