Skip to content
Open
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
4 changes: 2 additions & 2 deletions lib/src/mt_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -1696,14 +1696,14 @@ static inline bool mt_if_has_hdr_split(struct mtl_main_impl* impl, enum mtl_port
return false;
}

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
static inline bool mt_if_has_packet_loss_simulation(struct mtl_main_impl* impl) {
if (mt_get_user_params(impl)->flags & MTL_FLAG_REDUNDANT_SIMULATE_PACKET_LOSS)
return true;
else
return false;
}
#endif /* MTL_SIMULATE_PAKET_DROPS */
#endif /* MTL_SIMULATE_PACKET_DROPS */

static inline struct rte_mempool* mt_if_hdr_split_pool(struct mt_interface* inf,
uint16_t q) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/st2110/pipeline/st30_pipeline_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int st30p_tx_late_frame_drop(void* handle, uint64_t epoch_skipped) {
}

tx_st30p_notify_frame_available(ctx);
MT_USDT_ST30P_TX_FRAME_DONE(ctx->idx, framebuff->idx, framebuff->frame.rtp_timestamp);
MT_USDT_ST30P_TX_FRAME_DROP(ctx->idx, framebuff->idx, framebuff->frame.rtp_timestamp);

return 0;
}
Expand Down Expand Up @@ -168,7 +168,7 @@ static int tx_st30p_frame_done(void* priv, uint16_t frame_idx,
/* notify app can get frame */
tx_st30p_notify_frame_available(ctx);

MT_USDT_ST30P_TX_FRAME_DROP(ctx->idx, frame_idx, frame->rtp_timestamp);
MT_USDT_ST30P_TX_FRAME_DONE(ctx->idx, frame_idx, frame->rtp_timestamp);
return ret;
}

Expand Down
14 changes: 13 additions & 1 deletion lib/src/st2110/st_rx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,19 @@ static int rv_init_slot(struct st_rx_video_session_impl* s) {
}
}
s->slot_idx = -1;
s->slot_max = ST_VIDEO_RX_REC_NUM_OFO;

if (s->ops.flags & ST20_RX_FLAG_ENABLE_RTCP)
s->slot_max = ST_RX_VIDEO_RTCP_SLOT_NUM;
else if (s->ops.num_port > 1)
s->slot_max = ST_RX_VIDEO_REDUNDANT_SLOT_NUM;
else
s->slot_max = 1;

if (s->slot_max > ST_VIDEO_RX_REC_NUM_OFO) {
err("%s(%d), slot_max %d exceed max %d\n", __func__, idx, s->slot_max,
ST_VIDEO_RX_REC_NUM_OFO);
return -EINVAL;
}

dbg("%s(%d), succ\n", __func__, idx);
return 0;
Expand Down
6 changes: 6 additions & 0 deletions lib/src/st2110/st_rx_video_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include "st_main.h"

#define ST_RX_VIDEO_DMA_MIN_SIZE (1024)
/* Number of slots for out of order packet recovery for RTCP retransmission
cannot be bigger than ST_VIDEO_RX_REC_NUM_OFO*/
#define ST_RX_VIDEO_RTCP_SLOT_NUM 2

/* Number of slots for redundant support */
#define ST_RX_VIDEO_REDUNDANT_SLOT_NUM 2

#define ST_RV_TP_TSC_SYNC_MS (100) /* sync tsc with ptp period(ms) */
#define ST_RV_TP_TSC_SYNC_NS (ST_RV_TP_TSC_SYNC_MS * 1000 * 1000)
Expand Down
24 changes: 12 additions & 12 deletions lib/src/st2110/st_tx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "st_err.h"
#include "st_video_transmitter.h"

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
static inline void tv_simulate_packet_loss(struct st_tx_video_session_impl* s,
struct rte_ipv4_hdr* ipv4,
enum mtl_session_port session_port) {
Expand Down Expand Up @@ -44,7 +44,7 @@ static inline void tv_simulate_packet_loss(struct st_tx_video_session_impl* s,
ipv4->hdr_checksum = rte_ipv4_cksum(ipv4);
}
}
#endif /* MTL_SIMULATE_PAKET_DROPS */
#endif /* MTL_SIMULATE_PACKET_DROPS */

static inline uint64_t tai_from_frame_count(struct st_tx_video_pacing* pacing,
uint64_t frame_count) {
Expand Down Expand Up @@ -1003,7 +1003,7 @@ static int tv_build_st20_redundant(struct st_tx_video_session_impl* s,
rte_memcpy(hdr, &s->s_hdr[MTL_SESSION_PORT_R], sizeof(*hdr));
mt_mbuf_init_ipv4(pkt_r);

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_R);
#endif

Expand Down Expand Up @@ -1047,7 +1047,7 @@ static int tv_build_st20(struct st_tx_video_session_impl* s, struct rte_mbuf* pk
/* copy the basic hdrs: eth, ip, udp, rtp */
rte_memcpy(hdr, &s->s_hdr[MTL_SESSION_PORT_P], sizeof(*hdr));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_P);
#endif

Expand Down Expand Up @@ -1153,7 +1153,7 @@ static int tv_build_st20_chain(struct st_tx_video_session_impl* s, struct rte_mb
/* copy the hdr: eth, ip, udp, rtp */
rte_memcpy(hdr, &s->s_hdr[MTL_SESSION_PORT_P], sizeof(*hdr));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_P);
#endif

Expand Down Expand Up @@ -1269,7 +1269,7 @@ static int tv_build_st20_redundant_chain(struct st_tx_video_session_impl* s,
/* copy the hdr: eth, ip, udp, rtp */
rte_memcpy(hdr, &s->s_hdr[MTL_SESSION_PORT_R], sizeof(*hdr));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_R);
#endif

Expand Down Expand Up @@ -1324,7 +1324,7 @@ static int tv_build_rtp(struct mtl_main_impl* impl, struct st_tx_video_session_i
rte_memcpy(ipv4, &s->s_hdr[MTL_SESSION_PORT_P].ipv4, sizeof(hdr->ipv4));
rte_memcpy(udp, &s->s_hdr[MTL_SESSION_PORT_P].udp, sizeof(hdr->udp));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_P);
#endif

Expand Down Expand Up @@ -1397,7 +1397,7 @@ static int tv_build_rtp_chain(struct mtl_main_impl* impl,
rte_memcpy(ipv4, &s->s_hdr[MTL_SESSION_PORT_P].ipv4, sizeof(hdr->ipv4));
rte_memcpy(udp, &s->s_hdr[MTL_SESSION_PORT_P].udp, sizeof(hdr->udp));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_P);
#endif

Expand Down Expand Up @@ -1470,7 +1470,7 @@ static int tv_build_rtp_redundant_chain(struct st_tx_video_session_impl* s,
rte_memcpy(ipv4, &s->s_hdr[MTL_SESSION_PORT_R].ipv4, sizeof(hdr->ipv4));
rte_memcpy(&hdr->udp, &s->s_hdr[MTL_SESSION_PORT_R].udp, sizeof(hdr->udp));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_R);
#endif

Expand Down Expand Up @@ -1515,7 +1515,7 @@ static int tv_build_st22(struct st_tx_video_session_impl* s, struct rte_mbuf* pk
/* copy rtp */
rte_memcpy(rtp, &st22_info->rtp_hdr[MTL_SESSION_PORT_P], sizeof(*rtp));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_P);
#endif

Expand Down Expand Up @@ -1593,7 +1593,7 @@ static int tv_build_st22_chain(struct st_tx_video_session_impl* s, struct rte_mb
/* copy rtp */
rte_memcpy(rtp, &st22_info->rtp_hdr[MTL_SESSION_PORT_P], sizeof(*rtp));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_P);
#endif

Expand Down Expand Up @@ -1679,7 +1679,7 @@ static int tv_build_st22_redundant_chain(struct st_tx_video_session_impl* s,
/* copy the hdr: eth, ip, udp, rtp */
rte_memcpy(hdr, &s->s_hdr[MTL_SESSION_PORT_R], sizeof(*hdr));

#ifdef MTL_SIMULATE_PAKET_DROPS
#ifdef MTL_SIMULATE_PACKET_DROPS
tv_simulate_packet_loss(s, ipv4, MTL_SESSION_PORT_R);
#endif

Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ if get_option('buildtype') == 'debug'
endif

if get_option('buildtype') != 'release'
add_global_arguments('-DMTL_SIMULATE_PAKET_DROPS=1', language : 'c')
add_global_arguments('-DMTL_SIMULATE_PACKET_DROPS=1', language : 'c')
add_global_arguments('-DMTL_SIMULATE_PACKET_DROPS=1', language : 'cpp')
endif

# enable BSD_SOURCE
Expand Down
5 changes: 5 additions & 0 deletions tests/integration_tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ sources = files('tests.cpp', 'st_test.cpp', 'st22_test.cpp', 'st30_test.cpp',
'st40_test.cpp', 'dma_test.cpp', 'cvt_test.cpp', 'st22p_test.cpp',
'st20p_test.cpp', 'test_util.cpp', 'sch_test.cpp', 'st30p_test.cpp')

if get_option('buildtype') != 'release'
add_global_arguments('-DMTL_SIMULATE_PACKET_DROPS=1', language : 'c')
add_global_arguments('-DMTL_SIMULATE_PACKET_DROPS=1', language : 'cpp')
endif

subdir('st20')
sources += st20_sources

Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/noctx/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ while IFS= read -r test_name || [ -n "$test_name" ]; do
echo "Test NoCtxTestTest.$test_name failed with exit code $?"
exit 1
fi

sleep 5;
done < <(echo "$test_names")
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void St30pUserTimestamp::initializeTiming(St30pHandler* handler) {
frameTimeNs = NS_PER_MS;
}

startingTime = static_cast<uint64_t>(frameTimeNs * 20);
startingTime = static_cast<uint64_t>(frameTimeNs * 60);
timingInitialized = true;
}

Expand All @@ -112,7 +112,7 @@ void St30pUserTimestamp::verifyReceiveTiming(uint64_t frame_idx, uint64_t receiv
uint64_t expected_timestamp_ns) const {
const int64_t delta_ns =
static_cast<int64_t>(receive_time_ns) - static_cast<int64_t>(expected_timestamp_ns);
int64_t expected_delta_ns = 40 * NS_PER_US;
int64_t expected_delta_ns = 40 * NS_PER_US;
if (frame_idx == 0) {
expected_delta_ns = 80 * NS_PER_US;
}
Expand Down
119 changes: 21 additions & 98 deletions tests/integration_tests/noctx/testcases/st20p_redundant_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,102 +7,6 @@
#include "handlers/st20p_handler.hpp"
#include "strategies/st20p_strategies.hpp"

TEST_F(NoCtxTest, st20p_redundant_latency) {
if (ctx->para.num_ports < 4) {
throw std::runtime_error("st20p_redundant_latency test ctx needs at least 4 ports");
}

initDefaultContext();

uint testedLatencyMs = 10;

auto rxBundle = createSt20pHandlerBundle(
/*createTx=*/false, /*createRx=*/true,
[](St20pHandler* handler) { return new St20pRedundantLatency(0, handler); },
[](St20pHandler* handler) {
handler->sessionsOpsTx.flags |= ST20P_TX_FLAG_USER_PACING;
handler->sessionsOpsTx.flags |= ST20P_TX_FLAG_USER_TIMESTAMP;
handler->setSessionPorts(SESSION_SKIP_PORT, 0, SESSION_SKIP_PORT, 1);
});
auto* rxStrategy = static_cast<St20pRedundantLatency*>(rxBundle.strategy);

auto primaryBundle = createSt20pHandlerBundle(
/*createTx=*/true, /*createRx=*/false,
[](St20pHandler* handler) { return new St20pRedundantLatency(0, handler); },
[](St20pHandler* handler) {
handler->sessionsOpsTx.flags |= ST20P_TX_FLAG_USER_PACING;
handler->sessionsOpsTx.flags |= ST20P_TX_FLAG_USER_TIMESTAMP;
handler->setSessionPorts(2, SESSION_SKIP_PORT, SESSION_SKIP_PORT,
SESSION_SKIP_PORT);
});
auto* primaryStrategy = static_cast<St20pRedundantLatency*>(primaryBundle.strategy);

auto latencyBundle = createSt20pHandlerBundle(
/*createTx=*/true, /*createRx=*/false,
[testedLatencyMs](St20pHandler* handler) {
return new St20pRedundantLatency(testedLatencyMs, handler);
},
[this, testedLatencyMs](St20pHandler* handler) {
handler->sessionsOpsTx.flags |= ST20P_TX_FLAG_USER_PACING;
handler->sessionsOpsTx.rtp_timestamp_delta_us = -1 * (testedLatencyMs * 1000);
handler->setSessionPorts(3, SESSION_SKIP_PORT, SESSION_SKIP_PORT,
SESSION_SKIP_PORT);
memcpy(handler->sessionsOpsTx.port.dip_addr[MTL_SESSION_PORT_P],
ctx->mcast_ip_addr[MTL_PORT_R], MTL_IP_ADDR_LEN);
handler->sessionsOpsTx.port.udp_port[MTL_SESSION_PORT_P]++;
});

/* we are creating 3 handlers
- rxBundle receives both primary and redundant streams
- primaryBundle sends the primary stream (no modifications)
- latencyBundle sends the redundant stream delayed by testedLatencyMs

[primaryBundle]: Tx ---> Rx [latencyBundle]
[latencyBundle]: Tx ---> Rx [latencyBundle]
*/

rxBundle.handler->startSessionRx();
ASSERT_TRUE(waitForSession(rxBundle.handler->session));
primaryBundle.handler->startSessionTx();
ASSERT_TRUE(waitForSession(primaryBundle.handler->session));
latencyBundle.handler->startSessionTx();
ASSERT_TRUE(waitForSession(latencyBundle.handler->session));

StartFakePtpClock(); // reset ptp time to 0
mtl_start(ctx->handle);
sleepUntilFailure(30);

latencyBundle.handler->session.stop();
primaryBundle.handler->session.stop();
rxBundle.handler->session.stop();

st20_rx_user_stats stats;
st20p_rx_get_session_stats(rxBundle.handler->sessionsHandleRx, &stats);
st20_tx_user_stats statsTxPrimary;
st20p_tx_get_session_stats(primaryBundle.handler->sessionsHandleTx, &statsTxPrimary);
st20_tx_user_stats statsTxRedundant;
st20p_tx_get_session_stats(latencyBundle.handler->sessionsHandleTx, &statsTxRedundant);

uint64_t packetsSend = statsTxPrimary.common.port[0].packets;
uint64_t packetsRecieved = stats.common.port[0].packets + stats.common.port[1].packets;
uint64_t framesSend = primaryStrategy->idx_tx;
uint64_t framesRecieved = rxStrategy->idx_rx;

ASSERT_NEAR(packetsSend, packetsRecieved, packetsSend / 100)
<< "Comparison against primary stream";
ASSERT_LE(stats.common.stat_pkts_out_of_order, packetsRecieved / 1000)
<< "Out of order packets";
ASSERT_NEAR(framesSend, framesRecieved, framesSend / 100)
<< "Comparison against primary stream";
}

/**
* This test requires MTL_SIMULATE_PAKET_DROPS to be enabled in the build.
* so DEBUG mode is necessary for proper functionality.
* The packet skip feature affects the critical path performance,
*/
#ifdef MTL_SIMULATE_PAKET_DROPS

#define TX_SESSION_PORT_0 0
#define TX_SESSION_PORT_1 1
#define RX_SESSION_PORT_0 2
Expand All @@ -113,6 +17,12 @@ TEST_F(NoCtxTest, st20p_redundant_latency_drops_even_odd) {
throw std::runtime_error("st20p_redundant_latency test ctx needs at least 4 ports");
}

/**
* This test requires MTL_SIMULATE_PACKET_DROPS to be enabled in the build.
* so DEBUG mode is necessary for proper functionality.
* The packet skip feature affects the critical path performance,
*/
#ifdef MTL_SIMULATE_PACKET_DROPS
ctx->para.flags |= MTL_FLAG_REDUNDANT_SIMULATE_PACKET_LOSS;
ctx->para.port_packet_loss[TX_SESSION_PORT_0].tx_stream_loss_id =
0; /* drop even packets */
Expand All @@ -122,10 +32,13 @@ TEST_F(NoCtxTest, st20p_redundant_latency_drops_even_odd) {
1; /* drop odd packets */
ctx->para.port_packet_loss[TX_SESSION_PORT_1].tx_stream_loss_divider =
2; /* out of every 2 packets */
#endif

initDefaultContext();

/* Class a */
uint testedLatencyMs = 10;
uint testDurationS = 120; /* 2 minutes */

auto rxBundle = createSt20pHandlerBundle(
/*createTx=*/false, /*createRx=*/true,
Expand Down Expand Up @@ -185,7 +98,7 @@ TEST_F(NoCtxTest, st20p_redundant_latency_drops_even_odd) {
mtl_start(ctx->handle);

ASSERT_TRUE(waitForSession(latencyBundle.handler->session));
sleepUntilFailure(600);
sleepUntilFailure(testDurationS);

latencyBundle.handler->session.stop();
primaryBundle.handler->session.stop();
Expand All @@ -203,5 +116,15 @@ TEST_F(NoCtxTest, st20p_redundant_latency_drops_even_odd) {

ASSERT_NEAR(framesSend, framesRecieved, framesSend / 100)
<< "Comparison against primary stream";

/* packets will not match exactly if we use redundant simulate packet loss */
if (!(ctx->para.flags & MTL_FLAG_REDUNDANT_SIMULATE_PACKET_LOSS)) {
uint64_t packetsSend = statsTxPrimary.common.port[TX_SESSION_PORT_0].packets + statsTxRedundant.common.port[TX_SESSION_PORT_1].packets;
uint64_t packetsRecieved = stats.common.port[TX_SESSION_PORT_0].packets + stats.common.port[TX_SESSION_PORT_1].packets;

ASSERT_NEAR(packetsSend, packetsRecieved, packetsSend / 100)
<< "Comparison against primary stream";
ASSERT_LE(stats.common.stat_pkts_out_of_order, packetsRecieved / 1000)
<< "Out of order packets";
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TEST_F(NoCtxTest, st30p_user_pacing) {
ASSERT_NE(strategy, nullptr);

strategy->initializeTiming(handler);
sleep(1);

StartFakePtpClock();
mtl_start(ctx->handle);
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/RxTxApp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if get_option('buildtype') != 'debug'
endif

if get_option('buildtype') != 'release'
add_global_arguments('-DMTL_SIMULATE_PAKET_DROPS=1', language : 'c')
add_global_arguments('-DMTL_SIMULATE_PACKET_DROPS=1', language : 'c')
endif

app_c_args += ['-Wall']
Expand Down