#!/bin/tcsh
#
#	vi: set autoindent tabstop=8 shiftwidth=8 :
#
#	target-install
#
#	Script for installing and configuring the target
#
#
#	Copyright (C) 2001-2004 InterOperability Lab (IOL)
#				University of New Hampshire (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

/sbin/insmod ../target/unh_scsi_target.o
/sbin/insmod ../target/unh_iscsi_target.o
#
############## Configure Target ###############
./iscsi_manage target restore host=0
./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
#
#### force target to send a response in a key negotiation
#### even when that response is optional according to the standard
#./iscsi_manage target force r host=0
#
#### force target to reflect back the value of any X- or X# key
#### (instead of sending back value of NotUnderstood)
#./iscsi_manage target force xok 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=4 host=0
./iscsi_manage target set MaxOutstandingR2T=8 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
#./iscsi_manage target set MaxRecvDataSegmentLength=65536 host=0
#./iscsi_manage target set FirstBurstLength=131072 host=0
#./iscsi_manage target set MaxBurstLength=262144 host=0
#./iscsi_manage target set MaxRecvDataSegmentLength=8192 host=0
#./iscsi_manage target set FirstBurstLength=32768 host=0
#./iscsi_manage target set MaxBurstLength=32768 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
#./iscsi_manage target snack a=y host=0
#
############## Force nop pings to be sent to initiator every 10 seconds ########
#./iscsi_manage target force n=5 host=0
#
############## Require initiator to offer security #############
#./iscsi_manage target force s host=0
#
############## Require initiator to offer operational negotiations #############
#./iscsi_manage target force o 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
#./iscsi_manage target force b cl=256 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
#
################# text replies ###############
#uncomment this to force SendTarget reply to send one key per Text Response pdu
#./iscsi_manage target force tk1 host=0

