[spp] [PATCH 1/5] shared: add PIPE port type
Itsuro Oda
oda at valinux.co.jp
Wed Feb 26 02:37:42 CET 2020
This patch adds PIPE port type and related functions.
Signed-off-by: Itsuro Oda <oda at 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
More information about the spp
mailing list