Skip to content

Commit

Permalink
Fix up after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: alwin-joshy <[email protected]>
  • Loading branch information
alwin-joshy committed Oct 24, 2024
1 parent c01b0b6 commit 4eaaf8c
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 77 deletions.
1 change: 0 additions & 1 deletion drivers/network/virtio/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 3 additions & 10 deletions drivers/network/virtio/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -270,8 +267,4 @@ void init(void) {
sddf_init();
}


#else

#endif

#endif /* MICROKIT */
2 changes: 1 addition & 1 deletion drivers/timer/arm/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 14 additions & 15 deletions examples/echo_server/lwip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}
}
5 changes: 3 additions & 2 deletions examples/echo_server/lwip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions include/sddf/virtio/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <stdint.h>
#include <stdbool.h>
#include <sddf/util/printf.h>
Expand Down
18 changes: 11 additions & 7 deletions include/sys/microkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include <microkit.h>
#include <sel4/sel4.h>
#include <stdint.h>

void sddf_init(void);
void sddf_notified(uint32_t ch);

void notified(microkit_channel ch) {
sddf_notified(ch);
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion network/components/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 1 addition & 3 deletions network/components/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -63,6 +63,4 @@ void init() {
sddf_init();
}

#else

#endif /* MICROKIT */
8 changes: 4 additions & 4 deletions network/components/virt_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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 */
Expand All @@ -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);
}
}
25 changes: 10 additions & 15 deletions network/components/virt_rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
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;
};

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];
};

Expand Down Expand Up @@ -53,30 +54,29 @@ 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 = {},
};

for (int i = 0; i < NUM_NETWORK_CLIENTS; i++) {
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]
};
Expand All @@ -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
#endif /* MICROKIT */
8 changes: 4 additions & 4 deletions network/components/virt_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit 4eaaf8c

Please sign in to comment.