Skip to content

Commit

Permalink
mlx5: reading the counters support more type of kernel drivers
Browse files Browse the repository at this point in the history
Signed-off-by: Hanoh Haim <hhaim@cisco.com>
  • Loading branch information
hhaim committed Feb 10, 2021
1 parent 15c782f commit d7fe280
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/drivers/trex_driver_mlx5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,45 @@ bool CTRexExtendedDriverBaseMlnx5G::get_extended_stats(CPhyEthIF * _if, CPhyEthI
tx_discards_phy,
tx_errors_phy,
rx_out_of_buffer,
tx_pp_missed_interrupt_error,
tx_pp_rearm_queue_errors,
tx_pp_clock_queue_errors,
tx_pp_timestamp_past_errors,
tx_pp_timestamp_future_error,
tx_pp_jitter,
tx_pp_wander,
tx_pp_sync_lost,
//tx_pp_missed_interrupt_error,
//tx_pp_rearm_queue_errors,
//tx_pp_clock_queue_errors,
//tx_pp_timestamp_past_errors,
//tx_pp_timestamp_future_error,
//tx_pp_jitter,
//tx_pp_wander,
//tx_pp_sync_lost,
XCOUNT
};

uint16_t repid = _if->get_repid();
xstats_struct* xstats_struct = &m_port_xstats[repid];




if ( !xstats_struct->init ) {
// total_count = COUNT + per queue stats count + XCOUNT
xstats_struct->total_count = rte_eth_xstats_get(repid, NULL, 0);
assert(xstats_struct->total_count>=COUNT+XCOUNT);
struct rte_eth_xstat_name *xstats_names;

xstats_names = (struct rte_eth_xstat_name *)malloc(sizeof(struct rte_eth_xstat_name) * xstats_struct->total_count);
assert(xstats_names!= 0);
rte_eth_xstats_get_names(repid,xstats_names,xstats_struct->total_count);
int i;

for (i=0; i<xstats_struct->total_count; i++){
if (strncmp(xstats_names[i].name,"rx_out_of_buffer",RTE_ETH_XSTATS_NAME_SIZE) == 0) {
xstats_struct->last_offset = xstats_struct->total_count - 1 - i;
break;
}
}
free(xstats_names);
}

struct rte_eth_xstat xstats_array[xstats_struct->total_count];
struct rte_eth_xstat *xstats = &xstats_array[xstats_struct->total_count - XCOUNT];
struct rte_eth_xstat *xstats = &xstats_array[xstats_struct->total_count - XCOUNT - xstats_struct->last_offset];
struct rte_eth_stats *prev_stats = &stats->m_prev_stats;

/* fetch stats */
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/trex_driver_mlx5.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class CTRexExtendedDriverBaseMlnx5G : public CTRexExtendedDriverBase {
struct xstats_struct {
uint16_t total_count;
bool init;

uint16_t last_offset;
};
xstats_struct m_port_xstats[TREX_MAX_PORTS];
};
Expand Down

0 comments on commit d7fe280

Please sign in to comment.