Skip to content

Commit

Permalink
app/procinfo: fix eventdev xstats
Browse files Browse the repository at this point in the history
process_eventdev_xstats() function was iterating over
eventdev_var[] structure even if there is no eventdev present.
Revised the code to check to iterate and only look for the number
of eventdevs present in the system. Also, shortened function name to
eventdev_xstats().

Coverity issue: 395458
Fixes: 674bb39 ("app/procinfo: display eventdev xstats")
Cc: stable@dpdk.org

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
Tested-by: Dukai Yuan <dukaix.yuan@intel.com>
  • Loading branch information
asevince authored and tmonjalo committed Jul 12, 2023
1 parent 15f483f commit e45f45b
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions app/proc-info/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2045,40 +2045,41 @@ xstats_reset(uint8_t dev_id,

}

static int
process_eventdev_xstats(void)
static unsigned int
eventdev_xstats(void)
{
int i;
int j;
int processing_eventdev_xstats = 0;

for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
unsigned int count = 0;
int i, j;

if (!processing_eventdev_xstats)
processing_eventdev_xstats = 1;
for (i = 0; i < rte_event_dev_count(); i++) {

if (eventdev_var[i].dump_xstats) {
++count;
int ret = rte_event_dev_dump(i, stdout);

if (ret)
rte_panic("dump failed with err=%d\n", ret);
}

if (eventdev_var[i].shw_device_xstats == 1) {
++count;
xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);

if (eventdev_var[i].reset_xstats == 1)
xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
}

if (eventdev_var[i].shw_all_ports == 1) {
++count;
for (j = 0; j < MAX_PORTS_QUEUES; j++) {
xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);

if (eventdev_var[i].reset_xstats == 1)
xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
}
} else {
if (eventdev_var[i].num_ports > 0)
++count;
for (j = 0; j < eventdev_var[i].num_ports; j++) {
xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
eventdev_var[i].ports[j]);
Expand All @@ -2090,13 +2091,16 @@ process_eventdev_xstats(void)
}

if (eventdev_var[i].shw_all_queues == 1) {
++count;
for (j = 0; j < MAX_PORTS_QUEUES; j++) {
xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);

if (eventdev_var[i].reset_xstats == 1)
xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
}
} else {
if (eventdev_var[i].num_queues > 0)
++count;
for (j = 0; j < eventdev_var[i].num_queues; j++) {
xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
eventdev_var[i].queues[j]);
Expand All @@ -2108,10 +2112,7 @@ process_eventdev_xstats(void)
}
}

if (processing_eventdev_xstats)
return 1;

return 0;
return count;
}

int
Expand Down Expand Up @@ -2164,7 +2165,7 @@ main(int argc, char **argv)
return 0;
}

if (process_eventdev_xstats())
if (eventdev_xstats() > 0)
return 0;

nb_ports = rte_eth_dev_count_avail();
Expand Down

0 comments on commit e45f45b

Please sign in to comment.