Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / sandbox / include / asm / eth.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2015 National Instruments
4  *
5  * (C) Copyright 2015
6  * Joe Hershberger <joe.hershberger@ni.com>
7  */
8
9 #ifndef __ETH_H
10 #define __ETH_H
11
12 #include <net.h>
13
14 void sandbox_eth_disable_response(int index, bool disable);
15
16 void sandbox_eth_skip_timeout(void);
17
18 /*
19  * sandbox_eth_arp_req_to_reply()
20  *
21  * Check for an arp request to be sent. If so, inject a reply
22  *
23  * @dev: device that received the packet
24  * @packet: pointer to the received pacaket buffer
25  * @len: length of received packet
26  * @return 0 if injected, -EAGAIN if not
27  */
28 int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
29                                  unsigned int len);
30
31 /*
32  * sandbox_eth_ping_req_to_reply()
33  *
34  * Check for a ping request to be sent. If so, inject a reply
35  *
36  * @dev: device that received the packet
37  * @packet: pointer to the received pacaket buffer
38  * @len: length of received packet
39  * @return 0 if injected, -EAGAIN if not
40  */
41 int sandbox_eth_ping_req_to_reply(struct udevice *dev, void *packet,
42                                   unsigned int len);
43
44 /*
45  * sandbox_eth_recv_arp_req()
46  *
47  * Inject an ARP request for this target
48  *
49  * @dev: device that received the packet
50  * @return 0 if injected, -EOVERFLOW if not
51  */
52 int sandbox_eth_recv_arp_req(struct udevice *dev);
53
54 /*
55  * sandbox_eth_recv_ping_req()
56  *
57  * Inject a ping request for this target
58  *
59  * @dev: device that received the packet
60  * @return 0 if injected, -EOVERFLOW if not
61  */
62 int sandbox_eth_recv_ping_req(struct udevice *dev);
63
64 /**
65  * A packet handler
66  *
67  * dev - device pointer
68  * pkt - pointer to the "sent" packet
69  * len - packet length
70  */
71 typedef int sandbox_eth_tx_hand_f(struct udevice *dev, void *pkt,
72                                    unsigned int len);
73
74 /**
75  * struct eth_sandbox_priv - memory for sandbox mock driver
76  *
77  * fake_host_hwaddr - MAC address of mocked machine
78  * fake_host_ipaddr - IP address of mocked machine
79  * disabled - Will not respond
80  * recv_packet_buffer - buffers of the packet returned as received
81  * recv_packet_length - lengths of the packet returned as received
82  * recv_packets - number of packets returned
83  * tx_handler - function to generate responses to sent packets
84  * priv - a pointer to some structure a test may want to keep track of
85  */
86 struct eth_sandbox_priv {
87         uchar fake_host_hwaddr[ARP_HLEN];
88         struct in_addr fake_host_ipaddr;
89         bool disabled;
90         uchar * recv_packet_buffer[PKTBUFSRX];
91         int recv_packet_length[PKTBUFSRX];
92         int recv_packets;
93         sandbox_eth_tx_hand_f *tx_handler;
94         void *priv;
95 };
96
97 /*
98  * Set packet handler
99  *
100  * handler - The func ptr to call on send. If NULL, set to default handler
101  */
102 void sandbox_eth_set_tx_handler(int index, sandbox_eth_tx_hand_f *handler);
103
104 /*
105  * Set priv ptr
106  *
107  * priv - priv void ptr to store in the device
108  */
109 void sandbox_eth_set_priv(int index, void *priv);
110
111 #endif /* __ETH_H */