Thread (121 messages) 121 messages, 4 authors, 2021-05-12

[dpdk-dev] [PATCH v5 3/3] net/ena: disable dev ops not supported by secondary process

From: Michal Krawczyk <hidden>
Date: 2021-05-12 10:14:41
Subsystem: networking drivers, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

From: Stanislaw Kardach <redacted>

For dev_ops not supported by the secondary process, either return -EPERM
or return without doing anything. In both cases log a warning.

It's still application's responsibility to avoid calls like that and
those changes are for debugging/informational purposes.

Signed-off-by: Stanislaw Kardach <redacted>
Reviewed-by: Michal Krawczyk <redacted>
Reviewed-by: Igor Chauskin <redacted>
Reviewed-by: Shay Agroskin <redacted>
---
v5:
* Fix commit log.

v4:
* Fix commit heading style.

 drivers/net/ena/ena_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index e310e7ae8c..dfe68279fa 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -535,6 +535,12 @@ ena_dev_reset(struct rte_eth_dev *dev)
 {
 	int rc = 0;
 
+	/* Cannot release memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_reset not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	ena_destroy_device(dev);
 	rc = eth_ena_dev_init(dev);
 	if (rc)
@@ -1059,6 +1065,12 @@ static int ena_start(struct rte_eth_dev *dev)
 	uint64_t ticks;
 	int rc = 0;
 
+	/* Cannot allocate memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_start not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rc = ena_check_valid_conf(adapter);
 	if (rc)
 		return rc;
@@ -1105,6 +1117,12 @@ static int ena_stop(struct rte_eth_dev *dev)
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
 	int rc;
 
+	/* Cannot free memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_stop not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rte_timer_stop_sync(&adapter->timer_wd);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_TX);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_RX);
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help