net: Refactor to use NetSendPacket instead of eth_send directly
authorJoe Hershberger <joe.hershberger@ni.com>
Wed, 23 May 2012 07:59:13 +0000 (07:59 +0000)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 23 May 2012 22:46:20 +0000 (17:46 -0500)
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>
include/net.h
net/arp.c
net/cdp.c
net/net.c
net/ping.c

index 128c5ea465d62e4d29964c3ea6bcb3a8ec4db187..3214830831f78903eb5905c6915ad90b98d7b65b 100644 (file)
@@ -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 */
 
 /* 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
index e58a074512d62d2e6f602fee18d729daab453697..997c2abdb35a901b4fca87022bc055b3b28266ec 100644 (file)
--- a/net/arp.c
+++ b/net/arp.c
@@ -88,7 +88,7 @@ void ArpRequest(void)
        }
 
        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)
@@ -165,7 +165,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
                NetCopyIP(&arp->ar_tpa, &arp->ar_spa);
                memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN);
                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;
 
        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 */
                        memcpy(((struct ethernet_hdr *)NetArpWaitTxPacket)->
                                et_dest, NetArpWaitPacketMAC, ARP_HLEN);
-                       (void) eth_send(NetArpWaitTxPacket,
+                       NetSendPacket(NetArpWaitTxPacket,
                                        NetArpWaitTxPacketSize);
 
                        /* no arp request pending now */
index 9bec441497e51420701b357a4ab73743bd662809..3dab6a1462945ad7bd58c25418b9bb56b88dae62 100644 (file)
--- a/net/cdp.c
+++ b/net/cdp.c
@@ -216,7 +216,7 @@ CDPSendTrigger(void)
                chksum = 0xFFFF;
        *cp = htons(chksum);
 
-       (void) eth_send(NetTxPacket, (uchar *)s - NetTxPacket);
+       NetSendPacket(NetTxPacket, (uchar *)s - NetTxPacket);
        return 0;
 }
 
index b29d372b89ad3d1532205cd58396fc5ebb5d018e..e5fbda3e7f1decab768fef4df5c67baa99c2d48d 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -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 payload_len)
 {
@@ -646,7 +639,7 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,
                return 1;       /* waiting */
        } else {
                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 */
        }
 }
index 0f4d99088e0efd4e3541c8ff10622d0c268e0e45..f0026cc420368b175a78b035e63de1af2734a713 100644 (file)
@@ -112,8 +112,7 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
                icmph->checksum = 0;
                icmph->checksum = ~NetCksum((uchar *)icmph,
                        (len - IP_HDR_SIZE) >> 1);
-               (void) eth_send((uchar *)et,
-                               ETHER_HDR_SIZE + len);
+               NetSendPacket((uchar *)et, ETHER_HDR_SIZE + len);
                return;
 /*     default:
                return;*/