From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E8D2C1BEAF for ; Fri, 15 Jun 2018 18:52:31 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jun 2018 09:52:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,227,1526367600"; d="scan'208";a="237791040" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga006.fm.intel.com with ESMTP; 15 Jun 2018 09:52:30 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Fri, 15 Jun 2018 17:52:08 +0100 Message-Id: <20180615165224.25004-7-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180615165224.25004-1-jasvinder.singh@intel.com> References: <20180608124155.140663-2-jasvinder.singh@intel.com> <20180615165224.25004-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v2 06/22] 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, 15 Jun 2018 16:52:32 -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 48332cd..96a5f96 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 48d7fc2..cd35779 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