From 60c228c07734a6f3d670c89d2db2e3addd8a73a8 Mon Sep 17 00:00:00 2001 From: Andrew Goodbody Date: Fri, 12 Dec 2025 11:32:24 +0000 Subject: net: move net_state to net-common Move the net_state variable into common code so that it can be used by either the legacy network code or lwIP. This is needed for porting across the NFS support code for use with lwIP. Signed-off-by: Andrew Goodbody Reviewed-by: Jerome Forissier --- include/net-common.h | 17 +++++++++++++++++ include/net-legacy.h | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/net-common.h b/include/net-common.h index f5cff3e7c0c..d7a0f7dff7e 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -13,6 +13,7 @@ #include #define DEBUG_NET_PKT_TRACE 0 /* Trace all packet data */ +#define DEBUG_INT_STATE 0 /* Internal network state changes */ /* * The number of receive packet buffers, and the required packet buffer @@ -114,6 +115,22 @@ struct ip_udp_hdr { #define RINGSZ 4 #define RINGSZ_LOG2 2 +/* Network loop state */ +enum net_loop_state { + NETLOOP_CONTINUE, + NETLOOP_RESTART, + NETLOOP_SUCCESS, + NETLOOP_FAIL +}; + +extern enum net_loop_state net_state; + +static inline void net_set_state(enum net_loop_state state) +{ + debug_cond(DEBUG_INT_STATE, "--- NetState set to %d\n", state); + net_state = state; +} + extern int net_restart_wrap; /* Tried all network devices */ extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ extern const u8 net_bcast_ethaddr[ARP_HLEN]; /* Ethernet broadcast address */ diff --git a/include/net-legacy.h b/include/net-legacy.h index 9564e97d238..0a10121b0cf 100644 --- a/include/net-legacy.h +++ b/include/net-legacy.h @@ -25,7 +25,6 @@ struct udevice; #define DEBUG_LL_STATE 0 /* Link local state machine changes */ #define DEBUG_DEV_PKT 0 /* Packets or info directed to the device */ #define DEBUG_NET_PKT 0 /* Packets on info on the network at large */ -#define DEBUG_INT_STATE 0 /* Internal network state changes */ /* ARP hardware address length */ #define ARP_HLEN 6 @@ -369,22 +368,6 @@ 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 t, thand_f *f);/* Set timeout handler */ -/* Network loop state */ -enum net_loop_state { - NETLOOP_CONTINUE, - NETLOOP_RESTART, - NETLOOP_SUCCESS, - NETLOOP_FAIL -}; - -extern enum net_loop_state net_state; - -static inline void net_set_state(enum net_loop_state state) -{ - debug_cond(DEBUG_INT_STATE, "--- NetState set to %d\n", state); - net_state = state; -} - /* * net_get_async_tx_pkt_buf - Get a packet buffer that is not in use for * sending an asynchronous reply -- cgit v1.2.3 From 3938ae6457193cd3b0abb8b74957a388a6b3e639 Mon Sep 17 00:00:00 2001 From: Andrew Goodbody Date: Fri, 12 Dec 2025 11:32:25 +0000 Subject: net: Move some variables to net-common files Make some variables available to be used by either the legacy network code or lwIP by moving them into the net-common files. This also allowed removing a small number of duplicated variables from the lwIP code. Signed-off-by: Andrew Goodbody Reviewed-by: Jerome Forissier --- include/net-common.h | 12 ++++++++++-- include/net-legacy.h | 5 ----- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/net-common.h b/include/net-common.h index d7a0f7dff7e..f293b21bc0b 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -132,13 +132,21 @@ static inline void net_set_state(enum net_loop_state state) } extern int net_restart_wrap; /* Tried all network devices */ -extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ +extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ extern const u8 net_bcast_ethaddr[ARP_HLEN]; /* Ethernet broadcast address */ -extern char net_boot_file_name[1024];/* Boot File name */ extern struct in_addr net_ip; /* Our IP addr (0 = unknown) */ /* Indicates whether the pxe path prefix / config file was specified in dhcp option */ extern char *pxelinux_configfile; +/* Our IP addr (0 = unknown) */ +extern struct in_addr net_ip; +/* Boot File name */ +extern char net_boot_file_name[1024]; +/* The actual transferred size of the bootfile (in bytes) */ +extern u32 net_boot_file_size; +/* Boot file size in blocks as reported by the DHCP server */ +extern u32 net_boot_file_expected_size_in_blocks; + /** * compute_ip_checksum() - Compute IP checksum * diff --git a/include/net-legacy.h b/include/net-legacy.h index 0a10121b0cf..d489c2480cd 100644 --- a/include/net-legacy.h +++ b/include/net-legacy.h @@ -289,7 +289,6 @@ extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet address */ extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet address */ extern struct in_addr net_server_ip; /* Server IP addr (0 = unknown) */ extern uchar *net_tx_packet; /* THE transmit packet */ -extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ extern uchar *net_rx_packet; /* Current receive packet */ extern int net_rx_packet_len; /* Current rx packet length */ extern const u8 net_null_ethaddr[ARP_HLEN]; @@ -309,10 +308,6 @@ enum proto_t { /* Indicates whether the file name was specified on the command line */ extern bool net_boot_file_name_explicit; -/* The actual transferred size of the bootfile (in bytes) */ -extern u32 net_boot_file_size; -/* Boot file size in blocks as reported by the DHCP server */ -extern u32 net_boot_file_expected_size_in_blocks; #if defined(CONFIG_DNS) extern char *net_dns_resolve; /* The host to resolve */ -- cgit v1.2.3 From 230cf3bc277622081b27e33469f5f1f59fc48180 Mon Sep 17 00:00:00 2001 From: Andrew Goodbody Date: Fri, 12 Dec 2025 11:32:28 +0000 Subject: net: lwip: nfs: Port the NFS code to work with lwIP After the preparatory patches moved most of the NFS code into common files we now add the code to enable NFS support with lwIP. Signed-off-by: Andrew Goodbody Acked-by: Jerome Forissier --- include/net-lwip.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/net-lwip.h b/include/net-lwip.h index c910def5719..20cb0992cce 100644 --- a/include/net-lwip.h +++ b/include/net-lwip.h @@ -51,6 +51,7 @@ int net_lwip_dns_resolve(char *name_or_ip, ip_addr_t *ip); bool wget_validate_uri(char *uri); int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_nfs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); #endif /* __NET_LWIP_H__ */ -- cgit v1.2.3