[U-Boot] [PATCH v2] net: bootp: Add environment variable for timeout period
amessier.tyco at gmail.com
amessier.tyco at gmail.com
Mon Feb 1 23:08:57 CET 2016
From: Alexandre Messier <amessier at tycoint.com>
There is currently one config option (CONFIG_NET_RETRY_COUNT) that
is available to tune the retries of the network stack.
Unfortunately, it is global to all protocols, and the value is
interpreted differently in all of them.
Add a new environment variable that directly sets the retry period for
BOOTP timeouts. If this new value is not set, the period is still derived
from the default number of retries, or from CONFIG_NET_RETRY_COUNT if
defined. When both the new variable is set and CONFIG_NET_RETRY_COUNT
is defined, the variable has precedence.
Signed-off-by: Alexandre Messier <amessier at tycoint.com>
---
Changes since v1:
- Now uses an environment variable instead of a config option. This is to
have a similar approach as TFTP towards how timeouts are controlled.
(e.g. https://patchwork.ozlabs.org/patch/528815/)
- Title was changed, it was previously "net: bootp: Add BOOTP specific
config for timeout value."
- Removed from patch series. v1 was in a series, but now the patch
stands alone.
v1 can be found here:
Patchwork: https://patchwork.ozlabs.org/patch/571776/
Mailing list: http://lists.denx.de/pipermail/u-boot/2016-January/242840.html
README | 6 ++++++
net/bootp.c | 11 ++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/README b/README
index c7c9e0a..567243e 100644
--- a/README
+++ b/README
@@ -5429,6 +5429,12 @@ List of environment variables (most likely not complete):
Ethernet is encapsulated/received over 802.1q
VLAN tagged frames.
+ bootpretryperiod - Period during which BOOTP/DHCP sends retries.
+ Unsigned value, in milliseconds. If not set, the period will
+ be either the default (28000), or a value based on
+ CONFIG_NET_RETRY_COUNT, if defined. This value has
+ precedence over the valu based on CONFIG_NET_RETRY_COUNT.
+
The following image location variables contain the location of images
used in booting. The "Image" column gives the role of the image and is
not an environment variable name. The other columns are environment
diff --git a/net/bootp.c b/net/bootp.c
index f2978a2..aefc808 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -60,6 +60,8 @@ char net_nis_domain[32] = {0,}; /* Our NIS domain */
char net_hostname[32] = {0,}; /* Our hostname */
char net_root_path[64] = {0,}; /* Our bootpath */
+static ulong time_taken_max;
+
#if defined(CONFIG_CMD_DHCP)
static dhcp_state_t dhcp_state = INIT;
static u32 dhcp_leasetime;
@@ -380,7 +382,7 @@ static void bootp_timeout_handler(void)
{
ulong time_taken = get_timer(bootp_start);
- if (time_taken >= TIMEOUT_MS) {
+ if (time_taken >= time_taken_max) {
#ifdef CONFIG_BOOTP_MAY_FAIL
puts("\nRetry time exceeded\n");
net_set_state(NETLOOP_FAIL);
@@ -675,12 +677,19 @@ void bootp_request(void)
u32 bootp_id;
struct in_addr zero_ip;
struct in_addr bcast_ip;
+ char *ep; /* Environment pointer */
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start");
#if defined(CONFIG_CMD_DHCP)
dhcp_state = INIT;
#endif
+ ep = getenv("bootpretryperiod");
+ if (ep != NULL)
+ time_taken_max = simple_strtoul(ep, NULL, 10);
+ else
+ time_taken_max = TIMEOUT_MS;
+
#ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
if (bootp_try == 0)
srand_mac();
--
2.7.0
More information about the U-Boot
mailing list