4 * Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>.
5 * Copyright (c) Intel Corporation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef SPDK_ISCSI_TGT_NODE_H_
36 #define SPDK_ISCSI_TGT_NODE_H_
41 #include "spdk/scsi.h"
43 struct spdk_iscsi_conn
;
45 #define SPDK_ISCSI_MAX_QUEUE_DEPTH 64
46 #define MAX_TARGET_MAP 256
47 #define SPDK_TN_TAG_MAX 0x0000ffff
49 struct spdk_iscsi_tgt_node_map
{
50 struct spdk_iscsi_portal_grp
*pg
;
51 struct spdk_iscsi_init_grp
*ig
;
54 struct spdk_iscsi_tgt_node
{
59 pthread_mutex_t mutex
;
61 int auth_chap_disabled
;
62 int auth_chap_required
;
69 struct spdk_scsi_dev
*dev
;
71 * Counts number of active iSCSI connections associated with this
74 uint32_t num_active_conns
;
78 struct spdk_iscsi_tgt_node_map map
[MAX_TARGET_MAP
];
81 int spdk_iscsi_init_tgt_nodes(void);
83 int spdk_iscsi_shutdown_tgt_nodes(void);
84 int spdk_iscsi_shutdown_tgt_node_by_name(const char *target_name
);
85 int spdk_iscsi_send_tgts(struct spdk_iscsi_conn
*conn
, const char *iiqn
,
86 const char *iaddr
, const char *tiqn
, uint8_t *data
, int alloc_len
,
89 struct spdk_iscsi_init_grp
*
90 spdk_iscsi_find_init_grp(int tag
);
92 /* This typedef exists to work around an astyle 2.05 bug.
93 * Remove it when astyle is fixed.
95 typedef struct spdk_iscsi_tgt_node _spdk_iscsi_tgt_node
;
97 _spdk_iscsi_tgt_node
*
98 spdk_iscsi_tgt_node_construct(int target_index
,
99 const char *name
, const char *alias
,
100 int *pg_tag_list
, int *ig_tag_list
, uint16_t num_maps
,
101 char *lun_name_list
[], int *lun_id_list
, int num_luns
,
103 int no_auth_chap
, int auth_chap
, int auth_chap_mutual
, int auth_group
,
104 int header_digest
, int data_digest
);
106 int spdk_iscsi_tgt_node_access(struct spdk_iscsi_conn
*conn
,
107 struct spdk_iscsi_tgt_node
*target
, const char *iqn
,
109 struct spdk_iscsi_tgt_node
*spdk_iscsi_find_tgt_node(const char *target_name
);
110 int spdk_iscsi_tgt_node_reset(struct spdk_iscsi_tgt_node
*target
,
112 int spdk_iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn
*conn
,
113 struct spdk_iscsi_tgt_node
*target
);
114 void spdk_iscsi_tgt_node_delete_map(struct spdk_iscsi_portal_grp
*portal_group
,
115 struct spdk_iscsi_init_grp
*initiator_group
);
116 #endif /* SPDK_ISCSI_TGT_NODE_H_ */