iPXE
|
SCSI RDMA Protocol. More...
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ipxe/scsi.h>
#include <ipxe/xfer.h>
#include <ipxe/features.h>
#include <ipxe/srp.h>
Go to the source code of this file.
Data Structures | |
struct | srp_device |
An SRP device. More... | |
struct | srp_command |
An SRP command. More... | |
Functions | |
FILE_LICENCE (BSD2) | |
FEATURE (FEATURE_PROTOCOL, "SRP", DHCP_EB_FEATURE_SRP, 1) | |
static struct srp_device * | srpdev_get (struct srp_device *srpdev) |
Get reference to SRP device. More... | |
static void | srpdev_put (struct srp_device *srpdev) |
Drop reference to SRP device. More... | |
static struct srp_command * | srpcmd_get (struct srp_command *srpcmd) |
Get reference to SRP command. More... | |
static void | srpcmd_put (struct srp_command *srpcmd) |
Drop reference to SRP command. More... | |
static void | srpcmd_free (struct refcnt *refcnt) |
Free SRP command. More... | |
static void | srpcmd_close (struct srp_command *srpcmd, int rc) |
Close SRP command. More... | |
static void | srpdev_close (struct srp_device *srpdev, int rc) |
Close SRP device. More... | |
static struct srp_command * | srp_find_tag (struct srp_device *srpdev, uint32_t tag) |
Identify SRP command by tag. More... | |
static int | srp_new_tag (struct srp_device *srpdev) |
Choose an SRP command tag. More... | |
static int | srp_login (struct srp_device *srpdev, union srp_port_id *initiator, union srp_port_id *target, uint32_t tag) |
Transmit SRP login request. More... | |
static int | srp_login_rsp (struct srp_device *srpdev, const void *data, size_t len) |
Receive SRP login response. More... | |
static int | srp_login_rej (struct srp_device *srpdev, const void *data, size_t len) |
Receive SRP login rejection. More... | |
static int | srp_cmd (struct srp_device *srpdev, struct scsi_cmd *command, uint32_t tag) |
Transmit SRP SCSI command. More... | |
static int | srp_rsp (struct srp_device *srpdev, const void *data, size_t len) |
Receive SRP SCSI response. More... | |
static int | srp_unrecognised (struct srp_device *srpdev, const void *data, size_t len) |
Receive SRP unrecognised response IU. More... | |
static int | srpdev_scsi_command (struct srp_device *srpdev, struct interface *parent, struct scsi_cmd *command) |
Issue SRP SCSI command. More... | |
static int | srpdev_deliver (struct srp_device *srpdev, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Receive data from SRP socket. More... | |
static size_t | srpdev_window (struct srp_device *srpdev) |
Check SRP device flow-control window. More... | |
int | srp_open (struct interface *block, struct interface *socket, union srp_port_id *initiator, union srp_port_id *target, uint32_t memory_handle, struct scsi_lun *lun) |
Open SRP device. More... | |
Variables | |
static struct interface_operation | srpcmd_scsi_op [] |
SRP command SCSI interface operations. More... | |
static struct interface_descriptor | srpcmd_scsi_desc |
SRP command SCSI interface descriptor. More... | |
static struct interface_operation | srpdev_socket_op [] |
SRP device socket interface operations. More... | |
static struct interface_descriptor | srpdev_socket_desc |
SRP device socket interface descriptor. More... | |
static struct interface_operation | srpdev_scsi_op [] |
SRP device SCSI interface operations. More... | |
static struct interface_descriptor | srpdev_scsi_desc |
SRP device SCSI interface descriptor. More... | |
SCSI RDMA Protocol.
Definition in file srp.c.
#define SRP_MAX_I_T_IU_LEN 80 |
#define EINFO_SRP_LOGIN_REJ | ( | reason, | |
desc | |||
) | __einfo_uniqify ( EINFO_EPERM, ( (reason) & 0x0f ), desc ) |
#define EPERM_UNKNOWN __einfo_error ( EINFO_EPERM_UNKNOWN ) |
#define EINFO_EPERM_UNKNOWN |
#define EPERM_INSUFFICIENT_RESOURCES __einfo_error ( EINFO_EPERM_INSUFFICIENT_RESOURCES ) |
#define EINFO_EPERM_INSUFFICIENT_RESOURCES |
#define EPERM_BAD_MAX_I_T_IU_LEN __einfo_error ( EINFO_EPERM_BAD_MAX_I_T_IU_LEN ) |
#define EINFO_EPERM_BAD_MAX_I_T_IU_LEN |
#define EPERM_CANNOT_ASSOCIATE __einfo_error ( EINFO_EPERM_CANNOT_ASSOCIATE ) |
#define EINFO_EPERM_CANNOT_ASSOCIATE |
#define EPERM_UNSUPPORTED_BUFFER_FORMAT __einfo_error ( EINFO_EPERM_UNSUPPORTED_BUFFER_FORMAT ) |
#define EINFO_EPERM_UNSUPPORTED_BUFFER_FORMAT |
#define EPERM_NO_MULTIPLE_CHANNELS __einfo_error ( EINFO_EPERM_NO_MULTIPLE_CHANNELS ) |
#define EINFO_EPERM_NO_MULTIPLE_CHANNELS |
#define EPERM_NO_MORE_CHANNELS __einfo_error ( EINFO_EPERM_NO_MORE_CHANNELS ) |
#define EINFO_EPERM_NO_MORE_CHANNELS |
#define EPERM_LOGIN_REJ | ( | reason_nibble | ) |
FILE_LICENCE | ( | BSD2 | ) |
FEATURE | ( | FEATURE_PROTOCOL | , |
"SRP" | , | ||
DHCP_EB_FEATURE_SRP | , | ||
1 | |||
) |
|
inlinestatic |
Get reference to SRP device.
srpdev | SRP device |
srpdev | SRP device |
Definition at line 142 of file srp.c.
References ref_get, and srp_device::refcnt.
Referenced by srpdev_scsi_command().
|
inlinestatic |
Drop reference to SRP device.
srpdev | SRP device |
Definition at line 153 of file srp.c.
References ref_put, and srp_device::refcnt.
Referenced by srpcmd_free().
|
inlinestatic |
Get reference to SRP command.
srpcmd | SRP command |
srpcmd | SRP command |
Definition at line 164 of file srp.c.
References ref_get, and srp_command::refcnt.
Referenced by srp_rsp(), and srpdev_close().
|
inlinestatic |
Drop reference to SRP command.
srpcmd | SRP command |
Definition at line 175 of file srp.c.
References ref_put, and srp_command::refcnt.
Referenced by srp_rsp(), srpcmd_close(), and srpdev_close().
|
static |
Free SRP command.
refcnt | Reference count |
Definition at line 184 of file srp.c.
References assert(), container_of, free, srp_command::list, list_empty, srp_command::srpdev, and srpdev_put().
Referenced by srpdev_scsi_command().
|
static |
Close SRP command.
srpcmd | SRP command |
rc | Reason for close |
Definition at line 200 of file srp.c.
References DBGC, INIT_LIST_HEAD, intf_shutdown(), srp_command::list, list_del, list_empty, rc, srp_command::scsi, srpcmd_put(), srp_command::srpdev, strerror(), and srp_command::tag.
Referenced by srp_rsp(), srpdev_close(), and srpdev_scsi_command().
|
static |
Close SRP device.
srpdev | SRP device |
rc | Reason for close |
Definition at line 225 of file srp.c.
References srp_device::commands, DBGC, intf_shutdown(), srp_command::list, list_for_each_entry_safe, rc, srp_device::scsi, srp_device::socket, srpcmd_close(), srpcmd_get(), srpcmd_put(), srp_command::srpdev, strerror(), and tmp.
Referenced by srp_open(), and srpdev_deliver().
|
static |
Identify SRP command by tag.
srpdev | SRP device |
tag | Command tag |
srpcmd | SRP command, or NULL |
Definition at line 253 of file srp.c.
References srp_device::commands, srp_command::list, list_for_each_entry, NULL, srp_command::srpdev, tag, and srp_command::tag.
Referenced by srp_new_tag(), and srp_rsp().
|
static |
Choose an SRP command tag.
srpdev | SRP device |
tag | New tag, or negative error |
Definition at line 270 of file srp.c.
References EADDRINUSE, NULL, srp_find_tag(), and srp_command::srpdev.
Referenced by srp_open(), and srpdev_scsi_command().
|
static |
Transmit SRP login request.
srpdev | SRP device |
initiator | Initiator port ID |
target | Target port ID |
tag | Command tag |
rc | Return status code |
Definition at line 291 of file srp.c.
References io_buffer::data, DBGC, DBGC_HDA, srp_tag::dwords, ENOMEM, htonl, srp_login_req::initiator, iob_len(), iob_put, srp_login_req::max_i_t_iu_len, memcpy(), memset(), rc, srp_login_req::required_buffer_formats, srp_device::socket, SRP_LOGIN_REQ, SRP_LOGIN_REQ_FMT_DDBD, SRP_MAX_I_T_IU_LEN, SRP_TAG_MAGIC, strerror(), tag, srp_login_req::tag, srp_login_req::target, srp_login_req::type, xfer_alloc_iob(), and xfer_deliver_iob().
Referenced by srp_open().
|
static |
Receive SRP login response.
srpdev | SRP device |
data | SRP IU |
len | Length of SRP IU |
rc | Return status code |
Definition at line 335 of file srp.c.
References data, DBGC, DBGC_HDA, srp_tag::dwords, EINVAL, len, srp_device::logged_in, ntohl, srp_device::scsi, srp_login_rsp::tag, and xfer_window_changed().
Referenced by srpdev_deliver().
|
static |
Receive SRP login rejection.
srpdev | SRP device |
data | SRP IU |
len | Length of SRP IU |
rc | Return status code |
Definition at line 367 of file srp.c.
References data, DBGC, DBGC_HDA, srp_tag::dwords, EACCES, EINVAL, EPERM_LOGIN_REJ, len, ntohl, reason, srp_login_rej::reason, SRP_LOGIN_REJ_REASON_DEFINED, and srp_login_rej::tag.
Referenced by srpdev_deliver().
|
static |
Transmit SRP SCSI command.
srpdev | SRP device |
command | SCSI command |
tag | Command tag |
rc | Return status code |
Definition at line 396 of file srp.c.
References srp_memory_descriptor::address, cmd, cpu_to_be64, DBGC, DBGC2, EBUSY, ENOMEM, srp_memory_descriptor::handle, htonl, iob_put, srp_memory_descriptor::len, srp_device::logged_in, memcpy(), srp_device::memory_handle, memset(), ntohl, rc, SCSI_CDB_DATA, SCSI_CDB_FORMAT, srp_device::socket, SRP_CMD, SRP_CMD_DI_FMT_DIRECT, SRP_CMD_DO_FMT_DIRECT, SRP_MAX_I_T_IU_LEN, SRP_TAG_MAGIC, strerror(), tag, user_to_phys(), xfer_alloc_iob(), and xfer_deliver_iob().
|
static |
Receive SRP SCSI response.
srpdev | SRP device |
data | SRP IU |
len | Length of SRP IU |
rc | Returns status code |
Definition at line 467 of file srp.c.
References data, DBGC, DBGC2, EINVAL, ENOENT, len, memset(), ntohl, scsi_rsp::overrun, rsp, srp_command::scsi, scsi_parse_sense(), scsi_response(), scsi_rsp::sense, srp_find_tag(), srp_rsp_response_data_len(), srp_rsp_sense_data(), srp_rsp_sense_data_len(), SRP_RSP_VALID_DIOVER, SRP_RSP_VALID_DIUNDER, SRP_RSP_VALID_DOOVER, SRP_RSP_VALID_DOUNDER, SRP_RSP_VALID_RSPVALID, SRP_RSP_VALID_SNSVALID, srpcmd_close(), srpcmd_get(), srpcmd_put(), and scsi_rsp::status.
Referenced by srpdev_deliver().
|
static |
|
static |
Issue SRP SCSI command.
srpdev | SRP device |
parent | Parent interface |
command | SCSI command |
tag | Command tag, or negative error |
Definition at line 572 of file srp.c.
References srp_device::commands, ENOMEM, intf_init(), intf_plug_plug(), srp_command::list, list_add, rc, ref_init, srp_command::refcnt, srp_command::scsi, srp_new_tag(), srpcmd_close(), srpcmd_free(), srpcmd_scsi_desc, srp_command::srpdev, srpdev_get(), tag, srp_command::tag, and zalloc().
|
static |
Receive data from SRP socket.
srpdev | SRP device |
iobuf | Datagram I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 623 of file srp.c.
References common, data, io_buffer::data, DBGC, DBGC_HDA, EINVAL, free_iob(), iob_len(), len, rc, SRP_LOGIN_REJ, srp_login_rej(), SRP_LOGIN_RSP, srp_login_rsp(), srp_rsp(), SRP_RSP, srp_unrecognised(), srpdev_close(), strerror(), and type.
|
static |
Check SRP device flow-control window.
srpdev | SRP device |
len | Length of window |
Definition at line 676 of file srp.c.
References srp_device::logged_in.
int srp_open | ( | struct interface * | block, |
struct interface * | socket, | ||
union srp_port_id * | initiator, | ||
union srp_port_id * | target, | ||
uint32_t | memory_handle, | ||
struct scsi_lun * | lun | ||
) |
Open SRP device.
block | Block control interface |
socket | Socket interface |
initiator | Initiator port ID |
target | Target port ID |
memory_handle | RDMA memory handle |
lun | SCSI LUN |
rc | Return status code |
Definition at line 713 of file srp.c.
References assert(), block, srp_device::commands, DBGC, srp_port_id::dwords, ENOMEM, INIT_LIST_HEAD, intf_init(), intf_plug_plug(), lun, srp_device::memory_handle, ntohl, NULL, rc, ref_init, ref_put, srp_device::refcnt, srp_device::scsi, scsi_open(), srp_device::socket, srp_login(), srp_new_tag(), srpdev_close(), srpdev_scsi_desc, srpdev_socket_desc, strerror(), tag, and zalloc().
Referenced by ib_srp_open().
|
static |
SRP command SCSI interface operations.
|
static |
SRP command SCSI interface descriptor.
Definition at line 561 of file srp.c.
Referenced by srpdev_scsi_command().
|
static |
SRP device socket interface operations.
|
static |
SRP device socket interface descriptor.
Definition at line 687 of file srp.c.
Referenced by srp_open().
|
static |
SRP device SCSI interface operations.
|
static |
SRP device SCSI interface descriptor.
Definition at line 699 of file srp.c.
Referenced by srp_open().