Skip to content

Commit

Permalink
issue: 3807308 Add Ring TSO statistics
Browse files Browse the repository at this point in the history
TSO statistics are very important for tracking TX performance.
Two variables are added, TSO packets number and TSO bytes number.
With these two and with conjunction of total TX packets and bytes,
the needed information can be derrived.

Signed-off-by: Alexander Grissik <agrissik@nvidia.com>
  • Loading branch information
AlexanderGrissik authored and galnoam committed Jul 11, 2024
1 parent 059e54a commit c6feba5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/core/dev/hw_queue_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ inline int hw_queue_tx::fill_wqe(xlio_ibv_send_wr *pswr)
} else {
/* Support XLIO_IBV_WR_SEND_TSO operation
*/
wqe_size = fill_wqe_lso(pswr);
wqe_size = fill_wqe_lso(pswr, data_len);
return wqe_size;
}
}
Expand Down Expand Up @@ -750,7 +750,7 @@ inline int hw_queue_tx::fill_wqe_send(xlio_ibv_send_wr *pswr)
}

//! Filling wqe for LSO
inline int hw_queue_tx::fill_wqe_lso(xlio_ibv_send_wr *pswr)
inline int hw_queue_tx::fill_wqe_lso(xlio_ibv_send_wr *pswr, int data_len)
{
struct mlx5_wqe_ctrl_seg *ctrl = nullptr;
struct mlx5_wqe_eth_seg *eseg = nullptr;
Expand All @@ -771,6 +771,8 @@ inline int hw_queue_tx::fill_wqe_lso(xlio_ibv_send_wr *pswr)
if (0 == pswr->tso.mss) {
ctrl->opmod_idx_opcode =
htonl(((m_sq_wqe_counter & 0xffff) << 8) | (get_mlx5_opcode(XLIO_IBV_WR_SEND) & 0xff));
} else {
m_p_ring->update_tso_stats(static_cast<uint64_t>(data_len));
}

eseg = (struct mlx5_wqe_eth_seg *)((uint8_t *)m_sq_wqe_hot + sizeof(*ctrl));
Expand Down
2 changes: 1 addition & 1 deletion src/core/dev/hw_queue_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class hw_queue_tx : public xlio_ti_owner {
inline void store_current_wqe_prop(mem_buf_desc_t *wr_id, unsigned credits, xlio_ti *ti);
inline int fill_wqe(xlio_ibv_send_wr *p_send_wqe);
inline int fill_wqe_send(xlio_ibv_send_wr *pswr);
inline int fill_wqe_lso(xlio_ibv_send_wr *pswr);
inline int fill_wqe_lso(xlio_ibv_send_wr *pswr, int data_len);
inline int fill_inl_segment(sg_array &sga, uint8_t *cur_seg, uint8_t *data_addr,
int max_inline_len, int inline_len);
inline void ring_doorbell(int num_wqebb, bool skip_comp = false);
Expand Down
6 changes: 6 additions & 0 deletions src/core/dev/ring_simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ class ring_simple : public ring_slave {
struct ibv_comp_channel *get_tx_comp_event_channel() { return m_p_tx_comp_event_channel; }
void modify_cq_moderation(uint32_t period, uint32_t count);

void update_tso_stats(uint64_t bytes)
{
++m_p_ring_stat->simple.n_tx_tso_pkt_count;
m_p_ring_stat->simple.n_tx_tso_byte_count += bytes;
}

#ifdef DEFINED_UTLS
bool tls_tx_supported(void) override { return m_tls.tls_tx; }
bool tls_rx_supported(void) override { return m_tls.tls_rx; }
Expand Down
2 changes: 2 additions & 0 deletions src/core/util/xlio_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ typedef struct {
ring_type_t n_type;
union {
struct {
uint64_t n_tx_tso_pkt_count;
uint64_t n_tx_tso_byte_count;
uint64_t n_rx_interrupt_requests;
uint64_t n_rx_interrupt_received;
uint32_t n_rx_cq_moderation_count;
Expand Down
16 changes: 16 additions & 0 deletions src/stats/stats_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ void update_delta_ring_stat(ring_stats_t *p_curr_ring_stats, ring_stats_t *p_pre
p_prev_ring_stats->tap.n_vf_plugouts =
(p_curr_ring_stats->tap.n_vf_plugouts - p_prev_ring_stats->tap.n_vf_plugouts);
} else {
p_prev_ring_stats->simple.n_tx_tso_pkt_count =
(p_curr_ring_stats->simple.n_tx_tso_pkt_count -
p_prev_ring_stats->simple.n_tx_tso_pkt_count) /
delay;
p_prev_ring_stats->simple.n_tx_tso_byte_count =
(p_curr_ring_stats->simple.n_tx_tso_byte_count -
p_prev_ring_stats->simple.n_tx_tso_byte_count) /
delay;
p_prev_ring_stats->simple.n_rx_interrupt_received =
(p_curr_ring_stats->simple.n_rx_interrupt_received -
p_prev_ring_stats->simple.n_rx_interrupt_received) /
Expand Down Expand Up @@ -535,6 +543,12 @@ void print_ring_stats(ring_instance_block_t *p_ring_inst_arr)
printf(FORMAT_STATS_32bit, "Tap fd:", p_ring_stats->tap.n_tap_fd);
printf(FORMAT_RING_TAP_NAME, "Tap Device:", p_ring_stats->tap.s_tap_name);
} else {
if (p_ring_stats->simple.n_tx_tso_pkt_count ||
p_ring_stats->simple.n_tx_tso_byte_count) {
printf(FORMAT_RING_PACKETS, "TSO Offload:",
p_ring_stats->simple.n_tx_tso_byte_count / BYTES_TRAFFIC_UNIT,
p_ring_stats->simple.n_tx_tso_pkt_count, post_fix);
}
if (p_ring_stats->simple.n_rx_interrupt_requests ||
p_ring_stats->simple.n_rx_interrupt_received) {
printf(FORMAT_RING_INTERRUPT,
Expand Down Expand Up @@ -1799,6 +1813,8 @@ void zero_ring_stats(ring_stats_t *p_ring_stats)
if (p_ring_stats->n_type == RING_TAP) {
p_ring_stats->tap.n_vf_plugouts = 0;
} else {
p_ring_stats->simple.n_tx_tso_pkt_count = 0;
p_ring_stats->simple.n_tx_tso_byte_count = 0;
p_ring_stats->simple.n_rx_interrupt_received = 0;
p_ring_stats->simple.n_rx_interrupt_requests = 0;
p_ring_stats->simple.n_tx_dropped_wqes = 0;
Expand Down

0 comments on commit c6feba5

Please sign in to comment.