net/enic: fix crash on MTU update or rxq reconfigure
PATCH 1/2 net/enic: fix crash on MTU update or rxq reconfigure
The incorrect completion queue corresponding to an RQ would be freed if multiple Rx queues are in use and the MTU is changed, or an Rx queue is released. This could lead to a segmentation fault when the device is disabled or even in the Rx or Tx paths.
The index of the completion queue corresponding to a RQ needed to be adjusted after Rx scatter was introduced.
--- drivers/net/enic/enic.h | 5 +++++ drivers/net/enic/enic_main.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/enic/enic.h +5 -0
@@ -170,6 +170,11 @@ struct enic { }; +/* Get the CQ index from a Start of Packet(SOP) RQ index */ +static inline unsigned int enic_sop_rq_idx_to_cq_idx (unsigned int sop_idx) +{ +return sop_idx /2 ; +}static inline unsigned int enic_rq_sop (unsigned int sop_rq) {return sop_rq /2 ;
drivers/net/enic/enic_main.c +1 -1
@@ -541,7 +541,7 @@ void enic_free_rq(void *rxq)if (rq_data->in_use)vnic_rq_free (rq_data); -vnic_cq_free (&enic->cq[rq_sop->index]); +vnic_cq_free (&enic->cq[enic_sop_rq_idx_to_cq_idx (rq_sop->index)]); rq_sop->in_use =0 ; rq_data->in_use =0 ;
Signature · 1 line
2.10.0
PATCH 2/2 net/enic: trivial function name changes
The function names for converting between RQ indexes known to the RTE code and intenal RQ indexes for primary Start of Packet (SOP) queues and spill-over (Data) queues was unclear and confusing.
Clarify with more explicit function names.
--- drivers/net/enic/enic.h | 16 ++++++++----- drivers/net/enic/enic_clsf.c | 2 +- drivers/net/enic/enic_ethdev.c | 6 ++--- drivers/net/enic/enic_main.c | 51 ++++++++++++++++++++++++------------------ 4 files changed, 43 insertions(+), 32 deletions(-)
drivers/net/enic/enic.h +10 -6
@@ -175,19 +175,23 @@ static inline unsigned int enic_sop_rq_idx_to_cq_idx(unsigned int sop_idx) {return sop_idx /2 ; } -static inline unsigned int enic_rq_sop (unsigned int sop_rq) + +/* Get the RTE RQ index from a Start of Packet(SOP) RQ index */ +static inline unsigned int enic_sop_rq_idx_to_rte_idx (unsigned int sop_idx) { -return sop_rq /2 ; +return sop_idx /2 ; } -static inline unsigned int enic_sop_rq (unsigned int rq) +/* Get the Start of Packet(SOP) RQ index from a RTE RQ index */ +static inline unsigned int enic_rte_rq_idx_to_sop_idx (unsigned int rte_idx) { -return rq *2 ; +return rte_idx *2 ; } -static inline unsigned int enic_data_rq (unsigned int rq) +/* Get the Data RQ index from a RTE RQ index */ +static inline unsigned int enic_rte_rq_idx_to_data_idx (unsigned int rte_idx) { -return rq *2 +1 ; +return rte_idx *2 +1 ; }static inline unsigned int enic_vnic_rq_count (struct enic *enic)
drivers/net/enic/enic_clsf.c +1 -1
@@ -384,7 +384,7 @@ int enic_fdir_add_fltr(struct enic *enic, struct rte_eth_fdir_filter *params) }/* Get the enicpmd RQ from the DPDK Rx queue */ - queue =enic_sop_rq (params->action.rx_queue); + queue =enic_rte_rq_idx_to_sop_idx (params->action.rx_queue);if (!enic->rq[queue].in_use)return -EINVAL ;
drivers/net/enic/enic_ethdev.c +3 -3
@@ -154,7 +154,7 @@ static int enicpmd_dev_setup_intr(struct enic *enic)return 0 ;/* check start of packet (SOP) RQs only in case scatter is disabled. */ for (index =0 ; index < enic->rq_count; index++) { -if (!enic->rq[enic_sop_rq (index)].ctrl) +if (!enic->rq[enic_rte_rq_idx_to_sop_idx (index)].ctrl)break ; }if (enic->rq_count != index)
@@ -277,7 +277,7 @@ static uint32_t enicpmd_dev_rx_queue_count(struct rte_eth_dev *dev,return 0 ; } - rq_num =enic_sop_rq (rx_queue_id); + rq_num =enic_rte_rq_idx_to_sop_idx (rx_queue_id); cq = &enic->cq[enic_cq_rq (enic, rq_num)]; cq_idx = cq->to_clean;
@@ -313,7 +313,7 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, } eth_dev->data->rx_queues[queue_idx] = - (void *)&enic->rq[enic_sop_rq (queue_idx)]; + (void *)&enic->rq[enic_rte_rq_idx_to_sop_idx (queue_idx)]; ret =enic_alloc_rq (enic, queue_idx, socket_id, mp, nb_desc);if (ret) {
drivers/net/enic/enic_main.c +29 -22
132 lines not on this page · raw message
Signature · 1 line
2.10.0
Quoted 5 lines · John Daley
The incorrect completion queue corresponding to an RQ would be freed if multiple Rx queues are in use and the MTU is changed, or an Rx queue is released. This could lead to a segmentation fault when the device is disabled or even in the Rx or Tx paths.
Quoted 8 lines
The index of the completion queue corresponding to a RQ needed to be adjusted after Rx scatter was introduced.
Fixes 856d7ba7ed22 ("net/enic: support scattered Rx")Signed-off-by John Daley <[email protected]>Reviewed-by Nelson Escobar <[email protected]>---
Patchset applied to dpdk-next-net/rel_16_11
/Bruce