diff mbox series

[v4,21/23] net/softnic: start and stop function

Message ID 20180705154754.147420-22-jasvinder.singh@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Cristian Dumitrescu
Headers show
Series [v4,01/23] net/softnic: restructuring | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jasvinder Singh July 5, 2018, 3:47 p.m. UTC
Implements softnic start and stop function.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
 drivers/net/softnic/rte_eth_softnic.c           | 49 ++++++++++++++++++++-----
 drivers/net/softnic/rte_eth_softnic_internals.h |  6 +++
 drivers/net/softnic/rte_eth_softnic_pipeline.c  | 12 ++++++
 drivers/net/softnic/rte_eth_softnic_swq.c       | 16 ++++++++
 4 files changed, 73 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index db84bd4..933f08d 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -152,6 +152,26 @@  pmd_tx_queue_setup(struct rte_eth_dev *dev,
 static int
 pmd_dev_start(struct rte_eth_dev *dev)
 {
+	struct pmd_internals *p = dev->data->dev_private;
+	int status;
+
+	/* TM */
+	if (tm_used(dev)) {
+		status = tm_start(p);
+
+		if (status)
+			return status;
+	}
+
+	/* Firmware */
+	status = softnic_cli_script_process(p,
+		p->params.firmware,
+		conn_params_default.msg_in_len_max,
+		conn_params_default.msg_out_len_max);
+	if (status)
+		return status;
+
+	/* Link UP */
 	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
@@ -160,21 +180,30 @@  pmd_dev_start(struct rte_eth_dev *dev)
 static void
 pmd_dev_stop(struct rte_eth_dev *dev)
 {
+	struct pmd_internals *p = dev->data->dev_private;
+
+	/* Link DOWN */
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+
+	/* Firmware */
+	softnic_pipeline_disable_all(p);
+	softnic_pipeline_free(p);
+	softnic_table_action_profile_free(p);
+	softnic_port_in_action_profile_free(p);
+	softnic_tap_free(p);
+	softnic_tmgr_free(p);
+	softnic_link_free(p);
+	softnic_softnic_swq_free_keep_rxq_txq(p);
+	softnic_mempool_free(p);
+
+	/* TM */
+	tm_stop(p);
 }
 
 static void
-pmd_dev_close(struct rte_eth_dev *dev)
+pmd_dev_close(struct rte_eth_dev *dev __rte_unused)
 {
-	uint32_t i;
-
-	/* RX queues */
-	for (i = 0; i < dev->data->nb_rx_queues; i++)
-		rte_ring_free((struct rte_ring *)dev->data->rx_queues[i]);
-
-	/* TX queues */
-	for (i = 0; i < dev->data->nb_tx_queues; i++)
-		rte_ring_free((struct rte_ring *)dev->data->tx_queues[i]);
+	return;
 }
 
 static int
diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h
index a7bf1df..aaccae8 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -530,6 +530,9 @@  softnic_swq_init(struct pmd_internals *p);
 void
 softnic_swq_free(struct pmd_internals *p);
 
+void
+softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p);
+
 struct softnic_swq *
 softnic_swq_find(struct pmd_internals *p,
 	const char *name);
@@ -659,6 +662,9 @@  softnic_pipeline_init(struct pmd_internals *p);
 void
 softnic_pipeline_free(struct pmd_internals *p);
 
+void
+softnic_pipeline_disable_all(struct pmd_internals *p);
+
 struct pipeline *
 softnic_pipeline_find(struct pmd_internals *p, const char *name);
 
diff --git a/drivers/net/softnic/rte_eth_softnic_pipeline.c b/drivers/net/softnic/rte_eth_softnic_pipeline.c
index 63d4bd7..45136a4 100644
--- a/drivers/net/softnic/rte_eth_softnic_pipeline.c
+++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c
@@ -61,6 +61,18 @@  softnic_pipeline_free(struct pmd_internals *p)
 	}
 }
 
+void
+softnic_pipeline_disable_all(struct pmd_internals *p)
+{
+	struct pipeline *pipeline;
+
+	TAILQ_FOREACH(pipeline, &p->pipeline_list, node)
+		if (pipeline->enabled)
+			softnic_thread_pipeline_disable(p,
+				pipeline->thread_id,
+				pipeline->name);
+}
+
 struct pipeline *
 softnic_pipeline_find(struct pmd_internals *p,
 	const char *name)
diff --git a/drivers/net/softnic/rte_eth_softnic_swq.c b/drivers/net/softnic/rte_eth_softnic_swq.c
index c46cad9..1944fbb 100644
--- a/drivers/net/softnic/rte_eth_softnic_swq.c
+++ b/drivers/net/softnic/rte_eth_softnic_swq.c
@@ -33,6 +33,22 @@  softnic_swq_free(struct pmd_internals *p)
 	}
 }
 
+void
+softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p)
+{
+	struct softnic_swq *swq;
+
+	TAILQ_FOREACH(swq, &p->swq_list, node) {
+		if ((strncmp(swq->name, "RXQ", strlen("RXQ")) == 0) ||
+			(strncmp(swq->name, "TXQ", strlen("TXQ")) == 0))
+			continue;
+
+		TAILQ_REMOVE(&p->swq_list, swq, node);
+		rte_ring_free(swq->r);
+		free(swq);
+	}
+}
+
 struct softnic_swq *
 softnic_swq_find(struct pmd_internals *p,
 	const char *name)