Skip to content

Commit

Permalink
network: style
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan-Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Jan 8, 2025
1 parent 395ca02 commit 79ae25e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
9 changes: 5 additions & 4 deletions network/components/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include <sddf/util/util.h>
#include <sddf/util/printf.h>

__attribute__((__section__(".net_copy_config")))
net_copy_config_t config;
__attribute__((__section__(".net_copy_config"))) net_copy_config_t config;

net_queue_handle_t rx_queue_virt;
net_queue_handle_t rx_queue_cli;
Expand Down Expand Up @@ -91,8 +90,10 @@ void notified(microkit_channel ch)
void init(void)
{
/* Set up the queues */
net_queue_init(&rx_queue_cli, config.client.free_queue.vaddr, config.client.active_queue.vaddr, config.client.num_buffers);
net_queue_init(&rx_queue_virt, config.virt_rx.free_queue.vaddr, config.virt_rx.active_queue.vaddr, config.virt_rx.num_buffers);
net_queue_init(&rx_queue_cli, config.client.free_queue.vaddr, config.client.active_queue.vaddr,
config.client.num_buffers);
net_queue_init(&rx_queue_virt, config.virt_rx.free_queue.vaddr, config.virt_rx.active_queue.vaddr,
config.virt_rx.num_buffers);

net_buffers_init(&rx_queue_cli, 0);
}
11 changes: 6 additions & 5 deletions network/components/virt_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* any particular client. */
#define BROADCAST_ID (-2)

__attribute__((__section__(".net_virt_rx_config")))
net_virt_rx_config_t config;
__attribute__((__section__(".net_virt_rx_config"))) net_virt_rx_config_t config;

/* In order to handle broadcast packets where the same buffer is given to multiple clients
* we keep track of a reference count of each buffer and only hand it back to the driver once
Expand Down Expand Up @@ -68,7 +67,7 @@ int get_mac_addr_match(struct ethernet_header *buffer)
void rx_return(void)
{
bool reprocess = true;
bool notify_clients[SDDF_NET_MAX_CLIENTS] = {false};
bool notify_clients[SDDF_NET_MAX_CLIENTS] = { false };
while (reprocess) {
while (!net_queue_empty_active(&state.rx_queue_drv)) {
net_buff_desc_t buffer;
Expand Down Expand Up @@ -195,11 +194,13 @@ void init(void)

/* Set up client queues */
for (int i = 0; i < config.num_clients; i++) {
net_queue_init(&state.rx_queue_clients[i], config.clients[i].conn.free_queue.vaddr, config.clients[i].conn.active_queue.vaddr, config.clients[i].conn.num_buffers);
net_queue_init(&state.rx_queue_clients[i], config.clients[i].conn.free_queue.vaddr,
config.clients[i].conn.active_queue.vaddr, config.clients[i].conn.num_buffers);
}

/* Set up driver queues */
net_queue_init(&state.rx_queue_drv, config.driver.free_queue.vaddr, config.driver.active_queue.vaddr, config.driver.num_buffers);
net_queue_init(&state.rx_queue_drv, config.driver.free_queue.vaddr, config.driver.active_queue.vaddr,
config.driver.num_buffers);
net_buffers_init(&state.rx_queue_drv, config.data.io_addr);

if (net_require_signal_free(&state.rx_queue_drv)) {
Expand Down
14 changes: 8 additions & 6 deletions network/components/virt_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include <sddf/util/util.h>
#include <sddf/util/printf.h>

__attribute__((__section__(".net_virt_tx_config")))
net_virt_tx_config_t config;
__attribute__((__section__(".net_virt_tx_config"))) net_virt_tx_config_t config;

typedef struct state {
net_queue_handle_t tx_queue_drv;
Expand All @@ -24,7 +23,8 @@ int extract_offset(uintptr_t *phys)
{
for (int client = 0; client < config.num_clients; client++) {
if (*phys >= config.clients[client].data.io_addr
&& *phys < config.clients[client].data.io_addr + state.tx_queue_clients[client].capacity * NET_BUFFER_SIZE) {
&& *phys
< config.clients[client].data.io_addr + state.tx_queue_clients[client].capacity * NET_BUFFER_SIZE) {
*phys = *phys - config.clients[client].data.io_addr;
return client;
}
Expand Down Expand Up @@ -80,7 +80,7 @@ void tx_provide(void)
void tx_return(void)
{
bool reprocess = true;
bool notify_clients[SDDF_NET_MAX_CLIENTS] = {false};
bool notify_clients[SDDF_NET_MAX_CLIENTS] = { false };
while (reprocess) {
while (!net_queue_empty_free(&state.tx_queue_drv)) {
net_buff_desc_t buffer;
Expand Down Expand Up @@ -121,10 +121,12 @@ void notified(microkit_channel ch)
void init(void)
{
/* Set up driver queues */
net_queue_init(&state.tx_queue_drv, config.driver.free_queue.vaddr, config.driver.active_queue.vaddr, config.driver.num_buffers);
net_queue_init(&state.tx_queue_drv, config.driver.free_queue.vaddr, config.driver.active_queue.vaddr,
config.driver.num_buffers);

for (int i = 0; i < config.num_clients; i++) {
net_queue_init(&state.tx_queue_clients[i], config.clients[i].conn.free_queue.vaddr, config.clients[i].conn.active_queue.vaddr, config.clients[i].conn.num_buffers);
net_queue_init(&state.tx_queue_clients[i], config.clients[i].conn.free_queue.vaddr,
config.clients[i].conn.active_queue.vaddr, config.clients[i].conn.num_buffers);
}

tx_provide();
Expand Down

0 comments on commit 79ae25e

Please sign in to comment.