Skip to content
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
2 changes: 2 additions & 0 deletions Bdd/Targets/FreeRtos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ add_executable(SolidSyslogBddTarget
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosMutex.c
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosStaticResolver.c
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosSysUpTime.c
${CMAKE_SOURCE_DIR}/Platform/FreeRtos/Source/SolidSyslogFreeRtosTcpStream.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetInteractive.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetIps.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetLanguage.c
${CMAKE_SOURCE_DIR}/Bdd/Targets/Common/BddTargetSwitchConfig.c
$<TARGET_OBJECTS:solid_syslog_freertos_upstream>
)

Expand Down
18 changes: 12 additions & 6 deletions Bdd/Targets/FreeRtos/FreeRTOSIPConfig.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H

/* FreeRTOS-Plus-TCP configuration for the QEMU mps2-an385 bring-up smoke
* test (slice 3b.1 of S08.03). UDP-only, IPv4 static address, no DHCP / DNS /
* LLMNR / NBNS / TCP / IPv6. The smoke task creates a UDP socket and sends a
* single datagram to the slirp gateway (10.0.2.2:5514). */
/* FreeRTOS-Plus-TCP configuration for the QEMU mps2-an385 BDD target. UDP +
* TCP, IPv4 static address, no DHCP / DNS / LLMNR / NBNS / IPv6. UDP was
* brought up in S08.03; S08.09 enables TCP for the SolidSyslogFreeRtosTcpStream
* adapter so the SwitchingSender's TCP branch can land its frames on the
* syslog-ng oracle alongside the existing UDP scenarios. */

#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN

#define ipconfigUSE_IPv4 1
#define ipconfigUSE_IPv6 0
#define ipconfigUSE_RA 0
#define ipconfigUSE_TCP 0
#define ipconfigUSE_TCP 1
#define ipconfigTCP_KEEP_ALIVE 1
#define ipconfigTCP_KEEP_ALIVE_INTERVAL 10
#define ipconfigUSE_DHCP 0
#define ipconfigUSE_DHCPv6 0
#define ipconfigUSE_DHCP_HOOK 0
Expand All @@ -30,7 +33,10 @@
#define ipconfigSUPPORT_SELECT_FUNCTION 0
#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1

#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 8
/* Doubled from 8 — TCP needs descriptors for its retransmit window in
* addition to the in-flight UDP frames, and 8 is already tight on the BDD
* scenarios. The extra ~3 KB of .bss is trivial against mps2-an385 SRAM. */
#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 16
#define ipconfigEVENT_QUEUE_LENGTH (ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5)
#define ipconfigNETWORK_MTU 1500

Expand Down
60 changes: 56 additions & 4 deletions Bdd/Targets/FreeRtos/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "BddTargetInteractive.h"
#include "BddTargetIps.h"
#include "BddTargetLanguage.h"
#include "BddTargetSwitchConfig.h"
#include "SolidSyslog.h"
#include "SolidSyslogAtomicCounter.h"
#include "SolidSyslogCircularBuffer.h"
Expand All @@ -33,10 +34,13 @@
#include "SolidSyslogFreeRtosMutex.h"
#include "SolidSyslogFreeRtosStaticResolver.h"
#include "SolidSyslogFreeRtosSysUpTime.h"
#include "SolidSyslogFreeRtosTcpStream.h"
#include "SolidSyslogMetaSd.h"
#include "SolidSyslogNullStore.h"
#include "SolidSyslogOriginSd.h"
#include "SolidSyslogPrival.h"
#include "SolidSyslogStreamSender.h"
#include "SolidSyslogSwitchingSender.h"
#include "SolidSyslogTimeQuality.h"
#include "SolidSyslogTimeQualitySd.h"
#include "SolidSyslogUdpSender.h"
Expand Down Expand Up @@ -85,12 +89,17 @@
* Empirically the task hard-faults at *16 (8 KB) once the SolidSyslog
* setup runs — newlib printf and the formatter path together exceed that
* budget. *32 (16 KB) was stable while the line buffer was 256 B; the
* MAX_LINE_LENGTH bump to 2048 B in slice 6 adds ~4 KB peak (line + name
* frames) so *40 (20 KB) gives ~4 KB headroom. A follow-up will introduce
* MAX_LINE_LENGTH bump to 2048 B in slice 6 added ~4 KB peak (line + name
* frames) so *40 (20 KB) gave ~4 KB headroom. S08.09 adds a TCP path —
* StreamSender.Connect's address+host-formatter storage and
* TransmitFramed's prefix formatter consume an extra ~512 B of stack on
* top of the UDP-only chain — empirically tipping a *40 budget over the
* edge when the SwitchingSender flips transports under repeated sends.
* *48 (24 KB) restores ~4 KB headroom. A follow-up will introduce
* CMake-driven memory scaling once the budget is properly characterised.
* The task only exists in this single-task example, so heap_4 (96 KB)
* absorbs it. */
#define INTERACTIVE_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 40U)
#define INTERACTIVE_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 48U)

/* Static IPv4 wiring matching the QEMU slirp default. 10.0.2.15 is the
* standard slirp DHCP-allocated guest address; we hardcode it here so no
Expand Down Expand Up @@ -134,6 +143,8 @@ static NetworkEndPoint_t networkEndPoint;

static SolidSyslogFreeRtosStaticResolverStorage resolverStorage;
static SolidSyslogFreeRtosDatagramStorage datagramStorage;
static SolidSyslogFreeRtosTcpStreamStorage tcpStreamStorage;
static SolidSyslogStreamSenderStorage tcpSenderStorage;

/* CircularBuffer + FreeRtosMutex composition for cross-task emission.
* 8 max-sized messages is comfortably above the 3-message BDD scenarios
Expand Down Expand Up @@ -306,6 +317,16 @@ static bool OnSet(const char* name, const char* value)
g_message.severity = (enum SolidSyslog_Severity) parsed;
return true;
}
if (strcmp(name, "transport") == 0)
{
/* Switching sender selector — "udp" / "tcp" / "tls" / "mtls" route
* through BddTargetSwitchConfig (Bdd/Targets/Common). The FreeRTOS
* target only wires UDP and TCP inner senders today; selecting tls
* falls through to the SwitchingSender's nil sender, surfacing the
* gap as a send failure rather than a crash. */
BddTargetSwitchConfig_SetByName(value);
return true;
}
return false;
}

Expand Down Expand Up @@ -355,7 +376,35 @@ static void InteractiveTask(void* argument)
.endpoint = GetEndpoint,
.endpointVersion = GetEndpointVersion,
};
struct SolidSyslogSender* sender = SolidSyslogUdpSender_Create(&udpConfig);
struct SolidSyslogSender* udpSender = SolidSyslogUdpSender_Create(&udpConfig);

/* Plain TCP path via the new FreeRTOS Plus-TCP stream adapter. Shares the
* UDP endpoint callbacks because the BDD oracle (syslog-ng) listens on the
* same host:port for both transports — the syslog-ng config in
* Bdd/syslog-ng/syslog-ng.conf has a TCP listener on 5514 alongside UDP. */
struct SolidSyslogStream* stream = SolidSyslogFreeRtosTcpStream_Create(&tcpStreamStorage);
struct SolidSyslogStreamSenderConfig tcpConfig = {
.resolver = resolver,
.stream = stream,
.endpoint = GetEndpoint,
.endpointVersion = GetEndpointVersion,
};
struct SolidSyslogSender* tcpSender = SolidSyslogStreamSender_Create(&tcpSenderStorage, &tcpConfig);

/* SwitchingSender lets `set transport <udp|tcp>` flip the active transport
* at runtime. Default to UDP so existing UDP-tagged scenarios stay green;
* `--transport tcp` flowing through the behave harness lands here as
* `set transport tcp` over the UART and switches before the first send. */
static struct SolidSyslogSender* inners[2];
inners[BDD_TARGET_SWITCH_UDP] = udpSender;
inners[BDD_TARGET_SWITCH_TCP] = tcpSender;
struct SolidSyslogSwitchingSenderConfig switchConfig = {
.senders = inners,
.senderCount = sizeof(inners) / sizeof(inners[0]),
.selector = BddTargetSwitchConfig_Selector,
};
BddTargetSwitchConfig_SetByName("udp");
struct SolidSyslogSender* sender = SolidSyslogSwitchingSender_Create(&switchConfig);

/* CircularBuffer drained by ServiceTask below, with a FreeRtosMutex
* gating concurrent producers (interactive task today; multi-task
Expand Down Expand Up @@ -412,6 +461,9 @@ static void InteractiveTask(void* argument)
SolidSyslogNullStore_Destroy();
SolidSyslogCircularBuffer_Destroy(buffer);
SolidSyslogFreeRtosMutex_Destroy(mutex);
SolidSyslogSwitchingSender_Destroy();
SolidSyslogStreamSender_Destroy(tcpSender);
SolidSyslogFreeRtosTcpStream_Destroy(stream);
SolidSyslogUdpSender_Destroy();
SolidSyslogFreeRtosDatagram_Destroy(datagram);
SolidSyslogFreeRtosStaticResolver_Destroy(resolver);
Expand Down
5 changes: 5 additions & 0 deletions Bdd/features/steps/target_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
"--severity": "severity",
"--msgid": "msgid",
"--message": "msg",
# `--transport <udp|tcp>` lands as `set transport <value>` on the UART;
# OnSet routes it through BddTargetSwitchConfig_SetByName to flip the
# SolidSyslogSwitchingSender's active inner sender. Added in S08.09 with
# the FreeRTOS TCP stream adapter.
"--transport": "transport",
}


Expand Down
27 changes: 27 additions & 0 deletions Platform/FreeRtos/Interface/SolidSyslogFreeRtosTcpStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef SOLIDSYSLOGFREERTOSTCPSTREAM_H
#define SOLIDSYSLOGFREERTOSTCPSTREAM_H

#include "ExternC.h"

#include <stdint.h>

EXTERN_C_BEGIN

struct SolidSyslogStream;

enum
{
SOLIDSYSLOG_FREERTOSTCPSTREAM_SIZE = sizeof(intptr_t) * 8
};

typedef struct
{
intptr_t slots[(SOLIDSYSLOG_FREERTOSTCPSTREAM_SIZE + sizeof(intptr_t) - 1) / sizeof(intptr_t)];
} SolidSyslogFreeRtosTcpStreamStorage;

struct SolidSyslogStream* SolidSyslogFreeRtosTcpStream_Create(SolidSyslogFreeRtosTcpStreamStorage * storage);
void SolidSyslogFreeRtosTcpStream_Destroy(struct SolidSyslogStream * stream);

EXTERN_C_END

#endif /* SOLIDSYSLOGFREERTOSTCPSTREAM_H */
Loading
Loading