iscsi_conn.h revision 36c5fee33fa8b822175d410202aebcf592c8d342
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _TARGET_CONN_H
#define _TARGET_CONN_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Block comment which describes the contents of this file.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/iscsi_protocol.h>
#include "queue.h"
#include "iscsi_sess.h"
#include "iscsi_cmd.h"
#define LBUFSIZE 80
#define TARGET_LOCATION "targets"
/*
* data size is larger than 8k. To work around this problem I set the
* various negotiation parameters during login to limit things to 8k.
*/
#define NETWORK_SNDRCV 65536
#define NETWORK_SNDRCV_STR "65536"
typedef enum iscsi_state {
/* S2_XPT_WAIT, Not possible for target */
typedef enum iscsi_transition {
/*
* When grabbing mutex's make sure to grab c_mutex before c_mutex_state
* if you need to grab both.
*/
typedef struct iscsi_conn {
int c_fd;
/*
* This is a linked list of all connections. Not just the connections
* associated with a particular session.
*/
struct iscsi_conn *c_next,
*c_prev;
/*
* Time as reported by time(2) when this connection was started.
*/
/*
* This queue is used to accept notification that incoming packets
* are available and command completion status from Session.
*/
/*
* Messages are sent to Session, and from there onto STE, using
* this queue.
*/
/*
* Protected by c_mutex
*/
int c_statsn;
int c_cid;
/*
* Pointer to data buffer used to store text messages which have
* with a '\0' strlen can't be used to determine the amount of space
* used so we keep the length in c_text_len;
*/
char *c_text_area;
int c_text_len;
int c_text_sent;
struct sockaddr_storage c_initiator_sockaddr;
struct sockaddr_storage c_target_sockaddr;
int c_num;
int c_auth_pass : 1;
int c_cmds_active;
/*
* A performance issue has been found when the backing store
* is UFS. Because of the indirect blocks used by UFS large files
* (many GBs in size) perform poorly. This in turn can cause the
* initiator to issue commands which don't complete in time. So,
* we'll monitor the completion times for commands if if it's
* increasing the command window will be reduced.
* The avg_sum is in nanoseconds. This will wrap once every 584
* years.
*/
/*
* During an orderly shutdown the logout response is created when
* we receive the logout request. We must however wait for all I/O
* to complete before processing the data else we'll loose data
* which the initiator believes was successfully transferred.
* Once the STE and sessions have closed they will send a shutdown
* complete message. At that point the transmit side of the connection
* will set the state to T13 which pushes this message out.
* Unfortunately we need information from the Logout Request PDU
* to create the Logout Response PDU. Otherwise the response could
* be generated on the fly in the T13 state handler. By creating
* the response PDU and saving a pointer gives us some flexibility
* in the future if the final outgoing packet needs to change.
* Otherwise, storing that one bit of information from the request
* PDU might become dated.
*/
/*
* Connection parameters
*/
int c_tpgt,
char *c_targ_alias,
int auth_text_length;
} iscsi_conn_t;
void *conn_process(void *v);
void iscsi_inventory_change(char *targ_name);
#ifdef __cplusplus
}
#endif
#endif /* _TARGET_CONN_H */