iPXE
Data Structures | Functions | Variables
netdev_settings.c File Reference

Network device configuration settings. More...

#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/dhcp.h>
#include <ipxe/dhcpopts.h>
#include <ipxe/settings.h>
#include <ipxe/device.h>
#include <ipxe/netdevice.h>
#include <ipxe/init.h>

Go to the source code of this file.

Data Structures

struct  netdev_setting_operation
 A network device setting operation. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
const struct setting mac_setting __setting (SETTING_NETDEV, mac)
 Network device predefined settings. More...
 
const struct setting hwaddr_setting __setting (SETTING_NETDEV, hwaddr)
 
const struct setting bustype_setting __setting (SETTING_NETDEV, bustype)
 
const struct setting busloc_setting __setting (SETTING_NETDEV, busloc)
 
const struct setting busid_setting __setting (SETTING_NETDEV, busid)
 
const struct setting chip_setting __setting (SETTING_NETDEV, chip)
 
const struct setting ifname_setting __setting (SETTING_NETDEV, ifname)
 
const struct setting mtu_setting __setting (SETTING_NETDEV, mtu)
 
static int netdev_store_mac (struct net_device *netdev, const void *data, size_t len)
 Store link-layer address setting. More...
 
static int netdev_fetch_mac (struct net_device *netdev, void *data, size_t len)
 Fetch link-layer address setting. More...
 
static int netdev_fetch_hwaddr (struct net_device *netdev, void *data, size_t len)
 Fetch hardware address setting. More...
 
static int netdev_fetch_bustype (struct net_device *netdev, void *data, size_t len)
 Fetch bus type setting. More...
 
static int netdev_fetch_busloc (struct net_device *netdev, void *data, size_t len)
 Fetch bus location setting. More...
 
static int netdev_fetch_busid (struct net_device *netdev, void *data, size_t len)
 Fetch bus ID setting. More...
 
static int netdev_fetch_chip (struct net_device *netdev, void *data, size_t len)
 Fetch chip setting. More...
 
static int netdev_fetch_ifname (struct net_device *netdev, void *data, size_t len)
 Fetch ifname setting. More...
 
static int netdev_store (struct settings *settings, const struct setting *setting, const void *data, size_t len)
 Store value of network device setting. More...
 
static int netdev_fetch (struct settings *settings, struct setting *setting, void *data, size_t len)
 Fetch value of network device setting. More...
 
static void netdev_clear (struct settings *settings)
 Clear network device settings. More...
 
static struct settingsnetdev_redirect (struct settings *settings)
 Redirect "netX" settings block. More...
 
static void netdev_redirect_settings_init (void)
 Initialise "netX" settings. More...
 
struct init_fn netdev_redirect_settings_init_fn __init_fn (INIT_LATE)
 "netX" settings initialiser More...
 
static int apply_netdev_settings (void)
 Apply network device settings. More...
 

Variables

static struct netdev_setting_operation netdev_setting_operations []
 Network device settings. More...
 
struct settings_operations netdev_settings_operations
 Network device configuration settings operations. More...
 
static struct settings_operations netdev_redirect_settings_operations
 "netX" settings operations More...
 
static struct settings netdev_redirect_settings
 "netX" settings More...
 
struct settings_applicator netdev_applicator __settings_applicator
 Network device settings applicator. More...
 

Detailed Description

Network device configuration settings.

Definition in file netdev_settings.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __setting() [1/8]

const struct setting mac_setting __setting ( SETTING_NETDEV  ,
mac   
)

Network device predefined settings.

◆ __setting() [2/8]

const struct setting hwaddr_setting __setting ( SETTING_NETDEV  ,
hwaddr   
)

◆ __setting() [3/8]

const struct setting bustype_setting __setting ( SETTING_NETDEV  ,
bustype   
)

◆ __setting() [4/8]

const struct setting busloc_setting __setting ( SETTING_NETDEV  ,
busloc   
)

◆ __setting() [5/8]

const struct setting busid_setting __setting ( SETTING_NETDEV  ,
busid   
)

◆ __setting() [6/8]

const struct setting chip_setting __setting ( SETTING_NETDEV  ,
chip   
)

◆ __setting() [7/8]

const struct setting ifname_setting __setting ( SETTING_NETDEV  ,
ifname   
)

◆ __setting() [8/8]

const struct setting mtu_setting __setting ( SETTING_NETDEV  ,
mtu   
)

◆ netdev_store_mac()

static int netdev_store_mac ( struct net_device netdev,
const void *  data,
size_t  len 
)
static

Store link-layer address setting.

Parameters
netdevNetwork device
dataSetting data, or NULL to clear setting
lenLength of setting data
Return values
rcReturn status code

Definition at line 93 of file netdev_settings.c.

94  {
96 
97  /* Record new MAC address */
98  if ( data ) {
99  if ( len != netdev->ll_protocol->ll_addr_len )
100  return -EINVAL;
101  memcpy ( netdev->ll_addr, data, len );
102  } else {
103  /* Reset MAC address if clearing setting */
105  }
106 
107  return 0;
108 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
void(* init_addr)(const void *hw_addr, void *ll_addr)
Initialise link-layer address.
Definition: netdevice.h:150
A link-layer protocol.
Definition: netdevice.h:114
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366

References data, EINVAL, net_device::hw_addr, ll_protocol::init_addr, len, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy(), and netdev.

◆ netdev_fetch_mac()

static int netdev_fetch_mac ( struct net_device netdev,
void *  data,
size_t  len 
)
static

Fetch link-layer address setting.

Parameters
netdevNetwork device
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 118 of file netdev_settings.c.

119  {
121 
122  if ( len > max_len )
123  len = max_len;
124  memcpy ( data, netdev->ll_addr, len );
125  return max_len;
126 }
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
static void size_t size_t max_len
Definition: entropy.h:153
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366

References data, len, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, max_len, memcpy(), and netdev.

◆ netdev_fetch_hwaddr()

static int netdev_fetch_hwaddr ( struct net_device netdev,
void *  data,
size_t  len 
)
static

Fetch hardware address setting.

Parameters
netdevNetwork device
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 136 of file netdev_settings.c.

137  {
139 
140  if ( len > max_len )
141  len = max_len;
142  memcpy ( data, netdev->hw_addr, len );
143  return max_len;
144 }
static void size_t size_t max_len
Definition: entropy.h:153
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t hw_addr_len
Hardware address length.
Definition: netdevice.h:196
static struct net_device * netdev
Definition: gdbudp.c:52
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366

References data, net_device::hw_addr, ll_protocol::hw_addr_len, len, net_device::ll_protocol, max_len, memcpy(), and netdev.

◆ netdev_fetch_bustype()

static int netdev_fetch_bustype ( struct net_device netdev,
void *  data,
size_t  len 
)
static

Fetch bus type setting.

Parameters
netdevNetwork device
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 154 of file netdev_settings.c.

155  {
156  static const char *bustypes[] = {
157  [BUS_TYPE_PCI] = "PCI",
158  [BUS_TYPE_ISAPNP] = "ISAPNP",
159  [BUS_TYPE_EISA] = "EISA",
160  [BUS_TYPE_MCA] = "MCA",
161  [BUS_TYPE_ISA] = "ISA",
162  [BUS_TYPE_TAP] = "TAP",
163  [BUS_TYPE_EFI] = "EFI",
164  [BUS_TYPE_XEN] = "XEN",
165  [BUS_TYPE_HV] = "HV",
166  [BUS_TYPE_USB] = "USB",
167  };
168  struct device_description *desc = &netdev->dev->desc;
169  const char *bustype;
170 
171  assert ( desc->bus_type < ( sizeof ( bustypes ) /
172  sizeof ( bustypes[0] ) ) );
173  bustype = bustypes[desc->bus_type];
174  if ( ! bustype )
175  return -ENOENT;
176  strncpy ( data, bustype, len );
177  return strlen ( bustype );
178 }
#define ENOENT
No such file or directory.
Definition: errno.h:514
A hardware device description.
Definition: device.h:19
#define BUS_TYPE_MCA
MCA bus type.
Definition: device.h:52
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
Definition: string.c:317
#define BUS_TYPE_ISA
ISA bus type.
Definition: device.h:55
#define BUS_TYPE_PCI
PCI bus type.
Definition: device.h:43
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static struct net_device * netdev
Definition: gdbudp.c:52
#define BUS_TYPE_EISA
EISA bus type.
Definition: device.h:49
size_t strlen(const char *src)
Get length of string.
Definition: string.c:213
#define BUS_TYPE_EFI
EFI bus type.
Definition: device.h:61
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
#define BUS_TYPE_TAP
TAP bus type.
Definition: device.h:58
unsigned int bus_type
Bus type.
Definition: device.h:24
uint32_t len
Length.
Definition: ena.h:14
struct device_description desc
Device description.
Definition: device.h:79
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define BUS_TYPE_XEN
Xen bus type.
Definition: device.h:64
#define BUS_TYPE_USB
USB bus type.
Definition: device.h:70
#define BUS_TYPE_HV
Hyper-V bus type.
Definition: device.h:67
#define BUS_TYPE_ISAPNP
ISAPnP bus type.
Definition: device.h:46

References assert(), device_description::bus_type, BUS_TYPE_EFI, BUS_TYPE_EISA, BUS_TYPE_HV, BUS_TYPE_ISA, BUS_TYPE_ISAPNP, BUS_TYPE_MCA, BUS_TYPE_PCI, BUS_TYPE_TAP, BUS_TYPE_USB, BUS_TYPE_XEN, data, device::desc, net_device::dev, ENOENT, len, netdev, strlen(), and strncpy().

◆ netdev_fetch_busloc()

static int netdev_fetch_busloc ( struct net_device netdev,
void *  data,
size_t  len 
)
static

Fetch bus location setting.

Parameters
netdevNetwork device
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 188 of file netdev_settings.c.

189  {
190  struct device_description *desc = &netdev->dev->desc;
191  uint32_t busloc;
192 
193  busloc = cpu_to_be32 ( desc->location );
194  if ( len > sizeof ( busloc ) )
195  len = sizeof ( busloc );
196  memcpy ( data, &busloc, len );
197  return sizeof ( busloc );
198 }
A hardware device description.
Definition: device.h:19
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
unsigned int location
Location.
Definition: device.h:29
unsigned int uint32_t
Definition: stdint.h:12
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
#define cpu_to_be32(value)
Definition: byteswap.h:110
uint32_t len
Length.
Definition: ena.h:14
struct device_description desc
Device description.
Definition: device.h:79
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References cpu_to_be32, data, device::desc, net_device::dev, len, device_description::location, memcpy(), and netdev.

◆ netdev_fetch_busid()

static int netdev_fetch_busid ( struct net_device netdev,
void *  data,
size_t  len 
)
static

Fetch bus ID setting.

Parameters
netdevNetwork device
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 208 of file netdev_settings.c.

209  {
210  struct device_description *desc = &netdev->dev->desc;
211  struct dhcp_netdev_desc dhcp_desc;
212 
213  dhcp_desc.type = desc->bus_type;
214  dhcp_desc.vendor = htons ( desc->vendor );
215  dhcp_desc.device = htons ( desc->device );
216  if ( len > sizeof ( dhcp_desc ) )
217  len = sizeof ( dhcp_desc );
218  memcpy ( data, &dhcp_desc, len );
219  return sizeof ( dhcp_desc );
220 }
uint8_t type
Bus type ID.
Definition: dhcp.h:426
unsigned int vendor
Vendor ID.
Definition: device.h:31
A hardware device description.
Definition: device.h:19
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
Network device descriptor.
Definition: dhcp.h:424
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
unsigned int bus_type
Bus type.
Definition: device.h:24
uint32_t len
Length.
Definition: ena.h:14
unsigned int device
Device ID.
Definition: device.h:33
struct device_description desc
Device description.
Definition: device.h:79
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define htons(value)
Definition: byteswap.h:135

References device_description::bus_type, data, device::desc, net_device::dev, device_description::device, dhcp_netdev_desc::device, htons, len, memcpy(), netdev, dhcp_netdev_desc::type, device_description::vendor, and dhcp_netdev_desc::vendor.

◆ netdev_fetch_chip()

static int netdev_fetch_chip ( struct net_device netdev,
void *  data,
size_t  len 
)
static

Fetch chip setting.

Parameters
netdevNetwork device
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 230 of file netdev_settings.c.

231  {
232  const char *chip = netdev->dev->driver_name;
233 
234  strncpy ( data, chip, len );
235  return strlen ( chip );
236 }
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
Definition: string.c:317
static struct net_device * netdev
Definition: gdbudp.c:52
const char * driver_name
Driver name.
Definition: device.h:77
size_t strlen(const char *src)
Get length of string.
Definition: string.c:213
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, net_device::dev, device::driver_name, len, netdev, strlen(), and strncpy().

◆ netdev_fetch_ifname()

static int netdev_fetch_ifname ( struct net_device netdev,
void *  data,
size_t  len 
)
static

Fetch ifname setting.

Parameters
netdevNetwork device
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 246 of file netdev_settings.c.

247  {
248  const char *ifname = netdev->name;
249 
250  strncpy ( data, ifname, len );
251  return strlen ( ifname );
252 }
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
Definition: string.c:317
static struct net_device * netdev
Definition: gdbudp.c:52
size_t strlen(const char *src)
Get length of string.
Definition: string.c:213
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, len, net_device::name, netdev, strlen(), and strncpy().

◆ netdev_store()

static int netdev_store ( struct settings settings,
const struct setting setting,
const void *  data,
size_t  len 
)
static

Store value of network device setting.

Parameters
settingsSettings block
settingSetting to store
dataSetting data, or NULL to clear setting
lenLength of setting data
Return values
rcReturn status code

Definition at line 297 of file netdev_settings.c.

299  {
300  struct net_device *netdev = container_of ( settings, struct net_device,
301  settings.settings );
303  unsigned int i;
304 
305  /* Handle network device-specific settings */
306  for ( i = 0 ; i < ( sizeof ( netdev_setting_operations ) /
307  sizeof ( netdev_setting_operations[0] ) ) ; i++ ) {
309  if ( setting_cmp ( setting, op->setting ) == 0 ) {
310  if ( op->store ) {
311  return op->store ( netdev, data, len );
312  } else {
313  return -ENOTSUP;
314  }
315  }
316  }
317 
319 }
static struct netdev_setting_operation netdev_setting_operations[]
Network device settings.
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static struct net_device * netdev
Definition: gdbudp.c:52
A network device setting operation.
A network device.
Definition: netdevice.h:348
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
int generic_settings_store(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of generic setting.
Definition: settings.c:126
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124

References container_of, data, ENOTSUP, generic_settings_store(), len, netdev, netdev_setting_operations, op, and setting_cmp().

◆ netdev_fetch()

static int netdev_fetch ( struct settings settings,
struct setting setting,
void *  data,
size_t  len 
)
static

Fetch value of network device setting.

Parameters
settingsSettings block
settingSetting to fetch
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 330 of file netdev_settings.c.

331  {
332  struct net_device *netdev = container_of ( settings, struct net_device,
333  settings.settings );
335  unsigned int i;
336 
337  /* Handle network device-specific settings */
338  for ( i = 0 ; i < ( sizeof ( netdev_setting_operations ) /
339  sizeof ( netdev_setting_operations[0] ) ) ; i++ ) {
341  if ( setting_cmp ( setting, op->setting ) == 0 )
342  return op->fetch ( netdev, data, len );
343  }
344 
346 }
static struct netdev_setting_operation netdev_setting_operations[]
Network device settings.
int generic_settings_fetch(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of generic setting.
Definition: settings.c:178
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static struct net_device * netdev
Definition: gdbudp.c:52
A network device setting operation.
A network device.
Definition: netdevice.h:348
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124

References container_of, data, generic_settings_fetch(), len, netdev, netdev_setting_operations, op, and setting_cmp().

◆ netdev_clear()

static void netdev_clear ( struct settings settings)
static

Clear network device settings.

Parameters
settingsSettings block

Definition at line 353 of file netdev_settings.c.

353  {
355 }
void generic_settings_clear(struct settings *settings)
Clear generic settings block.
Definition: settings.c:207
A settings block.
Definition: settings.h:132

References generic_settings_clear().

◆ netdev_redirect()

static struct settings* netdev_redirect ( struct settings settings)
static

Redirect "netX" settings block.

Parameters
settingsSettings block
Return values
settingsUnderlying settings block

Definition at line 370 of file netdev_settings.c.

370  {
371  struct net_device *netdev;
372 
373  /* Redirect to most recently opened network device */
375  if ( netdev ) {
376  return netdev_settings ( netdev );
377  } else {
378  return settings;
379  }
380 }
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition: netdevice.h:577
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * last_opened_netdev(void)
Get most recently opened network device.
Definition: netdevice.c:973
A network device.
Definition: netdevice.h:348
struct generic_settings settings
Configuration settings applicable to this device.
Definition: netdevice.h:422

References last_opened_netdev(), netdev, netdev_settings(), and net_device::settings.

◆ netdev_redirect_settings_init()

static void netdev_redirect_settings_init ( void  )
static

Initialise "netX" settings.

Definition at line 396 of file netdev_settings.c.

396  {
397  int rc;
398 
400  "netX" ) ) != 0 ) {
401  DBG ( "Could not register netX settings: %s\n",
402  strerror ( rc ) );
403  return;
404  }
405 }
static struct settings netdev_redirect_settings
"netX" settings
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
Definition: settings.c:478
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBG, netdev_redirect_settings, NULL, rc, register_settings(), and strerror().

◆ __init_fn()

struct init_fn netdev_redirect_settings_init_fn __init_fn ( INIT_LATE  )

"netX" settings initialiser

◆ apply_netdev_settings()

static int apply_netdev_settings ( void  )
static

Apply network device settings.

Return values
rcReturn status code

Definition at line 417 of file netdev_settings.c.

417  {
418  struct net_device *netdev;
419  struct settings *settings;
420  struct ll_protocol *ll_protocol;
421  size_t max_mtu;
422  size_t old_mtu;
423  size_t mtu;
424  int rc;
425 
426  /* Process settings for each network device */
427  for_each_netdev ( netdev ) {
428 
429  /* Get network device settings */
431 
432  /* Get MTU */
433  mtu = fetch_uintz_setting ( settings, &mtu_setting );
434 
435  /* Do nothing unless MTU is specified */
436  if ( ! mtu )
437  continue;
438 
439  /* Limit MTU to maximum supported by hardware */
441  max_mtu = ( netdev->max_pkt_len - ll_protocol->ll_header_len );
442  if ( mtu > max_mtu ) {
443  DBGC ( netdev, "NETDEV %s cannot support MTU %zd (max "
444  "%zd)\n", netdev->name, mtu, max_mtu );
445  mtu = max_mtu;
446  }
447 
448  /* Update maximum packet length */
449  old_mtu = netdev->mtu;
450  netdev->mtu = mtu;
451  if ( mtu != old_mtu ) {
452  DBGC ( netdev, "NETDEV %s MTU is %zd\n",
453  netdev->name, mtu );
454  }
455 
456  /* Close and reopen network device if MTU has increased */
457  if ( netdev_is_open ( netdev ) && ( mtu > old_mtu ) ) {
458  netdev_close ( netdev );
459  if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
460  DBGC ( netdev, "NETDEV %s could not reopen: "
461  "%s\n", netdev->name, strerror ( rc ) );
462  return rc;
463  }
464  }
465  }
466 
467  return 0;
468 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:200
size_t mtu
Maximum transmission unit length.
Definition: netdevice.h:409
#define DBGC(...)
Definition: compiler.h:505
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition: netdevice.h:577
A link-layer protocol.
Definition: netdevice.h:114
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:652
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define for_each_netdev(netdev)
Iterate over all network devices.
Definition: netdevice.h:526
A network device.
Definition: netdevice.h:348
A settings block.
Definition: settings.h:132
unsigned long fetch_uintz_setting(struct settings *settings, const struct setting *setting)
Fetch value of unsigned integer setting, or zero.
Definition: settings.c:1072
void netdev_close(struct net_device *netdev)
Close network device.
Definition: netdevice.c:801
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:403
int netdev_open(struct net_device *netdev)
Open network device.
Definition: netdevice.c:767
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366

References DBGC, fetch_uintz_setting(), for_each_netdev, ll_protocol::ll_header_len, net_device::ll_protocol, net_device::max_pkt_len, mtu, net_device::mtu, net_device::name, netdev, netdev_close(), netdev_is_open(), netdev_open(), netdev_settings(), rc, and strerror().

Variable Documentation

◆ netdev_setting_operations

struct netdev_setting_operation netdev_setting_operations[]
static
Initial value:
= {
{ &mac_setting, netdev_store_mac, netdev_fetch_mac },
{ &hwaddr_setting, NULL, netdev_fetch_hwaddr },
{ &bustype_setting, NULL, netdev_fetch_bustype },
{ &busloc_setting, NULL, netdev_fetch_busloc },
{ &busid_setting, NULL, netdev_fetch_busid },
{ &chip_setting, NULL, netdev_fetch_chip },
{ &ifname_setting, NULL, netdev_fetch_ifname },
}
static int netdev_fetch_mac(struct net_device *netdev, void *data, size_t len)
Fetch link-layer address setting.
static int netdev_fetch_chip(struct net_device *netdev, void *data, size_t len)
Fetch chip setting.
static int netdev_fetch_busid(struct net_device *netdev, void *data, size_t len)
Fetch bus ID setting.
static int netdev_fetch_hwaddr(struct net_device *netdev, void *data, size_t len)
Fetch hardware address setting.
static int netdev_fetch_bustype(struct net_device *netdev, void *data, size_t len)
Fetch bus type setting.
static int netdev_fetch_ifname(struct net_device *netdev, void *data, size_t len)
Fetch ifname setting.
static int netdev_store_mac(struct net_device *netdev, const void *data, size_t len)
Store link-layer address setting.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static int netdev_fetch_busloc(struct net_device *netdev, void *data, size_t len)
Fetch bus location setting.

Network device settings.

Definition at line 278 of file netdev_settings.c.

Referenced by netdev_fetch(), and netdev_store().

◆ netdev_settings_operations

struct settings_operations netdev_settings_operations
Initial value:
= {
.store = netdev_store,
.fetch = netdev_fetch,
.clear = netdev_clear,
}
static void netdev_clear(struct settings *settings)
Clear network device settings.
static int netdev_store(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of network device setting.
static int netdev_fetch(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of network device setting.

Network device configuration settings operations.

Definition at line 358 of file netdev_settings.c.

Referenced by netdev_settings_init().

◆ netdev_redirect_settings_operations

struct settings_operations netdev_redirect_settings_operations
static
Initial value:
= {
.redirect = netdev_redirect,
}
static struct settings * netdev_redirect(struct settings *settings)
Redirect "netX" settings block.

"netX" settings operations

Definition at line 383 of file netdev_settings.c.

◆ netdev_redirect_settings

struct settings netdev_redirect_settings
static
Initial value:
= {
.refcnt = NULL,
}
static struct settings netdev_redirect_settings
"netX" settings
static struct settings_operations netdev_redirect_settings_operations
"netX" settings operations
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
struct list_head children
Child settings blocks.
Definition: settings.h:142
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition: list.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

"netX" settings

Definition at line 388 of file netdev_settings.c.

Referenced by netdev_redirect_settings_init().

◆ __settings_applicator

struct settings_applicator netdev_applicator __settings_applicator
Initial value:
= {
}
static int apply_netdev_settings(void)
Apply network device settings.

Network device settings applicator.

Definition at line 471 of file netdev_settings.c.