Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lwip echoserver #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions apps/lwipserver2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ includeGlobalComponents()
find_package(projects_libs REQUIRED)

set(CAmkESCPP ON CACHE BOOL "" FORCE)
if("${KernelArch}" STREQUAL "x86")
if(KernelArchX86)
set(cpp_define -DKernelArchX86)
elseif("${KernelArch}" STREQUAL "arm")
elseif(KernelArchARM)
set(cpp_define -DKernelArchArm)
endif()
Copy link
Member

@axel-h axel-h Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's give it a clear error message here for anything else and avoid potentially undefined default behavior

else()
    message(FATAL_ERROR "Unsupported architecture: '${KernelArch}'.")
endif()


include(${LWIP_HELPERS})
AddLWIPConfiguration(${CMAKE_CURRENT_LIST_DIR}/lwip_include)

set(libs sel4utils sel4vka sel4allocman sel4vspace sel4simple
sel4platsupport lwip)
set(libs sel4utils sel4vka sel4allocman sel4vspace sel4simple sel4platsupport lwip)

set(sources src/tcp_echo_socket.c src/udp_echo_socket.c src/utilization_socket.c)

Expand All @@ -35,7 +34,7 @@ DeclareCAmkESComponent(
LIBS
${libs}
LD_FLAGS
-Wl,--section-start=.note.gnu.build-id=0x400920
-Wl,--section-start=.note.gnu.build-id=0x400920 #Ensure reproducible build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 0x400920 have an meaning actually or could this be simply "1" also?

)

CAmkESAddCPPInclude("${CMAKE_CURRENT_LIST_DIR}/include/")
Expand Down
2 changes: 1 addition & 1 deletion apps/lwipserver2/include/echo/tuning_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define TX_BUFS 510
#define RX_BUFS 510

/* Size used for ethernet buffers */
/* Size used for ethernet buffers. This is the next 2^n for the 1500 byte ethernet MTU */
#define BUF_SIZE 2048

/* Maximum connected TCP clients */
Expand Down
5 changes: 2 additions & 3 deletions apps/lwipserver2/lwipserver2_x86_64.camkes
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import <SerialServer/SerialServer.camkes>;
#include <echo/tuning_params.h>

component LWIPServer {
include "lwipserver.h";
single_threaded_component()
lwip_ethernet_async_client_interfaces(eth0)
lwip_base_interfaces(lwip_base)
Expand All @@ -39,7 +38,7 @@ component HWEthDriver82574DF {
component Ethdriver82574DF {
single_threaded_component()
dynamic_untyped_allocators_interfaces(init_dynamic)
x86_iospace_dma_interfaces(init_iospaces, "0x12:0x0:0x19:0")
x86_iospace_dma_interfaces(init_iospaces, "0xc:0x02:0:0")
lwip_ethernet_async_server_interfaces(eth0)
SerialServer_putchar_printf_client(putchar)
/*
Expand All @@ -51,7 +50,7 @@ component Ethdriver82574DF {
dataport Buf(0x20000) EthDriver;

/* MMIO and IRQ default values */
attribute int mmio_paddr = 0xf7f00000;
attribute int mmio_paddr = 0xf7cc0000;
attribute int mmio_size = 0x20000;
attribute string irq_irq_type = "pci";
attribute int irq_irq_ioapic = 0;
Expand Down
4 changes: 2 additions & 2 deletions apps/lwipserver2/src/tcp_echo_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void pop_pbuf_from_chain(int client_id)

static err_t lwip_sent_callback(void *arg, struct tcp_pcb *pcb, u16_t len)
{
int client_id = (int) (uintptr_t) arg;
int client_id = (int)(uintptr_t) arg;
u16_t can_send = MIN(tcp_sndbuf(pcb), 0x1000);

if (tcp_clients[client_id].pbufs) {
Expand Down Expand Up @@ -120,7 +120,7 @@ static int add_pbuf_to_chain(int client_id, struct pbuf *p, u16_t packet_pointer

static err_t lwip_tcp_recv_callback(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
int client_id = (int) (uintptr_t) arg;
int client_id = (int)(uintptr_t) arg;
err_t error = ERR_OK;
if (p == NULL) {
printf("Connection closed on a TCP socket\n");
Expand Down
2 changes: 1 addition & 1 deletion apps/lwipserver2/src/udp_echo_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static char udp_data_packet[0x1000] ALIGN(0x1000);
static struct udp_pcb *udp_socket;

static void lwip_udp_recv_callback(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{
{
err_t error = udp_sendto(pcb, p, addr, port);
ZF_LOGF_IF(error, "Failed to send UDP packet through socket");
pbuf_free(p);
Expand Down
11 changes: 2 additions & 9 deletions apps/lwipserver2/x86_64_eth_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@

int ethif_init(struct eth_driver *eth_driver, ps_io_ops_t *io_ops)
{
ps_irq_t irq_info = (ps_irq_t) {
.type = PS_IOAPIC, .ioapic = { .ioapic = 0, .pin = 20,
.level = 1, .polarity = 1,
.vector = 20
}
};

ethif_intel_config_t *eth_config = calloc(1, sizeof(ethif_intel_config_t) + sizeof(ps_irq_t));
*eth_config = (ethif_intel_config_t) {
/* Ethdriver component dataport */
Expand All @@ -28,9 +21,9 @@ int ethif_init(struct eth_driver *eth_driver, ps_io_ops_t *io_ops)
};

eth_config->irq_info[0] = (ps_irq_t) {
.type = PS_IOAPIC, .ioapic = { .ioapic = 0, .pin = 20,
.type = PS_IOAPIC, .ioapic = { .ioapic = 0, .pin = 16,
.level = 1, .polarity = 1,
.vector = 20
.vector = 16
}
};

Expand Down