mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 22:51:37 +00:00
net: Refactor to use NetSendPacket instead of eth_send directly
Use this entry-point consistently across the net/ code Use a static inline function to preserve code size Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
61da3c2af8
commit
adf5d93e44
5 changed files with 10 additions and 15 deletions
|
@ -472,7 +472,10 @@ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */
|
||||||
extern void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */
|
extern void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */
|
||||||
|
|
||||||
/* Transmit "NetTxPacket" */
|
/* Transmit "NetTxPacket" */
|
||||||
extern void NetSendPacket(uchar *, int);
|
static inline void NetSendPacket(uchar *pkt, int len)
|
||||||
|
{
|
||||||
|
(void) eth_send(pkt, len);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transmit UDP packet, performing ARP request if needed
|
* Transmit UDP packet, performing ARP request if needed
|
||||||
|
|
|
@ -88,7 +88,7 @@ void ArpRequest(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
NetWriteIP(&arp->ar_tpa, NetArpWaitReplyIP);
|
NetWriteIP(&arp->ar_tpa, NetArpWaitReplyIP);
|
||||||
(void) eth_send(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE);
|
NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArpTimeoutCheck(void)
|
void ArpTimeoutCheck(void)
|
||||||
|
@ -165,7 +165,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
|
||||||
NetCopyIP(&arp->ar_tpa, &arp->ar_spa);
|
NetCopyIP(&arp->ar_tpa, &arp->ar_spa);
|
||||||
memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN);
|
memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN);
|
||||||
NetCopyIP(&arp->ar_spa, &NetOurIP);
|
NetCopyIP(&arp->ar_spa, &NetOurIP);
|
||||||
(void) eth_send((uchar *)et, eth_hdr_size + ARP_HDR_SIZE);
|
NetSendPacket((uchar *)et, eth_hdr_size + ARP_HDR_SIZE);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ARPOP_REPLY: /* arp reply */
|
case ARPOP_REPLY: /* arp reply */
|
||||||
|
@ -198,7 +198,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
|
||||||
/* modify header, and transmit it */
|
/* modify header, and transmit it */
|
||||||
memcpy(((struct ethernet_hdr *)NetArpWaitTxPacket)->
|
memcpy(((struct ethernet_hdr *)NetArpWaitTxPacket)->
|
||||||
et_dest, NetArpWaitPacketMAC, ARP_HLEN);
|
et_dest, NetArpWaitPacketMAC, ARP_HLEN);
|
||||||
(void) eth_send(NetArpWaitTxPacket,
|
NetSendPacket(NetArpWaitTxPacket,
|
||||||
NetArpWaitTxPacketSize);
|
NetArpWaitTxPacketSize);
|
||||||
|
|
||||||
/* no arp request pending now */
|
/* no arp request pending now */
|
||||||
|
|
|
@ -216,7 +216,7 @@ CDPSendTrigger(void)
|
||||||
chksum = 0xFFFF;
|
chksum = 0xFFFF;
|
||||||
*cp = htons(chksum);
|
*cp = htons(chksum);
|
||||||
|
|
||||||
(void) eth_send(NetTxPacket, (uchar *)s - NetTxPacket);
|
NetSendPacket(NetTxPacket, (uchar *)s - NetTxPacket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -584,13 +584,6 @@ NetSetTimeout(ulong iv, thand_f *f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
NetSendPacket(uchar *pkt, int len)
|
|
||||||
{
|
|
||||||
(void) eth_send(pkt, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
|
int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
|
||||||
int payload_len)
|
int payload_len)
|
||||||
{
|
{
|
||||||
|
@ -646,7 +639,7 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
|
||||||
return 1; /* waiting */
|
return 1; /* waiting */
|
||||||
} else {
|
} else {
|
||||||
debug("sending UDP to %pI4/%pM\n", &dest, ether);
|
debug("sending UDP to %pI4/%pM\n", &dest, ether);
|
||||||
eth_send(NetTxPacket, pkt_hdr_size + payload_len);
|
NetSendPacket(NetTxPacket, pkt_hdr_size + payload_len);
|
||||||
return 0; /* transmitted */
|
return 0; /* transmitted */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,7 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
|
||||||
icmph->checksum = 0;
|
icmph->checksum = 0;
|
||||||
icmph->checksum = ~NetCksum((uchar *)icmph,
|
icmph->checksum = ~NetCksum((uchar *)icmph,
|
||||||
(len - IP_HDR_SIZE) >> 1);
|
(len - IP_HDR_SIZE) >> 1);
|
||||||
(void) eth_send((uchar *)et,
|
NetSendPacket((uchar *)et, ETHER_HDR_SIZE + len);
|
||||||
ETHER_HDR_SIZE + len);
|
|
||||||
return;
|
return;
|
||||||
/* default:
|
/* default:
|
||||||
return;*/
|
return;*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue