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

Use capacity/length instead of size in network and serial subsystems #250

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions drivers/network/imx/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ net_queue_handle_t tx_queue;

volatile struct enet_regs *eth;

static inline bool hw_ring_full(hw_ring_t *ring, size_t ring_size)
static inline bool hw_ring_full(hw_ring_t *ring, size_t ring_capacity)
{
return !((ring->tail - ring->head + 1) % ring_size);
return !((ring->tail - ring->head + 1) % ring_capacity);
}

static inline bool hw_ring_empty(hw_ring_t *ring, size_t ring_size)
static inline bool hw_ring_empty(hw_ring_t *ring, size_t ring_capacity)
{
return !((ring->tail - ring->head) % ring_size);
return !((ring->tail - ring->head) % ring_capacity);
}

static void update_ring_slot(hw_ring_t *ring, unsigned int idx, uintptr_t phys,
Expand Down Expand Up @@ -302,8 +302,8 @@ void init(void)
{
eth_setup();

net_queue_init(&rx_queue, rx_free, rx_active, NET_RX_QUEUE_SIZE_DRIV);
net_queue_init(&tx_queue, tx_free, tx_active, NET_TX_QUEUE_SIZE_DRIV);
net_queue_init(&rx_queue, rx_free, rx_active, NET_RX_QUEUE_CAPACITY_DRIV);
net_queue_init(&tx_queue, tx_free, tx_active, NET_TX_QUEUE_CAPACITY_DRIV);

rx_provide();
tx_provide();
Expand All @@ -330,4 +330,4 @@ void notified(microkit_channel ch)
sddf_dprintf("ETH|LOG: received notification on unexpected channel: %u\n", ch);
break;
}
}
}
12 changes: 6 additions & 6 deletions drivers/network/meson/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ net_queue_handle_t tx_queue;
volatile struct eth_mac_regs *eth_mac;
volatile struct eth_dma_regs *eth_dma;

static inline bool hw_ring_full(hw_ring_t *ring, size_t ring_size)
static inline bool hw_ring_full(hw_ring_t *ring, size_t ring_capacity)
{
return !((ring->tail + 2 - ring->head) % ring_size);
return !((ring->tail + 2 - ring->head) % ring_capacity);
}

static inline bool hw_ring_empty(hw_ring_t *ring, size_t ring_size)
static inline bool hw_ring_empty(hw_ring_t *ring, size_t ring_capacity)
{
return !((ring->tail - ring->head) % ring_size);
return !((ring->tail - ring->head) % ring_capacity);
}

static void update_ring_slot(hw_ring_t *ring, unsigned int idx, uint32_t status,
Expand Down Expand Up @@ -271,8 +271,8 @@ void init(void)
{
eth_setup();

net_queue_init(&rx_queue, (net_queue_t *)rx_free, (net_queue_t *)rx_active, NET_RX_QUEUE_SIZE_DRIV);
net_queue_init(&tx_queue, (net_queue_t *)tx_free, (net_queue_t *)tx_active, NET_TX_QUEUE_SIZE_DRIV);
net_queue_init(&rx_queue, (net_queue_t *)rx_free, (net_queue_t *)rx_active, NET_RX_QUEUE_CAPACITY_DRIV);
net_queue_init(&tx_queue, (net_queue_t *)tx_free, (net_queue_t *)tx_active, NET_TX_QUEUE_CAPACITY_DRIV);

rx_provide();
tx_provide();
Expand Down
4 changes: 2 additions & 2 deletions drivers/network/virtio/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ void init(void)
ialloc_init(&rx_ialloc_desc, rx_descriptors, RX_COUNT);
ialloc_init(&tx_ialloc_desc, tx_descriptors, TX_COUNT);

net_queue_init(&rx_queue, rx_free, rx_active, NET_RX_QUEUE_SIZE_DRIV);
net_queue_init(&tx_queue, tx_free, tx_active, NET_TX_QUEUE_SIZE_DRIV);
net_queue_init(&rx_queue, rx_free, rx_active, NET_RX_QUEUE_CAPACITY_DRIV);
net_queue_init(&tx_queue, tx_free, tx_active, NET_TX_QUEUE_CAPACITY_DRIV);

eth_setup();

Expand Down
6 changes: 3 additions & 3 deletions drivers/serial/arm/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ void init(void)
uart_setup();

#if !SERIAL_TX_ONLY
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_SIZE_DRIV, rx_data);
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_CAPACITY_DRIV, rx_data);
#endif
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_SIZE_DRIV, tx_data);
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_CAPACITY_DRIV, tx_data);
}

void notified(microkit_channel ch)
Expand All @@ -198,4 +198,4 @@ void notified(microkit_channel ch)
sddf_dprintf("UART|LOG: received notification on unexpected channel: %u\n", ch);
break;
}
}
}
6 changes: 3 additions & 3 deletions drivers/serial/imx/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ void init(void)
uart_setup();

#if !SERIAL_TX_ONLY
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_SIZE_DRIV, rx_data);
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_CAPACITY_DRIV, rx_data);
#endif
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_SIZE_DRIV, tx_data);
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_CAPACITY_DRIV, tx_data);
}

void notified(microkit_channel ch)
Expand All @@ -204,4 +204,4 @@ void notified(microkit_channel ch)
sddf_dprintf("UART|LOG: received notification on unexpected channel: %u\n", ch);
break;
}
}
}
6 changes: 3 additions & 3 deletions drivers/serial/meson/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ void init(void)
uart_setup();

#if !SERIAL_TX_ONLY
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_SIZE_DRIV, rx_data);
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_CAPACITY_DRIV, rx_data);
#endif
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_SIZE_DRIV, tx_data);
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_CAPACITY_DRIV, tx_data);
Ivan-Velickovic marked this conversation as resolved.
Show resolved Hide resolved
}

void notified(microkit_channel ch)
Expand All @@ -229,4 +229,4 @@ void notified(microkit_channel ch)
sddf_dprintf("UART|LOG: received notification on unexpected channel: %u\n", ch);
break;
}
}
}
4 changes: 2 additions & 2 deletions drivers/serial/snps/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ void init(void)
*REG_PTR(UART_IER) = (UART_IER_ERBFI | UART_IER_ETBEI);

#if !SERIAL_TX_ONLY
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_SIZE_DRIV, rx_data);
serial_queue_init(&rx_queue_handle, rx_queue, SERIAL_RX_DATA_REGION_CAPACITY_DRIV, rx_data);
#endif
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_SIZE_DRIV, tx_data);
serial_queue_init(&tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_CAPACITY_DRIV, tx_data);
}

void notified(microkit_channel ch)
Expand Down
86 changes: 40 additions & 46 deletions examples/echo_server/include/ethernet_config/ethernet_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,44 @@
#error "Must define MAC addresses for clients in ethernet config"
#endif

#define NET_TX_QUEUE_SIZE_CLI0 512
#define NET_TX_QUEUE_SIZE_CLI1 512
#define NET_TX_QUEUE_SIZE_DRIV (NET_TX_QUEUE_SIZE_CLI0 + NET_TX_QUEUE_SIZE_CLI1)
#define NET_TX_QUEUE_CAPACITY_CLI0 512
#define NET_TX_QUEUE_CAPACITY_CLI1 512
#define NET_TX_QUEUE_CAPACITY_DRIV (NET_TX_QUEUE_CAPACITY_CLI0 + NET_TX_QUEUE_CAPACITY_CLI1)

#define NET_TX_DATA_REGION_SIZE_CLI0 NET_DATA_REGION_SIZE
#define NET_TX_DATA_REGION_SIZE_CLI1 NET_DATA_REGION_SIZE

_Static_assert(NET_TX_DATA_REGION_SIZE_CLI0 >= NET_TX_QUEUE_SIZE_CLI0 *NET_BUFFER_SIZE,
_Static_assert(NET_TX_DATA_REGION_SIZE_CLI0 >= NET_TX_QUEUE_CAPACITY_CLI0 * NET_BUFFER_SIZE,
"Client0 TX data region size must fit Client0 TX buffers");
_Static_assert(NET_TX_DATA_REGION_SIZE_CLI1 >= NET_TX_QUEUE_SIZE_CLI1 *NET_BUFFER_SIZE,
_Static_assert(NET_TX_DATA_REGION_SIZE_CLI1 >= NET_TX_QUEUE_CAPACITY_CLI1 * NET_BUFFER_SIZE,
"Client1 TX data region size must fit Client1 TX buffers");

#define NET_RX_QUEUE_SIZE_DRIV 512
#define NET_RX_QUEUE_SIZE_CLI0 512
#define NET_RX_QUEUE_SIZE_CLI1 512
#define NET_MAX_CLIENT_QUEUE_SIZE MAX(NET_RX_QUEUE_SIZE_CLI0, NET_RX_QUEUE_SIZE_CLI1)
#define NET_RX_QUEUE_SIZE_COPY0 NET_RX_QUEUE_SIZE_DRIV
#define NET_RX_QUEUE_SIZE_COPY1 NET_RX_QUEUE_SIZE_DRIV
#define NET_RX_QUEUE_CAPACITY_DRIV 512
#define NET_RX_QUEUE_CAPACITY_CLI0 512
#define NET_RX_QUEUE_CAPACITY_CLI1 512
#define NET_MAX_CLIENT_QUEUE_CAPACITY MAX(NET_RX_QUEUE_CAPACITY_CLI0, NET_RX_QUEUE_CAPACITY_CLI1)
#define NET_RX_QUEUE_CAPACITY_COPY0 NET_RX_QUEUE_CAPACITY_DRIV
#define NET_RX_QUEUE_CAPACITY_COPY1 NET_RX_QUEUE_CAPACITY_DRIV

#define NET_RX_DATA_REGION_SIZE_DRIV NET_DATA_REGION_SIZE
#define NET_RX_DATA_REGION_SIZE_CLI0 NET_DATA_REGION_SIZE
#define NET_RX_DATA_REGION_SIZE_CLI1 NET_DATA_REGION_SIZE

_Static_assert(NET_RX_DATA_REGION_SIZE_DRIV >= NET_RX_QUEUE_SIZE_DRIV *NET_BUFFER_SIZE,
_Static_assert(NET_RX_DATA_REGION_SIZE_DRIV >= NET_RX_QUEUE_CAPACITY_DRIV * NET_BUFFER_SIZE,
"Driver RX data region size must fit Driver RX buffers");
_Static_assert(NET_RX_DATA_REGION_SIZE_CLI0 >= NET_RX_QUEUE_SIZE_CLI0 *NET_BUFFER_SIZE,
_Static_assert(NET_RX_DATA_REGION_SIZE_CLI0 >= NET_RX_QUEUE_CAPACITY_CLI0 * NET_BUFFER_SIZE,
"Client0 RX data region size must fit Client0 RX buffers");
_Static_assert(NET_RX_DATA_REGION_SIZE_CLI1 >= NET_RX_QUEUE_SIZE_CLI1 *NET_BUFFER_SIZE,
_Static_assert(NET_RX_DATA_REGION_SIZE_CLI1 >= NET_RX_QUEUE_CAPACITY_CLI1 * NET_BUFFER_SIZE,
"Client1 RX data region size must fit Client1 RX buffers");

#define NET_MAX_QUEUE_SIZE MAX(NET_TX_QUEUE_SIZE_DRIV, MAX(NET_RX_QUEUE_SIZE_DRIV, MAX(NET_RX_QUEUE_SIZE_CLI0, NET_RX_QUEUE_SIZE_CLI1)))
_Static_assert(NET_TX_QUEUE_SIZE_DRIV >= NET_TX_QUEUE_SIZE_CLI0 + NET_TX_QUEUE_SIZE_CLI1,
#define NET_MAX_QUEUE_CAPACITY MAX(NET_TX_QUEUE_CAPACITY_DRIV, MAX(NET_RX_QUEUE_CAPACITY_DRIV, MAX(NET_RX_QUEUE_CAPACITY_CLI0, NET_RX_QUEUE_CAPACITY_CLI1)))
_Static_assert(NET_TX_QUEUE_CAPACITY_DRIV >= NET_TX_QUEUE_CAPACITY_CLI0 + NET_TX_QUEUE_CAPACITY_CLI1,
"Driver TX queue must have capacity to fit all of client's TX buffers.");
_Static_assert(NET_RX_QUEUE_SIZE_COPY0 >= NET_RX_QUEUE_SIZE_DRIV,
_Static_assert(NET_RX_QUEUE_CAPACITY_COPY0 >= NET_RX_QUEUE_CAPACITY_DRIV,
"Copy0 queues must have capacity to fit all RX buffers.");
_Static_assert(NET_RX_QUEUE_SIZE_COPY1 >= NET_RX_QUEUE_SIZE_DRIV,
_Static_assert(NET_RX_QUEUE_CAPACITY_COPY1 >= NET_RX_QUEUE_CAPACITY_DRIV,
"Copy1 queues must have capacity to fit all RX buffers.");
_Static_assert(sizeof(net_queue_t) + NET_MAX_QUEUE_SIZE *sizeof(net_buff_desc_t) <= NET_DATA_REGION_SIZE,
_Static_assert(sizeof(net_queue_t) + NET_MAX_QUEUE_CAPACITY * sizeof(net_buff_desc_t) <= NET_DATA_REGION_SIZE,
"net_queue_t must fit into a single data region.");

static inline uint64_t net_cli_mac_addr(char *pd_name)
Expand All @@ -102,55 +102,49 @@ static inline void net_virt_mac_addrs(char *pd_name, uint64_t macs[NUM_NETWORK_C
}
}

static inline void net_cli_queue_size(char *pd_name, size_t *rx_queue_size, size_t *tx_queue_size)
static inline void net_cli_queue_capacity(char *pd_name, size_t *rx_queue_capacity, size_t *tx_queue_capacity)
{
if (!sddf_strcmp(pd_name, NET_CLI0_NAME)) {
*rx_queue_size = NET_RX_QUEUE_SIZE_CLI0;
*tx_queue_size = NET_TX_QUEUE_SIZE_CLI0;
*rx_queue_capacity = NET_RX_QUEUE_CAPACITY_CLI0;
*tx_queue_capacity = NET_TX_QUEUE_CAPACITY_CLI0;
} else if (!sddf_strcmp(pd_name, NET_CLI1_NAME)) {
*rx_queue_size = NET_RX_QUEUE_SIZE_CLI1;
*tx_queue_size = NET_TX_QUEUE_SIZE_CLI1;
*rx_queue_capacity = NET_RX_QUEUE_CAPACITY_CLI1;
*tx_queue_capacity = NET_TX_QUEUE_CAPACITY_CLI1;
}
}

static inline void net_copy_queue_size(char *pd_name, size_t *cli_queue_size, size_t *virt_queue_size)
static inline void net_copy_queue_capacity(char *pd_name, size_t *cli_queue_capacity, size_t *virt_queue_capacity)
{
if (!sddf_strcmp(pd_name, NET_COPY0_NAME)) {
*cli_queue_size = NET_RX_QUEUE_SIZE_CLI0;
*virt_queue_size = NET_RX_QUEUE_SIZE_COPY0;
*cli_queue_capacity = NET_RX_QUEUE_CAPACITY_CLI0;
*virt_queue_capacity = NET_RX_QUEUE_CAPACITY_COPY0;
} else if (!sddf_strcmp(pd_name, NET_COPY1_NAME)) {
*cli_queue_size = NET_RX_QUEUE_SIZE_CLI1;
*virt_queue_size = NET_RX_QUEUE_SIZE_COPY1;
*cli_queue_capacity = NET_RX_QUEUE_CAPACITY_CLI1;
*virt_queue_capacity = NET_RX_QUEUE_CAPACITY_COPY1;
}
}

typedef struct net_queue_info {
net_queue_t *free;
net_queue_t *active;
size_t size;
size_t capacity;
} net_queue_info_t;

static inline void net_virt_queue_info(char *pd_name, net_queue_t *cli0_free, net_queue_t *cli0_active,
net_queue_info_t ret[NUM_NETWORK_CLIENTS])
{
if (!sddf_strcmp(pd_name, NET_VIRT_RX_NAME)) {
ret[0] = (net_queue_info_t) {
.free = cli0_free, .active = cli0_active, .size = NET_RX_QUEUE_SIZE_COPY0
};
ret[1] = (net_queue_info_t) {
.free = (net_queue_t *)((uintptr_t)cli0_free + 2 * NET_DATA_REGION_SIZE),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_SIZE),
.size = NET_RX_QUEUE_SIZE_COPY1
};
ret[0] =
(net_queue_info_t) { .free = cli0_free, .active = cli0_active, .capacity = NET_RX_QUEUE_CAPACITY_COPY0 };
ret[1] = (net_queue_info_t) { .free = (net_queue_t *)((uintptr_t)cli0_free + 2 * NET_DATA_REGION_SIZE),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_SIZE),
.capacity = NET_RX_QUEUE_CAPACITY_COPY1 };
} else if (!sddf_strcmp(pd_name, NET_VIRT_TX_NAME)) {
ret[0] = (net_queue_info_t) {
.free = cli0_free, .active = cli0_active, .size = NET_TX_QUEUE_SIZE_CLI0
};
ret[1] = (net_queue_info_t) {
.free = (net_queue_t *)((uintptr_t)cli0_free + 2 * NET_DATA_REGION_SIZE),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_SIZE),
.size = NET_TX_QUEUE_SIZE_CLI1
};
ret[0] =
(net_queue_info_t) { .free = cli0_free, .active = cli0_active, .capacity = NET_TX_QUEUE_CAPACITY_CLI0 };
ret[1] = (net_queue_info_t) { .free = (net_queue_t *)((uintptr_t)cli0_free + 2 * NET_DATA_REGION_SIZE),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_SIZE),
Ivan-Velickovic marked this conversation as resolved.
Show resolved Hide resolved
.capacity = NET_TX_QUEUE_CAPACITY_CLI1 };
}
}

Expand Down
36 changes: 18 additions & 18 deletions examples/echo_server/include/serial_config/serial_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,47 @@
#define SERIAL_CLI2_NAME "bench"
#define SERIAL_VIRT_TX_NAME "serial_virt_tx"

#define SERIAL_QUEUE_SIZE 0x1000
#define SERIAL_DATA_REGION_SIZE 0x2000
#define SERIAL_QUEUE_SIZE 0x1000
#define SERIAL_DATA_REGION_CAPACITY 0x2000

#define SERIAL_TX_DATA_REGION_SIZE_DRIV (2 * SERIAL_DATA_REGION_SIZE)
#define SERIAL_TX_DATA_REGION_SIZE_CLI0 SERIAL_DATA_REGION_SIZE
#define SERIAL_TX_DATA_REGION_SIZE_CLI1 SERIAL_DATA_REGION_SIZE
#define SERIAL_TX_DATA_REGION_SIZE_CLI2 SERIAL_DATA_REGION_SIZE
#define SERIAL_TX_DATA_REGION_CAPACITY_DRIV (2 * SERIAL_DATA_REGION_CAPACITY)
#define SERIAL_TX_DATA_REGION_CAPACITY_CLI0 SERIAL_DATA_REGION_CAPACITY
#define SERIAL_TX_DATA_REGION_CAPACITY_CLI1 SERIAL_DATA_REGION_CAPACITY
#define SERIAL_TX_DATA_REGION_CAPACITY_CLI2 SERIAL_DATA_REGION_CAPACITY

#define SERIAL_MAX_CLIENT_TX_DATA_SIZE MAX(SERIAL_TX_DATA_REGION_SIZE_CLI2, MAX(SERIAL_TX_DATA_REGION_SIZE_CLI0, SERIAL_TX_DATA_REGION_SIZE_CLI1))
#define SERIAL_MAX_CLIENT_TX_DATA_CAPACITY MAX(SERIAL_TX_DATA_REGION_CAPACITY_CLI2, MAX(SERIAL_TX_DATA_REGION_CAPACITY_CLI0, SERIAL_TX_DATA_REGION_CAPACITY_CLI1))
#if SERIAL_WITH_COLOUR
_Static_assert(SERIAL_TX_DATA_REGION_SIZE_DRIV > SERIAL_MAX_CLIENT_TX_DATA_SIZE,
_Static_assert(SERIAL_TX_DATA_REGION_CAPACITY_DRIV > SERIAL_MAX_CLIENT_TX_DATA_CAPACITY,
"Driver TX data region must be larger than all client data regions in SERIAL_WITH_COLOUR mode.");
#endif

#define SERIAL_MAX_DATA_SIZE MAX(SERIAL_TX_DATA_REGION_SIZE_DRIV, SERIAL_MAX_CLIENT_TX_DATA_SIZE)
_Static_assert(SERIAL_MAX_DATA_SIZE < UINT32_MAX,
#define SERIAL_MAX_DATA_CAPACITY MAX(SERIAL_TX_DATA_REGION_CAPACITY_DRIV, SERIAL_MAX_CLIENT_TX_DATA_CAPACITY)
_Static_assert(SERIAL_MAX_DATA_CAPACITY < UINT32_MAX,
"Data regions must be smaller than UINT32 max to correctly use queue data structure.");

static inline void serial_cli_queue_init_sys(char *pd_name, serial_queue_handle_t *rx_queue_handle,
serial_queue_t *rx_queue,
char *rx_data, serial_queue_handle_t *tx_queue_handle, serial_queue_t *tx_queue, char *tx_data)
{
if (!sddf_strcmp(pd_name, SERIAL_CLI0_NAME)) {
serial_queue_init(tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_SIZE_CLI0, tx_data);
serial_queue_init(tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_CAPACITY_CLI0, tx_data);
} else if (!sddf_strcmp(pd_name, SERIAL_CLI1_NAME)) {
serial_queue_init(tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_SIZE_CLI1, tx_data);
serial_queue_init(tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_CAPACITY_CLI1, tx_data);
} else if (!sddf_strcmp(pd_name, SERIAL_CLI2_NAME)) {
serial_queue_init(tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_SIZE_CLI2, tx_data);
serial_queue_init(tx_queue_handle, tx_queue, SERIAL_TX_DATA_REGION_CAPACITY_CLI2, tx_data);
}
}

static inline void serial_virt_queue_init_sys(char *pd_name, serial_queue_handle_t *cli_queue_handle,
serial_queue_t *cli_queue, char *cli_data)
{
if (!sddf_strcmp(pd_name, SERIAL_VIRT_TX_NAME)) {
serial_queue_init(cli_queue_handle, cli_queue, SERIAL_TX_DATA_REGION_SIZE_CLI0, cli_data);
serial_queue_init(cli_queue_handle, cli_queue, SERIAL_TX_DATA_REGION_CAPACITY_CLI0, cli_data);
serial_queue_init(&cli_queue_handle[1], (serial_queue_t *)((uintptr_t)cli_queue + SERIAL_QUEUE_SIZE),
SERIAL_TX_DATA_REGION_SIZE_CLI1, cli_data + SERIAL_TX_DATA_REGION_SIZE_CLI0);
SERIAL_TX_DATA_REGION_CAPACITY_CLI1, cli_data + SERIAL_TX_DATA_REGION_CAPACITY_CLI0);
serial_queue_init(&cli_queue_handle[2], (serial_queue_t *)((uintptr_t)cli_queue + 2 * SERIAL_QUEUE_SIZE),
SERIAL_TX_DATA_REGION_SIZE_CLI2, cli_data + SERIAL_TX_DATA_REGION_SIZE_CLI0 +
SERIAL_TX_DATA_REGION_SIZE_CLI1);
SERIAL_TX_DATA_REGION_CAPACITY_CLI2,
cli_data + SERIAL_TX_DATA_REGION_CAPACITY_CLI0 + SERIAL_TX_DATA_REGION_CAPACITY_CLI1);
}
}

Expand All @@ -84,4 +84,4 @@ static inline void serial_channel_names_init(char **client_names)
client_names[1] = SERIAL_CLI1_NAME;
client_names[2] = SERIAL_CLI2_NAME;
}
#endif
#endif
10 changes: 5 additions & 5 deletions examples/echo_server/lwip.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ serial_queue_t *serial_tx_queue;
serial_queue_handle_t serial_tx_queue_handle;

#define LWIP_TICK_MS 100
#define NUM_PBUFFS NET_MAX_CLIENT_QUEUE_SIZE
#define NUM_PBUFFS NET_MAX_CLIENT_QUEUE_CAPACITY

net_queue_t *rx_free;
net_queue_t *rx_active;
Expand Down Expand Up @@ -289,10 +289,10 @@ void 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);

size_t rx_size, tx_size;
net_cli_queue_size(microkit_name, &rx_size, &tx_size);
net_queue_init(&state.rx_queue, rx_free, rx_active, rx_size);
net_queue_init(&state.tx_queue, tx_free, tx_active, tx_size);
size_t rx_capacity, tx_capacity;
net_cli_queue_capacity(microkit_name, &rx_capacity, &tx_capacity);
net_queue_init(&state.rx_queue, rx_free, rx_active, rx_capacity);
net_queue_init(&state.tx_queue, tx_free, tx_active, tx_capacity);
net_buffers_init(&state.tx_queue, 0);

lwip_init();
Expand Down
Loading
Loading