2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2015-03-22 22:09:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 National Instruments
|
|
|
|
*
|
|
|
|
* (C) Copyright 2015
|
|
|
|
* Joe Hershberger <joe.hershberger@ni.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ETH_H
|
|
|
|
#define __ETH_H
|
|
|
|
|
|
|
|
void sandbox_eth_disable_response(int index, bool disable);
|
|
|
|
|
2015-04-21 18:57:19 +00:00
|
|
|
void sandbox_eth_skip_timeout(void);
|
|
|
|
|
2018-09-26 21:48:54 +00:00
|
|
|
/*
|
|
|
|
* sandbox_eth_arp_req_to_reply()
|
|
|
|
*
|
|
|
|
* Check for an arp request to be sent. If so, inject a reply
|
|
|
|
*
|
|
|
|
* @dev: device that received the packet
|
|
|
|
* @packet: pointer to the received pacaket buffer
|
|
|
|
* @len: length of received packet
|
|
|
|
* @return 0 if injected, -EAGAIN if not
|
|
|
|
*/
|
|
|
|
int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
|
|
|
|
unsigned int len);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sandbox_eth_ping_req_to_reply()
|
|
|
|
*
|
|
|
|
* Check for a ping request to be sent. If so, inject a reply
|
|
|
|
*
|
|
|
|
* @dev: device that received the packet
|
|
|
|
* @packet: pointer to the received pacaket buffer
|
|
|
|
* @len: length of received packet
|
|
|
|
* @return 0 if injected, -EAGAIN if not
|
|
|
|
*/
|
|
|
|
int sandbox_eth_ping_req_to_reply(struct udevice *dev, void *packet,
|
|
|
|
unsigned int len);
|
|
|
|
|
2018-09-26 21:49:00 +00:00
|
|
|
/*
|
|
|
|
* sandbox_eth_recv_arp_req()
|
|
|
|
*
|
|
|
|
* Inject an ARP request for this target
|
|
|
|
*
|
|
|
|
* @dev: device that received the packet
|
|
|
|
* @return 0 if injected, -EOVERFLOW if not
|
|
|
|
*/
|
|
|
|
int sandbox_eth_recv_arp_req(struct udevice *dev);
|
|
|
|
|
2018-09-26 21:49:01 +00:00
|
|
|
/*
|
|
|
|
* sandbox_eth_recv_ping_req()
|
|
|
|
*
|
|
|
|
* Inject a ping request for this target
|
|
|
|
*
|
|
|
|
* @dev: device that received the packet
|
|
|
|
* @return 0 if injected, -EOVERFLOW if not
|
|
|
|
*/
|
|
|
|
int sandbox_eth_recv_ping_req(struct udevice *dev);
|
|
|
|
|
2018-09-26 21:48:55 +00:00
|
|
|
/**
|
|
|
|
* A packet handler
|
|
|
|
*
|
|
|
|
* dev - device pointer
|
|
|
|
* pkt - pointer to the "sent" packet
|
|
|
|
* len - packet length
|
|
|
|
*/
|
|
|
|
typedef int sandbox_eth_tx_hand_f(struct udevice *dev, void *pkt,
|
|
|
|
unsigned int len);
|
|
|
|
|
2018-09-26 21:48:56 +00:00
|
|
|
/**
|
|
|
|
* struct eth_sandbox_priv - memory for sandbox mock driver
|
|
|
|
*
|
|
|
|
* fake_host_hwaddr - MAC address of mocked machine
|
|
|
|
* fake_host_ipaddr - IP address of mocked machine
|
|
|
|
* disabled - Will not respond
|
2018-09-26 21:48:57 +00:00
|
|
|
* recv_packet_buffer - buffers of the packet returned as received
|
|
|
|
* recv_packet_length - lengths of the packet returned as received
|
|
|
|
* recv_packets - number of packets returned
|
2018-09-26 21:48:56 +00:00
|
|
|
* tx_handler - function to generate responses to sent packets
|
2018-09-26 21:48:59 +00:00
|
|
|
* priv - a pointer to some structure a test may want to keep track of
|
2018-09-26 21:48:56 +00:00
|
|
|
*/
|
|
|
|
struct eth_sandbox_priv {
|
|
|
|
uchar fake_host_hwaddr[ARP_HLEN];
|
|
|
|
struct in_addr fake_host_ipaddr;
|
|
|
|
bool disabled;
|
2018-09-26 21:48:57 +00:00
|
|
|
uchar * recv_packet_buffer[PKTBUFSRX];
|
|
|
|
int recv_packet_length[PKTBUFSRX];
|
|
|
|
int recv_packets;
|
2018-09-26 21:48:56 +00:00
|
|
|
sandbox_eth_tx_hand_f *tx_handler;
|
2018-09-26 21:48:59 +00:00
|
|
|
void *priv;
|
2018-09-26 21:48:56 +00:00
|
|
|
};
|
|
|
|
|
2018-09-26 21:48:55 +00:00
|
|
|
/*
|
|
|
|
* Set packet handler
|
|
|
|
*
|
|
|
|
* handler - The func ptr to call on send. If NULL, set to default handler
|
|
|
|
*/
|
|
|
|
void sandbox_eth_set_tx_handler(int index, sandbox_eth_tx_hand_f *handler);
|
|
|
|
|
2018-09-26 21:48:59 +00:00
|
|
|
/*
|
|
|
|
* Set priv ptr
|
|
|
|
*
|
|
|
|
* priv - priv void ptr to store in the device
|
|
|
|
*/
|
|
|
|
void sandbox_eth_set_priv(int index, void *priv);
|
|
|
|
|
2015-03-22 22:09:19 +00:00
|
|
|
#endif /* __ETH_H */
|