All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Hershberger <joe.hershberger@ni.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 06/10] net: Add an accessor to know if waiting for ARP
Date: Wed, 26 Sep 2018 16:48:58 -0500	[thread overview]
Message-ID: <20180926214902.38803-7-joe.hershberger@ni.com> (raw)
In-Reply-To: <20180926214902.38803-1-joe.hershberger@ni.com>

This single-sources the state of the ARP.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

---

Changes in v2:
- return bool instead of int

 include/net.h |  1 +
 net/arp.c     | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/net.h b/include/net.h
index 2b2deb5aae..259c4a7ed4 100644
--- a/include/net.h
+++ b/include/net.h
@@ -635,6 +635,7 @@ rxhand_f *net_get_udp_handler(void);	/* Get UDP RX packet handler */
 void net_set_udp_handler(rxhand_f *);	/* Set UDP RX packet handler */
 rxhand_f *net_get_arp_handler(void);	/* Get ARP RX packet handler */
 void net_set_arp_handler(rxhand_f *);	/* Set ARP RX packet handler */
+bool arp_is_waiting(void);		/* Waiting for ARP reply? */
 void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */
 void net_set_timeout_handler(ulong, thand_f *);/* Set timeout handler */
 
diff --git a/net/arp.c b/net/arp.c
index b8a71684cd..ea685d9ac6 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -100,7 +100,7 @@ int arp_timeout_check(void)
 {
 	ulong t;
 
-	if (!net_arp_wait_packet_ip.s_addr)
+	if (!arp_is_waiting())
 		return 0;
 
 	t = get_timer(0);
@@ -187,8 +187,8 @@ void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
 		return;
 
 	case ARPOP_REPLY:		/* arp reply */
-		/* are we waiting for a reply */
-		if (!net_arp_wait_packet_ip.s_addr)
+		/* are we waiting for a reply? */
+		if (!arp_is_waiting())
 			break;
 
 #ifdef CONFIG_KEEP_SERVERADDR
@@ -233,3 +233,8 @@ void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
 		return;
 	}
 }
+
+bool arp_is_waiting(void)
+{
+	return !!net_arp_wait_packet_ip.s_addr;
+}
-- 
2.11.0

  parent reply	other threads:[~2018-09-26 21:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 21:48 [U-Boot] [PATCH v2 00/10] net: Fix packet corruption issue when handling asynch replies Joe Hershberger
2018-09-26 21:48 ` [U-Boot] [PATCH v2 01/10] net: sandbox: Move disabled flag into priv struct Joe Hershberger
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:48 ` [U-Boot] [PATCH v2 02/10] net: sandbox: Refactor sandbox send function Joe Hershberger
2018-09-27  6:38   ` Bin Meng
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:48 ` [U-Boot] [PATCH v2 03/10] net: sandbox: Make the fake eth driver response configurable Joe Hershberger
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:48 ` [U-Boot] [PATCH v2 04/10] net: sandbox: Share the priv structure with tests Joe Hershberger
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:48 ` [U-Boot] [PATCH v2 05/10] net: sandbox: Allow fake eth to handle more than 1 packet response Joe Hershberger
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:48 ` Joe Hershberger [this message]
2018-09-27  6:38   ` [U-Boot] [PATCH v2 06/10] net: Add an accessor to know if waiting for ARP Bin Meng
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:48 ` [U-Boot] [PATCH v2 07/10] net: sandbox: Add a priv ptr for tests to use Joe Hershberger
2018-09-27  6:52   ` Bin Meng
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:49 ` [U-Boot] [PATCH v2 08/10] test: eth: Add a test for ARP requests Joe Hershberger
2018-10-11 19:25   ` [U-Boot] " Joe Hershberger
2018-09-26 21:49 ` [U-Boot] [PATCH v2 09/10] test: eth: Add a test for the target being pinged Joe Hershberger
2018-10-11 19:26   ` [U-Boot] " Joe Hershberger
2018-09-26 21:49 ` [U-Boot] [PATCH v2 10/10] net: Don't overwrite waiting packets with asynchronous replies Joe Hershberger
2018-10-11 19:26   ` [U-Boot] " Joe Hershberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180926214902.38803-7-joe.hershberger@ni.com \
    --to=joe.hershberger@ni.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.