From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id C801B1C0BD for ; Wed, 27 Jun 2018 18:31:33 +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 orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2018 09:31:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,279,1526367600"; d="scan'208";a="240789607" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga005.fm.intel.com with ESMTP; 27 Jun 2018 09:31:31 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, bernard.iremonger@intel.com Date: Wed, 27 Jun 2018 17:31:06 +0100 Message-Id: <20180627163123.135686-7-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180627163123.135686-1-jasvinder.singh@intel.com> References: <20180615165224.25004-2-jasvinder.singh@intel.com> <20180627163123.135686-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v3 06/23] net/softnic: add traffic 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: Wed, 27 Jun 2018 16:31:34 -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 | 70 +++++++++++++++- drivers/net/softnic/rte_eth_softnic.h | 11 ++- drivers/net/softnic/rte_eth_softnic_internals.h | 39 +++++++-- drivers/net/softnic/rte_eth_softnic_tm.c | 103 +++++++++++++++++++++--- 4 files changed, 201 insertions(+), 22 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 6dd8463..d7580f6 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -20,10 +20,23 @@ #define PMD_PARAM_FIRMWARE "firmware" #define PMD_PARAM_CPU_ID "cpu_id" +#define PMD_PARAM_SCRIPT "script" +#define PMD_PARAM_CONN_PORT "conn_port" +#define PMD_PARAM_CPU_ID "cpu_id" +#define PMD_PARAM_TM_N_QUEUES "tm_n_queues" +#define PMD_PARAM_TM_QSIZE0 "tm_qsize0" +#define PMD_PARAM_TM_QSIZE1 "tm_qsize1" +#define PMD_PARAM_TM_QSIZE2 "tm_qsize2" +#define PMD_PARAM_TM_QSIZE3 "tm_qsize3" static const char *pmd_valid_args[] = { PMD_PARAM_FIRMWARE, PMD_PARAM_CPU_ID, + PMD_PARAM_TM_N_QUEUES, + PMD_PARAM_TM_QSIZE0, + PMD_PARAM_TM_QSIZE1, + PMD_PARAM_TM_QSIZE2, + PMD_PARAM_TM_QSIZE3, NULL }; @@ -154,7 +167,7 @@ pmd_link_update(struct rte_eth_dev *dev __rte_unused, static int pmd_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg) { - *(const struct rte_tm_ops **)arg = NULL; + *(const struct rte_tm_ops **)arg = &pmd_tm_ops; return 0; } @@ -225,6 +238,8 @@ pmd_init(struct pmd_params *params) mempool_init(p); swq_init(p); link_init(p); + tm_init(p); + tmgr_init(p); tap_init(p); return p; @@ -237,6 +252,8 @@ pmd_free(struct pmd_internals *p) return; tap_free(p); + tmgr_free(p); + tm_free(p); link_free(p); swq_free(p); mempool_free(p); @@ -322,6 +339,11 @@ pmd_parse_args(struct pmd_params *p, const char *params) memset(p, 0, sizeof(*p)); p->firmware = SOFTNIC_FIRMWARE; p->cpu_id = SOFTNIC_CPU_ID; + p->tm.n_queues = SOFTNIC_TM_N_QUEUES; + p->tm.qsize[0] = SOFTNIC_TM_QUEUE_SIZE; + p->tm.qsize[1] = SOFTNIC_TM_QUEUE_SIZE; + p->tm.qsize[2] = SOFTNIC_TM_QUEUE_SIZE; + p->tm.qsize[3] = SOFTNIC_TM_QUEUE_SIZE; /* Firmware script (optional) */ if (rte_kvargs_count(kvlist, PMD_PARAM_FIRMWARE) == 1) { @@ -339,6 +361,43 @@ pmd_parse_args(struct pmd_params *p, const char *params) goto out_free; } + /* TM number of queues (optional) */ + if (rte_kvargs_count(kvlist, PMD_PARAM_TM_N_QUEUES) == 1) { + ret = rte_kvargs_process(kvlist, PMD_PARAM_TM_N_QUEUES, + &get_uint32, &p->tm.n_queues); + if (ret < 0) + goto out_free; + } + + /* TM queue size 0 .. 3 (optional) */ + if (rte_kvargs_count(kvlist, PMD_PARAM_TM_QSIZE0) == 1) { + ret = rte_kvargs_process(kvlist, PMD_PARAM_TM_QSIZE0, + &get_uint32, &p->tm.qsize[0]); + if (ret < 0) + goto out_free; + } + + if (rte_kvargs_count(kvlist, PMD_PARAM_TM_QSIZE1) == 1) { + ret = rte_kvargs_process(kvlist, PMD_PARAM_TM_QSIZE1, + &get_uint32, &p->tm.qsize[1]); + if (ret < 0) + goto out_free; + } + + if (rte_kvargs_count(kvlist, PMD_PARAM_TM_QSIZE2) == 1) { + ret = rte_kvargs_process(kvlist, PMD_PARAM_TM_QSIZE2, + &get_uint32, &p->tm.qsize[2]); + if (ret < 0) + goto out_free; + } + + if (rte_kvargs_count(kvlist, PMD_PARAM_TM_QSIZE3) == 1) { + ret = rte_kvargs_process(kvlist, PMD_PARAM_TM_QSIZE3, + &get_uint32, &p->tm.qsize[3]); + if (ret < 0) + goto out_free; + } + out_free: rte_kvargs_free(kvlist); return ret; @@ -417,9 +476,16 @@ static struct rte_vdev_driver pmd_softnic_drv = { RTE_PMD_REGISTER_VDEV(net_softnic, pmd_softnic_drv); RTE_PMD_REGISTER_PARAM_STRING(net_softnic, PMD_PARAM_FIRMWARE "= " - PMD_PARAM_CPU_ID "="); + PMD_PARAM_CPU_ID "= " + PMD_PARAM_TM_N_QUEUES "= " + PMD_PARAM_TM_QSIZE0 "= " + PMD_PARAM_TM_QSIZE1 "= " + PMD_PARAM_TM_QSIZE2 "= " + PMD_PARAM_TM_QSIZE3 "=" +); RTE_INIT(pmd_softnic_init_log); + static void pmd_softnic_init_log(void) { diff --git a/drivers/net/softnic/rte_eth_softnic.h b/drivers/net/softnic/rte_eth_softnic.h index fb1d170..98b0828 100644 --- a/drivers/net/softnic/rte_eth_softnic.h +++ b/drivers/net/softnic/rte_eth_softnic.h @@ -21,6 +21,16 @@ extern "C" { #define SOFTNIC_CPU_ID 0 #endif +/** Traffic Manager: Number of scheduler queues. */ +#ifndef SOFTNIC_TM_N_QUEUES +#define SOFTNIC_TM_N_QUEUES (64 * 1024) +#endif + +/** Traffic Manager: Scheduler queue size (per traffic class). */ +#ifndef SOFTNIC_TM_QUEUE_SIZE +#define SOFTNIC_TM_QUEUE_SIZE 64 +#endif + /** * Soft NIC run. * @@ -29,7 +39,6 @@ extern "C" { * @return * Zero on success, error code otherwise. */ - int rte_pmd_softnic_run(uint16_t port_id); diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 6b7004c..e724cba 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -89,7 +89,7 @@ struct link { TAILQ_HEAD(link_list, link); /** - * Traffic Management (TM) Internals + * TMGR */ #ifndef TM_MAX_SUBPORTS @@ -200,6 +200,14 @@ 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; +}; + +TAILQ_HEAD(tmgr_port_list, tmgr_port); + /** * TAP */ @@ -218,7 +226,6 @@ struct pmd_internals { /** Params */ struct pmd_params params; - /** Soft device */ struct { struct tm_internals tm; /**< Traffic Management */ } soft; @@ -226,6 +233,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; }; @@ -284,12 +292,25 @@ 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); + +struct tmgr_port * +tmgr_port_create(struct pmd_internals *p, + const char *name, + struct rte_sched_port *sched); int -tm_init(struct pmd_internals *p, struct pmd_params *params, int numa_node); +tm_init(struct pmd_internals *p); void tm_free(struct pmd_internals *p); @@ -301,11 +322,15 @@ void tm_stop(struct pmd_internals *p); static inline int -tm_used(struct rte_eth_dev *dev __rte_unused) +tm_used(struct rte_eth_dev *dev) { - return 0; + struct pmd_internals *p = dev->data->dev_private; + + return p->soft.tm.h.n_tm_nodes[TM_NODE_LEVEL_PORT]; } +extern const struct rte_tm_ops pmd_tm_ops; + /** * TAP */ diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c index 8da8310..dd7ab3a 100644 --- a/drivers/net/softnic/rte_eth_softnic_tm.c +++ b/drivers/net/softnic/rte_eth_softnic_tm.c @@ -7,14 +7,83 @@ #include #include +#include #include "rte_eth_softnic_internals.h" #include "rte_eth_softnic.h" -#define BYTES_IN_MBPS (1000 * 1000 / 8) #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); + 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; +} + +struct tmgr_port * +tmgr_port_create(struct pmd_internals *p, + const char *name, + struct rte_sched_port *sched) +{ + struct tmgr_port *tmgr_port; + + /* Check input params */ + if (name == NULL || + tmgr_port_find(p, name) || + sched == NULL) + return NULL; + + /* Resource */ + + /* Node allocation */ + tmgr_port = calloc(1, sizeof(struct tmgr_port)); + if (tmgr_port == NULL) + return NULL; + + /* Node fill in */ + strlcpy(tmgr_port->name, name, sizeof(tmgr_port->name)); + tmgr_port->s = sched; + + /* Node add to list */ + TAILQ_INSERT_TAIL(&p->tmgr_port_list, tmgr_port, node); + + return tmgr_port; +} + static void tm_hierarchy_init(struct pmd_internals *p) { @@ -89,9 +158,7 @@ tm_hierarchy_uninit(struct pmd_internals *p) } int -tm_init(struct pmd_internals *p, - struct pmd_params *params __rte_unused, - int numa_node __rte_unused) +tm_init(struct pmd_internals *p) { tm_hierarchy_init(p); @@ -107,7 +174,9 @@ tm_free(struct pmd_internals *p) int tm_start(struct pmd_internals *p) { + struct tmgr_port *tmgr_port; struct tm_params *t = &p->soft.tm.params; + struct rte_sched_port *sched; uint32_t n_subports, subport_id; int status; @@ -116,8 +185,8 @@ tm_start(struct pmd_internals *p) return -1; /* Port */ - p->soft.tm.sched = rte_sched_port_config(&t->port_params); - if (p->soft.tm.sched == NULL) + sched = rte_sched_port_config(&t->port_params); + if (sched == NULL) return -1; /* Subport */ @@ -127,11 +196,11 @@ tm_start(struct pmd_internals *p) t->port_params.n_pipes_per_subport; uint32_t pipe_id; - status = rte_sched_subport_config(p->soft.tm.sched, + status = rte_sched_subport_config(sched, subport_id, &t->subport_params[subport_id]); if (status) { - rte_sched_port_free(p->soft.tm.sched); + rte_sched_port_free(sched); return -1; } @@ -145,26 +214,36 @@ tm_start(struct pmd_internals *p) if (profile_id < 0) continue; - status = rte_sched_pipe_config(p->soft.tm.sched, + status = rte_sched_pipe_config(sched, subport_id, pipe_id, profile_id); if (status) { - rte_sched_port_free(p->soft.tm.sched); + rte_sched_port_free(sched); return -1; } } } + tmgr_port = tmgr_port_create(p, "TMGR", sched); + if (tmgr_port == NULL) { + rte_sched_port_free(sched); + return -1; + } + + /* Commit */ + p->soft.tm.sched = sched; + return 0; } void tm_stop(struct pmd_internals *p) { - if (p->soft.tm.sched) + if (p->soft.tm.sched) { rte_sched_port_free(p->soft.tm.sched); - + p->soft.tm.sched = NULL; + } /* Unfreeze hierarchy */ p->soft.tm.hierarchy_frozen = 0; } -- 2.9.3