diff mbox series

[dpdk-dev,06/21] net/softnic: add trafic manager object

Message ID 20180608124155.140663-7-jasvinder.singh@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Cristian Dumitrescu
Headers show
Series [dpdk-dev,01/21] net/softnic: restructuring | expand

Checks

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

Commit Message

Singh, Jasvinder June 8, 2018, 12:41 p.m. UTC
Add traffic manager(tmgr) object to the softnic.

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           |  2 ++
 drivers/net/softnic/rte_eth_softnic_internals.h | 25 ++++++++++++++--
 drivers/net/softnic/rte_eth_softnic_tm.c        | 40 +++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index be5aad1..51148de 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -225,6 +225,7 @@  pmd_init(struct pmd_params *params)
 	mempool_init(p);
 	swq_init(p);
 	link_init(p);
+	tmgr_init(p);
 	tap_init(p);
 
 	return p;
@@ -237,6 +238,7 @@  pmd_free(struct pmd_internals *p)
 		return;
 
 	tap_free(p);
+	tmgr_free(p);
 	link_free(p);
 	swq_free(p);
 	mempool_free(p);
diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h
index 1e0c883..5aa17b9 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -106,7 +106,7 @@  struct link {
 TAILQ_HEAD(link_list, link);
 
 /**
- * Traffic Management (TM) Internals
+ * TMGR
  */
 
 #ifndef TM_MAX_SUBPORTS
@@ -217,6 +217,16 @@  struct tm_internals {
 	struct rte_sched_port *sched;
 };
 
+struct tmgr_port {
+	TAILQ_ENTRY(tmgr_port) node;
+	char name[NAME_SIZE];
+	struct rte_sched_port *s;
+	uint32_t n_subports_per_port;
+	uint32_t n_pipes_per_subport;
+};
+
+TAILQ_HEAD(tmgr_port_list, tmgr_port);
+
 /**
  * TAP
  */
@@ -243,6 +253,7 @@  struct pmd_internals {
 	struct mempool_list mempool_list;
 	struct swq_list swq_list;
 	struct link_list link_list;
+	struct tmgr_port_list tmgr_port_list;
 	struct tap_list tap_list;
 };
 
@@ -301,11 +312,21 @@  link_create(struct pmd_internals *p,
 	struct link_params *params);
 
 /**
- * Traffic Management (TM) Operation
+ * TMGR
  */
 extern const struct rte_tm_ops pmd_tm_ops;
 
 int
+tmgr_init(struct pmd_internals *p);
+
+void
+tmgr_free(struct pmd_internals *p);
+
+struct tmgr_port *
+tmgr_port_find(struct pmd_internals *p,
+	const char *name);
+
+int
 tm_init(struct pmd_internals *p, struct pmd_params *params, int numa_node);
 
 void
diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c
index 63fbeef..051bf10 100644
--- a/drivers/net/softnic/rte_eth_softnic_tm.c
+++ b/drivers/net/softnic/rte_eth_softnic_tm.c
@@ -15,6 +15,46 @@ 
 #define SUBPORT_TC_PERIOD	10
 #define PIPE_TC_PERIOD		40
 
+int
+tmgr_init(struct pmd_internals *p)
+{
+	TAILQ_INIT(&p->tmgr_port_list);
+
+	return 0;
+}
+
+void
+tmgr_free(struct pmd_internals *p)
+{
+	for ( ; ; ) {
+		struct tmgr_port *tmgr_port;
+
+		tmgr_port = TAILQ_FIRST(&p->tmgr_port_list);
+		if (tmgr_port == NULL)
+			break;
+
+		TAILQ_REMOVE(&p->tmgr_port_list, tmgr_port, node);
+		rte_sched_port_free(tmgr_port->s);
+		free(tmgr_port);
+	}
+}
+
+struct tmgr_port *
+tmgr_port_find(struct pmd_internals *p,
+	const char *name)
+{
+	struct tmgr_port *tmgr_port;
+
+	if (name == NULL)
+		return NULL;
+
+	TAILQ_FOREACH(tmgr_port, &p->tmgr_port_list, node)
+		if (strcmp(tmgr_port->name, name) == 0)
+			return tmgr_port;
+
+	return NULL;
+}
+
 static void
 tm_hierarchy_init(struct pmd_internals *p)
 {