summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2023-03-02 16:56:01 -0600
committerJoel Sherrill <joel@rtems.org>2023-03-08 14:58:33 -0600
commit8dfd35fb0bea3217b6055dbf488996c68b52fcea (patch)
treebea0394d32df03a361bc14c0a00ee27a2c1e9e65
parentlwip/api: Notify about dropped packets (diff)
downloadrtems-lwip-8dfd35fb0bea3217b6055dbf488996c68b52fcea.tar.bz2
rtemslwip: Use interrupt server for ISRs
lwIP requires locking to be available in its device ISRs. This is incompatible with RTEMS ISRs, but could be worked around on single-core systems. This moves lwIP device ISR execution to a task via the interrupt server. All network device driver code should use the interrupt server going forward.
-rw-r--r--defs/common/lwip.json1
-rw-r--r--rtemslwip/beaglebone/netstart.c5
-rw-r--r--rtemslwip/common/netstart_shared.c40
-rw-r--r--rtemslwip/include/netstart.h2
-rw-r--r--rtemslwip/zynqmp/xil_shims.c3
-rw-r--r--rtemslwip/zynqmp_cfc400x/netstart.c2
-rw-r--r--rtemslwip/zynqmp_hardware/netstart.c2
-rw-r--r--rtemslwip/zynqmp_qemu/netstart.c2
-rw-r--r--uLan/ports/os/rtems/arch/sys_arch.c2
9 files changed, 49 insertions, 10 deletions
diff --git a/defs/common/lwip.json b/defs/common/lwip.json
index a637c45..2dd5614 100644
--- a/defs/common/lwip.json
+++ b/defs/common/lwip.json
@@ -9,6 +9,7 @@
"uLan/ports/os/rtems/arch/sys_arch.c",
"rtemslwip/common/syslog.c",
"rtemslwip/common/rtems_lwip_io.c",
+ "rtemslwip/common/netstart_shared.c",
"rtemslwip/common/network_compat.c",
"rtemslwip/bsd_compat/netdb.c",
"rtemslwip/bsd_compat/ifaddrs.c",
diff --git a/rtemslwip/beaglebone/netstart.c b/rtemslwip/beaglebone/netstart.c
index 33384b6..a62e83d 100644
--- a/rtemslwip/beaglebone/netstart.c
+++ b/rtemslwip/beaglebone/netstart.c
@@ -25,9 +25,6 @@
*/
#include <netstart.h>
-#include "soc_AM335x.h"
-#include "beaglebone.h"
-#include <lwip/tcpip.h>
int start_networking(
struct netif *net_interface,
@@ -37,7 +34,7 @@ int start_networking(
unsigned char *mac_ethernet_address
)
{
- tcpip_init( NULL, NULL );
+ start_networking_shared();
return 0;
}
diff --git a/rtemslwip/common/netstart_shared.c b/rtemslwip/common/netstart_shared.c
new file mode 100644
index 0000000..216e5a1
--- /dev/null
+++ b/rtemslwip/common/netstart_shared.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 On-Line Applications Research Corporation (OAR)
+ * Written by Kinsey Moore <kinsey.moore@oarcorp.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <netstart.h>
+#include <lwip/tcpip.h>
+
+rtems_status_code start_networking_shared(void)
+{
+ tcpip_init( NULL, NULL );
+ return rtems_interrupt_server_initialize(
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ NULL
+ );
+}
diff --git a/rtemslwip/include/netstart.h b/rtemslwip/include/netstart.h
index d5c58d4..807183a 100644
--- a/rtemslwip/include/netstart.h
+++ b/rtemslwip/include/netstart.h
@@ -38,4 +38,6 @@ int start_networking(
unsigned char *mac_ethernet_address
);
+rtems_status_code start_networking_shared(void);
+
#endif
diff --git a/rtemslwip/zynqmp/xil_shims.c b/rtemslwip/zynqmp/xil_shims.c
index f0b1b9b..ec9ed12 100644
--- a/rtemslwip/zynqmp/xil_shims.c
+++ b/rtemslwip/zynqmp/xil_shims.c
@@ -67,7 +67,8 @@ BaseType_t xPortInstallInterruptHandler(
void *pvCallBackRef
)
{
- rtems_status_code sc = rtems_interrupt_handler_install(
+ rtems_status_code sc = rtems_interrupt_server_handler_install(
+ RTEMS_INTERRUPT_SERVER_DEFAULT,
ucInterruptID,
"CGEM Handler",
RTEMS_INTERRUPT_UNIQUE,
diff --git a/rtemslwip/zynqmp_cfc400x/netstart.c b/rtemslwip/zynqmp_cfc400x/netstart.c
index d19b36c..237133d 100644
--- a/rtemslwip/zynqmp_cfc400x/netstart.c
+++ b/rtemslwip/zynqmp_cfc400x/netstart.c
@@ -37,7 +37,7 @@ int start_networking(
unsigned char *mac_ethernet_address
)
{
- tcpip_init( NULL, NULL );
+ start_networking_shared();
if ( !xemac_add(
net_interface,
diff --git a/rtemslwip/zynqmp_hardware/netstart.c b/rtemslwip/zynqmp_hardware/netstart.c
index 01e392e..5d97ab2 100644
--- a/rtemslwip/zynqmp_hardware/netstart.c
+++ b/rtemslwip/zynqmp_hardware/netstart.c
@@ -37,7 +37,7 @@ int start_networking(
unsigned char *mac_ethernet_address
)
{
- tcpip_init( NULL, NULL );
+ start_networking_shared();
if ( !xemac_add(
net_interface,
diff --git a/rtemslwip/zynqmp_qemu/netstart.c b/rtemslwip/zynqmp_qemu/netstart.c
index d19b36c..237133d 100644
--- a/rtemslwip/zynqmp_qemu/netstart.c
+++ b/rtemslwip/zynqmp_qemu/netstart.c
@@ -37,7 +37,7 @@ int start_networking(
unsigned char *mac_ethernet_address
)
{
- tcpip_init( NULL, NULL );
+ start_networking_shared();
if ( !xemac_add(
net_interface,
diff --git a/uLan/ports/os/rtems/arch/sys_arch.c b/uLan/ports/os/rtems/arch/sys_arch.c
index 3a454b8..2651c9c 100644
--- a/uLan/ports/os/rtems/arch/sys_arch.c
+++ b/uLan/ports/os/rtems/arch/sys_arch.c
@@ -375,7 +375,6 @@ sys_arch_protect()
sys_prot_t pval;
#if RTEMS_SMP
- pval = _Thread_Dispatch_disable();
rtems_recursive_mutex_lock( &sys_arch_lock );
#else
rtems_interrupt_disable(pval);
@@ -388,7 +387,6 @@ sys_arch_unprotect(sys_prot_t pval)
{
#if RTEMS_SMP
rtems_recursive_mutex_unlock( &sys_arch_lock );
- _Thread_Dispatch_enable(pval);
#else
rtems_interrupt_enable(pval);
#endif