Convert CONFIG_NET_RETRY_COUNT to Kconfig
This converts the following to Kconfig:
CONFIG_NET_RETRY_COUNT
Cc: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
diff --git a/net/Kconfig b/net/Kconfig
index 683c2ad..2e32b55 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -12,6 +12,13 @@
int "Milliseconds before trying ARP again"
default 5000
+config NET_RETRY_COUNT
+ int "Number of timeouts before giving up"
+ default 5
+ help
+ This variable defines the number of retries for network operations
+ like ARP, RARP, TFTP, or BOOTP before giving up the operation.
+
config PROT_UDP
bool "Enable generic udp framework"
help
diff --git a/net/arp.c b/net/arp.c
index f29b867..37848ad 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -17,12 +17,6 @@
#include "arp.h"
-#ifndef CONFIG_NET_RETRY_COUNT
-# define ARP_TIMEOUT_COUNT 5 /* # of timeouts before giving up */
-#else
-# define ARP_TIMEOUT_COUNT CONFIG_NET_RETRY_COUNT
-#endif
-
struct in_addr net_arp_wait_packet_ip;
static struct in_addr net_arp_wait_reply_ip;
/* MAC address of waiting packet's destination */
@@ -104,7 +98,7 @@
if ((t - arp_wait_timer_start) > CONFIG_ARP_TIMEOUT) {
arp_wait_try++;
- if (arp_wait_try >= ARP_TIMEOUT_COUNT) {
+ if (arp_wait_try >= CONFIG_NET_RETRY_COUNT) {
puts("\nARP Retry count exceeded; starting again\n");
arp_wait_try = 0;
net_set_state(NETLOOP_FAIL);
diff --git a/net/bootp.c b/net/bootp.c
index a896e1e..a544bfc 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -31,7 +31,7 @@
/*
* The timeout for the initial BOOTP/DHCP request used to be described by a
- * counter of fixed-length timeout periods. TIMEOUT_COUNT represents
+ * counter of fixed-length timeout periods. CONFIG_NET_RETRY_COUNT represents
* that counter
*
* Now that the timeout periods are variable (exponential backoff and retry)
@@ -39,12 +39,7 @@
* execute that many retries, and keep sending retry packets until that time
* is reached.
*/
-#ifndef CONFIG_NET_RETRY_COUNT
-# define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
-#else
-# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
-#endif
-#define TIMEOUT_MS ((3 + (TIMEOUT_COUNT * 5)) * 1000)
+#define TIMEOUT_MS ((3 + (CONFIG_NET_RETRY_COUNT * 5)) * 1000)
#define PORT_BOOTPS 67 /* BOOTP server UDP port */
#define PORT_BOOTPC 68 /* BOOTP client UDP port */
diff --git a/net/rarp.c b/net/rarp.c
index a676a42..231b623 100644
--- a/net/rarp.c
+++ b/net/rarp.c
@@ -14,11 +14,6 @@
#include "rarp.h"
#define TIMEOUT 5000UL /* Milliseconds before trying BOOTP again */
-#ifndef CONFIG_NET_RETRY_COUNT
-#define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
-#else
-#define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
-#endif
int rarp_try;
@@ -57,7 +52,7 @@
*/
static void rarp_timeout_handler(void)
{
- if (rarp_try >= TIMEOUT_COUNT) {
+ if (rarp_try >= CONFIG_NET_RETRY_COUNT) {
puts("\nRetry count exceeded; starting again\n");
net_start_again();
} else {
diff --git a/net/tftp.c b/net/tftp.c
index 62a9648..e1e3597 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -27,12 +27,6 @@
#define WELL_KNOWN_PORT 69
/* Millisecs to timeout for lost pkt */
#define TIMEOUT 5000UL
-#ifndef CONFIG_NET_RETRY_COUNT
-/* # of timeouts before giving up */
-# define TIMEOUT_COUNT 10
-#else
-# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT * 2)
-#endif
/* Number of "loading" hashes per line (for checking the image size) */
#define HASHES_PER_LINE 65
@@ -47,7 +41,7 @@
#define TFTP_OACK 6
static ulong timeout_ms = TIMEOUT;
-static int timeout_count_max = TIMEOUT_COUNT;
+static int timeout_count_max = (CONFIG_NET_RETRY_COUNT * 2);
static ulong time_start; /* Record time we started tftp */
/*
@@ -60,7 +54,7 @@
* non-standard timeout behavior when initiating a TFTP transfer.
*/
ulong tftp_timeout_ms = TIMEOUT;
-int tftp_timeout_count_max = TIMEOUT_COUNT;
+int tftp_timeout_count_max = (CONFIG_NET_RETRY_COUNT * 2);
enum {
TFTP_ERR_UNDEFINED = 0,