TianoCore EDK2 master
|
#include "IScsiImpl.h"
Go to the source code of this file.
Variables | |
UINT32 | mDataSegPad = 0 |
The implementation of iSCSI protocol based on RFC3720.
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file IScsiProto.c.
Add an iSCSI key-value pair as a string into the data segment of the Login Request PDU. The DataSegmentLength and the actual size of the net buffer containing this PDU will be updated.
[in,out] | Pdu | The iSCSI PDU whose data segment the key-value pair will be added to. |
[in] | Key | The key name string. |
[in] | Value | The value string. |
EFI_SUCCESS | The key-value pair is added to the PDU's data segment and the correspondence length fields are updated. |
EFI_OUT_OF_RESOURCES | There is not enough space in the PDU to add the key-value pair. |
EFI_PROTOCOL_ERROR | There is no such data in the net buffer. |
Definition at line 677 of file IScsiProto.c.
VOID IScsiAttatchConnection | ( | IN OUT ISCSI_SESSION * | Session, |
IN OUT ISCSI_CONNECTION * | Conn | ||
) |
Attach the iSCSI connection to the iSCSI session.
[in,out] | Session | The iSCSI session. |
[in,out] | Conn | The iSCSI connection. |
Definition at line 21 of file IScsiProto.c.
LIST_ENTRY * IScsiBuildKeyValueList | ( | IN CHAR8 * | Data, |
IN UINT32 | Len | ||
) |
Build a key-value list from the data segment.
[in] | Data | The data segment containing the key-value pairs. |
[in] | Len | Length of the data segment. |
NULL | Other errors as indicated. |
Definition at line 1876 of file IScsiProto.c.
EFI_STATUS IScsiCheckOpParams | ( | IN OUT ISCSI_CONNECTION * | Conn | ) |
Check and get the result of the parameter negotiation.
[in,out] | Conn | The connection in iSCSI login. |
EFI_SUCCESS | The parameter check is passed and negotiation is finished. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1505 of file IScsiProto.c.
EFI_STATUS IScsiCheckSN | ( | IN OUT UINT32 * | ExpSN, |
IN UINT32 | NewSN | ||
) |
Check the sequence number according to RFC3720.
[in,out] | ExpSN | The currently expected sequence number. |
[in] | NewSN | The sequence number to check. |
EFI_SUCCESS | The check passed and the ExpSN is increased. |
EFI_NOT_READY | Response was sent due to a retransmission request. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
Definition at line 59 of file IScsiProto.c.
EFI_STATUS IScsiConnLogin | ( | IN OUT ISCSI_CONNECTION * | Conn, |
IN UINT16 | Timeout | ||
) |
This function does the iSCSI connection login.
[in,out] | Conn | The iSCSI connection to login. |
Timeout | The timeout value in millisecond. |
EFI_SUCCESS | The iSCSI connection is logged into the iSCSI target. |
EFI_TIMEOUT | Timeout occurred during the login procedure. |
Others | Other errors as indicated. |
Definition at line 122 of file IScsiProto.c.
VOID IScsiConnReset | ( | IN OUT ISCSI_CONNECTION * | Conn | ) |
Reset the iSCSI connection.
[in,out] | Conn | The iSCSI connection to reset. |
Definition at line 178 of file IScsiProto.c.
ISCSI_CONNECTION * IScsiCreateConnection | ( | IN ISCSI_SESSION * | Session | ) |
Create a TCP connection for the iSCSI session.
[in] | Session | Points to the iSCSI session. |
Definition at line 194 of file IScsiProto.c.
Delete the tcb from the connection and destroy it.
[in] | Tcb | The tcb to delete. |
Definition at line 2106 of file IScsiProto.c.
VOID IScsiDestroyConnection | ( | IN ISCSI_CONNECTION * | Conn | ) |
Destroy an iSCSI connection.
[in] | Conn | The connection to destroy. |
Definition at line 310 of file IScsiProto.c.
VOID IScsiDetatchConnection | ( | IN OUT ISCSI_CONNECTION * | Conn | ) |
Detach the iSCSI connection from the session it belongs to.
[in,out] | Conn | The iSCSI connection. |
Definition at line 38 of file IScsiProto.c.
EFI_STATUS IScsiExecuteScsiCommand | ( | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 * | Target, | ||
IN UINT64 | Lun, | ||
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET * | Packet | ||
) |
Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
[in] | PassThru | The EXT SCSI PASS THRU protocol. |
[in] | Target | The target ID. |
[in] | Lun | The LUN. |
[in,out] | Packet | The request packet containing IO request, SCSI command buffer and buffers to read/write. |
EFI_SUCCESS | The SCSI command is executed and the result is updated to the Packet. |
EFI_DEVICE_ERROR | Session state was not as required. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_PROTOCOL_ERROR | There is no such data in the net buffer. |
EFI_NOT_READY | The target can not accept new commands. |
Others | Other errors as indicated. |
Definition at line 2904 of file IScsiProto.c.
VOID IScsiFillOpParams | ( | IN ISCSI_CONNECTION * | Conn, |
IN OUT NET_BUF * | Pdu | ||
) |
Fill the operational parameters.
[in] | Conn | The connection in iSCSI login. |
[in,out] | Pdu | The iSCSI login request PDU to fill the parameters. |
Definition at line 1779 of file IScsiProto.c.
VOID IScsiFreeKeyValueList | ( | IN LIST_ENTRY * | KeyValueList | ) |
Free the key-value list.
[in] | KeyValueList | The key-value list. |
Definition at line 1978 of file IScsiProto.c.
VOID EFIAPI IScsiFreeNbufList | ( | VOID * | Arg | ) |
The callback function to free the net buffer list.
[in] | Arg | The opaque parameter. |
Definition at line 1262 of file IScsiProto.c.
LIST_ENTRY * IScsiGenerateDataOutPduSequence | ( | IN UINT8 * | Data, |
IN ISCSI_TCB * | Tcb, | ||
IN UINT64 | Lun | ||
) |
Generate a consecutive sequence of iSCSI SCSI Data Out PDUs.
[in] | Data | The data which will be carried by the sequence of iSCSI SCSI Data Out PDUs. |
[in] | Tcb | The task control block of the data to send out. |
[in] | Lun | The LUN the data will be sent to. |
NULL | Other errors as indicated. |
Definition at line 2445 of file IScsiProto.c.
EFI_STATUS IScsiGetIp6NicInfo | ( | IN ISCSI_CONNECTION * | Conn | ) |
Retrieve the IPv6 Address/Prefix/Gateway from the established TCP connection, these informations will be filled in the iSCSI Boot Firmware Table.
[in] | Conn | The connection used in the iSCSI login phase. |
EFI_SUCCESS | Get the NIC information successfully. |
Others | Other errors as indicated. |
Definition at line 332 of file IScsiProto.c.
CHAR8 * IScsiGetValueByKeyFromList | ( | IN OUT LIST_ENTRY * | KeyValueList, |
IN CHAR8 * | Key | ||
) |
Get the value string by the key name from the key-value list. If found, the key-value entry will be removed from the list.
[in,out] | KeyValueList | The key-value list. |
[in] | Key | The key name to find. |
NULL | The key value pair cannot be found. |
Definition at line 1945 of file IScsiProto.c.
VOID EFIAPI IScsiNbufExtFree | ( | VOID * | Arg | ) |
The callback function called in NetBufFree; it does nothing.
[in] | Arg | The opaque parameter. |
Definition at line 1280 of file IScsiProto.c.
NET_BUF * IScsiNewDataOutPdu | ( | IN UINT8 * | Data, |
IN UINT32 | Len, | ||
IN UINT32 | DataSN, | ||
IN ISCSI_TCB * | Tcb, | ||
IN UINT64 | Lun | ||
) |
Create a new iSCSI SCSI Data Out PDU.
[in] | Data | The data to put into the Data Out PDU. |
[in] | Len | Length of the data. |
[in] | DataSN | The DataSN of the Data Out PDU. |
[in] | Tcb | The task control block of this Data Out PDU. |
[in] | Lun | The LUN. |
NULL | Other errors as indicated. |
Definition at line 2349 of file IScsiProto.c.
Create a data segment, pad it, and calculate the CRC if needed.
[in] | Data | The data to fill into the data segment. |
[in] | Len | Length of the data. |
[in] | DataDigest | Whether to calculate CRC for this data segment. |
Definition at line 2126 of file IScsiProto.c.
NET_BUF * IScsiNewScsiCmdPdu | ( | IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET * | Packet, |
IN UINT64 | Lun, | ||
IN ISCSI_TCB * | Tcb | ||
) |
Create a iSCSI SCSI command PDU to encapsulate the command issued by SCSI through the EXT SCSI PASS THRU Protocol.
[in] | Packet | The EXT SCSI PASS THRU request packet containing the SCSI command. |
[in] | Lun | The LUN. |
[in] | Tcb | The tcb associated with this SCSI command. |
NULL | Other errors as indicated. |
Definition at line 2168 of file IScsiProto.c.
EFI_STATUS IScsiNewTcb | ( | IN ISCSI_CONNECTION * | Conn, |
OUT ISCSI_TCB ** | Tcb | ||
) |
Create an iSCSI task control block.
[in] | Conn | The connection on which the task control block will be created. |
[out] | Tcb | The newly created task control block. |
EFI_SUCCESS | The task control block is created. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_NOT_READY | The target cannot accept new commands. |
Definition at line 2058 of file IScsiProto.c.
EFI_STATUS IScsiNormalizeName | ( | IN OUT CHAR8 * | Name, |
IN UINTN | Len | ||
) |
Normalize the iSCSI name according to RFC.
[in,out] | Name | The iSCSI name. |
[in] | Len | Length of the iSCSI name. |
EFI_SUCCESS | The iSCSI name is valid and normalized. |
EFI_PROTOCOL_ERROR | The iSCSI name is malformatted or not in the IQN format. |
Definition at line 2006 of file IScsiProto.c.
EFI_STATUS IScsiOnDataInRcvd | ( | IN NET_BUF * | Pdu, |
IN ISCSI_TCB * | Tcb, | ||
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET * | Packet | ||
) |
Process the received iSCSI SCSI Data In PDU.
[in] | Pdu | The Data In PDU received. |
[in] | Tcb | The task control block. |
[in,out] | Packet | The EXT SCSI PASS THRU request packet. |
EFI_SUCCESS | The check on the Data IN PDU is passed and some update actions are taken. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
EFI_BAD_BUFFER_SIZEE | The buffer was not the proper size for the request. |
Others | Other errors as indicated. |
Definition at line 2583 of file IScsiProto.c.
EFI_STATUS IScsiOnNopInRcvd | ( | IN NET_BUF * | Pdu, |
IN ISCSI_TCB * | Tcb | ||
) |
Process the received NOP In PDU.
[in] | Pdu | The NOP In PDU received. |
[in] | Tcb | The task control block. |
EFI_SUCCESS | The NOP In PDU is processed and the related sequence numbers are updated. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
Definition at line 2852 of file IScsiProto.c.
EFI_STATUS IScsiOnR2TRcvd | ( | IN NET_BUF * | Pdu, |
IN ISCSI_TCB * | Tcb, | ||
IN UINT64 | Lun, | ||
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET * | Packet | ||
) |
Process the received iSCSI R2T PDU.
[in] | Pdu | The R2T PDU received. |
[in] | Tcb | The task control block. |
[in] | Lun | The Lun. |
[in,out] | Packet | The EXT SCSI PASS THRU request packet. |
EFI_SUCCESS | The R2T PDU is valid and the solicited data is sent out. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
Others | Other errors as indicated. |
Definition at line 2674 of file IScsiProto.c.
EFI_STATUS IScsiOnScsiRspRcvd | ( | IN NET_BUF * | Pdu, |
IN ISCSI_TCB * | Tcb, | ||
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET * | Packet | ||
) |
Process the received iSCSI SCSI Response PDU.
[in] | Pdu | The Response PDU received. |
[in] | Tcb | The task control block. |
[in,out] | Packet | The EXT SCSI PASS THRU request packet. |
EFI_SUCCESS | The Response PDU is processed. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
EFI_BAD_BUFFER_SIZEE | The buffer was not the proper size for the request. |
Others | Other errors as indicated. |
Definition at line 2745 of file IScsiProto.c.
EFI_STATUS IScsiPadSegment | ( | IN OUT NET_BUF * | Pdu, |
IN UINT32 | Len | ||
) |
Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
[in,out] | Pdu | The iSCSI pdu which contains segments to pad. |
[in] | Len | The length of the last segment in the PDU. |
EFI_SUCCESS | The segment is padded or there is no need to pad it. |
EFI_OUT_OF_RESOURCES | There is not enough remaining free space to add the padding bytes. |
Definition at line 1843 of file IScsiProto.c.
NET_BUF * IScsiPrepareLoginReq | ( | IN OUT ISCSI_CONNECTION * | Conn | ) |
Prepare the iSCSI login request to be sent according to the current login status.
[in,out] | Conn | The connection in the iSCSI login phase. |
NULL | Other errors as indicated. |
Definition at line 749 of file IScsiProto.c.
EFI_STATUS IScsiProcessLoginRsp | ( | IN OUT ISCSI_CONNECTION * | Conn, |
IN OUT NET_BUF * | Pdu | ||
) |
Process the iSCSI Login Response.
[in,out] | Conn | The connection on which the iSCSI login response is received. |
[in,out] | Pdu | The iSCSI login response PDU. |
EFI_SUCCESS | The iSCSI login response PDU is processed, and all checks are passed. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
EFI_MEDIA_CHANGED | Target is redirected. |
Others | Other errors as indicated. |
Definition at line 865 of file IScsiProto.c.
EFI_STATUS IScsiReceiveLoginRsp | ( | IN ISCSI_CONNECTION * | Conn | ) |
Receive and process the iSCSI login response.
[in] | Conn | The connection in the iSCSI login phase. |
EFI_SUCCESS | The iSCSI login response PDU is received and processed. |
Others | Other errors as indicated. |
Definition at line 631 of file IScsiProto.c.
EFI_STATUS IScsiReceivePdu | ( | IN ISCSI_CONNECTION * | Conn, |
OUT NET_BUF ** | Pdu, | ||
IN ISCSI_IN_BUFFER_CONTEXT *Context | OPTIONAL, | ||
IN BOOLEAN | HeaderDigest, | ||
IN BOOLEAN | DataDigest, | ||
IN EFI_EVENT TimeoutEvent | OPTIONAL | ||
) |
Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU header and an optional data segment. The two parts will be put into two blocks of buffers in the net buffer. The digest check will be conducted in this function if needed and the digests will be trimmed from the PDU buffer.
[in] | Conn | The iSCSI connection to receive data from. |
[out] | Pdu | The received iSCSI pdu. |
[in] | Context | The context used to describe information on the caller provided buffer to receive data segment of the iSCSI pdu. It is optional. |
[in] | HeaderDigest | Whether there will be header digest received. |
[in] | DataDigest | Whether there will be data digest. |
[in] | TimeoutEvent | The timeout event. It is optional. |
EFI_SUCCESS | An iSCSI pdu is received. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
Others | Other errors as indicated. |
Definition at line 1307 of file IScsiProto.c.
EFI_STATUS IScsiSendDataOutPduSequence | ( | IN UINT8 * | Data, |
IN UINT64 | Lun, | ||
IN ISCSI_TCB * | Tcb | ||
) |
Send the Data in a sequence of Data Out PDUs one by one.
[in] | Data | The data to carry by Data Out PDUs. |
[in] | Lun | The LUN the data will be sent to. |
[in] | Tcb | The task control block. |
EFI_SUCCESS | The data is sent out to the LUN. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Others | Other errors as indicated. |
Definition at line 2529 of file IScsiProto.c.
EFI_STATUS IScsiSendLoginReq | ( | IN ISCSI_CONNECTION * | Conn | ) |
Build and send the iSCSI login request to the iSCSI target according to the current login stage.
[in] | Conn | The connection in the iSCSI login phase. |
EFI_SUCCESS | The iSCSI login request PDU is built and sent on this connection. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_DEVICE_ERROR | Some kind of device error occurred. |
Definition at line 596 of file IScsiProto.c.
VOID IScsiSessionAbort | ( | IN OUT ISCSI_SESSION * | Session | ) |
Abort the iSCSI session. That is, reset all the connection(s), and free the resources.
[in,out] | Session | The iSCSI session. |
Definition at line 3166 of file IScsiProto.c.
VOID IScsiSessionInit | ( | IN OUT ISCSI_SESSION * | Session, |
IN BOOLEAN | Recovery | ||
) |
Initialize some session parameters before login.
[in,out] | Session | The iSCSI session. |
[in] | Recovery | Whether the request is from a fresh new start or recovery. |
Definition at line 3125 of file IScsiProto.c.
EFI_STATUS IScsiSessionLogin | ( | IN ISCSI_SESSION * | Session | ) |
Login the iSCSI session.
[in] | Session | The iSCSI session. |
EFI_SUCCESS | The iSCSI session login procedure finished. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_NO_MEDIA | There was a media error. |
Others | Other errors as indicated. |
Definition at line 452 of file IScsiProto.c.
EFI_STATUS IScsiSessionReinstatement | ( | IN ISCSI_SESSION * | Session | ) |
Reinstate the session on some error.
[in] | Session | The iSCSI session |
EFI_SUCCESS | The session is reinstated from some error. |
Other | Reinstatement failed. |
Definition at line 3095 of file IScsiProto.c.
EFI_STATUS IScsiSessionReLogin | ( | IN ISCSI_SESSION * | Session | ) |
Wait for IPsec negotiation, then try to login the iSCSI session again.
[in] | Session | The iSCSI session. |
EFI_SUCCESS | The iSCSI session login procedure finished. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_PROTOCOL_ERROR | Some kind of iSCSI protocol error occurred. |
Definition at line 547 of file IScsiProto.c.
STATIC VOID IScsiSessionResetAuthData | ( | IN OUT ISCSI_SESSION * | Session | ) |
Re-set any stateful session-level authentication information that is used by the leading login / leading connection.
(Note that this driver only supports a single connection per session – see ISCSI_MAX_CONNS_PER_SESSION.)
[in,out] | Session | The iSCSI session. |
Definition at line 431 of file IScsiProto.c.
VOID IScsiUpdateCmdSN | ( | IN OUT ISCSI_SESSION * | Session, |
IN UINT32 | MaxCmdSN, | ||
IN UINT32 | ExpCmdSN | ||
) |
Update the sequence numbers for the iSCSI command.
[in,out] | Session | The iSCSI session. |
[in] | MaxCmdSN | Maximum CmdSN from the target. |
[in] | ExpCmdSN | Next expected CmdSN from the target. |
Definition at line 91 of file IScsiProto.c.
EFI_STATUS IScsiUpdateTargetAddress | ( | IN OUT ISCSI_SESSION * | Session, |
IN CHAR8 * | Data, | ||
IN UINT32 | Len | ||
) |
Updated the target information according the data received in the iSCSI login response with an target redirection status.
[in,out] | Session | The iSCSI session. |
[in] | Data | The data segment that should contain the TargetAddress key-value list. |
[in] | Len | Length of the data. |
EFI_SUCCESS | The target address is updated. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_NOT_FOUND | The TargetAddress key is not found. |
Others | Other errors as indicated. |
Definition at line 1103 of file IScsiProto.c.
UINT32 mDataSegPad = 0 |
Definition at line 11 of file IScsiProto.c.