#!/bin/tcsh
#
#	vi: set autoindent tabstop=4 shiftwidth=4 :
#
#	target-install
#
#	Script for installing and configuring the target for 2.6.x kernels.
#
#
#	Copyright (C) 2001-2003 InterOperability Lab (IOL)
#							University of New Hampshier (UNH)
#							Durham, NH 03824
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 2, or (at your option)
#	any later version.
#
#	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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
#	USA.
#
#	The name of IOL and/or UNH may not be used to endorse or promote products
#	derived from this software without specific prior written permission.
#
#

#	change the max and default read/write socket buffer sizes to 1 Megabyte
echo "1048575" > /proc/sys/net/core/rmem_max
echo "1048575" > /proc/sys/net/core/rmem_default
echo "1048575" > /proc/sys/net/core/wmem_max
echo "1048575" > /proc/sys/net/core/wmem_default

#	disable the TCP RTT calculation
echo "0" > /proc/sys/net/ipv4/tcp_timestamps

insmod ../unh_scsi_target.ko
insmod ../unh_iscsi_target.ko
#
############## Configure Target ###############
./iscsi_manage target set TargetPortalGroupTag=1 host=0
#
#### p=0 to never phase collapse, p=1 to always phase collapse
#### p=2 to phase collapse every other opportunity
./iscsi_manage target force p=1 host=0
#
#./iscsi_manage target set HeaderDigest=CRC32C,None host=0
#./iscsi_manage target set DataDigest=CRC32C,None host=0
#
./iscsi_manage target set MaxConnections=2 host=0
##./iscsi_manage target set MaxOutstandingR2T=2 host=0
#
#### performance usually better the larger these numbers are
##./iscsi_manage target set MaxRecvDataSegmentLength=4096 host=0
##./iscsi_manage target set MaxBurstLength=16384 host=0
##./iscsi_manage target set FirstBurstLength=16384 host=0
#./iscsi_manage target set MaxRecvDataSegmentLength=12288 host=0
#./iscsi_manage target set FirstBurstLength=16384 host=0
#./iscsi_manage target set MaxBurstLength=32768 host=0
#./iscsi_manage target set MaxRecvDataSegmentLength=16773120 host=0
#./iscsi_manage target set MaxBurstLength=16773120 host=0
#./iscsi_manage target set FirstBurstLength=16773120 host=0

#### performance usually better when all write data goes immediate/unsolicited
#### (which is the combination InitialR2T=NO and ImmediateData=Yes)
#./iscsi_manage target set InitialR2T=No host=0
#./iscsi_manage target set ImmediateData=No host=0
#
#### performance usually better when everything goes in order
#./iscsi_manage target set DataPDUInOrder=No host=0
#./iscsi_manage target set DataSequenceInOrder=No host=0
#
############## Error Recovery #################
./iscsi_manage target set ErrorRecoveryLevel=1 host=0
./iscsi_manage target force r2tp=2 host=0
./iscsi_manage target snack d=y host=0
./iscsi_manage target snack s=y host=0
./iscsi_manage target snack h=1 host=0
#
############## Require initiator to offer security #############
#./iscsi_manage target force s host=0
#
################### Chap ######################
#./iscsi_manage target set AuthMethod=CHAP,None host=0
#./iscsi_manage target force b t cl=256 px="wild_cat_and_dog" pn=UNH-reference-Target lx="UNH cowhampshire" ln=anonymous-user-of-UNH-reference-Target host=0
#
################### SRP ######################
#./iscsi_manage target set AuthMethod=SRP,None host=0
#./iscsi_manage target force b sx="old_man_of_the_mountain" sn=UNH-IOL-user-name host=0
#
################# start SLP ##################
#register the SLP service by calling a script regTarget
#source target-reg-slp $1
