Skip to content

Commit c721248

Browse files
Fix: adress review comments
1 parent 43bd78a commit c721248

18 files changed

+232
-116
lines changed

include/experimental/st40_pipeline_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct st40p_tx_ops {
148148
* - >=0 succ.
149149
* - <0: Error code.
150150
*/
151-
int st40p_tx_get_session_stats(st40p_tx_handle handle, struct st40_tx_users_stats* stats);
151+
int st40p_tx_get_session_stats(st40p_tx_handle handle, struct st40_tx_user_stats* stats);
152152

153153
/**
154154
* Reset the general statistics(I/O) for one rx st2110-40(pipeline) session.

include/st40_api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ struct st40_rx_ops {
404404
/**
405405
* A structure used to retrieve general statistics(I/O) for a st40 tx session.
406406
*/
407-
struct st40_tx_users_stats {
407+
struct st40_tx_user_stats {
408408
struct st_tx_port_stats port[MTL_SESSION_PORT_MAX];
409409
uint64_t stat_epoch_mismatch;
410410
uint64_t stat_epoch_drop;
@@ -445,7 +445,7 @@ struct st40_rx_user_stats {
445445
* - >=0 succ.
446446
* - <0: Error code.
447447
*/
448-
int st40_tx_get_session_stats(st40_tx_handle handle, struct st40_tx_users_stats* stats);
448+
int st40_tx_get_session_stats(st40_tx_handle handle, struct st40_tx_user_stats* stats);
449449

450450
/**
451451
* Reset the general statistics(I/O) for one tx st2110-40(ancillary) session.

include/st41_api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ struct st41_rx_ops {
280280
/**
281281
* A structure used to retrieve general statistics(I/O) for a st41 tx port.
282282
*/
283-
struct st41_tx_users_stats {
283+
struct st41_tx_user_stats {
284284
struct st_tx_port_stats
285285
port[MTL_SESSION_PORT_MAX]; /**< Base structure for tx port stats */
286286
uint64_t stat_pkts_redundant;
@@ -331,7 +331,7 @@ struct st41_rx_user_stats {
331331
* - >=0 succ.
332332
* - <0: Error code.
333333
*/
334-
int st41_tx_get_session_stats(st41_tx_handle handle, struct st41_tx_users_stats* stats);
334+
int st41_tx_get_session_stats(st41_tx_handle handle, struct st41_tx_user_stats* stats);
335335

336336
/**
337337
* Reset the general statistics(I/O) for one tx st2110-41(fastmetadata) session.

lib/src/st2110/experimental/st40_pipeline_tx.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,16 @@ void* st40p_tx_get_fb_addr(st40p_tx_handle handle, uint16_t idx) {
662662
}
663663

664664
int st40p_tx_get_session_stats(st40p_tx_handle handle,
665-
struct st40_tx_users_stats* stats) {
665+
struct st40_tx_user_stats* stats) {
666666
struct st40p_tx_ctx* ctx = handle;
667-
int cidx = ctx->idx;
667+
int cidx;
668+
669+
if(!handle || !stats) {
670+
err("%s, invalid handle %p or stats %p\n", __func__, handle, stats);
671+
return -EINVAL;
672+
}
668673

674+
cidx = ctx->idx;
669675
if (ctx->type != MT_ST40_HANDLE_PIPELINE_TX) {
670676
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
671677
return 0;
@@ -676,8 +682,14 @@ int st40p_tx_get_session_stats(st40p_tx_handle handle,
676682

677683
int st40p_tx_reset_session_stats(st40p_tx_handle handle) {
678684
struct st40p_tx_ctx* ctx = handle;
679-
int cidx = ctx->idx;
685+
int cidx;
686+
687+
if(!handle) {
688+
err("%s, invalid handle %p\n", __func__, handle);
689+
return -EINVAL;
690+
}
680691

692+
cidx = ctx->idx;
681693
if (ctx->type != MT_ST40_HANDLE_PIPELINE_TX) {
682694
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
683695
return 0;

lib/src/st2110/pipeline/st20_pipeline_rx.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,14 @@ int st20p_rx_get_sch_idx(st20p_rx_handle handle) {
11561156

11571157
int st20p_rx_get_session_stats(st20p_rx_handle handle, struct st20_rx_user_stats* stats) {
11581158
struct st20p_rx_ctx* ctx = handle;
1159-
int cidx = ctx->idx;
1159+
int cidx;
1160+
1161+
if(!handle || !stats) {
1162+
err("%s, invalid handle %p or stats %p\n", __func__, handle, stats);
1163+
return -EINVAL;
1164+
}
11601165

1166+
cidx = ctx->idx;
11611167
if (ctx->type != MT_ST20_HANDLE_PIPELINE_RX) {
11621168
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
11631169
return 0;
@@ -1168,8 +1174,14 @@ int st20p_rx_get_session_stats(st20p_rx_handle handle, struct st20_rx_user_stats
11681174

11691175
int st20p_rx_reset_session_stats(st20p_rx_handle handle) {
11701176
struct st20p_rx_ctx* ctx = handle;
1171-
int cidx = ctx->idx;
1177+
int cidx;
1178+
1179+
if(!handle) {
1180+
err("%s, invalid handle %p\n", __func__, handle);
1181+
return -EINVAL;
1182+
}
11721183

1184+
cidx = ctx->idx;
11731185
if (ctx->type != MT_ST20_HANDLE_PIPELINE_RX) {
11741186
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
11751187
return 0;

lib/src/st2110/pipeline/st20_pipeline_tx.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,14 @@ int st20p_tx_get_sch_idx(st20p_tx_handle handle) {
986986

987987
int st20p_tx_get_session_stats(st20p_tx_handle handle, struct st20_tx_user_stats* stats) {
988988
struct st20p_tx_ctx* ctx = handle;
989-
int cidx = ctx->idx;
989+
int cidx;
990+
991+
if(!handle || !stats) {
992+
err("%s, invalid handle %p or stats %p\n", __func__, handle, stats);
993+
return -EINVAL;
994+
}
990995

996+
cidx = ctx->idx;
991997
if (ctx->type != MT_ST20_HANDLE_PIPELINE_TX) {
992998
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
993999
return 0;
@@ -998,8 +1004,14 @@ int st20p_tx_get_session_stats(st20p_tx_handle handle, struct st20_tx_user_stats
9981004

9991005
int st20p_tx_reset_session_stats(st20p_tx_handle handle) {
10001006
struct st20p_tx_ctx* ctx = handle;
1001-
int cidx = ctx->idx;
1007+
int cidx;
1008+
1009+
if(!handle) {
1010+
err("%s, invalid handle %p\n", __func__, handle);
1011+
return -EINVAL;
1012+
}
10021013

1014+
cidx = ctx->idx;
10031015
if (ctx->type != MT_ST20_HANDLE_PIPELINE_TX) {
10041016
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
10051017
return 0;

lib/src/st2110/pipeline/st30_pipeline_rx.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,14 @@ int st30p_rx_get_queue_meta(st30p_rx_handle handle, struct st_queue_meta* meta)
495495

496496
int st30p_rx_get_session_stats(st30p_rx_handle handle, struct st30_rx_user_stats* stats) {
497497
struct st30p_rx_ctx* ctx = handle;
498-
int cidx = ctx->idx;
498+
int cidx;
499+
500+
if(!handle || !stats) {
501+
err("%s, invalid handle %p or stats %p\n", __func__, handle, stats);
502+
return -EINVAL;
503+
}
499504

505+
cidx = ctx->idx;
500506
if (ctx->type != MT_ST30_HANDLE_PIPELINE_RX) {
501507
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
502508
return 0;
@@ -507,8 +513,14 @@ int st30p_rx_get_session_stats(st30p_rx_handle handle, struct st30_rx_user_stats
507513

508514
int st30p_rx_reset_session_stats(st30p_rx_handle handle) {
509515
struct st30p_rx_ctx* ctx = handle;
510-
int cidx = ctx->idx;
516+
int cidx;
517+
518+
if(!handle) {
519+
err("%s, invalid handle %p\n", __func__, handle);
520+
return -EINVAL;
521+
}
511522

523+
cidx = ctx->idx;
512524
if (ctx->type != MT_ST30_HANDLE_PIPELINE_RX) {
513525
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
514526
return 0;

lib/src/st2110/pipeline/st30_pipeline_tx.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,14 @@ void* st30p_tx_get_fb_addr(st30p_tx_handle handle, uint16_t idx) {
637637

638638
int st30p_tx_get_session_stats(st30p_tx_handle handle, struct st30_tx_user_stats* stats) {
639639
struct st30p_tx_ctx* ctx = handle;
640-
int cidx = ctx->idx;
640+
int cidx;
641+
642+
if(!handle || !stats) {
643+
err("%s, invalid handle %p or stats %p\n", __func__, handle, stats);
644+
return -EINVAL;
645+
}
641646

647+
cidx = ctx->idx;
642648
if (ctx->type != MT_ST30_HANDLE_PIPELINE_TX) {
643649
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
644650
return 0;
@@ -649,8 +655,14 @@ int st30p_tx_get_session_stats(st30p_tx_handle handle, struct st30_tx_user_stats
649655

650656
int st30p_tx_reset_session_stats(st30p_tx_handle handle) {
651657
struct st30p_tx_ctx* ctx = handle;
652-
int cidx = ctx->idx;
658+
int cidx;
659+
660+
if(!handle) {
661+
err("%s, invalid handle %p\n", __func__, handle);
662+
return -EINVAL;
663+
}
653664

665+
cidx = ctx->idx;
654666
if (ctx->type != MT_ST30_HANDLE_PIPELINE_TX) {
655667
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
656668
return 0;

lib/src/st2110/st_header.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@
8181
#define ST_SESSION_STAT_INC(s, stat) \
8282
do { \
8383
(s)->stat++; \
84-
(s)->port_user_stats->stat++; \
84+
(s)->port_user_stats.stat++; \
8585
} while (0)
8686

8787
#define ST_SESSION_STAT_ADD(s, stat, val) \
8888
do { \
8989
(s)->stat += (val); \
90-
(s)->port_user_stats->stat += (val); \
90+
(s)->port_user_stats.stat += (val); \
9191
} while (0)
9292

9393
enum st21_tx_frame_status {
@@ -416,7 +416,7 @@ struct st_tx_video_session_impl {
416416
double stat_cpu_busy_score;
417417
/* for tasklet session time measure */
418418
struct mt_stat_u64 stat_time;
419-
struct st20_tx_user_stats port_user_stats[MTL_SESSION_PORT_MAX];
419+
struct st20_tx_user_stats port_user_stats;
420420
};
421421

422422
struct st_tx_video_sessions_mgr {
@@ -735,7 +735,7 @@ struct st_rx_video_session_impl {
735735
int stat_burst_succ_cnt;
736736
uint16_t stat_burst_pkts_max;
737737
uint64_t stat_burst_pkts_sum;
738-
struct st20_rx_user_stats port_user_stats[MTL_SESSION_PORT_MAX];
738+
struct st20_rx_user_stats port_user_stats;
739739
};
740740

741741
struct st_rx_video_sessions_mgr {
@@ -834,7 +834,7 @@ struct st_tx_audio_session_impl {
834834
struct mt_txq_entry* queue[MTL_SESSION_PORT_MAX];
835835
bool shared_queue;
836836

837-
struct st30_tx_user_stats port_user_stats[MTL_SESSION_PORT_MAX];
837+
struct st30_tx_user_stats port_user_stats;
838838

839839
enum st30_tx_pacing_way tx_pacing_way;
840840
/* for rl based pacing */
@@ -1041,7 +1041,7 @@ struct st_rx_audio_session_impl {
10411041
rte_atomic32_t stat_frames_received;
10421042
uint64_t stat_last_time;
10431043
uint32_t stat_max_notify_frame_us;
1044-
struct st30_rx_user_stats port_user_stats[MTL_SESSION_PORT_MAX];
1044+
struct st30_rx_user_stats port_user_stats;
10451045
/* for tasklet session time measure */
10461046
struct mt_stat_u64 stat_time;
10471047
};
@@ -1139,7 +1139,7 @@ struct st_tx_ancillary_session_impl {
11391139
/* interlace */
11401140
uint32_t stat_interlace_first_field;
11411141
uint32_t stat_interlace_second_field;
1142-
struct st40_tx_users_stats port_user_stats[MTL_SESSION_PORT_MAX];
1142+
struct st40_tx_user_stats port_user_stats;
11431143
};
11441144

11451145
struct st_tx_ancillary_sessions_mgr {
@@ -1205,7 +1205,7 @@ struct st_rx_ancillary_session_impl {
12051205
uint32_t stat_interlace_first_field;
12061206
uint32_t stat_interlace_second_field;
12071207
int stat_pkts_wrong_interlace_dropped;
1208-
struct st40_rx_user_stats port_user_stats[MTL_SESSION_PORT_MAX];
1208+
struct st40_rx_user_stats port_user_stats;
12091209
};
12101210

12111211
struct st_rx_ancillary_sessions_mgr {
@@ -1264,7 +1264,7 @@ struct st_tx_fastmetadata_session_impl {
12641264
struct rte_ring* packet_ring;
12651265
bool second_field;
12661266

1267-
struct st41_tx_users_stats port_user_stats[MTL_SESSION_PORT_MAX];
1267+
struct st41_tx_user_stats port_user_stats;
12681268

12691269
/* dedicated queue tx mode */
12701270
struct mt_txq_entry* queue[MTL_SESSION_PORT_MAX];
@@ -1376,7 +1376,7 @@ struct st_rx_fastmetadata_session_impl {
13761376
uint32_t stat_interlace_first_field;
13771377
uint32_t stat_interlace_second_field;
13781378
int stat_pkts_wrong_interlace_dropped;
1379-
struct st41_rx_user_stats port_user_stats[MTL_SESSION_PORT_MAX];
1379+
struct st41_rx_user_stats port_user_stats;
13801380
};
13811381

13821382
struct st_rx_fastmetadata_sessions_mgr {

lib/src/st2110/st_rx_ancillary_session.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ static int rx_ancillary_session_handle_pkt(struct mtl_main_impl* impl,
158158

159159
if (tmstamp != s->tmstamp) {
160160
rte_atomic32_inc(&s->stat_frames_received);
161-
s->port_user_stats->port[s_port].frames++;
161+
s->port_user_stats.port[s_port].frames++;
162162
s->tmstamp = tmstamp;
163163
}
164164
ST_SESSION_STAT_INC(s, stat_pkts_received);
165-
s->port_user_stats->port[s_port].packets++;
165+
s->port_user_stats.port[s_port].packets++;
166166

167167
/* get a valid packet */
168168
uint64_t tsc_start = 0;
@@ -990,6 +990,11 @@ int st40_rx_get_queue_meta(st40_rx_handle handle, struct st_queue_meta* meta) {
990990
int st40_rx_get_session_stats(st40_rx_handle handle, struct st40_rx_user_stats* stats) {
991991
struct st_rx_ancillary_session_handle_impl* s_impl = handle;
992992

993+
if(!handle || !stats) {
994+
err("%s, invalid handle %p or stats %p\n", __func__, handle, stats);
995+
return -EINVAL;
996+
}
997+
993998
if (s_impl->type != MT_HANDLE_RX_ANC) {
994999
err("%s, invalid type %d\n", __func__, s_impl->type);
9951000
return -EINVAL;
@@ -1003,6 +1008,11 @@ int st40_rx_get_session_stats(st40_rx_handle handle, struct st40_rx_user_stats*
10031008
int st40_rx_reset_session_stats(st40_rx_handle handle) {
10041009
struct st_rx_ancillary_session_handle_impl* s_impl = handle;
10051010

1011+
if(!handle) {
1012+
err("%s, invalid handle %p\n", __func__, handle);
1013+
return -EINVAL;
1014+
}
1015+
10061016
if (s_impl->type != MT_HANDLE_RX_ANC) {
10071017
err("%s, invalid type %d\n", __func__, s_impl->type);
10081018
return -EINVAL;

0 commit comments

Comments
 (0)