Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH 0/7] introduce pipe PMD
@ 2020-02-25 23:32 Itsuro Oda
  2020-02-25 23:32 ` [spp] [PATCH 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

pipe PMD provides a device named spp_pipe which communicates
using rings allocated by spp_primary.
For example spp_pipe0 made with devargs "rx=ring:0,tx=ring:1"
recieves packets from ring:0 and sends packets to ring:1.
spp_pipe enables high-speed communication between an application
and other application or SPP secondary processes (ex. spp_nfv)
using rings.
Note that an application using spp_pipe must be a secondary
process under spp_primary.

This series of patches add the part of driver. CLI and REST
API to request to make spp_pipe devices will be provided
by following patches. The document will be provided by
following patches too.

Itsuro Oda (7):
  drivers/pipe: add pipe PMD driver
  drivers: add pipe PMD in Makefile
  spp_primary: add link to pipe PMD in Makefile
  spp_nfv: add link to pipe PMD in Makefile
  spp_vf: add link to pipe PMD in Makefile
  spp_mirror: add link to pipe PMD in Makefile
  spp_pcap: add link to pipe PMD in Makefile

 src/drivers/Makefile                          |   1 +
 src/drivers/pipe/Makefile                     |  26 ++
 src/drivers/pipe/rte_pmd_spp_pipe_version.map |   4 +
 src/drivers/pipe/rte_spp_pipe.c               | 425 ++++++++++++++++++
 src/mirror/Makefile                           |   2 +-
 src/nfv/Makefile                              |   2 +-
 src/pcap/Makefile                             |   2 +-
 src/primary/Makefile                          |   2 +-
 src/vf/Makefile                               |   2 +-
 9 files changed, 461 insertions(+), 5 deletions(-)
 create mode 100644 src/drivers/pipe/Makefile
 create mode 100644 src/drivers/pipe/rte_pmd_spp_pipe_version.map
 create mode 100644 src/drivers/pipe/rte_spp_pipe.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH 1/7] drivers/pipe: add pipe PMD driver
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
@ 2020-02-25 23:32 ` Itsuro Oda
  2020-02-28  8:30   ` Yasufumi Ogawa
  2020-02-25 23:32 ` [spp] [PATCH 2/7] drivers: add pipe PMD in Makefile Itsuro Oda
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

pipe PMD provides a device named spp_pipe which communicates
using rings allocated by spp_primary.
For example spp_pipe0 made with devargs "rx=ring:0,tx=ring:1"
recieves packets from ring:0 and sends packets to ring:1.
spp_pipe enables high-speed communication between an application
and other application or SPP secondary processes (ex. spp_nfv)
using rings.
Note that an application using spp_pipe must be a secondary
process under spp_primary.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/drivers/pipe/Makefile                     |  26 ++
 src/drivers/pipe/rte_pmd_spp_pipe_version.map |   4 +
 src/drivers/pipe/rte_spp_pipe.c               | 425 ++++++++++++++++++
 3 files changed, 455 insertions(+)
 create mode 100644 src/drivers/pipe/Makefile
 create mode 100644 src/drivers/pipe/rte_pmd_spp_pipe_version.map
 create mode 100644 src/drivers/pipe/rte_spp_pipe.c

diff --git a/src/drivers/pipe/Makefile b/src/drivers/pipe/Makefile
new file mode 100644
index 0000000..a401dc6
--- /dev/null
+++ b/src/drivers/pipe/Makefile
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Nippon Telegraph and Telephone Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_spp_pipe.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
+LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
+LDLIBS += -lrte_bus_vdev
+
+EXPORT_MAP := rte_pmd_spp_pipe_version.map
+
+LIBABIVER := 2
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y += rte_spp_pipe.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/src/drivers/pipe/rte_pmd_spp_pipe_version.map b/src/drivers/pipe/rte_pmd_spp_pipe_version.map
new file mode 100644
index 0000000..ef35398
--- /dev/null
+++ b/src/drivers/pipe/rte_pmd_spp_pipe_version.map
@@ -0,0 +1,4 @@
+DPDK_2.0 {
+
+	local: *;
+};
diff --git a/src/drivers/pipe/rte_spp_pipe.c b/src/drivers/pipe/rte_spp_pipe.c
new file mode 100644
index 0000000..18618dd
--- /dev/null
+++ b/src/drivers/pipe/rte_spp_pipe.c
@@ -0,0 +1,425 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation
+ * Copyright(c) 2020 Nippon Telegraph and Telephone Corporation
+ */
+
+#include "rte_eth_ring.h"
+#include <rte_mbuf.h>
+#include <rte_ethdev_driver.h>
+#include <rte_ethdev_vdev.h>
+#include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_string_fns.h>
+#include <rte_bus_vdev.h>
+#include <rte_kvargs.h>
+#include <rte_errno.h>
+#include <string.h>
+
+#define ETH_PIPE_RX_ARG	"rx"
+#define ETH_PIPE_TX_ARG	"tx"
+
+/* TODO: define in config */
+#define PMD_PIPE_MAX_RX_RINGS 1
+#define PMD_PIPE_MAX_TX_RINGS 1
+
+static const char *valid_arguments[] = {
+	ETH_PIPE_RX_ARG,
+	ETH_PIPE_TX_ARG,
+	NULL
+};
+
+struct ring_queue {
+	struct rte_ring *rng;
+	rte_atomic64_t rx_pkts;
+	rte_atomic64_t tx_pkts;
+	rte_atomic64_t err_pkts;
+};
+
+struct pipe_private {
+	uint16_t nb_rx_queues;
+	uint16_t nb_tx_queues;
+	struct ring_queue rx_ring_queues[PMD_PIPE_MAX_RX_RINGS];
+	struct ring_queue tx_ring_queues[PMD_PIPE_MAX_TX_RINGS];
+};
+
+static struct rte_eth_link pmd_pipe_link = {
+	.link_speed = ETH_SPEED_NUM_10G,
+	.link_duplex = ETH_LINK_FULL_DUPLEX,
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_FIXED,
+};
+
+static int eth_pipe_logtype;
+
+#define PMD_PIPE_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, eth_pipe_logtype, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+static uint16_t
+eth_pipe_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+	void **ptrs = (void *)&bufs[0];
+	struct ring_queue *r = q;
+	uint16_t nb_rx;
+
+	if (!q)
+		return 0;
+
+	nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng, ptrs, nb_bufs, NULL);
+
+	if (r->rng->flags & RING_F_SC_DEQ)
+		r->rx_pkts.cnt += nb_rx;
+	else
+		rte_atomic64_add(&(r->rx_pkts), nb_rx);
+
+	return nb_rx;
+}
+
+static uint16_t
+eth_pipe_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+	void **ptrs = (void *)&bufs[0];
+	struct ring_queue *r = q;
+	uint16_t nb_tx;
+
+	if (!q)
+		return 0;
+
+	nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng, ptrs, nb_bufs, NULL);
+
+	if (r->rng->flags & RING_F_SP_ENQ) {
+		r->tx_pkts.cnt += nb_tx;
+		r->err_pkts.cnt += nb_bufs - nb_tx;
+	} else {
+		rte_atomic64_add(&(r->tx_pkts), nb_tx);
+		rte_atomic64_add(&(r->err_pkts), nb_bufs - nb_tx);
+	}
+
+	return nb_tx;
+}
+
+static int
+eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
+{
+	return 0;
+}
+
+static int
+eth_dev_start(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_UP;
+	return 0;
+}
+
+static void
+eth_dev_stop(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+}
+
+static int
+eth_rx_queue_setup(struct rte_eth_dev *dev,
+		uint16_t rx_queue_id,
+		uint16_t nb_rx_desc __rte_unused,
+		unsigned int socket_id __rte_unused,
+		const struct rte_eth_rxconf *rx_conf __rte_unused,
+		struct rte_mempool *mb_pool __rte_unused)
+{
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	dev->data->rx_queues[rx_queue_id] = &pipe_priv->rx_ring_queues[rx_queue_id];
+	return 0;
+}
+
+static int
+eth_tx_queue_setup(struct rte_eth_dev *dev,
+		uint16_t tx_queue_id,
+		uint16_t nb_tx_desc __rte_unused,
+		unsigned int socket_id __rte_unused,
+		const struct rte_eth_txconf *tx_conf __rte_unused)
+{
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	dev->data->tx_queues[tx_queue_id] = &pipe_priv->tx_ring_queues[tx_queue_id];
+	return 0;
+}
+
+static int
+eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	dev_info->max_mac_addrs = 1;
+	dev_info->max_rx_pktlen = (uint32_t)-1;
+	dev_info->max_rx_queues = pipe_priv->nb_rx_queues;
+	dev_info->max_tx_queues = pipe_priv->nb_tx_queues;
+	dev_info->min_rx_bufsize = 0;
+
+	return 0;
+}
+
+static int
+eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	unsigned i;
+	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
+	const struct pipe_private *pipe_priv = dev->data->dev_private;
+
+	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+			i < dev->data->nb_rx_queues; i++) {
+		stats->q_ipackets[i] = pipe_priv->rx_ring_queues[i].rx_pkts.cnt;
+		rx_total += stats->q_ipackets[i];
+	}
+
+	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+			i < dev->data->nb_tx_queues; i++) {
+		stats->q_opackets[i] = pipe_priv->tx_ring_queues[i].tx_pkts.cnt;
+		stats->q_errors[i] = pipe_priv->tx_ring_queues[i].err_pkts.cnt;
+		tx_total += stats->q_opackets[i];
+		tx_err_total += stats->q_errors[i];
+	}
+
+	stats->ipackets = rx_total;
+	stats->opackets = tx_total;
+	stats->oerrors = tx_err_total;
+
+	return 0;
+}
+
+static int
+eth_stats_reset(struct rte_eth_dev *dev)
+{
+	unsigned i;
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	for (i = 0; i < dev->data->nb_rx_queues; i++)
+		pipe_priv->rx_ring_queues[i].rx_pkts.cnt = 0;
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		pipe_priv->tx_ring_queues[i].tx_pkts.cnt = 0;
+		pipe_priv->tx_ring_queues[i].err_pkts.cnt = 0;
+	}
+
+	return 0;
+}
+
+static void
+eth_queue_release(void *q __rte_unused)
+{
+}
+
+static int
+eth_link_update(struct rte_eth_dev *dev __rte_unused,
+		int wait_to_complete __rte_unused)
+{
+	return 0;
+}
+
+static const struct eth_dev_ops ops = {
+	.dev_start = eth_dev_start,
+	.dev_stop = eth_dev_stop,
+	.dev_configure = eth_dev_configure,
+	.dev_infos_get = eth_dev_info,
+	.rx_queue_setup = eth_rx_queue_setup,
+	.tx_queue_setup = eth_tx_queue_setup,
+	.rx_queue_release = eth_queue_release,
+	.tx_queue_release = eth_queue_release,
+	.link_update = eth_link_update,
+	.stats_get = eth_stats_get,
+	.stats_reset = eth_stats_reset,
+};
+
+static char *get_rx_queue_name(unsigned int id)
+{
+        static char buffer[32];
+
+        snprintf(buffer, sizeof(buffer) - 1, "eth_ring%u", id);
+
+        return buffer;
+}
+
+static int
+validate_ring_name(const char *value, unsigned *num)
+{
+	const char *ring_name = "ring:";
+	size_t len = strlen(ring_name);
+	const char *num_start = value + len;
+	char *end;
+
+	if (value == NULL || strncmp(ring_name, value, len) != 0) {
+		return -1;
+	}
+
+	*num = (unsigned)strtoul(num_start, &end, 10);
+	if (*num_start == '\0' || *end != '\0') {
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+parse_rings(const char *key, const char *value, void *data)
+{
+	struct pipe_private *pipe_priv = data;
+	unsigned num;
+	struct rte_ring *r;
+
+	if (validate_ring_name(value, &num) == -1) {
+		PMD_PIPE_LOG(ERR, "invalid ring name %s", value);
+		return -1;
+	}
+
+	r = rte_ring_lookup(get_rx_queue_name(num));
+	if (r == NULL) {
+		PMD_PIPE_LOG(ERR, "ring %s does not exist", value);
+		return -1;
+	}
+
+	PMD_PIPE_LOG(DEBUG, "%s %s cons.head: %u cons.tail: %u "
+			"prod.head: %u prod.tail: %u",
+			key, value, r->cons.head, r->cons.tail,
+			r->prod.head, r->prod.tail);
+
+	if(strcmp(key, ETH_PIPE_RX_ARG) == 0) {
+		if (pipe_priv->nb_rx_queues >= PMD_PIPE_MAX_RX_RINGS) {
+			PMD_PIPE_LOG(ERR, "rx rings exceeds max(%d)",
+					PMD_PIPE_MAX_RX_RINGS);
+			return -1;
+		}
+		pipe_priv->rx_ring_queues[pipe_priv->nb_rx_queues].rng = r;
+		pipe_priv->nb_rx_queues++;
+	} else { /* ETH_PIPE_TX_ARG */
+		if (pipe_priv->nb_tx_queues >= PMD_PIPE_MAX_TX_RINGS) {
+			PMD_PIPE_LOG(ERR, "tx rings exceeds max(%d)",
+					PMD_PIPE_MAX_TX_RINGS);
+			return -1;
+		}
+		pipe_priv->tx_ring_queues[pipe_priv->nb_tx_queues].rng = r;
+		pipe_priv->nb_tx_queues++;
+	}
+
+	return 0;
+}
+
+static int
+rte_pmd_pipe_probe(struct rte_vdev_device *dev)
+{
+	const char *name = rte_vdev_device_name(dev);
+	struct rte_kvargs *kvlist;
+	int ret;
+	struct pipe_private *pipe_priv;
+	struct rte_eth_dev *eth_dev;
+	struct rte_ether_addr *eth_addr;
+
+	PMD_PIPE_LOG(INFO, "Initializing pmd_pipe for %s", name);
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		PMD_PIPE_LOG(DEBUG, "secondary");
+		eth_dev = rte_eth_dev_attach_secondary(name);
+		if (!eth_dev) {
+			PMD_PIPE_LOG(ERR, "device not found");
+			return -EINVAL;
+		}
+
+		eth_dev->dev_ops = &ops;
+		eth_dev->rx_pkt_burst = eth_pipe_rx;
+		eth_dev->tx_pkt_burst = eth_pipe_tx;
+		eth_dev->device = &dev->device;
+
+		rte_eth_dev_probing_finish(eth_dev);
+
+		PMD_PIPE_LOG(DEBUG, "%s created", name);
+		PMD_PIPE_LOG(DEBUG, "port_id = %d", eth_dev->data->port_id);
+
+		return 0;
+	}
+
+	kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
+	if (kvlist == NULL) {
+		PMD_PIPE_LOG(ERR, "invalid parameter");
+		return -EINVAL;
+	}
+
+	eth_addr = rte_zmalloc_socket(NULL, sizeof(*eth_addr), 0, rte_socket_id());
+	if (eth_addr == NULL) {
+		PMD_PIPE_LOG(ERR, "can't alloc memory");
+		rte_kvargs_free(kvlist);
+		return -ENOMEM;
+	}
+
+	eth_dev = rte_eth_vdev_allocate(dev, sizeof(*pipe_priv));
+	if (eth_dev == NULL) {
+		PMD_PIPE_LOG(ERR, "can't alloc memory");
+		rte_kvargs_free(kvlist);
+		return -ENOMEM;
+	}
+
+	pipe_priv = eth_dev->data->dev_private;
+
+	ret = rte_kvargs_process(kvlist, NULL, parse_rings, pipe_priv);
+	rte_kvargs_free(kvlist);
+	if (ret == -1) {
+		ret = -EINVAL;
+	} else if (pipe_priv->nb_rx_queues == 0) {
+		PMD_PIPE_LOG(ERR, "no rx ring specified");
+		ret = -EINVAL;
+	} else if (pipe_priv->nb_tx_queues == 0) {
+		PMD_PIPE_LOG(ERR, "no tx ring specified");
+		ret = -EINVAL;
+	}
+	if (ret != 0) {
+		rte_eth_dev_release_port(eth_dev);
+		return ret;
+	}
+
+	eth_dev->data->dev_link = pmd_pipe_link;
+	eth_dev->data->mac_addrs = eth_addr;
+
+	eth_dev->dev_ops = &ops;
+	eth_dev->rx_pkt_burst = eth_pipe_rx;
+	eth_dev->tx_pkt_burst = eth_pipe_tx;
+
+	rte_eth_dev_probing_finish(eth_dev);
+
+	PMD_PIPE_LOG(DEBUG, "%s created", name);
+	PMD_PIPE_LOG(DEBUG, "port_id = %d", eth_dev->data->port_id);
+
+	return 0;
+}
+
+static int
+rte_pmd_pipe_remove(struct rte_vdev_device *dev)
+{
+	const char *name = rte_vdev_device_name(dev);
+	struct rte_eth_dev *eth_dev = NULL;
+
+	if (name == NULL)
+		return -EINVAL;
+
+	PMD_PIPE_LOG(INFO, "Un-Initializing pmd_pipe for %s", name);
+
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL) {
+		PMD_PIPE_LOG(ERR, "no eth_dev allocated for %s", name);
+		return -ENODEV;
+	}
+
+	eth_dev_stop(eth_dev);
+
+	rte_eth_dev_release_port(eth_dev);
+
+	PMD_PIPE_LOG(DEBUG, "%s removed", name);
+
+	return 0;
+}
+
+static struct rte_vdev_driver pmd_pipe_drv = {
+	.probe = rte_pmd_pipe_probe,
+	.remove = rte_pmd_pipe_remove,
+};
+
+RTE_PMD_REGISTER_VDEV(spp_pipe, pmd_pipe_drv);
+RTE_PMD_REGISTER_PARAM_STRING(spp_pipe, "rx=<rx_ring> tx=<tx_ring>");
+
+RTE_INIT(eth_pipe_init_log)
+{
+	eth_pipe_logtype = rte_log_register("pmd.spp.pipe");
+	if (eth_pipe_logtype >= 0)
+		rte_log_set_level(eth_pipe_logtype, RTE_LOG_INFO);
+}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH 2/7] drivers: add pipe PMD in Makefile
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
  2020-02-25 23:32 ` [spp] [PATCH 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
@ 2020-02-25 23:32 ` Itsuro Oda
  2020-02-25 23:33 ` [spp] [PATCH 3/7] spp_primary: add link to " Itsuro Oda
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds the directory of pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/drivers/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/drivers/Makefile b/src/drivers/Makefile
index f2deba7..f759238 100644
--- a/src/drivers/Makefile
+++ b/src/drivers/Makefile
@@ -11,5 +11,6 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 include $(RTE_SDK)/mk/rte.vars.mk
 
 DIRS-y += vhost
+DIRS-y += pipe
 
 include $(RTE_SDK)/mk/rte.extsubdir.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH 3/7] spp_primary: add link to pipe PMD in Makefile
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
  2020-02-25 23:32 ` [spp] [PATCH 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
  2020-02-25 23:32 ` [spp] [PATCH 2/7] drivers: add pipe PMD in Makefile Itsuro Oda
@ 2020-02-25 23:33 ` " Itsuro Oda
  2020-02-25 23:33 ` [spp] [PATCH 4/7] spp_nfv: " Itsuro Oda
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:33 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/primary/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/primary/Makefile b/src/primary/Makefile
index ace6228..997cdb4 100644
--- a/src/primary/Makefile
+++ b/src/primary/Makefile
@@ -42,6 +42,6 @@ endif
 EXTRA_CFLAGS += -fno-strict-aliasing
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH 4/7] spp_nfv: add link to pipe PMD in Makefile
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
                   ` (2 preceding siblings ...)
  2020-02-25 23:33 ` [spp] [PATCH 3/7] spp_primary: add link to " Itsuro Oda
@ 2020-02-25 23:33 ` " Itsuro Oda
  2020-02-25 23:33 ` [spp] [PATCH 5/7] spp_vf: " Itsuro Oda
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:33 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/nfv/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nfv/Makefile b/src/nfv/Makefile
index a717616..16a10f7 100644
--- a/src/nfv/Makefile
+++ b/src/nfv/Makefile
@@ -28,6 +28,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH 5/7] spp_vf: add link to pipe PMD in Makefile
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
                   ` (3 preceding siblings ...)
  2020-02-25 23:33 ` [spp] [PATCH 4/7] spp_nfv: " Itsuro Oda
@ 2020-02-25 23:33 ` " Itsuro Oda
  2020-02-25 23:33 ` [spp] [PATCH 6/7] spp_mirror: " Itsuro Oda
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:33 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/vf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vf/Makefile b/src/vf/Makefile
index e42f8b7..0f7410f 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -49,6 +49,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH 6/7] spp_mirror: add link to pipe PMD in Makefile
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
                   ` (4 preceding siblings ...)
  2020-02-25 23:33 ` [spp] [PATCH 5/7] spp_vf: " Itsuro Oda
@ 2020-02-25 23:33 ` " Itsuro Oda
  2020-02-25 23:33 ` [spp] [PATCH 7/7] spp_pcap: " Itsuro Oda
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:33 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/mirror/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mirror/Makefile b/src/mirror/Makefile
index f82b08f..e00ca76 100644
--- a/src/mirror/Makefile
+++ b/src/mirror/Makefile
@@ -54,6 +54,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH 7/7] spp_pcap: add link to pipe PMD in Makefile
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
                   ` (5 preceding siblings ...)
  2020-02-25 23:33 ` [spp] [PATCH 6/7] spp_mirror: " Itsuro Oda
@ 2020-02-25 23:33 ` " Itsuro Oda
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-02-25 23:33 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/pcap/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pcap/Makefile b/src/pcap/Makefile
index 7d93c60..fd51c65 100644
--- a/src/pcap/Makefile
+++ b/src/pcap/Makefile
@@ -44,6 +44,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [spp] [PATCH 1/7] drivers/pipe: add pipe PMD driver
  2020-02-25 23:32 ` [spp] [PATCH 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
@ 2020-02-28  8:30   ` Yasufumi Ogawa
  0 siblings, 0 replies; 18+ messages in thread
From: Yasufumi Ogawa @ 2020-02-28  8:30 UTC (permalink / raw)
  To: Itsuro Oda; +Cc: spp, ferruh.yigit

Hi,

I have checked your latest 15 patches and found two patches are invalid. 
I'd appreciate if you fix them quickly. This is the first one.

Thanks.

$ checkpatches.sh patches/0001-drivers-pipe-add-pipe-PMD-driver.patch

### [PATCH 01/15] drivers/pipe: add pipe PMD driver

WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should 
probably be static const char * const
#98: FILE: src/drivers/pipe/rte_spp_pipe.c:25:
+static const char *valid_arguments[] = {

WARNING:LONG_LINE: line over 80 characters
#202: FILE: src/drivers/pipe/rte_spp_pipe.c:129:
+	dev->data->rx_queues[rx_queue_id] = 
&pipe_priv->rx_ring_queues[rx_queue_id];

WARNING:LONG_LINE: line over 80 characters
#214: FILE: src/drivers/pipe/rte_spp_pipe.c:141:
+	dev->data->tx_queues[tx_queue_id] = 
&pipe_priv->tx_ring_queues[tx_queue_id];

WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#234: FILE: src/drivers/pipe/rte_spp_pipe.c:161:
+	unsigned i;

WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#262: FILE: src/drivers/pipe/rte_spp_pipe.c:189:
+	unsigned i;

ERROR:CODE_INDENT: code indent should use tabs where possible
#302: FILE: src/drivers/pipe/rte_spp_pipe.c:229:
+        static char buffer[32];$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#302: FILE: src/drivers/pipe/rte_spp_pipe.c:229:
+        static char buffer[32];$

ERROR:CODE_INDENT: code indent should use tabs where possible
#304: FILE: src/drivers/pipe/rte_spp_pipe.c:231:
+        snprintf(buffer, sizeof(buffer) - 1, "eth_ring%u", id);$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#304: FILE: src/drivers/pipe/rte_spp_pipe.c:231:
+        snprintf(buffer, sizeof(buffer) - 1, "eth_ring%u", id);$

ERROR:CODE_INDENT: code indent should use tabs where possible
#306: FILE: src/drivers/pipe/rte_spp_pipe.c:233:
+        return buffer;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#306: FILE: src/drivers/pipe/rte_spp_pipe.c:233:
+        return buffer;$

WARNING:UNSPECIFIED_INT: Prefer 'unsigned int *' to bare use of 'unsigned *'
#310: FILE: src/drivers/pipe/rte_spp_pipe.c:237:
+validate_ring_name(const char *value, unsigned *num)

WARNING:BRACES: braces {} are not necessary for single statement blocks
#317: FILE: src/drivers/pipe/rte_spp_pipe.c:244:
+	if (value == NULL || strncmp(ring_name, value, len) != 0) {
+		return -1;
+	}

WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#321: FILE: src/drivers/pipe/rte_spp_pipe.c:248:
+	*num = (unsigned)strtoul(num_start, &end, 10);

WARNING:BRACES: braces {} are not necessary for single statement blocks
#322: FILE: src/drivers/pipe/rte_spp_pipe.c:249:
+	if (*num_start == '\0' || *end != '\0') {
+		return -1;
+	}

WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#333: FILE: src/drivers/pipe/rte_spp_pipe.c:260:
+	unsigned num;

ERROR:SPACING: space required before the open parenthesis '('
#352: FILE: src/drivers/pipe/rte_spp_pipe.c:279:
+	if(strcmp(key, ETH_PIPE_RX_ARG) == 0) {

WARNING:LONG_LINE: line over 80 characters
#412: FILE: src/drivers/pipe/rte_spp_pipe.c:339:
+	eth_addr = rte_zmalloc_socket(NULL, sizeof(*eth_addr), 0, 
rte_socket_id());

total: 4 errors, 14 warnings, 455 lines checked

0/1 valid patch


On 2020/02/26 8:32, Itsuro Oda wrote:
> pipe PMD provides a device named spp_pipe which communicates
> using rings allocated by spp_primary.
> For example spp_pipe0 made with devargs "rx=ring:0,tx=ring:1"
> recieves packets from ring:0 and sends packets to ring:1.
> spp_pipe enables high-speed communication between an application
> and other application or SPP secondary processes (ex. spp_nfv)
> using rings.
> Note that an application using spp_pipe must be a secondary
> process under spp_primary.
> 
> Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
> ---
>   src/drivers/pipe/Makefile                     |  26 ++
>   src/drivers/pipe/rte_pmd_spp_pipe_version.map |   4 +
>   src/drivers/pipe/rte_spp_pipe.c               | 425 ++++++++++++++++++
>   3 files changed, 455 insertions(+)
>   create mode 100644 src/drivers/pipe/Makefile
>   create mode 100644 src/drivers/pipe/rte_pmd_spp_pipe_version.map
>   create mode 100644 src/drivers/pipe/rte_spp_pipe.c
> 
> diff --git a/src/drivers/pipe/Makefile b/src/drivers/pipe/Makefile
> new file mode 100644
> index 0000000..a401dc6
> --- /dev/null
> +++ b/src/drivers/pipe/Makefile
> @@ -0,0 +1,26 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2020 Nippon Telegraph and Telephone Corporation
> +
> +include $(RTE_SDK)/mk/rte.vars.mk
> +
> +#
> +# library name
> +#
> +LIB = librte_pmd_spp_pipe.a
> +
> +CFLAGS += -O3
> +CFLAGS += $(WERROR_FLAGS)
> +LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
> +LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
> +LDLIBS += -lrte_bus_vdev
> +
> +EXPORT_MAP := rte_pmd_spp_pipe_version.map
> +
> +LIBABIVER := 2
> +
> +#
> +# all source are stored in SRCS-y
> +#
> +SRCS-y += rte_spp_pipe.c
> +
> +include $(RTE_SDK)/mk/rte.lib.mk
> diff --git a/src/drivers/pipe/rte_pmd_spp_pipe_version.map b/src/drivers/pipe/rte_pmd_spp_pipe_version.map
> new file mode 100644
> index 0000000..ef35398
> --- /dev/null
> +++ b/src/drivers/pipe/rte_pmd_spp_pipe_version.map
> @@ -0,0 +1,4 @@
> +DPDK_2.0 {
> +
> +	local: *;
> +};
> diff --git a/src/drivers/pipe/rte_spp_pipe.c b/src/drivers/pipe/rte_spp_pipe.c
> new file mode 100644
> index 0000000..18618dd
> --- /dev/null
> +++ b/src/drivers/pipe/rte_spp_pipe.c
> @@ -0,0 +1,425 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2015 Intel Corporation
> + * Copyright(c) 2020 Nippon Telegraph and Telephone Corporation
> + */
> +
> +#include "rte_eth_ring.h"
> +#include <rte_mbuf.h>
> +#include <rte_ethdev_driver.h>
> +#include <rte_ethdev_vdev.h>
> +#include <rte_malloc.h>
> +#include <rte_memcpy.h>
> +#include <rte_string_fns.h>
> +#include <rte_bus_vdev.h>
> +#include <rte_kvargs.h>
> +#include <rte_errno.h>
> +#include <string.h>
> +
> +#define ETH_PIPE_RX_ARG	"rx"
> +#define ETH_PIPE_TX_ARG	"tx"
> +
> +/* TODO: define in config */
> +#define PMD_PIPE_MAX_RX_RINGS 1
> +#define PMD_PIPE_MAX_TX_RINGS 1
> +
> +static const char *valid_arguments[] = {
> +	ETH_PIPE_RX_ARG,
> +	ETH_PIPE_TX_ARG,
> +	NULL
> +};
> +
> +struct ring_queue {
> +	struct rte_ring *rng;
> +	rte_atomic64_t rx_pkts;
> +	rte_atomic64_t tx_pkts;
> +	rte_atomic64_t err_pkts;
> +};
> +
> +struct pipe_private {
> +	uint16_t nb_rx_queues;
> +	uint16_t nb_tx_queues;
> +	struct ring_queue rx_ring_queues[PMD_PIPE_MAX_RX_RINGS];
> +	struct ring_queue tx_ring_queues[PMD_PIPE_MAX_TX_RINGS];
> +};
> +
> +static struct rte_eth_link pmd_pipe_link = {
> +	.link_speed = ETH_SPEED_NUM_10G,
> +	.link_duplex = ETH_LINK_FULL_DUPLEX,
> +	.link_status = ETH_LINK_DOWN,
> +	.link_autoneg = ETH_LINK_FIXED,
> +};
> +
> +static int eth_pipe_logtype;
> +
> +#define PMD_PIPE_LOG(level, fmt, args...) \
> +	rte_log(RTE_LOG_ ## level, eth_pipe_logtype, \
> +		"%s(): " fmt "\n", __func__, ##args)
> +
> +static uint16_t
> +eth_pipe_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
> +{
> +	void **ptrs = (void *)&bufs[0];
> +	struct ring_queue *r = q;
> +	uint16_t nb_rx;
> +
> +	if (!q)
> +		return 0;
> +
> +	nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng, ptrs, nb_bufs, NULL);
> +
> +	if (r->rng->flags & RING_F_SC_DEQ)
> +		r->rx_pkts.cnt += nb_rx;
> +	else
> +		rte_atomic64_add(&(r->rx_pkts), nb_rx);
> +
> +	return nb_rx;
> +}
> +
> +static uint16_t
> +eth_pipe_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
> +{
> +	void **ptrs = (void *)&bufs[0];
> +	struct ring_queue *r = q;
> +	uint16_t nb_tx;
> +
> +	if (!q)
> +		return 0;
> +
> +	nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng, ptrs, nb_bufs, NULL);
> +
> +	if (r->rng->flags & RING_F_SP_ENQ) {
> +		r->tx_pkts.cnt += nb_tx;
> +		r->err_pkts.cnt += nb_bufs - nb_tx;
> +	} else {
> +		rte_atomic64_add(&(r->tx_pkts), nb_tx);
> +		rte_atomic64_add(&(r->err_pkts), nb_bufs - nb_tx);
> +	}
> +
> +	return nb_tx;
> +}
> +
> +static int
> +eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
> +{
> +	return 0;
> +}
> +
> +static int
> +eth_dev_start(struct rte_eth_dev *dev)
> +{
> +	dev->data->dev_link.link_status = ETH_LINK_UP;
> +	return 0;
> +}
> +
> +static void
> +eth_dev_stop(struct rte_eth_dev *dev)
> +{
> +	dev->data->dev_link.link_status = ETH_LINK_DOWN;
> +}
> +
> +static int
> +eth_rx_queue_setup(struct rte_eth_dev *dev,
> +		uint16_t rx_queue_id,
> +		uint16_t nb_rx_desc __rte_unused,
> +		unsigned int socket_id __rte_unused,
> +		const struct rte_eth_rxconf *rx_conf __rte_unused,
> +		struct rte_mempool *mb_pool __rte_unused)
> +{
> +	struct pipe_private *pipe_priv = dev->data->dev_private;
> +	dev->data->rx_queues[rx_queue_id] = &pipe_priv->rx_ring_queues[rx_queue_id];
> +	return 0;
> +}
> +
> +static int
> +eth_tx_queue_setup(struct rte_eth_dev *dev,
> +		uint16_t tx_queue_id,
> +		uint16_t nb_tx_desc __rte_unused,
> +		unsigned int socket_id __rte_unused,
> +		const struct rte_eth_txconf *tx_conf __rte_unused)
> +{
> +	struct pipe_private *pipe_priv = dev->data->dev_private;
> +	dev->data->tx_queues[tx_queue_id] = &pipe_priv->tx_ring_queues[tx_queue_id];
> +	return 0;
> +}
> +
> +static int
> +eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
> +{
> +	struct pipe_private *pipe_priv = dev->data->dev_private;
> +	dev_info->max_mac_addrs = 1;
> +	dev_info->max_rx_pktlen = (uint32_t)-1;
> +	dev_info->max_rx_queues = pipe_priv->nb_rx_queues;
> +	dev_info->max_tx_queues = pipe_priv->nb_tx_queues;
> +	dev_info->min_rx_bufsize = 0;
> +
> +	return 0;
> +}
> +
> +static int
> +eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
> +{
> +	unsigned i;
> +	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
> +	const struct pipe_private *pipe_priv = dev->data->dev_private;
> +
> +	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
> +			i < dev->data->nb_rx_queues; i++) {
> +		stats->q_ipackets[i] = pipe_priv->rx_ring_queues[i].rx_pkts.cnt;
> +		rx_total += stats->q_ipackets[i];
> +	}
> +
> +	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
> +			i < dev->data->nb_tx_queues; i++) {
> +		stats->q_opackets[i] = pipe_priv->tx_ring_queues[i].tx_pkts.cnt;
> +		stats->q_errors[i] = pipe_priv->tx_ring_queues[i].err_pkts.cnt;
> +		tx_total += stats->q_opackets[i];
> +		tx_err_total += stats->q_errors[i];
> +	}
> +
> +	stats->ipackets = rx_total;
> +	stats->opackets = tx_total;
> +	stats->oerrors = tx_err_total;
> +
> +	return 0;
> +}
> +
> +static int
> +eth_stats_reset(struct rte_eth_dev *dev)
> +{
> +	unsigned i;
> +	struct pipe_private *pipe_priv = dev->data->dev_private;
> +	for (i = 0; i < dev->data->nb_rx_queues; i++)
> +		pipe_priv->rx_ring_queues[i].rx_pkts.cnt = 0;
> +	for (i = 0; i < dev->data->nb_tx_queues; i++) {
> +		pipe_priv->tx_ring_queues[i].tx_pkts.cnt = 0;
> +		pipe_priv->tx_ring_queues[i].err_pkts.cnt = 0;
> +	}
> +
> +	return 0;
> +}
> +
> +static void
> +eth_queue_release(void *q __rte_unused)
> +{
> +}
> +
> +static int
> +eth_link_update(struct rte_eth_dev *dev __rte_unused,
> +		int wait_to_complete __rte_unused)
> +{
> +	return 0;
> +}
> +
> +static const struct eth_dev_ops ops = {
> +	.dev_start = eth_dev_start,
> +	.dev_stop = eth_dev_stop,
> +	.dev_configure = eth_dev_configure,
> +	.dev_infos_get = eth_dev_info,
> +	.rx_queue_setup = eth_rx_queue_setup,
> +	.tx_queue_setup = eth_tx_queue_setup,
> +	.rx_queue_release = eth_queue_release,
> +	.tx_queue_release = eth_queue_release,
> +	.link_update = eth_link_update,
> +	.stats_get = eth_stats_get,
> +	.stats_reset = eth_stats_reset,
> +};
> +
> +static char *get_rx_queue_name(unsigned int id)
> +{
> +        static char buffer[32];
> +
> +        snprintf(buffer, sizeof(buffer) - 1, "eth_ring%u", id);
> +
> +        return buffer;
> +}
> +
> +static int
> +validate_ring_name(const char *value, unsigned *num)
> +{
> +	const char *ring_name = "ring:";
> +	size_t len = strlen(ring_name);
> +	const char *num_start = value + len;
> +	char *end;
> +
> +	if (value == NULL || strncmp(ring_name, value, len) != 0) {
> +		return -1;
> +	}
> +
> +	*num = (unsigned)strtoul(num_start, &end, 10);
> +	if (*num_start == '\0' || *end != '\0') {
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +parse_rings(const char *key, const char *value, void *data)
> +{
> +	struct pipe_private *pipe_priv = data;
> +	unsigned num;
> +	struct rte_ring *r;
> +
> +	if (validate_ring_name(value, &num) == -1) {
> +		PMD_PIPE_LOG(ERR, "invalid ring name %s", value);
> +		return -1;
> +	}
> +
> +	r = rte_ring_lookup(get_rx_queue_name(num));
> +	if (r == NULL) {
> +		PMD_PIPE_LOG(ERR, "ring %s does not exist", value);
> +		return -1;
> +	}
> +
> +	PMD_PIPE_LOG(DEBUG, "%s %s cons.head: %u cons.tail: %u "
> +			"prod.head: %u prod.tail: %u",
> +			key, value, r->cons.head, r->cons.tail,
> +			r->prod.head, r->prod.tail);
> +
> +	if(strcmp(key, ETH_PIPE_RX_ARG) == 0) {
> +		if (pipe_priv->nb_rx_queues >= PMD_PIPE_MAX_RX_RINGS) {
> +			PMD_PIPE_LOG(ERR, "rx rings exceeds max(%d)",
> +					PMD_PIPE_MAX_RX_RINGS);
> +			return -1;
> +		}
> +		pipe_priv->rx_ring_queues[pipe_priv->nb_rx_queues].rng = r;
> +		pipe_priv->nb_rx_queues++;
> +	} else { /* ETH_PIPE_TX_ARG */
> +		if (pipe_priv->nb_tx_queues >= PMD_PIPE_MAX_TX_RINGS) {
> +			PMD_PIPE_LOG(ERR, "tx rings exceeds max(%d)",
> +					PMD_PIPE_MAX_TX_RINGS);
> +			return -1;
> +		}
> +		pipe_priv->tx_ring_queues[pipe_priv->nb_tx_queues].rng = r;
> +		pipe_priv->nb_tx_queues++;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +rte_pmd_pipe_probe(struct rte_vdev_device *dev)
> +{
> +	const char *name = rte_vdev_device_name(dev);
> +	struct rte_kvargs *kvlist;
> +	int ret;
> +	struct pipe_private *pipe_priv;
> +	struct rte_eth_dev *eth_dev;
> +	struct rte_ether_addr *eth_addr;
> +
> +	PMD_PIPE_LOG(INFO, "Initializing pmd_pipe for %s", name);
> +
> +	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> +		PMD_PIPE_LOG(DEBUG, "secondary");
> +		eth_dev = rte_eth_dev_attach_secondary(name);
> +		if (!eth_dev) {
> +			PMD_PIPE_LOG(ERR, "device not found");
> +			return -EINVAL;
> +		}
> +
> +		eth_dev->dev_ops = &ops;
> +		eth_dev->rx_pkt_burst = eth_pipe_rx;
> +		eth_dev->tx_pkt_burst = eth_pipe_tx;
> +		eth_dev->device = &dev->device;
> +
> +		rte_eth_dev_probing_finish(eth_dev);
> +
> +		PMD_PIPE_LOG(DEBUG, "%s created", name);
> +		PMD_PIPE_LOG(DEBUG, "port_id = %d", eth_dev->data->port_id);
> +
> +		return 0;
> +	}
> +
> +	kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
> +	if (kvlist == NULL) {
> +		PMD_PIPE_LOG(ERR, "invalid parameter");
> +		return -EINVAL;
> +	}
> +
> +	eth_addr = rte_zmalloc_socket(NULL, sizeof(*eth_addr), 0, rte_socket_id());
> +	if (eth_addr == NULL) {
> +		PMD_PIPE_LOG(ERR, "can't alloc memory");
> +		rte_kvargs_free(kvlist);
> +		return -ENOMEM;
> +	}
> +
> +	eth_dev = rte_eth_vdev_allocate(dev, sizeof(*pipe_priv));
> +	if (eth_dev == NULL) {
> +		PMD_PIPE_LOG(ERR, "can't alloc memory");
> +		rte_kvargs_free(kvlist);
> +		return -ENOMEM;
> +	}
> +
> +	pipe_priv = eth_dev->data->dev_private;
> +
> +	ret = rte_kvargs_process(kvlist, NULL, parse_rings, pipe_priv);
> +	rte_kvargs_free(kvlist);
> +	if (ret == -1) {
> +		ret = -EINVAL;
> +	} else if (pipe_priv->nb_rx_queues == 0) {
> +		PMD_PIPE_LOG(ERR, "no rx ring specified");
> +		ret = -EINVAL;
> +	} else if (pipe_priv->nb_tx_queues == 0) {
> +		PMD_PIPE_LOG(ERR, "no tx ring specified");
> +		ret = -EINVAL;
> +	}
> +	if (ret != 0) {
> +		rte_eth_dev_release_port(eth_dev);
> +		return ret;
> +	}
> +
> +	eth_dev->data->dev_link = pmd_pipe_link;
> +	eth_dev->data->mac_addrs = eth_addr;
> +
> +	eth_dev->dev_ops = &ops;
> +	eth_dev->rx_pkt_burst = eth_pipe_rx;
> +	eth_dev->tx_pkt_burst = eth_pipe_tx;
> +
> +	rte_eth_dev_probing_finish(eth_dev);
> +
> +	PMD_PIPE_LOG(DEBUG, "%s created", name);
> +	PMD_PIPE_LOG(DEBUG, "port_id = %d", eth_dev->data->port_id);
> +
> +	return 0;
> +}
> +
> +static int
> +rte_pmd_pipe_remove(struct rte_vdev_device *dev)
> +{
> +	const char *name = rte_vdev_device_name(dev);
> +	struct rte_eth_dev *eth_dev = NULL;
> +
> +	if (name == NULL)
> +		return -EINVAL;
> +
> +	PMD_PIPE_LOG(INFO, "Un-Initializing pmd_pipe for %s", name);
> +
> +	eth_dev = rte_eth_dev_allocated(name);
> +	if (eth_dev == NULL) {
> +		PMD_PIPE_LOG(ERR, "no eth_dev allocated for %s", name);
> +		return -ENODEV;
> +	}
> +
> +	eth_dev_stop(eth_dev);
> +
> +	rte_eth_dev_release_port(eth_dev);
> +
> +	PMD_PIPE_LOG(DEBUG, "%s removed", name);
> +
> +	return 0;
> +}
> +
> +static struct rte_vdev_driver pmd_pipe_drv = {
> +	.probe = rte_pmd_pipe_probe,
> +	.remove = rte_pmd_pipe_remove,
> +};
> +
> +RTE_PMD_REGISTER_VDEV(spp_pipe, pmd_pipe_drv);
> +RTE_PMD_REGISTER_PARAM_STRING(spp_pipe, "rx=<rx_ring> tx=<tx_ring>");
> +
> +RTE_INIT(eth_pipe_init_log)
> +{
> +	eth_pipe_logtype = rte_log_register("pmd.spp.pipe");
> +	if (eth_pipe_logtype >= 0)
> +		rte_log_set_level(eth_pipe_logtype, RTE_LOG_INFO);
> +}
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 0/7] introduce pipe PMD
  2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
                   ` (6 preceding siblings ...)
  2020-02-25 23:33 ` [spp] [PATCH 7/7] spp_pcap: " Itsuro Oda
@ 2020-03-01 23:34 ` Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
                     ` (7 more replies)
  7 siblings, 8 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

pipe PMD provides a device named spp_pipe which communicates
using rings allocated by spp_primary.
For example spp_pipe0 made with devargs "rx=ring:0,tx=ring:1"
receives packets from ring:0 and sends packets to ring:1.
spp_pipe enables high-speed communication between an application
and other application or SPP secondary processes (ex. spp_nfv)
using rings.
Note that an application using spp_pipe must be a secondary
process under spp_primary.

This series of patches add the part of driver. CLI and REST
API to request to make spp_pipe devices will be provided
by following patches. The document will be provided by
following patches too.

---
v2:
* fix checkpatches.sh errors

Itsuro Oda (7):
  drivers/pipe: add pipe PMD driver
  drivers: add pipe PMD in Makefile
  spp_primary: add link to pipe PMD in Makefile
  spp_nfv: add link to pipe PMD in Makefile
  spp_vf: add link to pipe PMD in Makefile
  spp_mirror: add link to pipe PMD in Makefile
  spp_pcap: add link to pipe PMD in Makefile

 src/drivers/Makefile                          |   1 +
 src/drivers/pipe/Makefile                     |  26 ++
 src/drivers/pipe/rte_pmd_spp_pipe_version.map |   4 +
 src/drivers/pipe/rte_spp_pipe.c               | 426 ++++++++++++++++++
 src/mirror/Makefile                           |   2 +-
 src/nfv/Makefile                              |   2 +-
 src/pcap/Makefile                             |   2 +-
 src/primary/Makefile                          |   2 +-
 src/vf/Makefile                               |   2 +-
 9 files changed, 462 insertions(+), 5 deletions(-)
 create mode 100644 src/drivers/pipe/Makefile
 create mode 100644 src/drivers/pipe/rte_pmd_spp_pipe_version.map
 create mode 100644 src/drivers/pipe/rte_spp_pipe.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 1/7] drivers/pipe: add pipe PMD driver
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
@ 2020-03-01 23:34   ` Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 2/7] drivers: add pipe PMD in Makefile Itsuro Oda
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

pipe PMD provides a device named spp_pipe which communicates
using rings allocated by spp_primary.
For example spp_pipe0 made with devargs "rx=ring:0,tx=ring:1"
receives packets from ring:0 and sends packets to ring:1.
spp_pipe enables high-speed communication between an application
and other application or SPP secondary processes (ex. spp_nfv)
using rings.
Note that an application using spp_pipe must be a secondary
process under spp_primary.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/drivers/pipe/Makefile                     |  26 ++
 src/drivers/pipe/rte_pmd_spp_pipe_version.map |   4 +
 src/drivers/pipe/rte_spp_pipe.c               | 426 ++++++++++++++++++
 3 files changed, 456 insertions(+)
 create mode 100644 src/drivers/pipe/Makefile
 create mode 100644 src/drivers/pipe/rte_pmd_spp_pipe_version.map
 create mode 100644 src/drivers/pipe/rte_spp_pipe.c

diff --git a/src/drivers/pipe/Makefile b/src/drivers/pipe/Makefile
new file mode 100644
index 0000000..a401dc6
--- /dev/null
+++ b/src/drivers/pipe/Makefile
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Nippon Telegraph and Telephone Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_spp_pipe.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
+LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
+LDLIBS += -lrte_bus_vdev
+
+EXPORT_MAP := rte_pmd_spp_pipe_version.map
+
+LIBABIVER := 2
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y += rte_spp_pipe.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/src/drivers/pipe/rte_pmd_spp_pipe_version.map b/src/drivers/pipe/rte_pmd_spp_pipe_version.map
new file mode 100644
index 0000000..ef35398
--- /dev/null
+++ b/src/drivers/pipe/rte_pmd_spp_pipe_version.map
@@ -0,0 +1,4 @@
+DPDK_2.0 {
+
+	local: *;
+};
diff --git a/src/drivers/pipe/rte_spp_pipe.c b/src/drivers/pipe/rte_spp_pipe.c
new file mode 100644
index 0000000..6ffbbb6
--- /dev/null
+++ b/src/drivers/pipe/rte_spp_pipe.c
@@ -0,0 +1,426 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation
+ * Copyright(c) 2020 Nippon Telegraph and Telephone Corporation
+ */
+
+#include "rte_eth_ring.h"
+#include <rte_mbuf.h>
+#include <rte_ethdev_driver.h>
+#include <rte_ethdev_vdev.h>
+#include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_string_fns.h>
+#include <rte_bus_vdev.h>
+#include <rte_kvargs.h>
+#include <rte_errno.h>
+#include <string.h>
+
+#define ETH_PIPE_RX_ARG	"rx"
+#define ETH_PIPE_TX_ARG	"tx"
+
+/* TODO: define in config */
+#define PMD_PIPE_MAX_RX_RINGS 1
+#define PMD_PIPE_MAX_TX_RINGS 1
+
+static const char * const valid_arguments[] = {
+	ETH_PIPE_RX_ARG,
+	ETH_PIPE_TX_ARG,
+	NULL
+};
+
+struct ring_queue {
+	struct rte_ring *rng;
+	rte_atomic64_t rx_pkts;
+	rte_atomic64_t tx_pkts;
+	rte_atomic64_t err_pkts;
+};
+
+struct pipe_private {
+	uint16_t nb_rx_queues;
+	uint16_t nb_tx_queues;
+	struct ring_queue rx_ring_queues[PMD_PIPE_MAX_RX_RINGS];
+	struct ring_queue tx_ring_queues[PMD_PIPE_MAX_TX_RINGS];
+};
+
+static struct rte_eth_link pmd_pipe_link = {
+	.link_speed = ETH_SPEED_NUM_10G,
+	.link_duplex = ETH_LINK_FULL_DUPLEX,
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_FIXED,
+};
+
+static int eth_pipe_logtype;
+
+#define PMD_PIPE_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, eth_pipe_logtype, \
+		"%s(): " fmt "\n", __func__, ##args)
+
+static uint16_t
+eth_pipe_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+	void **ptrs = (void *)&bufs[0];
+	struct ring_queue *r = q;
+	uint16_t nb_rx;
+
+	if (!q)
+		return 0;
+
+	nb_rx = (uint16_t)rte_ring_dequeue_burst(r->rng, ptrs, nb_bufs, NULL);
+
+	if (r->rng->flags & RING_F_SC_DEQ)
+		r->rx_pkts.cnt += nb_rx;
+	else
+		rte_atomic64_add(&(r->rx_pkts), nb_rx);
+
+	return nb_rx;
+}
+
+static uint16_t
+eth_pipe_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+	void **ptrs = (void *)&bufs[0];
+	struct ring_queue *r = q;
+	uint16_t nb_tx;
+
+	if (!q)
+		return 0;
+
+	nb_tx = (uint16_t)rte_ring_enqueue_burst(r->rng, ptrs, nb_bufs, NULL);
+
+	if (r->rng->flags & RING_F_SP_ENQ) {
+		r->tx_pkts.cnt += nb_tx;
+		r->err_pkts.cnt += nb_bufs - nb_tx;
+	} else {
+		rte_atomic64_add(&(r->tx_pkts), nb_tx);
+		rte_atomic64_add(&(r->err_pkts), nb_bufs - nb_tx);
+	}
+
+	return nb_tx;
+}
+
+static int
+eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
+{
+	return 0;
+}
+
+static int
+eth_dev_start(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_UP;
+	return 0;
+}
+
+static void
+eth_dev_stop(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+}
+
+static int
+eth_rx_queue_setup(struct rte_eth_dev *dev,
+		uint16_t rx_queue_id,
+		uint16_t nb_rx_desc __rte_unused,
+		unsigned int socket_id __rte_unused,
+		const struct rte_eth_rxconf *rx_conf __rte_unused,
+		struct rte_mempool *mb_pool __rte_unused)
+{
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	dev->data->rx_queues[rx_queue_id] =
+				&pipe_priv->rx_ring_queues[rx_queue_id];
+	return 0;
+}
+
+static int
+eth_tx_queue_setup(struct rte_eth_dev *dev,
+		uint16_t tx_queue_id,
+		uint16_t nb_tx_desc __rte_unused,
+		unsigned int socket_id __rte_unused,
+		const struct rte_eth_txconf *tx_conf __rte_unused)
+{
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	dev->data->tx_queues[tx_queue_id] =
+				&pipe_priv->tx_ring_queues[tx_queue_id];
+	return 0;
+}
+
+static int
+eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	dev_info->max_mac_addrs = 1;
+	dev_info->max_rx_pktlen = (uint32_t)-1;
+	dev_info->max_rx_queues = pipe_priv->nb_rx_queues;
+	dev_info->max_tx_queues = pipe_priv->nb_tx_queues;
+	dev_info->min_rx_bufsize = 0;
+
+	return 0;
+}
+
+static int
+eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	unsigned int i;
+	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
+	const struct pipe_private *pipe_priv = dev->data->dev_private;
+
+	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+			i < dev->data->nb_rx_queues; i++) {
+		stats->q_ipackets[i] = pipe_priv->rx_ring_queues[i].rx_pkts.cnt;
+		rx_total += stats->q_ipackets[i];
+	}
+
+	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+			i < dev->data->nb_tx_queues; i++) {
+		stats->q_opackets[i] = pipe_priv->tx_ring_queues[i].tx_pkts.cnt;
+		stats->q_errors[i] = pipe_priv->tx_ring_queues[i].err_pkts.cnt;
+		tx_total += stats->q_opackets[i];
+		tx_err_total += stats->q_errors[i];
+	}
+
+	stats->ipackets = rx_total;
+	stats->opackets = tx_total;
+	stats->oerrors = tx_err_total;
+
+	return 0;
+}
+
+static int
+eth_stats_reset(struct rte_eth_dev *dev)
+{
+	unsigned int i;
+	struct pipe_private *pipe_priv = dev->data->dev_private;
+	for (i = 0; i < dev->data->nb_rx_queues; i++)
+		pipe_priv->rx_ring_queues[i].rx_pkts.cnt = 0;
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		pipe_priv->tx_ring_queues[i].tx_pkts.cnt = 0;
+		pipe_priv->tx_ring_queues[i].err_pkts.cnt = 0;
+	}
+
+	return 0;
+}
+
+static void
+eth_queue_release(void *q __rte_unused)
+{
+}
+
+static int
+eth_link_update(struct rte_eth_dev *dev __rte_unused,
+		int wait_to_complete __rte_unused)
+{
+	return 0;
+}
+
+static const struct eth_dev_ops ops = {
+	.dev_start = eth_dev_start,
+	.dev_stop = eth_dev_stop,
+	.dev_configure = eth_dev_configure,
+	.dev_infos_get = eth_dev_info,
+	.rx_queue_setup = eth_rx_queue_setup,
+	.tx_queue_setup = eth_tx_queue_setup,
+	.rx_queue_release = eth_queue_release,
+	.tx_queue_release = eth_queue_release,
+	.link_update = eth_link_update,
+	.stats_get = eth_stats_get,
+	.stats_reset = eth_stats_reset,
+};
+
+static char *get_rx_queue_name(unsigned int id)
+{
+	static char buffer[32];
+
+	snprintf(buffer, sizeof(buffer) - 1, "eth_ring%u", id);
+
+	return buffer;
+}
+
+static int
+validate_ring_name(const char *value, unsigned int *num)
+{
+	const char *ring_name = "ring:";
+	size_t len = strlen(ring_name);
+	const char *num_start = value + len;
+	char *end;
+
+	if (value == NULL || strncmp(ring_name, value, len) != 0)
+		return -1;
+
+	*num = (unsigned int)strtoul(num_start, &end, 10);
+	if (*num_start == '\0' || *end != '\0')
+		return -1;
+
+	return 0;
+}
+
+static int
+parse_rings(const char *key, const char *value, void *data)
+{
+	struct pipe_private *pipe_priv = data;
+	unsigned int num;
+	struct rte_ring *r;
+
+	if (validate_ring_name(value, &num) == -1) {
+		PMD_PIPE_LOG(ERR, "invalid ring name %s", value);
+		return -1;
+	}
+
+	r = rte_ring_lookup(get_rx_queue_name(num));
+	if (r == NULL) {
+		PMD_PIPE_LOG(ERR, "ring %s does not exist", value);
+		return -1;
+	}
+
+	PMD_PIPE_LOG(DEBUG, "%s %s cons.head: %u cons.tail: %u "
+			"prod.head: %u prod.tail: %u",
+			key, value, r->cons.head, r->cons.tail,
+			r->prod.head, r->prod.tail);
+
+	if (strcmp(key, ETH_PIPE_RX_ARG) == 0) {
+		if (pipe_priv->nb_rx_queues >= PMD_PIPE_MAX_RX_RINGS) {
+			PMD_PIPE_LOG(ERR, "rx rings exceeds max(%d)",
+					PMD_PIPE_MAX_RX_RINGS);
+			return -1;
+		}
+		pipe_priv->rx_ring_queues[pipe_priv->nb_rx_queues].rng = r;
+		pipe_priv->nb_rx_queues++;
+	} else { /* ETH_PIPE_TX_ARG */
+		if (pipe_priv->nb_tx_queues >= PMD_PIPE_MAX_TX_RINGS) {
+			PMD_PIPE_LOG(ERR, "tx rings exceeds max(%d)",
+					PMD_PIPE_MAX_TX_RINGS);
+			return -1;
+		}
+		pipe_priv->tx_ring_queues[pipe_priv->nb_tx_queues].rng = r;
+		pipe_priv->nb_tx_queues++;
+	}
+
+	return 0;
+}
+
+static int
+rte_pmd_pipe_probe(struct rte_vdev_device *dev)
+{
+	const char *name = rte_vdev_device_name(dev);
+	struct rte_kvargs *kvlist;
+	int ret;
+	struct pipe_private *pipe_priv;
+	struct rte_eth_dev *eth_dev;
+	struct rte_ether_addr *eth_addr;
+
+	PMD_PIPE_LOG(INFO, "Initializing pmd_pipe for %s", name);
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		PMD_PIPE_LOG(DEBUG, "secondary");
+		eth_dev = rte_eth_dev_attach_secondary(name);
+		if (!eth_dev) {
+			PMD_PIPE_LOG(ERR, "device not found");
+			return -EINVAL;
+		}
+
+		eth_dev->dev_ops = &ops;
+		eth_dev->rx_pkt_burst = eth_pipe_rx;
+		eth_dev->tx_pkt_burst = eth_pipe_tx;
+		eth_dev->device = &dev->device;
+
+		rte_eth_dev_probing_finish(eth_dev);
+
+		PMD_PIPE_LOG(DEBUG, "%s created", name);
+		PMD_PIPE_LOG(DEBUG, "port_id = %d", eth_dev->data->port_id);
+
+		return 0;
+	}
+
+	kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
+	if (kvlist == NULL) {
+		PMD_PIPE_LOG(ERR, "invalid parameter");
+		return -EINVAL;
+	}
+
+	eth_addr = rte_zmalloc_socket(NULL, sizeof(*eth_addr), 0,
+		       rte_socket_id());
+	if (eth_addr == NULL) {
+		PMD_PIPE_LOG(ERR, "can't alloc memory");
+		rte_kvargs_free(kvlist);
+		return -ENOMEM;
+	}
+
+	eth_dev = rte_eth_vdev_allocate(dev, sizeof(*pipe_priv));
+	if (eth_dev == NULL) {
+		PMD_PIPE_LOG(ERR, "can't alloc memory");
+		rte_kvargs_free(kvlist);
+		return -ENOMEM;
+	}
+
+	pipe_priv = eth_dev->data->dev_private;
+
+	ret = rte_kvargs_process(kvlist, NULL, parse_rings, pipe_priv);
+	rte_kvargs_free(kvlist);
+	if (ret == -1) {
+		ret = -EINVAL;
+	} else if (pipe_priv->nb_rx_queues == 0) {
+		PMD_PIPE_LOG(ERR, "no rx ring specified");
+		ret = -EINVAL;
+	} else if (pipe_priv->nb_tx_queues == 0) {
+		PMD_PIPE_LOG(ERR, "no tx ring specified");
+		ret = -EINVAL;
+	}
+	if (ret != 0) {
+		rte_eth_dev_release_port(eth_dev);
+		return ret;
+	}
+
+	eth_dev->data->dev_link = pmd_pipe_link;
+	eth_dev->data->mac_addrs = eth_addr;
+
+	eth_dev->dev_ops = &ops;
+	eth_dev->rx_pkt_burst = eth_pipe_rx;
+	eth_dev->tx_pkt_burst = eth_pipe_tx;
+
+	rte_eth_dev_probing_finish(eth_dev);
+
+	PMD_PIPE_LOG(DEBUG, "%s created", name);
+	PMD_PIPE_LOG(DEBUG, "port_id = %d", eth_dev->data->port_id);
+
+	return 0;
+}
+
+static int
+rte_pmd_pipe_remove(struct rte_vdev_device *dev)
+{
+	const char *name = rte_vdev_device_name(dev);
+	struct rte_eth_dev *eth_dev = NULL;
+
+	if (name == NULL)
+		return -EINVAL;
+
+	PMD_PIPE_LOG(INFO, "Un-Initializing pmd_pipe for %s", name);
+
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL) {
+		PMD_PIPE_LOG(ERR, "no eth_dev allocated for %s", name);
+		return -ENODEV;
+	}
+
+	eth_dev_stop(eth_dev);
+
+	rte_eth_dev_release_port(eth_dev);
+
+	PMD_PIPE_LOG(DEBUG, "%s removed", name);
+
+	return 0;
+}
+
+static struct rte_vdev_driver pmd_pipe_drv = {
+	.probe = rte_pmd_pipe_probe,
+	.remove = rte_pmd_pipe_remove,
+};
+
+RTE_PMD_REGISTER_VDEV(spp_pipe, pmd_pipe_drv);
+RTE_PMD_REGISTER_PARAM_STRING(spp_pipe, "rx=<rx_ring> tx=<tx_ring>");
+
+RTE_INIT(eth_pipe_init_log)
+{
+	eth_pipe_logtype = rte_log_register("pmd.spp.pipe");
+	if (eth_pipe_logtype >= 0)
+		rte_log_set_level(eth_pipe_logtype, RTE_LOG_INFO);
+}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 2/7] drivers: add pipe PMD in Makefile
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
@ 2020-03-01 23:34   ` Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 3/7] spp_primary: add link to " Itsuro Oda
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds the directory of pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/drivers/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/drivers/Makefile b/src/drivers/Makefile
index f2deba7..f759238 100644
--- a/src/drivers/Makefile
+++ b/src/drivers/Makefile
@@ -11,5 +11,6 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 include $(RTE_SDK)/mk/rte.vars.mk
 
 DIRS-y += vhost
+DIRS-y += pipe
 
 include $(RTE_SDK)/mk/rte.extsubdir.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 3/7] spp_primary: add link to pipe PMD in Makefile
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 2/7] drivers: add pipe PMD in Makefile Itsuro Oda
@ 2020-03-01 23:34   ` " Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 4/7] spp_nfv: " Itsuro Oda
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/primary/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/primary/Makefile b/src/primary/Makefile
index 35ae788..156b7cd 100644
--- a/src/primary/Makefile
+++ b/src/primary/Makefile
@@ -52,6 +52,6 @@ endif
 EXTRA_CFLAGS += -fno-strict-aliasing
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 4/7] spp_nfv: add link to pipe PMD in Makefile
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
                     ` (2 preceding siblings ...)
  2020-03-01 23:34   ` [spp] [PATCH v2 3/7] spp_primary: add link to " Itsuro Oda
@ 2020-03-01 23:34   ` " Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 5/7] spp_vf: " Itsuro Oda
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/nfv/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nfv/Makefile b/src/nfv/Makefile
index a717616..16a10f7 100644
--- a/src/nfv/Makefile
+++ b/src/nfv/Makefile
@@ -28,6 +28,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 5/7] spp_vf: add link to pipe PMD in Makefile
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
                     ` (3 preceding siblings ...)
  2020-03-01 23:34   ` [spp] [PATCH v2 4/7] spp_nfv: " Itsuro Oda
@ 2020-03-01 23:34   ` " Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 6/7] spp_mirror: " Itsuro Oda
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/vf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vf/Makefile b/src/vf/Makefile
index e42f8b7..0f7410f 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -49,6 +49,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 6/7] spp_mirror: add link to pipe PMD in Makefile
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
                     ` (4 preceding siblings ...)
  2020-03-01 23:34   ` [spp] [PATCH v2 5/7] spp_vf: " Itsuro Oda
@ 2020-03-01 23:34   ` " Itsuro Oda
  2020-03-01 23:34   ` [spp] [PATCH v2 7/7] spp_pcap: " Itsuro Oda
  2020-03-05  1:25   ` [spp] [PATCH v2 0/7] introduce pipe PMD Yasufumi Ogawa
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/mirror/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mirror/Makefile b/src/mirror/Makefile
index f82b08f..e00ca76 100644
--- a/src/mirror/Makefile
+++ b/src/mirror/Makefile
@@ -54,6 +54,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [spp] [PATCH v2 7/7] spp_pcap: add link to pipe PMD in Makefile
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
                     ` (5 preceding siblings ...)
  2020-03-01 23:34   ` [spp] [PATCH v2 6/7] spp_mirror: " Itsuro Oda
@ 2020-03-01 23:34   ` " Itsuro Oda
  2020-03-05  1:25   ` [spp] [PATCH v2 0/7] introduce pipe PMD Yasufumi Ogawa
  7 siblings, 0 replies; 18+ messages in thread
From: Itsuro Oda @ 2020-03-01 23:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This patch adds link to pipe PMD in Makefile.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/pcap/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pcap/Makefile b/src/pcap/Makefile
index 7d93c60..fd51c65 100644
--- a/src/pcap/Makefile
+++ b/src/pcap/Makefile
@@ -44,6 +44,6 @@ LDLIBS += -lrte_pmd_vhost
 endif
 
 SPP_DRIVERS_DIR = $(BASE_OUTPUT)/src/drivers
-EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost --whole-archive -lrte_pmd_spp_vhost --no-whole-archive
+EXTRA_LDLIBS = -L$(SPP_DRIVERS_DIR)/vhost -L$(SPP_DRIVERS_DIR)/pipe --whole-archive -lrte_pmd_spp_vhost -lrte_pmd_spp_pipe --no-whole-archive
 
 include $(RTE_SDK)/mk/rte.extapp.mk
-- 
2.17.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [spp] [PATCH v2 0/7] introduce pipe PMD
  2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
                     ` (6 preceding siblings ...)
  2020-03-01 23:34   ` [spp] [PATCH v2 7/7] spp_pcap: " Itsuro Oda
@ 2020-03-05  1:25   ` Yasufumi Ogawa
  7 siblings, 0 replies; 18+ messages in thread
From: Yasufumi Ogawa @ 2020-03-05  1:25 UTC (permalink / raw)
  To: Itsuro Oda; +Cc: spp, ferruh.yigit

> pipe PMD provides a device named spp_pipe which communicates
> using rings allocated by spp_primary.
> For example spp_pipe0 made with devargs "rx=ring:0,tx=ring:1"
> receives packets from ring:0 and sends packets to ring:1.
> spp_pipe enables high-speed communication between an application
> and other application or SPP secondary processes (ex. spp_nfv)
> using rings.
> Note that an application using spp_pipe must be a secondary
> process under spp_primary.
> 
> This series of patches add the part of driver. CLI and REST
> API to request to make spp_pipe devices will be provided
> by following patches. The document will be provided by
> following patches too.
Applied, thanks.

> 
> ---
> v2:
> * fix checkpatches.sh errors
> 
> Itsuro Oda (7):
>    drivers/pipe: add pipe PMD driver
>    drivers: add pipe PMD in Makefile
>    spp_primary: add link to pipe PMD in Makefile
>    spp_nfv: add link to pipe PMD in Makefile
>    spp_vf: add link to pipe PMD in Makefile
>    spp_mirror: add link to pipe PMD in Makefile
>    spp_pcap: add link to pipe PMD in Makefile
> 
>   src/drivers/Makefile                          |   1 +
>   src/drivers/pipe/Makefile                     |  26 ++
>   src/drivers/pipe/rte_pmd_spp_pipe_version.map |   4 +
>   src/drivers/pipe/rte_spp_pipe.c               | 426 ++++++++++++++++++
>   src/mirror/Makefile                           |   2 +-
>   src/nfv/Makefile                              |   2 +-
>   src/pcap/Makefile                             |   2 +-
>   src/primary/Makefile                          |   2 +-
>   src/vf/Makefile                               |   2 +-
>   9 files changed, 462 insertions(+), 5 deletions(-)
>   create mode 100644 src/drivers/pipe/Makefile
>   create mode 100644 src/drivers/pipe/rte_pmd_spp_pipe_version.map
>   create mode 100644 src/drivers/pipe/rte_spp_pipe.c
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, back to index

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 23:32 [spp] [PATCH 0/7] introduce pipe PMD Itsuro Oda
2020-02-25 23:32 ` [spp] [PATCH 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
2020-02-28  8:30   ` Yasufumi Ogawa
2020-02-25 23:32 ` [spp] [PATCH 2/7] drivers: add pipe PMD in Makefile Itsuro Oda
2020-02-25 23:33 ` [spp] [PATCH 3/7] spp_primary: add link to " Itsuro Oda
2020-02-25 23:33 ` [spp] [PATCH 4/7] spp_nfv: " Itsuro Oda
2020-02-25 23:33 ` [spp] [PATCH 5/7] spp_vf: " Itsuro Oda
2020-02-25 23:33 ` [spp] [PATCH 6/7] spp_mirror: " Itsuro Oda
2020-02-25 23:33 ` [spp] [PATCH 7/7] spp_pcap: " Itsuro Oda
2020-03-01 23:34 ` [spp] [PATCH v2 0/7] introduce pipe PMD Itsuro Oda
2020-03-01 23:34   ` [spp] [PATCH v2 1/7] drivers/pipe: add pipe PMD driver Itsuro Oda
2020-03-01 23:34   ` [spp] [PATCH v2 2/7] drivers: add pipe PMD in Makefile Itsuro Oda
2020-03-01 23:34   ` [spp] [PATCH v2 3/7] spp_primary: add link to " Itsuro Oda
2020-03-01 23:34   ` [spp] [PATCH v2 4/7] spp_nfv: " Itsuro Oda
2020-03-01 23:34   ` [spp] [PATCH v2 5/7] spp_vf: " Itsuro Oda
2020-03-01 23:34   ` [spp] [PATCH v2 6/7] spp_mirror: " Itsuro Oda
2020-03-01 23:34   ` [spp] [PATCH v2 7/7] spp_pcap: " Itsuro Oda
2020-03-05  1:25   ` [spp] [PATCH v2 0/7] introduce pipe PMD Yasufumi Ogawa

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox