[U-Boot] [PATCH v2 07/18] net: Refactor to use NetSendPacket instead of eth_send directly

Simon Glass sjg at chromium.org
Wed Apr 4 03:06:13 CEST 2012


On Tue, Mar 27, 2012 at 4:42 PM, Joe Hershberger <joe.hershberger at ni.com> wrote:
> 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 at ni.com>
> Cc: Joe Hershberger <joe.hershberger at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Mike Frysinger <vapier at gentoo.org>

Acked-by: Simon Glass <sjg at chromium.org>

> ---
> Changes for v2:
>   - Change NetSendPacket into a static inline
>
>  include/net.h |    5 ++++-
>  net/arp.c     |    6 +++---
>  net/cdp.c     |    2 +-
>  net/net.c     |    9 +--------
>  net/ping.c    |    3 +--
>  5 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/include/net.h b/include/net.h
> index 6eb25ee..f84511c 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -466,7 +466,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 */
>  extern int     NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport,
> diff --git a/net/arp.c b/net/arp.c
> index 6cb3c10..90a6b01 100644
> --- 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 */
> diff --git a/net/cdp.c b/net/cdp.c
> index 5c4b3e8..34c5401 100644
> --- a/net/cdp.c
> +++ b/net/cdp.c
> @@ -215,7 +215,7 @@ CDPSendTrigger(void)
>                chksum = 0xFFFF;
>        *cp = htons(chksum);
>
> -       (void) eth_send(NetTxPacket, (uchar *)s - NetTxPacket);
> +       NetSendPacket(NetTxPacket, (uchar *)s - NetTxPacket);
>        return 0;
>  }
>
> diff --git a/net/net.c b/net/net.c
> index d5e6e54..0d14e2c 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -586,13 +586,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)
> @@ -649,7 +642,7 @@ 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 */
>        }
>  }
> diff --git a/net/ping.c b/net/ping.c
> index eb0f0cc..4896bce 100644
> --- a/net/ping.c
> +++ b/net/ping.c
> @@ -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;*/
> --
> 1.6.0.2
>


More information about the U-Boot mailing list