iPXE
Data Structures | Macros | Enumerations | Functions | Variables
fcoe.c File Reference

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 LIST_HEAD (fcoe_ports)
 List of FCoE ports. More...
 
static struct fcoe_portfcoe_demux (struct net_device *netdev)
 Identify FCoE port by network device. More...
 
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_bufferfcoe_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 devicefcoe_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)
 Create FCoE port. More...
 
static void fcoe_notify (struct net_device *netdev)
 Handle FCoE port device or link state change. More...
 
static void fcoe_remove (struct net_device *netdev)
 Destroy FCoE port. More...
 

Variables

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 net_driver fcoe_driver __net_driver
 FCoE driver. More...
 
struct errortab fcoe_errors [] __errortab
 Human-readable message for CRC errors. More...
 

Detailed Description

FCoE protocol.

Definition in file fcoe.c.

Macro Definition Documentation

◆ EINVAL_UNDERLENGTH

#define EINVAL_UNDERLENGTH   __einfo_error ( EINFO_EINVAL_UNDERLENGTH )

Definition at line 57 of file fcoe.c.

◆ EINFO_EINVAL_UNDERLENGTH

#define EINFO_EINVAL_UNDERLENGTH   __einfo_uniqify ( EINFO_EINVAL, 0x01, "Underlength packet" )

Definition at line 58 of file fcoe.c.

◆ EINVAL_SOF

#define EINVAL_SOF   __einfo_error ( EINFO_EINVAL_SOF )

Definition at line 60 of file fcoe.c.

◆ EINFO_EINVAL_SOF

#define EINFO_EINVAL_SOF   __einfo_uniqify ( EINFO_EINVAL, 0x02, "Invalid SoF delimiter" )

Definition at line 61 of file fcoe.c.

◆ EINVAL_CRC

#define EINVAL_CRC   __einfo_error ( EINFO_EINVAL_CRC )

Definition at line 63 of file fcoe.c.

◆ EINFO_EINVAL_CRC

#define EINFO_EINVAL_CRC   __einfo_uniqify ( EINFO_EINVAL, 0x03, "Invalid CRC (not stripped?)" )

Definition at line 64 of file fcoe.c.

◆ EINVAL_EOF

#define EINVAL_EOF   __einfo_error ( EINFO_EINVAL_EOF )

Definition at line 66 of file fcoe.c.

◆ EINFO_EINVAL_EOF

#define EINFO_EINVAL_EOF   __einfo_uniqify ( EINFO_EINVAL, 0x04, "Invalid EoF delimiter" )

Definition at line 67 of file fcoe.c.

◆ FCOE_MAX_VLAN_REQUESTS

#define FCOE_MAX_VLAN_REQUESTS   2

Maximum number of VLAN requests before giving up on VLAN discovery.

Definition at line 138 of file fcoe.c.

◆ FCOE_VLAN_RETRY_DELAY

#define FCOE_VLAN_RETRY_DELAY   ( TICKS_PER_SEC )

Delay between retrying VLAN requests.

Definition at line 141 of file fcoe.c.

◆ FCOE_VLAN_POLL_DELAY

#define FCOE_VLAN_POLL_DELAY   ( 30 * TICKS_PER_SEC )

Delay between retrying polling VLAN requests.

Definition at line 144 of file fcoe.c.

◆ FCOE_MAX_FIP_SOLICITATIONS

#define FCOE_MAX_FIP_SOLICITATIONS   2

Maximum number of FIP solicitations before giving up on FIP.

Definition at line 147 of file fcoe.c.

◆ FCOE_FIP_RETRY_DELAY

#define FCOE_FIP_RETRY_DELAY   ( TICKS_PER_SEC )

Delay between retrying FIP solicitations.

Definition at line 150 of file fcoe.c.

◆ FCOE_MAX_FIP_MISSING_KEEPALIVES

#define FCOE_MAX_FIP_MISSING_KEEPALIVES   4

Maximum number of missing discovery advertisements.

Definition at line 153 of file fcoe.c.

Enumeration Type Documentation

◆ fcoe_flags

enum fcoe_flags

FCoE flags.

Enumerator
FCOE_HAVE_NETWORK 

Underlying network device is available.

FCOE_HAVE_FCF 

We have selected an FCoE forwarder to use.

FCOE_HAVE_FIP_FCF 

We have a FIP-capable FCoE forwarder available to be used.

FCOE_FCF_ALLOWS_SPMA 

FCoE forwarder supports server-provided MAC addresses.

FCOE_VLAN_FOUND 

An alternative VLAN has been found.

FCOE_VLAN_TIMED_OUT 

VLAN discovery has timed out.

Definition at line 103 of file fcoe.c.

103  {
104  /** Underlying network device is available */
105  FCOE_HAVE_NETWORK = 0x0001,
106  /** We have selected an FCoE forwarder to use */
107  FCOE_HAVE_FCF = 0x0002,
108  /** We have a FIP-capable FCoE forwarder available to be used */
109  FCOE_HAVE_FIP_FCF = 0x0004,
110  /** FCoE forwarder supports server-provided MAC addresses */
111  FCOE_FCF_ALLOWS_SPMA = 0x0008,
112  /** An alternative VLAN has been found */
113  FCOE_VLAN_FOUND = 0x0010,
114  /** VLAN discovery has timed out */
115  FCOE_VLAN_TIMED_OUT = 0x0020,
116 };
An alternative VLAN has been found.
Definition: fcoe.c:113
Underlying network device is available.
Definition: fcoe.c:105
We have a FIP-capable FCoE forwarder available to be used.
Definition: fcoe.c:109
FCoE forwarder supports server-provided MAC addresses.
Definition: fcoe.c:111
VLAN discovery has timed out.
Definition: fcoe.c:115
We have selected an FCoE forwarder to use.
Definition: fcoe.c:107

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FEATURE()

FEATURE ( FEATURE_PROTOCOL  ,
"FCoE"  ,
DHCP_EB_FEATURE_FCOE  ,
 
)

◆ LIST_HEAD()

static LIST_HEAD ( fcoe_ports  )
static

List of FCoE ports.

◆ fcoe_demux()

static struct fcoe_port* fcoe_demux ( struct net_device netdev)
static

Identify FCoE port by network device.

Parameters
netdevNetwork device
Return values
fcoeFCoE port, or NULL

Definition at line 171 of file fcoe.c.

171  {
172  struct fcoe_port *fcoe;
173 
174  list_for_each_entry ( fcoe, &fcoe_ports, list ) {
175  if ( fcoe->netdev == netdev )
176  return fcoe;
177  }
178  return NULL;
179 }
struct list_head list
List of FCoE ports.
Definition: fcoe.c:75
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
static struct net_device * netdev
Definition: gdbudp.c:52
An FCoE port.
Definition: fcoe.c:71
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References fcoe_port::list, list_for_each_entry, netdev, fcoe_port::netdev, and NULL.

Referenced by fcoe_fip_rx(), fcoe_notify(), fcoe_remove(), and fcoe_rx().

◆ fcoe_reset()

static void fcoe_reset ( struct fcoe_port fcoe)
static

Reset FCoE port.

Parameters
fcoeFCoE port

Definition at line 186 of file fcoe.c.

186  {
187 
188  /* Detach FC port, if any */
189  intf_restart ( &fcoe->transport, -ECANCELED );
190 
191  /* Reset any FIP state */
192  stop_timer ( &fcoe->timer );
193  fcoe->timeouts = 0;
194  fcoe->flags = 0;
195  fcoe->priority = ( FIP_LOWEST_PRIORITY + 1 );
196  fcoe->keepalive = 0;
197  memcpy ( fcoe->fcf_mac, default_fcf_mac,
198  sizeof ( fcoe->fcf_mac ) );
199  memcpy ( fcoe->local_mac, fcoe->netdev->ll_addr,
200  sizeof ( fcoe->local_mac ) );
201 
202  /* Start FIP solicitation if network is available */
203  if ( netdev_is_open ( fcoe->netdev ) &&
204  netdev_link_ok ( fcoe->netdev ) ) {
205  fcoe->flags |= FCOE_HAVE_NETWORK;
206  start_timer_nodelay ( &fcoe->timer );
207  DBGC ( fcoe, "FCoE %s starting %s\n", fcoe->netdev->name,
208  ( vlan_can_be_trunk ( fcoe->netdev ) ?
209  "VLAN discovery" : "FIP solicitation" ) );
210  }
211 
212  /* Send notification of window change */
213  xfer_window_changed ( &fcoe->transport );
214 }
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:145
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
Definition: interface.c:337
unsigned int priority
FCoE forwarder priority.
Definition: fcoe.c:93
#define FIP_LOWEST_PRIORITY
Lowest FIP priority.
Definition: fip.h:142
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
unsigned int flags
Flags.
Definition: fcoe.c:91
struct net_device * netdev
Network device.
Definition: fcoe.c:79
unsigned int timeouts
FIP timeout counter.
Definition: fcoe.c:89
#define DBGC(...)
Definition: compiler.h:505
Underlying network device is available.
Definition: fcoe.c:105
uint8_t local_mac[ETH_ALEN]
Local MAC address.
Definition: fcoe.c:99
#define ECANCELED
Operation canceled.
Definition: errno.h:343
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:652
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
struct retry_timer timer
FIP retransmission timer.
Definition: fcoe.c:87
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
int vlan_can_be_trunk(struct net_device *trunk)
Check if network device can be used as a VLAN trunk device.
Definition: vlan.c:324
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
unsigned int keepalive
Keepalive delay (in ms)
Definition: fcoe.c:95
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
static uint8_t default_fcf_mac[ETH_ALEN]
Default FCoE forwarded MAC address.
Definition: fcoe.c:134
uint8_t fcf_mac[ETH_ALEN]
FCoE forwarder MAC address.
Definition: fcoe.c:97
struct interface transport
Transport interface.
Definition: fcoe.c:77

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().

◆ fcoe_deliver()

static int fcoe_deliver ( struct fcoe_port fcoe,
struct io_buffer iobuf,
struct xfer_metadata *meta  __unused 
)
static

Transmit FCoE packet.

Parameters
fcoeFCoE port
iobufI/O buffer
metaData transfer metadata
Return values
rcReturn status code

Definition at line 224 of file fcoe.c.

226  {
227  struct fc_frame_header *fchdr = iobuf->data;
228  struct fc_els_frame_common *els = ( iobuf->data + sizeof ( *fchdr ) );
229  struct fcoe_header *fcoehdr;
230  struct fcoe_footer *fcoeftr;
231  struct fip_header *fiphdr;
232  struct fip_login *fipflogi;
233  struct fip_mac_address *fipmac;
234  uint32_t crc;
235  struct net_protocol *net_protocol;
236  void *ll_source;
237  int rc;
238 
239  /* Send as FIP or FCoE as appropriate */
240  if ( ( fchdr->r_ctl == ( FC_R_CTL_ELS | FC_R_CTL_UNSOL_CTRL ) ) &&
241  ( els->command == FC_ELS_FLOGI ) &&
242  ( fcoe->flags & FCOE_HAVE_FIP_FCF ) ) {
243 
244  /* Create FIP FLOGI descriptor */
245  fipflogi = iob_push ( iobuf,
246  offsetof ( typeof ( *fipflogi ), fc ) );
247  memset ( fipflogi, 0, offsetof ( typeof ( *fipflogi ), fc ) );
248  fipflogi->type = FIP_FLOGI;
249  fipflogi->len = ( iob_len ( iobuf ) / 4 );
250 
251  /* Create FIP MAC address descriptor */
252  fipmac = iob_put ( iobuf, sizeof ( *fipmac ) );
253  memset ( fipmac, 0, sizeof ( *fipmac ) );
254  fipmac->type = FIP_MAC_ADDRESS;
255  fipmac->len = ( sizeof ( *fipmac ) / 4 );
256  if ( fcoe->flags & FCOE_FCF_ALLOWS_SPMA ) {
257  memcpy ( fipmac->mac, fcoe->netdev->ll_addr,
258  sizeof ( fipmac->mac ) );
259  }
260 
261  /* Create FIP header */
262  fiphdr = iob_push ( iobuf, sizeof ( *fiphdr ) );
263  memset ( fiphdr, 0, sizeof ( *fiphdr ) );
264  fiphdr->version = FIP_VERSION;
265  fiphdr->code = htons ( FIP_CODE_ELS );
266  fiphdr->subcode = FIP_ELS_REQUEST;
267  fiphdr->len =
268  htons ( ( iob_len ( iobuf ) - sizeof ( *fiphdr ) ) / 4);
269  fiphdr->flags = ( ( fcoe->flags & FCOE_FCF_ALLOWS_SPMA ) ?
270  htons ( FIP_SP ) : htons ( FIP_FP ) );
271 
272  /* Send as FIP packet from netdev's own MAC address */
273  net_protocol = &fip_protocol;
274  ll_source = fcoe->netdev->ll_addr;
275 
276  } else {
277 
278  /* Calculate CRC */
279  crc = crc32_le ( ~((uint32_t)0), iobuf->data,
280  iob_len ( iobuf ) );
281 
282  /* Create FCoE header */
283  fcoehdr = iob_push ( iobuf, sizeof ( *fcoehdr ) );
284  memset ( fcoehdr, 0, sizeof ( *fcoehdr ) );
285  fcoehdr->sof = ( ( fchdr->seq_cnt == ntohs ( 0 ) ) ?
287 
288  /* Create FCoE footer */
289  fcoeftr = iob_put ( iobuf, sizeof ( *fcoeftr ) );
290  memset ( fcoeftr, 0, sizeof ( *fcoeftr ) );
291  fcoeftr->crc = cpu_to_le32 ( crc ^ ~((uint32_t)0) );
292  fcoeftr->eof = ( ( fchdr->f_ctl_es & FC_F_CTL_ES_END ) ?
294 
295  /* Send as FCoE packet from FCoE MAC address */
296  net_protocol = &fcoe_protocol;
297  ll_source = fcoe->local_mac;
298  }
299 
300  /* Transmit packet */
301  if ( ( rc = net_tx ( iob_disown ( iobuf ), fcoe->netdev, net_protocol,
302  fcoe->fcf_mac, ll_source ) ) != 0 ) {
303  DBGC ( fcoe, "FCoE %s could not transmit: %s\n",
304  fcoe->netdev->name, strerror ( rc ) );
305  goto done;
306  }
307 
308  done:
309  free_iob ( iobuf );
310  return rc;
311 }
A FIP descriptor containing an encapsulated login frame.
Definition: fip.h:219
Fibre Channel ELS frame common parameters.
Definition: fcels.h:22
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
unsigned int flags
Flags.
Definition: fcoe.c:91
Fabric Login.
Definition: fcels.h:34
struct net_device * netdev
Network device.
Definition: fcoe.c:79
uint16_t seq_cnt
Sequence count.
Definition: fc.h:146
#define iob_push(iobuf, len)
Definition: iobuf.h:80
u16 fc
802.11 Frame Control field
Definition: ieee80211.h:14
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define FIP_VERSION
FIP frame version.
Definition: fip.h:47
uint8_t command
ELS command code.
Definition: fcels.h:24
#define DBGC(...)
Definition: compiler.h:505
MAC address.
Definition: fip.h:104
FLOGI.
Definition: fip.h:109
Extended Link Services.
Definition: fc.h:162
#define ntohs(value)
Definition: byteswap.h:136
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
uint8_t local_mac[ETH_ALEN]
Local MAC address.
Definition: fcoe.c:99
An FCoE header.
Definition: fcoe.h:50
Last Data Frame of Sequence.
Definition: fc.h:203
uint8_t type
Type.
Definition: fip.h:147
Unsolicited Control.
Definition: fc.h:178
uint8_t len
Length in 32-bit words.
Definition: fip.h:223
End of Frame Terminate.
Definition: fcoe.h:84
u32 crc32_le(u32 seed, const void *data, size_t len)
Calculate 32-bit little-endian CRC checksum.
Definition: crc32.c:39
uint16_t code
Protocol code.
Definition: fip.h:35
A FIP frame header.
Definition: fip.h:29
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:208
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint16_t flags
Flags.
Definition: fip.h:43
We have a FIP-capable FCoE forwarder available to be used.
Definition: fcoe.c:109
uint8_t version
Frame version.
Definition: fip.h:31
#define cpu_to_le32(value)
Definition: byteswap.h:107
FCoE forwarder supports server-provided MAC addresses.
Definition: fcoe.c:111
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint8_t len
Length in 32-bit words.
Definition: fip.h:149
uint8_t r_ctl
Routing control.
Definition: fc.h:126
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
uint16_t len
Descriptor list length in 32-bit words.
Definition: fip.h:41
A FIP MAC address descriptor.
Definition: fip.h:145
unsigned int uint32_t
Definition: stdint.h:12
A network-layer protocol.
Definition: netdevice.h:64
uint8_t f_ctl_es
Frame control - exchange and sequence.
Definition: fc.h:136
Start of Frame Initiate Class 3.
Definition: fcoe.h:67
Extended link services.
Definition: fip.h:52
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
Definition: netdevice.c:999
void * data
Start of data.
Definition: iobuf.h:44
uint8_t mac[ETH_ALEN]
MAC address.
Definition: fip.h:151
uint8_t sof
Start of Frame marker.
Definition: fcoe.h:56
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
Fabric-provided MAC address.
Definition: fip.h:83
uint8_t subcode
Subcode.
Definition: fip.h:39
ELS request.
Definition: fip.h:65
uint8_t type
Type.
Definition: fip.h:221
Start of Frame Normal Class 3.
Definition: fcoe.h:68
#define htons(value)
Definition: byteswap.h:135
struct bofm_section_header done
Definition: bofm_test.c:46
uint8_t fcf_mac[ETH_ALEN]
FCoE forwarder MAC address.
Definition: fcoe.c:97
Server-provided MAC address.
Definition: fip.h:84
End of Frame Normal.
Definition: fcoe.h:83
A Fibre Channel Frame Header.
Definition: fc.h:120
void * memset(void *dest, int character, size_t len) __nonnull

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, and fip_header::version.

◆ fcoe_alloc_iob()

static struct io_buffer* fcoe_alloc_iob ( struct fcoe_port *fcoe  __unused,
size_t  len 
)
static

Allocate FCoE I/O buffer.

Parameters
lenPayload length
Return values
iobufI/O buffer, or NULL

Definition at line 319 of file fcoe.c.

320  {
321  struct io_buffer *iobuf;
322 
323  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( struct fcoe_header ) +
324  len + sizeof ( struct fcoe_footer ) );
325  if ( iobuf ) {
326  iob_reserve ( iobuf, ( MAX_LL_HEADER_LEN +
327  sizeof ( struct fcoe_header ) ) );
328  }
329  return iobuf;
330 }
An FCoE header.
Definition: fcoe.h:50
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:45
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
uint32_t len
Length.
Definition: ena.h:14
A persistent I/O buffer.
Definition: iobuf.h:32

References alloc_iob(), iob_reserve, len, and MAX_LL_HEADER_LEN.

◆ fcoe_rx()

static int fcoe_rx ( struct io_buffer iobuf,
struct net_device netdev,
const void *  ll_dest,
const void *  ll_source,
unsigned int flags  __unused 
)
static

Process incoming FCoE packets.

Parameters
iobufI/O buffer
netdevNetwork device
ll_destLink-layer destination address
ll_sourceLink-layer source address
flagsPacket flags
Return values
rcReturn status code

Definition at line 342 of file fcoe.c.

344  {
345  struct fcoe_header *fcoehdr;
346  struct fcoe_footer *fcoeftr;
347  struct fcoe_port *fcoe;
348  int rc;
349 
350  /* Identify FCoE port */
351  if ( ( fcoe = fcoe_demux ( netdev ) ) == NULL ) {
352  DBG ( "FCoE received frame for net device %s missing FCoE "
353  "port\n", netdev->name );
354  rc = -ENOTCONN;
355  goto done;
356  }
357 
358  /* Discard packets not destined for us */
359  if ( ( memcmp ( fcoe->local_mac, ll_dest,
360  sizeof ( fcoe->local_mac ) ) != 0 ) &&
361  ( memcmp ( default_fcf_mac, ll_dest,
362  sizeof ( default_fcf_mac ) ) != 0 ) ) {
363  DBGC2 ( fcoe, "FCoE %s ignoring packet for %s\n",
364  fcoe->netdev->name, eth_ntoa ( ll_dest ) );
365  rc = -ENOTCONN;
366  goto done;
367  }
368 
369  /* Sanity check */
370  if ( iob_len ( iobuf ) < ( sizeof ( *fcoehdr ) + sizeof ( *fcoeftr ) )){
371  DBGC ( fcoe, "FCoE %s received under-length frame (%zd "
372  "bytes)\n", fcoe->netdev->name, iob_len ( iobuf ) );
374  goto done;
375  }
376 
377  /* Strip header and footer */
378  fcoehdr = iobuf->data;
379  iob_pull ( iobuf, sizeof ( *fcoehdr ) );
380  fcoeftr = ( iobuf->data + iob_len ( iobuf ) - sizeof ( *fcoeftr ) );
381  iob_unput ( iobuf, sizeof ( *fcoeftr ) );
382 
383  /* Validity checks */
384  if ( fcoehdr->version != FCOE_FRAME_VER ) {
385  DBGC ( fcoe, "FCoE %s received unsupported frame version "
386  "%02x\n", fcoe->netdev->name, fcoehdr->version );
387  rc = -EPROTONOSUPPORT;
388  goto done;
389  }
390  if ( ! ( ( fcoehdr->sof == FCOE_SOF_I3 ) ||
391  ( fcoehdr->sof == FCOE_SOF_N3 ) ) ) {
392  DBGC ( fcoe, "FCoE %s received unsupported start-of-frame "
393  "delimiter %02x\n", fcoe->netdev->name, fcoehdr->sof );
394  rc = -EINVAL_SOF;
395  goto done;
396  }
397  if ( ( le32_to_cpu ( fcoeftr->crc ) ^ ~((uint32_t)0) ) !=
398  crc32_le ( ~((uint32_t)0), iobuf->data, iob_len ( iobuf ) ) ) {
399  DBGC ( fcoe, "FCoE %s received invalid CRC\n",
400  fcoe->netdev->name );
401  rc = -EINVAL_CRC;
402  goto done;
403  }
404  if ( ! ( ( fcoeftr->eof == FCOE_EOF_N ) ||
405  ( fcoeftr->eof == FCOE_EOF_T ) ) ) {
406  DBGC ( fcoe, "FCoE %s received unsupported end-of-frame "
407  "delimiter %02x\n", fcoe->netdev->name, fcoeftr->eof );
408  rc = -EINVAL_EOF;
409  goto done;
410  }
411 
412  /* Record FCF address if applicable */
413  if ( ( fcoe->flags & FCOE_HAVE_FCF ) &&
414  ( ! ( fcoe->flags & FCOE_HAVE_FIP_FCF ) ) ) {
415  memcpy ( &fcoe->fcf_mac, ll_source, sizeof ( fcoe->fcf_mac ) );
416  }
417 
418  /* Hand off via transport interface */
419  if ( ( rc = xfer_deliver_iob ( &fcoe->transport,
420  iob_disown ( iobuf ) ) ) != 0 ) {
421  DBGC ( fcoe, "FCoE %s could not deliver frame: %s\n",
422  fcoe->netdev->name, strerror ( rc ) );
423  goto done;
424  }
425 
426  done:
427  free_iob ( iobuf );
428  return rc;
429 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:98
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EINVAL_UNDERLENGTH
Definition: fcoe.c:57
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
Definition: xfer.c:254
unsigned int flags
Flags.
Definition: fcoe.c:91
#define le32_to_cpu(value)
Definition: byteswap.h:113
struct net_device * netdev
Network device.
Definition: fcoe.c:79
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define DBGC(...)
Definition: compiler.h:505
uint8_t version
FCoE frame version.
Definition: fcoe.h:52
uint8_t local_mac[ETH_ALEN]
Local MAC address.
Definition: fcoe.c:99
An FCoE header.
Definition: fcoe.h:50
static struct fcoe_port * fcoe_demux(struct net_device *netdev)
Identify FCoE port by network device.
Definition: fcoe.c:171
End of Frame Terminate.
Definition: fcoe.h:84
u32 crc32_le(u32 seed, const void *data, size_t len)
Calculate 32-bit little-endian CRC checksum.
Definition: crc32.c:39
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:208
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
We have a FIP-capable FCoE forwarder available to be used.
Definition: fcoe.c:109
#define ENOTCONN
The socket is not connected.
Definition: errno.h:569
#define iob_unput(iobuf, len)
Definition: iobuf.h:131
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
An FCoE port.
Definition: fcoe.c:71
unsigned int uint32_t
Definition: stdint.h:12
#define EINVAL_CRC
Definition: fcoe.c:63
#define EINVAL_EOF
Definition: fcoe.c:66
Start of Frame Initiate Class 3.
Definition: fcoe.h:67
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
#define DBGC2(...)
Definition: compiler.h:522
#define EPROTONOSUPPORT
Protocol not supported.
Definition: errno.h:629
#define EINVAL_SOF
Definition: fcoe.c:60
void * data
Start of data.
Definition: iobuf.h:44
We have selected an FCoE forwarder to use.
Definition: fcoe.c:107
uint8_t sof
Start of Frame marker.
Definition: fcoe.h:56
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define FCOE_FRAME_VER
FCoE frame version.
Definition: fcoe.h:60
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
static uint8_t default_fcf_mac[ETH_ALEN]
Default FCoE forwarded MAC address.
Definition: fcoe.c:134
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
Start of Frame Normal Class 3.
Definition: fcoe.h:68
struct bofm_section_header done
Definition: bofm_test.c:46
uint8_t fcf_mac[ETH_ALEN]
FCoE forwarder MAC address.
Definition: fcoe.c:97
struct interface transport
Transport interface.
Definition: fcoe.c:77
End of Frame Normal.
Definition: fcoe.h:83

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_demux(), 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, NULL, rc, fcoe_header::sof, strerror(), fcoe_port::transport, fcoe_header::version, and xfer_deliver_iob().

◆ fcoe_window()

static size_t fcoe_window ( struct fcoe_port fcoe)
static

Check FCoE flow control window.

Parameters
fcoeFCoE port
Return values
lenLength of window

Definition at line 437 of file fcoe.c.

437  {
438  return ( ( fcoe->flags & FCOE_HAVE_FCF ) ? ~( ( size_t ) 0 ) : 0 );
439 }
unsigned int flags
Flags.
Definition: fcoe.c:91
We have selected an FCoE forwarder to use.
Definition: fcoe.c:107

References FCOE_HAVE_FCF, and fcoe_port::flags.

◆ fcoe_close()

static void fcoe_close ( struct fcoe_port fcoe,
int  rc 
)
static

Close FCoE port.

Parameters
fcoeFCoE port
rcReason for close

Definition at line 447 of file fcoe.c.

447  {
448 
449  stop_timer ( &fcoe->timer );
450  intf_shutdown ( &fcoe->transport, rc );
451  netdev_put ( fcoe->netdev );
452  list_del ( &fcoe->list );
453  ref_put ( &fcoe->refcnt );
454 }
struct list_head list
List of FCoE ports.
Definition: fcoe.c:75
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:273
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct refcnt refcnt
Reference count.
Definition: fcoe.c:73
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
struct retry_timer timer
FIP retransmission timer.
Definition: fcoe.c:87
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
struct interface transport
Transport interface.
Definition: fcoe.c:77
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References intf_shutdown(), fcoe_port::list, list_del, fcoe_port::netdev, netdev_put(), rc, ref_put, fcoe_port::refcnt, stop_timer(), fcoe_port::timer, and fcoe_port::transport.

Referenced by fcoe_remove().

◆ fcoe_identify_device()

static struct device* fcoe_identify_device ( struct fcoe_port fcoe)
static

Identify device underlying FCoE port.

Parameters
fcoeFCoE port
Return values
deviceUnderlying device

Definition at line 462 of file fcoe.c.

462  {
463  return fcoe->netdev->dev;
464 }
struct net_device * netdev
Network device.
Definition: fcoe.c:79
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360

References net_device::dev, and fcoe_port::netdev.

◆ fcoe_fip_parse()

static int fcoe_fip_parse ( struct fcoe_port fcoe,
struct fip_header fiphdr,
size_t  len,
struct fip_descriptors descs 
)
static

Parse FIP packet into descriptor set.

Parameters
fcoeFCoE port
fiphdrFIP header
lenLength of FIP packet
descsDescriptor set to fill in
Return values
rcReturn status code

Definition at line 496 of file fcoe.c.

497  {
498  union fip_descriptor *desc;
499  size_t descs_len;
500  size_t desc_len;
501  size_t desc_offset;
502  unsigned int desc_type;
503 
504  /* Check FIP version */
505  if ( fiphdr->version != FIP_VERSION ) {
506  DBGC ( fcoe, "FCoE %s received unsupported FIP version %02x\n",
507  fcoe->netdev->name, fiphdr->version );
508  return -EINVAL;
509  }
510 
511  /* Check length */
512  descs_len = ( ntohs ( fiphdr->len ) * 4 );
513  if ( ( sizeof ( *fiphdr ) + descs_len ) > len ) {
514  DBGC ( fcoe, "FCoE %s received bad descriptor list length\n",
515  fcoe->netdev->name );
516  return -EINVAL;
517  }
518 
519  /* Parse descriptor list */
520  memset ( descs, 0, sizeof ( *descs ) );
521  for ( desc_offset = 0 ;
522  desc_offset <= ( descs_len - sizeof ( desc->common ) ) ;
523  desc_offset += desc_len ) {
524 
525  /* Find descriptor and validate length */
526  desc = ( ( ( void * ) ( fiphdr + 1 ) ) + desc_offset );
527  desc_type = desc->common.type;
528  desc_len = ( desc->common.len * 4 );
529  if ( desc_len == 0 ) {
530  DBGC ( fcoe, "FCoE %s received zero-length "
531  "descriptor\n", fcoe->netdev->name );
532  return -EINVAL;
533  }
534  if ( ( desc_offset + desc_len ) > descs_len ) {
535  DBGC ( fcoe, "FCoE %s descriptor overrun\n",
536  fcoe->netdev->name );
537  return -EINVAL;
538  }
539 
540  /* Handle descriptors that we understand */
541  if ( ( desc_type > FIP_RESERVED ) &&
542  ( desc_type < FIP_NUM_DESCRIPTOR_TYPES ) ) {
543  /* Use only the first instance of a descriptor */
544  if ( descs->desc[desc_type] == NULL )
545  descs->desc[desc_type] = desc;
546  continue;
547  }
548 
549  /* Abort if we cannot understand a critical descriptor */
550  if ( FIP_IS_CRITICAL ( desc_type ) ) {
551  DBGC ( fcoe, "FCoE %s cannot understand critical "
552  "descriptor type %02x\n",
553  fcoe->netdev->name, desc_type );
554  return -ENOTSUP;
555  }
556 
557  /* Ignore non-critical descriptors that we cannot understand */
558  }
559 
560  return 0;
561 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
Reserved.
Definition: fip.h:102
uint8_t type
Type.
Definition: fip.h:93
struct net_device * netdev
Network device.
Definition: fcoe.c:79
uint8_t len
Length in 32-bit words.
Definition: fip.h:95
#define FIP_VERSION
FIP frame version.
Definition: fip.h:47
#define DBGC(...)
Definition: compiler.h:505
#define ntohs(value)
Definition: byteswap.h:136
struct fip_common common
Common fields.
Definition: fip.h:350
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
uint8_t version
Frame version.
Definition: fip.h:31
uint16_t len
Descriptor list length in 32-bit words.
Definition: fip.h:41
union fip_descriptor * desc[FIP_NUM_DESCRIPTOR_TYPES]
Descriptors, indexed by type.
Definition: fip.h:408
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
uint32_t len
Length.
Definition: ena.h:14
A FIP descriptor.
Definition: fip.h:348
#define FIP_IS_CRITICAL(type)
FIP descriptor type is critical.
Definition: fip.h:121
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void * memset(void *dest, int character, size_t len) __nonnull

References fip_descriptor::common, DBGC, fip_descriptors::desc, EINVAL, ENOTSUP, FIP_IS_CRITICAL, FIP_NUM_DESCRIPTOR_TYPES, FIP_RESERVED, FIP_VERSION, len, fip_header::len, fip_common::len, memset(), net_device::name, fcoe_port::netdev, ntohs, NULL, fip_common::type, and fip_header::version.

Referenced by fcoe_fip_rx().

◆ fcoe_fip_tx_vlan()

static int fcoe_fip_tx_vlan ( struct fcoe_port fcoe)
static

Send FIP VLAN request.

Parameters
fcoeFCoE port
Return values
rcReturn status code

Definition at line 569 of file fcoe.c.

569  {
570  struct io_buffer *iobuf;
571  struct {
572  struct fip_header hdr;
573  struct fip_mac_address mac_address;
574  } __attribute__ (( packed )) *request;
575  int rc;
576 
577  /* Allocate I/O buffer */
578  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *request ) );
579  if ( ! iobuf )
580  return -ENOMEM;
581  iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
582 
583  /* Construct VLAN request */
584  request = iob_put ( iobuf, sizeof ( *request ) );
585  memset ( request, 0, sizeof ( *request ) );
586  request->hdr.version = FIP_VERSION;
587  request->hdr.code = htons ( FIP_CODE_VLAN );
588  request->hdr.subcode = FIP_VLAN_REQUEST;
589  request->hdr.len = htons ( ( sizeof ( *request ) -
590  sizeof ( request->hdr ) ) / 4 );
591  request->mac_address.type = FIP_MAC_ADDRESS;
592  request->mac_address.len =
593  ( sizeof ( request->mac_address ) / 4 );
594  memcpy ( request->mac_address.mac, fcoe->netdev->ll_addr,
595  sizeof ( request->mac_address.mac ) );
596 
597  /* Send VLAN request */
598  if ( ( rc = net_tx ( iob_disown ( iobuf ), fcoe->netdev,
599  &fip_protocol, all_fcf_macs,
600  fcoe->netdev->ll_addr ) ) != 0 ) {
601  DBGC ( fcoe, "FCoE %s could not send VLAN request: "
602  "%s\n", fcoe->netdev->name, strerror ( rc ) );
603  return rc;
604  }
605 
606  return 0;
607 }
#define __attribute__(x)
Definition: compiler.h:10
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define FIP_VERSION
FIP frame version.
Definition: fip.h:47
#define DBGC(...)
Definition: compiler.h:505
MAC address.
Definition: fip.h:104
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
A FIP frame header.
Definition: fip.h:29
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:208
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static uint8_t all_fcf_macs[ETH_ALEN]
FCoE All-FCF-MACs address.
Definition: fcoe.c:130
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:45
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
VLAN.
Definition: fip.h:54
A FIP MAC address descriptor.
Definition: fip.h:145
uint32_t hdr
Message header.
Definition: intelvf.h:12
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
VLAN request.
Definition: fip.h:77
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
Definition: netdevice.c:999
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
#define htons(value)
Definition: byteswap.h:135
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:32

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().

◆ fcoe_fip_rx_vlan()

static int fcoe_fip_rx_vlan ( struct fcoe_port fcoe,
struct fip_descriptors descs,
unsigned int flags  __unused 
)
static

Handle received FIP VLAN notification.

Parameters
fcoeFCoE port
descsDescriptor list
flagsFlags
Return values
rcReturn status code

Definition at line 617 of file fcoe.c.

619  {
620  struct fip_mac_address *mac_address = fip_mac_address ( descs );
621  struct fip_vlan *vlan = fip_vlan ( descs );
622  unsigned int tag;
623  int rc;
624 
625  /* Sanity checks */
626  if ( ! mac_address ) {
627  DBGC ( fcoe, "FCoE %s received VLAN notification missing MAC "
628  "address\n", fcoe->netdev->name );
629  return -EINVAL;
630  }
631  if ( ! vlan ) {
632  DBGC ( fcoe, "FCoE %s received VLAN notification missing VLAN "
633  "tag\n", fcoe->netdev->name );
634  return -EINVAL;
635  }
636 
637  /* Create VLAN */
638  tag = ntohs ( vlan->vlan );
639  DBGC ( fcoe, "FCoE %s creating VLAN %d for FCF %s\n",
640  fcoe->netdev->name, tag, eth_ntoa ( mac_address->mac ) );
641  if ( ( rc = vlan_create ( fcoe->netdev, tag,
642  FCOE_VLAN_PRIORITY ) ) != 0 ) {
643  DBGC ( fcoe, "FCoE %s could not create VLAN %d: %s\n",
644  fcoe->netdev->name, tag, strerror ( rc ) );
645  return rc;
646  }
647 
648  /* Record that a VLAN was found. This FCoE port will play no
649  * further active role; the real FCoE traffic will use the
650  * port automatically created for the new VLAN device.
651  */
652  fcoe->flags |= FCOE_VLAN_FOUND;
653 
654  return 0;
655 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
An alternative VLAN has been found.
Definition: fcoe.c:113
unsigned int flags
Flags.
Definition: fcoe.c:91
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define FCOE_VLAN_PRIORITY
FCoE VLAN priority.
Definition: fcoe.h:90
#define DBGC(...)
Definition: compiler.h:505
#define ntohs(value)
Definition: byteswap.h:136
int vlan_create(struct net_device *trunk, unsigned int tag, unsigned int priority)
Create VLAN device.
Definition: vlan.c:338
A FIP VLAN descriptor.
Definition: fip.h:338
uint16_t vlan
VLAN ID.
Definition: fip.h:344
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A FIP MAC address descriptor.
Definition: fip.h:145
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
uint8_t mac[ETH_ALEN]
MAC address.
Definition: fip.h:151
uint64_t tag
Identity tag.
Definition: edd.h:30

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().

◆ fcoe_fip_tx_solicitation()

static int fcoe_fip_tx_solicitation ( struct fcoe_port fcoe)
static

Send FIP discovery solicitation.

Parameters
fcoeFCoE port
Return values
rcReturn status code

Definition at line 663 of file fcoe.c.

663  {
664  struct io_buffer *iobuf;
665  struct {
666  struct fip_header hdr;
667  struct fip_mac_address mac_address;
668  struct fip_name_id name_id;
669  struct fip_max_fcoe_size max_fcoe_size;
670  } __attribute__ (( packed )) *solicitation;
671  int rc;
672 
673  /* Allocate I/O buffer */
674  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *solicitation ) );
675  if ( ! iobuf )
676  return -ENOMEM;
677  iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
678 
679  /* Construct discovery solicitation */
680  solicitation = iob_put ( iobuf, sizeof ( *solicitation ) );
681  memset ( solicitation, 0, sizeof ( *solicitation ) );
682  solicitation->hdr.version = FIP_VERSION;
683  solicitation->hdr.code = htons ( FIP_CODE_DISCOVERY );
684  solicitation->hdr.subcode = FIP_DISCOVERY_SOLICIT;
685  solicitation->hdr.len = htons ( ( sizeof ( *solicitation ) -
686  sizeof ( solicitation->hdr ) ) / 4 );
687  solicitation->hdr.flags = htons ( FIP_FP | FIP_SP );
688  solicitation->mac_address.type = FIP_MAC_ADDRESS;
689  solicitation->mac_address.len =
690  ( sizeof ( solicitation->mac_address ) / 4 );
691  memcpy ( solicitation->mac_address.mac, fcoe->netdev->ll_addr,
692  sizeof ( solicitation->mac_address.mac ) );
693  solicitation->name_id.type = FIP_NAME_ID;
694  solicitation->name_id.len = ( sizeof ( solicitation->name_id ) / 4 );
695  memcpy ( &solicitation->name_id.name, &fcoe->node_wwn.fc,
696  sizeof ( solicitation->name_id.name ) );
697  solicitation->max_fcoe_size.type = FIP_MAX_FCOE_SIZE;
698  solicitation->max_fcoe_size.len =
699  ( sizeof ( solicitation->max_fcoe_size ) / 4 );
700  solicitation->max_fcoe_size.mtu =
701  htons ( ETH_MAX_MTU - sizeof ( struct fcoe_header ) -
702  sizeof ( struct fcoe_footer ) );
703 
704  /* Send discovery solicitation */
705  if ( ( rc = net_tx ( iob_disown ( iobuf ), fcoe->netdev,
706  &fip_protocol, all_fcf_macs,
707  fcoe->netdev->ll_addr ) ) != 0 ) {
708  DBGC ( fcoe, "FCoE %s could not send discovery solicitation: "
709  "%s\n", fcoe->netdev->name, strerror ( rc ) );
710  return rc;
711  }
712 
713  return 0;
714 }
#define __attribute__(x)
Definition: compiler.h:10
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define FIP_VERSION
FIP frame version.
Definition: fip.h:47
#define DBGC(...)
Definition: compiler.h:505
MAC address.
Definition: fip.h:104
Max FCoE size.
Definition: fip.h:108
#define ETH_MAX_MTU
Definition: if_ether.h:14
An FCoE header.
Definition: fcoe.h:50
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
A FIP frame header.
Definition: fip.h:29
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:208
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Discovery solicitation.
Definition: fip.h:59
static uint8_t all_fcf_macs[ETH_ALEN]
FCoE All-FCF-MACs address.
Definition: fcoe.c:130
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:45
union fcoe_name node_wwn
Node WWN.
Definition: fcoe.c:82
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
Name identifier.
Definition: fip.h:106
A FIP MAC address descriptor.
Definition: fip.h:145
A FIP max FCoE size descriptor.
Definition: fip.h:195
struct fc_name fc
Fibre Channel name.
Definition: fcoe.h:20
uint32_t hdr
Message header.
Definition: intelvf.h:12
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
Definition: netdevice.c:999
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
Fabric-provided MAC address.
Definition: fip.h:83
A FIP name identifier descriptor.
Definition: fip.h:167
Discovery.
Definition: fip.h:51
#define htons(value)
Definition: byteswap.h:135
Server-provided MAC address.
Definition: fip.h:84
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:32

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().

◆ fcoe_fip_rx_advertisement()

static int fcoe_fip_rx_advertisement ( struct fcoe_port fcoe,
struct fip_descriptors descs,
unsigned int  flags 
)
static

Handle received FIP discovery advertisement.

Parameters
fcoeFCoE port
descsDescriptor list
flagsFlags
Return values
rcReturn status code

Definition at line 724 of file fcoe.c.

726  {
727  struct fip_priority *priority = fip_priority ( descs );
728  struct fip_mac_address *mac_address = fip_mac_address ( descs );
729  struct fip_fka_adv_p *fka_adv_p = fip_fka_adv_p ( descs );
730 
731  /* Sanity checks */
732  if ( ! priority ) {
733  DBGC ( fcoe, "FCoE %s received advertisement missing "
734  "priority\n", fcoe->netdev->name );
735  return -EINVAL;
736  }
737  if ( ! mac_address ) {
738  DBGC ( fcoe, "FCoE %s received advertisement missing MAC "
739  "address\n", fcoe->netdev->name );
740  return -EINVAL;
741  }
742  if ( ! fka_adv_p ) {
743  DBGC ( fcoe, "FCoE %s received advertisement missing FKA ADV "
744  "period\n", fcoe->netdev->name );
745  return -EINVAL;
746  }
747 
748  if ( ! ( fcoe->flags & FCOE_HAVE_FCF ) ) {
749 
750  /* We are soliciting for an FCF. Store the highest
751  * (i.e. lowest-valued) priority solicited
752  * advertisement that we receive.
753  */
754  if ( ( ( flags & ( FIP_A | FIP_S | FIP_F ) ) ==
755  ( FIP_A | FIP_S | FIP_F ) ) &&
756  ( priority->priority < fcoe->priority ) ) {
757 
758  fcoe->flags |= FCOE_HAVE_FIP_FCF;
759  fcoe->priority = priority->priority;
760  if ( fka_adv_p->flags & FIP_NO_KEEPALIVE ) {
761  fcoe->keepalive = 0;
762  } else {
763  fcoe->keepalive = ntohl ( fka_adv_p->period );
764  }
765  fcoe->flags &= ~FCOE_FCF_ALLOWS_SPMA;
766  if ( flags & FIP_SP )
767  fcoe->flags |= FCOE_FCF_ALLOWS_SPMA;
768  memcpy ( fcoe->fcf_mac, mac_address->mac,
769  sizeof ( fcoe->fcf_mac ) );
770  DBGC ( fcoe, "FCoE %s selected FCF %s (pri %d",
771  fcoe->netdev->name, eth_ntoa ( fcoe->fcf_mac ),
772  fcoe->priority );
773  if ( fcoe->keepalive ) {
774  DBGC ( fcoe, ", FKA ADV %dms",
775  fcoe->keepalive );
776  }
777  DBGC ( fcoe, ", %cPMA)\n",
778  ( ( fcoe->flags & FCOE_FCF_ALLOWS_SPMA ) ?
779  'S' : 'F' ) );
780  }
781 
782  } else if ( fcoe->flags & FCOE_HAVE_FIP_FCF ) {
783 
784  /* We are checking that the FCF remains alive. Reset
785  * the timeout counter if this is an advertisement
786  * from our forwarder.
787  */
788  if ( memcmp ( fcoe->fcf_mac, mac_address->mac,
789  sizeof ( fcoe->fcf_mac ) ) == 0 ) {
790  fcoe->timeouts = 0;
791  }
792 
793  } else {
794 
795  /* We are operating in non-FIP mode and have received
796  * a FIP advertisement. Reset the link in order to
797  * attempt FIP.
798  */
799  fcoe_reset ( fcoe );
800 
801  }
802 
803  return 0;
804 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
unsigned int priority
FCoE forwarder priority.
Definition: fcoe.c:93
unsigned int flags
Flags.
Definition: fcoe.c:91
A FIP priority descriptor.
Definition: fip.h:124
struct net_device * netdev
Network device.
Definition: fcoe.c:79
uint8_t flags
Flags.
Definition: fip.h:315
unsigned int timeouts
FIP timeout counter.
Definition: fcoe.c:89
#define DBGC(...)
Definition: compiler.h:505
#define ntohl(value)
Definition: byteswap.h:134
Forwarder.
Definition: fip.h:87
Available for login.
Definition: fip.h:85
void * memcpy(void *dest, const void *src, size_t len) __nonnull
We have a FIP-capable FCoE forwarder available to be used.
Definition: fcoe.c:109
static void fcoe_reset(struct fcoe_port *fcoe)
Reset FCoE port.
Definition: fcoe.c:186
FCoE forwarder supports server-provided MAC addresses.
Definition: fcoe.c:111
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A FIP MAC address descriptor.
Definition: fip.h:145
A FIP FKA ADV period descriptor.
Definition: fip.h:307
Solicited.
Definition: fip.h:86
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
unsigned int keepalive
Keepalive delay (in ms)
Definition: fcoe.c:95
uint16_t priority
Priotity.
Definition: stp.h:12
We have selected an FCoE forwarder to use.
Definition: fcoe.c:107
uint8_t mac[ETH_ALEN]
MAC address.
Definition: fip.h:151
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
Do not send keepalives.
Definition: fip.h:322
uint8_t fcf_mac[ETH_ALEN]
FCoE forwarder MAC address.
Definition: fcoe.c:97
uint32_t period
Keep alive advertisement period in milliseconds.
Definition: fip.h:317
Server-provided MAC address.
Definition: fip.h:84
uint8_t flags
Flags.
Definition: ena.h:18

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.

◆ fcoe_fip_rx_els_response()

static int fcoe_fip_rx_els_response ( struct fcoe_port fcoe,
struct fip_descriptors descs,
unsigned int flags  __unused 
)
static

Handle received FIP ELS response.

Parameters
fcoeFCoE port
descsDescriptor list
flagsFlags
Return values
rcReturn status code

Definition at line 814 of file fcoe.c.

816  {
817  struct fip_els *flogi = fip_flogi ( descs );
818  struct fip_mac_address *mac_address = fip_mac_address ( descs );
819  void *frame;
820  size_t frame_len;
821  int rc;
822 
823  /* Sanity checks */
824  if ( ! flogi ) {
825  DBGC ( fcoe, "FCoE %s received ELS response missing FLOGI\n",
826  fcoe->netdev->name );
827  return -EINVAL;
828  }
829  if ( ! mac_address ) {
830  DBGC ( fcoe, "FCoE %s received ELS response missing MAC "
831  "address\n", fcoe->netdev->name );
832  return -EINVAL;
833  }
834 
835  /* Record local MAC address */
836  memcpy ( fcoe->local_mac, mac_address->mac, sizeof ( fcoe->local_mac ));
837  DBGC ( fcoe, "FCoE %s using local MAC %s\n",
838  fcoe->netdev->name, eth_ntoa ( fcoe->local_mac ) );
839 
840  /* Hand off via transport interface */
841  frame = &flogi->fc;
842  frame_len = ( ( flogi->len * 4 ) - offsetof ( typeof ( *flogi ), fc ) );
843  if ( ( rc = xfer_deliver_raw ( &fcoe->transport, frame,
844  frame_len ) ) != 0 ) {
845  DBGC ( fcoe, "FCoE %s could not deliver FIP FLOGI frame: %s\n",
846  fcoe->netdev->name, strerror ( rc ) );
847  return rc;
848  }
849 
850  return 0;
851 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct net_device * netdev
Network device.
Definition: fcoe.c:79
u16 fc
802.11 Frame Control field
Definition: ieee80211.h:14
#define DBGC(...)
Definition: compiler.h:505
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
uint8_t local_mac[ETH_ALEN]
Local MAC address.
Definition: fcoe.c:99
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:287
unsigned long frame
Definition: xengrant.h:178
void * memcpy(void *dest, const void *src, size_t len) __nonnull
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A FIP MAC address descriptor.
Definition: fip.h:145
A FIP descriptor containing an encapsulated ELS frame.
Definition: fip.h:205
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
uint8_t mac[ETH_ALEN]
MAC address.
Definition: fip.h:151
struct fc_frame_header fc
Fibre Channel frame header.
Definition: fip.h:213
uint8_t len
Length in 32-bit words.
Definition: fip.h:209
struct interface transport
Transport interface.
Definition: fcoe.c:77

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, and xfer_deliver_raw().

◆ fcoe_fip_tx_keepalive()

static int fcoe_fip_tx_keepalive ( struct fcoe_port fcoe)
static

Send FIP keepalive.

Parameters
fcoeFCoE port
Return values
rcReturn status code

Definition at line 859 of file fcoe.c.

859  {
860  struct io_buffer *iobuf;
861  struct {
862  struct fip_header hdr;
863  struct fip_mac_address mac_address;
864  } __attribute__ (( packed )) *keepalive;
865  int rc;
866 
867  /* Allocate I/O buffer */
868  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + sizeof ( *keepalive ) );
869  if ( ! iobuf )
870  return -ENOMEM;
871  iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
872 
873  /* Construct keepalive */
874  keepalive = iob_put ( iobuf, sizeof ( *keepalive ) );
875  memset ( keepalive, 0, sizeof ( *keepalive ) );
876  keepalive->hdr.version = FIP_VERSION;
877  keepalive->hdr.code = htons ( FIP_CODE_MAINTAIN );
878  keepalive->hdr.subcode = FIP_MAINTAIN_KEEP_ALIVE;
879  keepalive->hdr.len = htons ( ( sizeof ( *keepalive ) -
880  sizeof ( keepalive->hdr ) ) / 4 );
881  keepalive->mac_address.type = FIP_MAC_ADDRESS;
882  keepalive->mac_address.len =
883  ( sizeof ( keepalive->mac_address ) / 4 );
884  memcpy ( keepalive->mac_address.mac, fcoe->netdev->ll_addr,
885  sizeof ( keepalive->mac_address.mac ) );
886 
887  /* Send keepalive */
888  if ( ( rc = net_tx ( iob_disown ( iobuf ), fcoe->netdev,
889  &fip_protocol, fcoe->fcf_mac,
890  fcoe->netdev->ll_addr ) ) != 0 ) {
891  DBGC ( fcoe, "FCoE %s could not send keepalive: %s\n",
892  fcoe->netdev->name, strerror ( rc ) );
893  return rc;
894  }
895 
896  return 0;
897 }
#define __attribute__(x)
Definition: compiler.h:10
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define FIP_VERSION
FIP frame version.
Definition: fip.h:47
#define DBGC(...)
Definition: compiler.h:505
MAC address.
Definition: fip.h:104
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
Keep alive.
Definition: fip.h:71
A FIP frame header.
Definition: fip.h:29
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:208
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:45
Maintain virtual links.
Definition: fip.h:53
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A FIP MAC address descriptor.
Definition: fip.h:145
uint32_t hdr
Message header.
Definition: intelvf.h:12
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
Definition: netdevice.c:999
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
#define htons(value)
Definition: byteswap.h:135
uint8_t fcf_mac[ETH_ALEN]
FCoE forwarder MAC address.
Definition: fcoe.c:97
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:32

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().

◆ fcoe_fip_rx()

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 
)
static

Process incoming FIP packets.

Parameters
iobufI/O buffer
netdevNetwork device
ll_destLink-layer destination address
ll_sourceLink-layer source address
flagsPacket flags
Return values
rcReturn status code

Definition at line 937 of file fcoe.c.

941  {
942  struct fip_header *fiphdr = iobuf->data;
943  struct fip_descriptors descs;
944  struct fip_handler *handler;
945  struct fcoe_port *fcoe;
946  unsigned int i;
947  int rc;
948 
949  /* Identify FCoE port */
950  if ( ( fcoe = fcoe_demux ( netdev ) ) == NULL ) {
951  DBG ( "FCoE received FIP frame for net device %s missing FCoE "
952  "port\n", netdev->name );
953  rc = -ENOTCONN;
954  goto done;
955  }
956 
957  /* Discard packets not destined for us */
958  if ( ( memcmp ( fcoe->netdev->ll_addr, ll_dest, ETH_ALEN ) != 0 ) &&
959  ( memcmp ( all_fcoe_macs, ll_dest,
960  sizeof ( all_fcoe_macs ) ) != 0 ) &&
961  ( memcmp ( all_enode_macs, ll_dest,
962  sizeof ( all_enode_macs ) ) != 0 ) ) {
963  DBGC2 ( fcoe, "FCoE %s ignoring FIP packet for %s\n",
964  fcoe->netdev->name, eth_ntoa ( ll_dest ) );
965  rc = -ENOTCONN;
966  goto done;
967  }
968 
969  /* Parse FIP packet */
970  if ( ( rc = fcoe_fip_parse ( fcoe, fiphdr, iob_len ( iobuf ),
971  &descs ) ) != 0 )
972  goto done;
973 
974  /* Find a suitable handler */
975  for ( i = 0 ; i < ( sizeof ( fip_handlers ) /
976  sizeof ( fip_handlers[0] ) ) ; i++ ) {
977  handler = &fip_handlers[i];
978  if ( ( handler->code == ntohs ( fiphdr->code ) ) &&
979  ( handler->subcode == fiphdr->subcode ) ) {
980  rc = handler->rx ( fcoe, &descs,
981  ntohs ( fiphdr->flags ) );
982  goto done;
983  }
984  }
985  DBGC ( fcoe, "FCoE %s received unsupported FIP code %04x.%02x\n",
986  fcoe->netdev->name, ntohs ( fiphdr->code ), fiphdr->subcode );
987  rc = -ENOTSUP;
988 
989  done:
990  free_iob ( iobuf );
991  return rc;
992 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct net_device * netdev
Network device.
Definition: fcoe.c:79
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
static struct fip_handler fip_handlers[]
FIP handlers.
Definition: fcoe.c:918
A FIP handler.
Definition: fcoe.c:900
#define DBGC(...)
Definition: compiler.h:505
#define ntohs(value)
Definition: byteswap.h:136
static struct fcoe_port * fcoe_demux(struct net_device *netdev)
Identify FCoE port by network device.
Definition: fcoe.c:171
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.
Definition: fcoe.c:496
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static uint8_t all_enode_macs[ETH_ALEN]
FCoE All-ENode-MACs address.
Definition: fcoe.c:126
uint16_t code
Protocol code.
Definition: fip.h:35
A FIP frame header.
Definition: fip.h:29
static struct net_device * netdev
Definition: gdbudp.c:52
uint16_t flags
Flags.
Definition: fip.h:43
#define ENOTCONN
The socket is not connected.
Definition: errno.h:569
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A FIP descriptor set.
Definition: fip.h:406
An FCoE port.
Definition: fcoe.c:71
#define ETH_ALEN
Definition: if_ether.h:8
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
#define DBGC2(...)
Definition: compiler.h:522
uint8_t subcode
Protocol subcode.
Definition: fcoe.c:904
uint16_t code
Protocol code.
Definition: fcoe.c:902
void * data
Start of data.
Definition: iobuf.h:44
int(* rx)(struct fcoe_port *fcoe, struct fip_descriptors *descs, unsigned int flags)
Receive FIP packet.
Definition: fcoe.c:913
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint8_t subcode
Subcode.
Definition: fip.h:39
static uint8_t all_fcoe_macs[ETH_ALEN]
FCoE All-FCoE-MACs address.
Definition: fcoe.c:122
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct bofm_section_header done
Definition: bofm_test.c:46

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_demux(), fcoe_fip_parse(), fip_handlers, fip_header::flags, free_iob(), iob_len(), net_device::ll_addr, memcmp(), net_device::name, netdev, fcoe_port::netdev, ntohs, NULL, rc, fip_handler::rx, fip_header::subcode, and fip_handler::subcode.

◆ fcoe_expired()

static void fcoe_expired ( struct retry_timer timer,
int over  __unused 
)
static

Handle FCoE timer expiry.

Parameters
timerFIP timer
overTimer expired

Definition at line 1007 of file fcoe.c.

1007  {
1008  struct fcoe_port *fcoe =
1009  container_of ( timer, struct fcoe_port, timer );
1010  int rc;
1011 
1012  /* Sanity check */
1013  assert ( fcoe->flags & FCOE_HAVE_NETWORK );
1014 
1015  /* Increment the timeout counter */
1016  fcoe->timeouts++;
1017 
1018  if ( vlan_can_be_trunk ( fcoe->netdev ) &&
1019  ! ( fcoe->flags & FCOE_VLAN_TIMED_OUT ) ) {
1020 
1021  /* If we have already found a VLAN, send infrequent
1022  * VLAN requests, in case VLAN information changes.
1023  */
1024  if ( fcoe->flags & FCOE_VLAN_FOUND ) {
1025  fcoe->flags &= ~FCOE_VLAN_FOUND;
1026  fcoe->timeouts = 0;
1027  start_timer_fixed ( &fcoe->timer,
1029  fcoe_fip_tx_vlan ( fcoe );
1030  return;
1031  }
1032 
1033  /* If we have not yet found a VLAN, and we have not
1034  * yet timed out and given up on finding one, then
1035  * send a VLAN request and wait.
1036  */
1037  if ( fcoe->timeouts <= FCOE_MAX_VLAN_REQUESTS ) {
1038  start_timer_fixed ( &fcoe->timer,
1040  fcoe_fip_tx_vlan ( fcoe );
1041  return;
1042  }
1043 
1044  /* We have timed out waiting for a VLAN; proceed to
1045  * FIP discovery.
1046  */
1047  fcoe->flags |= FCOE_VLAN_TIMED_OUT;
1048  fcoe->timeouts = 0;
1049  DBGC ( fcoe, "FCoE %s giving up on VLAN discovery\n",
1050  fcoe->netdev->name );
1051  start_timer_nodelay ( &fcoe->timer );
1052 
1053  } else if ( ! ( fcoe->flags & FCOE_HAVE_FCF ) ) {
1054 
1055  /* If we have not yet found a FIP-capable forwarder,
1056  * and we have not yet timed out and given up on
1057  * finding one, then send a FIP solicitation and wait.
1058  */
1060  if ( ( ! ( fcoe->flags & FCOE_HAVE_FIP_FCF ) ) &&
1061  ( fcoe->timeouts <= FCOE_MAX_FIP_SOLICITATIONS ) ) {
1062  fcoe_fip_tx_solicitation ( fcoe );
1063  return;
1064  }
1065 
1066  /* Attach Fibre Channel port */
1067  if ( ( rc = fc_port_open ( &fcoe->transport, &fcoe->node_wwn.fc,
1068  &fcoe->port_wwn.fc,
1069  fcoe->netdev->name ) ) != 0 ) {
1070  DBGC ( fcoe, "FCoE %s could not create FC port: %s\n",
1071  fcoe->netdev->name, strerror ( rc ) );
1072  /* We will try again on the next timer expiry */
1073  return;
1074  }
1075  stop_timer ( &fcoe->timer );
1076 
1077  /* Either we have found a FIP-capable forwarder, or we
1078  * have timed out and will fall back to pre-FIP mode.
1079  */
1080  fcoe->flags |= FCOE_HAVE_FCF;
1081  fcoe->timeouts = 0;
1082  DBGC ( fcoe, "FCoE %s using %sFIP FCF %s\n", fcoe->netdev->name,
1083  ( ( fcoe->flags & FCOE_HAVE_FIP_FCF ) ? "" : "non-" ),
1084  eth_ntoa ( fcoe->fcf_mac ) );
1085 
1086  /* Start sending keepalives if applicable */
1087  if ( fcoe->keepalive )
1088  start_timer_nodelay ( &fcoe->timer );
1089 
1090  /* Send notification of window change */
1091  xfer_window_changed ( &fcoe->transport );
1092 
1093  } else {
1094 
1095  /* Send keepalive */
1096  start_timer_fixed ( &fcoe->timer,
1097  ( fcoe->keepalive * TICKS_PER_MS ) );
1098  fcoe_fip_tx_keepalive ( fcoe );
1099 
1100  /* Abandon FCF if we have not seen its advertisements */
1101  if ( fcoe->timeouts > FCOE_MAX_FIP_MISSING_KEEPALIVES ) {
1102  DBGC ( fcoe, "FCoE %s abandoning FCF %s\n",
1103  fcoe->netdev->name, eth_ntoa ( fcoe->fcf_mac ));
1104  fcoe_reset ( fcoe );
1105  }
1106  }
1107 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:145
#define FCOE_VLAN_POLL_DELAY
Delay between retrying polling VLAN requests.
Definition: fcoe.c:144
An alternative VLAN has been found.
Definition: fcoe.c:113
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
static int fcoe_fip_tx_keepalive(struct fcoe_port *fcoe)
Send FIP keepalive.
Definition: fcoe.c:859
unsigned int flags
Flags.
Definition: fcoe.c:91
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define FCOE_VLAN_RETRY_DELAY
Delay between retrying VLAN requests.
Definition: fcoe.c:141
unsigned int timeouts
FIP timeout counter.
Definition: fcoe.c:89
#define DBGC(...)
Definition: compiler.h:505
Underlying network device is available.
Definition: fcoe.c:105
#define FCOE_FIP_RETRY_DELAY
Delay between retrying FIP solicitations.
Definition: fcoe.c:150
static int fcoe_fip_tx_vlan(struct fcoe_port *fcoe)
Send FIP VLAN request.
Definition: fcoe.c:569
#define FCOE_MAX_VLAN_REQUESTS
Maximum number of VLAN requests before giving up on VLAN discovery.
Definition: fcoe.c:138
A timer.
Definition: timer.h:28
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
union fcoe_name node_wwn
Node WWN.
Definition: fcoe.c:82
We have a FIP-capable FCoE forwarder available to be used.
Definition: fcoe.c:109
#define FCOE_MAX_FIP_MISSING_KEEPALIVES
Maximum number of missing discovery advertisements.
Definition: fcoe.c:153
static void fcoe_reset(struct fcoe_port *fcoe)
Reset FCoE port.
Definition: fcoe.c:186
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int fcoe_fip_tx_solicitation(struct fcoe_port *fcoe)
Send FIP discovery solicitation.
Definition: fcoe.c:663
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
int fc_port_open(struct interface *transport, const struct fc_name *node_wwn, const struct fc_name *port_wwn, const char *name)
Create Fibre Channel port.
Definition: fc.c:1189
#define FCOE_MAX_FIP_SOLICITATIONS
Maximum number of FIP solicitations before giving up on FIP.
Definition: fcoe.c:147
An FCoE port.
Definition: fcoe.c:71
struct retry_timer timer
FIP retransmission timer.
Definition: fcoe.c:87
struct fc_name fc
Fibre Channel name.
Definition: fcoe.h:20
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
VLAN discovery has timed out.
Definition: fcoe.c:115
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
int vlan_can_be_trunk(struct net_device *trunk)
Check if network device can be used as a VLAN trunk device.
Definition: vlan.c:324
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
unsigned int keepalive
Keepalive delay (in ms)
Definition: fcoe.c:95
We have selected an FCoE forwarder to use.
Definition: fcoe.c:107
union fcoe_name port_wwn
Port WWN.
Definition: fcoe.c:84
uint8_t fcf_mac[ETH_ALEN]
FCoE forwarder MAC address.
Definition: fcoe.c:97
#define TICKS_PER_MS
Number of ticks per millisecond.
Definition: timer.h:25
struct interface transport
Transport interface.
Definition: fcoe.c:77

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().

◆ fcoe_probe()

static int fcoe_probe ( struct net_device netdev)
static

Create FCoE port.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 1115 of file fcoe.c.

1115  {
1117  struct fcoe_port *fcoe;
1118  int rc;
1119 
1120  /* Sanity check */
1121  if ( ll_protocol->ll_proto != htons ( ARPHRD_ETHER ) ) {
1122  /* Not an error; simply skip this net device */
1123  DBG ( "FCoE skipping non-Ethernet device %s\n", netdev->name );
1124  rc = 0;
1125  goto err_non_ethernet;
1126  }
1127 
1128  /* Allocate and initialise structure */
1129  fcoe = zalloc ( sizeof ( *fcoe ) );
1130  if ( ! fcoe ) {
1131  rc = -ENOMEM;
1132  goto err_zalloc;
1133  }
1134  ref_init ( &fcoe->refcnt, NULL );
1135  intf_init ( &fcoe->transport, &fcoe_transport_desc, &fcoe->refcnt );
1136  timer_init ( &fcoe->timer, fcoe_expired, &fcoe->refcnt );
1137  fcoe->netdev = netdev_get ( netdev );
1138 
1139  /* Construct node and port names */
1141  memcpy ( &fcoe->node_wwn.fcoe.mac, netdev->ll_addr,
1142  sizeof ( fcoe->node_wwn.fcoe.mac ) );
1144  memcpy ( &fcoe->port_wwn.fcoe.mac, netdev->ll_addr,
1145  sizeof ( fcoe->port_wwn.fcoe.mac ) );
1146 
1147  DBGC ( fcoe, "FCoE %s is %s", fcoe->netdev->name,
1148  fc_ntoa ( &fcoe->node_wwn.fc ) );
1149  DBGC ( fcoe, " port %s\n", fc_ntoa ( &fcoe->port_wwn.fc ) );
1150 
1151  /* Transfer reference to port list */
1152  list_add ( &fcoe->list, &fcoe_ports );
1153  return 0;
1154 
1155  netdev_put ( fcoe->netdev );
1156  err_zalloc:
1157  err_non_ethernet:
1158  return rc;
1159 }
struct list_head list
List of FCoE ports.
Definition: fcoe.c:75
#define FCOE_AUTHORITY_IEEE
IEEE 48-bit address.
Definition: fcoe.h:31
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
struct net_device * netdev
Network device.
Definition: fcoe.c:79
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
uint8_t mac[ETH_ALEN]
MAC address.
Definition: fcoe.h:26
static struct interface_descriptor fcoe_transport_desc
FCoE transport interface descriptor.
Definition: fcoe.c:477
#define DBGC(...)
Definition: compiler.h:505
const char * fc_ntoa(const struct fc_name *wwn)
Format Fibre Channel WWN.
Definition: fc.c:127
A link-layer protocol.
Definition: netdevice.h:114
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct fcoe_name::@524 fcoe
FCoE name.
struct refcnt refcnt
Reference count.
Definition: fcoe.c:73
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
static struct net_device * netdev
Definition: gdbudp.c:52
union fcoe_name node_wwn
Node WWN.
Definition: fcoe.c:82
uint16_t authority
Naming authority.
Definition: fcoe.h:24
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
An FCoE port.
Definition: fcoe.c:71
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
Definition: netdevice.h:544
uint16_t ll_proto
Link-layer protocol.
Definition: netdevice.h:194
struct retry_timer timer
FIP retransmission timer.
Definition: fcoe.c:87
struct fc_name fc
Fibre Channel name.
Definition: fcoe.h:20
static void fcoe_expired(struct retry_timer *timer, int over __unused)
Handle FCoE timer expiry.
Definition: fcoe.c:1007
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:173
#define ARPHRD_ETHER
Ethernet 10Mbps.
Definition: if_arp.h:16
#define FCOE_AUTHORITY_IEEE_EXTENDED
IEEE extended.
Definition: fcoe.h:34
union fcoe_name port_wwn
Port WWN.
Definition: fcoe.c:84
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define htons(value)
Definition: byteswap.h:135
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
struct interface transport
Transport interface.
Definition: fcoe.c:77

References ARPHRD_ETHER, fcoe_name::authority, DBG, DBGC, ENOMEM, fcoe_name::fc, fc_ntoa(), fcoe_name::fcoe, FCOE_AUTHORITY_IEEE, FCOE_AUTHORITY_IEEE_EXTENDED, fcoe_expired(), fcoe_transport_desc, htons, intf_init(), fcoe_port::list, list_add, net_device::ll_addr, ll_protocol::ll_proto, net_device::ll_protocol, fcoe_name::mac, memcpy(), net_device::name, netdev, fcoe_port::netdev, netdev_get(), netdev_put(), fcoe_port::node_wwn, NULL, fcoe_port::port_wwn, rc, ref_init, fcoe_port::refcnt, fcoe_port::timer, fcoe_port::transport, and zalloc().

◆ fcoe_notify()

static void fcoe_notify ( struct net_device netdev)
static

Handle FCoE port device or link state change.

Parameters
netdevNetwork device

Definition at line 1166 of file fcoe.c.

1166  {
1167  struct fcoe_port *fcoe;
1168 
1169  /* Sanity check */
1170  if ( ( fcoe = fcoe_demux ( netdev ) ) == NULL ) {
1171  DBG ( "FCoE notification for net device %s missing FCoE "
1172  "port\n", netdev->name );
1173  return;
1174  }
1175 
1176  /* Reset the FCoE link if necessary */
1177  if ( ! ( netdev_is_open ( netdev ) &&
1178  netdev_link_ok ( netdev ) &&
1179  ( fcoe->flags & FCOE_HAVE_NETWORK ) ) ) {
1180  fcoe_reset ( fcoe );
1181  }
1182 }
unsigned int flags
Flags.
Definition: fcoe.c:91
Underlying network device is available.
Definition: fcoe.c:105
static struct fcoe_port * fcoe_demux(struct net_device *netdev)
Identify FCoE port by network device.
Definition: fcoe.c:171
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:652
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:630
static struct net_device * netdev
Definition: gdbudp.c:52
static void fcoe_reset(struct fcoe_port *fcoe)
Reset FCoE port.
Definition: fcoe.c:186
An FCoE port.
Definition: fcoe.c:71
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBG, fcoe_demux(), FCOE_HAVE_NETWORK, fcoe_reset(), fcoe_port::flags, net_device::name, netdev, netdev_is_open(), netdev_link_ok(), and NULL.

◆ fcoe_remove()

static void fcoe_remove ( struct net_device netdev)
static

Destroy FCoE port.

Parameters
netdevNetwork device

Definition at line 1189 of file fcoe.c.

1189  {
1190  struct fcoe_port *fcoe;
1191 
1192  /* Sanity check */
1193  if ( ( fcoe = fcoe_demux ( netdev ) ) == NULL ) {
1194  DBG ( "FCoE removal of net device %s missing FCoE port\n",
1195  netdev->name );
1196  return;
1197  }
1198 
1199  /* Close FCoE device */
1200  fcoe_close ( fcoe, 0 );
1201 }
static void fcoe_close(struct fcoe_port *fcoe, int rc)
Close FCoE port.
Definition: fcoe.c:447
static struct fcoe_port * fcoe_demux(struct net_device *netdev)
Identify FCoE port by network device.
Definition: fcoe.c:171
static struct net_device * netdev
Definition: gdbudp.c:52
An FCoE port.
Definition: fcoe.c:71
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBG, fcoe_close(), fcoe_demux(), net_device::name, netdev, and NULL.

Variable Documentation

◆ __net_protocol

struct net_protocol fip_protocol __net_protocol
Initial value:
= {
.name = "FCoE",
.net_proto = htons ( ETH_P_FCOE ),
.rx = fcoe_rx,
}
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.
Definition: fcoe.c:342
#define htons(value)
Definition: byteswap.h:135
#define ETH_P_FCOE
Definition: if_ether.h:26

FCoE protocol.

AoE protocol.

FIP protocol.

Definition at line 118 of file fcoe.c.

◆ all_fcoe_macs

uint8_t all_fcoe_macs[ETH_ALEN]
static
Initial value:
=
{ 0x01, 0x10, 0x18, 0x01, 0x00, 0x00 }

FCoE All-FCoE-MACs address.

Definition at line 122 of file fcoe.c.

Referenced by fcoe_fip_rx().

◆ all_enode_macs

uint8_t all_enode_macs[ETH_ALEN]
static
Initial value:
=
{ 0x01, 0x10, 0x18, 0x01, 0x00, 0x01 }

FCoE All-ENode-MACs address.

Definition at line 126 of file fcoe.c.

Referenced by fcoe_fip_rx().

◆ all_fcf_macs

uint8_t all_fcf_macs[ETH_ALEN]
static
Initial value:
=
{ 0x01, 0x10, 0x18, 0x01, 0x00, 0x02 }

FCoE All-FCF-MACs address.

Definition at line 130 of file fcoe.c.

Referenced by fcoe_fip_tx_solicitation(), and fcoe_fip_tx_vlan().

◆ default_fcf_mac

uint8_t default_fcf_mac[ETH_ALEN]
static
Initial value:
=
{ 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }

Default FCoE forwarded MAC address.

Definition at line 134 of file fcoe.c.

Referenced by fcoe_reset(), and fcoe_rx().

◆ fcoe_transport_op

struct interface_operation fcoe_transport_op[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:244
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
Definition: xfer.c:157
static void fcoe_close(struct fcoe_port *fcoe, int rc)
Close FCoE port.
Definition: fcoe.c:447
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition: xfer.c:115
static int fcoe_deliver(struct fcoe_port *fcoe, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
Transmit FCoE packet.
Definition: fcoe.c:224
static struct io_buffer * fcoe_alloc_iob(struct fcoe_port *fcoe __unused, size_t len)
Allocate FCoE I/O buffer.
Definition: fcoe.c:319
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:193
An FCoE port.
Definition: fcoe.c:71
static struct device * fcoe_identify_device(struct fcoe_port *fcoe)
Identify device underlying FCoE port.
Definition: fcoe.c:462
static size_t fcoe_window(struct fcoe_port *fcoe)
Check FCoE flow control window.
Definition: fcoe.c:437
struct device * identify_device(struct interface *intf)
Identify a device behind an interface.
Definition: device.c:125

FCoE transport interface operations.

Definition at line 467 of file fcoe.c.

◆ fcoe_transport_desc

struct interface_descriptor fcoe_transport_desc
static
Initial value:
=
static struct interface_operation fcoe_transport_op[]
FCoE transport interface operations.
Definition: fcoe.c:467
An FCoE port.
Definition: fcoe.c:71
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:65
struct interface transport
Transport interface.
Definition: fcoe.c:77

FCoE transport interface descriptor.

Definition at line 477 of file fcoe.c.

Referenced by fcoe_probe().

◆ fip_handlers

struct fip_handler fip_handlers[]
static
Initial value:
= {
}
Discovery advertisement.
Definition: fip.h:60
static int fcoe_fip_rx_advertisement(struct fcoe_port *fcoe, struct fip_descriptors *descs, unsigned int flags)
Handle received FIP discovery advertisement.
Definition: fcoe.c:724
VLAN.
Definition: fip.h:54
ELS response.
Definition: fip.h:66
static int fcoe_fip_rx_vlan(struct fcoe_port *fcoe, struct fip_descriptors *descs, unsigned int flags __unused)
Handle received FIP VLAN notification.
Definition: fcoe.c:617
Extended link services.
Definition: fip.h:52
VLAN notification.
Definition: fip.h:78
static int fcoe_fip_rx_els_response(struct fcoe_port *fcoe, struct fip_descriptors *descs, unsigned int flags __unused)
Handle received FIP ELS response.
Definition: fcoe.c:814
Discovery.
Definition: fip.h:51

FIP handlers.

Definition at line 918 of file fcoe.c.

Referenced by fcoe_fip_rx().

◆ __net_driver

struct net_driver fcoe_driver __net_driver
Initial value:
= {
.name = "FCoE",
.probe = fcoe_probe,
.notify = fcoe_notify,
.remove = fcoe_remove,
}
static void fcoe_remove(struct net_device *netdev)
Destroy FCoE port.
Definition: fcoe.c:1189
static void fcoe_notify(struct net_device *netdev)
Handle FCoE port device or link state change.
Definition: fcoe.c:1166
static int fcoe_probe(struct net_device *netdev)
Create FCoE port.
Definition: fcoe.c:1115

FCoE driver.

Definition at line 1204 of file fcoe.c.

◆ __errortab

struct errortab fcoe_errors [] __errortab
Initial value:
= {
}
#define __einfo_errortab(einfo)
Definition: errortab.h:23
#define EINFO_EINVAL_CRC
Definition: fcoe.c:64

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.

Definition at line 1231 of file fcoe.c.