12f245829Sagc /* 2b6364952Sagc * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 3b6364952Sagc * By downloading, copying, installing or using the software you agree 4b6364952Sagc * to this license. If you do not agree to this license, do not 5b6364952Sagc * download, install, copy or use the software. 62f245829Sagc * 72f245829Sagc * Intel License Agreement 82f245829Sagc * 92f245829Sagc * Copyright (c) 2000, Intel Corporation 102f245829Sagc * All rights reserved. 112f245829Sagc * 12b6364952Sagc * Redistribution and use in source and binary forms, with or without 13b6364952Sagc * modification, are permitted provided that the following conditions 14b6364952Sagc * are met: 152f245829Sagc * 16b6364952Sagc * -Redistributions of source code must retain the above copyright 17b6364952Sagc * notice, this list of conditions and the following disclaimer. 182f245829Sagc * 19b6364952Sagc * -Redistributions in binary form must reproduce the above copyright 20b6364952Sagc * notice, this list of conditions and the following disclaimer in the 21b6364952Sagc * documentation and/or other materials provided with the 22b6364952Sagc * distribution. 232f245829Sagc * 24b6364952Sagc * -The name of Intel Corporation may not be used to endorse or 25b6364952Sagc * promote products derived from this software without specific prior 26b6364952Sagc * written permission. 272f245829Sagc * 28b6364952Sagc * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29b6364952Sagc * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30b6364952Sagc * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 31b6364952Sagc * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL 32b6364952Sagc * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33b6364952Sagc * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34b6364952Sagc * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 35b6364952Sagc * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 36b6364952Sagc * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37b6364952Sagc * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 38b6364952Sagc * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39b6364952Sagc * SUCH DAMAGE. 402f245829Sagc */ 412f245829Sagc #ifndef _TARGET_H_ 422f245829Sagc #define _TARGET_H_ 432f245829Sagc 44b6364952Sagc #include "iscsiprotocol.h" 452f245829Sagc #include "iscsiutil.h" 462f245829Sagc #include "parameters.h" 472f245829Sagc #include "storage.h" 48b6364952Sagc #include "iscsi.h" 492f245829Sagc 502f245829Sagc /* Default configuration */ 512f245829Sagc #define DEFAULT_TARGET_MAX_SESSIONS 16 /* n+1 */ 522f245829Sagc #define DEFAULT_TARGET_NUM_LUNS 1 532f245829Sagc #define DEFAULT_TARGET_BLOCK_LEN 512 542f245829Sagc #define DEFAULT_TARGET_NUM_BLOCKS 204800 552f245829Sagc #define DEFAULT_TARGET_NAME "iqn.1994-04.org.netbsd.iscsi-target" 562f245829Sagc #define DEFAULT_TARGET_QUEUE_DEPTH 8 572f245829Sagc #define DEFAULT_TARGET_TCQ 0 582f245829Sagc 592f245829Sagc enum { 60b6364952Sagc MAX_INITIATOR_ADDRESS_SIZE = 256 612f245829Sagc 622f245829Sagc }; 632f245829Sagc 642f245829Sagc /* session parameters */ 652f245829Sagc typedef struct target_session_t { 662f245829Sagc int id; 672f245829Sagc int d; 68b6364952Sagc int sock; 692f245829Sagc uint16_t cid; 702f245829Sagc uint32_t StatSN; 712f245829Sagc uint32_t ExpCmdSN; 722f245829Sagc uint32_t MaxCmdSN; 732f245829Sagc uint8_t *buff; 742f245829Sagc int UsePhaseCollapsedRead; 752f245829Sagc int IsFullFeature; 762f245829Sagc int IsLoggedIn; 772f245829Sagc int LoginStarted; 782f245829Sagc uint64_t isid; 792f245829Sagc int tsih; 80*5e01dafbSagc iscsi_target_t *target; 812f245829Sagc iscsi_worker_t worker; 822f245829Sagc iscsi_parameter_t *params; 832f245829Sagc iscsi_sess_param_t sess_params; 842f245829Sagc char initiator[MAX_INITIATOR_ADDRESS_SIZE]; 852f245829Sagc int address_family; 862f245829Sagc int32_t last_tsih; 872f245829Sagc } target_session_t; 882f245829Sagc 892f245829Sagc typedef struct target_cmd_t { 902f245829Sagc iscsi_scsi_cmd_args_t *scsi_cmd; 912f245829Sagc int (*callback) (void *); 922f245829Sagc void *callback_arg; 932f245829Sagc } target_cmd_t; 942f245829Sagc 952f245829Sagc int target_transfer_data(target_session_t *, iscsi_scsi_cmd_args_t *, struct iovec *, int); 962f245829Sagc 97b6364952Sagc int find_target_tsih(iscsi_target_t *, int); 982f245829Sagc int find_target_iqn(target_session_t *); 992f245829Sagc 1002f245829Sagc #endif /* _TARGET_H_ */ 101