mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-30 11:01:33 +00:00
sandbox: eth: Add ability to disable ping reply in sandbox eth driver
This is needed to test the netretry functionality (make the command fail on a sandbox eth device). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
7d104eab7d
commit
2eede1f363
2 changed files with 32 additions and 0 deletions
15
arch/sandbox/include/asm/eth.h
Normal file
15
arch/sandbox/include/asm/eth.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 National Instruments
|
||||||
|
*
|
||||||
|
* (C) Copyright 2015
|
||||||
|
* Joe Hershberger <joe.hershberger@ni.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ETH_H
|
||||||
|
#define __ETH_H
|
||||||
|
|
||||||
|
void sandbox_eth_disable_response(int index, bool disable);
|
||||||
|
|
||||||
|
#endif /* __ETH_H */
|
|
@ -29,6 +29,19 @@ struct eth_sandbox_priv {
|
||||||
int recv_packet_length;
|
int recv_packet_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool disabled[8] = {false};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sandbox_eth_disable_response()
|
||||||
|
*
|
||||||
|
* index - The alias index (also DM seq number)
|
||||||
|
* disable - If non-zero, ignore sent packets and don't send mock response
|
||||||
|
*/
|
||||||
|
void sandbox_eth_disable_response(int index, bool disable)
|
||||||
|
{
|
||||||
|
disabled[index] = disable;
|
||||||
|
}
|
||||||
|
|
||||||
static int sb_eth_start(struct udevice *dev)
|
static int sb_eth_start(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct eth_sandbox_priv *priv = dev_get_priv(dev);
|
struct eth_sandbox_priv *priv = dev_get_priv(dev);
|
||||||
|
@ -48,6 +61,10 @@ static int sb_eth_send(struct udevice *dev, void *packet, int length)
|
||||||
|
|
||||||
debug("eth_sandbox: Send packet %d\n", length);
|
debug("eth_sandbox: Send packet %d\n", length);
|
||||||
|
|
||||||
|
if (dev->seq >= 0 && dev->seq < ARRAY_SIZE(disabled) &&
|
||||||
|
disabled[dev->seq])
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (ntohs(eth->et_protlen) == PROT_ARP) {
|
if (ntohs(eth->et_protlen) == PROT_ARP) {
|
||||||
struct arp_hdr *arp = packet + ETHER_HDR_SIZE;
|
struct arp_hdr *arp = packet + ETHER_HDR_SIZE;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue