Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
195a68c
add SHM POSIX example
JacobBarthelmeh Sep 2, 2025
ef114a4
refactor POSIX example
JacobBarthelmeh Sep 3, 2025
1133376
adjust CI test for refactor
JacobBarthelmeh Sep 3, 2025
ccb35ae
make example variables unique
JacobBarthelmeh Sep 3, 2025
6616109
refactor examples from feedback, provide arguments for benchmark appl…
JacobBarthelmeh Sep 12, 2025
c680830
remove debug prints and usleep call
JacobBarthelmeh Sep 12, 2025
558aff4
add -lm to client build for DH and initialize variable value
JacobBarthelmeh Sep 12, 2025
6448a42
fix for address set after rebase
JacobBarthelmeh Sep 12, 2025
8cf4e7d
account for potential overflow and resolve syntax
JacobBarthelmeh Sep 12, 2025
18c26b9
fix initialization of config structs in test case
JacobBarthelmeh Sep 12, 2025
6cf5795
simplify DMA feature and move NVM+RAMSIM into cfg file
JacobBarthelmeh Sep 14, 2025
e541383
add macro guard for example
JacobBarthelmeh Sep 14, 2025
b3da97a
revert comment out of no malloc define in example user settings header
JacobBarthelmeh Sep 15, 2025
28a8c8f
format fixes from git-clang-format
JacobBarthelmeh Sep 15, 2025
68481f0
update example README and change DMA ADDR macro to be generic
JacobBarthelmeh Sep 17, 2025
edc6703
remove unnecessary includes
JacobBarthelmeh Sep 17, 2025
ec6d0af
refactor out common DMA code sections
JacobBarthelmeh Sep 22, 2025
c913f85
rename example functions and run test all
JacobBarthelmeh Sep 22, 2025
f22fb17
add sanity check on benchnark transport type
JacobBarthelmeh Sep 22, 2025
8da879c
additional macro guards after rebase
JacobBarthelmeh Sep 22, 2025
81a6716
remove explicit set of dma config in test app, void return on functio…
JacobBarthelmeh Sep 22, 2025
fb29659
update examples Makefile and comments
JacobBarthelmeh Sep 22, 2025
95d6046
fixes to examples README
JacobBarthelmeh Sep 22, 2025
750648d
re-run git-clang-format
JacobBarthelmeh Sep 23, 2025
795f836
function and file rename, endif comments, fix examples README, macro …
JacobBarthelmeh Sep 23, 2025
e0a1169
rename example functions for better clarity
JacobBarthelmeh Sep 23, 2025
630ac53
narrow scope of heap hint set and get functions, make it specific to …
JacobBarthelmeh Sep 24, 2025
66bb141
adjustments to example Makefiles
JacobBarthelmeh Sep 24, 2025
3699d72
fix typo in benchmark printf and run git-clang-format
JacobBarthelmeh Sep 24, 2025
b5d1b53
run clang-format on posix_transport_shm.c to help out git-clang-forma…
JacobBarthelmeh Sep 24, 2025
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
43 changes: 28 additions & 15 deletions .github/workflows/build-and-run-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ on:

jobs:
build:

strategy:
matrix:
transport: [ 'tcp', 'shm', 'dma' ]
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@master
Expand All @@ -22,28 +25,38 @@ jobs:
path: wolfssl

# Build examples
- name: Build POSIX TCP server
run: cd examples/posix/tcp/wh_server_tcp && make -j WOLFSSL_DIR=../../../../wolfssl
- name: Build POSIX TCP client
run: cd examples/posix/tcp/wh_client_tcp && make -j WOLFSSL_DIR=../../../../wolfssl
- name: Build POSIX server
run: |
if [ "${{ matrix.transport }}" = "dma" ]; then
cd examples/posix/wh_posix_server && DMA=1 make -j WOLFSSL_DIR=../../../wolfssl
else
cd examples/posix/wh_posix_server && make -j WOLFSSL_DIR=../../../wolfssl
fi
- name: Build POSIX client
run: |
if [ "${{ matrix.transport }}" = "dma" ]; then
cd examples/posix/wh_posix_client && DMA=1 make -j WOLFSSL_DIR=../../../wolfssl
else
cd examples/posix/wh_posix_client && make -j WOLFSSL_DIR=../../../wolfssl
fi

# Start the server in the background
- name: Run POSIX TCP server
- name: Run POSIX server
run: |
cd examples/posix/tcp/wh_server_tcp
./Build/wh_server_tcp.elf &
TCP_SERVER_PID=$!
echo "TCP_SERVER_PID=$TCP_SERVER_PID" >> $GITHUB_ENV
cd examples/posix/wh_posix_server
./Build/wh_posix_server.elf --type ${{ matrix.transport }} &
POSIX_SERVER_PID=$!
echo "POSIX_SERVER_PID=$POSIX_SERVER_PID" >> $GITHUB_ENV

# Run the client that connects to the server
- name: Run POSIX TCP client
- name: Run POSIX client
run: |
cd examples/posix/tcp/wh_client_tcp
./Build/wh_client_tcp.elf
cd examples/posix/wh_posix_client
./Build/wh_posix_client.elf --type ${{ matrix.transport }}

# Optional: Kill the server process if it doesn't exit on its own
- name: Cleanup POSIX TCP server
- name: Cleanup POSIX server
if: always()
run: kill $TCP_SERVER_PID || true
run: kill $POSIX_SERVER_PID || true


16 changes: 8 additions & 8 deletions .github/workflows/build-and-test-clientonly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ jobs:
with:
repository: wolfssl/wolfssl
path: wolfssl

# Build example server
- name: Build POSIX TCP server
- name: Build POSIX server
run: |
cd examples/posix/tcp/wh_server_tcp
make -j SHE=1 WOLFSSL_DIR=../../../../wolfssl
cd examples/posix/wh_posix_server
make -j SHE=1 WOLFSSL_DIR=../../../wolfssl

# Start the server in the background
- name: Run POSIX TCP server
- name: Run POSIX server
run: |
cd examples/posix/tcp/wh_server_tcp
./Build/wh_server_tcp.elf &
cd examples/posix/wh_posix_server
./Build/wh_posix_server.elf &
TCP_SERVER_PID=$!
echo "TCP_SERVER_PID=$TCP_SERVER_PID" >> $GITHUB_ENV

Expand All @@ -54,4 +54,4 @@ jobs:
- name: Cleanup POSIX TCP server
if: always()
run: kill $TCP_SERVER_PID || true


6 changes: 5 additions & 1 deletion benchmark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ CFLAGS += $(DBGFLAGS)
LDFLAGS += $(DBGFLAGS)
endif

ifneq ($(DEBUG),1)
CFLAGS += -O2
endif


# Add address sanitizer option
ifeq ($(ASAN),1)
CFLAGS += -fsanitize=address
Expand Down Expand Up @@ -133,7 +138,6 @@ SRC_C += $(wildcard $(PROJECT_DIR)/*.c)
SRC_C += $(wildcard $(MODULES_DIR)/*.c)

## Automated processing below

FILENAMES_C = $(notdir $(SRC_C))
OBJS_C = $(addprefix $(BUILD_DIR)/, $(FILENAMES_C:.c=.o))
vpath %.c $(dir $(SRC_C))
Expand Down
43 changes: 40 additions & 3 deletions benchmark/bench_modules/wh_bench_mod_sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@
#include "wh_bench_mod.h"

#include "wolfhsm/wh_error.h"
#include "wolfhsm/wh_client_crypto.h"

#include "wolfssl/wolfcrypt/hash.h"
#include "wolfssl/wolfcrypt/sha256.h"

#if defined(WOLFHSM_CFG_BENCH_ENABLE)

#if defined(WOLFHSM_CFG_DMA) && defined(WOLFHSM_CFG_TEST_POSIX)
#include "port/posix/posix_transport_shm.h"
#endif /* WOLFHSM_CFG_DMA && WOLFHSM_CFG_POSIX_TRANSPORT */

#if !defined(NO_SHA256)

int _benchSha256(whClientContext* client, whBenchOpContext* ctx, int id,
Expand All @@ -33,17 +38,39 @@ int _benchSha256(whClientContext* client, whBenchOpContext* ctx, int id,
(void)client;

int ret = 0;
wc_Sha256 sha256[1];
uint8_t out[WC_SHA256_DIGEST_SIZE];
wc_Sha256* sha256 = NULL;
wc_Sha256 sha256Stack;
uint8_t outStack[WC_SHA256_DIGEST_SIZE];
uint8_t* out;
int i = 0;
int sha256Initialized = 0;
const uint8_t* in;
size_t inLen;

sha256 = &sha256Stack;
out = outStack;

#if defined(WOLFHSM_CFG_DMA)
if (devId == WH_DEV_ID_DMA) {
in = WH_BENCH_DMA_BUFFER;
inLen = WOLFHSM_CFG_BENCH_DMA_BUFFER_SIZE;
if (ctx->transportType == WH_BENCH_TRANSPORT_POSIX_DMA) {
/* if static memory was used with DMA then use XMALLOC */
void* heap =
posixTransportShm_GetDmaHeap(client->comm->transport_context);
in = XMALLOC(inLen, heap, DYNAMIC_TYPE_TMP_BUFFER);
if (in == NULL) {
WH_BENCH_PRINTF("Failed to allocate memory for DMA\n");
return WH_ERROR_NOSPACE;
}
out = XMALLOC(WC_SHA256_DIGEST_SIZE, heap, DYNAMIC_TYPE_TMP_BUFFER);
if (out == NULL) {
WH_BENCH_PRINTF("Failed to allocate memory for DMA\n");
return WH_ERROR_NOSPACE;
}
}
else {
in = WH_BENCH_DMA_BUFFER;
}
}
else
#endif
Expand Down Expand Up @@ -111,6 +138,16 @@ int _benchSha256(whClientContext* client, whBenchOpContext* ctx, int id,
(void)wc_Sha256Free(sha256);
}

#if defined(WOLFHSM_CFG_DMA)
if (devId == WH_DEV_ID_DMA &&
ctx->transportType == WH_BENCH_TRANSPORT_POSIX_DMA) {
/* if static memory was used with DMA then use XFREE */
void* heap =
posixTransportShm_GetDmaHeap(client->comm->transport_context);
XFREE((uint8_t*)in, heap, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(out, heap, DYNAMIC_TYPE_TMP_BUFFER);
}
#endif
return ret;
}

Expand Down
5 changes: 5 additions & 0 deletions benchmark/config/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ extern "C" {
#endif
#endif

#ifdef WOLFHSM_CFG_DMA
/* use static memory to divide up DMA shared buffer */
#undef WOLFSSL_STATIC_MEMORY
#define WOLFSSL_STATIC_MEMORY
#endif

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/config/wolfhsm_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define WOLFHSM_CFG_SERVER_KEYCACHE_BUFSIZE 300
#define WOLFHSM_CFG_SERVER_KEYCACHE_BIG_COUNT 2
#define WOLFHSM_CFG_SERVER_KEYCACHE_BIG_BUFSIZE WOLFHSM_CFG_COMM_DATA_LEN
#define WOLFHSM_CFG_SERVER_DMAADDR_COUNT 8
#define WOLFHSM_CFG_DMAADDR_COUNT 8
#define WOLFHSM_CFG_SERVER_CUSTOMCB_COUNT 6

#define WOLFHSM_CFG_CERTIFICATE_MANAGER
Expand Down
Loading