Soft Patch Panel
 help / color / mirror / Atom feed
From: Itsuro Oda <oda@valinux.co.jp>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 1/5] shared: add PIPE port type
Date: Wed, 26 Feb 2020 10:37:42 +0900
Message-ID: <20200226013746.2875-2-oda@valinux.co.jp> (raw)
In-Reply-To: <20200226013746.2875-1-oda@valinux.co.jp>

This patch adds PIPE port type and related functions.

Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/shared/common.c                           |  9 +++++
 src/shared/common.h                           |  2 ++
 src/shared/secondary/add_port.c               | 34 +++++++++++++++++++
 src/shared/secondary/add_port.h               | 16 +++++++++
 .../secondary/spp_worker_th/cmd_utils.c       |  2 ++
 5 files changed, 63 insertions(+)

diff --git a/src/shared/common.c b/src/shared/common.c
index d878c5a..d1c3e36 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -139,6 +139,15 @@ int parse_dev_name(char *dev_name, int *port_type, int *port_id)
 		*port_id = (int)strtol(pid_str, NULL, 10);
 		*port_type = NULLPMD;
 
+	} else if (strncmp(dev_name, VDEV_SPP_PIPE,
+			strlen(VDEV_SPP_PIPE)) == 0) {
+		dev_str_len = strlen(VDEV_SPP_PIPE);
+		pid_len = dev_name_len - dev_str_len;
+		strncpy(pid_str, dev_name + strlen(VDEV_SPP_PIPE),
+				pid_len);
+		*port_id = (int)strtol(pid_str, NULL, 10);
+		*port_type = PIPE;
+
 	/* TODO(yasufum) add checking invalid port type and return -1 */
 	} else {
 		*port_id = 0;
diff --git a/src/shared/common.h b/src/shared/common.h
index b4af73c..1688437 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -41,6 +41,7 @@
 #define VDEV_ETH_TAP "eth_tap"
 #define VDEV_NET_TAP "net_tap"
 #define VDEV_NET_MEMIF "net_memif"
+#define VDEV_SPP_PIPE "spp_pipe"
 #define VDEV_ETH_NULL "eth_null"
 
 
@@ -85,6 +86,7 @@ enum port_type {
 	NULLPMD,
 	TAP,
 	MEMIF,
+	PIPE,
 	UNDEF,
 };
 
diff --git a/src/shared/secondary/add_port.c b/src/shared/secondary/add_port.c
index 652ef69..a7b7261 100644
--- a/src/shared/secondary/add_port.c
+++ b/src/shared/secondary/add_port.c
@@ -62,6 +62,14 @@ get_null_pmd_name(int id)
 	return buffer;
 }
 
+static inline const char *
+get_pipe_pmd_name(int id)
+{
+	static char buffer[sizeof(PIPE_PMD_DEV_NAME) + 2];
+	snprintf(buffer, sizeof(buffer) - 1, PIPE_PMD_DEV_NAME, id);
+	return buffer;
+}
+
 /*
  * Create an empty rx pcap file to given path if it does not exit
  * Return 0 for succeeded, or -1 for failed.
@@ -447,3 +455,29 @@ add_null_pmd(int index)
 
 	return null_pmd_port_id;
 }
+
+/*
+ * Create a pipe. Note that this function used by primary only.
+ * Because a pipe is used by an application as a normal ether
+ * device, this function does creation only but does not do
+ * configuration etc.
+ */
+int
+add_pipe_pmd(int index, const char *rx_ring, const char *tx_ring)
+{
+	const char *name;
+	char devargs[64];
+	uint16_t pipe_pmd_port_id;
+
+	int ret;
+
+	name = get_pipe_pmd_name(index);
+	sprintf(devargs, "%s,rx=%s,tx=%s", name, rx_ring, tx_ring);
+	ret = dev_attach_by_devargs(devargs, &pipe_pmd_port_id);
+	if (ret < 0)
+		return ret;
+
+	RTE_LOG(DEBUG, SHARED, "pipe port id %d\n", pipe_pmd_port_id);
+
+	return pipe_pmd_port_id;
+}
diff --git a/src/shared/secondary/add_port.h b/src/shared/secondary/add_port.h
index d686f20..39feb50 100644
--- a/src/shared/secondary/add_port.h
+++ b/src/shared/secondary/add_port.h
@@ -15,6 +15,7 @@
 #define PCAP_PMD_DEV_NAME "eth_pcap%u"
 #define MEMIF_PMD_DEV_NAME "net_memif%u"
 #define NULL_PMD_DEV_NAME "eth_null%u"
+#define PIPE_PMD_DEV_NAME "spp_pipe%u"
 
 #define PCAP_IFACE_RX "/tmp/spp-rx%d.pcap"
 #define PCAP_IFACE_TX "/tmp/spp-tx%d.pcap"
@@ -108,4 +109,19 @@ add_memif_pmd(int index);
 int
 add_null_pmd(int index);
 
+/**
+ * Create a pipe PMD with given ID.
+ *
+ * @param port_id
+ *   ID of the next possible valid port.
+ * @param rx_ring
+ *   Ring name for rx
+ * @param tx_ring
+ *   Ring name for tx
+ * @return
+ *   Unique port ID
+ */
+int
+add_pipe_pmd(int index, const char *rx_ring, const char *tx_ring);
+
 #endif
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 69d7222..84d7fbe 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -448,6 +448,8 @@ init_host_port_info(void)
 			p_iface_info->ring[port_id].iface_type = port_type;
 			p_iface_info->ring[port_id].ethdev_port_id = port_id;
 			break;
+		case PIPE:
+			break;
 		default:
 			RTE_LOG(ERR, WK_CMD_UTILS,
 					"Unsupported port on host, "
-- 
2.17.1


  reply	other threads:[~2020-02-26  1:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26  1:37 [spp] [PATCH 0/5] REST API and CLI support for pipe PMD Itsuro Oda
2020-02-26  1:37 ` Itsuro Oda [this message]
2020-02-26  1:37 ` [spp] [PATCH 2/5] primary: suport " Itsuro Oda
2020-02-26  6:29   ` Yasufumi Ogawa
2020-02-26  1:37 ` [spp] [PATCH 3/5] spp_nfv: ignore " Itsuro Oda
2020-02-26  1:37 ` [spp] [PATCH 4/5] spp-ctl: enable add pipe port to the primary Itsuro Oda
2020-02-26  1:37 ` [spp] [PATCH 5/5] cli: support pipe PMD Itsuro Oda
2020-02-26  7:06 ` [spp] [PATCH v2 0/5] REST API and CLI support for " Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 1/5] shared: add PIPE port type Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 2/5] primary: suport pipe PMD Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 3/5] spp_nfv: ignore " Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 4/5] spp-ctl: enable add pipe port to the primary Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 5/5] cli: support pipe PMD Itsuro Oda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226013746.2875-2-oda@valinux.co.jp \
    --to=oda@valinux.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    --cc=yasufum.o@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Soft Patch Panel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://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/ https://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


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