Coverage Report

Created: 2026-03-11 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/u-boot/include/net-common.h
Line
Count
Source
1
/* SPDX-License-Identifier: GPL-2.0+ */
2
3
#ifndef __NET_COMMON_H__
4
#define __NET_COMMON_H__
5
6
#include <asm/cache.h>
7
#include <command.h>
8
#include <hexdump.h>
9
#include <linux/if_ether.h>
10
#include <linux/sizes.h>
11
#include <linux/types.h>
12
#include <rand.h>
13
#include <time.h>
14
15
0
#define DEBUG_NET_PKT_TRACE 0  /* Trace all packet data */
16
#define DEBUG_INT_STATE 0 /* Internal network state changes */
17
18
/*
19
 *  The number of receive packet buffers, and the required packet buffer
20
 *  alignment in memory.
21
 *
22
 */
23
0
#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER
24
0
#define PKTALIGN  ARCH_DMA_MINALIGN
25
26
/* IPv4 addresses are always 32 bits in size */
27
struct in_addr {
28
  __be32 s_addr;
29
};
30
31
0
#define PROT_IP   0x0800    /* IP protocol      */
32
0
#define PROT_ARP  0x0806    /* IP ARP protocol    */
33
#define PROT_WOL  0x0842    /* ether-wake WoL protocol  */
34
0
#define PROT_RARP 0x8035    /* IP ARP protocol    */
35
0
#define PROT_VLAN 0x8100    /* IEEE 802.1q protocol   */
36
#define PROT_IPV6 0x86dd    /* IPv6 over bluebook   */
37
#define PROT_PPP_SES  0x8864    /* PPPoE session messages */
38
#define PROT_NCSI 0x88f8    /* NC-SI control packets        */
39
40
0
#define IPPROTO_ICMP   1  /* Internet Control Message Protocol  */
41
0
#define IPPROTO_TCP 6  /* Transmission Control Protocol  */
42
0
#define IPPROTO_UDP 17  /* User Datagram Protocol   */
43
44
#define IP_OFFS   0x1fff /* ip offset *= 8 */
45
#define IP_FLAGS  0xe000 /* first 3 bits */
46
#define IP_FLAGS_RES  0x8000 /* reserved */
47
#define IP_FLAGS_DFRAG  0x4000 /* don't fragments */
48
#define IP_FLAGS_MFRAG  0x2000 /* more fragments */
49
50
#define IP_HDR_SIZE   (sizeof(struct ip_hdr))
51
52
#define IP_MIN_FRAG_DATAGRAM_SIZE (IP_HDR_SIZE + 8)
53
54
/*
55
 *  Internet Protocol (IP) + UDP header.
56
 */
57
struct ip_udp_hdr {
58
  u8    ip_hl_v;  /* header length and version  */
59
  u8    ip_tos;   /* type of service    */
60
  u16   ip_len;   /* total length     */
61
  u16   ip_id;    /* identification   */
62
  u16   ip_off;   /* fragment offset field  */
63
  u8    ip_ttl;   /* time to live     */
64
  u8    ip_p;   /* protocol     */
65
  u16   ip_sum;   /* checksum     */
66
  struct in_addr  ip_src;   /* Source IP address    */
67
  struct in_addr  ip_dst;   /* Destination IP address */
68
  u16   udp_src;  /* UDP source port    */
69
  u16   udp_dst;  /* UDP destination port   */
70
  u16   udp_len;  /* Length of UDP packet   */
71
  u16   udp_xsum; /* Checksum     */
72
} __packed;
73
74
0
#define IP_UDP_HDR_SIZE   (sizeof(struct ip_udp_hdr))
75
0
#define UDP_HDR_SIZE    (IP_UDP_HDR_SIZE - IP_HDR_SIZE)
76
77
/* Number of packets processed together */
78
0
#define ETH_PACKETS_BATCH_RECV  32
79
80
/* ARP hardware address length */
81
#define ARP_HLEN 6
82
/*
83
 * The size of a MAC address in string form, each digit requires two chars
84
 * and five separator characters to form '00:00:00:00:00:00'.
85
 */
86
#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1)
87
88
0
#define ARP_HDR_SIZE  (8 + 20)  /* Size assuming ethernet */
89
90
#   define ARP_ETHER      1   /* Ethernet  hardware address */
91
92
/*
93
 * Maximum packet size; used to allocate packet storage. Use
94
 * the maximum Ethernet frame size as specified by the Ethernet
95
 * standard including the 802.1Q tag (VLAN tagging).
96
 * maximum packet size =  1522
97
 * maximum packet size and multiple of 32 bytes =  1536
98
 */
99
#define PKTSIZE     1522
100
#ifndef CONFIG_DM_DSA
101
#define PKTSIZE_ALIGN   1536
102
#else
103
/* Maximum DSA tagging overhead (headroom and/or tailroom) */
104
#define DSA_MAX_OVR   256
105
#define PKTSIZE_ALIGN   (1536 + DSA_MAX_OVR)
106
#endif
107
108
/*
109
 * Maximum receive ring size; that is, the number of packets
110
 * we can buffer before overflow happens. Basically, this just
111
 * needs to be enough to prevent a packet being discarded while
112
 * we are processing the previous one.
113
 * Used only in drivers/net/mvgbe.c.
114
 */
115
#define RINGSZ    4
116
#define RINGSZ_LOG2 2
117
118
/* Network loop state */
119
enum net_loop_state {
120
  NETLOOP_CONTINUE,
121
  NETLOOP_RESTART,
122
  NETLOOP_SUCCESS,
123
  NETLOOP_FAIL
124
};
125
126
extern enum net_loop_state net_state;
127
128
static inline void net_set_state(enum net_loop_state state)
129
0
{
130
0
  debug_cond(DEBUG_INT_STATE, "--- NetState set to %d\n", state);
131
0
  net_state = state;
132
0
}
Unexecuted instantiation: bootm.c:net_set_state
Unexecuted instantiation: pxe_utils.c:net_set_state
Unexecuted instantiation: bootmeth_pxe.c:net_set_state
Unexecuted instantiation: bootmeth_efi.c:net_set_state
Unexecuted instantiation: bootmeth_script.c:net_set_state
Unexecuted instantiation: fdt_support.c:net_set_state
Unexecuted instantiation: boot.c:net_set_state
Unexecuted instantiation: bdinfo.c:net_set_state
Unexecuted instantiation: efidebug.c:net_set_state
Unexecuted instantiation: elf.c:net_set_state
Unexecuted instantiation: load.c:net_set_state
Unexecuted instantiation: mii.c:net_set_state
Unexecuted instantiation: mdio.c:net_set_state
Unexecuted instantiation: net.c:net_set_state
Unexecuted instantiation: net-common.c:net_set_state
Unexecuted instantiation: pcap.c:net_set_state
Unexecuted instantiation: pxe.c:net_set_state
Unexecuted instantiation: fastboot.c:net_set_state
Unexecuted instantiation: ethsw.c:net_set_state
Unexecuted instantiation: main.c:net_set_state
Unexecuted instantiation: board_r.c:net_set_state
Unexecuted instantiation: miiphyutil.c:net_set_state
Unexecuted instantiation: dfu.c:net_set_state
Unexecuted instantiation: dsa_sandbox.c:net_set_state
Unexecuted instantiation: sandbox.c:net_set_state
Unexecuted instantiation: sandbox-raw.c:net_set_state
Unexecuted instantiation: mdio_mux_sandbox.c:net_set_state
Unexecuted instantiation: mdio_sandbox.c:net_set_state
Unexecuted instantiation: netconsole.c:net_set_state
Unexecuted instantiation: phy.c:net_set_state
Unexecuted instantiation: virtio_net.c:net_set_state
Unexecuted instantiation: fb_common.c:net_set_state
Unexecuted instantiation: ether.c:net_set_state
Unexecuted instantiation: common.c:net_set_state
Unexecuted instantiation: efi_bootmgr.c:net_set_state
Unexecuted instantiation: efi_bootbin.c:net_set_state
Unexecuted instantiation: efi_boottime.c:net_set_state
Unexecuted instantiation: efi_device_path.c:net_set_state
Unexecuted instantiation: efi_device_path_to_text.c:net_set_state
Unexecuted instantiation: efi_setup.c:net_set_state
Unexecuted instantiation: efi_net.c:net_set_state
Unexecuted instantiation: efi_ipconfig.c:net_set_state
Unexecuted instantiation: efi_http.c:net_set_state
Unexecuted instantiation: efi_selftest_console.c:net_set_state
Unexecuted instantiation: efi_selftest_snp.c:net_set_state
Unexecuted instantiation: efi_selftest_http.c:net_set_state
Unexecuted instantiation: efi_selftest_ipconfig.c:net_set_state
Unexecuted instantiation: net_utils.c:net_set_state
Unexecuted instantiation: fdtdec.c:net_set_state
Unexecuted instantiation: arp.c:net_set_state
Unexecuted instantiation: bootp.c:net_set_state
Unexecuted instantiation: cdp.c:net_set_state
Unexecuted instantiation: dns.c:net_set_state
Unexecuted instantiation: link_local.c:net_set_state
Unexecuted instantiation: ndisc.c:net_set_state
Unexecuted instantiation: net6.c:net_set_state
Unexecuted instantiation: ping.c:net_set_state
Unexecuted instantiation: ping6.c:net_set_state
Unexecuted instantiation: dhcpv6.c:net_set_state
Unexecuted instantiation: rarp.c:net_set_state
Unexecuted instantiation: sntp.c:net_set_state
Unexecuted instantiation: tftp.c:net_set_state
Unexecuted instantiation: fastboot_udp.c:net_set_state
Unexecuted instantiation: udp.c:net_set_state
Unexecuted instantiation: tcp.c:net_set_state
Unexecuted instantiation: wget.c:net_set_state
Unexecuted instantiation: dsa-uclass.c:net_set_state
Unexecuted instantiation: eth-uclass.c:net_set_state
Unexecuted instantiation: eth_bootdev.c:net_set_state
Unexecuted instantiation: mdio-uclass.c:net_set_state
Unexecuted instantiation: mdio-mux-uclass.c:net_set_state
Unexecuted instantiation: eth_common.c:net_set_state
Unexecuted instantiation: test-main.c:net_set_state
Unexecuted instantiation: dsa.c:net_set_state
Unexecuted instantiation: eth.c:net_set_state
Unexecuted instantiation: mdio_mux.c:net_set_state
133
134
extern int    net_restart_wrap; /* Tried all network devices */
135
extern uchar    *net_rx_packets[PKTBUFSRX]; /* Receive packets */
136
extern const u8   net_bcast_ethaddr[ARP_HLEN];  /* Ethernet broadcast address */
137
extern struct in_addr net_ip;   /* Our    IP addr (0 = unknown) */
138
/* Indicates whether the pxe path prefix / config file was specified in dhcp option */
139
extern char *pxelinux_configfile;
140
141
/* Our IP addr (0 = unknown) */
142
extern struct in_addr net_ip;
143
/* Boot File name */
144
extern char net_boot_file_name[1024];
145
/* The actual transferred size of the bootfile (in bytes) */
146
extern u32  net_boot_file_size;
147
/* Boot file size in blocks as reported by the DHCP server */
148
extern u32  net_boot_file_expected_size_in_blocks;
149
150
/**
151
 * compute_ip_checksum() - Compute IP checksum
152
 *
153
 * @addr: Address to check (must be 16-bit aligned)
154
 * @nbytes: Number of bytes to check (normally a multiple of 2)
155
 * Return: 16-bit IP checksum
156
 */
157
unsigned compute_ip_checksum(const void *addr, unsigned int nbytes);
158
159
/**
160
 * ip_checksum_ok() - check if a checksum is correct
161
 *
162
 * This works by making sure the checksum sums to 0
163
 *
164
 * @addr: Address to check (must be 16-bit aligned)
165
 * @nbytes: Number of bytes to check (normally a multiple of 2)
166
 * Return: true if the checksum matches, false if not
167
 */
168
int ip_checksum_ok(const void *addr, unsigned int nbytes);
169
170
/**
171
 * add_ip_checksums() - add two IP checksums
172
 *
173
 * @offset: Offset of first sum (if odd we do a byte-swap)
174
 * @sum:  First checksum
175
 * @new_sum:  New checksum to add
176
 * Return: updated 16-bit IP checksum
177
 */
178
unsigned add_ip_checksums(unsigned offset, unsigned sum, unsigned int new_sum);
179
180
/*
181
 * The devname can be either an exact name given by the driver or device tree
182
 * or it can be an alias of the form "eth%d"
183
 */
184
struct udevice *eth_get_dev_by_name(const char *devname);
185
int eth_is_active(struct udevice *dev); /* Test device for active state */
186
187
/*
188
 * Get the hardware address for an ethernet interface .
189
 * Args:
190
 *  base_name - base name for device (normally "eth")
191
 *  index - device index number (0 for first)
192
 *  enetaddr - returns 6 byte hardware address
193
 * Returns:
194
 *  Return true if the address is valid.
195
 */
196
int eth_env_get_enetaddr_by_index(const char *base_name, int index,
197
         uchar *enetaddr);
198
199
/**
200
 * eth_env_set_enetaddr_by_index() - set the MAC address environment variable
201
 *
202
 * This sets up an environment variable with the given MAC address (@enetaddr).
203
 * The environment variable to be set is defined by <@base_name><@index>addr.
204
 * If @index is 0 it is omitted. For common Ethernet this means ethaddr,
205
 * eth1addr, etc.
206
 *
207
 * @base_name:  Base name for variable, typically "eth"
208
 * @index:      Index of interface being updated (>=0)
209
 * @enetaddr:   Pointer to MAC address to put into the variable
210
 * Return: 0 if OK, other value on error
211
 */
212
int eth_env_set_enetaddr_by_index(const char *base_name, int index,
213
          uchar *enetaddr);
214
215
/*
216
 * Initialize USB ethernet device with CONFIG_DM_ETH
217
 * Returns:
218
 *  0 is success, non-zero is error status.
219
 */
220
int usb_ether_init(void);
221
222
int eth_init(void);     /* Initialize the device */
223
int eth_start_udev(struct udevice *dev); /* ->start() if not already running */
224
int eth_send(void *packet, int length);    /* Send a packet */
225
#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER)
226
int eth_receive(void *packet, int length); /* Receive a packet*/
227
extern void (*push_packet)(void *packet, int length);
228
#endif
229
int eth_rx(void);     /* Check for received packets */
230
231
/**
232
 * reset_phy() - Reset the Ethernet PHY
233
 *
234
 * This should be implemented by boards if CONFIG_RESET_PHY_R is enabled
235
 */
236
void reset_phy(void);
237
238
#if CONFIG_IS_ENABLED(NET) || CONFIG_IS_ENABLED(NET_LWIP)
239
/**
240
 * eth_set_enable_bootdevs() - Enable or disable binding of Ethernet bootdevs
241
 *
242
 * These get in the way of bootstd testing, so are normally disabled by tests.
243
 * This provide control of this setting. It only affects binding of Ethernet
244
 * devices, so if that has already happened, this flag does nothing.
245
 *
246
 * @enable: true to enable binding of bootdevs when binding new Ethernet
247
 * devices, false to disable it
248
 */
249
void eth_set_enable_bootdevs(bool enable);
250
#else
251
static inline void eth_set_enable_bootdevs(bool enable) {}
252
#endif
253
254
static inline void net_send_packet(uchar *pkt, int len)
255
0
{
256
0
  if (DEBUG_NET_PKT_TRACE)
257
0
    print_hex_dump_bytes("tx: ", DUMP_PREFIX_OFFSET, pkt, len);
258
  /* Currently no way to return errors from eth_send() */
259
0
  (void)eth_send(pkt, len);
260
0
}
Unexecuted instantiation: bootm.c:net_send_packet
Unexecuted instantiation: pxe_utils.c:net_send_packet
Unexecuted instantiation: bootmeth_pxe.c:net_send_packet
Unexecuted instantiation: bootmeth_efi.c:net_send_packet
Unexecuted instantiation: bootmeth_script.c:net_send_packet
Unexecuted instantiation: fdt_support.c:net_send_packet
Unexecuted instantiation: boot.c:net_send_packet
Unexecuted instantiation: bdinfo.c:net_send_packet
Unexecuted instantiation: efidebug.c:net_send_packet
Unexecuted instantiation: elf.c:net_send_packet
Unexecuted instantiation: load.c:net_send_packet
Unexecuted instantiation: mii.c:net_send_packet
Unexecuted instantiation: mdio.c:net_send_packet
Unexecuted instantiation: net.c:net_send_packet
Unexecuted instantiation: net-common.c:net_send_packet
Unexecuted instantiation: pcap.c:net_send_packet
Unexecuted instantiation: pxe.c:net_send_packet
Unexecuted instantiation: fastboot.c:net_send_packet
Unexecuted instantiation: ethsw.c:net_send_packet
Unexecuted instantiation: main.c:net_send_packet
Unexecuted instantiation: board_r.c:net_send_packet
Unexecuted instantiation: miiphyutil.c:net_send_packet
Unexecuted instantiation: dfu.c:net_send_packet
Unexecuted instantiation: dsa_sandbox.c:net_send_packet
Unexecuted instantiation: sandbox.c:net_send_packet
Unexecuted instantiation: sandbox-raw.c:net_send_packet
Unexecuted instantiation: mdio_mux_sandbox.c:net_send_packet
Unexecuted instantiation: mdio_sandbox.c:net_send_packet
Unexecuted instantiation: netconsole.c:net_send_packet
Unexecuted instantiation: phy.c:net_send_packet
Unexecuted instantiation: virtio_net.c:net_send_packet
Unexecuted instantiation: fb_common.c:net_send_packet
Unexecuted instantiation: ether.c:net_send_packet
Unexecuted instantiation: common.c:net_send_packet
Unexecuted instantiation: efi_bootmgr.c:net_send_packet
Unexecuted instantiation: efi_bootbin.c:net_send_packet
Unexecuted instantiation: efi_boottime.c:net_send_packet
Unexecuted instantiation: efi_device_path.c:net_send_packet
Unexecuted instantiation: efi_device_path_to_text.c:net_send_packet
Unexecuted instantiation: efi_setup.c:net_send_packet
Unexecuted instantiation: efi_net.c:net_send_packet
Unexecuted instantiation: efi_ipconfig.c:net_send_packet
Unexecuted instantiation: efi_http.c:net_send_packet
Unexecuted instantiation: efi_selftest_console.c:net_send_packet
Unexecuted instantiation: efi_selftest_snp.c:net_send_packet
Unexecuted instantiation: efi_selftest_http.c:net_send_packet
Unexecuted instantiation: efi_selftest_ipconfig.c:net_send_packet
Unexecuted instantiation: net_utils.c:net_send_packet
Unexecuted instantiation: fdtdec.c:net_send_packet
Unexecuted instantiation: arp.c:net_send_packet
Unexecuted instantiation: bootp.c:net_send_packet
Unexecuted instantiation: cdp.c:net_send_packet
Unexecuted instantiation: dns.c:net_send_packet
Unexecuted instantiation: link_local.c:net_send_packet
Unexecuted instantiation: ndisc.c:net_send_packet
Unexecuted instantiation: net6.c:net_send_packet
Unexecuted instantiation: ping.c:net_send_packet
Unexecuted instantiation: ping6.c:net_send_packet
Unexecuted instantiation: dhcpv6.c:net_send_packet
Unexecuted instantiation: rarp.c:net_send_packet
Unexecuted instantiation: sntp.c:net_send_packet
Unexecuted instantiation: tftp.c:net_send_packet
Unexecuted instantiation: fastboot_udp.c:net_send_packet
Unexecuted instantiation: udp.c:net_send_packet
Unexecuted instantiation: tcp.c:net_send_packet
Unexecuted instantiation: wget.c:net_send_packet
Unexecuted instantiation: dsa-uclass.c:net_send_packet
Unexecuted instantiation: eth-uclass.c:net_send_packet
Unexecuted instantiation: eth_bootdev.c:net_send_packet
Unexecuted instantiation: mdio-uclass.c:net_send_packet
Unexecuted instantiation: mdio-mux-uclass.c:net_send_packet
Unexecuted instantiation: eth_common.c:net_send_packet
Unexecuted instantiation: test-main.c:net_send_packet
Unexecuted instantiation: dsa.c:net_send_packet
Unexecuted instantiation: eth.c:net_send_packet
Unexecuted instantiation: mdio_mux.c:net_send_packet
261
262
enum eth_recv_flags {
263
  /*
264
   * Check hardware device for new packets (otherwise only return those
265
   * which are already in the memory buffer ready to process)
266
   */
267
  ETH_RECV_CHECK_DEVICE   = 1 << 0,
268
};
269
270
/**
271
 * struct eth_ops - functions of Ethernet MAC controllers
272
 *
273
 * start: Prepare the hardware to send and receive packets
274
 * send: Send the bytes passed in "packet" as a packet on the wire
275
 * recv: Check if the hardware received a packet. If so, set the pointer to the
276
 *   packet buffer in the packetp parameter. If not, return an error or 0 to
277
 *   indicate that the hardware receive FIFO is empty. If 0 is returned, the
278
 *   network stack will not process the empty packet, but free_pkt() will be
279
 *   called if supplied
280
 * free_pkt: Give the driver an opportunity to manage its packet buffer memory
281
 *       when the network stack is finished processing it. This will only be
282
 *       called when no error was returned from recv - optional
283
 * stop: Stop the hardware from looking for packets - may be called even if
284
 *   state == PASSIVE
285
 * mcast: Join or leave a multicast group (for TFTP) - optional
286
 * write_hwaddr: Write a MAC address to the hardware (used to pass it to Linux
287
 *     on some platforms like ARM). This function expects the
288
 *     eth_pdata::enetaddr field to be populated. The method can
289
 *     return -ENOSYS to indicate that this is not implemented for
290
     this hardware - optional.
291
 * read_rom_hwaddr: Some devices have a backup of the MAC address stored in a
292
 *        ROM on the board. This is how the driver should expose it
293
 *        to the network stack. This function should fill in the
294
 *        eth_pdata::enetaddr field - optional
295
 * set_promisc: Enable or Disable promiscuous mode
296
 * get_sset_count: Number of statistics counters
297
 * get_string: Names of the statistic counters
298
 * get_stats: The values of the statistic counters
299
 */
300
struct eth_ops {
301
  int (*start)(struct udevice *dev);
302
  int (*send)(struct udevice *dev, void *packet, int length);
303
  int (*recv)(struct udevice *dev, int flags, uchar **packetp);
304
  int (*free_pkt)(struct udevice *dev, uchar *packet, int length);
305
  void (*stop)(struct udevice *dev);
306
  int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join);
307
  int (*write_hwaddr)(struct udevice *dev);
308
  int (*read_rom_hwaddr)(struct udevice *dev);
309
  int (*set_promisc)(struct udevice *dev, bool enable);
310
  int (*get_sset_count)(struct udevice *dev);
311
  void (*get_strings)(struct udevice *dev, u8 *data);
312
  void (*get_stats)(struct udevice *dev, u64 *data);
313
};
314
315
0
#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops)
316
317
struct udevice *eth_get_dev(void); /* get the current device */
318
void eth_set_dev(struct udevice *dev); /* set a device */
319
unsigned char *eth_get_ethaddr(void); /* get the current device MAC */
320
int eth_rx(void);                      /* Check for received packets */
321
void eth_halt(void);      /* stop SCC */
322
const char *eth_get_name(void);   /* get name of current device */
323
int eth_get_dev_index(void);
324
325
int eth_initialize(void);   /* Initialize network subsystem */
326
void eth_try_another(int first_restart);  /* Change the device */
327
void eth_set_current(void);   /* set nterface to ethcur var */
328
329
enum eth_state_t {
330
  ETH_STATE_INIT,
331
  ETH_STATE_PASSIVE,
332
  ETH_STATE_ACTIVE
333
};
334
335
/**
336
 * struct eth_pdata - Platform data for Ethernet MAC controllers
337
 *
338
 * @iobase: The base address of the hardware registers
339
 * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env
340
 * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_...
341
 * @max_speed: Maximum speed of Ethernet connection supported by MAC
342
 * @priv_pdata: device specific plat
343
 */
344
struct eth_pdata {
345
  phys_addr_t iobase;
346
  unsigned char enetaddr[ARP_HLEN];
347
  int phy_interface;
348
  int max_speed;
349
  void *priv_pdata;
350
};
351
352
struct ethernet_hdr {
353
  u8    et_dest[ARP_HLEN];  /* Destination node */
354
  u8    et_src[ARP_HLEN]; /* Source node    */
355
  u16   et_protlen;   /* Protocol or length */
356
} __packed;
357
358
/* Ethernet header size */
359
0
#define ETHER_HDR_SIZE  (sizeof(struct ethernet_hdr))
360
361
/**
362
 * net_random_ethaddr - Generate software assigned random Ethernet address
363
 * @addr: Pointer to a six-byte array containing the Ethernet address
364
 *
365
 * Generate a random Ethernet address (MAC) that is not multicast
366
 * and has the local assigned bit set.
367
 */
368
static inline void net_random_ethaddr(uchar *addr)
369
0
{
370
0
  int i;
371
0
  unsigned int seed = get_ticks();
372
373
0
  for (i = 0; i < 6; i++)
374
0
    addr[i] = rand_r(&seed);
375
376
0
  addr[0] &= 0xfe;  /* clear multicast bit */
377
0
  addr[0] |= 0x02;  /* set local assignment bit (IEEE802) */
378
0
}
Unexecuted instantiation: bootm.c:net_random_ethaddr
Unexecuted instantiation: pxe_utils.c:net_random_ethaddr
Unexecuted instantiation: bootmeth_pxe.c:net_random_ethaddr
Unexecuted instantiation: bootmeth_efi.c:net_random_ethaddr
Unexecuted instantiation: bootmeth_script.c:net_random_ethaddr
Unexecuted instantiation: fdt_support.c:net_random_ethaddr
Unexecuted instantiation: boot.c:net_random_ethaddr
Unexecuted instantiation: bdinfo.c:net_random_ethaddr
Unexecuted instantiation: efidebug.c:net_random_ethaddr
Unexecuted instantiation: elf.c:net_random_ethaddr
Unexecuted instantiation: load.c:net_random_ethaddr
Unexecuted instantiation: mii.c:net_random_ethaddr
Unexecuted instantiation: mdio.c:net_random_ethaddr
Unexecuted instantiation: net.c:net_random_ethaddr
Unexecuted instantiation: net-common.c:net_random_ethaddr
Unexecuted instantiation: pcap.c:net_random_ethaddr
Unexecuted instantiation: pxe.c:net_random_ethaddr
Unexecuted instantiation: fastboot.c:net_random_ethaddr
Unexecuted instantiation: ethsw.c:net_random_ethaddr
Unexecuted instantiation: main.c:net_random_ethaddr
Unexecuted instantiation: board_r.c:net_random_ethaddr
Unexecuted instantiation: miiphyutil.c:net_random_ethaddr
Unexecuted instantiation: dfu.c:net_random_ethaddr
Unexecuted instantiation: dsa_sandbox.c:net_random_ethaddr
Unexecuted instantiation: sandbox.c:net_random_ethaddr
Unexecuted instantiation: sandbox-raw.c:net_random_ethaddr
Unexecuted instantiation: mdio_mux_sandbox.c:net_random_ethaddr
Unexecuted instantiation: mdio_sandbox.c:net_random_ethaddr
Unexecuted instantiation: netconsole.c:net_random_ethaddr
Unexecuted instantiation: phy.c:net_random_ethaddr
Unexecuted instantiation: virtio_net.c:net_random_ethaddr
Unexecuted instantiation: fb_common.c:net_random_ethaddr
Unexecuted instantiation: ether.c:net_random_ethaddr
Unexecuted instantiation: common.c:net_random_ethaddr
Unexecuted instantiation: efi_bootmgr.c:net_random_ethaddr
Unexecuted instantiation: efi_bootbin.c:net_random_ethaddr
Unexecuted instantiation: efi_boottime.c:net_random_ethaddr
Unexecuted instantiation: efi_device_path.c:net_random_ethaddr
Unexecuted instantiation: efi_device_path_to_text.c:net_random_ethaddr
Unexecuted instantiation: efi_setup.c:net_random_ethaddr
Unexecuted instantiation: efi_net.c:net_random_ethaddr
Unexecuted instantiation: efi_ipconfig.c:net_random_ethaddr
Unexecuted instantiation: efi_http.c:net_random_ethaddr
Unexecuted instantiation: efi_selftest_console.c:net_random_ethaddr
Unexecuted instantiation: efi_selftest_snp.c:net_random_ethaddr
Unexecuted instantiation: efi_selftest_http.c:net_random_ethaddr
Unexecuted instantiation: efi_selftest_ipconfig.c:net_random_ethaddr
Unexecuted instantiation: net_utils.c:net_random_ethaddr
Unexecuted instantiation: fdtdec.c:net_random_ethaddr
Unexecuted instantiation: arp.c:net_random_ethaddr
Unexecuted instantiation: bootp.c:net_random_ethaddr
Unexecuted instantiation: cdp.c:net_random_ethaddr
Unexecuted instantiation: dns.c:net_random_ethaddr
Unexecuted instantiation: link_local.c:net_random_ethaddr
Unexecuted instantiation: ndisc.c:net_random_ethaddr
Unexecuted instantiation: net6.c:net_random_ethaddr
Unexecuted instantiation: ping.c:net_random_ethaddr
Unexecuted instantiation: ping6.c:net_random_ethaddr
Unexecuted instantiation: dhcpv6.c:net_random_ethaddr
Unexecuted instantiation: rarp.c:net_random_ethaddr
Unexecuted instantiation: sntp.c:net_random_ethaddr
Unexecuted instantiation: tftp.c:net_random_ethaddr
Unexecuted instantiation: fastboot_udp.c:net_random_ethaddr
Unexecuted instantiation: udp.c:net_random_ethaddr
Unexecuted instantiation: tcp.c:net_random_ethaddr
Unexecuted instantiation: wget.c:net_random_ethaddr
Unexecuted instantiation: dsa-uclass.c:net_random_ethaddr
Unexecuted instantiation: eth-uclass.c:net_random_ethaddr
Unexecuted instantiation: eth_bootdev.c:net_random_ethaddr
Unexecuted instantiation: mdio-uclass.c:net_random_ethaddr
Unexecuted instantiation: mdio-mux-uclass.c:net_random_ethaddr
Unexecuted instantiation: eth_common.c:net_random_ethaddr
Unexecuted instantiation: test-main.c:net_random_ethaddr
Unexecuted instantiation: dsa.c:net_random_ethaddr
Unexecuted instantiation: eth.c:net_random_ethaddr
Unexecuted instantiation: mdio_mux.c:net_random_ethaddr
379
380
/**
381
 * is_zero_ethaddr - Determine if give Ethernet address is all zeros.
382
 * @addr: Pointer to a six-byte array containing the Ethernet address
383
 *
384
 * Return true if the address is all zeroes.
385
 */
386
static inline int is_zero_ethaddr(const u8 *addr)
387
0
{
388
0
  return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
389
0
}
Unexecuted instantiation: bootm.c:is_zero_ethaddr
Unexecuted instantiation: pxe_utils.c:is_zero_ethaddr
Unexecuted instantiation: bootmeth_pxe.c:is_zero_ethaddr
Unexecuted instantiation: bootmeth_efi.c:is_zero_ethaddr
Unexecuted instantiation: bootmeth_script.c:is_zero_ethaddr
Unexecuted instantiation: fdt_support.c:is_zero_ethaddr
Unexecuted instantiation: boot.c:is_zero_ethaddr
Unexecuted instantiation: bdinfo.c:is_zero_ethaddr
Unexecuted instantiation: efidebug.c:is_zero_ethaddr
Unexecuted instantiation: elf.c:is_zero_ethaddr
Unexecuted instantiation: load.c:is_zero_ethaddr
Unexecuted instantiation: mii.c:is_zero_ethaddr
Unexecuted instantiation: mdio.c:is_zero_ethaddr
Unexecuted instantiation: net.c:is_zero_ethaddr
Unexecuted instantiation: net-common.c:is_zero_ethaddr
Unexecuted instantiation: pcap.c:is_zero_ethaddr
Unexecuted instantiation: pxe.c:is_zero_ethaddr
Unexecuted instantiation: fastboot.c:is_zero_ethaddr
Unexecuted instantiation: ethsw.c:is_zero_ethaddr
Unexecuted instantiation: main.c:is_zero_ethaddr
Unexecuted instantiation: board_r.c:is_zero_ethaddr
Unexecuted instantiation: miiphyutil.c:is_zero_ethaddr
Unexecuted instantiation: dfu.c:is_zero_ethaddr
Unexecuted instantiation: dsa_sandbox.c:is_zero_ethaddr
Unexecuted instantiation: sandbox.c:is_zero_ethaddr
Unexecuted instantiation: sandbox-raw.c:is_zero_ethaddr
Unexecuted instantiation: mdio_mux_sandbox.c:is_zero_ethaddr
Unexecuted instantiation: mdio_sandbox.c:is_zero_ethaddr
Unexecuted instantiation: netconsole.c:is_zero_ethaddr
Unexecuted instantiation: phy.c:is_zero_ethaddr
Unexecuted instantiation: virtio_net.c:is_zero_ethaddr
Unexecuted instantiation: fb_common.c:is_zero_ethaddr
Unexecuted instantiation: ether.c:is_zero_ethaddr
Unexecuted instantiation: common.c:is_zero_ethaddr
Unexecuted instantiation: efi_bootmgr.c:is_zero_ethaddr
Unexecuted instantiation: efi_bootbin.c:is_zero_ethaddr
Unexecuted instantiation: efi_boottime.c:is_zero_ethaddr
Unexecuted instantiation: efi_device_path.c:is_zero_ethaddr
Unexecuted instantiation: efi_device_path_to_text.c:is_zero_ethaddr
Unexecuted instantiation: efi_setup.c:is_zero_ethaddr
Unexecuted instantiation: efi_net.c:is_zero_ethaddr
Unexecuted instantiation: efi_ipconfig.c:is_zero_ethaddr
Unexecuted instantiation: efi_http.c:is_zero_ethaddr
Unexecuted instantiation: efi_selftest_console.c:is_zero_ethaddr
Unexecuted instantiation: efi_selftest_snp.c:is_zero_ethaddr
Unexecuted instantiation: efi_selftest_http.c:is_zero_ethaddr
Unexecuted instantiation: efi_selftest_ipconfig.c:is_zero_ethaddr
Unexecuted instantiation: net_utils.c:is_zero_ethaddr
Unexecuted instantiation: fdtdec.c:is_zero_ethaddr
Unexecuted instantiation: arp.c:is_zero_ethaddr
Unexecuted instantiation: bootp.c:is_zero_ethaddr
Unexecuted instantiation: cdp.c:is_zero_ethaddr
Unexecuted instantiation: dns.c:is_zero_ethaddr
Unexecuted instantiation: link_local.c:is_zero_ethaddr
Unexecuted instantiation: ndisc.c:is_zero_ethaddr
Unexecuted instantiation: net6.c:is_zero_ethaddr
Unexecuted instantiation: ping.c:is_zero_ethaddr
Unexecuted instantiation: ping6.c:is_zero_ethaddr
Unexecuted instantiation: dhcpv6.c:is_zero_ethaddr
Unexecuted instantiation: rarp.c:is_zero_ethaddr
Unexecuted instantiation: sntp.c:is_zero_ethaddr
Unexecuted instantiation: tftp.c:is_zero_ethaddr
Unexecuted instantiation: fastboot_udp.c:is_zero_ethaddr
Unexecuted instantiation: udp.c:is_zero_ethaddr
Unexecuted instantiation: tcp.c:is_zero_ethaddr
Unexecuted instantiation: wget.c:is_zero_ethaddr
Unexecuted instantiation: dsa-uclass.c:is_zero_ethaddr
Unexecuted instantiation: eth-uclass.c:is_zero_ethaddr
Unexecuted instantiation: eth_bootdev.c:is_zero_ethaddr
Unexecuted instantiation: mdio-uclass.c:is_zero_ethaddr
Unexecuted instantiation: mdio-mux-uclass.c:is_zero_ethaddr
Unexecuted instantiation: eth_common.c:is_zero_ethaddr
Unexecuted instantiation: test-main.c:is_zero_ethaddr
Unexecuted instantiation: dsa.c:is_zero_ethaddr
Unexecuted instantiation: eth.c:is_zero_ethaddr
Unexecuted instantiation: mdio_mux.c:is_zero_ethaddr
390
391
/**
392
 * is_multicast_ethaddr - Determine if the Ethernet address is a multicast.
393
 * @addr: Pointer to a six-byte array containing the Ethernet address
394
 *
395
 * Return true if the address is a multicast address.
396
 * By definition the broadcast address is also a multicast address.
397
 */
398
static inline int is_multicast_ethaddr(const u8 *addr)
399
0
{
400
0
  return 0x01 & addr[0];
401
0
}
Unexecuted instantiation: bootm.c:is_multicast_ethaddr
Unexecuted instantiation: pxe_utils.c:is_multicast_ethaddr
Unexecuted instantiation: bootmeth_pxe.c:is_multicast_ethaddr
Unexecuted instantiation: bootmeth_efi.c:is_multicast_ethaddr
Unexecuted instantiation: bootmeth_script.c:is_multicast_ethaddr
Unexecuted instantiation: fdt_support.c:is_multicast_ethaddr
Unexecuted instantiation: boot.c:is_multicast_ethaddr
Unexecuted instantiation: bdinfo.c:is_multicast_ethaddr
Unexecuted instantiation: efidebug.c:is_multicast_ethaddr
Unexecuted instantiation: elf.c:is_multicast_ethaddr
Unexecuted instantiation: load.c:is_multicast_ethaddr
Unexecuted instantiation: mii.c:is_multicast_ethaddr
Unexecuted instantiation: mdio.c:is_multicast_ethaddr
Unexecuted instantiation: net.c:is_multicast_ethaddr
Unexecuted instantiation: net-common.c:is_multicast_ethaddr
Unexecuted instantiation: pcap.c:is_multicast_ethaddr
Unexecuted instantiation: pxe.c:is_multicast_ethaddr
Unexecuted instantiation: fastboot.c:is_multicast_ethaddr
Unexecuted instantiation: ethsw.c:is_multicast_ethaddr
Unexecuted instantiation: main.c:is_multicast_ethaddr
Unexecuted instantiation: board_r.c:is_multicast_ethaddr
Unexecuted instantiation: miiphyutil.c:is_multicast_ethaddr
Unexecuted instantiation: dfu.c:is_multicast_ethaddr
Unexecuted instantiation: dsa_sandbox.c:is_multicast_ethaddr
Unexecuted instantiation: sandbox.c:is_multicast_ethaddr
Unexecuted instantiation: sandbox-raw.c:is_multicast_ethaddr
Unexecuted instantiation: mdio_mux_sandbox.c:is_multicast_ethaddr
Unexecuted instantiation: mdio_sandbox.c:is_multicast_ethaddr
Unexecuted instantiation: netconsole.c:is_multicast_ethaddr
Unexecuted instantiation: phy.c:is_multicast_ethaddr
Unexecuted instantiation: virtio_net.c:is_multicast_ethaddr
Unexecuted instantiation: fb_common.c:is_multicast_ethaddr
Unexecuted instantiation: ether.c:is_multicast_ethaddr
Unexecuted instantiation: common.c:is_multicast_ethaddr
Unexecuted instantiation: efi_bootmgr.c:is_multicast_ethaddr
Unexecuted instantiation: efi_bootbin.c:is_multicast_ethaddr
Unexecuted instantiation: efi_boottime.c:is_multicast_ethaddr
Unexecuted instantiation: efi_device_path.c:is_multicast_ethaddr
Unexecuted instantiation: efi_device_path_to_text.c:is_multicast_ethaddr
Unexecuted instantiation: efi_setup.c:is_multicast_ethaddr
Unexecuted instantiation: efi_net.c:is_multicast_ethaddr
Unexecuted instantiation: efi_ipconfig.c:is_multicast_ethaddr
Unexecuted instantiation: efi_http.c:is_multicast_ethaddr
Unexecuted instantiation: efi_selftest_console.c:is_multicast_ethaddr
Unexecuted instantiation: efi_selftest_snp.c:is_multicast_ethaddr
Unexecuted instantiation: efi_selftest_http.c:is_multicast_ethaddr
Unexecuted instantiation: efi_selftest_ipconfig.c:is_multicast_ethaddr
Unexecuted instantiation: net_utils.c:is_multicast_ethaddr
Unexecuted instantiation: fdtdec.c:is_multicast_ethaddr
Unexecuted instantiation: arp.c:is_multicast_ethaddr
Unexecuted instantiation: bootp.c:is_multicast_ethaddr
Unexecuted instantiation: cdp.c:is_multicast_ethaddr
Unexecuted instantiation: dns.c:is_multicast_ethaddr
Unexecuted instantiation: link_local.c:is_multicast_ethaddr
Unexecuted instantiation: ndisc.c:is_multicast_ethaddr
Unexecuted instantiation: net6.c:is_multicast_ethaddr
Unexecuted instantiation: ping.c:is_multicast_ethaddr
Unexecuted instantiation: ping6.c:is_multicast_ethaddr
Unexecuted instantiation: dhcpv6.c:is_multicast_ethaddr
Unexecuted instantiation: rarp.c:is_multicast_ethaddr
Unexecuted instantiation: sntp.c:is_multicast_ethaddr
Unexecuted instantiation: tftp.c:is_multicast_ethaddr
Unexecuted instantiation: fastboot_udp.c:is_multicast_ethaddr
Unexecuted instantiation: udp.c:is_multicast_ethaddr
Unexecuted instantiation: tcp.c:is_multicast_ethaddr
Unexecuted instantiation: wget.c:is_multicast_ethaddr
Unexecuted instantiation: dsa-uclass.c:is_multicast_ethaddr
Unexecuted instantiation: eth-uclass.c:is_multicast_ethaddr
Unexecuted instantiation: eth_bootdev.c:is_multicast_ethaddr
Unexecuted instantiation: mdio-uclass.c:is_multicast_ethaddr
Unexecuted instantiation: mdio-mux-uclass.c:is_multicast_ethaddr
Unexecuted instantiation: eth_common.c:is_multicast_ethaddr
Unexecuted instantiation: test-main.c:is_multicast_ethaddr
Unexecuted instantiation: dsa.c:is_multicast_ethaddr
Unexecuted instantiation: eth.c:is_multicast_ethaddr
Unexecuted instantiation: mdio_mux.c:is_multicast_ethaddr
402
403
/*
404
 * is_broadcast_ethaddr - Determine if the Ethernet address is broadcast
405
 * @addr: Pointer to a six-byte array containing the Ethernet address
406
 *
407
 * Return true if the address is the broadcast address.
408
 */
409
static inline int is_broadcast_ethaddr(const u8 *addr)
410
0
{
411
0
  return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) ==
412
0
    0xff;
413
0
}
Unexecuted instantiation: bootm.c:is_broadcast_ethaddr
Unexecuted instantiation: pxe_utils.c:is_broadcast_ethaddr
Unexecuted instantiation: bootmeth_pxe.c:is_broadcast_ethaddr
Unexecuted instantiation: bootmeth_efi.c:is_broadcast_ethaddr
Unexecuted instantiation: bootmeth_script.c:is_broadcast_ethaddr
Unexecuted instantiation: fdt_support.c:is_broadcast_ethaddr
Unexecuted instantiation: boot.c:is_broadcast_ethaddr
Unexecuted instantiation: bdinfo.c:is_broadcast_ethaddr
Unexecuted instantiation: efidebug.c:is_broadcast_ethaddr
Unexecuted instantiation: elf.c:is_broadcast_ethaddr
Unexecuted instantiation: load.c:is_broadcast_ethaddr
Unexecuted instantiation: mii.c:is_broadcast_ethaddr
Unexecuted instantiation: mdio.c:is_broadcast_ethaddr
Unexecuted instantiation: net.c:is_broadcast_ethaddr
Unexecuted instantiation: net-common.c:is_broadcast_ethaddr
Unexecuted instantiation: pcap.c:is_broadcast_ethaddr
Unexecuted instantiation: pxe.c:is_broadcast_ethaddr
Unexecuted instantiation: fastboot.c:is_broadcast_ethaddr
Unexecuted instantiation: ethsw.c:is_broadcast_ethaddr
Unexecuted instantiation: main.c:is_broadcast_ethaddr
Unexecuted instantiation: board_r.c:is_broadcast_ethaddr
Unexecuted instantiation: miiphyutil.c:is_broadcast_ethaddr
Unexecuted instantiation: dfu.c:is_broadcast_ethaddr
Unexecuted instantiation: dsa_sandbox.c:is_broadcast_ethaddr
Unexecuted instantiation: sandbox.c:is_broadcast_ethaddr
Unexecuted instantiation: sandbox-raw.c:is_broadcast_ethaddr
Unexecuted instantiation: mdio_mux_sandbox.c:is_broadcast_ethaddr
Unexecuted instantiation: mdio_sandbox.c:is_broadcast_ethaddr
Unexecuted instantiation: netconsole.c:is_broadcast_ethaddr
Unexecuted instantiation: phy.c:is_broadcast_ethaddr
Unexecuted instantiation: virtio_net.c:is_broadcast_ethaddr
Unexecuted instantiation: fb_common.c:is_broadcast_ethaddr
Unexecuted instantiation: ether.c:is_broadcast_ethaddr
Unexecuted instantiation: common.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_bootmgr.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_bootbin.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_boottime.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_device_path.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_device_path_to_text.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_setup.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_net.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_ipconfig.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_http.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_selftest_console.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_selftest_snp.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_selftest_http.c:is_broadcast_ethaddr
Unexecuted instantiation: efi_selftest_ipconfig.c:is_broadcast_ethaddr
Unexecuted instantiation: net_utils.c:is_broadcast_ethaddr
Unexecuted instantiation: fdtdec.c:is_broadcast_ethaddr
Unexecuted instantiation: arp.c:is_broadcast_ethaddr
Unexecuted instantiation: bootp.c:is_broadcast_ethaddr
Unexecuted instantiation: cdp.c:is_broadcast_ethaddr
Unexecuted instantiation: dns.c:is_broadcast_ethaddr
Unexecuted instantiation: link_local.c:is_broadcast_ethaddr
Unexecuted instantiation: ndisc.c:is_broadcast_ethaddr
Unexecuted instantiation: net6.c:is_broadcast_ethaddr
Unexecuted instantiation: ping.c:is_broadcast_ethaddr
Unexecuted instantiation: ping6.c:is_broadcast_ethaddr
Unexecuted instantiation: dhcpv6.c:is_broadcast_ethaddr
Unexecuted instantiation: rarp.c:is_broadcast_ethaddr
Unexecuted instantiation: sntp.c:is_broadcast_ethaddr
Unexecuted instantiation: tftp.c:is_broadcast_ethaddr
Unexecuted instantiation: fastboot_udp.c:is_broadcast_ethaddr
Unexecuted instantiation: udp.c:is_broadcast_ethaddr
Unexecuted instantiation: tcp.c:is_broadcast_ethaddr
Unexecuted instantiation: wget.c:is_broadcast_ethaddr
Unexecuted instantiation: dsa-uclass.c:is_broadcast_ethaddr
Unexecuted instantiation: eth-uclass.c:is_broadcast_ethaddr
Unexecuted instantiation: eth_bootdev.c:is_broadcast_ethaddr
Unexecuted instantiation: mdio-uclass.c:is_broadcast_ethaddr
Unexecuted instantiation: mdio-mux-uclass.c:is_broadcast_ethaddr
Unexecuted instantiation: eth_common.c:is_broadcast_ethaddr
Unexecuted instantiation: test-main.c:is_broadcast_ethaddr
Unexecuted instantiation: dsa.c:is_broadcast_ethaddr
Unexecuted instantiation: eth.c:is_broadcast_ethaddr
Unexecuted instantiation: mdio_mux.c:is_broadcast_ethaddr
414
415
/*
416
 * is_valid_ethaddr - Determine if the given Ethernet address is valid
417
 * @addr: Pointer to a six-byte array containing the Ethernet address
418
 *
419
 * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
420
 * a multicast address, and is not FF:FF:FF:FF:FF:FF.
421
 *
422
 * Return true if the address is valid.
423
 */
424
static inline int is_valid_ethaddr(const u8 *addr)
425
0
{
426
  /* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to
427
   * explicitly check for it here. */
428
0
  return !is_multicast_ethaddr(addr) && !is_zero_ethaddr(addr);
429
0
}
Unexecuted instantiation: bootm.c:is_valid_ethaddr
Unexecuted instantiation: pxe_utils.c:is_valid_ethaddr
Unexecuted instantiation: bootmeth_pxe.c:is_valid_ethaddr
Unexecuted instantiation: bootmeth_efi.c:is_valid_ethaddr
Unexecuted instantiation: bootmeth_script.c:is_valid_ethaddr
Unexecuted instantiation: fdt_support.c:is_valid_ethaddr
Unexecuted instantiation: boot.c:is_valid_ethaddr
Unexecuted instantiation: bdinfo.c:is_valid_ethaddr
Unexecuted instantiation: efidebug.c:is_valid_ethaddr
Unexecuted instantiation: elf.c:is_valid_ethaddr
Unexecuted instantiation: load.c:is_valid_ethaddr
Unexecuted instantiation: mii.c:is_valid_ethaddr
Unexecuted instantiation: mdio.c:is_valid_ethaddr
Unexecuted instantiation: net.c:is_valid_ethaddr
Unexecuted instantiation: net-common.c:is_valid_ethaddr
Unexecuted instantiation: pcap.c:is_valid_ethaddr
Unexecuted instantiation: pxe.c:is_valid_ethaddr
Unexecuted instantiation: fastboot.c:is_valid_ethaddr
Unexecuted instantiation: ethsw.c:is_valid_ethaddr
Unexecuted instantiation: main.c:is_valid_ethaddr
Unexecuted instantiation: board_r.c:is_valid_ethaddr
Unexecuted instantiation: miiphyutil.c:is_valid_ethaddr
Unexecuted instantiation: dfu.c:is_valid_ethaddr
Unexecuted instantiation: dsa_sandbox.c:is_valid_ethaddr
Unexecuted instantiation: sandbox.c:is_valid_ethaddr
Unexecuted instantiation: sandbox-raw.c:is_valid_ethaddr
Unexecuted instantiation: mdio_mux_sandbox.c:is_valid_ethaddr
Unexecuted instantiation: mdio_sandbox.c:is_valid_ethaddr
Unexecuted instantiation: netconsole.c:is_valid_ethaddr
Unexecuted instantiation: phy.c:is_valid_ethaddr
Unexecuted instantiation: virtio_net.c:is_valid_ethaddr
Unexecuted instantiation: fb_common.c:is_valid_ethaddr
Unexecuted instantiation: ether.c:is_valid_ethaddr
Unexecuted instantiation: common.c:is_valid_ethaddr
Unexecuted instantiation: efi_bootmgr.c:is_valid_ethaddr
Unexecuted instantiation: efi_bootbin.c:is_valid_ethaddr
Unexecuted instantiation: efi_boottime.c:is_valid_ethaddr
Unexecuted instantiation: efi_device_path.c:is_valid_ethaddr
Unexecuted instantiation: efi_device_path_to_text.c:is_valid_ethaddr
Unexecuted instantiation: efi_setup.c:is_valid_ethaddr
Unexecuted instantiation: efi_net.c:is_valid_ethaddr
Unexecuted instantiation: efi_ipconfig.c:is_valid_ethaddr
Unexecuted instantiation: efi_http.c:is_valid_ethaddr
Unexecuted instantiation: efi_selftest_console.c:is_valid_ethaddr
Unexecuted instantiation: efi_selftest_snp.c:is_valid_ethaddr
Unexecuted instantiation: efi_selftest_http.c:is_valid_ethaddr
Unexecuted instantiation: efi_selftest_ipconfig.c:is_valid_ethaddr
Unexecuted instantiation: net_utils.c:is_valid_ethaddr
Unexecuted instantiation: fdtdec.c:is_valid_ethaddr
Unexecuted instantiation: arp.c:is_valid_ethaddr
Unexecuted instantiation: bootp.c:is_valid_ethaddr
Unexecuted instantiation: cdp.c:is_valid_ethaddr
Unexecuted instantiation: dns.c:is_valid_ethaddr
Unexecuted instantiation: link_local.c:is_valid_ethaddr
Unexecuted instantiation: ndisc.c:is_valid_ethaddr
Unexecuted instantiation: net6.c:is_valid_ethaddr
Unexecuted instantiation: ping.c:is_valid_ethaddr
Unexecuted instantiation: ping6.c:is_valid_ethaddr
Unexecuted instantiation: dhcpv6.c:is_valid_ethaddr
Unexecuted instantiation: rarp.c:is_valid_ethaddr
Unexecuted instantiation: sntp.c:is_valid_ethaddr
Unexecuted instantiation: tftp.c:is_valid_ethaddr
Unexecuted instantiation: fastboot_udp.c:is_valid_ethaddr
Unexecuted instantiation: udp.c:is_valid_ethaddr
Unexecuted instantiation: tcp.c:is_valid_ethaddr
Unexecuted instantiation: wget.c:is_valid_ethaddr
Unexecuted instantiation: dsa-uclass.c:is_valid_ethaddr
Unexecuted instantiation: eth-uclass.c:is_valid_ethaddr
Unexecuted instantiation: eth_bootdev.c:is_valid_ethaddr
Unexecuted instantiation: mdio-uclass.c:is_valid_ethaddr
Unexecuted instantiation: mdio-mux-uclass.c:is_valid_ethaddr
Unexecuted instantiation: eth_common.c:is_valid_ethaddr
Unexecuted instantiation: test-main.c:is_valid_ethaddr
Unexecuted instantiation: dsa.c:is_valid_ethaddr
Unexecuted instantiation: eth.c:is_valid_ethaddr
Unexecuted instantiation: mdio_mux.c:is_valid_ethaddr
430
431
/**
432
 * string_to_enetaddr() - Parse a MAC address
433
 *
434
 * Convert a string MAC address
435
 *
436
 * Implemented in lib/net_utils.c (built unconditionally)
437
 *
438
 * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit
439
 *  hex value
440
 * @enetaddr: Place to put MAC address (6 bytes)
441
 */
442
void string_to_enetaddr(const char *addr, uint8_t *enetaddr);
443
444
/**
445
 * string_to_ip() - Convert a string to ip address
446
 *
447
 * Implemented in lib/net_utils.c (built unconditionally)
448
 *
449
 * @s: Input string to parse
450
 * @return: in_addr struct containing the parsed IP address
451
 */
452
struct in_addr string_to_ip(const char *s);
453
454
/**
455
 * ip_to_string() - Convert an IPv4 address to a string
456
 *
457
 * Implemented in lib/net_utils.c (built unconditionally)
458
 *
459
 * @x: Input ip to parse
460
 * @s: string containing the parsed ip address
461
 */
462
void ip_to_string(struct in_addr x, char *s);
463
464
/* copy a filename (allow for "..." notation, limit length) */
465
void copy_filename(char *dst, const char *src, int size);
466
467
/* Processes a received packet */
468
void net_process_received_packet(uchar *in_packet, int len);
469
470
/**
471
 * update_tftp - Update firmware over TFTP (via DFU)
472
 *
473
 * This function updates board's firmware via TFTP
474
 *
475
 * @param addr - memory address where data is stored
476
 * @param interface - the DFU medium name - e.g. "mmc"
477
 * @param devstring - the DFU medium number - e.g. "1"
478
 *
479
 * Return: - 0 on success, other value on failure
480
 */
481
int update_tftp(ulong addr, char *interface, char *devstring);
482
483
int net_init(void);
484
485
/* Called when a network operation fails to know if it should be re-tried */
486
int net_start_again(void);
487
488
/* NET compatibility */
489
enum proto_t;
490
int net_loop(enum proto_t protocol);
491
492
/**
493
 * dhcp_run() - Run DHCP on the current ethernet device
494
 *
495
 * This sets the autoload variable, then puts it back to similar to its original
496
 * state (y, n or unset).
497
 *
498
 * @addr: Address to load the file into (0 if @autoload is false)
499
 * @fname: Filename of file to load (NULL if @autoload is false or to use the
500
 * default filename)
501
 * @autoload: true to load the file, false to just get the network IP
502
 * @return 0 if OK, -EINVAL if the environment failed, -ENOENT if ant file was
503
 * not found
504
 */
505
int dhcp_run(ulong addr, const char *fname, bool autoload);
506
507
/**
508
 * do_dhcp - Run the dhcp command
509
 *
510
 * @cmdtp: Unused
511
 * @flag: Command flags (CMD_FLAG_...)
512
 * @argc: Number of arguments
513
 * @argv: List of arguments
514
 * Return: result (see enum command_ret_t)
515
 */
516
int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
517
518
/**
519
 * tftpb_run() - Run TFTP on the current ethernet device
520
 *
521
 * @addr: Address to load the file into
522
 * @fname: Filename of file to load (NULL to use the default filename)
523
 * @return 0 if OK, -ENOENT if ant file was not found
524
 */
525
int tftpb_run(ulong addr, const char *fname);
526
527
/**
528
 * do_ping - Run the ping command
529
 *
530
 * @cmdtp: Unused
531
 * @flag: Command flags (CMD_FLAG_...)
532
 * @argc: Number of arguments
533
 * @argv: List of arguments
534
 * Return: result (see enum command_ret_t)
535
 */
536
int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
537
538
/**
539
 * do_sntp - Run the sntp command
540
 *
541
 * @cmdtp: Unused
542
 * @flag: Command flags (CMD_FLAG_...)
543
 * @argc: Number of arguments
544
 * @argv: List of arguments
545
 * Return: result (see enum command_ret_t)
546
 */
547
int do_sntp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
548
549
/**
550
 * do_tftpb - Run the tftpboot command
551
 *
552
 * @cmdtp: Command information for tftpboot
553
 * @flag: Command flags (CMD_FLAG_...)
554
 * @argc: Number of arguments
555
 * @argv: List of arguments
556
 * Return: result (see enum command_ret_t)
557
 */
558
int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
559
560
/**
561
 * wget_do_request() - sends a wget request
562
 *
563
 * Sends a wget request, if DNS resolution is enabled it resolves the
564
 * given uri.
565
 *
566
 * @dst_addr: destination address to download the file
567
 * @uri:  uri string of target file of wget
568
 * Return:  zero on success, negative if failed
569
 */
570
int wget_do_request(ulong dst_addr, char *uri);
571
/**
572
 * wget_validate_uri() - varidate the uri
573
 *
574
 * @uri:  uri string of target file of wget
575
 * Return:  true if uri is valid, false if uri is invalid
576
 */
577
bool wget_validate_uri(char *uri);
578
579
/**
580
 * enum wget_http_method - http method
581
 */
582
enum wget_http_method {
583
  WGET_HTTP_METHOD_GET,
584
  WGET_HTTP_METHOD_POST,
585
  WGET_HTTP_METHOD_PATCH,
586
  WGET_HTTP_METHOD_OPTIONS,
587
  WGET_HTTP_METHOD_CONNECT,
588
  WGET_HTTP_METHOD_HEAD,
589
  WGET_HTTP_METHOD_PUT,
590
  WGET_HTTP_METHOD_DELETE,
591
  WGET_HTTP_METHOD_TRACE,
592
  WGET_HTTP_METHOD_MAX
593
};
594
595
/**
596
 * define MAX_HTTP_HEADERS_SIZE - maximum headers buffer size
597
 *
598
 * When receiving http headers, wget fills a buffer with up
599
 * to MAX_HTTP_HEADERS_SIZE bytes of header information.
600
 */
601
0
#define MAX_HTTP_HEADERS_SIZE SZ_64K
602
603
/**
604
 * struct wget_http_info - wget parameters
605
 * @method:   HTTP Method. Filled by client.
606
 * @status_code:  HTTP status code. Filled by wget.
607
 * @file_size:    download size. Filled by wget.
608
 * @buffer_size:  size of client-provided buffer. Filled by client.
609
 * @set_bootdev:  set boot device with download. Filled by client.
610
 * @check_buffer_size:  check download does not exceed buffer size.
611
 *      Filled by client.
612
 * @hdr_cont_len: content length according to headers. Filled by wget
613
 * @headers:    buffer for headers. Filled by wget.
614
 * @silent:   do not print anything to the console. Filled by client.
615
 */
616
struct wget_http_info {
617
  enum wget_http_method method;
618
  u32 status_code;
619
  ulong file_size;
620
  ulong buffer_size;
621
  bool set_bootdev;
622
  bool check_buffer_size;
623
  u32 hdr_cont_len;
624
  char *headers;
625
  bool silent;
626
};
627
628
extern struct wget_http_info default_wget_info;
629
extern struct wget_http_info *wget_info;
630
int wget_request(ulong dst_addr, char *uri, struct wget_http_info *info);
631
632
void net_sntp_set_rtc(u32 seconds);
633
634
#endif /* __NET_COMMON_H__ */