iPXE
Functions | Variables
eth_slow.c File Reference

Ethernet slow protocols. More...

#include <stdlib.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <ipxe/timer.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/eth_slow.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static const char * eth_slow_lacp_tlv_name (uint8_t type)
 Name LACP TLV type. More...
 
static const char * eth_slow_marker_tlv_name (uint8_t type)
 Name marker TLV type. More...
 
static const char * eth_slow_lacp_state_name (uint8_t state)
 Name LACP state. More...
 
static void eth_slow_lacp_dump (struct io_buffer *iobuf, struct net_device *netdev, const char *label)
 Dump LACP packet. More...
 
static int eth_slow_lacp_rx (struct io_buffer *iobuf, struct net_device *netdev)
 Process incoming LACP packet. More...
 
static void eth_slow_marker_dump (struct io_buffer *iobuf, struct net_device *netdev, const char *label)
 Dump marker packet. More...
 
static int eth_slow_marker_rx (struct io_buffer *iobuf, struct net_device *netdev)
 Process incoming marker packet. More...
 
static int eth_slow_rx (struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest __unused, const void *ll_source __unused, unsigned int flags __unused)
 Process incoming slow packet. More...
 

Variables

struct net_protocol eth_slow_protocol __net_protocol
 Slow protocol. More...
 
static const uint8_t eth_slow_address [ETH_ALEN]
 Slow protocols multicast address. More...
 

Detailed Description

Ethernet slow protocols.

We implement a very simple passive LACP entity, that pretends that each port is the only port on an individual system. We avoid the need for timeout logic (and retaining local state about our partner) by requesting the same timeout period (1s or 30s) as our partner requests, and then simply responding to every packet the partner sends us.

Definition in file eth_slow.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ eth_slow_lacp_tlv_name()

static const char* eth_slow_lacp_tlv_name ( uint8_t  type)
inlinestatic

Name LACP TLV type.

Parameters
typeLACP TLV type
Return values
nameName of LACP TLV type

Definition at line 62 of file eth_slow.c.

62  {
63  switch ( type ) {
64  case ETH_SLOW_TLV_TERMINATOR: return "terminator";
65  case ETH_SLOW_TLV_LACP_ACTOR: return "actor";
66  case ETH_SLOW_TLV_LACP_PARTNER: return "partner";
67  case ETH_SLOW_TLV_LACP_COLLECTOR: return "collector";
68  default: return "<invalid>";
69  }
70 }
uint32_t type
Operating system type.
Definition: ena.h:12
#define ETH_SLOW_TLV_LACP_COLLECTOR
LACP collector type.
Definition: eth_slow.h:68
#define ETH_SLOW_TLV_LACP_PARTNER
LACP partner type.
Definition: eth_slow.h:61
#define ETH_SLOW_TLV_TERMINATOR
Terminator type.
Definition: eth_slow.h:48
#define ETH_SLOW_TLV_LACP_ACTOR
LACP actor type.
Definition: eth_slow.h:54

References ETH_SLOW_TLV_LACP_ACTOR, ETH_SLOW_TLV_LACP_COLLECTOR, ETH_SLOW_TLV_LACP_PARTNER, ETH_SLOW_TLV_TERMINATOR, and type.

◆ eth_slow_marker_tlv_name()

static const char* eth_slow_marker_tlv_name ( uint8_t  type)
inlinestatic

Name marker TLV type.

Parameters
typeMarker TLV type
Return values
nameName of marker TLV type

Definition at line 79 of file eth_slow.c.

79  {
80  switch ( type ) {
81  case ETH_SLOW_TLV_TERMINATOR: return "terminator";
82  case ETH_SLOW_TLV_MARKER_REQUEST: return "request";
83  case ETH_SLOW_TLV_MARKER_RESPONSE: return "response";
84  default: return "<invalid>";
85  }
86 }
uint32_t type
Operating system type.
Definition: ena.h:12
#define ETH_SLOW_TLV_MARKER_REQUEST
Marker request type.
Definition: eth_slow.h:75
#define ETH_SLOW_TLV_MARKER_RESPONSE
Marker response type.
Definition: eth_slow.h:82
#define ETH_SLOW_TLV_TERMINATOR
Terminator type.
Definition: eth_slow.h:48

References ETH_SLOW_TLV_MARKER_REQUEST, ETH_SLOW_TLV_MARKER_RESPONSE, ETH_SLOW_TLV_TERMINATOR, and type.

Referenced by eth_slow_marker_dump().

◆ eth_slow_lacp_state_name()

static const char* eth_slow_lacp_state_name ( uint8_t  state)
static

Name LACP state.

Parameters
stateLACP state
Return values
nameLACP state name

Definition at line 94 of file eth_slow.c.

94  {
95  static char state_chars[] = "AFGSCDLX";
96  unsigned int i;
97 
98  for ( i = 0 ; i < 8 ; i++ ) {
99  state_chars[i] |= 0x20;
100  if ( state & ( 1 << i ) )
101  state_chars[i] &= ~0x20;
102  }
103  return state_chars;
104 }
uint8_t state
State.
Definition: eth_slow.h:47

References state.

Referenced by eth_slow_lacp_dump().

◆ eth_slow_lacp_dump()

static void eth_slow_lacp_dump ( struct io_buffer iobuf,
struct net_device netdev,
const char *  label 
)
static

Dump LACP packet.

Parameters
iobufI/O buffer
netdevNetwork device
label"RX" or "TX"

Definition at line 113 of file eth_slow.c.

115  {
116  union eth_slow_packet *eth_slow = iobuf->data;
117  struct eth_slow_lacp *lacp = &eth_slow->lacp;
118 
119  DBGC ( netdev,
120  "SLOW %s %s LACP actor (%04x,%s,%04x,%02x,%04x) [%s]\n",
121  netdev->name, label, ntohs ( lacp->actor.system_priority ),
122  eth_ntoa ( lacp->actor.system ),
123  ntohs ( lacp->actor.key ),
125  ntohs ( lacp->actor.port ),
127  DBGC ( netdev,
128  "SLOW %s %s LACP partner (%04x,%s,%04x,%02x,%04x) [%s]\n",
131  ntohs ( lacp->partner.key ),
133  ntohs ( lacp->partner.port ),
135  DBGC ( netdev, "SLOW %s %s LACP collector %04x (%d us)\n",
136  netdev->name, label, ntohs ( lacp->collector.max_delay ),
137  ( ntohs ( lacp->collector.max_delay ) * 10 ) );
138  DBGC2_HDA ( netdev, 0, iobuf->data, iob_len ( iobuf ) );
139 }
struct eth_slow_lacp lacp
LACP packet.
Definition: eth_slow.h:256
#define DBGC(...)
Definition: compiler.h:505
struct eth_slow_lacp lacp
LACP packet.
Definition: eth_slow.h:14
Slow protocols packet.
Definition: eth_slow.h:252
#define ntohs(value)
Definition: byteswap.h:136
struct eth_slow_lacp_collector_tlv collector
Collector information.
Definition: eth_slow.h:232
uint8_t state
State.
Definition: eth_slow.h:132
LACP packet.
Definition: eth_slow.h:224
uint16_t max_delay
Maximum delay (in 10us increments)
Definition: eth_slow.h:204
uint8_t system[ETH_ALEN]
System identifier.
Definition: eth_slow.h:109
static struct net_device * netdev
Definition: gdbudp.c:52
#define DBGC2_HDA(...)
Definition: compiler.h:523
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
struct eth_slow_lacp_entity_tlv partner
Partner information.
Definition: eth_slow.h:230
uint16_t system_priority
System priority.
Definition: eth_slow.h:103
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
void * data
Start of data.
Definition: iobuf.h:48
uint16_t port_priority
Port priority.
Definition: eth_slow.h:121
static const char * eth_slow_lacp_state_name(uint8_t state)
Name LACP state.
Definition: eth_slow.c:94
struct eth_slow_lacp_entity_tlv actor
Actor information.
Definition: eth_slow.h:228
uint16_t port
Port identifier.
Definition: eth_slow.h:126

References eth_slow_lacp::actor, eth_slow_lacp::collector, io_buffer::data, DBGC, DBGC2_HDA, eth_ntoa(), eth_slow_lacp_state_name(), iob_len(), eth_slow_lacp_entity_tlv::key, lacp, eth_slow_packet::lacp, eth_slow_lacp_collector_tlv::max_delay, net_device::name, netdev, ntohs, eth_slow_lacp::partner, eth_slow_lacp_entity_tlv::port, eth_slow_lacp_entity_tlv::port_priority, eth_slow_lacp_entity_tlv::state, eth_slow_lacp_entity_tlv::system, and eth_slow_lacp_entity_tlv::system_priority.

Referenced by eth_slow_lacp_rx().

◆ eth_slow_lacp_rx()

static int eth_slow_lacp_rx ( struct io_buffer iobuf,
struct net_device netdev 
)
static

Process incoming LACP packet.

Parameters
iobufI/O buffer
netdevNetwork device
Return values
rcReturn status code

Definition at line 148 of file eth_slow.c.

149  {
150  union eth_slow_packet *eth_slow = iobuf->data;
151  struct eth_slow_lacp *lacp = &eth_slow->lacp;
152  unsigned int interval;
153 
154  eth_slow_lacp_dump ( iobuf, netdev, "RX" );
155 
156  /* Check for looped-back packets */
157  if ( memcmp ( lacp->actor.system, netdev->ll_addr,
158  sizeof ( lacp->actor.system ) ) == 0 ) {
159  DBGC ( netdev, "SLOW %s RX loopback detected\n",
160  netdev->name );
161  return -ELOOP;
162  }
163 
164  /* If partner is not in sync, collecting, and distributing,
165  * then block the link until after the next expected LACP
166  * packet.
167  */
168  if ( ~lacp->actor.state & ( LACP_STATE_IN_SYNC |
171  DBGC ( netdev, "SLOW %s LACP partner is down\n", netdev->name );
172  interval = ( ( lacp->actor.state & LACP_STATE_FAST ) ?
173  ( ( LACP_INTERVAL_FAST + 1 ) * TICKS_PER_SEC ) :
174  ( ( LACP_INTERVAL_SLOW + 1 ) * TICKS_PER_SEC ) );
175  netdev_link_block ( netdev, interval );
176  } else {
177  if ( netdev_link_blocked ( netdev ) ) {
178  DBGC ( netdev, "SLOW %s LACP partner is up\n",
179  netdev->name );
180  }
182  }
183 
184  /* Build response */
185  memset ( lacp->reserved, 0, sizeof ( lacp->reserved ) );
186  memset ( &lacp->terminator, 0, sizeof ( lacp->terminator ) );
187  memset ( &lacp->collector, 0, sizeof ( lacp->collector ) );
190  memcpy ( &lacp->partner, &lacp->actor, sizeof ( lacp->partner ) );
193  memset ( &lacp->partner.reserved, 0,
194  sizeof ( lacp->partner.reserved ) );
195  memset ( &lacp->actor, 0, sizeof ( lacp->actor ) );
200  sizeof ( lacp->actor.system ) );
201  lacp->actor.key = htons ( 1 );
203  lacp->actor.port = htons ( 1 );
210 
211  /* Send response */
212  eth_slow_lacp_dump ( iobuf, netdev, "TX" );
213  return net_tx ( iobuf, netdev, &eth_slow_protocol, eth_slow_address,
214  netdev->ll_addr );
215 }
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
struct eth_slow_lacp lacp
LACP packet.
Definition: eth_slow.h:256
uint8_t reserved[3]
Reserved.
Definition: eth_slow.h:134
#define ETH_SLOW_LACP_VERSION
LACP version number.
Definition: eth_slow.h:24
struct eth_slow_terminator_tlv terminator
Terminator.
Definition: eth_slow.h:234
static const uint8_t eth_slow_address[ETH_ALEN]
Slow protocols multicast address.
Definition: eth_slow.c:52
#define LACP_STATE_AGGREGATABLE
LACP link is aggregateable.
Definition: eth_slow.h:161
#define DBGC(...)
Definition: compiler.h:505
#define LACP_STATE_COLLECTING
LACP link is collecting (receiving)
Definition: eth_slow.h:173
#define LACP_STATE_IN_SYNC
LACP link is in synchronisation.
Definition: eth_slow.h:167
struct eth_slow_lacp lacp
LACP packet.
Definition: eth_slow.h:14
Slow protocols packet.
Definition: eth_slow.h:252
#define LACP_SYSTEM_PRIORITY_MAX
Maximum system priority.
Definition: eth_slow.h:138
struct eth_slow_tlv_header tlv
TLV header.
Definition: eth_slow.h:97
#define ETH_SLOW_TLV_LACP_COLLECTOR
LACP collector type.
Definition: eth_slow.h:68
static int netdev_link_blocked(struct net_device *netdev)
Check link block state of network device.
Definition: netdevice.h:653
struct eth_slow_lacp_collector_tlv collector
Collector information.
Definition: eth_slow.h:232
uint8_t state
State.
Definition: eth_slow.h:132
LACP packet.
Definition: eth_slow.h:224
#define ELOOP
Too many levels of symbolic links.
Definition: errno.h:448
struct eth_slow_tlv_header tlv
TLV header.
Definition: eth_slow.h:202
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void netdev_link_block(struct net_device *netdev, unsigned long timeout)
Mark network device link as being blocked.
Definition: netdevice.c:203
uint8_t system[ETH_ALEN]
System identifier.
Definition: eth_slow.h:109
void netdev_link_unblock(struct net_device *netdev)
Mark network device link as being unblocked.
Definition: netdevice.c:218
static struct net_device * netdev
Definition: gdbudp.c:52
struct eth_slow_header header
Slow protocols header.
Definition: eth_slow.h:226
#define LACP_PORT_PRIORITY_MAX
Maximum port priority.
Definition: eth_slow.h:141
#define LACP_STATE_FAST
LACP timeout is short.
Definition: eth_slow.h:155
uint8_t length
Length.
Definition: eth_slow.h:44
#define ETH_SLOW_TLV_LACP_PARTNER
LACP partner type.
Definition: eth_slow.h:61
#define ETH_SLOW_TLV_LACP_ACTOR_LEN
LACP actor length.
Definition: eth_slow.h:57
#define ETH_SLOW_TLV_LACP_COLLECTOR_LEN
LACP collector length.
Definition: eth_slow.h:71
#define ETH_SLOW_TLV_LACP_PARTNER_LEN
LACP partner length.
Definition: eth_slow.h:64
struct eth_slow_lacp_entity_tlv partner
Partner information.
Definition: eth_slow.h:230
#define LACP_INTERVAL_SLOW
LACP slow interval (30 seconds)
Definition: eth_slow.h:197
uint8_t reserved[50]
Reserved.
Definition: eth_slow.h:236
uint16_t system_priority
System priority.
Definition: eth_slow.h:103
uint8_t type
Type.
Definition: eth_slow.h:38
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
#define ETH_SLOW_TLV_LACP_ACTOR
LACP actor type.
Definition: eth_slow.h:54
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:1054
void * data
Start of data.
Definition: iobuf.h:48
uint16_t port_priority
Port priority.
Definition: eth_slow.h:121
struct eth_slow_lacp_entity_tlv actor
Actor information.
Definition: eth_slow.h:228
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
#define LACP_STATE_DISTRIBUTING
LACP link is distributing (transmitting)
Definition: eth_slow.h:179
#define LACP_INTERVAL_FAST
LACP fast interval (1 second)
Definition: eth_slow.h:194
uint16_t port
Port identifier.
Definition: eth_slow.h:126
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define htons(value)
Definition: byteswap.h:135
static void eth_slow_lacp_dump(struct io_buffer *iobuf, struct net_device *netdev, const char *label)
Dump LACP packet.
Definition: eth_slow.c:113
uint8_t version
Subtype version number.
Definition: eth_slow.h:17
void * memset(void *dest, int character, size_t len) __nonnull

References eth_slow_lacp::actor, eth_slow_lacp::collector, io_buffer::data, DBGC, ELOOP, eth_slow_address, eth_slow_lacp_dump(), ETH_SLOW_LACP_VERSION, ETH_SLOW_TLV_LACP_ACTOR, ETH_SLOW_TLV_LACP_ACTOR_LEN, ETH_SLOW_TLV_LACP_COLLECTOR, ETH_SLOW_TLV_LACP_COLLECTOR_LEN, ETH_SLOW_TLV_LACP_PARTNER, ETH_SLOW_TLV_LACP_PARTNER_LEN, eth_slow_lacp::header, htons, eth_slow_lacp_entity_tlv::key, lacp, eth_slow_packet::lacp, LACP_INTERVAL_FAST, LACP_INTERVAL_SLOW, LACP_PORT_PRIORITY_MAX, LACP_STATE_AGGREGATABLE, LACP_STATE_COLLECTING, LACP_STATE_DISTRIBUTING, LACP_STATE_FAST, LACP_STATE_IN_SYNC, LACP_SYSTEM_PRIORITY_MAX, eth_slow_tlv_header::length, net_device::ll_addr, memcmp(), memcpy(), memset(), net_device::name, net_tx(), netdev, netdev_link_block(), netdev_link_blocked(), netdev_link_unblock(), eth_slow_lacp::partner, eth_slow_lacp_entity_tlv::port, eth_slow_lacp_entity_tlv::port_priority, eth_slow_lacp_entity_tlv::reserved, eth_slow_lacp::reserved, eth_slow_lacp_entity_tlv::state, eth_slow_lacp_entity_tlv::system, eth_slow_lacp_entity_tlv::system_priority, eth_slow_lacp::terminator, TICKS_PER_SEC, eth_slow_lacp_entity_tlv::tlv, eth_slow_lacp_collector_tlv::tlv, eth_slow_tlv_header::type, and eth_slow_header::version.

Referenced by eth_slow_rx().

◆ eth_slow_marker_dump()

static void eth_slow_marker_dump ( struct io_buffer iobuf,
struct net_device netdev,
const char *  label 
)
static

Dump marker packet.

Parameters
iobufI/O buffer
netdevNetwork device
label"RX" or "TX"

Definition at line 224 of file eth_slow.c.

226  {
227  union eth_slow_packet *eth_slow = iobuf->data;
228  struct eth_slow_marker *marker = &eth_slow->marker;
229 
230  DBGC ( netdev, "SLOW %s %s marker %s port %04x system %s xact %08x\n",
231  netdev->name, label,
233  ntohs ( marker->marker.port ),
234  eth_ntoa ( marker->marker.system ),
235  ntohl ( marker->marker.xact ) );
236  DBGC2_HDA ( netdev, 0, iobuf->data, iob_len ( iobuf ) );
237 }
uint8_t system[ETH_ALEN]
Requester system.
Definition: eth_slow.h:216
#define DBGC(...)
Definition: compiler.h:505
Slow protocols packet.
Definition: eth_slow.h:252
#define ntohl(value)
Definition: byteswap.h:134
#define ntohs(value)
Definition: byteswap.h:136
Marker packet.
Definition: eth_slow.h:240
static struct net_device * netdev
Definition: gdbudp.c:52
uint16_t port
Requester port.
Definition: eth_slow.h:214
static const char * eth_slow_marker_tlv_name(uint8_t type)
Name marker TLV type.
Definition: eth_slow.c:79
#define DBGC2_HDA(...)
Definition: compiler.h:523
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
uint32_t xact
Requester transaction ID.
Definition: eth_slow.h:218
uint8_t type
Type.
Definition: eth_slow.h:38
struct eth_slow_marker marker
Marker packet.
Definition: eth_slow.h:258
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
void * data
Start of data.
Definition: iobuf.h:48
struct eth_slow_tlv_header tlv
TLV header.
Definition: eth_slow.h:212
struct eth_slow_marker_tlv marker
Marker information.
Definition: eth_slow.h:14

References io_buffer::data, DBGC, DBGC2_HDA, eth_ntoa(), eth_slow_marker_tlv_name(), iob_len(), eth_slow_packet::marker, marker, net_device::name, netdev, ntohl, ntohs, eth_slow_marker_tlv::port, eth_slow_marker_tlv::system, eth_slow_marker_tlv::tlv, eth_slow_tlv_header::type, and eth_slow_marker_tlv::xact.

Referenced by eth_slow_marker_rx().

◆ eth_slow_marker_rx()

static int eth_slow_marker_rx ( struct io_buffer iobuf,
struct net_device netdev 
)
static

Process incoming marker packet.

Parameters
iobufI/O buffer
netdevNetwork device
Return values
rcReturn status code

Definition at line 246 of file eth_slow.c.

247  {
248  union eth_slow_packet *eth_slow = iobuf->data;
249  struct eth_slow_marker *marker = &eth_slow->marker;
250 
251  eth_slow_marker_dump ( iobuf, netdev, "RX" );
252 
253  if ( marker->marker.tlv.type == ETH_SLOW_TLV_MARKER_REQUEST ) {
254  /* Send marker response */
256  eth_slow_marker_dump ( iobuf, netdev, "TX" );
257  return net_tx ( iobuf, netdev, &eth_slow_protocol,
259  } else {
260  /* Discard all other marker packets */
261  free_iob ( iobuf );
262  return -EINVAL;
263  }
264 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
static const uint8_t eth_slow_address[ETH_ALEN]
Slow protocols multicast address.
Definition: eth_slow.c:52
#define ETH_SLOW_TLV_MARKER_REQUEST
Marker request type.
Definition: eth_slow.h:75
Slow protocols packet.
Definition: eth_slow.h:252
Marker packet.
Definition: eth_slow.h:240
#define ETH_SLOW_TLV_MARKER_RESPONSE
Marker response type.
Definition: eth_slow.h:82
static struct net_device * netdev
Definition: gdbudp.c:52
uint8_t type
Type.
Definition: eth_slow.h:38
struct eth_slow_marker marker
Marker packet.
Definition: eth_slow.h:258
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:1054
void * data
Start of data.
Definition: iobuf.h:48
static void eth_slow_marker_dump(struct io_buffer *iobuf, struct net_device *netdev, const char *label)
Dump marker packet.
Definition: eth_slow.c:224
struct eth_slow_tlv_header tlv
TLV header.
Definition: eth_slow.h:212
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
struct eth_slow_marker_tlv marker
Marker information.
Definition: eth_slow.h:14

References io_buffer::data, EINVAL, eth_slow_address, eth_slow_marker_dump(), ETH_SLOW_TLV_MARKER_REQUEST, ETH_SLOW_TLV_MARKER_RESPONSE, free_iob(), net_device::ll_addr, eth_slow_packet::marker, marker, net_tx(), netdev, eth_slow_marker_tlv::tlv, and eth_slow_tlv_header::type.

Referenced by eth_slow_rx().

◆ eth_slow_rx()

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

Process incoming slow packet.

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 276 of file eth_slow.c.

280  {
281  union eth_slow_packet *eth_slow = iobuf->data;
282 
283  /* Sanity checks */
284  if ( iob_len ( iobuf ) < sizeof ( *eth_slow ) ) {
285  free_iob ( iobuf );
286  return -EINVAL;
287  }
288 
289  /* Strip any trailing padding */
290  iob_unput ( iobuf, ( sizeof ( *eth_slow ) - iob_len ( iobuf ) ) );
291 
292  /* Handle according to subtype */
293  switch ( eth_slow->header.subtype ) {
295  return eth_slow_lacp_rx ( iobuf, netdev );
297  return eth_slow_marker_rx ( iobuf, netdev );
298  default:
299  DBGC ( netdev, "SLOW %s RX unknown subtype %02x\n",
300  netdev->name, eth_slow->header.subtype );
301  free_iob ( iobuf );
302  return -EINVAL;
303  }
304 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
static int eth_slow_lacp_rx(struct io_buffer *iobuf, struct net_device *netdev)
Process incoming LACP packet.
Definition: eth_slow.c:148
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define ETH_SLOW_SUBTYPE_MARKER
Marker subtype.
Definition: eth_slow.h:27
#define DBGC(...)
Definition: compiler.h:505
Slow protocols packet.
Definition: eth_slow.h:252
struct eth_slow_header header
Slow protocols header.
Definition: eth_slow.h:254
static int eth_slow_marker_rx(struct io_buffer *iobuf, struct net_device *netdev)
Process incoming marker packet.
Definition: eth_slow.c:246
static struct net_device * netdev
Definition: gdbudp.c:52
#define iob_unput(iobuf, len)
Definition: iobuf.h:135
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
uint8_t subtype
Slow protocols subtype.
Definition: eth_slow.h:15
#define ETH_SLOW_SUBTYPE_LACP
LACP subtype.
Definition: eth_slow.h:21
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
void * data
Start of data.
Definition: iobuf.h:48

References io_buffer::data, DBGC, EINVAL, eth_slow_lacp_rx(), eth_slow_marker_rx(), ETH_SLOW_SUBTYPE_LACP, ETH_SLOW_SUBTYPE_MARKER, free_iob(), eth_slow_packet::header, iob_len(), iob_unput, net_device::name, netdev, and eth_slow_header::subtype.

Variable Documentation

◆ __net_protocol

struct net_protocol eth_slow_protocol __net_protocol
Initial value:
= {
.name = "Slow",
.net_proto = htons ( ETH_P_SLOW ),
.rx = eth_slow_rx,
}
#define ETH_P_SLOW
Definition: if_ether.h:23
static int eth_slow_rx(struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest __unused, const void *ll_source __unused, unsigned int flags __unused)
Process incoming slow packet.
Definition: eth_slow.c:276
#define htons(value)
Definition: byteswap.h:135

Slow protocol.

AoE protocol.

Definition at line 49 of file eth_slow.c.

◆ eth_slow_address

const uint8_t eth_slow_address[ETH_ALEN]
static
Initial value:
=
{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x02 }

Slow protocols multicast address.

Definition at line 52 of file eth_slow.c.

Referenced by eth_slow_lacp_rx(), and eth_slow_marker_rx().