From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 222805F54 for ; Fri, 8 Jun 2018 14:42:03 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 05:42:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,490,1520924400"; d="scan'208";a="235505330" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga005.fm.intel.com with ESMTP; 08 Jun 2018 05:42:01 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Fri, 8 Jun 2018 13:41:40 +0100 Message-Id: <20180608124155.140663-7-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180608124155.140663-1-jasvinder.singh@intel.com> References: <20180608124155.140663-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH 06/21] net/softnic: add trafic manager object X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2018 12:42:04 -0000 Add traffic manager(tmgr) object to the softnic. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- 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 --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) { -- 2.9.3