net/memif: fix crash with different number of Rx/Tx queues

There's a bug in memif_stats_get() function due to confusion
between C2S (client->server) and S2C (server->client) rings,
causing a crash if there's a different number of Rx and Tx queues.

Fixit by selectiing the correct rings for Rx and Tx i.e for Rx, S2C
rings are selected and for Tx, C2S rings are selected.

Bugzilla ID: 734
Fixes: 09c7e63a71 ("net/memif: introduce memory interface PMD")
Cc: stable@dpdk.org

Signed-off-by: Huzaifa Rahman <huzaifa.rahman@emumba.com>
Reviewed-by: Joyce Kong <joyce.kong@arm.com>
This commit is contained in:
Huzaifa Rahman 2022-07-26 15:16:28 +05:00 committed by Andrew Rybchenko
parent 9b4b4d95bc
commit 231435a5e6

View File

@ -1444,8 +1444,8 @@ memif_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
stats->opackets = 0;
stats->obytes = 0;
tmp = (pmd->role == MEMIF_ROLE_CLIENT) ? pmd->run.num_c2s_rings :
pmd->run.num_s2c_rings;
tmp = (pmd->role == MEMIF_ROLE_CLIENT) ? pmd->run.num_s2c_rings :
pmd->run.num_c2s_rings;
nq = (tmp < RTE_ETHDEV_QUEUE_STAT_CNTRS) ? tmp :
RTE_ETHDEV_QUEUE_STAT_CNTRS;
@ -1458,8 +1458,8 @@ memif_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
stats->ibytes += mq->n_bytes;
}
tmp = (pmd->role == MEMIF_ROLE_CLIENT) ? pmd->run.num_s2c_rings :
pmd->run.num_c2s_rings;
tmp = (pmd->role == MEMIF_ROLE_CLIENT) ? pmd->run.num_c2s_rings :
pmd->run.num_s2c_rings;
nq = (tmp < RTE_ETHDEV_QUEUE_STAT_CNTRS) ? tmp :
RTE_ETHDEV_QUEUE_STAT_CNTRS;