iscsi.h File Reference

iSCSI protocol More...

#include <stdint.h>
#include <gpxe/socket.h>
#include <gpxe/scsi.h>
#include <gpxe/chap.h>
#include <gpxe/refcnt.h>
#include <gpxe/xfer.h>
#include <gpxe/process.h>

Go to the source code of this file.

Data Structures

union  iscsi_segment_lengths
 iSCSI segment lengths More...
struct  iscsi_bhs_common
 iSCSI basic header segment common fields More...
struct  iscsi_bhs_common_response
 iSCSI basic header segment common request fields More...
struct  iscsi_bhs_login_request
 iSCSI login request basic header segment More...
struct  iscsi_bhs_login_response
 iSCSI login response basic header segment More...
struct  iscsi_bhs_scsi_command
 iSCSI SCSI command basic header segment More...
struct  iscsi_bhs_scsi_response
 iSCSI SCSI response basic header segment More...
struct  iscsi_bhs_data_in
 iSCSI data-in basic header segment More...
struct  iscsi_bhs_data_out
 iSCSI data-out basic header segment More...
struct  iscsi_bhs_r2t
 iSCSI request to transfer basic header segment More...
union  iscsi_bhs
 An iSCSI basic header segment. More...
struct  iscsi_session
 An iSCSI session. More...

Defines

#define ISCSI_PORT   3260
 Default iSCSI port.
#define ISCSI_AHS_LEN(segment_lengths)   ( (segment_lengths).bytes.ahs_len )
 The length of the additional header segment, in dwords.
#define ISCSI_DATA_LEN(segment_lengths)   ( ntohl ( (segment_lengths).ahs_and_data_len ) & 0xffffff )
 The length of the data segment, in bytes, excluding any padding.
#define ISCSI_DATA_PAD_LEN(segment_lengths)   ( ( 0 - (segment_lengths).bytes.data_len[2] ) & 0x03 )
 The padding of the data segment, in bytes.
#define ISCSI_SET_LENGTHS(segment_lengths, ahs_len, data_len)
 Set additional header and data segment lengths.
#define ISCSI_OPCODE_MASK   0x3f
 Opcode mask.
#define ISCSI_FLAG_IMMEDIATE   0x40
 Immediate delivery.
#define ISCSI_FLAG_FINAL   0x80
 Final PDU of a sequence.
#define ISCSI_OPCODE_LOGIN_REQUEST   0x03
 Login request opcode.
#define ISCSI_LOGIN_FLAG_TRANSITION   0x80
 Willingness to transition to next stage.
#define ISCSI_LOGIN_FLAG_CONTINUE   0x40
 Key=value pairs continued in subsequent request.
#define ISCSI_LOGIN_CSG_MASK   0x0c
#define ISCSI_LOGIN_CSG_SECURITY_NEGOTIATION   0x00
#define ISCSI_LOGIN_CSG_OPERATIONAL_NEGOTIATION   0x04
#define ISCSI_LOGIN_CSG_FULL_FEATURE_PHASE   0x0c
#define ISCSI_LOGIN_NSG_MASK   0x03
#define ISCSI_LOGIN_NSG_SECURITY_NEGOTIATION   0x00
#define ISCSI_LOGIN_NSG_OPERATIONAL_NEGOTIATION   0x01
#define ISCSI_LOGIN_NSG_FULL_FEATURE_PHASE   0x03
#define ISCSI_ISID_IANA   0x40000000
 ISID IANA format marker.
#define IANA_EN_FEN_SYSTEMS   10019
 Fen Systems Ltd.
#define ISCSI_OPCODE_LOGIN_RESPONSE   0x23
 Login response opcode.
#define ISCSI_STATUS_SUCCESS   0x00
#define ISCSI_STATUS_REDIRECT   0x01
#define ISCSI_STATUS_INITIATOR_ERROR   0x02
#define ISCSI_STATUS_INITIATOR_ERROR_AUTHENTICATION   0x01
#define ISCSI_STATUS_INITIATOR_ERROR_AUTHORISATION   0x02
#define ISCSI_STATUS_INITIATOR_ERROR_NOT_FOUND   0x03
#define ISCSI_STATUS_INITIATOR_ERROR_REMOVED   0x04
#define ISCSI_STATUS_TARGET_ERROR   0x03
#define ISCSI_OPCODE_SCSI_COMMAND   0x01
 SCSI command opcode.
#define ISCSI_COMMAND_FLAG_READ   0x40
 Command will read data.
#define ISCSI_COMMAND_FLAG_WRITE   0x20
 Command will write data.
#define ISCSI_COMMAND_ATTR_UNTAGGED   0x00
#define ISCSI_COMMAND_ATTR_SIMPLE   0x01
#define ISCSI_COMMAND_ATTR_ORDERED   0x02
#define ISCSI_COMMAND_ATTR_HEAD_OF_QUEUE   0x03
#define ISCSI_COMMAND_ATTR_ACA   0x04
#define ISCSI_OPCODE_SCSI_RESPONSE   0x21
 SCSI response opcode.
#define ISCSI_RESPONSE_COMMAND_COMPLETE   0x00
 SCSI command completed at target.
#define ISCSI_RESPONSE_TARGET_FAILURE   0x01
 SCSI target failure.
#define ISCSI_SENSE_RESPONSE_CODE_OFFSET   2
 SCSI sense response code offset.
#define ISCSI_OPCODE_DATA_IN   0x25
 Data-in opcode.
#define ISCSI_DATA_FLAG_ACKNOWLEDGE   0x40
 Data requires acknowledgement.
#define ISCSI_DATA_FLAG_OVERFLOW   0x04
 Data overflow occurred.
#define ISCSI_DATA_FLAG_UNDERFLOW   0x02
 Data underflow occurred.
#define ISCSI_DATA_FLAG_STATUS   0x01
 SCSI status code and overflow/underflow flags are valid.
#define ISCSI_OPCODE_DATA_OUT   0x05
 Data-out opcode.
#define ISCSI_OPCODE_R2T   0x31
 R2T opcode.
#define ISCSI_STATUS_SECURITY_NEGOTIATION_PHASE
 iSCSI session is currently in the security negotiation phase
#define ISCSI_STATUS_OPERATIONAL_NEGOTIATION_PHASE
 iSCSI session is currently in the operational parameter negotiation phase
#define ISCSI_STATUS_FULL_FEATURE_PHASE   ISCSI_LOGIN_CSG_FULL_FEATURE_PHASE
 iSCSI session is currently in the full feature phase
#define ISCSI_STATUS_PHASE_MASK   ( ISCSI_LOGIN_CSG_MASK | ISCSI_LOGIN_NSG_MASK )
 Mask for all iSCSI session phases.
#define ISCSI_STATUS_STRINGS_SECURITY   0x0100
 iSCSI session needs to send the initial security negotiation strings
#define ISCSI_STATUS_STRINGS_CHAP_ALGORITHM   0x0200
 iSCSI session needs to send the CHAP_A string
#define ISCSI_STATUS_STRINGS_CHAP_RESPONSE   0x0400
 iSCSI session needs to send the CHAP response
#define ISCSI_STATUS_STRINGS_CHAP_CHALLENGE   0x0800
 iSCSI session needs to send the mutual CHAP challenge
#define ISCSI_STATUS_STRINGS_OPERATIONAL   0x1000
 iSCSI session needs to send the operational negotiation strings
#define ISCSI_STATUS_STRINGS_MASK   0xff00
 Mask for all iSCSI "needs to send" flags.
#define ISCSI_STATUS_AUTH_FORWARD_REQUIRED   0x00010000
 Target has requested forward (initiator) authentication.
#define ISCSI_STATUS_AUTH_REVERSE_REQUIRED   0x00020000
 Initiator requires target (reverse) authentication.
#define ISCSI_STATUS_AUTH_REVERSE_OK   0x00040000
 Target authenticated itself correctly.
#define ISCSI_MAX_RETRIES   2
 Maximum number of retries at connecting.

Enumerations

enum  iscsi_tx_state {
  ISCSI_TX_IDLE = 0, ISCSI_TX_BHS, ISCSI_TX_AHS, ISCSI_TX_DATA,
  ISCSI_TX_DATA_PADDING
}
 State of an iSCSI TX engine. More...
enum  iscsi_rx_state { ISCSI_RX_BHS = 0, ISCSI_RX_AHS, ISCSI_RX_DATA, ISCSI_RX_DATA_PADDING }
 State of an iSCSI RX engine. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER)
int iscsi_attach (struct scsi_device *scsi, const char *root_path)
 Attach iSCSI interface.
void iscsi_detach (struct scsi_device *scsi)
 Shut down iSCSI interface.
const char * iscsi_initiator_iqn (void)
 Get iSCSI initiator IQN.


Detailed Description

iSCSI protocol

Definition in file iscsi.h.


Define Documentation

#define ISCSI_PORT   3260

Default iSCSI port.

Definition at line 21 of file iscsi.h.

Referenced by iscsi_handle_targetaddress_value(), and iscsi_parse_root_path().

#define ISCSI_AHS_LEN ( segment_lengths   )     ( (segment_lengths).bytes.ahs_len )

The length of the additional header segment, in dwords.

Definition at line 46 of file iscsi.h.

Referenced by iscsi_socket_deliver_raw().

#define ISCSI_DATA_LEN ( segment_lengths   )     ( ntohl ( (segment_lengths).ahs_and_data_len ) & 0xffffff )

The length of the data segment, in bytes, excluding any padding.

Definition at line 50 of file iscsi.h.

Referenced by iscsi_rx_bhs(), iscsi_socket_deliver_raw(), iscsi_tx_data_out(), iscsi_tx_login_request(), and iscsi_tx_step().

#define ISCSI_DATA_PAD_LEN ( segment_lengths   )     ( ( 0 - (segment_lengths).bytes.data_len[2] ) & 0x03 )

The padding of the data segment, in bytes.

Definition at line 54 of file iscsi.h.

Referenced by iscsi_socket_deliver_raw(), iscsi_tx_data_padding(), and iscsi_tx_step().

#define ISCSI_SET_LENGTHS ( segment_lengths,
ahs_len,
data_len   ) 

Value:

do {    \
        (segment_lengths).ahs_and_data_len =                            \
                htonl ( data_len | ( ahs_len << 24 ) );                 \
        } while ( 0 )
Set additional header and data segment lengths.

Definition at line 58 of file iscsi.h.

Referenced by iscsi_start_data_out(), and iscsi_start_login().

#define ISCSI_OPCODE_MASK   0x3f

Opcode mask.

Definition at line 85 of file iscsi.h.

Referenced by iscsi_rx_data(), iscsi_tx_data(), and iscsi_tx_done().

#define ISCSI_FLAG_IMMEDIATE   0x40

Immediate delivery.

Definition at line 88 of file iscsi.h.

Referenced by iscsi_start_login().

#define ISCSI_FLAG_FINAL   0x80

Final PDU of a sequence.

Definition at line 91 of file iscsi.h.

Referenced by iscsi_data_out_done(), iscsi_rx_data_in(), iscsi_start_command(), and iscsi_start_data_out().

#define ISCSI_OPCODE_LOGIN_REQUEST   0x03

Login request opcode.

Definition at line 156 of file iscsi.h.

Referenced by iscsi_start_login(), iscsi_tx_data(), and iscsi_tx_done().

#define ISCSI_LOGIN_FLAG_TRANSITION   0x80

Willingness to transition to next stage.

Definition at line 159 of file iscsi.h.

Referenced by iscsi_rx_login_response(), and iscsi_start_login().

#define ISCSI_LOGIN_FLAG_CONTINUE   0x40

Key=value pairs continued in subsequent request.

Definition at line 162 of file iscsi.h.

#define ISCSI_LOGIN_CSG_MASK   0x0c

Definition at line 165 of file iscsi.h.

#define ISCSI_LOGIN_CSG_SECURITY_NEGOTIATION   0x00

Definition at line 166 of file iscsi.h.

#define ISCSI_LOGIN_CSG_OPERATIONAL_NEGOTIATION   0x04

Definition at line 167 of file iscsi.h.

#define ISCSI_LOGIN_CSG_FULL_FEATURE_PHASE   0x0c

Definition at line 168 of file iscsi.h.

#define ISCSI_LOGIN_NSG_MASK   0x03

Definition at line 171 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_LOGIN_NSG_SECURITY_NEGOTIATION   0x00

Definition at line 172 of file iscsi.h.

#define ISCSI_LOGIN_NSG_OPERATIONAL_NEGOTIATION   0x01

Definition at line 173 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_LOGIN_NSG_FULL_FEATURE_PHASE   0x03

Definition at line 174 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_ISID_IANA   0x40000000

ISID IANA format marker.

Definition at line 177 of file iscsi.h.

Referenced by iscsi_start_login().

#define IANA_EN_FEN_SYSTEMS   10019

Fen Systems Ltd.

IANA enterprise number

Permission is hereby granted to use Fen Systems Ltd.'s IANA enterprise number with this iSCSI implementation.

Definition at line 184 of file iscsi.h.

Referenced by iscsi_start_login().

#define ISCSI_OPCODE_LOGIN_RESPONSE   0x23

Login response opcode.

Definition at line 226 of file iscsi.h.

Referenced by iscsi_rx_data().

#define ISCSI_STATUS_SUCCESS   0x00

Definition at line 229 of file iscsi.h.

#define ISCSI_STATUS_REDIRECT   0x01

Definition at line 230 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_STATUS_INITIATOR_ERROR   0x02

Definition at line 231 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_STATUS_INITIATOR_ERROR_AUTHENTICATION   0x01

Definition at line 232 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_STATUS_INITIATOR_ERROR_AUTHORISATION   0x02

Definition at line 233 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_STATUS_INITIATOR_ERROR_NOT_FOUND   0x03

Definition at line 234 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_STATUS_INITIATOR_ERROR_REMOVED   0x04

Definition at line 235 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_STATUS_TARGET_ERROR   0x03

Definition at line 236 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_OPCODE_SCSI_COMMAND   0x01

SCSI command opcode.

Definition at line 266 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_FLAG_READ   0x40

Command will read data.

Definition at line 269 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_FLAG_WRITE   0x20

Command will write data.

Definition at line 272 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_ATTR_UNTAGGED   0x00

Definition at line 275 of file iscsi.h.

#define ISCSI_COMMAND_ATTR_SIMPLE   0x01

Definition at line 276 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_ATTR_ORDERED   0x02

Definition at line 277 of file iscsi.h.

#define ISCSI_COMMAND_ATTR_HEAD_OF_QUEUE   0x03

Definition at line 278 of file iscsi.h.

#define ISCSI_COMMAND_ATTR_ACA   0x04

Definition at line 279 of file iscsi.h.

#define ISCSI_OPCODE_SCSI_RESPONSE   0x21

SCSI response opcode.

Definition at line 315 of file iscsi.h.

Referenced by iscsi_rx_data().

#define ISCSI_RESPONSE_COMMAND_COMPLETE   0x00

SCSI command completed at target.

Definition at line 318 of file iscsi.h.

Referenced by iscsi_rx_scsi_response().

#define ISCSI_RESPONSE_TARGET_FAILURE   0x01

SCSI target failure.

Definition at line 321 of file iscsi.h.

#define ISCSI_SENSE_RESPONSE_CODE_OFFSET   2

SCSI sense response code offset.

The SCSI response may contain unsolicited sense data in the data segment. If it does, this is the offset to the sense response code byte, which is the only byte we care about.

Definition at line 329 of file iscsi.h.

Referenced by iscsi_rx_scsi_response().

#define ISCSI_OPCODE_DATA_IN   0x25

Data-in opcode.

Definition at line 367 of file iscsi.h.

Referenced by iscsi_rx_data().

#define ISCSI_DATA_FLAG_ACKNOWLEDGE   0x40

Data requires acknowledgement.

Definition at line 370 of file iscsi.h.

#define ISCSI_DATA_FLAG_OVERFLOW   0x04

Data overflow occurred.

Definition at line 373 of file iscsi.h.

#define ISCSI_DATA_FLAG_UNDERFLOW   0x02

Data underflow occurred.

Definition at line 376 of file iscsi.h.

#define ISCSI_DATA_FLAG_STATUS   0x01

SCSI status code and overflow/underflow flags are valid.

Definition at line 379 of file iscsi.h.

Referenced by iscsi_rx_data_in().

#define ISCSI_OPCODE_DATA_OUT   0x05

Data-out opcode.

Definition at line 415 of file iscsi.h.

Referenced by iscsi_start_data_out(), iscsi_tx_data(), and iscsi_tx_done().

#define ISCSI_OPCODE_R2T   0x31

R2T opcode.

Definition at line 451 of file iscsi.h.

Referenced by iscsi_rx_data().

#define ISCSI_STATUS_SECURITY_NEGOTIATION_PHASE

Value:

iSCSI session is currently in the security negotiation phase

Definition at line 627 of file iscsi.h.

Referenced by iscsi_open_connection().

#define ISCSI_STATUS_OPERATIONAL_NEGOTIATION_PHASE

Value:

iSCSI session is currently in the operational parameter negotiation phase

Definition at line 634 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_STATUS_FULL_FEATURE_PHASE   ISCSI_LOGIN_CSG_FULL_FEATURE_PHASE

iSCSI session is currently in the full feature phase

Definition at line 639 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_STATUS_PHASE_MASK   ( ISCSI_LOGIN_CSG_MASK | ISCSI_LOGIN_NSG_MASK )

Mask for all iSCSI session phases.

Definition at line 642 of file iscsi.h.

Referenced by iscsi_rx_login_response(), and iscsi_start_login().

#define ISCSI_STATUS_STRINGS_SECURITY   0x0100

iSCSI session needs to send the initial security negotiation strings

Definition at line 645 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_open_connection().

#define ISCSI_STATUS_STRINGS_CHAP_ALGORITHM   0x0200

iSCSI session needs to send the CHAP_A string

Definition at line 648 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_handle_authmethod_value().

#define ISCSI_STATUS_STRINGS_CHAP_RESPONSE   0x0400

iSCSI session needs to send the CHAP response

Definition at line 651 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_handle_chap_c_value().

#define ISCSI_STATUS_STRINGS_CHAP_CHALLENGE   0x0800

iSCSI session needs to send the mutual CHAP challenge

Definition at line 654 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_handle_chap_c_value().

#define ISCSI_STATUS_STRINGS_OPERATIONAL   0x1000

iSCSI session needs to send the operational negotiation strings

Definition at line 657 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_rx_login_response().

#define ISCSI_STATUS_STRINGS_MASK   0xff00

Mask for all iSCSI "needs to send" flags.

Definition at line 660 of file iscsi.h.

Referenced by iscsi_login_request_done(), and iscsi_rx_login_response().

#define ISCSI_STATUS_AUTH_FORWARD_REQUIRED   0x00010000

Target has requested forward (initiator) authentication.

Definition at line 663 of file iscsi.h.

Referenced by ibft_fill_target_chap(), and iscsi_handle_authmethod_value().

#define ISCSI_STATUS_AUTH_REVERSE_REQUIRED   0x00020000

Initiator requires target (reverse) authentication.

Definition at line 666 of file iscsi.h.

Referenced by ibft_fill_target_reverse_chap(), iscsi_open_connection(), and iscsi_rx_login_response().

#define ISCSI_STATUS_AUTH_REVERSE_OK   0x00040000

Target authenticated itself correctly.

Definition at line 669 of file iscsi.h.

Referenced by iscsi_handle_chap_r_value(), and iscsi_rx_login_response().

#define ISCSI_MAX_RETRIES   2

Maximum number of retries at connecting.

Definition at line 672 of file iscsi.h.

Referenced by iscsi_socket_close().


Enumeration Type Documentation

State of an iSCSI TX engine.

Enumerator:
ISCSI_TX_IDLE  Nothing to send.
ISCSI_TX_BHS  Sending the basic header segment.
ISCSI_TX_AHS  Sending the additional header segment.
ISCSI_TX_DATA  Sending the data segment.
ISCSI_TX_DATA_PADDING  Sending the data segment padding.

Definition at line 470 of file iscsi.h.

00470                     {
00471         /** Nothing to send */
00472         ISCSI_TX_IDLE = 0,
00473         /** Sending the basic header segment */
00474         ISCSI_TX_BHS,
00475         /** Sending the additional header segment */
00476         ISCSI_TX_AHS,
00477         /** Sending the data segment */
00478         ISCSI_TX_DATA,
00479         /** Sending the data segment padding */
00480         ISCSI_TX_DATA_PADDING,
00481 };

State of an iSCSI RX engine.

Enumerator:
ISCSI_RX_BHS  Receiving the basic header segment.
ISCSI_RX_AHS  Receiving the additional header segment.
ISCSI_RX_DATA  Receiving the data segment.
ISCSI_RX_DATA_PADDING  Receiving the data segment padding.

Definition at line 484 of file iscsi.h.

00484                     {
00485         /** Receiving the basic header segment */
00486         ISCSI_RX_BHS = 0,
00487         /** Receiving the additional header segment */
00488         ISCSI_RX_AHS,
00489         /** Receiving the data segment */
00490         ISCSI_RX_DATA,
00491         /** Receiving the data segment padding */
00492         ISCSI_RX_DATA_PADDING,
00493 };


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

int iscsi_attach ( struct scsi_device scsi,
const char *  root_path 
)

Attach iSCSI interface.

Parameters:
scsi SCSI device
root_path iSCSI root path (as per RFC4173)
Return values:
rc Return status code

Definition at line 1746 of file iscsi.c.

References scsi_device::backend, scsi_device::command, DBGC, EINVAL, ENOMEM, ENOTSUP_DISCOVERY, refcnt::free, iscsi_command(), iscsi_free(), iscsi_initiator_password, iscsi_initiator_username, iscsi_parse_root_path(), iscsi_set_auth(), iscsi_target_password, iscsi_target_username, iscsi_tx_step(), iscsi_session::process, process_init(), ref_get(), ref_put(), iscsi_session::refcnt, iscsi_session::socket, iscsi_session::target_address, iscsi_session::target_iqn, xfer_init(), and zalloc().

Referenced by iscsiboot().

01746                                                                      {
01747         struct iscsi_session *iscsi;
01748         int rc;
01749 
01750         /* Allocate and initialise structure */
01751         iscsi = zalloc ( sizeof ( *iscsi ) );
01752         if ( ! iscsi )
01753                 return -ENOMEM;
01754         iscsi->refcnt.free = iscsi_free;
01755         xfer_init ( &iscsi->socket, &iscsi_socket_operations, &iscsi->refcnt );
01756         process_init ( &iscsi->process, iscsi_tx_step, &iscsi->refcnt );
01757 
01758         /* Parse root path */
01759         if ( ( rc = iscsi_parse_root_path ( iscsi, root_path ) ) != 0 )
01760                 goto err;
01761         /* Set fields not specified by root path */
01762         if ( ( rc = iscsi_set_auth ( iscsi,
01763                                      iscsi_initiator_username,
01764                                      iscsi_initiator_password,
01765                                      iscsi_target_username,
01766                                      iscsi_target_password ) ) != 0 )
01767                 goto err;
01768 
01769         /* Sanity checks */
01770         if ( ! iscsi->target_address ) {
01771                 DBGC ( iscsi, "iSCSI %p does not yet support discovery\n",
01772                        iscsi );
01773                 rc = -ENOTSUP_DISCOVERY;
01774                 goto err;
01775         }
01776         if ( ! iscsi->target_iqn ) {
01777                 DBGC ( iscsi, "iSCSI %p no target address supplied in %s\n",
01778                        iscsi, root_path );
01779                 rc = -EINVAL;
01780                 goto err;
01781         }
01782 
01783         /* Attach parent interface, mortalise self, and return */
01784         scsi->backend = ref_get ( &iscsi->refcnt );
01785         scsi->command = iscsi_command;
01786         ref_put ( &iscsi->refcnt );
01787         return 0;
01788         
01789  err:
01790         ref_put ( &iscsi->refcnt );
01791         return rc;
01792 }

void iscsi_detach ( struct scsi_device scsi  ) 

Shut down iSCSI interface.

Parameters:
scsi SCSI device

Definition at line 1599 of file iscsi.c.

References scsi_device::backend, scsi_device::command, container_of, iscsi_close_connection(), NULL, iscsi_session::process, process_del(), ref_put(), scsi_detached_command(), and iscsi_session::socket.

Referenced by iscsiboot().

01599                                                {
01600         struct iscsi_session *iscsi =
01601                 container_of ( scsi->backend, struct iscsi_session, refcnt );
01602 
01603         xfer_nullify ( &iscsi->socket );
01604         iscsi_close_connection ( iscsi, 0 );
01605         process_del ( &iscsi->process );
01606         scsi->command = scsi_detached_command;
01607         ref_put ( scsi->backend );
01608         scsi->backend = NULL;
01609 }

const char* iscsi_initiator_iqn ( void   ) 

Get iSCSI initiator IQN.

Parameters:
iscsi iSCSI session
Return values:
rc Return status code

Definition at line 1947 of file iscsi.c.

References iscsi_default_initiator_iqn, and iscsi_explicit_initiator_iqn.

Referenced by ibft_fill_initiator(), and iscsi_build_login_request_strings().

01947                                           {
01948 
01949         if ( iscsi_explicit_initiator_iqn )
01950                 return iscsi_explicit_initiator_iqn;
01951         if ( iscsi_default_initiator_iqn )
01952                 return iscsi_default_initiator_iqn;
01953         return "iqn.2000-09.org.etherboot:UNKNOWN";
01954 }


Generated on Tue Apr 6 20:01:51 2010 for gPXE by  doxygen 1.5.7.1