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 7FAD31C10F for ; Wed, 27 Jun 2018 18:31:30 +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:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,279,1526367600"; d="scan'208";a="240789577" 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:28 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, bernard.iremonger@intel.com Date: Wed, 27 Jun 2018 17:31:03 +0100 Message-Id: <20180627163123.135686-4-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 03/23] net/softnic: add link 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:31 -0000 Add link object implementation to the softnic. Signed-off-by: Cristian Dumitrescu Signed-off-by: Jasvinder Singh --- drivers/net/softnic/Makefile | 1 + drivers/net/softnic/rte_eth_softnic.c | 4 + drivers/net/softnic/rte_eth_softnic_internals.h | 37 ++++++++++ drivers/net/softnic/rte_eth_softnic_link.c | 98 +++++++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 drivers/net/softnic/rte_eth_softnic_link.c diff --git a/drivers/net/softnic/Makefile b/drivers/net/softnic/Makefile index 5da7842..3a7a10f 100644 --- a/drivers/net/softnic/Makefile +++ b/drivers/net/softnic/Makefile @@ -23,6 +23,7 @@ LIBABIVER := 1 # SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_swq.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_link.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_SOFTNIC) += rte_eth_softnic_tm.c # diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 9fff795..e1c6a25 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -223,6 +223,8 @@ pmd_init(struct pmd_params *params) /* Resources */ swq_init(p); + link_init(p); + return p; } @@ -232,7 +234,9 @@ pmd_free(struct pmd_internals *p) if (p == NULL) return; + link_free(p); swq_free(p); + rte_free(p); } diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 5c857b3..2163979 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -52,6 +52,24 @@ struct swq { TAILQ_HEAD(swq_list, swq); /** + * LINK + */ +struct link_params { + const char *dev_name; + uint16_t port_id; /**< Valid only when *dev_name* is NULL. */ +}; + +struct link { + TAILQ_ENTRY(link) node; + char name[NAME_SIZE]; + uint16_t port_id; + uint32_t n_rxq; + uint32_t n_txq; +}; + +TAILQ_HEAD(link_list, link); + +/** * Traffic Management (TM) Internals */ @@ -176,6 +194,7 @@ struct pmd_internals { } soft; struct swq_list swq_list; + struct link_list link_list; }; /** @@ -197,6 +216,24 @@ swq_create(struct pmd_internals *p, struct swq_params *params); /** + * LINK + */ +int +link_init(struct pmd_internals *p); + +void +link_free(struct pmd_internals *p); + +struct link * +link_find(struct pmd_internals *p, + const char *name); + +struct link * +link_create(struct pmd_internals *p, + const char *name, + struct link_params *params); + +/** * Traffic Management (TM) Operation */ extern const struct rte_tm_ops pmd_tm_ops; diff --git a/drivers/net/softnic/rte_eth_softnic_link.c b/drivers/net/softnic/rte_eth_softnic_link.c new file mode 100644 index 0000000..709344c --- /dev/null +++ b/drivers/net/softnic/rte_eth_softnic_link.c @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2018 Intel Corporation + */ + +#include +#include + +#include +#include + +#include "rte_eth_softnic_internals.h" + +int +link_init(struct pmd_internals *p) +{ + TAILQ_INIT(&p->link_list); + + return 0; +} + +void +link_free(struct pmd_internals *p) +{ + for ( ; ; ) { + struct link *link; + + link = TAILQ_FIRST(&p->link_list); + if (link == NULL) + break; + + TAILQ_REMOVE(&p->link_list, link, node); + free(link); + } +} + +struct link * +link_find(struct pmd_internals *p, + const char *name) +{ + struct link *link; + + if (name == NULL) + return NULL; + + TAILQ_FOREACH(link, &p->link_list, node) + if (strcmp(link->name, name) == 0) + return link; + + return NULL; +} + +struct link * +link_create(struct pmd_internals *p, + const char *name, + struct link_params *params) +{ + struct rte_eth_dev_info port_info; + struct link *link; + uint16_t port_id; + + /* Check input params */ + if (name == NULL || + link_find(p, name) || + params == NULL) + return NULL; + + port_id = params->port_id; + if (params->dev_name) { + int status; + + status = rte_eth_dev_get_port_by_name(params->dev_name, + &port_id); + + if (status) + return NULL; + } else { + if (!rte_eth_dev_is_valid_port(port_id)) + return NULL; + } + + rte_eth_dev_info_get(port_id, &port_info); + + /* Node allocation */ + link = calloc(1, sizeof(struct link)); + if (link == NULL) + return NULL; + + /* Node fill in */ + strlcpy(link->name, name, sizeof(link->name)); + link->port_id = port_id; + link->n_rxq = port_info.nb_rx_queues; + link->n_txq = port_info.nb_tx_queues; + + /* Node add to list */ + TAILQ_INSERT_TAIL(&p->link_list, link, node); + + return link; +} -- 2.9.3