Skip to content

Commit

Permalink
Update to latest sDDF
Browse files Browse the repository at this point in the history
Various breaking changes, mainly size -> capacity rename.

Signed-off-by: Peter Chubb <[email protected]>
Signed-off-by: Ivan-Velickovic <[email protected]>
Signed-off-by: Courtney Darville <[email protected]>
  • Loading branch information
wom-bat authored and Ivan-Velickovic committed Nov 8, 2024
1 parent c0356e7 commit d5e4a65
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 224 deletions.
4 changes: 2 additions & 2 deletions components/fs/fat/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ void print_sector_data(uint8_t *buffer, unsigned long size) {
LOG_FATFS("\n");
}

_Static_assert(BLK_QUEUE_SIZE_CLI_FAT >= FAT_WORKER_THREAD_NUM,
_Static_assert(BLK_QUEUE_CAPACITY_CLI_FAT >= FAT_WORKER_THREAD_NUM,
"The size of queue between fs and blk should be at least the size of FAT_WORKER_THREAD_NUM");

void init(void) {
// Init the block device queue
// Have to make sure who initialize this SDDF queue
blk_queue_init(blk_queue_handle, blk_request, blk_response, BLK_QUEUE_SIZE_CLI_FAT);
blk_queue_init(blk_queue_handle, blk_request, blk_response, BLK_QUEUE_CAPACITY_CLI_FAT);
/*
This part of the code is for setting up the thread pool by
assign stacks and size of the stack to the pool
Expand Down
10 changes: 5 additions & 5 deletions components/fs/nfs/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ state_t state;

LWIP_MEMPOOL_DECLARE(
RX_POOL,
NET_RX_QUEUE_SIZE_CLI0 * 2,
NET_RX_QUEUE_CAPACITY_CLI0 * 2,
sizeof(pbuf_custom_offset_t),
"Zero-copy RX pool");

Expand Down Expand Up @@ -241,10 +241,10 @@ void tcp_update(void)

void tcp_init_0(void)
{
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
10 changes: 5 additions & 5 deletions components/micropython/mpnetworkport.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ state_t state;

LWIP_MEMPOOL_DECLARE(
RX_POOL,
NET_RX_QUEUE_SIZE_CLI1 * 2,
NET_RX_QUEUE_CAPACITY_CLI1 * 2,
sizeof(pbuf_custom_offset_t),
"Zero-copy RX pool");

Expand Down Expand Up @@ -170,10 +170,10 @@ static err_t ethernet_init(struct netif *netif)

void init_networking(void) {
/* Set up shared memory regions */
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
2 changes: 1 addition & 1 deletion dep/sddf
Submodule sddf updated 42 files
+13 −13 .github/workflows/examples.yaml
+180 −194 blk/components/virt.c
+122 −0 build.zig
+1 −1 drivers/blk/mmc/imx/mmc_driver.mk
+13 −13 drivers/blk/mmc/imx/usdhc.c
+0 −0 drivers/blk/mmc/imx/usdhc.h
+12 −12 drivers/blk/virtio/block.c
+0 −2 drivers/blk/virtio/block.h
+9 −8 drivers/network/imx/ethernet.c
+22 −16 drivers/network/meson/ethernet.c
+15 −6 drivers/network/virtio/ethernet.c
+3 −3 drivers/serial/arm/uart.c
+3 −3 drivers/serial/imx/uart.c
+3 −3 drivers/serial/meson/uart.c
+2 −2 drivers/serial/snps/uart.c
+445 −0 drivers/serial/virtio/console.c
+34 −0 drivers/serial/virtio/include/console.h
+29 −0 drivers/serial/virtio/serial_driver.mk
+1 −1 examples/blk/README.md
+1 −1 examples/blk/basic_data.txt
+14 −21 examples/blk/blk_config.h
+16 −15 examples/blk/board/qemu_virt_aarch64/blk.system
+3 −3 examples/blk/client.c
+40 −46 examples/echo_server/include/ethernet_config/ethernet_config.h
+18 −18 examples/echo_server/include/serial_config/serial_config.h
+5 −5 examples/echo_server/lwip.c
+7 −7 examples/echo_server/tcp_echo_socket.c
+25 −24 examples/mmc/board/imx8mm_evk/mmc.system
+25 −24 examples/mmc/board/maaxboard/mmc.system
+3 −3 examples/mmc/client.c
+15 −22 examples/mmc/include/configs/blk_config.h
+23 −23 examples/serial/include/serial_config/serial_config.h
+2 −0 include/sddf/blk/queue.h
+2 −0 include/sddf/blk/storage_info.h
+15 −15 include/sddf/network/queue.h
+39 −35 include/sddf/serial/queue.h
+1 −0 include/sddf/virtio/virtio.h
+6 −5 network/components/copy.c
+5 −6 network/components/virt_rx.c
+6 −7 network/components/virt_tx.c
+2 −2 serial/components/virt_rx.c
+2 −2 serial/components/virt_tx.c
25 changes: 13 additions & 12 deletions examples/fileio/board/maaxboard/fileio.system
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
<memory_region name="blk_virtio_headers" size="0x10000" />
<memory_region name="blk_driver_metadata" size="0x200000" />

<memory_region name="blk_driver_config" size="0x1000" page_size="0x1000" />
<memory_region name="blk_driver_storage_info" size="0x1000" page_size="0x1000" />
<memory_region name="blk_driver_request" size="0x200_000" page_size="0x200_000"/>
<memory_region name="blk_driver_response" size="0x200_000" page_size="0x200_000"/>
<memory_region name="blk_driver_data" size="0x200_000" page_size="0x200_000" />
Expand All @@ -192,24 +192,25 @@
<irq irq="54" id="1" />

<!-- sDDF block -->
<map mr="blk_driver_config" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_driver_storage_info" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_storage_info" />
<map mr="blk_driver_request" vaddr="0x40200000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="blk_driver_response" vaddr="0x40400000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
</protection_domain>

<protection_domain name="BLK_VIRT" priority="101">
<program_image path="blk_virt.elf" />

<map mr="blk_driver_config" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_config_driver" />
<map mr="blk_driver_request" vaddr="0x40200000" perms="rw" cached="false" setvar_vaddr="blk_req_queue_driver" />
<map mr="blk_driver_response" vaddr="0x40400000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue_driver" />
<map mr="blk_driver_data" vaddr="0x40600000" perms="rw" cached="true" setvar_vaddr="blk_data_driver" />
<setvar symbol="blk_data_driver_paddr" region_paddr="blk_driver_data" />

<map mr="blk_client_config" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_client_request" vaddr="0x30200000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="blk_client_response" vaddr="0x30400000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
<map mr="blk_client_data" vaddr="0x30600000" perms="rw" cached="true" setvar_vaddr="blk_client_data_start" />
<map mr="blk_driver_storage_info" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_driver_storage_info" />
<map mr="blk_driver_request" vaddr="0x40200000" perms="rw" cached="false" setvar_vaddr="blk_driver_req_queue" />
<map mr="blk_driver_response" vaddr="0x40400000" perms="rw" cached="false" setvar_vaddr="blk_driver_resp_queue" />
<map mr="blk_driver_data" vaddr="0x40600000" perms="rw" cached="true" setvar_vaddr="blk_driver_data" />
<setvar symbol="blk_data_paddr_driver" region_paddr="blk_driver_data" />

<map mr="blk_client_config" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_client_storage_info" />
<map mr="blk_client_request" vaddr="0x30200000" perms="rw" cached="false" setvar_vaddr="blk_client_req_queue" />
<map mr="blk_client_response" vaddr="0x30400000" perms="rw" cached="false" setvar_vaddr="blk_client_resp_queue" />
<map mr="blk_client_data" vaddr="0x30600000" perms="rw" cached="true" setvar_vaddr="blk_client_data" />
<setvar symbol="blk_client0_data_paddr" region_paddr="blk_client_data" />
</protection_domain>

<!-- FAT File system -->
Expand Down
29 changes: 15 additions & 14 deletions examples/fileio/board/qemu_virt_aarch64/fileio.system
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<memory_region name="blk_virtio_headers" size="0x10000" />
<memory_region name="blk_driver_metadata" size="0x200000" />

<memory_region name="blk_driver_config" size="0x1000" page_size="0x1000" />
<memory_region name="blk_driver_storage_info" size="0x1000" page_size="0x1000" />
<memory_region name="blk_driver_request" size="0x200_000" page_size="0x200_000"/>
<memory_region name="blk_driver_response" size="0x200_000" page_size="0x200_000"/>
<memory_region name="blk_driver_data" size="0x200_000" page_size="0x200_000" />
Expand All @@ -189,9 +189,9 @@
<setvar symbol="virtio_headers_paddr" region_paddr="blk_virtio_headers" />
<setvar symbol="requests_paddr" region_paddr="blk_driver_metadata" />

<map mr="blk_driver_config" vaddr="0x40_000_000" perms="rw" cached="true" setvar_vaddr="blk_config" />
<map mr="blk_driver_request" vaddr="0x40_200_000" perms="rw" cached="true" setvar_vaddr="blk_request" />
<map mr="blk_driver_response" vaddr="0x40_400_000" perms="rw" cached="true" setvar_vaddr="blk_response" />
<map mr="blk_driver_storage_info" vaddr="0x40_000_000" perms="rw" cached="true" setvar_vaddr="blk_storage_info" />
<map mr="blk_driver_request" vaddr="0x40_200_000" perms="rw" cached="true" setvar_vaddr="blk_req_queue" />
<map mr="blk_driver_response" vaddr="0x40_400_000" perms="rw" cached="true" setvar_vaddr="blk_resp_queue" />

<map mr="blk_virtio_headers" vaddr="0x50_000_000" perms="rw" cached="false" setvar_vaddr="virtio_headers_vaddr" />
<map mr="blk_driver_metadata" vaddr="0x60_000_000" perms="rw" cached="false" setvar_vaddr="requests_vaddr" />
Expand All @@ -202,16 +202,17 @@
<protection_domain name="BLK_VIRT" priority="101">
<program_image path="blk_virt.elf" />

<map mr="blk_driver_config" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_config_driver" />
<map mr="blk_driver_request" vaddr="0x40200000" perms="rw" cached="false" setvar_vaddr="blk_req_queue_driver" />
<map mr="blk_driver_response" vaddr="0x40400000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue_driver" />
<map mr="blk_driver_data" vaddr="0x40600000" perms="rw" cached="true" setvar_vaddr="blk_data_driver" />
<setvar symbol="blk_data_driver_paddr" region_paddr="blk_driver_data" />

<map mr="blk_client_config" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_client_request" vaddr="0x30200000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="blk_client_response" vaddr="0x30400000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
<map mr="blk_client_data" vaddr="0x30600000" perms="rw" cached="true" setvar_vaddr="blk_client_data_start" />
<map mr="blk_driver_storage_info" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_driver_storage_info" />
<map mr="blk_driver_request" vaddr="0x40200000" perms="rw" cached="false" setvar_vaddr="blk_driver_req_queue" />
<map mr="blk_driver_response" vaddr="0x40400000" perms="rw" cached="false" setvar_vaddr="blk_driver_resp_queue" />
<map mr="blk_driver_data" vaddr="0x40600000" perms="rw" cached="true" setvar_vaddr="blk_driver_data" />
<setvar symbol="blk_data_paddr_driver" region_paddr="blk_driver_data" />

<map mr="blk_client_config" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_client_storage_info" />
<map mr="blk_client_request" vaddr="0x30200000" perms="rw" cached="false" setvar_vaddr="blk_client_req_queue" />
<map mr="blk_client_response" vaddr="0x30400000" perms="rw" cached="false" setvar_vaddr="blk_client_resp_queue" />
<map mr="blk_client_data" vaddr="0x30600000" perms="rw" cached="true" setvar_vaddr="blk_client_data" />
<setvar symbol="blk_client0_data_paddr" region_paddr="blk_client_data" />
</protection_domain>

<!-- FAT File system -->
Expand Down
16 changes: 8 additions & 8 deletions examples/fileio/src/config/blk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

#define BLK_NAME_CLI0 "fat"

#define BLK_QUEUE_SIZE_CLI_FAT 16
#define BLK_QUEUE_SIZE_CLI0 BLK_QUEUE_SIZE_CLI_FAT
#define BLK_QUEUE_SIZE_DRIV 1024
#define BLK_QUEUE_CAPACITY_CLI_FAT 16
#define BLK_QUEUE_CAPACITY_CLI0 BLK_QUEUE_CAPACITY_CLI_FAT
#define BLK_QUEUE_CAPACITY_DRIV 1024

#define BLK_REGION_SIZE 0x200000
#define BLK_CONFIG_REGION_SIZE_CLI0 BLK_REGION_SIZE
Expand All @@ -34,7 +34,7 @@ _Static_assert(BLK_DATA_REGION_SIZE_DRIV >= BLK_TRANSFER_SIZE && BLK_DATA_REGION
/* Mapping from client index to disk partition that the client will have access to. */
static const int blk_partition_mapping[BLK_NUM_CLIENTS] = { 0 };

static inline blk_storage_info_t *blk_virt_cli_config_info(blk_storage_info_t *info, unsigned int id)
static inline blk_storage_info_t *blk_virt_cli_storage_info(blk_storage_info_t *info, unsigned int id)
{
switch (id) {
case 0:
Expand Down Expand Up @@ -84,20 +84,20 @@ static inline blk_resp_queue_t *blk_virt_cli_resp_queue(blk_resp_queue_t *resp,
}
}

static inline uint32_t blk_virt_cli_queue_size(unsigned int id)
static inline uint32_t blk_virt_cli_queue_capacity(unsigned int id)
{
switch (id) {
case 0:
return BLK_QUEUE_SIZE_CLI0;
return BLK_QUEUE_CAPACITY_CLI0;
default:
return 0;
}
}

static inline uint32_t blk_cli_queue_size(char *pd_name)
static inline uint32_t blk_cli_queue_capacity(char *pd_name)
{
if (!sddf_strcmp(pd_name, BLK_NAME_CLI0)) {
return BLK_QUEUE_SIZE_CLI0;
return BLK_QUEUE_CAPACITY_CLI0;
} else {
return 0;
}
Expand Down
53 changes: 27 additions & 26 deletions examples/fileio/src/config/ethernet_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,45 @@
#error "Must define MAC addresses for clients in ethernet config"
#endif

#define NET_TX_QUEUE_SIZE_CLI0 512
#define NET_TX_QUEUE_SIZE_DRIV (NET_TX_QUEUE_SIZE_CLI0)
#define NET_TX_QUEUE_CAPACITY_CLI0 512
#define NET_TX_QUEUE_CAPACITY_DRIV (NET_TX_QUEUE_CAPACITY_CLI0)

#define NET_TX_DATA_REGION_SIZE_CLI0 NET_DATA_REGION_SIZE
#define NET_TX_DATA_REGION_SIZE_CLI0 NET_DATA_REGION_SIZE

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

#define NET_RX_QUEUE_SIZE_DRIV 512
#define NET_RX_QUEUE_SIZE_CLI0 512
#define NET_RX_QUEUE_SIZE_COPY0 NET_RX_QUEUE_SIZE_DRIV
#define NET_RX_QUEUE_CAPACITY_DRIV 512
#define NET_RX_QUEUE_CAPACITY_CLI0 512
#define NET_RX_QUEUE_CAPACITY_COPY0 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

_Static_assert(NET_RX_DATA_REGION_SIZE_DRIV >=
NET_RX_QUEUE_SIZE_DRIV * NET_BUFFER_SIZE,
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,
NET_RX_QUEUE_CAPACITY_CLI0 * NET_BUFFER_SIZE,
"Client0 RX data region size must fit Client0 RX buffers");

#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif

#define ETH_MAX_QUEUE_SIZE MAX(NET_TX_QUEUE_SIZE_DRIV, \
MAX(NET_RX_QUEUE_SIZE_DRIV, \
NET_RX_QUEUE_SIZE_CLI0))
#define NET_MAX_QUEUE_CAPACITY MAX(NET_TX_QUEUE_CAPACITY_DRIV, \
MAX(NET_RX_QUEUE_CAPACITY_DRIV, \
NET_RX_QUEUE_CAPACITY_CLI0))

_Static_assert(NET_TX_QUEUE_SIZE_DRIV >=NET_TX_QUEUE_SIZE_CLI0,
_Static_assert(NET_TX_QUEUE_CAPACITY_DRIV >= NET_TX_QUEUE_CAPACITY_CLI0,
"Network 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,
"Network Copy0 queue must have capacity to fit all RX buffers.");
_Static_assert(sizeof(net_queue_t) <= NET_DATA_REGION_SIZE,
"Netowkr Queue must fit into a single data region.");
_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 @@ -87,38 +88,38 @@ 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;
}
}

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

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
.free = cli0_free, .active = cli0_active, .capacity = NET_RX_QUEUE_CAPACITY_COPY0
};
} 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
.free = cli0_free, .active = cli0_active, .capacity = NET_TX_QUEUE_CAPACITY_CLI0
};
}
}
Expand All @@ -132,6 +133,6 @@ static inline void net_mem_region_vaddr(char *pd_name, uintptr_t mem_regions[NUM
}

// Hacking define to get micropython's mpnetworkport.c compiled
#define NET_RX_QUEUE_SIZE_CLI1 512
#define NET_RX_QUEUE_CAPACITY_CLI1 512

#endif /* FILEIO_ETHERNET_CONFIG_H */
Loading

0 comments on commit d5e4a65

Please sign in to comment.