Skip to content

Commit

Permalink
rx/timing_parser: rename and control on session level (#633)
Browse files Browse the repository at this point in the history
Add ST20_RX_FLAG_ENABLE_TIMING_PARSER and
ST30_RX_FLAG_ENABLE_TIMING_PARSER

test with:
./build/app/RxTxApp --config_file
tests/script/loop_json/unicast_1v_1a_1anc.json --rx_timing_parser

MT: 2023-12-08 11:15:27, rv_tp_stat(0), COMPLIANT NARROW 598 WIDE 0
FAILED 1!
MT: 2023-12-08 11:15:27, rv_tp_stat(0), Cinst AVG 0.00 MIN 0 MAX 1!
MT: 2023-12-08 11:15:27, rv_tp_stat(0), VRX AVG 6.50 MIN -21 MAX 8!
MT: 2023-12-08 11:15:27, rv_tp_stat(0), Inter-packet time(ns) AVG
3891.00 MIN 0 MAX 10496!
MT: 2023-12-08 11:15:27, rv_tp_stat(0), FPT AVG 614819.50 MIN 613426 MAX
617580 DIFF 4154!
MT: 2023-12-08 11:15:27, rv_tp_stat(0), LATENCY AVG 9272.67 MIN 2314 MAX
17580!
MT: 2023-12-08 11:15:27, rv_tp_stat(0), RTP OFFSET AVG 54.50 MIN 54 MAX
55!
MT: 2023-12-08 11:15:27, rv_tp_stat(0), RTP TS DELTA AVG 1501.50 MIN
1501 MAX 1502!
MT: 2023-12-08 11:15:27, RX_AUDIO_SESSION(0,0:app_rx_audio0): fps
999.914135, st30 received frames 9997, received pkts 9997
MT: 2023-12-08 11:15:27, ra_tp_stat(0), COMPLIANT NARROW 9997 WIDE 0
FAILED 0!
MT: 2023-12-08 11:15:27, ra_tp_stat(0), dpvr AVG 5.37 MIN 3 MAX 6,
pkt_cnt 9997
MT: 2023-12-08 11:15:27, ra_tp_stat(0), tsdf 3

Signed-off-by: Frank Du <[email protected]>
  • Loading branch information
frankdjx authored Dec 8, 2023
1 parent fde8c05 commit 4943d31
Show file tree
Hide file tree
Showing 27 changed files with 638 additions and 638 deletions.
1 change: 1 addition & 0 deletions app/src/app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ struct st_app_context {
bool enable_hdr_split;
bool tx_copy_once;
bool app_thread;
bool enable_timing_parser;

bool ptp_systime_sync;
int ptp_sync_cnt;
Expand Down
9 changes: 5 additions & 4 deletions app/src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum st_args_cmd {
ST_ARG_TEST_TIME,
ST_ARG_PTP_UNICAST_ADDR,
ST_ARG_CNI_THREAD,
ST_ARG_RX_EBU,
ST_ARG_RX_TIMING_PARSER,
ST_ARG_USER_LCORES,
ST_ARG_SCH_DATA_QUOTA,
ST_ARG_SCH_SESSION_QUOTA,
Expand Down Expand Up @@ -182,7 +182,7 @@ static struct option st_app_args_options[] = {
{"test_time", required_argument, 0, ST_ARG_TEST_TIME},
{"ptp_unicast", no_argument, 0, ST_ARG_PTP_UNICAST_ADDR},
{"cni_thread", no_argument, 0, ST_ARG_CNI_THREAD},
{"ebu", no_argument, 0, ST_ARG_RX_EBU},
{"rx_timing_parser", no_argument, 0, ST_ARG_RX_TIMING_PARSER},
{"lcores", required_argument, 0, ST_ARG_USER_LCORES},
{"sch_data_quota", required_argument, 0, ST_ARG_SCH_DATA_QUOTA},
{"sch_session_quota", required_argument, 0, ST_ARG_SCH_SESSION_QUOTA},
Expand Down Expand Up @@ -528,8 +528,9 @@ int st_app_parse_args(struct st_app_context* ctx, struct mtl_init_params* p, int
case ST_ARG_TEST_TIME:
ctx->test_time_s = atoi(optarg);
break;
case ST_ARG_RX_EBU:
p->flags |= MTL_FLAG_RX_VIDEO_EBU;
case ST_ARG_RX_TIMING_PARSER:
ctx->enable_timing_parser = true;
p->flags |= MTL_FLAG_ENABLE_HW_TIMESTAMP;
break;
case ST_ARG_RX_MONO_POOL:
p->flags |= MTL_FLAG_RX_MONO_POOL;
Expand Down
1 change: 1 addition & 0 deletions app/src/rx_audio_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ static int app_rx_audio_init(struct st_app_context* ctx, st_json_audio_session_t
ops.framebuff_cnt = s->framebuff_cnt;
ops.rtp_ring_size = ctx->rx_audio_rtp_ring_size ? ctx->rx_audio_rtp_ring_size : 16;
if (audio && audio->enable_rtcp) ops.flags |= ST30_RX_FLAG_ENABLE_RTCP;
if (ctx->enable_timing_parser) ops.flags |= ST30_RX_FLAG_ENABLE_TIMING_PARSER;

st_pthread_mutex_init(&s->st30_wake_mutex, NULL);
st_pthread_cond_init(&s->st30_wake_cond, NULL);
Expand Down
1 change: 1 addition & 0 deletions app/src/rx_st20p_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ static int app_rx_st20p_init(struct st_app_context* ctx,
/* always try to enable DMA offload */
ops.flags = ST20P_RX_FLAG_DMA_OFFLOAD;
if (st20p && st20p->enable_rtcp) ops.flags |= ST20P_RX_FLAG_ENABLE_RTCP;
if (ctx->enable_timing_parser) ops.flags |= ST20P_RX_FLAG_ENABLE_TIMING_PARSER;

st_pthread_mutex_init(&s->st20p_wake_mutex, NULL);
st_pthread_cond_init(&s->st20p_wake_cond, NULL);
Expand Down
1 change: 1 addition & 0 deletions app/src/rx_video_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ static int app_rx_video_init(struct st_app_context* ctx, st_json_video_session_t
ops_rtcp.nack_interval_us = 250;
ops.rtcp = &ops_rtcp;
}
if (ctx->enable_timing_parser) ops.flags |= ST20_RX_FLAG_ENABLE_TIMING_PARSER;

st_pthread_mutex_init(&s->st20_wake_mutex, NULL);
st_pthread_cond_init(&s->st20_wake_cond, NULL);
Expand Down
2 changes: 1 addition & 1 deletion doc/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ If it failed to run the sample, please help to collect the system setup status b
--log_file <file path> : set log file for mtl log. If you're initiating multiple RxTxApp processes simultaneously, please ensure each process has a unique filename path. Default the log is writing to stderr.
--arp_timeout_s <sec> : set the arp timeout in seconds if using unicast address. Default timeout value is 60 seconds.
--ebu : debug option, enable timing check for video rx streams.
--rx_timing_parser : debug option, enable timing check for video rx streams.
--pcapng_dump <n> : debug option, dump n packets from rx video streams to pcapng files.
--rx_video_file_frames <n> : debug option, dump the received video frames to a yuv file, n is dump file size in frame unit.
--rx_video_fb_cnt<n> : debug option, the frame buffer count.
Expand Down
5 changes: 3 additions & 2 deletions include/mtl_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,10 @@ enum st21_tx_pacing_way {
#define MTL_FLAG_CNI_THREAD (MTL_BIT64(32))
/**
* Flag bit in flags of struct mtl_init_params, debug usage only.
* Enable video rx ebu check
* Enable HW offload timestamp for all RX packets target the compliance analyze. Only can
* work for PF on E810 now.
*/
#define MTL_FLAG_RX_VIDEO_EBU (MTL_BIT64(33))
#define MTL_FLAG_ENABLE_HW_TIMESTAMP (MTL_BIT64(33))
/**
* Flag bit in flags of struct mtl_init_params, debug usage only.
* Enable NIC promiscuous mode for RX
Expand Down
5 changes: 5 additions & 0 deletions include/st20_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ extern "C" {
* Always disable MIGRATE for this session.
*/
#define ST20_RX_FLAG_DISABLE_MIGRATE (MTL_BIT32(20))
/**
* Flag bit in flags of struct st20_rx_ops.
* Enable the timing analyze
*/
#define ST20_RX_FLAG_ENABLE_TIMING_PARSER (MTL_BIT32(21))

/**
* Flag bit in flags of struct st22_rx_ops, for non MTL_PMD_DPDK_USER.
Expand Down
5 changes: 5 additions & 0 deletions include/st30_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ typedef struct st_rx_audio_session_handle_impl* st30_rx_handle;
* If enable the rtcp.
*/
#define ST30_RX_FLAG_ENABLE_RTCP (MTL_BIT32(1))
/**
* Flag bit in flags of struct st30_rx_ops.
* Enable the timing analyze
*/
#define ST30_RX_FLAG_ENABLE_TIMING_PARSER (MTL_BIT32(16))

/** default time in the fifo between packet builder and pacing */
#define ST30_TX_FIFO_DEFAULT_TIME_MS (10)
Expand Down
5 changes: 5 additions & 0 deletions include/st_pipeline_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,11 @@ enum st22_quality_mode {
* Always disable MIGRATE for this session.
*/
#define ST20P_RX_FLAG_DISABLE_MIGRATE (MTL_BIT32(20))
/**
* Flag bit in flags of struct st20p_rx_ops.
* Enable the timing analyze
*/
#define ST20P_RX_FLAG_ENABLE_TIMING_PARSER (MTL_BIT32(21))

/** The structure info for st plugin encode session create request. */
struct st22_encoder_create_req {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/dev/mt_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ int mt_dev_create(struct mtl_main_impl* impl) {

#if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0)
/* DPDK 21.11 support start time sync before rte_eth_dev_start */
if ((mt_user_ptp_service(impl) || mt_user_ebu_active(impl)) &&
if ((mt_user_ptp_service(impl) || mt_user_hw_timestamp(impl)) &&
(port_type == MT_PORT_PF)) {
ret = dev_start_timesync(inf);
if (ret >= 0) inf->feature |= MT_IF_FEATURE_TIMESYNC;
Expand Down Expand Up @@ -1798,7 +1798,7 @@ int mt_dev_create(struct mtl_main_impl* impl) {
}
}
/* try to start time sync after rte_eth_dev_start */
if ((mt_user_ptp_service(impl) || mt_user_ebu_active(impl)) &&
if ((mt_user_ptp_service(impl) || mt_user_hw_timestamp(impl)) &&
(port_type == MT_PORT_PF) && !(inf->feature & MT_IF_FEATURE_TIMESYNC)) {
ret = dev_start_timesync(inf);
if (ret >= 0) inf->feature |= MT_IF_FEATURE_TIMESYNC;
Expand Down Expand Up @@ -2192,7 +2192,7 @@ int mt_dev_if_init(struct mtl_main_impl* impl) {
}
#endif

if (mt_user_ebu_active(impl) &&
if (mt_user_hw_timestamp(impl) &&
#if RTE_VERSION >= RTE_VERSION_NUM(22, 3, 0, 0)
(dev_info->rx_offload_capa & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
#else
Expand Down
18 changes: 13 additions & 5 deletions lib/src/mt_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -1397,9 +1397,9 @@ static inline bool mt_user_quota_active(struct mtl_main_impl* impl) {
return false;
}

/* if user enable ebu feature */
static inline bool mt_user_ebu_active(struct mtl_main_impl* impl) {
if (mt_get_user_params(impl)->flags & MTL_FLAG_RX_VIDEO_EBU)
/* if user enable hw offload timestamp */
static inline bool mt_user_hw_timestamp(struct mtl_main_impl* impl) {
if (mt_get_user_params(impl)->flags & MTL_FLAG_ENABLE_HW_TIMESTAMP)
return true;
else
return false;
Expand Down Expand Up @@ -1582,6 +1582,14 @@ static inline bool mt_if_has_timesync(struct mtl_main_impl* impl, enum mtl_port
return false;
}

static inline bool mt_if_has_offload_timestamp(struct mtl_main_impl* impl,
enum mtl_port port) {
if (mt_if(impl, port)->feature & MT_IF_FEATURE_RX_OFFLOAD_TIMESTAMP)
return true;
else
return false;
}

static inline bool mt_if_has_offload_ipv4_cksum(struct mtl_main_impl* impl,
enum mtl_port port) {
if (mt_if(impl, port)->feature & MT_IF_FEATURE_TX_OFFLOAD_IPV4_CKSUM)
Expand Down Expand Up @@ -1838,8 +1846,8 @@ struct rte_mbuf* mt_pcapng_copy(struct mtl_main_impl* impl, enum mtl_port port,
enum rte_pcapng_direction direction);
#endif

uint64_t mt_mbuf_hw_time_stamp(struct mtl_main_impl* impl, struct rte_mbuf* mbuf,
enum mtl_port port);
uint64_t mt_mbuf_time_stamp(struct mtl_main_impl* impl, struct rte_mbuf* mbuf,
enum mtl_port port);

static inline uint64_t mt_get_ptp_time(struct mtl_main_impl* impl, enum mtl_port port) {
return mt_if(impl, port)->ptp_get_time_fn(impl, port);
Expand Down
37 changes: 16 additions & 21 deletions lib/src/mt_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define MT_PTP_CHECK_RX_TIME_STAMP (0)
#define MT_PTP_PRINT_ERR_RESULT (0)

#define MT_PTP_EBU_SYNC_MS (10)
#define MT_PTP_TP_SYNC_MS (10)

#define MT_PTP_DEFAULT_KP 5e-10 /* to be tuned */
#define MT_PTP_DEFAULT_KI 1e-10 /* to be tuned */
Expand Down Expand Up @@ -1070,7 +1070,7 @@ static void ptp_sync_from_user_handler(void* param) {
struct mt_ptp_impl* ptp = param;

ptp_sync_from_user(ptp->impl, ptp);
rte_eal_alarm_set(MT_PTP_EBU_SYNC_MS * 1000, ptp_sync_from_user_handler, ptp);
rte_eal_alarm_set(MT_PTP_TP_SYNC_MS * 1000, ptp_sync_from_user_handler, ptp);
}

#ifdef WINDOWSENV
Expand Down Expand Up @@ -1233,11 +1233,11 @@ static int ptp_init(struct mtl_main_impl* impl, struct mt_ptp_impl* ptp,
ptp_coefficient_result_reset(ptp);

if (!mt_user_ptp_service(impl)) {
if (mt_user_ebu_active(impl)) {
if (mt_if_has_offload_timestamp(impl, port)) {
ptp->no_timesync = true;
info("%s(%d), ptp running for ebu without time sync\n", __func__, port);
info("%s(%d), ptp sync from user for hw offload timestamp\n", __func__, port);
ptp_sync_from_user(impl, ptp);
rte_eal_alarm_set(MT_PTP_EBU_SYNC_MS * 1000, ptp_sync_from_user_handler, ptp);
rte_eal_alarm_set(MT_PTP_TP_SYNC_MS * 1000, ptp_sync_from_user_handler, ptp);
ptp->connected = true;
ptp->locked = true;
ptp->active = true;
Expand Down Expand Up @@ -1397,7 +1397,6 @@ int mt_ptp_parse(struct mt_ptp_impl* ptp, struct mt_ptp_header* hdr, bool vlan,

static int ptp_stat(void* priv) {
struct mt_ptp_impl* ptp = priv;
struct mtl_main_impl* impl = ptp->impl;
enum mtl_port port = ptp->port;
char date_time[64];
struct timespec spec;
Expand All @@ -1411,19 +1410,7 @@ static int ptp_stat(void* priv) {
strftime(date_time, sizeof(date_time), "%Y-%m-%d %H:%M:%S", &t);
notice("PTP(%d): time %" PRIu64 ", %s\n", port, ns, date_time);

if (!ptp->active) {
if (mt_user_ebu_active(impl)) {
notice("PTP(%d): raw ptp %" PRIu64 "\n", port, ptp_get_raw_time(ptp));
if (ptp->stat_delta_cnt) {
notice("PTP(%d): delta avr %" PRId64 ", min %" PRId64 ", max %" PRId64
", cnt %d, expect %d\n",
port, ptp->stat_delta_sum / ptp->stat_delta_cnt, ptp->stat_delta_min,
ptp->stat_delta_max, ptp->stat_delta_cnt, ptp->expect_result_avg);
}
ptp_stat_clear(ptp);
}
return 0;
}
if (!ptp->active) return 0;

if (ptp->stat_delta_cnt) {
if (ptp->phc2sys_active) {
Expand Down Expand Up @@ -1514,15 +1501,23 @@ uint64_t mt_get_raw_ptp_time(struct mtl_main_impl* impl, enum mtl_port port) {
return ptp_get_raw_time(mt_get_ptp(impl, port));
}

uint64_t mt_mbuf_hw_time_stamp(struct mtl_main_impl* impl, struct rte_mbuf* mbuf,
enum mtl_port port) {
static uint64_t mbuf_hw_time_stamp(struct mtl_main_impl* impl, struct rte_mbuf* mbuf,
enum mtl_port port) {
struct mt_ptp_impl* ptp = mt_get_ptp(impl, port);
uint64_t time_stamp =
*RTE_MBUF_DYNFIELD(mbuf, impl->dynfield_offset, rte_mbuf_timestamp_t*);
time_stamp += ptp->ptp_delta;
return ptp_correct_ts(ptp, time_stamp);
}

uint64_t mt_mbuf_time_stamp(struct mtl_main_impl* impl, struct rte_mbuf* mbuf,
enum mtl_port port) {
if (mt_if_has_offload_timestamp(impl, port))
return mbuf_hw_time_stamp(impl, mbuf, port);
else
return mtl_ptp_read_time(impl);
}

int mt_ptp_wait_stable(struct mtl_main_impl* impl, enum mtl_port port, int timeout_ms) {
struct mt_ptp_impl* ptp = mt_get_ptp(impl, port);
uint64_t start_ts = mt_get_tsc(impl);
Expand Down
4 changes: 4 additions & 0 deletions lib/src/mt_ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ int mt_ptp_parse(struct mt_ptp_impl* ptp, struct mt_ptp_header* hdr, bool vlan,
enum mt_ptp_l_mode mode, uint16_t timesync,
struct mt_ipv4_udp* ipv4_hdr);

static inline bool mt_ptp_is_active(struct mtl_main_impl* impl, enum mtl_port port) {
return mt_get_ptp(impl, port)->active;
}

static inline bool mt_ptp_is_locked(struct mtl_main_impl* impl, enum mtl_port port) {
return mt_get_ptp(impl, port)->locked;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/st2110/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sources += files(
'st_avx512_vbmi.c',
'st_convert.c',
'st_fmt.c',
'st_rx_ebu.c',
'st_rx_timing_parser.c',
)

subdir('pipeline')
Expand Down
2 changes: 2 additions & 0 deletions lib/src/st2110/pipeline/st20_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ static int rx_st20p_create_transport(struct mtl_main_impl* impl, struct st20p_rx
if (ops->flags & ST20P_RX_FLAG_HDR_SPLIT) ops_rx.flags |= ST20_RX_FLAG_HDR_SPLIT;
if (ops->flags & ST20P_RX_FLAG_DISABLE_MIGRATE)
ops_rx.flags |= ST20_RX_FLAG_DISABLE_MIGRATE;
if (ops->flags & ST20P_RX_FLAG_ENABLE_TIMING_PARSER)
ops_rx.flags |= ST20_RX_FLAG_ENABLE_TIMING_PARSER;
if (ops->flags & ST20P_RX_FLAG_PKT_CONVERT) {
uint64_t pkt_cvt_output_cap =
ST_FMT_CAP_YUV422PLANAR10LE | ST_FMT_CAP_Y210 | ST_FMT_CAP_UYVY;
Expand Down
Loading

0 comments on commit 4943d31

Please sign in to comment.