net/octeontx2: fix device configuration sequence
diff mbox series

Message ID 20200404151951.1013-1-pbhagavatula@marvell.com
State Accepted, archived
Delegated to: Jerin Jacob
Headers show
Series
  • net/octeontx2: fix device configuration sequence
Related show

Checks

Context Check Description
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch warning coding style issues

Commit Message

Pavan Nikhilesh Bhagavatula April 4, 2020, 3:19 p.m. UTC
From: Pavan Nikhilesh <pbhagavatula@marvell.com>

When an application invokes rte_eth_dev_configure consecutively without
setting up Rx/Tx queues, it will incorrectly return error while trying
to restore Rx/Tx queue configuration.

Fix configuration sequence by checking if any Rx/Tx queues are
previously configured before trying to restore them.

Fixes: 548b5839a32b ("net/octeontx2: add device configure operation")
Cc: stable@dpdk.org

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 drivers/net/octeontx2/otx2_ethdev.c | 16 ++++++++++++----
 drivers/net/octeontx2/otx2_ethdev.h |  1 +
 2 files changed, 13 insertions(+), 4 deletions(-)

Comments

Jerin Jacob April 6, 2020, 6:19 a.m. UTC | #1
On Sat, Apr 4, 2020 at 8:50 PM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> When an application invokes rte_eth_dev_configure consecutively without
> setting up Rx/Tx queues, it will incorrectly return error while trying
> to restore Rx/Tx queue configuration.
>
> Fix configuration sequence by checking if any Rx/Tx queues are
> previously configured before trying to restore them.
>
> Fixes: 548b5839a32b ("net/octeontx2: add device configure operation")
> Cc: stable@dpdk.org
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>


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


> ---
>  drivers/net/octeontx2/otx2_ethdev.c | 16 ++++++++++++----
>  drivers/net/octeontx2/otx2_ethdev.h |  1 +
>  2 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
> index e60f4901c..9fbca2b05 100644
> --- a/drivers/net/octeontx2/otx2_ethdev.c
> +++ b/drivers/net/octeontx2/otx2_ethdev.c
> @@ -1132,10 +1132,12 @@ nix_store_queue_cfg_and_then_release(struct rte_eth_dev *eth_dev)
>         txq = (struct otx2_eth_txq **)eth_dev->data->tx_queues;
>         for (i = 0; i < nb_txq; i++) {
>                 if (txq[i] == NULL) {
> -                       otx2_err("txq[%d] is already released", i);
> -                       goto fail;
> +                       tx_qconf[i].valid = false;
> +                       otx2_info("txq[%d] is already released", i);
> +                       continue;
>                 }
>                 memcpy(&tx_qconf[i], &txq[i]->qconf, sizeof(*tx_qconf));
> +               tx_qconf[i].valid = true;
>                 otx2_nix_tx_queue_release(txq[i]);
>                 eth_dev->data->tx_queues[i] = NULL;
>         }
> @@ -1143,10 +1145,12 @@ nix_store_queue_cfg_and_then_release(struct rte_eth_dev *eth_dev)
>         rxq = (struct otx2_eth_rxq **)eth_dev->data->rx_queues;
>         for (i = 0; i < nb_rxq; i++) {
>                 if (rxq[i] == NULL) {
> -                       otx2_err("rxq[%d] is already released", i);
> -                       goto fail;
> +                       rx_qconf[i].valid = false;
> +                       otx2_info("rxq[%d] is already released", i);
> +                       continue;
>                 }
>                 memcpy(&rx_qconf[i], &rxq[i]->qconf, sizeof(*rx_qconf));
> +               rx_qconf[i].valid = true;
>                 otx2_nix_rx_queue_release(rxq[i]);
>                 eth_dev->data->rx_queues[i] = NULL;
>         }
> @@ -1201,6 +1205,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
>          * queues are already setup in port_configure().
>          */
>         for (i = 0; i < nb_txq; i++) {
> +               if (!tx_qconf[i].valid)
> +                       continue;
>                 rc = otx2_nix_tx_queue_setup(eth_dev, i, tx_qconf[i].nb_desc,
>                                              tx_qconf[i].socket_id,
>                                              &tx_qconf[i].conf.tx);
> @@ -1216,6 +1222,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
>         free(tx_qconf); tx_qconf = NULL;
>
>         for (i = 0; i < nb_rxq; i++) {
> +               if (!rx_qconf[i].valid)
> +                       continue;
>                 rc = otx2_nix_rx_queue_setup(eth_dev, i, rx_qconf[i].nb_desc,
>                                              rx_qconf[i].socket_id,
>                                              &rx_qconf[i].conf.rx,
> diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h
> index e5684f9f0..238afb3a8 100644
> --- a/drivers/net/octeontx2/otx2_ethdev.h
> +++ b/drivers/net/octeontx2/otx2_ethdev.h
> @@ -196,6 +196,7 @@ struct otx2_eth_qconf {
>         void *mempool;
>         uint32_t socket_id;
>         uint16_t nb_desc;
> +       uint8_t valid;
>  };
>
>  struct otx2_fc_info {
> --
> 2.17.1
>

Patch
diff mbox series

diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
index e60f4901c..9fbca2b05 100644
--- a/drivers/net/octeontx2/otx2_ethdev.c
+++ b/drivers/net/octeontx2/otx2_ethdev.c
@@ -1132,10 +1132,12 @@  nix_store_queue_cfg_and_then_release(struct rte_eth_dev *eth_dev)
 	txq = (struct otx2_eth_txq **)eth_dev->data->tx_queues;
 	for (i = 0; i < nb_txq; i++) {
 		if (txq[i] == NULL) {
-			otx2_err("txq[%d] is already released", i);
-			goto fail;
+			tx_qconf[i].valid = false;
+			otx2_info("txq[%d] is already released", i);
+			continue;
 		}
 		memcpy(&tx_qconf[i], &txq[i]->qconf, sizeof(*tx_qconf));
+		tx_qconf[i].valid = true;
 		otx2_nix_tx_queue_release(txq[i]);
 		eth_dev->data->tx_queues[i] = NULL;
 	}
@@ -1143,10 +1145,12 @@  nix_store_queue_cfg_and_then_release(struct rte_eth_dev *eth_dev)
 	rxq = (struct otx2_eth_rxq **)eth_dev->data->rx_queues;
 	for (i = 0; i < nb_rxq; i++) {
 		if (rxq[i] == NULL) {
-			otx2_err("rxq[%d] is already released", i);
-			goto fail;
+			rx_qconf[i].valid = false;
+			otx2_info("rxq[%d] is already released", i);
+			continue;
 		}
 		memcpy(&rx_qconf[i], &rxq[i]->qconf, sizeof(*rx_qconf));
+		rx_qconf[i].valid = true;
 		otx2_nix_rx_queue_release(rxq[i]);
 		eth_dev->data->rx_queues[i] = NULL;
 	}
@@ -1201,6 +1205,8 @@  nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
 	 * queues are already setup in port_configure().
 	 */
 	for (i = 0; i < nb_txq; i++) {
+		if (!tx_qconf[i].valid)
+			continue;
 		rc = otx2_nix_tx_queue_setup(eth_dev, i, tx_qconf[i].nb_desc,
 					     tx_qconf[i].socket_id,
 					     &tx_qconf[i].conf.tx);
@@ -1216,6 +1222,8 @@  nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
 	free(tx_qconf); tx_qconf = NULL;
 
 	for (i = 0; i < nb_rxq; i++) {
+		if (!rx_qconf[i].valid)
+			continue;
 		rc = otx2_nix_rx_queue_setup(eth_dev, i, rx_qconf[i].nb_desc,
 					     rx_qconf[i].socket_id,
 					     &rx_qconf[i].conf.rx,
diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h
index e5684f9f0..238afb3a8 100644
--- a/drivers/net/octeontx2/otx2_ethdev.h
+++ b/drivers/net/octeontx2/otx2_ethdev.h
@@ -196,6 +196,7 @@  struct otx2_eth_qconf {
 	void *mempool;
 	uint32_t socket_id;
 	uint16_t nb_desc;
+	uint8_t valid;
 };
 
 struct otx2_fc_info {