mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
net: Fix net buffer initialization
A new non-static function net_init() will initialize buffers and read from the environment. Only update from the env on each entry to NetLoop(). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
cb1c991120
commit
46c495d524
2 changed files with 32 additions and 14 deletions
|
@ -436,6 +436,7 @@ extern IPaddr_t Mcast_addr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize the network adapter */
|
/* Initialize the network adapter */
|
||||||
|
extern void net_init(void);
|
||||||
extern int NetLoop(enum proto_t);
|
extern int NetLoop(enum proto_t);
|
||||||
|
|
||||||
/* Shutdown adapters and cleanup */
|
/* Shutdown adapters and cleanup */
|
||||||
|
|
45
net/net.c
45
net/net.c
|
@ -265,6 +265,31 @@ static void net_cleanup_loop(void)
|
||||||
net_clear_handlers();
|
net_clear_handlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void net_init(void)
|
||||||
|
{
|
||||||
|
static int first_call = 1;
|
||||||
|
|
||||||
|
if (first_call) {
|
||||||
|
/*
|
||||||
|
* Setup packet buffers, aligned correctly.
|
||||||
|
*/
|
||||||
|
int i;
|
||||||
|
|
||||||
|
NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
|
||||||
|
NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
|
||||||
|
for (i = 0; i < PKTBUFSRX; i++)
|
||||||
|
NetRxPackets[i] = NetTxPacket + (i + 1) * PKTSIZE_ALIGN;
|
||||||
|
|
||||||
|
ArpInit();
|
||||||
|
net_clear_handlers();
|
||||||
|
|
||||||
|
/* Only need to setup buffer pointers once. */
|
||||||
|
first_call = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetInitLoop();
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/*
|
/*
|
||||||
* Main network processing loop.
|
* Main network processing loop.
|
||||||
|
@ -272,28 +297,15 @@ static void net_cleanup_loop(void)
|
||||||
|
|
||||||
int NetLoop(enum proto_t protocol)
|
int NetLoop(enum proto_t protocol)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
bd_t *bd = gd->bd;
|
bd_t *bd = gd->bd;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
NetRestarted = 0;
|
NetRestarted = 0;
|
||||||
NetDevExists = 0;
|
NetDevExists = 0;
|
||||||
|
|
||||||
NetTxPacket = NULL;
|
|
||||||
NetTryCount = 1;
|
NetTryCount = 1;
|
||||||
|
|
||||||
ArpInit();
|
|
||||||
net_clear_handlers();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Setup packet buffers, aligned correctly.
|
|
||||||
*/
|
|
||||||
NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
|
|
||||||
NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
|
|
||||||
for (i = 0; i < PKTBUFSRX; i++)
|
|
||||||
NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
|
|
||||||
|
|
||||||
bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start");
|
bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start");
|
||||||
|
net_init();
|
||||||
eth_halt();
|
eth_halt();
|
||||||
eth_set_current();
|
eth_set_current();
|
||||||
if (eth_init(bd) < 0) {
|
if (eth_init(bd) < 0) {
|
||||||
|
@ -624,6 +636,11 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
|
||||||
int eth_hdr_size;
|
int eth_hdr_size;
|
||||||
int pkt_hdr_size;
|
int pkt_hdr_size;
|
||||||
|
|
||||||
|
/* make sure the NetTxPacket is initialized (NetInit() was called) */
|
||||||
|
assert(NetTxPacket != NULL);
|
||||||
|
if (NetTxPacket == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* convert to new style broadcast */
|
/* convert to new style broadcast */
|
||||||
if (dest == 0)
|
if (dest == 0)
|
||||||
dest = 0xFFFFFFFF;
|
dest = 0xFFFFFFFF;
|
||||||
|
|
Loading…
Add table
Reference in a new issue