net/cnxk: fix crash during hotplug detach operation

Message ID 20220329102857.2872895-1-skori@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series net/cnxk: fix crash during hotplug detach operation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Sunil Kumar Kori March 29, 2022, 10:28 a.m. UTC
  From: Sunil Kumar Kori <skori@marvell.com>

hot_plug application does not perform any port setup
configuration via rte_eth_dev_configure() API. All the probed
Ethernet ports do not contain any Rx and Tx queues.

While detaching a device via rte_eal_hotplug_remove(), CNXK
driver expects Rx and Tx queues structures populated during
reset of PFC. So application gets crashed as data->rx_queues
and data->tx_queues are NULL.

Fixes: 9544713564f5 ("net/cnxk: support priority flow control")

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
 drivers/net/cnxk/cnxk_ethdev_ops.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Jerin Jacob May 2, 2022, 5:44 p.m. UTC | #1
On Tue, Mar 29, 2022 at 3:59 PM <skori@marvell.com> wrote:
>
> From: Sunil Kumar Kori <skori@marvell.com>
>
> hot_plug application does not perform any port setup
> configuration via rte_eth_dev_configure() API. All the probed
> Ethernet ports do not contain any Rx and Tx queues.
>
> While detaching a device via rte_eal_hotplug_remove(), CNXK
> driver expects Rx and Tx queues structures populated during
> reset of PFC. So application gets crashed as data->rx_queues
> and data->tx_queues are NULL.
>
> Fixes: 9544713564f5 ("net/cnxk: support priority flow control")

Cc: stable@dpdk.org

> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/for-next-net. Thanks

> ---
>  drivers/net/cnxk/cnxk_ethdev_ops.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c
> index f4a0562475..15d8e8efa6 100644
> --- a/drivers/net/cnxk/cnxk_ethdev_ops.c
> +++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
> @@ -1069,6 +1069,11 @@ nix_priority_flow_ctrl_configure(struct rte_eth_dev *eth_dev,
>         rx_pause = (mode == RTE_ETH_FC_FULL) || (mode == RTE_ETH_FC_RX_PAUSE);
>         tx_pause = (mode == RTE_ETH_FC_FULL) || (mode == RTE_ETH_FC_TX_PAUSE);
>
> +       if (data->rx_queues == NULL || data->tx_queues == NULL) {
> +               rc = 0;
> +               goto exit;
> +       }
> +
>         /* Configure CQs */
>         memset(&fc_cfg, 0, sizeof(struct roc_nix_fc_cfg));
>         rxq = ((struct cnxk_eth_rxq_sp *)data->rx_queues[conf->rx_qid]) - 1;
> --
> 2.25.1
>
  

Patch

diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c
index f4a0562475..15d8e8efa6 100644
--- a/drivers/net/cnxk/cnxk_ethdev_ops.c
+++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
@@ -1069,6 +1069,11 @@  nix_priority_flow_ctrl_configure(struct rte_eth_dev *eth_dev,
 	rx_pause = (mode == RTE_ETH_FC_FULL) || (mode == RTE_ETH_FC_RX_PAUSE);
 	tx_pause = (mode == RTE_ETH_FC_FULL) || (mode == RTE_ETH_FC_TX_PAUSE);
 
+	if (data->rx_queues == NULL || data->tx_queues == NULL) {
+		rc = 0;
+		goto exit;
+	}
+
 	/* Configure CQs */
 	memset(&fc_cfg, 0, sizeof(struct roc_nix_fc_cfg));
 	rxq = ((struct cnxk_eth_rxq_sp *)data->rx_queues[conf->rx_qid]) - 1;