net/softnic: add traffic manager object
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>
This commit is contained in:
parent
5d37574846
commit
ea96935de2
@ -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
|
||||
};
|
||||
|
||||
@ -155,7 +168,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;
|
||||
}
|
||||
@ -219,6 +232,8 @@ pmd_init(struct pmd_params *params)
|
||||
softnic_mempool_init(p);
|
||||
softnic_swq_init(p);
|
||||
softnic_link_init(p);
|
||||
tm_init(p);
|
||||
softnic_tmgr_init(p);
|
||||
softnic_tap_init(p);
|
||||
|
||||
return p;
|
||||
@ -231,6 +246,8 @@ pmd_free(struct pmd_internals *p)
|
||||
return;
|
||||
|
||||
softnic_tap_free(p);
|
||||
softnic_tmgr_free(p);
|
||||
tm_free(p);
|
||||
softnic_link_free(p);
|
||||
softnic_swq_free(p);
|
||||
softnic_mempool_free(p);
|
||||
@ -316,6 +333,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) {
|
||||
@ -333,6 +355,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;
|
||||
@ -411,7 +470,14 @@ 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 "=<string> "
|
||||
PMD_PARAM_CPU_ID "=<uint32>");
|
||||
PMD_PARAM_CPU_ID "=<uint32> "
|
||||
PMD_PARAM_TM_N_QUEUES "=<uint32> "
|
||||
PMD_PARAM_TM_QSIZE0 "=<uint32> "
|
||||
PMD_PARAM_TM_QSIZE1 "=<uint32> "
|
||||
PMD_PARAM_TM_QSIZE2 "=<uint32> "
|
||||
PMD_PARAM_TM_QSIZE3 "=<uint32>"
|
||||
);
|
||||
|
||||
|
||||
RTE_INIT(pmd_softnic_init_log)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -89,7 +89,7 @@ struct softnic_link {
|
||||
TAILQ_HEAD(softnic_link_list, softnic_link);
|
||||
|
||||
/**
|
||||
* Traffic Management (TM) Internals
|
||||
* TMGR
|
||||
*/
|
||||
|
||||
#ifndef TM_MAX_SUBPORTS
|
||||
@ -200,6 +200,14 @@ struct tm_internals {
|
||||
struct rte_sched_port *sched;
|
||||
};
|
||||
|
||||
struct softnic_tmgr_port {
|
||||
TAILQ_ENTRY(softnic_tmgr_port) node;
|
||||
char name[NAME_SIZE];
|
||||
struct rte_sched_port *s;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(softnic_tmgr_port_list, softnic_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 softnic_mempool_list mempool_list;
|
||||
struct softnic_swq_list swq_list;
|
||||
struct softnic_link_list link_list;
|
||||
struct softnic_tmgr_port_list tmgr_port_list;
|
||||
struct softnic_tap_list tap_list;
|
||||
};
|
||||
|
||||
@ -284,12 +292,25 @@ softnic_link_create(struct pmd_internals *p,
|
||||
struct softnic_link_params *params);
|
||||
|
||||
/**
|
||||
* Traffic Management (TM) Operation
|
||||
* TMGR
|
||||
*/
|
||||
extern const struct rte_tm_ops pmd_tm_ops;
|
||||
int
|
||||
softnic_tmgr_init(struct pmd_internals *p);
|
||||
|
||||
void
|
||||
softnic_tmgr_free(struct pmd_internals *p);
|
||||
|
||||
struct softnic_tmgr_port *
|
||||
softnic_tmgr_port_find(struct pmd_internals *p,
|
||||
const char *name);
|
||||
|
||||
struct softnic_tmgr_port *
|
||||
softnic_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
|
||||
*/
|
||||
|
@ -7,14 +7,83 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_string_fns.h>
|
||||
|
||||
#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
|
||||
softnic_tmgr_init(struct pmd_internals *p)
|
||||
{
|
||||
TAILQ_INIT(&p->tmgr_port_list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
softnic_tmgr_free(struct pmd_internals *p)
|
||||
{
|
||||
for ( ; ; ) {
|
||||
struct softnic_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 softnic_tmgr_port *
|
||||
softnic_tmgr_port_find(struct pmd_internals *p,
|
||||
const char *name)
|
||||
{
|
||||
struct softnic_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 softnic_tmgr_port *
|
||||
softnic_tmgr_port_create(struct pmd_internals *p,
|
||||
const char *name,
|
||||
struct rte_sched_port *sched)
|
||||
{
|
||||
struct softnic_tmgr_port *tmgr_port;
|
||||
|
||||
/* Check input params */
|
||||
if (name == NULL ||
|
||||
softnic_tmgr_port_find(p, name) ||
|
||||
sched == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Resource */
|
||||
|
||||
/* Node allocation */
|
||||
tmgr_port = calloc(1, sizeof(struct softnic_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 softnic_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 = softnic_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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user