iPXE
|
FCoE protocol. More...
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/if_ether.h>
#include <ipxe/if_arp.h>
#include <ipxe/iobuf.h>
#include <ipxe/interface.h>
#include <ipxe/xfer.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/vlan.h>
#include <ipxe/features.h>
#include <ipxe/errortab.h>
#include <ipxe/device.h>
#include <ipxe/crc32.h>
#include <ipxe/retry.h>
#include <ipxe/timer.h>
#include <ipxe/fc.h>
#include <ipxe/fip.h>
#include <ipxe/fcoe.h>
Go to the source code of this file.
Data Structures | |
struct | fcoe_port |
An FCoE port. More... | |
struct | fip_handler |
A FIP handler. More... | |
Macros | |
#define | EINVAL_UNDERLENGTH __einfo_error ( EINFO_EINVAL_UNDERLENGTH ) |
#define | EINFO_EINVAL_UNDERLENGTH __einfo_uniqify ( EINFO_EINVAL, 0x01, "Underlength packet" ) |
#define | EINVAL_SOF __einfo_error ( EINFO_EINVAL_SOF ) |
#define | EINFO_EINVAL_SOF __einfo_uniqify ( EINFO_EINVAL, 0x02, "Invalid SoF delimiter" ) |
#define | EINVAL_CRC __einfo_error ( EINFO_EINVAL_CRC ) |
#define | EINFO_EINVAL_CRC __einfo_uniqify ( EINFO_EINVAL, 0x03, "Invalid CRC (not stripped?)" ) |
#define | EINVAL_EOF __einfo_error ( EINFO_EINVAL_EOF ) |
#define | EINFO_EINVAL_EOF __einfo_uniqify ( EINFO_EINVAL, 0x04, "Invalid EoF delimiter" ) |
#define | FCOE_MAX_VLAN_REQUESTS 2 |
Maximum number of VLAN requests before giving up on VLAN discovery. More... | |
#define | FCOE_VLAN_RETRY_DELAY ( TICKS_PER_SEC ) |
Delay between retrying VLAN requests. More... | |
#define | FCOE_VLAN_POLL_DELAY ( 30 * TICKS_PER_SEC ) |
Delay between retrying polling VLAN requests. More... | |
#define | FCOE_MAX_FIP_SOLICITATIONS 2 |
Maximum number of FIP solicitations before giving up on FIP. More... | |
#define | FCOE_FIP_RETRY_DELAY ( TICKS_PER_SEC ) |
Delay between retrying FIP solicitations. More... | |
#define | FCOE_MAX_FIP_MISSING_KEEPALIVES 4 |
Maximum number of missing discovery advertisements. More... | |
Enumerations | |
enum | fcoe_flags { FCOE_HAVE_NETWORK = 0x0001, FCOE_HAVE_FCF = 0x0002, FCOE_HAVE_FIP_FCF = 0x0004, FCOE_FCF_ALLOWS_SPMA = 0x0008, FCOE_VLAN_FOUND = 0x0010, FCOE_VLAN_TIMED_OUT = 0x0020 } |
FCoE flags. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
FEATURE (FEATURE_PROTOCOL, "FCoE", DHCP_EB_FEATURE_FCOE, 1) | |
static void | fcoe_reset (struct fcoe_port *fcoe) |
Reset FCoE port. More... | |
static int | fcoe_deliver (struct fcoe_port *fcoe, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Transmit FCoE packet. More... | |
static struct io_buffer * | fcoe_alloc_iob (struct fcoe_port *fcoe __unused, size_t len) |
Allocate FCoE I/O buffer. More... | |
static int | fcoe_rx (struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest, const void *ll_source, unsigned int flags __unused) |
Process incoming FCoE packets. More... | |
static size_t | fcoe_window (struct fcoe_port *fcoe) |
Check FCoE flow control window. More... | |
static void | fcoe_close (struct fcoe_port *fcoe, int rc) |
Close FCoE port. More... | |
static struct device * | fcoe_identify_device (struct fcoe_port *fcoe) |
Identify device underlying FCoE port. More... | |
static int | fcoe_fip_parse (struct fcoe_port *fcoe, struct fip_header *fiphdr, size_t len, struct fip_descriptors *descs) |
Parse FIP packet into descriptor set. More... | |
static int | fcoe_fip_tx_vlan (struct fcoe_port *fcoe) |
Send FIP VLAN request. More... | |
static int | fcoe_fip_rx_vlan (struct fcoe_port *fcoe, struct fip_descriptors *descs, unsigned int flags __unused) |
Handle received FIP VLAN notification. More... | |
static int | fcoe_fip_tx_solicitation (struct fcoe_port *fcoe) |
Send FIP discovery solicitation. More... | |
static int | fcoe_fip_rx_advertisement (struct fcoe_port *fcoe, struct fip_descriptors *descs, unsigned int flags) |
Handle received FIP discovery advertisement. More... | |
static int | fcoe_fip_rx_els_response (struct fcoe_port *fcoe, struct fip_descriptors *descs, unsigned int flags __unused) |
Handle received FIP ELS response. More... | |
static int | fcoe_fip_tx_keepalive (struct fcoe_port *fcoe) |
Send FIP keepalive. More... | |
static int | fcoe_fip_rx (struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest, const void *ll_source __unused, unsigned int flags __unused) |
Process incoming FIP packets. More... | |
static void | fcoe_expired (struct retry_timer *timer, int over __unused) |
Handle FCoE timer expiry. More... | |
static int | fcoe_probe (struct net_device *netdev, void *priv) |
Create FCoE port. More... | |
static void | fcoe_notify (struct net_device *netdev, void *priv) |
Handle FCoE port device or link state change. More... | |
static void | fcoe_remove (struct net_device *netdev __unused, void *priv) |
Destroy FCoE port. More... | |
Variables | |
struct net_driver fcoe_driver | __net_driver |
FCoE driver. More... | |
struct net_protocol fcoe_protocol | __net_protocol |
FCoE protocol. More... | |
static uint8_t | all_fcoe_macs [ETH_ALEN] |
FCoE All-FCoE-MACs address. More... | |
static uint8_t | all_enode_macs [ETH_ALEN] |
FCoE All-ENode-MACs address. More... | |
static uint8_t | all_fcf_macs [ETH_ALEN] |
FCoE All-FCF-MACs address. More... | |
static uint8_t | default_fcf_mac [ETH_ALEN] |
Default FCoE forwarded MAC address. More... | |
static struct interface_operation | fcoe_transport_op [] |
FCoE transport interface operations. More... | |
static struct interface_descriptor | fcoe_transport_desc |
FCoE transport interface descriptor. More... | |
static struct fip_handler | fip_handlers [] |
FIP handlers. More... | |
struct errortab fcoe_errors [] | __errortab |
Human-readable message for CRC errors. More... | |
FCoE protocol.
Definition in file fcoe.c.
#define EINVAL_UNDERLENGTH __einfo_error ( EINFO_EINVAL_UNDERLENGTH ) |
#define EINFO_EINVAL_UNDERLENGTH __einfo_uniqify ( EINFO_EINVAL, 0x01, "Underlength packet" ) |
#define EINVAL_SOF __einfo_error ( EINFO_EINVAL_SOF ) |
#define EINFO_EINVAL_SOF __einfo_uniqify ( EINFO_EINVAL, 0x02, "Invalid SoF delimiter" ) |
#define EINVAL_CRC __einfo_error ( EINFO_EINVAL_CRC ) |
#define EINFO_EINVAL_CRC __einfo_uniqify ( EINFO_EINVAL, 0x03, "Invalid CRC (not stripped?)" ) |
#define EINVAL_EOF __einfo_error ( EINFO_EINVAL_EOF ) |
#define EINFO_EINVAL_EOF __einfo_uniqify ( EINFO_EINVAL, 0x04, "Invalid EoF delimiter" ) |
#define FCOE_MAX_VLAN_REQUESTS 2 |
#define FCOE_VLAN_RETRY_DELAY ( TICKS_PER_SEC ) |
#define FCOE_VLAN_POLL_DELAY ( 30 * TICKS_PER_SEC ) |
#define FCOE_MAX_FIP_SOLICITATIONS 2 |
#define FCOE_FIP_RETRY_DELAY ( TICKS_PER_SEC ) |
#define FCOE_MAX_FIP_MISSING_KEEPALIVES 4 |
enum fcoe_flags |
FCoE flags.
Definition at line 99 of file fcoe.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
FEATURE | ( | FEATURE_PROTOCOL | , |
"FCoE" | , | ||
DHCP_EB_FEATURE_FCOE | , | ||
1 | |||
) |
|
static |
Reset FCoE port.
fcoe | FCoE port |
Definition at line 164 of file fcoe.c.
References DBGC, default_fcf_mac, ECANCELED, fcoe_port::fcf_mac, FCOE_HAVE_NETWORK, FIP_LOWEST_PRIORITY, fcoe_port::flags, intf_restart(), fcoe_port::keepalive, net_device::ll_addr, fcoe_port::local_mac, memcpy(), net_device::name, fcoe_port::netdev, netdev_is_open(), netdev_link_ok(), fcoe_port::priority, start_timer_nodelay(), stop_timer(), fcoe_port::timeouts, fcoe_port::timer, fcoe_port::transport, vlan_can_be_trunk(), and xfer_window_changed().
Referenced by fcoe_expired(), fcoe_fip_rx_advertisement(), and fcoe_notify().
|
static |
Transmit FCoE packet.
fcoe | FCoE port |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 202 of file fcoe.c.
References fip_header::code, fc_els_frame_common::command, cpu_to_le32, fcoe_footer::crc, crc32_le(), io_buffer::data, DBGC, done, fcoe_footer::eof, fc_frame_header::f_ctl_es, fc, FC_ELS_FLOGI, FC_F_CTL_ES_END, FC_R_CTL_ELS, FC_R_CTL_UNSOL_CTRL, fcoe_port::fcf_mac, FCOE_EOF_N, FCOE_EOF_T, FCOE_FCF_ALLOWS_SPMA, FCOE_HAVE_FIP_FCF, FCOE_SOF_I3, FCOE_SOF_N3, FIP_CODE_ELS, FIP_ELS_REQUEST, FIP_FLOGI, FIP_FP, FIP_MAC_ADDRESS, FIP_SP, FIP_VERSION, fip_header::flags, fcoe_port::flags, free_iob(), htons, iob_disown, iob_len(), iob_push, iob_put, fip_header::len, fip_mac_address::len, fip_login::len, net_device::ll_addr, fcoe_port::local_mac, fip_mac_address::mac, memcpy(), memset(), net_device::name, net_tx(), fcoe_port::netdev, ntohs, offsetof, fc_frame_header::r_ctl, rc, fc_frame_header::seq_cnt, fcoe_header::sof, strerror(), fip_header::subcode, fip_mac_address::type, fip_login::type, typeof(), and fip_header::version.
Allocate FCoE I/O buffer.
len | Payload length |
iobuf | I/O buffer, or NULL |
Definition at line 297 of file fcoe.c.
References alloc_iob(), iob_reserve, len, and MAX_LL_HEADER_LEN.
|
static |
Process incoming FCoE packets.
iobuf | I/O buffer |
netdev | Network device |
ll_dest | Link-layer destination address |
ll_source | Link-layer source address |
flags | Packet flags |
rc | Return status code |
Definition at line 320 of file fcoe.c.
References fcoe_footer::crc, crc32_le(), io_buffer::data, DBG, DBGC, DBGC2, default_fcf_mac, done, EINVAL_CRC, EINVAL_EOF, EINVAL_SOF, EINVAL_UNDERLENGTH, ENOTCONN, fcoe_footer::eof, EPROTONOSUPPORT, eth_ntoa(), fcoe_port::fcf_mac, FCOE_EOF_N, FCOE_EOF_T, FCOE_FRAME_VER, FCOE_HAVE_FCF, FCOE_HAVE_FIP_FCF, FCOE_SOF_I3, FCOE_SOF_N3, fcoe_port::flags, free_iob(), iob_disown, iob_len(), iob_pull, iob_unput, le32_to_cpu, fcoe_port::local_mac, memcmp(), memcpy(), net_device::name, netdev, fcoe_port::netdev, netdev_priv(), rc, fcoe_header::sof, strerror(), fcoe_port::transport, fcoe_header::version, and xfer_deliver_iob().
Check FCoE flow control window.
fcoe | FCoE port |
len | Length of window |
Definition at line 416 of file fcoe.c.
References FCOE_HAVE_FCF, and fcoe_port::flags.
|
static |
Close FCoE port.
fcoe | FCoE port |
rc | Reason for close |
Definition at line 426 of file fcoe.c.
References intf_shutdown(), rc, stop_timer(), fcoe_port::timer, and fcoe_port::transport.
Referenced by fcoe_remove().
Identify device underlying FCoE port.
fcoe | FCoE port |
device | Underlying device |
Definition at line 438 of file fcoe.c.
References net_device::dev, and fcoe_port::netdev.
|
static |
Parse FIP packet into descriptor set.
fcoe | FCoE port |
fiphdr | FIP header |
len | Length of FIP packet |
descs | Descriptor set to fill in |
rc | Return status code |
Definition at line 472 of file fcoe.c.
References DBGC, desc, fip_descriptors::desc, EINVAL, ENOTSUP, FIP_IS_CRITICAL, FIP_NUM_DESCRIPTOR_TYPES, FIP_RESERVED, FIP_VERSION, len, fip_header::len, memset(), net_device::name, fcoe_port::netdev, ntohs, NULL, and fip_header::version.
Referenced by fcoe_fip_rx().
|
static |
Send FIP VLAN request.
fcoe | FCoE port |
rc | Return status code |
Definition at line 545 of file fcoe.c.
References __attribute__, all_fcf_macs, alloc_iob(), DBGC, ENOMEM, FIP_CODE_VLAN, FIP_MAC_ADDRESS, FIP_VERSION, FIP_VLAN_REQUEST, hdr, htons, iob_disown, iob_put, iob_reserve, net_device::ll_addr, MAX_LL_HEADER_LEN, memcpy(), memset(), net_device::name, net_tx(), fcoe_port::netdev, rc, request, and strerror().
Referenced by fcoe_expired().
|
static |
Handle received FIP VLAN notification.
fcoe | FCoE port |
descs | Descriptor list |
flags | Flags |
rc | Return status code |
Definition at line 593 of file fcoe.c.
References DBGC, EINVAL, eth_ntoa(), FCOE_VLAN_FOUND, FCOE_VLAN_PRIORITY, fcoe_port::flags, fip_mac_address::mac, net_device::name, fcoe_port::netdev, ntohs, rc, strerror(), tag, fip_vlan::vlan, and vlan_create().
|
static |
Send FIP discovery solicitation.
fcoe | FCoE port |
rc | Return status code |
Definition at line 639 of file fcoe.c.
References __attribute__, all_fcf_macs, alloc_iob(), DBGC, ENOMEM, ETH_MAX_MTU, fcoe_name::fc, FIP_CODE_DISCOVERY, FIP_DISCOVERY_SOLICIT, FIP_FP, FIP_MAC_ADDRESS, FIP_MAX_FCOE_SIZE, FIP_NAME_ID, FIP_SP, FIP_VERSION, hdr, htons, iob_disown, iob_put, iob_reserve, net_device::ll_addr, MAX_LL_HEADER_LEN, memcpy(), memset(), net_device::name, net_tx(), fcoe_port::netdev, fcoe_port::node_wwn, rc, and strerror().
Referenced by fcoe_expired().
|
static |
Handle received FIP discovery advertisement.
fcoe | FCoE port |
descs | Descriptor list |
flags | Flags |
rc | Return status code |
Definition at line 700 of file fcoe.c.
References DBGC, EINVAL, eth_ntoa(), fcoe_port::fcf_mac, FCOE_FCF_ALLOWS_SPMA, FCOE_HAVE_FCF, FCOE_HAVE_FIP_FCF, fcoe_reset(), FIP_A, FIP_F, FIP_NO_KEEPALIVE, FIP_S, FIP_SP, flags, fcoe_port::flags, fip_fka_adv_p::flags, fcoe_port::keepalive, fip_mac_address::mac, memcmp(), memcpy(), net_device::name, fcoe_port::netdev, ntohl, fip_fka_adv_p::period, priority, fcoe_port::priority, and fcoe_port::timeouts.
|
static |
Handle received FIP ELS response.
fcoe | FCoE port |
descs | Descriptor list |
flags | Flags |
rc | Return status code |
Definition at line 790 of file fcoe.c.
References DBGC, EINVAL, eth_ntoa(), fc, fip_els::fc, frame, fip_els::len, fcoe_port::local_mac, fip_mac_address::mac, memcpy(), net_device::name, fcoe_port::netdev, offsetof, rc, strerror(), fcoe_port::transport, typeof(), and xfer_deliver_raw().
|
static |
Send FIP keepalive.
fcoe | FCoE port |
rc | Return status code |
Definition at line 835 of file fcoe.c.
References __attribute__, alloc_iob(), DBGC, ENOMEM, fcoe_port::fcf_mac, FIP_CODE_MAINTAIN, FIP_MAC_ADDRESS, FIP_MAINTAIN_KEEP_ALIVE, FIP_VERSION, hdr, htons, iob_disown, iob_put, iob_reserve, net_device::ll_addr, MAX_LL_HEADER_LEN, memcpy(), memset(), net_device::name, net_tx(), fcoe_port::netdev, rc, and strerror().
Referenced by fcoe_expired().
|
static |
Process incoming FIP packets.
iobuf | I/O buffer |
netdev | Network device |
ll_dest | Link-layer destination address |
ll_source | Link-layer source address |
flags | Packet flags |
rc | Return status code |
Definition at line 913 of file fcoe.c.
References all_enode_macs, all_fcoe_macs, fip_header::code, fip_handler::code, io_buffer::data, DBG, DBGC, DBGC2, done, ENOTCONN, ENOTSUP, ETH_ALEN, eth_ntoa(), fcoe_fip_parse(), fip_handlers, fip_header::flags, free_iob(), iob_len(), net_device::ll_addr, memcmp(), net_device::name, netdev, fcoe_port::netdev, netdev_priv(), ntohs, rc, fip_handler::rx, fip_header::subcode, and fip_handler::subcode.
|
static |
Handle FCoE timer expiry.
timer | FIP timer |
over | Timer expired |
Definition at line 984 of file fcoe.c.
References assert(), container_of, DBGC, eth_ntoa(), fcoe_name::fc, fc_port_open(), fcoe_port::fcf_mac, FCOE_FIP_RETRY_DELAY, fcoe_fip_tx_keepalive(), fcoe_fip_tx_solicitation(), fcoe_fip_tx_vlan(), FCOE_HAVE_FCF, FCOE_HAVE_FIP_FCF, FCOE_HAVE_NETWORK, FCOE_MAX_FIP_MISSING_KEEPALIVES, FCOE_MAX_FIP_SOLICITATIONS, FCOE_MAX_VLAN_REQUESTS, fcoe_reset(), FCOE_VLAN_FOUND, FCOE_VLAN_POLL_DELAY, FCOE_VLAN_RETRY_DELAY, FCOE_VLAN_TIMED_OUT, fcoe_port::flags, fcoe_port::keepalive, net_device::name, fcoe_port::netdev, fcoe_port::node_wwn, fcoe_port::port_wwn, rc, start_timer_fixed(), start_timer_nodelay(), stop_timer(), strerror(), TICKS_PER_MS, fcoe_port::timeouts, fcoe_port::timer, fcoe_port::transport, vlan_can_be_trunk(), and xfer_window_changed().
Referenced by fcoe_probe().
|
static |
Create FCoE port.
netdev | Network device |
priv | Private data |
rc | Return status code |
Definition at line 1093 of file fcoe.c.
References ARPHRD_ETHER, fcoe_name::authority, DBG, DBGC, fcoe_name::fc, fc_ntoa(), fcoe_name::fcoe, FCOE_AUTHORITY_IEEE, FCOE_AUTHORITY_IEEE_EXTENDED, fcoe_expired(), fcoe_transport_desc, htons, intf_init(), net_device::ll_addr, ll_protocol::ll_proto, net_device::ll_protocol, fcoe_name::mac, memcpy(), net_device::name, netdev, fcoe_port::netdev, fcoe_port::node_wwn, fcoe_port::port_wwn, priv, net_device::refcnt, fcoe_port::timer, and fcoe_port::transport.
|
static |
Handle FCoE port device or link state change.
netdev | Network device |
priv | Private data |
Definition at line 1130 of file fcoe.c.
References FCOE_HAVE_NETWORK, fcoe_reset(), fcoe_port::flags, netdev, fcoe_port::netdev, netdev_is_open(), netdev_link_ok(), and priv.
|
static |
Destroy FCoE port.
netdev | Network device |
priv | Private data |
Definition at line 1151 of file fcoe.c.
References fcoe_close(), fcoe_port::netdev, and priv.
struct net_driver fcoe_driver __net_driver |
FCoE driver.
struct net_protocol fip_protocol __net_protocol |
FCoE protocol.
AoE protocol.
FIP protocol.
FCoE All-FCoE-MACs address.
Definition at line 119 of file fcoe.c.
Referenced by fcoe_fip_rx().
FCoE All-ENode-MACs address.
Definition at line 123 of file fcoe.c.
Referenced by fcoe_fip_rx().
FCoE All-FCF-MACs address.
Definition at line 127 of file fcoe.c.
Referenced by fcoe_fip_tx_solicitation(), and fcoe_fip_tx_vlan().
Default FCoE forwarded MAC address.
Definition at line 131 of file fcoe.c.
Referenced by fcoe_reset(), and fcoe_rx().
|
static |
FCoE transport interface operations.
|
static |
FCoE transport interface descriptor.
Definition at line 453 of file fcoe.c.
Referenced by fcoe_probe().
|
static |
FIP handlers.
Definition at line 894 of file fcoe.c.
Referenced by fcoe_fip_rx().
struct errortab fcoe_errors [] __errortab |
Human-readable message for CRC errors.
It seems as though several drivers neglect to strip the Ethernet CRC, which will cause the FCoE footer to be misplaced and result (coincidentally) in an "invalid CRC" error from FCoE.