Skip to content

Commit

Permalink
Still use size for the size of data regions, only use capacity for nu…
Browse files Browse the repository at this point in the history
…mber of entries in a queue

Signed-off-by: Courtney Darville <[email protected]>
  • Loading branch information
Courtney3141 committed Oct 31, 2024
1 parent 0bcf16f commit 2c4a507
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
32 changes: 16 additions & 16 deletions examples/kitty/src/config/ethernet_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define NET_VIRT_TX_NAME "eth_virt_tx"
#define NET_DRIVER_NAME "eth"

#define NET_DATA_REGION_CAPACITY 0x200000
#define NET_DATA_REGION_SIZE 0x200000
#define NET_HW_REGION_SIZE 0x10000

#if defined(CONFIG_PLAT_ODROIDC4)
Expand All @@ -40,13 +40,13 @@
#define NET_TX_QUEUE_CAPACITY_DRIV (NET_TX_QUEUE_CAPACITY_CLI0 \
+ NET_TX_QUEUE_CAPACITY_CLI1)

#define NET_TX_DATA_REGION_CAPACITY_CLI0 NET_DATA_REGION_CAPACITY
#define NET_TX_DATA_REGION_CAPACITY_CLI1 NET_DATA_REGION_CAPACITY
#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_CAPACITY_CLI0 >=
_Static_assert(NET_TX_DATA_REGION_SIZE_CLI0 >=
NET_TX_QUEUE_CAPACITY_CLI0 * NET_BUFFER_SIZE,
"Client0 TX data region capacity must fit Client0 TX buffers");
_Static_assert(NET_TX_DATA_REGION_CAPACITY_CLI1 >=
_Static_assert(NET_TX_DATA_REGION_SIZE_CLI1 >=
NET_TX_QUEUE_CAPACITY_CLI1 * NET_BUFFER_SIZE,
"Client1 TX data region capacity must fit Client1 TX buffers");

Expand All @@ -56,17 +56,17 @@ _Static_assert(NET_TX_DATA_REGION_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_CAPACITY_DRIV NET_DATA_REGION_CAPACITY
#define NET_RX_DATA_REGION_CAPACITY_CLI0 NET_DATA_REGION_CAPACITY
#define NET_RX_DATA_REGION_CAPACITY_CLI1 NET_DATA_REGION_CAPACITY
#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_CAPACITY_DRIV >=
_Static_assert(NET_RX_DATA_REGION_SIZE_DRIV >=
NET_RX_QUEUE_CAPACITY_DRIV * NET_BUFFER_SIZE,
"Driver RX data region capacity must fit Driver RX buffers");
_Static_assert(NET_RX_DATA_REGION_CAPACITY_CLI0 >=
_Static_assert(NET_RX_DATA_REGION_SIZE_CLI0 >=
NET_RX_QUEUE_CAPACITY_CLI0 * NET_BUFFER_SIZE,
"Client0 RX data region capacity must fit Client0 RX buffers");
_Static_assert(NET_RX_DATA_REGION_CAPACITY_CLI1 >=
_Static_assert(NET_RX_DATA_REGION_SIZE_CLI1 >=
NET_RX_QUEUE_CAPACITY_CLI1 * NET_BUFFER_SIZE,
"Client1 RX data region capacity must fit Client1 RX buffers");

Expand Down Expand Up @@ -147,17 +147,17 @@ static inline void net_virt_queue_info(char *pd_name, net_queue_t *cli0_free, ne
.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_CAPACITY),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_CAPACITY),
.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, .capacity = NET_TX_QUEUE_CAPACITY_CLI0
};
ret[1] = (net_queue_info_t) {
.free = (net_queue_t *)((uintptr_t)cli0_free + 2 * NET_DATA_REGION_CAPACITY),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_CAPACITY),
.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_TX_QUEUE_CAPACITY_CLI1
};
}
Expand All @@ -168,7 +168,7 @@ static inline void net_mem_region_vaddr(char *pd_name, uintptr_t mem_regions[NUM
{
if (!sddf_strcmp(pd_name, NET_VIRT_TX_NAME)) {
mem_regions[0] = start_region;
mem_regions[1] = start_region + NET_DATA_REGION_CAPACITY;
mem_regions[1] = start_region + NET_DATA_REGION_SIZE;
}
}

Expand Down
12 changes: 6 additions & 6 deletions examples/kitty/src/config/serial_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
/* Default baud rate of the uart device */
#define UART_DEFAULT_BAUD 115200

/* String to be printed to start console input */
#define SERIAL_CONSOLE_BEGIN_STRING ""
#define SERIAL_CONSOLE_BEGIN_STRING_LEN 0

/* One read/write client, one write only client */
#define SERIAL_CLI0_NAME "micropython"
#define SERIAL_CLI1_NAME "nfs"
#define SERIAL_VIRT_RX_NAME "serial_virt_rx"
#define SERIAL_VIRT_TX_NAME "serial_virt_tx"

#define SERIAL_QUEUE_CAPACITY 0x1000
#define SERIAL_QUEUE_SIZE 0x1000
#define SERIAL_DATA_REGION_CAPACITY 0x2000

#define SERIAL_TX_DATA_REGION_CAPACITY_DRIV (2 * SERIAL_DATA_REGION_CAPACITY)
Expand All @@ -44,10 +48,6 @@
#define SERIAL_MAX_DATA_CAPACITY MAX(SERIAL_MAX_TX_DATA_CAPACITY, \
SERIAL_MAX_RX_DATA_CAPACITY)

/* String to be printed to start console input */
#define SERIAL_CONSOLE_BEGIN_STRING ""
#define SERIAL_CONSOLE_BEGIN_STRING_LEN 0

_Static_assert(SERIAL_MAX_DATA_CAPACITY < UINT32_MAX,
"Data regions must be smaller than UINT32"
" max to use queue data structure correctly.");
Expand Down Expand Up @@ -86,7 +86,7 @@ static inline void serial_virt_queue_init_sys(char *pd_name,
SERIAL_TX_DATA_REGION_CAPACITY_CLI0, cli_data);
serial_queue_init(&cli_queue_handle[1],
(serial_queue_t *)((uintptr_t)cli_queue +
SERIAL_QUEUE_CAPACITY),
SERIAL_QUEUE_SIZE),
SERIAL_TX_DATA_REGION_CAPACITY_CLI1,
cli_data + SERIAL_TX_DATA_REGION_CAPACITY_CLI0);
}
Expand Down
32 changes: 16 additions & 16 deletions examples/webserver/config/ethernet_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define NET_VIRT_TX_NAME "eth_virt_tx"
#define NET_DRIVER_NAME "eth"

#define NET_DATA_REGION_CAPACITY 0x200000
#define NET_DATA_REGION_SIZE 0x200000
#define NET_HW_REGION_SIZE 0x10000

#if defined(CONFIG_PLAT_ODROIDC4)
Expand All @@ -40,13 +40,13 @@
#define NET_TX_QUEUE_CAPACITY_DRIV (NET_TX_QUEUE_CAPACITY_CLI0 \
+ NET_TX_QUEUE_CAPACITY_CLI1)

#define NET_TX_DATA_REGION_CAPACITY_CLI0 NET_DATA_REGION_CAPACITY
#define NET_TX_DATA_REGION_CAPACITY_CLI1 NET_DATA_REGION_CAPACITY
#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_CAPACITY_CLI0 >=
_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_CAPACITY_CLI1 >=
_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");

Expand All @@ -56,17 +56,17 @@ _Static_assert(NET_TX_DATA_REGION_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_CAPACITY_DRIV NET_DATA_REGION_CAPACITY
#define NET_RX_DATA_REGION_CAPACITY_CLI0 NET_DATA_REGION_CAPACITY
#define NET_RX_DATA_REGION_CAPACITY_CLI1 NET_DATA_REGION_CAPACITY
#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_CAPACITY_DRIV >=
_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_CAPACITY_CLI0 >=
_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_CAPACITY_CLI1 >=
_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");

Expand Down Expand Up @@ -144,17 +144,17 @@ static inline void net_virt_queue_info(char *pd_name, net_queue_t *cli0_free, ne
.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_CAPACITY),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_CAPACITY),
.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, .capacity = NET_TX_QUEUE_CAPACITY_CLI0
};
ret[1] = (net_queue_info_t) {
.free = (net_queue_t *)((uintptr_t)cli0_free + 2 * NET_DATA_REGION_CAPACITY),
.active = (net_queue_t *)((uintptr_t)cli0_active + 2 * NET_DATA_REGION_CAPACITY),
.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_TX_QUEUE_CAPACITY_CLI1
};
}
Expand All @@ -165,7 +165,7 @@ static inline void net_mem_region_vaddr(char *pd_name, uintptr_t mem_regions[NUM
{
if (!sddf_strcmp(pd_name, NET_VIRT_TX_NAME)) {
mem_regions[0] = start_region;
mem_regions[1] = start_region + NET_DATA_REGION_CAPACITY;
mem_regions[1] = start_region + NET_DATA_REGION_SIZE;
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/webserver/config/serial_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define SERIAL_CLI1_NAME "nfs"
#define SERIAL_VIRT_TX_NAME "serial_virt_tx"

#define SERIAL_QUEUE_CAPACITY 0x1000
#define SERIAL_QUEUE_SIZE 0x1000
#define SERIAL_DATA_REGION_CAPACITY 0x2000

#define SERIAL_TX_DATA_REGION_CAPACITY_DRIV (2 * SERIAL_DATA_REGION_CAPACITY)
Expand Down Expand Up @@ -73,7 +73,7 @@ static inline void serial_virt_queue_init_sys(char *pd_name,
SERIAL_TX_DATA_REGION_CAPACITY_CLI0, cli_data);
serial_queue_init(&cli_queue_handle[1],
(serial_queue_t *)((uintptr_t)cli_queue +
SERIAL_QUEUE_CAPACITY),
SERIAL_QUEUE_SIZE),
SERIAL_TX_DATA_REGION_CAPACITY_CLI1,
cli_data + SERIAL_TX_DATA_REGION_CAPACITY_CLI0);
}
Expand Down

0 comments on commit 2c4a507

Please sign in to comment.