Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_login.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 /**
34  * @file
35  * Defines the iSCSI Login interface functions.
36  *
37  * This module will queue requests when insufficent resources exist to send
38  * the request immediately.
39  */
40 
41 #ifndef _OCS_LOGIN_H
42 #define _OCS_LOGIN_H
43 
44 /* Used as a bit mask to identify key flags */
45 #define KEY_FLAG_SEND_INI (1 << 0) /* specifies the sender of the key */
46 #define KEY_FLAG_SEND_TGT (1 << 1)
47 #define KEY_FLAG_SEND_BOTH (KEY_FLAG_SEND_INI | KEY_FLAG_SEND_TGT)
48 #define KEY_FLAG_PHASE_SEC (1 << 2) /* specifies the valid phases for the key */
49 #define KEY_FLAG_PHASE_OPER (1 << 3)
50 #define KEY_FLAG_PHASE_FFP (1 << 4)
51 #define KEY_FLAG_PHASE_SEC_OPER (KEY_FLAG_PHASE_SEC | KEY_FLAG_PHASE_OPER)
52 #define KEY_FLAG_PHASE_ALL (KEY_FLAG_PHASE_SEC | KEY_FLAG_PHASE_OPER | KEY_FLAG_PHASE_FFP)
53 #define KEY_FLAG_USE_LEADING (1 << 5) /* Valid on leading login only */
54 #define KEY_FLAG_USE_LOGIN (1 << 6) /* Valid on any login */
55 #define KEY_FLAG_VALID_DISC (1 << 7) /* Valid on discovery sessions */
56 #define KEY_FLAG_NEGOTIATE (1 << 8) /* This code should automatically negotiate the key */
57 #define KEY_FLAG_DEFAULT (1 << 9) /* Value is default, negotiation not required */
58 #define KEY_FLAG_ALLOW_MULTI (1 << 10) /* do not error if key is sent multiple times */
59 #define KEY_FLAG_ALLOW_LARGE (1 << 11) /* do not error if key value is > 255 characters */
60 
61 /**
62  * @brief enum identifying valid login keys.
63  */
64 typedef enum {
65  /* Security Keys */
74 
75  /* Operational Keys */
92 
93  /* Steering Keys */
98 
99  /* Chap Keys */
105 
106  KEY_MAX /* Must be last */
108 
109 /**
110  * @brief Defines the state of the CHAP negotiation.
111  */
112 typedef enum {
120 
121 
122 /**
123  * @brief Defines the fields required to track the login keys during negotiation.
124  */
125 typedef struct {
126  char *key_name;
127  uint32_t flags;
129 
131 
132 #define OCS_LOGIN_ERROR_WRONG_STATE -10
133 #define OCS_LOGIN_ERROR_VIRT_ARRAY_TOO_SMALL -11
134 #define OCS_LOGIN_REQUEST_QUEUED -12
135 #define OCS_LOGIN_NO_QUEUING_RESOURCES -13
136 
140 void ocs_iscsi_login_retry(ocs_cxn_t *cxn);
141 
142 int32_t ocs_iscsi_send_login(ocs_cxn_t *cxn,
143  bool is_discovery,
144  char *tgt_name);
145 
147  ocs_hal_rq_buffer_t *hdr,
148  uint32_t hdr_len,
149  ocs_hal_rq_buffer_t *data,
150  uint32_t data_len);
151 
152 int32_t ocs_iscsi_send_login_rsp_invalid_during_login(ocs_cxn_t *cxn,
153  uint32_t itt);
154 
155 int32_t ocs_iscsi_recv_login_rsp(ocs_cxn_t *cxn,
156  ocs_hal_rq_buffer_t *hdr,
157  uint32_t hdr_len,
158  ocs_hal_rq_buffer_t *data,
159  uint32_t data_len);
160 
161 void ocs_iscsi_ffp_text_timeout(void *arg);
162 
164  ocs_hal_rq_buffer_t *hdr,
165  uint32_t hdr_len,
166  ocs_hal_rq_buffer_t *data,
167  uint32_t data_len,
168  uint8_t *reject_reason);
169 
170 int32_t ocs_iscsi_send_logout(ocs_cxn_t *cxn,
171  uint8_t immediate,
172  uint8_t reason_code);
173 
175  ocs_hal_rq_buffer_t *hdr,
176  uint32_t hdr_len);
177 
178 int32_t ocs_iscsi_send_logout_rsp(ocs_cxn_t *cxn,
179  uint8_t response,
180  uint32_t itt);
181 
182 int32_t ocs_iscsi_recv_logout_rsp(ocs_cxn_t *cxn,
183  ocs_hal_rq_buffer_t *hdr,
184  uint32_t hdr_len);
185 
186 int32_t ocs_iscsi_send_nop_out(ocs_cxn_t *cxn,
187  uint64_t lun,
188  uint32_t itt,
189  uint32_t ttt,
190  char *data_ptr,
191  uint32_t data_len);
192 
193 int32_t ocs_iscsi_send_nop_in(ocs_cxn_t *cxn,
194  uint64_t lun,
195  uint32_t itt,
196  uint32_t ttt,
197  char *data_ptr,
198  uint32_t data_len);
199 
200 int32_t ocs_iscsi_recv_nop_in(ocs_cxn_t *cxn,
201  ocs_hal_rq_buffer_t *hdr,
202  uint32_t hdr_len,
203  ocs_hal_rq_buffer_t *data,
204  uint32_t data_len);
205 
207  ocs_hal_rq_buffer_t *hdr,
208  uint32_t hdr_len,
209  ocs_hal_rq_buffer_t *data,
210  uint32_t data_len);
211 
212 int32_t ocs_iscsi_send_reject(ocs_cxn_t *cxn,
213  void *hdr,
214  uint32_t hdr_len,
215  uint8_t reason);
216 
217 int32_t ocs_iscsi_send_async(ocs_cxn_t *cxn,
218  void *payload,
219  uint32_t payload_len,
220  uint8_t reason,
221  uint64_t lun,
222  uint16_t param1,
223  uint16_t param2,
224  uint16_t param3);
225 
226 int32_t ocs_iscsi_are_login_reqs_outstanding(ocs_cxn_t *cxn);
227 
228 void ocs_iscsi_cbit_cleanup(ocs_cxn_t *cxn);
229 
230 #endif /* !_OCS_LOGIN_H */
231 
232 /* vim: set noexpandtab textwidth=120: */
ocs_login_key_t
enum identifying valid login keys.
Definition: ocs_login.h:64
int32_t ocs_iscsi_send_logout(ocs_cxn_t *cxn, uint8_t immediate, uint8_t reason_code)
Function to send a logout PDU.
Definition: ocs_login.c:3992
void ocs_iscsi_ffp_text_timeout(void *arg)
This function is called to check for stalled text negotiations for a connection on a target...
Definition: ocs_login.c:3496
void ocs_iscsi_cbit_cleanup(ocs_cxn_t *cxn)
Sends the login parameters to the firmware.
Definition: ocs_login.c:2410
int32_t ocs_iscsi_recv_login_rsp(ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len)
Function to process a login response PDU.
Definition: ocs_login.c:2893
ocs_pdu_process_rtn_e ocs_iscsi_recv_login(ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len)
Function to process a login PDU on a target.
Definition: ocs_login.c:2450
int32_t ocs_iscsi_send_async(ocs_cxn_t *cxn, void *payload, uint32_t payload_len, uint8_t reason, uint64_t lun, uint16_t param1, uint16_t param2, uint16_t param3)
Sends a asynchronous PDU with an optional payload.
Definition: ocs_login.c:4792
ocs_pdu_process_rtn_e
iSCSI PDU processing return codes
Definition: ocs_iscsi.h:99
int32_t ocs_iscsi_are_login_reqs_outstanding(ocs_cxn_t *cxn)
Checks to see if there are any retry or login IOs active on a connection.
Definition: ocs_login.c:245
int32_t ocs_iscsi_login_initialize(ocs_iscsi_t *iscsi)
Initialize the login and retry object used within the login module.
Definition: ocs_login.c:200
Defines the fields required to track the login keys during negotiation.
Definition: ocs_login.h:125
ocs_chap_state_e
Defines the state of the CHAP negotiation.
Definition: ocs_login.h:112
int32_t ocs_iscsi_send_login(ocs_cxn_t *cxn, bool is_discovery, char *tgt_name)
Function to send an initial login PDU.
Definition: ocs_login.c:3182
ocs_hal_rtn_e
defines common HAL return statuses.
Definition: ocs_hal.h:78
const ocs_login_key_def_t ocs_login_key_defs[KEY_MAX]
Definition: ocs_login.c:58
ocs_pdu_process_rtn_e ocs_iscsi_recv_text(ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len, uint8_t *reject_reason)
Function to process a text PDU.
Definition: ocs_login.c:3546
void ocs_iscsi_login_teardown(ocs_iscsi_t *iscsi)
Releases the login and retry object used within the login module.
Definition: ocs_login.c:227
int32_t ocs_iscsi_send_reject(ocs_cxn_t *cxn, void *hdr, uint32_t hdr_len, uint8_t reason)
Sends a reject PDU for the supplied PDU header.
Definition: ocs_login.c:4652
int32_t ocs_iscsi_send_nop_out(ocs_cxn_t *cxn, uint64_t lun, uint32_t itt, uint32_t ttt, char *data_ptr, uint32_t data_len)
Send NOP-Out from an initiator.
Definition: ocs_login.c:4250
iSCSI object
Definition: ocs_iscsi.h:293
ocs_pdu_process_rtn_e ocs_iscsi_recv_nop_out(ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len)
Handle NOP-OUT from an initiator.
Definition: ocs_login.c:4560
Defines a wrapper for the RQ payload buffers so that we can place it back on the proper queue...
Definition: ocs_hal.h:694
ocs_pdu_process_rtn_e ocs_iscsi_recv_logout(ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len)
Function to process a logout PDU.
Definition: ocs_login.c:3881
int32_t ocs_iscsi_send_nop_in(ocs_cxn_t *cxn, uint64_t lun, uint32_t itt, uint32_t ttt, char *data_ptr, uint32_t data_len)
Send NOP-In from a target.
Definition: ocs_login.c:4404
int32_t ocs_iscsi_send_login_rsp_invalid_during_login(ocs_cxn_t *cxn, uint32_t itt)
Function to send an login Response PDU (invalid during login).
Definition: ocs_login.c:2815
void ocs_iscsi_login_retry(ocs_cxn_t *cxn)
Attempt to start a request on the retry queue.
Definition: ocs_login.c:402
int32_t ocs_iscsi_send_logout_rsp(ocs_cxn_t *cxn, uint8_t response, uint32_t itt)
Function to send a logout response PDU.
Definition: ocs_login.c:4095
int32_t ocs_iscsi_recv_logout_rsp(ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len)
Handle logout response from a target.
Definition: ocs_login.c:4163
int32_t ocs_iscsi_recv_nop_in(ocs_cxn_t *cxn, ocs_hal_rq_buffer_t *hdr, uint32_t hdr_len, ocs_hal_rq_buffer_t *data, uint32_t data_len)
Handle NOP-IN from a target.
Definition: ocs_login.c:4503
ocs_hal_rtn_e ocs_iscsi_login_cxn_cleanup(ocs_cxn_t *cxn)
Frees any retry objects for the connection.
Definition: ocs_login.c:277