iPXE
|
Fibre Channel Protocol. More...
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/refcnt.h>
#include <ipxe/list.h>
#include <ipxe/interface.h>
#include <ipxe/xfer.h>
#include <ipxe/iobuf.h>
#include <ipxe/open.h>
#include <ipxe/process.h>
#include <ipxe/uri.h>
#include <ipxe/acpi.h>
#include <ipxe/scsi.h>
#include <ipxe/device.h>
#include <ipxe/edd.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/fc.h>
#include <ipxe/fcels.h>
#include <ipxe/fcp.h>
Go to the source code of this file.
Data Structures | |
struct | fcp_device |
An FCP device. More... | |
struct | fcp_command |
An FCP command. More... | |
Macros | |
#define | ERANGE_READ_DATA_ORDERING __einfo_error ( EINFO_ERANGE_READ_DATA_ORDERING ) |
#define | EINFO_ERANGE_READ_DATA_ORDERING __einfo_uniqify ( EINFO_ERANGE, 0x01, "Read data out of order" ) |
#define | ERANGE_READ_DATA_OVERRUN __einfo_error ( EINFO_ERANGE_READ_DATA_OVERRUN ) |
#define | EINFO_ERANGE_READ_DATA_OVERRUN __einfo_uniqify ( EINFO_ERANGE, 0x02, "Read data overrun" ) |
#define | ERANGE_WRITE_DATA_STUCK __einfo_error ( EINFO_ERANGE_WRITE_DATA_STUCK ) |
#define | EINFO_ERANGE_WRITE_DATA_STUCK __einfo_uniqify ( EINFO_ERANGE, 0x03, "Write data stuck" ) |
#define | ERANGE_WRITE_DATA_OVERRUN __einfo_error ( EINFO_ERANGE_WRITE_DATA_OVERRUN ) |
#define | EINFO_ERANGE_WRITE_DATA_OVERRUN __einfo_uniqify ( EINFO_ERANGE, 0x04, "Write data overrun" ) |
#define | ERANGE_DATA_UNDERRUN __einfo_error ( EINFO_ERANGE_DATA_UNDERRUN ) |
#define | EINFO_ERANGE_DATA_UNDERRUN __einfo_uniqify ( EINFO_ERANGE, 0x05, "Data underrun" ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | fcp_prli_tx (struct fc_els *els) |
Transmit FCP PRLI. More... | |
static int | fcp_prli_rx (struct fc_els *els, void *data, size_t len) |
Receive FCP PRLI. More... | |
static int | fcp_prli_detect (struct fc_els *els, const void *data, size_t len) |
Detect FCP PRLI. More... | |
static struct fcp_device * | fcpdev_get (struct fcp_device *fcpdev) |
Get reference to FCP device. More... | |
static void | fcpdev_put (struct fcp_device *fcpdev) |
Drop reference to FCP device. More... | |
static struct fcp_command * | fcpcmd_get (struct fcp_command *fcpcmd) |
Get reference to FCP command. More... | |
static void | fcpcmd_put (struct fcp_command *fcpcmd) |
Drop reference to FCP command. More... | |
static void | fcpcmd_start_send (struct fcp_command *fcpcmd, int(*send)(struct fcp_command *fcpcmd)) |
Start FCP command sending. More... | |
static void | fcpcmd_stop_send (struct fcp_command *fcpcmd) |
Stop FCP command sending. More... | |
static void | fcpcmd_free (struct refcnt *refcnt) |
Free FCP command. More... | |
static void | fcpcmd_close (struct fcp_command *fcpcmd, int rc) |
Close FCP command. More... | |
static void | fcpcmd_close_err (struct fcp_command *fcpcmd, int rc) |
Close FCP command in error. More... | |
static int | fcpcmd_send_cmnd (struct fcp_command *fcpcmd) |
Send FCP command IU. More... | |
static int | fcpcmd_recv_rddata (struct fcp_command *fcpcmd, struct io_buffer *iobuf, struct xfer_metadata *meta) |
Handle FCP read data IU. More... | |
static int | fcpcmd_send_wrdata (struct fcp_command *fcpcmd) |
Send FCP write data IU. More... | |
static int | fcpcmd_recv_xfer_rdy (struct fcp_command *fcpcmd, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Handle FCP transfer ready IU. More... | |
static int | fcpcmd_recv_rsp (struct fcp_command *fcpcmd, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Handle FCP response IU. More... | |
static int | fcpcmd_recv_unknown (struct fcp_command *fcpcmd, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Handle unknown FCP IU. More... | |
static void | fcpcmd_step (struct fcp_command *fcpcmd) |
Transmit FCP frame. More... | |
static int | fcpcmd_deliver (struct fcp_command *fcpcmd, struct io_buffer *iobuf, struct xfer_metadata *meta) |
Receive FCP frame. More... | |
static int | fcpdev_scsi_command (struct fcp_device *fcpdev, struct interface *parent, struct scsi_cmd *command) |
Issue FCP SCSI command. More... | |
static void | fcpdev_close (struct fcp_device *fcpdev, int rc) |
Close FCP device. More... | |
static size_t | fcpdev_window (struct fcp_device *fcpdev) |
Check FCP device flow-control window. More... | |
static int | fcpdev_edd_describe (struct fcp_device *fcpdev, struct edd_interface_type *type, union edd_device_path *path) |
Describe FCP device using EDD. More... | |
static struct device * | fcpdev_identify_device (struct fcp_device *fcpdev) |
Identify device underlying FCP device. More... | |
static EFI_DEVICE_PATH_PROTOCOL * | fcpdev_efi_describe (struct fcp_device *fcpdev) |
Describe as an EFI device path. More... | |
static void | fcpdev_examine (struct fc_ulp_user *user) |
Examine FCP ULP link state. More... | |
static int | fcpdev_open (struct interface *parent, struct fc_name *wwn, struct scsi_lun *lun) |
Open FCP device. More... | |
static int | fcp_parse_uri (struct uri *uri, struct fc_name *wwn, struct scsi_lun *lun) |
Parse FCP URI. More... | |
static int | fcp_open (struct interface *parent, struct uri *uri) |
Open FCP URI. More... | |
Variables | |
struct fc_els_prli_descriptor fcp_prli_descriptor | __fc_els_prli_descriptor |
FCP PRLI descriptor. More... | |
struct fc_els_handler fcp_prli_handler | __fc_els_handler |
FCP PRLI ELS handler. More... | |
static struct interface_operation | fcpcmd_scsi_op [] |
FCP command SCSI interface operations. More... | |
static struct interface_descriptor | fcpcmd_scsi_desc |
FCP command SCSI interface descriptor. More... | |
static struct interface_operation | fcpcmd_xchg_op [] |
FCP command Fibre Channel exchange interface operations. More... | |
static struct interface_descriptor | fcpcmd_xchg_desc |
FCP command Fibre Channel exchange interface descriptor. More... | |
static struct process_descriptor | fcpcmd_process_desc |
FCP command process descriptor. More... | |
static struct interface_operation | fcpdev_scsi_op [] |
FCP device SCSI interface operations. More... | |
static struct interface_descriptor | fcpdev_scsi_desc |
FCP device SCSI interface descriptor. More... | |
struct uri_opener fcp_uri_opener | __uri_opener |
FCP URI opener. More... | |
Fibre Channel Protocol.
Definition in file fcp.c.
#define ERANGE_READ_DATA_ORDERING __einfo_error ( EINFO_ERANGE_READ_DATA_ORDERING ) |
#define EINFO_ERANGE_READ_DATA_ORDERING __einfo_uniqify ( EINFO_ERANGE, 0x01, "Read data out of order" ) |
#define ERANGE_READ_DATA_OVERRUN __einfo_error ( EINFO_ERANGE_READ_DATA_OVERRUN ) |
#define EINFO_ERANGE_READ_DATA_OVERRUN __einfo_uniqify ( EINFO_ERANGE, 0x02, "Read data overrun" ) |
#define ERANGE_WRITE_DATA_STUCK __einfo_error ( EINFO_ERANGE_WRITE_DATA_STUCK ) |
#define EINFO_ERANGE_WRITE_DATA_STUCK __einfo_uniqify ( EINFO_ERANGE, 0x03, "Write data stuck" ) |
#define ERANGE_WRITE_DATA_OVERRUN __einfo_error ( EINFO_ERANGE_WRITE_DATA_OVERRUN ) |
#define EINFO_ERANGE_WRITE_DATA_OVERRUN __einfo_uniqify ( EINFO_ERANGE, 0x04, "Write data overrun" ) |
#define ERANGE_DATA_UNDERRUN __einfo_error ( EINFO_ERANGE_DATA_UNDERRUN ) |
#define EINFO_ERANGE_DATA_UNDERRUN __einfo_uniqify ( EINFO_ERANGE, 0x05, "Data underrun" ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Transmit FCP PRLI.
els | Fibre Channel ELS transaction |
rc | Return status code |
Definition at line 94 of file fcp.c.
References fc_els_prli_tx(), FCP_PRLI_INITIATOR, FCP_PRLI_NO_READ_RDY, htonl, memset(), and param.
Receive FCP PRLI.
els | Fibre Channel ELS transaction |
frame | ELS frame |
len | Length of ELS frame |
rc | Return status code |
Definition at line 112 of file fcp.c.
References data, fc_els_prli_rx(), and len.
Detect FCP PRLI.
els | Fibre Channel ELS transaction |
data | ELS frame |
len | Length of ELS frame |
rc | Return status code |
Definition at line 124 of file fcp.c.
References data, fc_els_prli_detect(), and len.
|
inlinestatic |
Get reference to FCP device.
fcpdev | FCP device |
fcpdev | FCP device |
Definition at line 203 of file fcp.c.
References ref_get, and fcp_device::refcnt.
Referenced by fcpdev_scsi_command().
|
inlinestatic |
Drop reference to FCP device.
fcpdev | FCP device |
Definition at line 214 of file fcp.c.
References ref_put, and fcp_device::refcnt.
Referenced by fcpcmd_free().
|
inlinestatic |
Get reference to FCP command.
fcpcmd | FCP command |
fcpcmd | FCP command |
Definition at line 225 of file fcp.c.
References ref_get, and fcp_command::refcnt.
Referenced by fcpdev_close().
|
inlinestatic |
Drop reference to FCP command.
fcpcmd | FCP command |
Definition at line 236 of file fcp.c.
References ref_put, and fcp_command::refcnt.
Referenced by fcpdev_close().
|
inlinestatic |
Start FCP command sending.
fcpcmd | FCP command |
send | Send method |
Definition at line 247 of file fcp.c.
References fcp_command::process, process_add(), fcp_command::send, and send.
Referenced by fcpcmd_recv_xfer_rdy(), and fcpdev_scsi_command().
|
inlinestatic |
Stop FCP command sending.
fcpcmd | FCP command |
Definition at line 259 of file fcp.c.
References fcp_command::process, and process_del().
Referenced by fcpcmd_close(), fcpcmd_send_cmnd(), and fcpcmd_send_wrdata().
|
static |
Free FCP command.
refcnt | Reference count |
Definition at line 268 of file fcp.c.
References container_of, fcp_command::fcpdev, fcpdev_put(), free, fcp_command::list, and list_del.
Referenced by fcpdev_scsi_command().
|
static |
Close FCP command.
fcpcmd | FCP command |
rc | Reason for close |
Definition at line 286 of file fcp.c.
References DBGC, fcpcmd_stop_send(), fcp_command::fcpdev, intf_shutdown(), rc, fcp_command::scsi, strerror(), fcp_command::xchg, and fcp_command::xchg_id.
Referenced by fcpcmd_close_err(), fcpcmd_deliver(), fcpcmd_recv_rsp(), fcpcmd_step(), fcpdev_close(), and fcpdev_scsi_command().
|
static |
|
static |
Send FCP command IU.
fcpcmd | FCP command |
rc | Return status code |
Definition at line 320 of file fcp.c.
References assert(), scsi_cmd::cdb, fcp_cmnd::cdb, fcp_command::command, DBGC, DBGC2, fcp_cmnd::dirn, ENOMEM, ENOTSUP, FCP_CMND_RDDATA, FCP_CMND_WRDATA, fcpcmd_stop_send(), fcp_command::fcpdev, htonl, iob_disown, iob_put, fcp_cmnd::len, fcp_cmnd::lun, memcpy(), memset(), meta(), ntohl, rc, SCSI_CDB_DATA, SCSI_CDB_FORMAT, strerror(), fcp_command::xchg, fcp_command::xchg_id, xfer_alloc_iob(), xfer_deliver(), XFER_FL_CMD_STAT, and XFER_FL_OVER.
Referenced by fcpdev_scsi_command().
|
static |
Handle FCP read data IU.
fcpcmd | FCP command |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 382 of file fcp.c.
References assert(), fcp_command::command, copy_to_user(), io_buffer::data, DBGC, DBGC2, done, ERANGE_READ_DATA_ORDERING, ERANGE_READ_DATA_OVERRUN, fcp_command::fcpdev, free_iob(), iob_len(), len, meta(), offset, fcp_command::offset, rc, fcp_command::xchg_id, and XFER_FL_ABS_OFFSET.
Referenced by fcpcmd_deliver().
|
static |
Send FCP write data IU.
fcpcmd | FCP command |
rc | Return status code |
Definition at line 432 of file fcp.c.
References assert(), fcp_command::command, copy_from_user(), DBGC, DBGC2, ENOMEM, ERANGE_WRITE_DATA_OVERRUN, ERANGE_WRITE_DATA_STUCK, fcpcmd_stop_send(), fcp_command::fcpdev, iob_disown, iob_len(), iob_put, len, memset(), meta(), fcp_command::offset, rc, fcp_command::remaining, strerror(), fcp_command::xchg, fcp_command::xchg_id, xfer_alloc_iob(), xfer_deliver(), XFER_FL_ABS_OFFSET, XFER_FL_OVER, XFER_FL_RESPONSE, and xfer_window().
Referenced by fcpcmd_recv_xfer_rdy().
|
static |
Handle FCP transfer ready IU.
fcpcmd | FCP command |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 505 of file fcp.c.
References io_buffer::data, DBGC, DBGC2, DBGC_HDA, done, EPROTO, fcpcmd_send_wrdata(), fcpcmd_start_send(), fcp_command::fcpdev, free_iob(), iob_len(), fcp_xfer_rdy::len, ntohl, fcp_xfer_rdy::offset, fcp_command::offset, rc, fcp_command::remaining, and fcp_command::xchg_id.
Referenced by fcpcmd_deliver().
|
static |
Handle FCP response IU.
fcpcmd | FCP command |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 551 of file fcp.c.
References fcp_command::command, io_buffer::data, DBGC, DBGC2, DBGC2_HDA, DBGC_HDA, done, EPROTO, ERANGE_DATA_UNDERRUN, FCP_RSP_RESIDUAL_OVERRUN, FCP_RSP_RESIDUAL_UNDERRUN, fcp_rsp_response_data(), fcp_rsp_response_data_len(), FCP_RSP_RESPONSE_LEN_VALID, fcp_rsp_sense_data(), fcp_rsp_sense_data_len(), FCP_RSP_SENSE_LEN_VALID, fcpcmd_close(), fcp_command::fcpdev, free_iob(), iob_disown, iob_len(), memset(), ntohl, fcp_command::offset, scsi_rsp::overrun, rc, rsp, fcp_command::scsi, scsi_parse_sense(), scsi_response(), scsi_rsp::sense, scsi_rsp::status, and fcp_command::xchg_id.
Referenced by fcpcmd_deliver().
|
static |
Handle unknown FCP IU.
fcpcmd | FCP command |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 640 of file fcp.c.
References io_buffer::data, DBGC, DBGC_HDA, EPROTO, fcp_command::fcpdev, free_iob(), iob_len(), and fcp_command::xchg_id.
Referenced by fcpcmd_deliver().
|
static |
Transmit FCP frame.
fcpcmd | FCP command |
Definition at line 657 of file fcp.c.
References fcpcmd_close(), rc, and fcp_command::send.
|
static |
Receive FCP frame.
fcpcmd | FCP command |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 675 of file fcp.c.
References fcpcmd_close(), fcpcmd_recv_rddata(), fcpcmd_recv_rsp(), fcpcmd_recv_unknown(), fcpcmd_recv_xfer_rdy(), iob_disown, meta(), rc, XFER_FL_CMD_STAT, and XFER_FL_RESPONSE.
|
static |
Issue FCP SCSI command.
fcpdev | FCP device |
parent | Parent interface |
command | SCSI command |
tag | Command tag, or negative error |
Definition at line 739 of file fcp.c.
References assert(), fcp_command::command, DBGC, ENOMEM, ENOTTY, FC_TYPE_FCP, fc_xchg_originate(), FCP_PRLI_TARGET, FCP_TAG_MAGIC, fcpcmd_close(), fcpcmd_free(), fcpcmd_process_desc, fcpcmd_scsi_desc, fcpcmd_send_cmnd(), fcpcmd_start_send(), fcpcmd_xchg_desc, fcp_device::fcpcmds, fcp_command::fcpdev, fcpdev_get(), htonl, intf_init(), intf_plug_plug(), fc_ulp::link, fcp_command::list, list_add, memcpy(), NULL, param, fc_ulp::param, fc_ulp::param_len, fc_ulp::peer, fc_peer::port, fc_peer::port_id, fcp_command::process, process_init_stopped(), fc_link_state::rc, rc, ref_init, ref_put, fcp_command::refcnt, fcp_command::scsi, strerror(), fc_ulp_user::ulp, fcp_device::user, fcp_command::xchg, fcp_command::xchg_id, and zalloc().
|
static |
Close FCP device.
fcpdev | FCP device |
rc | Reason for close |
Definition at line 814 of file fcp.c.
References DBGC, fc_ulp_detach(), fcpcmd_close(), fcpcmd_get(), fcpcmd_put(), fcp_device::fcpcmds, fcp_command::fcpdev, intf_shutdown(), fcp_command::list, list_for_each_entry_safe, rc, fcp_device::scsi, strerror(), tmp, and fcp_device::user.
Referenced by fcpdev_open().
|
static |
Check FCP device flow-control window.
fcpdev | FCP device |
len | Length of window |
Definition at line 840 of file fcp.c.
References fc_link_ok(), fcp_command::fcpdev, fc_ulp::link, fc_ulp_user::ulp, and fcp_device::user.
|
static |
Describe FCP device using EDD.
fcpdev | FCP device |
type | EDD interface type |
path | EDD device path |
rc | Return status code |
Definition at line 853 of file fcp.c.
References be64_to_cpu, cpu_to_le64, fcp_device::desc, EDD_INTF_TYPE_FIBRE, fc, lun, edd_device_path::lun, fcp_description::lun, memcpy(), type, wwn, edd_device_path::wwn, and fcp_description::wwn.
|
static |
Identify device underlying FCP device.
fcpdev | FCP device |
device | Underlying device |
Definition at line 879 of file fcp.c.
References assert(), DBGC, fc_link_ok(), identify_device(), fc_ulp::link, NULL, fc_ulp::peer, fc_peer::port, fc_port::transport, fc_ulp_user::ulp, and fcp_device::user.
|
static |
Describe as an EFI device path.
fcp | FCP device |
path | EFI device path, or NULL on error |
Definition at line 902 of file fcp.c.
References fcp_device::desc, and efi_fcp_path().
|
static |
Examine FCP ULP link state.
user | Fibre Channel upper-layer protocol user |
Definition at line 927 of file fcp.c.
References container_of, DBGC, fc_link_ok(), fc_ulp::link, fc_link_state::rc, fcp_device::scsi, strerror(), fc_ulp_user::ulp, fcp_device::user, and xfer_window_changed().
Referenced by fcpdev_open().
|
static |
Open FCP device.
parent | Parent interface |
wwn | Fibre Channel WWN |
lun | SCSI LUN |
rc | Return status code |
Definition at line 950 of file fcp.c.
References DBGC, fcp_device::desc, ENOMEM, fc_ntoa(), FC_TYPE_FCP, fc_ulp_attach(), fc_ulp_get_wwn_type(), fc_ulp_put(), fc_ulp_user_init(), fcp_device::fcpcmds, fcpdev_close(), fcpdev_examine(), fcpdev_scsi_desc, INIT_LIST_HEAD, intf_init(), lun, fcp_description::lun, memcpy(), NULL, rc, ref_init, ref_put, fcp_device::refcnt, fcp_device::scsi, scsi_open(), strerror(), fcp_device::user, wwn, fcp_description::wwn, and zalloc().
Referenced by fcp_open().
Parse FCP URI.
uri | URI |
wwn | Fibre Channel WWN |
lun | SCSI LUN |
rc | Return status code |
An FCP URI has the form "fcp:<wwn>:<lun>" or "fcp://<wwn>/<lun>"
Definition at line 1023 of file fcp.c.
References EINVAL, fc_aton(), FC_NAME_STRLEN, uri::host, lun, uri::opaque, uri::path, rc, scsi_parse_lun(), snprintf(), and wwn.
Referenced by fcp_open().
Open FCP URI.
parent | Parent interface |
uri | URI |
rc | Return status code |
Definition at line 1068 of file fcp.c.
References fcp_parse_uri(), fcpdev_open(), lun, rc, and wwn.
struct fc_els_prli_descriptor fcp_prli_descriptor __fc_els_prli_descriptor |
FCP PRLI descriptor.
struct fc_els_handler fcp_prli_handler __fc_els_handler |
FCP PRLI ELS handler.
|
static |
FCP command SCSI interface operations.
|
static |
FCP command SCSI interface descriptor.
Definition at line 714 of file fcp.c.
Referenced by fcpdev_scsi_command().
|
static |
FCP command Fibre Channel exchange interface operations.
|
static |
FCP command Fibre Channel exchange interface descriptor.
Definition at line 724 of file fcp.c.
Referenced by fcpdev_scsi_command().
|
static |
FCP command process descriptor.
Definition at line 728 of file fcp.c.
Referenced by fcpdev_scsi_command().
|
static |
FCP device SCSI interface operations.
|
static |
FCP device SCSI interface descriptor.
Definition at line 919 of file fcp.c.
Referenced by fcpdev_open().
struct uri_opener fcp_uri_opener __uri_opener |
FCP URI opener.