summaryrefslogtreecommitdiffstats
path: root/net/net.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-05-23 07:59:24 +0000
committerJoe Hershberger <joe.hershberger@ni.com>2012-05-23 17:53:07 -0500
commite94070c443bdc9c0231abeca920d9f9362701aec (patch)
tree070a846a4e5ec79753f6267ada3ac09c31ed1320 /net/net.c
parentd7310c7e63ca9ffd42527dc9735cb505cbe908b7 (diff)
downloadblackbird-obmc-uboot-e94070c443bdc9c0231abeca920d9f9362701aec.tar.gz
blackbird-obmc-uboot-e94070c443bdc9c0231abeca920d9f9362701aec.zip
net: Don't copy every packet that waits for an ARP
Use the NetArpTxPacket for the ARP packet, not to hold what used to be in NetTxPacket. This saves a copy and makes the code easier to understand. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'net/net.c')
-rw-r--r--net/net.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/net/net.c b/net/net.c
index 4b4c0f1e5f..aa1ff48892 100644
--- a/net/net.c
+++ b/net/net.c
@@ -442,6 +442,9 @@ restart:
* Abort if ctrl-c was pressed.
*/
if (ctrlc()) {
+ /* cancel any ARP that may not have completed */
+ NetArpWaitPacketIP = 0;
+
net_cleanup_loop();
eth_halt();
puts("\nAbort\n");
@@ -632,7 +635,6 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
int payload_len)
{
uchar *pkt;
- int need_arp = 0;
int eth_hdr_size;
int pkt_hdr_size;
@@ -649,35 +651,21 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
if (dest == 0xFFFFFFFF)
ether = NetBcastAddr;
- /*
- * if MAC address was not discovered yet, save the packet and do
- * an ARP request
- */
- if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
- need_arp = 1;
- pkt = NetArpWaitTxPacket;
- } else
- pkt = (uchar *)NetTxPacket;
+ pkt = (uchar *)NetTxPacket;
eth_hdr_size = NetSetEther(pkt, ether, PROT_IP);
pkt += eth_hdr_size;
net_set_udp_header(pkt, dest, dport, sport, payload_len);
pkt_hdr_size = eth_hdr_size + IP_UDP_HDR_SIZE;
- if (need_arp) {
+ /* if MAC address was not discovered yet, do an ARP request */
+ if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
debug("sending ARP for %pI4\n", &dest);
/* save the ip and eth addr for the packet to send after arp */
NetArpWaitPacketIP = dest;
NetArpWaitPacketMAC = ether;
- /*
- * Copy the packet data from the NetTxPacket into the
- * NetArpWaitTxPacket to send after arp
- */
- memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket +
- pkt_hdr_size, payload_len);
-
/* size of the waiting packet */
NetArpWaitTxPacketSize = pkt_hdr_size + payload_len;
OpenPOWER on IntegriCloud