iPXE
Data Structures | Defines | Enumerations | Functions
iscsi.h File Reference

iSCSI protocol More...

#include <stdint.h>
#include <ipxe/socket.h>
#include <ipxe/scsi.h>
#include <ipxe/chap.h>
#include <ipxe/refcnt.h>
#include <ipxe/xfer.h>
#include <ipxe/process.h>
#include <ipxe/acpi.h>
#include <ipxe/settings.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...
struct  iscsi_nop_in
 iSCSI NOP-In 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_TAG_MAGIC   0x18ae0000
 iSCSI tag magic marker
#define ISCSI_TAG_RESERVED   0xffffffff
 iSCSI reserved tag value
#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_STATUS_TARGET_ERROR_UNAVAILABLE   0x01
#define ISCSI_STATUS_TARGET_ERROR_NO_RESOURCES   0x02
#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_RESPONSE_FLAG_OVERFLOW   0x20
 Data overflow occurred.
#define ISCSI_RESPONSE_FLAG_UNDERFLOW   0x40
 Data underflow occurred.
#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_OPCODE_NOP_IN   0x20
 NOP-In 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_DEFAULT_IQN_PREFIX   "iqn.2010-04.org.ipxe"
 Default initiator IQN prefix.

Enumerations

enum  iscsi_tx_state { ISCSI_TX_IDLE = 0, ISCSI_TX_BHS, ISCSI_TX_AHS, ISCSI_TX_DATA }
 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_OR_UBDL)
struct setting
initiator_iqn_setting 
__setting (SETTING_SANBOOT_EXTRA, initiator-iqn)

Detailed Description

iSCSI protocol

Definition in file iscsi.h.


Define Documentation

#define ISCSI_PORT   3260

Default iSCSI port.

Definition at line 23 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 48 of file iscsi.h.

Referenced by iscsi_socket_deliver().

#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 52 of file iscsi.h.

Referenced by iscsi_rx_bhs(), iscsi_rx_scsi_response(), iscsi_socket_deliver(), 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 56 of file iscsi.h.

Referenced by iscsi_socket_deliver(), iscsi_tx_data_out(), and iscsi_tx_login_request().

#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 60 of file iscsi.h.

Referenced by iscsi_start_data_out(), and iscsi_start_login().

#define ISCSI_OPCODE_MASK   0x3f

Opcode mask.

Definition at line 87 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 90 of file iscsi.h.

Referenced by iscsi_start_login().

#define ISCSI_FLAG_FINAL   0x80

Final PDU of a sequence.

Definition at line 93 of file iscsi.h.

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

#define ISCSI_TAG_MAGIC   0x18ae0000

iSCSI tag magic marker

Definition at line 96 of file iscsi.h.

Referenced by iscsi_new_itt().

#define ISCSI_TAG_RESERVED   0xffffffff

iSCSI reserved tag value

Definition at line 99 of file iscsi.h.

Referenced by iscsi_rx_nop_in().

#define ISCSI_OPCODE_LOGIN_REQUEST   0x03

Login request opcode.

Definition at line 164 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 167 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 170 of file iscsi.h.

#define ISCSI_LOGIN_CSG_MASK   0x0c

Definition at line 173 of file iscsi.h.

Referenced by iscsi_start_login().

Definition at line 174 of file iscsi.h.

Referenced by iscsi_start_login().

Definition at line 175 of file iscsi.h.

Referenced by iscsi_start_login().

Definition at line 176 of file iscsi.h.

#define ISCSI_LOGIN_NSG_MASK   0x03

Definition at line 179 of file iscsi.h.

Referenced by iscsi_rx_login_response().

Definition at line 180 of file iscsi.h.

Definition at line 181 of file iscsi.h.

Referenced by iscsi_rx_login_response().

Definition at line 182 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_ISID_IANA   0x40000000

ISID IANA format marker.

Definition at line 185 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 192 of file iscsi.h.

Referenced by iscsi_start_login().

#define ISCSI_OPCODE_LOGIN_RESPONSE   0x23

Login response opcode.

Definition at line 234 of file iscsi.h.

Referenced by iscsi_rx_data().

#define ISCSI_STATUS_SUCCESS   0x00

Definition at line 237 of file iscsi.h.

#define ISCSI_STATUS_REDIRECT   0x01

Definition at line 238 of file iscsi.h.

Referenced by iscsi_rx_login_response().

#define ISCSI_STATUS_INITIATOR_ERROR   0x02

Definition at line 239 of file iscsi.h.

Referenced by iscsi_status_to_rc().

Definition at line 240 of file iscsi.h.

Referenced by iscsi_status_to_rc().

Definition at line 241 of file iscsi.h.

Referenced by iscsi_status_to_rc().

Definition at line 242 of file iscsi.h.

Referenced by iscsi_status_to_rc().

Definition at line 243 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_STATUS_TARGET_ERROR   0x03

Definition at line 244 of file iscsi.h.

Referenced by iscsi_status_to_rc().

Definition at line 245 of file iscsi.h.

Referenced by iscsi_status_to_rc().

Definition at line 246 of file iscsi.h.

Referenced by iscsi_status_to_rc().

#define ISCSI_OPCODE_SCSI_COMMAND   0x01

SCSI command opcode.

Definition at line 276 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_FLAG_READ   0x40

Command will read data.

Definition at line 279 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_FLAG_WRITE   0x20

Command will write data.

Definition at line 282 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_ATTR_UNTAGGED   0x00

Definition at line 285 of file iscsi.h.

#define ISCSI_COMMAND_ATTR_SIMPLE   0x01

Definition at line 286 of file iscsi.h.

Referenced by iscsi_start_command().

#define ISCSI_COMMAND_ATTR_ORDERED   0x02

Definition at line 287 of file iscsi.h.

Definition at line 288 of file iscsi.h.

#define ISCSI_COMMAND_ATTR_ACA   0x04

Definition at line 289 of file iscsi.h.

#define ISCSI_OPCODE_SCSI_RESPONSE   0x21

SCSI response opcode.

Definition at line 327 of file iscsi.h.

Referenced by iscsi_rx_data().

SCSI command completed at target.

Definition at line 330 of file iscsi.h.

Referenced by iscsi_rx_scsi_response().

#define ISCSI_RESPONSE_TARGET_FAILURE   0x01

SCSI target failure.

Definition at line 333 of file iscsi.h.

#define ISCSI_RESPONSE_FLAG_OVERFLOW   0x20

Data overflow occurred.

Definition at line 336 of file iscsi.h.

#define ISCSI_RESPONSE_FLAG_UNDERFLOW   0x40

Data underflow occurred.

Definition at line 339 of file iscsi.h.

#define ISCSI_OPCODE_DATA_IN   0x25

Data-in opcode.

Definition at line 377 of file iscsi.h.

Referenced by iscsi_rx_data().

#define ISCSI_DATA_FLAG_ACKNOWLEDGE   0x40

Data requires acknowledgement.

Definition at line 380 of file iscsi.h.

#define ISCSI_DATA_FLAG_OVERFLOW   0x04

Data overflow occurred.

Definition at line 383 of file iscsi.h.

Referenced by iscsi_rx_scsi_response().

#define ISCSI_DATA_FLAG_UNDERFLOW   0x02

Data underflow occurred.

Definition at line 386 of file iscsi.h.

Referenced by iscsi_rx_scsi_response().

#define ISCSI_DATA_FLAG_STATUS   0x01

SCSI status code and overflow/underflow flags are valid.

Definition at line 389 of file iscsi.h.

Referenced by iscsi_rx_data_in().

#define ISCSI_OPCODE_DATA_OUT   0x05

Data-out opcode.

Definition at line 425 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 461 of file iscsi.h.

Referenced by iscsi_rx_data().

#define ISCSI_OPCODE_NOP_IN   0x20

NOP-In opcode.

Definition at line 491 of file iscsi.h.

Referenced by iscsi_rx_data().

Value:
( ISCSI_LOGIN_CSG_SECURITY_NEGOTIATION |        \
          ISCSI_LOGIN_NSG_OPERATIONAL_NEGOTIATION )

iSCSI session is currently in the security negotiation phase

Definition at line 657 of file iscsi.h.

Referenced by iscsi_open_connection().

Value:
( ISCSI_LOGIN_CSG_OPERATIONAL_NEGOTIATION |     \
          ISCSI_LOGIN_NSG_FULL_FEATURE_PHASE )

iSCSI session is currently in the operational parameter negotiation phase

Definition at line 664 of file iscsi.h.

Referenced by iscsi_rx_login_response().

iSCSI session is currently in the full feature phase

Definition at line 669 of file iscsi.h.

Referenced by iscsi_rx_login_response(), and iscsi_scsi_window().

Mask for all iSCSI session phases.

Definition at line 672 of file iscsi.h.

Referenced by iscsi_rx_login_response(), iscsi_scsi_window(), and iscsi_start_login().

#define ISCSI_STATUS_STRINGS_SECURITY   0x0100

iSCSI session needs to send the initial security negotiation strings

Definition at line 675 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_open_connection().

iSCSI session needs to send the CHAP_A string

Definition at line 678 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_handle_authmethod_value().

iSCSI session needs to send the CHAP response

Definition at line 681 of file iscsi.h.

Referenced by iscsi_build_login_request_strings(), and iscsi_handle_chap_c_value().

iSCSI session needs to send the mutual CHAP challenge

Definition at line 684 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 687 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 690 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 693 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 696 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 699 of file iscsi.h.

Referenced by iscsi_handle_chap_r_value(), and iscsi_rx_login_response().

#define ISCSI_DEFAULT_IQN_PREFIX   "iqn.2010-04.org.ipxe"

Default initiator IQN prefix.

Definition at line 702 of file iscsi.h.

Referenced by iscsi_fetch_settings().


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.

Definition at line 511 of file iscsi.h.

                    {
        /** Nothing to send */
        ISCSI_TX_IDLE = 0,
        /** Sending the basic header segment */
        ISCSI_TX_BHS,
        /** Sending the additional header segment */
        ISCSI_TX_AHS,
        /** Sending the data segment */
        ISCSI_TX_DATA,
};

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 523 of file iscsi.h.

                    {
        /** Receiving the basic header segment */
        ISCSI_RX_BHS = 0,
        /** Receiving the additional header segment */
        ISCSI_RX_AHS,
        /** Receiving the data segment */
        ISCSI_RX_DATA,
        /** Receiving the data segment padding */
        ISCSI_RX_DATA_PADDING,
};

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
struct setting initiator_iqn_setting __setting ( SETTING_SANBOOT_EXTRA  ,
initiator-  iqn 
) [read]