From 4eaaf8cec244e8d2ab9f57e244c7610d8ad7c466 Mon Sep 17 00:00:00 2001 From: alwin-joshy Date: Thu, 24 Oct 2024 12:34:13 +1100 Subject: [PATCH] Fix up after rebase Signed-off-by: alwin-joshy --- drivers/network/virtio/ethernet.c | 1 - drivers/network/virtio/ethernet.h | 13 +++---------- drivers/timer/arm/timer.c | 2 +- examples/echo_server/lwip.c | 29 ++++++++++++++--------------- examples/echo_server/lwip.h | 5 +++-- include/sddf/virtio/virtio.h | 2 ++ include/sys/microkit.h | 18 +++++++++++------- network/components/copy.c | 2 +- network/components/copy.h | 4 +--- network/components/virt_rx.c | 8 ++++---- network/components/virt_rx.h | 25 ++++++++++--------------- network/components/virt_tx.c | 8 ++++---- network/components/virt_tx.h | 24 ++++++++++-------------- 13 files changed, 64 insertions(+), 77 deletions(-) diff --git a/drivers/network/virtio/ethernet.c b/drivers/network/virtio/ethernet.c index bed86c59b..f88347e79 100644 --- a/drivers/network/virtio/ethernet.c +++ b/drivers/network/virtio/ethernet.c @@ -445,7 +445,6 @@ void sddf_init(void) void sddf_notified(uint32_t id) { - if (id == resources.irq_id) { handle_irq(); sddf_irq_ack(resources.irq_id); diff --git a/drivers/network/virtio/ethernet.h b/drivers/network/virtio/ethernet.h index ec7fccb61..040a8bc20 100644 --- a/drivers/network/virtio/ethernet.h +++ b/drivers/network/virtio/ethernet.h @@ -228,9 +228,6 @@ struct resources { struct resources resources; -void sddf_init(void); -void sddf_notified(uint32_t ch); - #ifdef MICROKIT #define IRQ_CH 0 @@ -259,8 +256,8 @@ void init(void) { .rx_active = rx_active, .tx_free = tx_free, .tx_active = tx_active, - .rx_queue_size = NET_RX_QUEUE_SIZE_DRIV, - .tx_queue_size = NET_TX_QUEUE_SIZE_DRIV, + .rx_queue_size = NET_RX_QUEUE_CAPACITY_DRIV, + .tx_queue_size = NET_TX_QUEUE_CAPACITY_DRIV, .irq_id = IRQ_CH, .rx_id = RX_CH, @@ -270,8 +267,4 @@ void init(void) { sddf_init(); } - -#else - -#endif - +#endif /* MICROKIT */ diff --git a/drivers/timer/arm/timer.c b/drivers/timer/arm/timer.c index 52e00a8e3..fe67e9fa3 100644 --- a/drivers/timer/arm/timer.c +++ b/drivers/timer/arm/timer.c @@ -158,7 +158,7 @@ void sddf_init() void sddf_notified(unsigned int ch) { assert(ch == resources.irq_id); - sddf_irq_ack_delayed(ch); + sddf_deferred_irq_ack(ch); generic_timer_set_compare(UINT64_MAX); uint64_t curr_time = freq_cycles_and_hz_to_ns(get_ticks(), timer_freq); diff --git a/examples/echo_server/lwip.c b/examples/echo_server/lwip.c index 949cff27a..8293b5130 100644 --- a/examples/echo_server/lwip.c +++ b/examples/echo_server/lwip.c @@ -275,12 +275,11 @@ static void netif_status_callback(struct netif *netif) void sddf_init(void) { - // serial_cli_queue_init_sys(microkit_name, NULL, NULL, NULL, &serial_tx_queue_handle, serial_tx_queue, serial_tx_data); - // serial_putchar_init(SERIAL_TX_CH, &serial_tx_queue_handle); + serial_cli_queue_init_sys(microkit_name, NULL, NULL, NULL, &serial_tx_queue_handle, serial_tx_queue, serial_tx_data); + serial_putchar_init(SERIAL_TX_CH, &serial_tx_queue_handle); net_queue_init(&state.rx_queue, resources.rx_free, resources.rx_active, resources.rx_queue_size); net_queue_init(&state.tx_queue, resources.tx_free, resources.tx_active, resources.tx_queue_size); - net_buffers_init(&state.tx_queue, 0); lwip_init(); @@ -320,22 +319,22 @@ void sddf_init(void) if (notify_rx && net_require_signal_free(&state.rx_queue)) { net_cancel_signal_free(&state.rx_queue); notify_rx = false; - unsigned int curr_delayed = sddf_notify_delayed_curr(); + unsigned int curr_delayed = sddf_deferred_notify_curr(); if (curr_delayed == -1) { - sddf_notify_delayed(resources.rx_id); + sddf_deferred_notify(resources.rx_id); } else if (curr_delayed != resources.rx_id) { - sddf_notify(resources.rx_id); + sddf_deferred_notify(resources.rx_id); } } if (notify_tx && net_require_signal_active(&state.tx_queue)) { net_cancel_signal_active(&state.tx_queue); notify_tx = false; - unsigned int curr_delayed = sddf_notify_delayed_curr(); + unsigned int curr_delayed = sddf_deferred_notify_curr(); if (curr_delayed == -1) { - sddf_notify_delayed(resources.tx_id); + sddf_deferred_notify(resources.tx_id); } else if (curr_delayed != resources.tx_id) { - sddf_notify(resources.tx_id); + sddf_deferred_notify(resources.tx_id); } } } @@ -355,22 +354,22 @@ void sddf_notified(unsigned int id) if (notify_rx && net_require_signal_free(&state.rx_queue)) { net_cancel_signal_free(&state.rx_queue); notify_rx = false; - unsigned int curr_delayed = sddf_notify_delayed_curr(); + unsigned int curr_delayed = sddf_deferred_notify_curr(); if (curr_delayed == -1) { - sddf_notify_delayed(resources.rx_id); + sddf_deferred_notify(resources.rx_id); } else if (curr_delayed != resources.rx_id) { - sddf_notify(resources.rx_id); + sddf_deferred_notify(resources.rx_id); } } if (notify_tx && net_require_signal_active(&state.tx_queue)) { net_cancel_signal_active(&state.tx_queue); notify_tx = false; - unsigned int curr_delayed = sddf_notify_delayed_curr(); + unsigned int curr_delayed = sddf_deferred_notify_curr(); if (curr_delayed == -1) { - sddf_notify_delayed(resources.tx_id); + sddf_deferred_notify(resources.tx_id); } else if (curr_delayed != resources.tx_id) { - sddf_notify(resources.tx_id); + sddf_deferred_notify(resources.tx_id); } } } diff --git a/examples/echo_server/lwip.h b/examples/echo_server/lwip.h index d43d95638..8edf77a00 100644 --- a/examples/echo_server/lwip.h +++ b/examples/echo_server/lwip.h @@ -45,9 +45,10 @@ uintptr_t rx_buffer_data_region; uintptr_t tx_buffer_data_region; void init() { + size_t rx_queue_size, tx_queue_size; - net_cli_queue_info(microkit_name, &rx_queue_size, &tx_queue_size); - uint64_t mac_addr = net_cli_mac_addr_info(microkit_name); + net_cli_queue_capacity(microkit_name, &rx_queue_size, &tx_queue_size); + uint64_t mac_addr = net_cli_mac_addr(microkit_name); resources = (struct resources) { .rx_free = rx_free, diff --git a/include/sddf/virtio/virtio.h b/include/sddf/virtio/virtio.h index 4fd8b5456..5e5aef30c 100644 --- a/include/sddf/virtio/virtio.h +++ b/include/sddf/virtio/virtio.h @@ -3,6 +3,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#pragma once + #include #include #include diff --git a/include/sys/microkit.h b/include/sys/microkit.h index a868a2785..0f618a027 100644 --- a/include/sys/microkit.h +++ b/include/sys/microkit.h @@ -2,6 +2,10 @@ #include #include +#include + +void sddf_init(void); +void sddf_notified(uint32_t ch); void notified(microkit_channel ch) { sddf_notified(ch); @@ -11,24 +15,24 @@ static inline void sddf_irq_ack(microkit_channel ch) { microkit_irq_ack(ch); } -void sddf_irq_ack_delayed(microkit_channel ch) { - sddf_irq_ack_delayed(ch); +void sddf_deferred_irq_ack(microkit_channel ch) { + microkit_deferred_irq_ack(ch); } static inline void sddf_notify(microkit_channel ch) { microkit_notify(ch); } -inline void sddf_notify_delayed(microkit_channel ch) { - microkit_notify_delayed(ch); +inline void sddf_deferred_notify(microkit_channel ch) { + microkit_deferred_notify(ch); } -inline unsigned int sddf_notify_delayed_curr() { - if (!have_signal) { +inline unsigned int sddf_deferred_notify_curr() { + if (!microkit_have_signal) { return -1; } - return signal_cap - BASE_OUTPUT_NOTIFICATION_CAP; + return microkit_signal_cap - BASE_OUTPUT_NOTIFICATION_CAP; } inline microkit_msginfo sddf_ppcall(microkit_channel ch, microkit_msginfo msginfo) { diff --git a/network/components/copy.c b/network/components/copy.c index 3a6330a4f..a08291cc4 100644 --- a/network/components/copy.c +++ b/network/components/copy.c @@ -76,7 +76,7 @@ void rx_return(void) if (enqueued && net_require_signal_free(&rx_queue_virt)) { net_cancel_signal_free(&rx_queue_virt); - sddf_notify_delayed(resources.virt_id); + sddf_deferred_notify(resources.virt_id); } } diff --git a/network/components/copy.h b/network/components/copy.h index c4ee1991a..31fb85475 100644 --- a/network/components/copy.h +++ b/network/components/copy.h @@ -44,7 +44,7 @@ uintptr_t cli_buffer_data_region; void init() { size_t cli_queue_size, virt_queue_size; - net_copy_queue_info(microkit_name, &cli_queue_size, &virt_queue_size); + net_copy_queue_capacity(microkit_name, &cli_queue_size, &virt_queue_size); resources = (struct resources) { .virt_free = rx_free_virt, @@ -63,6 +63,4 @@ void init() { sddf_init(); } -#else - #endif /* MICROKIT */ \ No newline at end of file diff --git a/network/components/virt_rx.c b/network/components/virt_rx.c index 986c449e2..159cb31f7 100644 --- a/network/components/virt_rx.c +++ b/network/components/virt_rx.c @@ -175,7 +175,7 @@ void rx_provide(void) if (notify_drv && net_require_signal_free(&state.rx_queue_drv)) { net_cancel_signal_free(&state.rx_queue_drv); - sddf_notify_delayed(resources.driver_id); + sddf_deferred_notify(resources.driver_id); notify_drv = false; } } @@ -190,8 +190,8 @@ void sddf_init(void) { /* Set up client queues */ for (int i = 0; i < NUM_NETWORK_CLIENTS; i++) { - net_set_mac_addr((uint8_t *) &state.mac_addrs[i], resources.clients[i].macs_addr); - net_queue_init(&state.rx_queue_clients[i], queue_info[i].free, queue_info[i].active, queue_info[i].capacity); + net_set_mac_addr((uint8_t *) &state.mac_addrs[i], resources.clients[i].mac_addr); + net_queue_init(&state.rx_queue_clients[i], resources.clients[i].rx_free, resources.clients[i].rx_active, resources.clients[i].queue_capacity); } /* Set up driver queues */ @@ -200,6 +200,6 @@ void sddf_init(void) if (net_require_signal_free(&state.rx_queue_drv)) { net_cancel_signal_free(&state.rx_queue_drv); - sddf_notify_delayed(resources.driver_id); + sddf_deferred_notify(resources.driver_id); } } diff --git a/network/components/virt_rx.h b/network/components/virt_rx.h index 80ca9ba48..54b651972 100644 --- a/network/components/virt_rx.h +++ b/network/components/virt_rx.h @@ -14,7 +14,7 @@ struct client { uint64_t rx_free; uint64_t rx_active; - uint64_t queue_size; + uint64_t queue_capacity; uint8_t client_id; uint64_t mac_addr; }; @@ -22,10 +22,11 @@ struct client { struct resources { uint64_t rx_free_drv; uint64_t rx_active_drv; - uint64_t drv_queue_size; + uint64_t drv_queue_capacity; uint64_t buffer_data_vaddr; uint64_t buffer_data_paddr; uint8_t driver_id; + uint8_t num_network_clients; struct client clients[MAX_CLIENTS]; }; @@ -53,22 +54,21 @@ net_queue_t *rx_active_cli1; uintptr_t buffer_data_vaddr; uintptr_t buffer_data_paddr; -#define MAX_CLIENTS 64 - void init() { - queue_info_t client_queue_info[MAX_CLIENTS]; + net_queue_info_t client_queue_info[MAX_CLIENTS] = {0}; net_virt_queue_info(microkit_name, rx_free_cli0, rx_active_cli0, client_queue_info); - uint64_t mac_addrs[MAX_CLIENTS]; - net_virt_mac_addr_info(microkit_name, mac_addrs); + uint64_t mac_addrs[MAX_CLIENTS] = {0}; + net_virt_mac_addrs(microkit_name, mac_addrs); resources = (struct resources) { .rx_free_drv = rx_free_drv, .rx_active_drv = rx_active_drv, - .drv_queue_size = NET_RX_QUEUE_SIZE_DRIV, + .drv_queue_capacity = NET_RX_QUEUE_CAPACITY_DRIV, .buffer_data_vaddr = buffer_data_vaddr, .buffer_data_paddr = buffer_data_paddr, .driver_id = DRIVER_CH, + .num_network_clients = NUM_NETWORK_CLIENTS, .clients = {}, }; @@ -76,7 +76,7 @@ void init() { resources.clients[i] = (struct client) { .rx_free = client_queue_info[i].free, .rx_active = client_queue_info[i].active, - .queue_size = client_queue_info[i].size, + .queue_capacity = client_queue_info[i].capacity, .client_id = CLIENT_0_CH + i, .mac_addr = mac_addrs[i] }; @@ -85,9 +85,4 @@ void init() { sddf_init(); } -#else - -#define NUM_NETWORK_CLIENTS 1 -#define NET_RX_QUEUE_SIZE_DRIV 512 //@alwin: What to do about this? - -#endif \ No newline at end of file +#endif /* MICROKIT */ \ No newline at end of file diff --git a/network/components/virt_tx.c b/network/components/virt_tx.c index ec4e04915..16b6d2bfa 100644 --- a/network/components/virt_tx.c +++ b/network/components/virt_tx.c @@ -70,7 +70,7 @@ void tx_provide(void) if (enqueued && net_require_signal_active(&state.tx_queue_drv)) { net_cancel_signal_active(&state.tx_queue_drv); - sddf_notify_delayed(resources.drv_id); + sddf_deferred_notify(resources.drv_id); } } @@ -118,10 +118,10 @@ void sddf_notified(unsigned int id) void sddf_init(void) { net_queue_init(&state.tx_queue_drv, (net_queue_t *)resources.tx_free_drv, - (net_queue_t *)resources.tx_active_drv, resources.drv_queue_size); + (net_queue_t *)resources.tx_active_drv, resources.drv_queue_capacity); - for (int i = 0; i < NUM_NETWORK_CLIENTS; i++) { - net_queue_init(&state.tx_queue_clients[i], (net_queue_t *) resources.clients[i].tx_free, (net_queue_t *)resources.clients[i].tx_active, resources.clients[i].queue_size); + for (int i = 0; i < resources.num_network_clients; i++) { + net_queue_init(&state.tx_queue_clients[i], (net_queue_t *) resources.clients[i].tx_free, (net_queue_t *)resources.clients[i].tx_active, resources.clients[i].queue_capacity); state.buffer_region_vaddrs[i] = resources.clients[i].buffer_data_region_vaddr; state.buffer_region_paddrs[i] = resources.clients[i].buffer_data_region_paddr; } diff --git a/network/components/virt_tx.h b/network/components/virt_tx.h index 6704d20d3..0222d774d 100644 --- a/network/components/virt_tx.h +++ b/network/components/virt_tx.h @@ -13,7 +13,7 @@ struct client { uint64_t tx_free; uint64_t tx_active; - uint64_t queue_size; + uint64_t queue_capacity; uint8_t client_id; uint64_t buffer_data_region_vaddr; uint64_t buffer_data_region_paddr; @@ -22,8 +22,9 @@ struct client { struct resources { uint64_t tx_free_drv; uint64_t tx_active_drv; - uint64_t drv_queue_size; + uint64_t drv_queue_capacity; uint8_t drv_id; + uint8_t num_network_clients; struct client clients[MAX_CLIENTS]; }; @@ -50,20 +51,19 @@ uintptr_t buffer_data_region_cli0_paddr; uintptr_t buffer_data_region_cli1_vaddr; uintptr_t buffer_data_region_cli1_paddr; -#define MAX_CLIENTS 64 - void init() { - queue_info_t client_queue_info[MAX_CLIENTS]; + net_queue_info_t client_queue_info[MAX_CLIENTS] = {0}; net_virt_queue_info(microkit_name, tx_free_cli0, tx_active_cli0, client_queue_info); - uintptr_t buffer_region_vaddrs[MAX_CLIENTS]; - net_mem_region_info(microkit_name, buffer_region_vaddrs, buffer_data_region_cli0_vaddr); + uintptr_t buffer_region_vaddrs[MAX_CLIENTS] = {0}; + net_mem_region_vaddr(microkit_name, buffer_region_vaddrs, buffer_data_region_cli0_vaddr); resources = (struct resources) { .tx_free_drv = tx_free_drv, .tx_active_drv = tx_active_drv, - .drv_queue_size = NET_TX_QUEUE_SIZE_DRIV, + .drv_queue_capacity = NET_TX_QUEUE_CAPACITY_DRIV, .drv_id = DRIVER_CH, + .num_network_clients = NUM_NETWORK_CLIENTS, .clients = {}, }; @@ -71,7 +71,7 @@ void init() { resources.clients[i] = (struct client) { .tx_free = client_queue_info[i].free, .tx_active = client_queue_info[i].active, - .queue_size = client_queue_info[i].size, + .queue_capacity = client_queue_info[i].capacity, .buffer_data_region_vaddr = buffer_region_vaddrs[i], .client_id = CLIENT_0_CH + i, }; @@ -82,8 +82,4 @@ void init() { sddf_init(); } -#else -/* @alwin: Actually these should kinda be defined in rust and exported or something */ -#define NUM_NETWORK_CLIENTS 1 - -#endif \ No newline at end of file +#endif /* MICROKIT */ \ No newline at end of file