2016-08-02 16:34:45 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>.
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPDK_ISCSI_H
|
|
|
|
#define SPDK_ISCSI_H
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
#include "spdk/bdev.h"
|
2016-08-08 17:34:24 +00:00
|
|
|
#include "spdk/iscsi_spec.h"
|
2018-06-11 20:32:15 +00:00
|
|
|
#include "spdk/thread.h"
|
2020-01-15 16:51:04 +00:00
|
|
|
#include "spdk/sock.h"
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2019-06-28 00:52:40 +00:00
|
|
|
#include "spdk/scsi.h"
|
2016-08-02 16:34:45 +00:00
|
|
|
#include "iscsi/param.h"
|
|
|
|
|
|
|
|
#include "spdk/assert.h"
|
2019-03-07 03:39:38 +00:00
|
|
|
#include "spdk/dif.h"
|
2018-08-10 18:27:02 +00:00
|
|
|
#include "spdk/util.h"
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
#define SPDK_ISCSI_DEFAULT_NODEBASE "iqn.2016-06.io.spdk"
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
#define DEFAULT_MAXR2T 4
|
2018-11-19 08:20:32 +00:00
|
|
|
#define MAX_INITIATOR_PORT_NAME 256
|
|
|
|
#define MAX_INITIATOR_NAME 223
|
|
|
|
#define MAX_TARGET_NAME 223
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
#define MAX_PORTAL 1024
|
|
|
|
#define MAX_INITIATOR 256
|
|
|
|
#define MAX_NETMASK 256
|
2019-02-14 07:09:09 +00:00
|
|
|
#define MAX_ISCSI_CONNECTIONS 1024
|
2019-08-08 05:57:43 +00:00
|
|
|
#define MAX_PORTAL_ADDR 256
|
|
|
|
#define MAX_PORTAL_PORT 32
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
#define DEFAULT_PORT 3260
|
|
|
|
#define DEFAULT_MAX_SESSIONS 128
|
|
|
|
#define DEFAULT_MAX_CONNECTIONS_PER_SESSION 2
|
|
|
|
#define DEFAULT_MAXOUTSTANDINGR2T 1
|
|
|
|
#define DEFAULT_DEFAULTTIME2WAIT 2
|
|
|
|
#define DEFAULT_DEFAULTTIME2RETAIN 20
|
2018-03-12 09:38:53 +00:00
|
|
|
#define DEFAULT_INITIALR2T true
|
|
|
|
#define DEFAULT_IMMEDIATEDATA true
|
|
|
|
#define DEFAULT_DATAPDUINORDER true
|
|
|
|
#define DEFAULT_DATASEQUENCEINORDER true
|
2016-08-02 16:34:45 +00:00
|
|
|
#define DEFAULT_ERRORRECOVERYLEVEL 0
|
|
|
|
#define DEFAULT_TIMEOUT 60
|
|
|
|
#define MAX_NOPININTERVAL 60
|
|
|
|
#define DEFAULT_NOPININTERVAL 30
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SPDK iSCSI target currently only supports 64KB as the maximum data segment length
|
|
|
|
* it can receive from initiators. Other values may work, but no guarantees.
|
|
|
|
*/
|
|
|
|
#define SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH 65536
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Defines maximum number of data out buffers each connection can have in
|
|
|
|
* use at any given time.
|
|
|
|
*/
|
|
|
|
#define MAX_DATA_OUT_PER_CONNECTION 16
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Defines maximum number of data in buffers each connection can have in
|
2016-09-26 05:33:23 +00:00
|
|
|
* use at any given time. So this limit does not affect I/O smaller than
|
2017-05-05 20:15:51 +00:00
|
|
|
* SPDK_BDEV_SMALL_BUF_MAX_SIZE.
|
2016-08-02 16:34:45 +00:00
|
|
|
*/
|
2016-09-26 05:33:23 +00:00
|
|
|
#define MAX_LARGE_DATAIN_PER_CONNECTION 64
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
#define SPDK_ISCSI_MAX_BURST_LENGTH \
|
|
|
|
(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH * MAX_DATA_OUT_PER_CONNECTION)
|
|
|
|
|
2018-08-10 18:27:02 +00:00
|
|
|
/*
|
|
|
|
* Defines default maximum amount in bytes of unsolicited data the iSCSI
|
|
|
|
* initiator may send to the SPDK iSCSI target during the execution of
|
|
|
|
* a single SCSI command. And it is smaller than the MaxBurstLength.
|
|
|
|
*/
|
2016-08-02 16:34:45 +00:00
|
|
|
#define SPDK_ISCSI_FIRST_BURST_LENGTH 8192
|
|
|
|
|
2018-08-10 18:27:02 +00:00
|
|
|
/*
|
|
|
|
* Defines minimum amount in bytes of unsolicited data the iSCSI initiator
|
|
|
|
* may send to the SPDK iSCSI target during the execution of a single
|
|
|
|
* SCSI command.
|
|
|
|
*/
|
|
|
|
#define SPDK_ISCSI_MIN_FIRST_BURST_LENGTH 512
|
|
|
|
|
2019-02-14 07:24:48 +00:00
|
|
|
#define SPDK_ISCSI_MAX_FIRST_BURST_LENGTH 16777215
|
|
|
|
|
2019-02-14 09:37:35 +00:00
|
|
|
/*
|
|
|
|
* Defines default maximum queue depth per connection and this can be
|
|
|
|
* changed by configuration file.
|
|
|
|
*/
|
|
|
|
#define DEFAULT_MAX_QUEUE_DEPTH 64
|
|
|
|
|
2019-10-08 00:30:42 +00:00
|
|
|
/** Defines how long we should wait for a logout request when the target
|
|
|
|
* requests logout to the initiator asynchronously.
|
|
|
|
*/
|
|
|
|
#define ISCSI_LOGOUT_REQUEST_TIMEOUT 30 /* in seconds */
|
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
/** Defines how long we should wait for a TCP close after responding to a
|
|
|
|
* logout request, before terminating the connection ourselves.
|
|
|
|
*/
|
|
|
|
#define ISCSI_LOGOUT_TIMEOUT 5 /* in seconds */
|
|
|
|
|
|
|
|
/* For spdk_iscsi_login_in related function use, we need to avoid the conflict
|
|
|
|
* with other errors
|
|
|
|
* */
|
|
|
|
#define SPDK_ISCSI_LOGIN_ERROR_RESPONSE -1000
|
|
|
|
#define SPDK_ISCSI_LOGIN_ERROR_PARAMETER -1001
|
|
|
|
#define SPDK_ISCSI_PARAMETER_EXCHANGE_NOT_ONCE -1002
|
|
|
|
|
|
|
|
#define ISCSI_AHS_LEN 60
|
|
|
|
|
|
|
|
struct spdk_mobj {
|
2017-12-08 08:12:30 +00:00
|
|
|
struct spdk_mempool *mp;
|
2016-08-02 16:34:45 +00:00
|
|
|
void *buf;
|
|
|
|
};
|
|
|
|
|
2020-01-15 16:51:04 +00:00
|
|
|
/*
|
|
|
|
* Maximum number of SGL elements, i.e.,
|
|
|
|
* BHS, AHS, Header Digest, Data Segment and Data Digest.
|
|
|
|
*/
|
|
|
|
#define SPDK_ISCSI_MAX_SGL_DESCRIPTORS (5)
|
|
|
|
|
2020-01-17 12:58:50 +00:00
|
|
|
typedef void (*iscsi_conn_xfer_complete_cb)(void *cb_arg);
|
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
struct spdk_iscsi_pdu {
|
2019-09-19 04:00:07 +00:00
|
|
|
struct iscsi_bhs bhs;
|
2016-08-02 16:34:45 +00:00
|
|
|
struct spdk_mobj *mobj;
|
2019-10-10 05:13:49 +00:00
|
|
|
bool is_rejected;
|
2016-08-02 16:34:45 +00:00
|
|
|
uint8_t *data_buf;
|
|
|
|
uint8_t *data;
|
|
|
|
uint8_t header_digest[ISCSI_DIGEST_LEN];
|
|
|
|
uint8_t data_digest[ISCSI_DIGEST_LEN];
|
|
|
|
size_t data_segment_len;
|
|
|
|
int bhs_valid_bytes;
|
|
|
|
int ahs_valid_bytes;
|
2019-10-08 07:43:29 +00:00
|
|
|
uint32_t data_valid_bytes;
|
2016-08-02 16:34:45 +00:00
|
|
|
int hdigest_valid_bytes;
|
|
|
|
int ddigest_valid_bytes;
|
|
|
|
int ref;
|
2016-10-09 04:31:06 +00:00
|
|
|
bool data_from_mempool; /* indicate whether the data buffer is allocated from mempool */
|
2016-08-02 16:34:45 +00:00
|
|
|
struct spdk_iscsi_task *task; /* data tied to a task buffer */
|
|
|
|
uint32_t cmd_sn;
|
|
|
|
uint32_t writev_offset;
|
2019-03-01 05:25:35 +00:00
|
|
|
uint32_t data_buf_len;
|
2019-03-07 03:39:38 +00:00
|
|
|
bool dif_insert_or_strip;
|
|
|
|
struct spdk_dif_ctx dif_ctx;
|
2020-01-15 17:20:21 +00:00
|
|
|
struct spdk_iscsi_conn *conn;
|
2020-01-15 16:51:04 +00:00
|
|
|
|
2020-01-17 12:58:50 +00:00
|
|
|
iscsi_conn_xfer_complete_cb cb_fn;
|
|
|
|
void *cb_arg;
|
|
|
|
|
2020-01-15 16:51:04 +00:00
|
|
|
/* The sock request ends with a 0 length iovec. Place the actual iovec immediately
|
|
|
|
* after it. There is a static assert below to check if the compiler inserted
|
|
|
|
* any unwanted padding */
|
|
|
|
int32_t mapped_length;
|
|
|
|
struct spdk_sock_request sock_req;
|
|
|
|
struct iovec iov[SPDK_ISCSI_MAX_SGL_DESCRIPTORS];
|
2016-08-02 16:34:45 +00:00
|
|
|
TAILQ_ENTRY(spdk_iscsi_pdu) tailq;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 60 bytes of AHS should suffice for now.
|
|
|
|
* This should always be at the end of PDU data structure.
|
|
|
|
* we need to not zero this out when doing memory clear.
|
|
|
|
*/
|
2017-07-13 00:50:19 +00:00
|
|
|
uint8_t ahs[ISCSI_AHS_LEN];
|
2016-10-31 17:39:59 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
uint16_t length; /* iSCSI SenseLength (big-endian) */
|
|
|
|
uint8_t data[32];
|
|
|
|
} sense;
|
2016-08-02 16:34:45 +00:00
|
|
|
};
|
2020-01-15 16:51:04 +00:00
|
|
|
SPDK_STATIC_ASSERT(offsetof(struct spdk_iscsi_pdu,
|
|
|
|
sock_req) + sizeof(struct spdk_sock_request) == offsetof(struct spdk_iscsi_pdu, iov),
|
|
|
|
"Compiler inserted padding between iov and sock_req");
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
enum iscsi_connection_state {
|
|
|
|
ISCSI_CONN_STATE_INVALID = 0,
|
|
|
|
ISCSI_CONN_STATE_RUNNING = 1,
|
2019-10-07 22:55:20 +00:00
|
|
|
ISCSI_CONN_STATE_EXITING = 2,
|
|
|
|
ISCSI_CONN_STATE_EXITED = 3,
|
2016-08-02 16:34:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum iscsi_chap_phase {
|
|
|
|
ISCSI_CHAP_PHASE_NONE = 0,
|
|
|
|
ISCSI_CHAP_PHASE_WAIT_A = 1,
|
|
|
|
ISCSI_CHAP_PHASE_WAIT_NR = 2,
|
|
|
|
ISCSI_CHAP_PHASE_END = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum session_type {
|
|
|
|
SESSION_TYPE_INVALID = 0,
|
|
|
|
SESSION_TYPE_NORMAL = 1,
|
|
|
|
SESSION_TYPE_DISCOVERY = 2,
|
|
|
|
};
|
|
|
|
|
2018-08-20 01:32:30 +00:00
|
|
|
#define ISCSI_CHAP_CHALLENGE_LEN 1024
|
|
|
|
#define ISCSI_CHAP_MAX_USER_LEN 255
|
|
|
|
#define ISCSI_CHAP_MAX_SECRET_LEN 255
|
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
struct iscsi_chap_auth {
|
|
|
|
enum iscsi_chap_phase chap_phase;
|
|
|
|
|
2018-08-20 01:32:30 +00:00
|
|
|
char user[ISCSI_CHAP_MAX_USER_LEN + 1];
|
|
|
|
char secret[ISCSI_CHAP_MAX_SECRET_LEN + 1];
|
|
|
|
char muser[ISCSI_CHAP_MAX_USER_LEN + 1];
|
|
|
|
char msecret[ISCSI_CHAP_MAX_SECRET_LEN + 1];
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
uint8_t chap_id[1];
|
|
|
|
uint8_t chap_mid[1];
|
|
|
|
int chap_challenge_len;
|
|
|
|
uint8_t chap_challenge[ISCSI_CHAP_CHALLENGE_LEN];
|
|
|
|
int chap_mchallenge_len;
|
|
|
|
uint8_t chap_mchallenge[ISCSI_CHAP_CHALLENGE_LEN];
|
|
|
|
};
|
|
|
|
|
2018-08-20 01:32:30 +00:00
|
|
|
struct spdk_iscsi_auth_secret {
|
|
|
|
char user[ISCSI_CHAP_MAX_USER_LEN + 1];
|
|
|
|
char secret[ISCSI_CHAP_MAX_SECRET_LEN + 1];
|
|
|
|
char muser[ISCSI_CHAP_MAX_USER_LEN + 1];
|
|
|
|
char msecret[ISCSI_CHAP_MAX_SECRET_LEN + 1];
|
|
|
|
TAILQ_ENTRY(spdk_iscsi_auth_secret) tailq;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spdk_iscsi_auth_group {
|
|
|
|
int32_t tag;
|
|
|
|
TAILQ_HEAD(, spdk_iscsi_auth_secret) secret_head;
|
|
|
|
TAILQ_ENTRY(spdk_iscsi_auth_group) tailq;
|
|
|
|
};
|
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
struct spdk_iscsi_sess {
|
|
|
|
uint32_t connections;
|
|
|
|
struct spdk_iscsi_conn **conns;
|
|
|
|
|
2017-05-03 19:41:55 +00:00
|
|
|
struct spdk_scsi_port *initiator_port;
|
2016-08-02 16:34:45 +00:00
|
|
|
int tag;
|
|
|
|
|
|
|
|
uint64_t isid;
|
|
|
|
uint16_t tsih;
|
|
|
|
struct spdk_iscsi_tgt_node *target;
|
|
|
|
int queue_depth;
|
|
|
|
|
|
|
|
struct iscsi_param *params;
|
|
|
|
|
|
|
|
enum session_type session_type;
|
|
|
|
uint32_t MaxConnections;
|
|
|
|
uint32_t MaxOutstandingR2T;
|
|
|
|
uint32_t DefaultTime2Wait;
|
|
|
|
uint32_t DefaultTime2Retain;
|
|
|
|
uint32_t FirstBurstLength;
|
|
|
|
uint32_t MaxBurstLength;
|
2018-03-12 09:38:53 +00:00
|
|
|
bool InitialR2T;
|
|
|
|
bool ImmediateData;
|
|
|
|
bool DataPDUInOrder;
|
|
|
|
bool DataSequenceInOrder;
|
2016-08-02 16:34:45 +00:00
|
|
|
uint32_t ErrorRecoveryLevel;
|
|
|
|
|
|
|
|
uint32_t ExpCmdSN;
|
|
|
|
uint32_t MaxCmdSN;
|
|
|
|
|
|
|
|
uint32_t current_text_itt;
|
|
|
|
};
|
|
|
|
|
2018-02-13 05:09:49 +00:00
|
|
|
struct spdk_iscsi_poll_group {
|
|
|
|
struct spdk_poller *poller;
|
2018-02-28 05:55:38 +00:00
|
|
|
struct spdk_poller *nop_poller;
|
2018-02-13 05:09:49 +00:00
|
|
|
STAILQ_HEAD(connections, spdk_iscsi_conn) connections;
|
2018-02-14 02:26:10 +00:00
|
|
|
struct spdk_sock_group *sock_group;
|
2019-07-30 03:00:15 +00:00
|
|
|
TAILQ_ENTRY(spdk_iscsi_poll_group) link;
|
2018-02-13 05:09:49 +00:00
|
|
|
};
|
|
|
|
|
2018-03-08 23:19:30 +00:00
|
|
|
struct spdk_iscsi_opts {
|
|
|
|
char *authfile;
|
|
|
|
char *nodebase;
|
2018-07-17 17:44:22 +00:00
|
|
|
int32_t timeout;
|
|
|
|
int32_t nopininterval;
|
2018-08-22 01:29:23 +00:00
|
|
|
bool disable_chap;
|
|
|
|
bool require_chap;
|
|
|
|
bool mutual_chap;
|
|
|
|
int32_t chap_group;
|
2018-03-08 23:19:30 +00:00
|
|
|
uint32_t MaxSessions;
|
|
|
|
uint32_t MaxConnectionsPerSession;
|
|
|
|
uint32_t MaxConnections;
|
|
|
|
uint32_t MaxQueueDepth;
|
|
|
|
uint32_t DefaultTime2Wait;
|
|
|
|
uint32_t DefaultTime2Retain;
|
2018-08-10 18:27:02 +00:00
|
|
|
uint32_t FirstBurstLength;
|
2018-03-12 09:38:53 +00:00
|
|
|
bool ImmediateData;
|
2018-03-08 23:19:30 +00:00
|
|
|
uint32_t ErrorRecoveryLevel;
|
2018-03-12 09:38:53 +00:00
|
|
|
bool AllowDuplicateIsid;
|
2018-03-08 23:19:30 +00:00
|
|
|
};
|
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
struct spdk_iscsi_globals {
|
|
|
|
char *authfile;
|
|
|
|
char *nodebase;
|
|
|
|
pthread_mutex_t mutex;
|
2020-01-31 00:10:20 +00:00
|
|
|
uint32_t refcnt;
|
2017-09-30 02:23:27 +00:00
|
|
|
TAILQ_HEAD(, spdk_iscsi_portal) portal_head;
|
2016-08-02 16:34:45 +00:00
|
|
|
TAILQ_HEAD(, spdk_iscsi_portal_grp) pg_head;
|
|
|
|
TAILQ_HEAD(, spdk_iscsi_init_grp) ig_head;
|
2017-11-29 06:56:19 +00:00
|
|
|
TAILQ_HEAD(, spdk_iscsi_tgt_node) target_head;
|
2018-08-20 01:32:30 +00:00
|
|
|
TAILQ_HEAD(, spdk_iscsi_auth_group) auth_group_head;
|
2019-07-30 03:00:15 +00:00
|
|
|
TAILQ_HEAD(, spdk_iscsi_poll_group) poll_group_head;
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2018-07-17 17:44:22 +00:00
|
|
|
int32_t timeout;
|
|
|
|
int32_t nopininterval;
|
2018-08-22 01:29:23 +00:00
|
|
|
bool disable_chap;
|
|
|
|
bool require_chap;
|
|
|
|
bool mutual_chap;
|
|
|
|
int32_t chap_group;
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
uint32_t MaxSessions;
|
|
|
|
uint32_t MaxConnectionsPerSession;
|
|
|
|
uint32_t MaxConnections;
|
2017-11-22 05:58:25 +00:00
|
|
|
uint32_t MaxQueueDepth;
|
2016-08-02 16:34:45 +00:00
|
|
|
uint32_t DefaultTime2Wait;
|
|
|
|
uint32_t DefaultTime2Retain;
|
2018-08-10 18:27:02 +00:00
|
|
|
uint32_t FirstBurstLength;
|
2018-03-12 09:38:53 +00:00
|
|
|
bool ImmediateData;
|
2016-08-02 16:34:45 +00:00
|
|
|
uint32_t ErrorRecoveryLevel;
|
2018-03-12 09:38:53 +00:00
|
|
|
bool AllowDuplicateIsid;
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2017-12-08 08:12:30 +00:00
|
|
|
struct spdk_mempool *pdu_pool;
|
|
|
|
struct spdk_mempool *pdu_immediate_data_pool;
|
|
|
|
struct spdk_mempool *pdu_data_out_pool;
|
|
|
|
struct spdk_mempool *session_pool;
|
2017-12-06 04:41:52 +00:00
|
|
|
struct spdk_mempool *task_pool;
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
struct spdk_iscsi_sess **session;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ISCSI_SECURITY_NEGOTIATION_PHASE 0
|
|
|
|
#define ISCSI_OPERATIONAL_NEGOTIATION_PHASE 1
|
|
|
|
#define ISCSI_NSG_RESERVED_CODE 2
|
|
|
|
#define ISCSI_FULL_FEATURE_PHASE 3
|
|
|
|
|
2019-10-28 22:24:28 +00:00
|
|
|
/* logout reason */
|
|
|
|
#define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0
|
|
|
|
#define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1
|
|
|
|
#define ISCSI_LOGOUT_REASON_REMOVE_CONN_FOR_RECOVERY 2
|
|
|
|
|
2016-08-02 16:34:45 +00:00
|
|
|
enum spdk_error_codes {
|
|
|
|
SPDK_ISCSI_CONNECTION_FATAL = -1,
|
|
|
|
SPDK_PDU_FATAL = -2,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DGET24(B) \
|
|
|
|
((( (uint32_t) *((uint8_t *)(B)+0)) << 16) \
|
|
|
|
| (((uint32_t) *((uint8_t *)(B)+1)) << 8) \
|
|
|
|
| (((uint32_t) *((uint8_t *)(B)+2)) << 0))
|
|
|
|
|
|
|
|
#define DSET24(B,D) \
|
|
|
|
(((*((uint8_t *)(B)+0)) = (uint8_t)((uint32_t)(D) >> 16)), \
|
|
|
|
((*((uint8_t *)(B)+1)) = (uint8_t)((uint32_t)(D) >> 8)), \
|
|
|
|
((*((uint8_t *)(B)+2)) = (uint8_t)((uint32_t)(D) >> 0)))
|
|
|
|
|
|
|
|
#define xstrdup(s) (s ? strdup(s) : (char *)NULL)
|
|
|
|
|
2020-04-13 21:05:20 +00:00
|
|
|
extern struct spdk_iscsi_globals g_iscsi;
|
2018-05-14 23:24:19 +00:00
|
|
|
extern struct spdk_iscsi_opts *g_spdk_iscsi_opts;
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
struct spdk_iscsi_task;
|
2018-05-07 23:33:15 +00:00
|
|
|
struct spdk_json_write_ctx;
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2018-02-22 02:26:00 +00:00
|
|
|
typedef void (*spdk_iscsi_init_cb)(void *cb_arg, int rc);
|
|
|
|
|
|
|
|
void spdk_iscsi_init(spdk_iscsi_init_cb cb_fn, void *cb_arg);
|
2017-11-10 17:02:00 +00:00
|
|
|
typedef void (*spdk_iscsi_fini_cb)(void *arg);
|
|
|
|
void spdk_iscsi_fini(spdk_iscsi_fini_cb cb_fn, void *cb_arg);
|
2020-04-16 02:18:51 +00:00
|
|
|
void shutdown_iscsi_conns_done(void);
|
2017-06-13 17:38:16 +00:00
|
|
|
void spdk_iscsi_config_text(FILE *fp);
|
2018-05-07 23:33:15 +00:00
|
|
|
void spdk_iscsi_config_json(struct spdk_json_write_ctx *w);
|
2017-06-13 17:38:16 +00:00
|
|
|
|
2020-04-16 02:18:51 +00:00
|
|
|
struct spdk_iscsi_opts *iscsi_opts_alloc(void);
|
|
|
|
void iscsi_opts_free(struct spdk_iscsi_opts *opts);
|
|
|
|
struct spdk_iscsi_opts *iscsi_opts_copy(struct spdk_iscsi_opts *src);
|
|
|
|
void iscsi_opts_info_json(struct spdk_json_write_ctx *w);
|
|
|
|
int iscsi_set_discovery_auth(bool disable_chap, bool require_chap,
|
|
|
|
bool mutual_chap, int32_t chap_group);
|
|
|
|
int iscsi_chap_get_authinfo(struct iscsi_chap_auth *auth, const char *authuser,
|
|
|
|
int ag_tag);
|
|
|
|
int iscsi_add_auth_group(int32_t tag, struct spdk_iscsi_auth_group **_group);
|
|
|
|
struct spdk_iscsi_auth_group *iscsi_find_auth_group_by_tag(int32_t tag);
|
|
|
|
void iscsi_delete_auth_group(struct spdk_iscsi_auth_group *group);
|
|
|
|
int iscsi_auth_group_add_secret(struct spdk_iscsi_auth_group *group,
|
|
|
|
const char *user, const char *secret,
|
|
|
|
const char *muser, const char *msecret);
|
|
|
|
int iscsi_auth_group_delete_secret(struct spdk_iscsi_auth_group *group,
|
|
|
|
const char *user);
|
|
|
|
void iscsi_auth_groups_info_json(struct spdk_json_write_ctx *w);
|
|
|
|
|
|
|
|
void iscsi_task_response(struct spdk_iscsi_conn *conn,
|
|
|
|
struct spdk_iscsi_task *task);
|
|
|
|
int iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, int iovcnt,
|
|
|
|
struct spdk_iscsi_pdu *pdu, uint32_t *mapped_length);
|
|
|
|
int iscsi_handle_incoming_pdus(struct spdk_iscsi_conn *conn);
|
|
|
|
void iscsi_task_mgmt_response(struct spdk_iscsi_conn *conn,
|
2016-08-02 16:34:45 +00:00
|
|
|
struct spdk_iscsi_task *task);
|
|
|
|
|
2020-04-16 02:10:57 +00:00
|
|
|
void iscsi_free_sess(struct spdk_iscsi_sess *sess);
|
|
|
|
void iscsi_clear_all_transfer_task(struct spdk_iscsi_conn *conn,
|
|
|
|
struct spdk_scsi_lun *lun,
|
|
|
|
struct spdk_iscsi_pdu *pdu);
|
|
|
|
bool iscsi_del_transfer_task(struct spdk_iscsi_conn *conn, uint32_t CmdSN);
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2020-04-16 02:18:51 +00:00
|
|
|
uint32_t iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu);
|
|
|
|
uint32_t iscsi_pdu_calc_data_digest(struct spdk_iscsi_pdu *pdu);
|
2016-08-02 16:34:45 +00:00
|
|
|
|
|
|
|
/* Memory management */
|
2020-04-16 02:10:57 +00:00
|
|
|
void iscsi_put_pdu(struct spdk_iscsi_pdu *pdu);
|
|
|
|
struct spdk_iscsi_pdu *iscsi_get_pdu(struct spdk_iscsi_conn *conn);
|
2020-04-16 02:18:51 +00:00
|
|
|
void iscsi_op_abort_task_set(struct spdk_iscsi_task *task,
|
|
|
|
uint8_t function);
|
|
|
|
void iscsi_queue_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task);
|
2016-08-02 16:34:45 +00:00
|
|
|
|
2019-10-08 07:43:29 +00:00
|
|
|
static inline uint32_t
|
2020-04-16 02:10:57 +00:00
|
|
|
iscsi_get_max_immediate_data_size(void)
|
2016-08-02 16:34:45 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Specify enough extra space in addition to FirstBurstLength to
|
|
|
|
* account for a header digest, data digest and additional header
|
|
|
|
* segments (AHS). These are not normally used but they do not
|
|
|
|
* take up much space and we need to make sure the worst-case scenario
|
|
|
|
* can be satisified by the size returned here.
|
|
|
|
*/
|
2020-04-13 21:05:20 +00:00
|
|
|
return g_iscsi.FirstBurstLength +
|
2016-08-02 16:34:45 +00:00
|
|
|
ISCSI_DIGEST_LEN + /* data digest */
|
|
|
|
ISCSI_DIGEST_LEN + /* header digest */
|
|
|
|
8 + /* bidirectional AHS */
|
|
|
|
52; /* extended CDB AHS (for a 64-byte CDB) */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SPDK_ISCSI_H */
|