* [spp] [PATCH 0/6] Refactor for including headers
@ 2019-01-15 3:28 ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 1/6] shared: fix include error of add_port libs ogawa.yasufumi
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: ogawa.yasufumi @ 2019-01-15 3:28 UTC (permalink / raw)
To: ferruh.yigit, spp, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
This series of update is to refactor for including functions and
definitions appropriately.
* Change libs for adding ports in `shared/secondary` from inline to
ordinary to avoid `not used` error during compilation. This libs are
not used for packet forwarding and no need to be inline function.
* Remove definition of RTE_LOGTYPE_APP from `common.h` because tag of
log message should not be `APP` but the name of process, for instance,
`SPP_PRI`, `SPP_NFV` or so.
* Add definition of `RTE_LOGTYPE_*` for each of secondary processes.
* Update makefiles in each of secondaries to change include path from
`-I$(SRCDIR)/../shared` to `-I$(SRCDIR)/../`. It is because for
including explicitly from `shared` directory in each of codes.
Yasufumi Ogawa (6):
shared: fix include error of add_port libs
spp_nfv: update to use common app_port libs
spp_vf/common: add RTE_LOGTYPE in each of files
spp_vf/common: change name of func of adding port
spp_vf: update makefile
spp_mirror: update makefile
src/mirror/Makefile | 3 +-
src/mirror/spp_mirror.c | 4 +-
src/nfv/Makefile | 3 +-
src/nfv/commands.h | 1 +
src/shared/secondary/add_port.c | 336 +++++++++++++++++++++++++++
src/shared/secondary/add_port.h | 386 ++++++--------------------------
src/vf/Makefile | 3 +-
src/vf/common/command_dec.c | 1 +
src/vf/common/command_proc.c | 1 +
src/vf/common/spp_proc.c | 11 +-
src/vf/common/spp_proc.h | 6 +-
src/vf/spp_vf.h | 4 +-
12 files changed, 426 insertions(+), 333 deletions(-)
create mode 100644 src/shared/secondary/add_port.c
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 1/6] shared: fix include error of add_port libs
2019-01-15 3:28 [spp] [PATCH 0/6] Refactor for including headers ogawa.yasufumi
@ 2019-01-15 3:28 ` ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 2/6] spp_nfv: update to use common app_port libs ogawa.yasufumi
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ogawa.yasufumi @ 2019-01-15 3:28 UTC (permalink / raw)
To: ferruh.yigit, spp, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Change common add_port libraries not to be static function to avoid
`not used` error while compiling.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/shared/secondary/add_port.c | 336 +++++++++++++++++++++++++++
src/shared/secondary/add_port.h | 386 ++++++--------------------------
2 files changed, 400 insertions(+), 322 deletions(-)
create mode 100644 src/shared/secondary/add_port.c
diff --git a/src/shared/secondary/add_port.c b/src/shared/secondary/add_port.c
new file mode 100644
index 0000000..ca55a04
--- /dev/null
+++ b/src/shared/secondary/add_port.c
@@ -0,0 +1,336 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2015-2016 Intel Corporation
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <rte_ethdev_driver.h>
+#include <rte_eth_ring.h>
+
+#include "shared/common.h"
+#include "shared/secondary/add_port.h"
+#include "shared/secondary/utils.h"
+
+char *
+get_vhost_backend_name(unsigned int id)
+{
+ /*
+ * buffer for return value. Size calculated by %u being replaced
+ * by maximum 3 digits (plus an extra byte for safety)
+ */
+ static char buffer[sizeof(VHOST_BACKEND_NAME) + 2];
+
+ snprintf(buffer, sizeof(buffer) - 1, VHOST_BACKEND_NAME, id);
+ return buffer;
+}
+
+char *
+get_vhost_iface_name(unsigned int id)
+{
+ /*
+ * buffer for return value. Size calculated by %u being replaced
+ * by maximum 3 digits (plus an extra byte for safety)
+ */
+ static char buffer[sizeof(VHOST_IFACE_NAME) + 2];
+
+ snprintf(buffer, sizeof(buffer) - 1, VHOST_IFACE_NAME, id);
+ return buffer;
+}
+
+static inline const char *
+get_pcap_pmd_name(int id)
+{
+ static char buffer[sizeof(PCAP_PMD_DEV_NAME) + 2];
+ snprintf(buffer, sizeof(buffer) - 1, PCAP_PMD_DEV_NAME, id);
+ return buffer;
+}
+
+static inline const char *
+get_null_pmd_name(int id)
+{
+ static char buffer[sizeof(NULL_PMD_DEV_NAME) + 2];
+ snprintf(buffer, sizeof(buffer) - 1, NULL_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.
+ */
+static int
+create_pcap_rx(char *rx_fpath)
+{
+ int res;
+ FILE *tmp_fp;
+ char cmd_str[256];
+
+ // empty file is required for 'text2pcap' command for
+ // creating a pcap file.
+ char template[] = "/tmp/spp-emptyfile.txt";
+
+ // create empty file if it is not exist
+ tmp_fp = fopen(template, "r");
+ if (tmp_fp == NULL) {
+ (tmp_fp = fopen(template, "w"));
+ if (tmp_fp == NULL) {
+ RTE_LOG(ERR, SHARED, "Failed to open %s\n", template);
+ return -1;
+ }
+ }
+
+ sprintf(cmd_str, "text2pcap %s %s", template, rx_fpath);
+ res = system(cmd_str);
+ if (res != 0) {
+ RTE_LOG(ERR, SHARED,
+ "Failed to create pcap device %s\n",
+ rx_fpath);
+ return -1;
+ }
+ RTE_LOG(INFO, SHARED, "PCAP device created\n");
+ fclose(tmp_fp);
+ return 0;
+}
+
+/*
+ * Create a ring PMD with given ring_id.
+ */
+int
+add_ring_pmd(int ring_id)
+{
+ struct rte_ring *ring;
+ int res;
+ char rx_queue_name[32]; /* Prefix and number like as 'eth_ring_0' */
+
+ memset(rx_queue_name, '\0', sizeof(rx_queue_name));
+ sprintf(rx_queue_name, "%s", get_rx_queue_name(ring_id));
+
+ /* Look up ring with provided ring_id */
+ ring = rte_ring_lookup(rx_queue_name);
+ if (ring == NULL) {
+ RTE_LOG(ERR, SHARED,
+ "Failed to get RX ring %s - is primary running?\n",
+ rx_queue_name);
+ return -1;
+ }
+ RTE_LOG(INFO, SHARED, "Looked up ring '%s'\n", rx_queue_name);
+
+ /* create ring pmd*/
+ res = rte_eth_from_ring(ring);
+ if (res < 0) {
+ RTE_LOG(ERR, SHARED,
+ "Cannot create eth dev with rte_eth_from_ring()\n");
+ return -1;
+ }
+ RTE_LOG(INFO, SHARED, "Created ring PMD: %d\n", res);
+
+ return res;
+}
+
+int
+add_vhost_pmd(int index)
+{
+ struct rte_eth_conf port_conf = {
+ .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+ };
+ struct rte_mempool *mp;
+ uint16_t vhost_port_id;
+ int nr_queues = 1;
+ const char *name;
+ char devargs[64];
+ char *iface;
+ uint16_t q;
+ int ret;
+
+ mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
+ if (mp == NULL)
+ rte_exit(EXIT_FAILURE, "Cannot get mempool for mbufs\n");
+
+ /* eth_vhost0 index 0 iface /tmp/sock0 on numa 0 */
+ name = get_vhost_backend_name(index);
+ iface = get_vhost_iface_name(index);
+
+ sprintf(devargs, "%s,iface=%s,queues=%d", name, iface, nr_queues);
+ ret = dev_attach_by_devargs(devargs, &vhost_port_id);
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_dev_configure(vhost_port_id, nr_queues, nr_queues,
+ &port_conf);
+ if (ret < 0)
+ return ret;
+
+ /* Allocate and set up 1 RX queue per Ethernet port. */
+ for (q = 0; q < nr_queues; q++) {
+ ret = rte_eth_rx_queue_setup(vhost_port_id, q, NR_DESCS,
+ rte_eth_dev_socket_id(vhost_port_id), NULL, mp);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Allocate and set up 1 TX queue per Ethernet port. */
+ for (q = 0; q < nr_queues; q++) {
+ ret = rte_eth_tx_queue_setup(vhost_port_id, q, NR_DESCS,
+ rte_eth_dev_socket_id(vhost_port_id), NULL);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Start the Ethernet port. */
+ ret = rte_eth_dev_start(vhost_port_id);
+ if (ret < 0)
+ return ret;
+
+ RTE_LOG(DEBUG, SHARED, "vhost port id %d\n", vhost_port_id);
+
+ return vhost_port_id;
+}
+
+/*
+ * Open pcap files with given index for rx and tx.
+ * Index is given as a argument of 'patch' command.
+ * This function returns a port ID if it is succeeded,
+ * or negative int if failed.
+ */
+int
+add_pcap_pmd(int index)
+{
+ struct rte_eth_conf port_conf = {
+ .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+ };
+
+ struct rte_mempool *mp;
+ const char *name;
+ char devargs[256];
+ uint16_t pcap_pmd_port_id;
+ uint16_t nr_queues = 1;
+ int ret;
+
+ // PCAP file path
+ char rx_fpath[128];
+ char tx_fpath[128];
+
+ FILE *rx_fp;
+
+ sprintf(rx_fpath, PCAP_IFACE_RX, index);
+ sprintf(tx_fpath, PCAP_IFACE_TX, index);
+
+ // create rx pcap file if it does not exist
+ rx_fp = fopen(rx_fpath, "r");
+ if (rx_fp == NULL) {
+ ret = create_pcap_rx(rx_fpath);
+ if (ret < 0)
+ return ret;
+ }
+
+ mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
+ if (mp == NULL)
+ rte_exit(EXIT_FAILURE, "Cannon get mempool for mbuf\n");
+
+ name = get_pcap_pmd_name(index);
+ sprintf(devargs,
+ "%s,rx_pcap=%s,tx_pcap=%s",
+ name, rx_fpath, tx_fpath);
+ ret = dev_attach_by_devargs(devargs, &pcap_pmd_port_id);
+
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_dev_configure(
+ pcap_pmd_port_id, nr_queues, nr_queues, &port_conf);
+
+ if (ret < 0)
+ return ret;
+
+ /* Allocate and set up 1 RX queue per Ethernet port. */
+ uint16_t q;
+ for (q = 0; q < nr_queues; q++) {
+ ret = rte_eth_rx_queue_setup(
+ pcap_pmd_port_id, q, NR_DESCS,
+ rte_eth_dev_socket_id(pcap_pmd_port_id),
+ NULL, mp);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Allocate and set up 1 TX queue per Ethernet port. */
+ for (q = 0; q < nr_queues; q++) {
+ ret = rte_eth_tx_queue_setup(
+ pcap_pmd_port_id, q, NR_DESCS,
+ rte_eth_dev_socket_id(pcap_pmd_port_id),
+ NULL);
+ if (ret < 0)
+ return ret;
+ }
+
+ ret = rte_eth_dev_start(pcap_pmd_port_id);
+
+ if (ret < 0)
+ return ret;
+
+ RTE_LOG(DEBUG, SHARED, "pcap port id %d\n", pcap_pmd_port_id);
+
+ return pcap_pmd_port_id;
+}
+
+int
+add_null_pmd(int index)
+{
+ struct rte_eth_conf port_conf = {
+ .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+ };
+
+ struct rte_mempool *mp;
+ const char *name;
+ char devargs[64];
+ uint16_t null_pmd_port_id;
+ uint16_t nr_queues = 1;
+
+ int ret;
+
+ mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
+ if (mp == NULL)
+ rte_exit(EXIT_FAILURE, "Cannon get mempool for mbuf\n");
+
+ name = get_null_pmd_name(index);
+ sprintf(devargs, "%s", name);
+ ret = dev_attach_by_devargs(devargs, &null_pmd_port_id);
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_dev_configure(
+ null_pmd_port_id, nr_queues, nr_queues,
+ &port_conf);
+ if (ret < 0)
+ return ret;
+
+ /* Allocate and set up 1 RX queue per Ethernet port. */
+ uint16_t q;
+ for (q = 0; q < nr_queues; q++) {
+ ret = rte_eth_rx_queue_setup(
+ null_pmd_port_id, q, NR_DESCS,
+ rte_eth_dev_socket_id(
+ null_pmd_port_id), NULL, mp);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Allocate and set up 1 TX queue per Ethernet port. */
+ for (q = 0; q < nr_queues; q++) {
+ ret = rte_eth_tx_queue_setup(
+ null_pmd_port_id, q, NR_DESCS,
+ rte_eth_dev_socket_id(
+ null_pmd_port_id),
+ NULL);
+ if (ret < 0)
+ return ret;
+ }
+
+ ret = rte_eth_dev_start(null_pmd_port_id);
+ if (ret < 0)
+ return ret;
+
+ RTE_LOG(DEBUG, SHARED, "null port id %d\n", null_pmd_port_id);
+
+ return null_pmd_port_id;
+}
diff --git a/src/shared/secondary/add_port.h b/src/shared/secondary/add_port.h
index 83f2514..cfae1af 100644
--- a/src/shared/secondary/add_port.h
+++ b/src/shared/secondary/add_port.h
@@ -6,9 +6,6 @@
#ifndef _SHARED_SECONDARY_ADD_PORT_H_
#define _SHARED_SECONDARY_ADD_PORT_H_
-#include <arpa/inet.h>
-#include "utils.h"
-
// The number of receive descriptors to allocate for the receive ring.
#define NR_DESCS 128
@@ -23,327 +20,72 @@
#define RTE_LOGTYPE_SHARED RTE_LOGTYPE_USER1
-static inline const char *
-get_vhost_backend_name(unsigned int id)
-{
- /*
- * buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety)
- */
- static char buffer[sizeof(VHOST_BACKEND_NAME) + 2];
-
- snprintf(buffer, sizeof(buffer) - 1, VHOST_BACKEND_NAME, id);
- return buffer;
-}
-
-static inline char *
-get_vhost_iface_name(unsigned int id)
-{
- /*
- * buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety)
- */
- static char buffer[sizeof(VHOST_IFACE_NAME) + 2];
-
- snprintf(buffer, sizeof(buffer) - 1, VHOST_IFACE_NAME, id);
- return buffer;
-}
-
-static inline const char *
-get_pcap_pmd_name(int id)
-{
- static char buffer[sizeof(PCAP_PMD_DEV_NAME) + 2];
- snprintf(buffer, sizeof(buffer) - 1, PCAP_PMD_DEV_NAME, id);
- return buffer;
-}
-
-static inline const char *
-get_null_pmd_name(int id)
-{
- static char buffer[sizeof(NULL_PMD_DEV_NAME) + 2];
- snprintf(buffer, sizeof(buffer) - 1, NULL_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.
+/**
+ * Get unique name used to reserve vhost interface.
+ *
+ * @param port_id
+ * ID of the next possible valid port.
+ * @return
+ * Unique name with VHOST_BACKEND_NAME and ID.
+ * e.g. `eth_vhost0`
*/
-static int
-create_pcap_rx(char *rx_fpath)
-{
- int res;
- FILE *tmp_fp;
- char cmd_str[256];
-
- // empty file is required for 'text2pcap' command for
- // creating a pcap file.
- char template[] = "/tmp/spp-emptyfile.txt";
-
- // create empty file if it is not exist
- tmp_fp = fopen(template, "r");
- if (tmp_fp == NULL) {
- (tmp_fp = fopen(template, "w"));
- if (tmp_fp == NULL) {
- RTE_LOG(ERR, SHARED, "Failed to open %s\n", template);
- return -1;
- }
- }
-
- sprintf(cmd_str, "text2pcap %s %s", template, rx_fpath);
- res = system(cmd_str);
- if (res != 0) {
- RTE_LOG(ERR, SHARED,
- "Failed to create pcap device %s\n",
- rx_fpath);
- return -1;
- }
- RTE_LOG(INFO, SHARED, "PCAP device created\n");
- fclose(tmp_fp);
- return 0;
-}
-
-/*
- * Create ring PMD with given ring_id.
+char *
+get_vhost_backend_name(unsigned int id);
+
+/**
+ * Get vhost name as the path of sock device.
+ *
+ * @param port_id
+ * ID of the next possible valid port.
+ * @return
+ * Unique name with VHOST_IFACE_NAME and ID.
+ * e.g. `tmp/sock0`
*/
-static int
-add_ring_pmd(int ring_id)
-{
- struct rte_ring *ring;
- int res;
- char rx_queue_name[32]; /* Prefix and number like as 'eth_ring_0' */
-
- memset(rx_queue_name, '\0', sizeof(rx_queue_name));
- sprintf(rx_queue_name, "%s", get_rx_queue_name(ring_id));
-
- /* Look up ring with provided ring_id */
- ring = rte_ring_lookup(rx_queue_name);
- if (ring == NULL) {
- RTE_LOG(ERR, SHARED,
- "Failed to get RX ring %s - is primary running?\n",
- rx_queue_name);
- return -1;
- }
- RTE_LOG(INFO, SHARED, "Looked up ring '%s'\n", rx_queue_name);
-
- /* create ring pmd*/
- res = rte_eth_from_ring(ring);
- if (res < 0) {
- RTE_LOG(ERR, SHARED,
- "Cannot create eth dev with rte_eth_from_ring()\n");
- return -1;
- }
- RTE_LOG(INFO, SHARED, "Created ring PMD: %d\n", res);
-
- return res;
-}
-
-static int
-add_vhost_pmd(int index)
-{
- struct rte_eth_conf port_conf = {
- .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
- };
- struct rte_mempool *mp;
- uint16_t vhost_port_id;
- int nr_queues = 1;
- const char *name;
- char devargs[64];
- char *iface;
- uint16_t q;
- int ret;
-
- mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
- if (mp == NULL)
- rte_exit(EXIT_FAILURE, "Cannot get mempool for mbufs\n");
-
- /* eth_vhost0 index 0 iface /tmp/sock0 on numa 0 */
- name = get_vhost_backend_name(index);
- iface = get_vhost_iface_name(index);
-
- sprintf(devargs, "%s,iface=%s,queues=%d", name, iface, nr_queues);
- ret = dev_attach_by_devargs(devargs, &vhost_port_id);
- if (ret < 0)
- return ret;
-
- ret = rte_eth_dev_configure(vhost_port_id, nr_queues, nr_queues,
- &port_conf);
- if (ret < 0)
- return ret;
-
- /* Allocate and set up 1 RX queue per Ethernet port. */
- for (q = 0; q < nr_queues; q++) {
- ret = rte_eth_rx_queue_setup(vhost_port_id, q, NR_DESCS,
- rte_eth_dev_socket_id(vhost_port_id), NULL, mp);
- if (ret < 0)
- return ret;
- }
-
- /* Allocate and set up 1 TX queue per Ethernet port. */
- for (q = 0; q < nr_queues; q++) {
- ret = rte_eth_tx_queue_setup(vhost_port_id, q, NR_DESCS,
- rte_eth_dev_socket_id(vhost_port_id), NULL);
- if (ret < 0)
- return ret;
- }
-
- /* Start the Ethernet port. */
- ret = rte_eth_dev_start(vhost_port_id);
- if (ret < 0)
- return ret;
-
- RTE_LOG(DEBUG, SHARED, "vhost port id %d\n", vhost_port_id);
-
- return vhost_port_id;
-}
-
-/*
- * Open pcap files with given index for rx and tx.
- * Index is given as a argument of 'patch' command.
- * This function returns a port ID if it is succeeded,
- * or negative int if failed.
+char *
+get_vhost_iface_name(unsigned int id);
+
+/**
+ * Create a ring PMD with given ring_id.
+ *
+ * @param port_id
+ * ID of the next possible valid port.
+ * @return
+ * Unique port ID
*/
-static int
-add_pcap_pmd(int index)
-{
- struct rte_eth_conf port_conf = {
- .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
- };
-
- struct rte_mempool *mp;
- const char *name;
- char devargs[256];
- uint16_t pcap_pmd_port_id;
- uint16_t nr_queues = 1;
- int ret;
-
- // PCAP file path
- char rx_fpath[128];
- char tx_fpath[128];
-
- FILE *rx_fp;
-
- sprintf(rx_fpath, PCAP_IFACE_RX, index);
- sprintf(tx_fpath, PCAP_IFACE_TX, index);
-
- // create rx pcap file if it does not exist
- rx_fp = fopen(rx_fpath, "r");
- if (rx_fp == NULL) {
- ret = create_pcap_rx(rx_fpath);
- if (ret < 0)
- return ret;
- }
-
- mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
- if (mp == NULL)
- rte_exit(EXIT_FAILURE, "Cannon get mempool for mbuf\n");
-
- name = get_pcap_pmd_name(index);
- sprintf(devargs,
- "%s,rx_pcap=%s,tx_pcap=%s",
- name, rx_fpath, tx_fpath);
- ret = dev_attach_by_devargs(devargs, &pcap_pmd_port_id);
-
- if (ret < 0)
- return ret;
-
- ret = rte_eth_dev_configure(
- pcap_pmd_port_id, nr_queues, nr_queues, &port_conf);
-
- if (ret < 0)
- return ret;
-
- /* Allocate and set up 1 RX queue per Ethernet port. */
- uint16_t q;
- for (q = 0; q < nr_queues; q++) {
- ret = rte_eth_rx_queue_setup(
- pcap_pmd_port_id, q, NR_DESCS,
- rte_eth_dev_socket_id(pcap_pmd_port_id),
- NULL, mp);
- if (ret < 0)
- return ret;
- }
-
- /* Allocate and set up 1 TX queue per Ethernet port. */
- for (q = 0; q < nr_queues; q++) {
- ret = rte_eth_tx_queue_setup(
- pcap_pmd_port_id, q, NR_DESCS,
- rte_eth_dev_socket_id(pcap_pmd_port_id),
- NULL);
- if (ret < 0)
- return ret;
- }
-
- ret = rte_eth_dev_start(pcap_pmd_port_id);
-
- if (ret < 0)
- return ret;
-
- RTE_LOG(DEBUG, SHARED, "pcap port id %d\n", pcap_pmd_port_id);
-
- return pcap_pmd_port_id;
-}
-
-static int
-add_null_pmd(int index)
-{
- struct rte_eth_conf port_conf = {
- .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
- };
-
- struct rte_mempool *mp;
- const char *name;
- char devargs[64];
- uint16_t null_pmd_port_id;
- uint16_t nr_queues = 1;
-
- int ret;
-
- mp = rte_mempool_lookup(PKTMBUF_POOL_NAME);
- if (mp == NULL)
- rte_exit(EXIT_FAILURE, "Cannon get mempool for mbuf\n");
-
- name = get_null_pmd_name(index);
- sprintf(devargs, "%s", name);
- ret = dev_attach_by_devargs(devargs, &null_pmd_port_id);
- if (ret < 0)
- return ret;
-
- ret = rte_eth_dev_configure(
- null_pmd_port_id, nr_queues, nr_queues,
- &port_conf);
- if (ret < 0)
- return ret;
-
- /* Allocate and set up 1 RX queue per Ethernet port. */
- uint16_t q;
- for (q = 0; q < nr_queues; q++) {
- ret = rte_eth_rx_queue_setup(
- null_pmd_port_id, q, NR_DESCS,
- rte_eth_dev_socket_id(
- null_pmd_port_id), NULL, mp);
- if (ret < 0)
- return ret;
- }
-
- /* Allocate and set up 1 TX queue per Ethernet port. */
- for (q = 0; q < nr_queues; q++) {
- ret = rte_eth_tx_queue_setup(
- null_pmd_port_id, q, NR_DESCS,
- rte_eth_dev_socket_id(
- null_pmd_port_id),
- NULL);
- if (ret < 0)
- return ret;
- }
-
- ret = rte_eth_dev_start(null_pmd_port_id);
- if (ret < 0)
- return ret;
-
- RTE_LOG(DEBUG, SHARED, "null port id %d\n", null_pmd_port_id);
-
- return null_pmd_port_id;
-}
+int
+add_ring_pmd(int ring_id);
+
+/**
+ * Create a vhost PMD with given ring_id.
+ *
+ * @param port_id
+ * ID of the next possible valid port.
+ * @return
+ * Unique port ID
+ */
+int
+add_vhost_pmd(int index);
+
+/**
+ * Create a PCAP PMD with given ring_id.
+ *
+ * @param port_id
+ * ID of the next possible valid port.
+ * @return
+ * Unique port ID
+ */
+int
+add_pcap_pmd(int index);
+
+/**
+ * Create a null PMD with given ID.
+ *
+ * @param port_id
+ * ID of the next possible valid port.
+ * @return
+ * Unique port ID
+ */
+int
+add_null_pmd(int index);
#endif
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 2/6] spp_nfv: update to use common app_port libs
2019-01-15 3:28 [spp] [PATCH 0/6] Refactor for including headers ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 1/6] shared: fix include error of add_port libs ogawa.yasufumi
@ 2019-01-15 3:28 ` ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 3/6] spp_vf/common: add RTE_LOGTYPE in each of files ogawa.yasufumi
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ogawa.yasufumi @ 2019-01-15 3:28 UTC (permalink / raw)
To: ferruh.yigit, spp, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Add common app_port libraries to list of source codes.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/nfv/Makefile | 3 ++-
src/nfv/commands.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/nfv/Makefile b/src/nfv/Makefile
index e921010..88533af 100644
--- a/src/nfv/Makefile
+++ b/src/nfv/Makefile
@@ -13,7 +13,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
APP = spp_nfv
# all source are stored in SRCS-y
-SRCS-y := main.c nfv_status.c ../shared/common.c ../shared/secondary/utils.c
+SRCS-y := main.c nfv_status.c ../shared/common.c
+SRCS-y += ../shared/secondary/utils.c ../shared/secondary/add_port.c
CFLAGS += -DALLOW_EXPERIMENTAL_API
CFLAGS += $(WERROR_FLAGS) -O3 -MMD
diff --git a/src/nfv/commands.h b/src/nfv/commands.h
index 3280d69..54e0f21 100644
--- a/src/nfv/commands.h
+++ b/src/nfv/commands.h
@@ -7,6 +7,7 @@
#define _NFV_COMMANDS_H_
#include "shared/secondary/add_port.h"
+#include "shared/secondary/utils.h"
#define RTE_LOGTYPE_SPP_NFV RTE_LOGTYPE_USER1
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 3/6] spp_vf/common: add RTE_LOGTYPE in each of files
2019-01-15 3:28 [spp] [PATCH 0/6] Refactor for including headers ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 1/6] shared: fix include error of add_port libs ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 2/6] spp_nfv: update to use common app_port libs ogawa.yasufumi
@ 2019-01-15 3:28 ` ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 4/6] spp_vf/common: change name of func of adding port ogawa.yasufumi
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ogawa.yasufumi @ 2019-01-15 3:28 UTC (permalink / raw)
To: ferruh.yigit, spp, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Define RTE_LOGTYPE_APP was removed from `common.h` to diversify
notation of log messages. This update is to define RTE_LOGTYPE_APP
in each of source files.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/vf/common/command_dec.c | 1 +
src/vf/common/command_proc.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/vf/common/command_dec.c b/src/vf/common/command_dec.c
index b328ca8..61dd4f4 100644
--- a/src/vf/common/command_dec.c
+++ b/src/vf/common/command_dec.c
@@ -12,6 +12,7 @@
#include "command_dec.h"
#define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
+#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER2
/* command string */
#define SPP_COMMAND_CLASSFIER_TABLE_STR "classifier_table"
diff --git a/src/vf/common/command_proc.c b/src/vf/common/command_proc.c
index 00ecdc1..0e5c5f1 100644
--- a/src/vf/common/command_proc.c
+++ b/src/vf/common/command_proc.c
@@ -22,6 +22,7 @@
#include "command_proc.h"
#define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
+#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER2
/* request message initial size */
#define CMD_RES_ERR_MSG_SIZE 128
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 4/6] spp_vf/common: change name of func of adding port
2019-01-15 3:28 [spp] [PATCH 0/6] Refactor for including headers ogawa.yasufumi
` (2 preceding siblings ...)
2019-01-15 3:28 ` [spp] [PATCH 3/6] spp_vf/common: add RTE_LOGTYPE in each of files ogawa.yasufumi
@ 2019-01-15 3:28 ` ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 5/6] spp_vf: update makefile ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 6/6] spp_mirror: " ogawa.yasufumi
5 siblings, 0 replies; 7+ messages in thread
From: ogawa.yasufumi @ 2019-01-15 3:28 UTC (permalink / raw)
To: ferruh.yigit, spp, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
To avoid to be same as the name of common library, change add_ring_pmd()
and add_vhost_pmd() to have prefix.
* spp_vf_add_ring_pmd()
* spp_vf_add_vhost_pmd()
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/vf/common/spp_proc.c | 11 ++++++++---
src/vf/common/spp_proc.h | 6 +++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/vf/common/spp_proc.c b/src/vf/common/spp_proc.c
index abbd5d5..9a118bd 100644
--- a/src/vf/common/spp_proc.c
+++ b/src/vf/common/spp_proc.c
@@ -14,6 +14,9 @@
#include "spp_proc.h"
#include "spp_port.h"
+#include "shared/secondary/add_port.h"
+#include "shared/secondary/utils.h"
+
#ifdef SPP_VF_MODULE
#include "../spp_forward.h"
#include "../classifier_mac.h"
@@ -22,6 +25,8 @@
#include "../../mirror/spp_mirror.h"
#endif /* SPP_MIRROR_MODULE */
+#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
+
/* Manage data to addoress */
struct manage_data_addr_info {
struct startup_param *p_startup_param;
@@ -71,7 +76,7 @@ dump_buff(const char *name, const void *addr, const size_t size)
/* generation of the ring port */
int
-add_ring_pmd(int ring_id)
+spp_vf_add_ring_pmd(int ring_id)
{
struct rte_ring *ring;
int ring_port_id;
@@ -93,7 +98,7 @@ add_ring_pmd(int ring_id)
/* generation of the vhost port */
int
-add_vhost_pmd(int index, int client)
+spp_vf_add_vhost_pmd(int index, int client)
{
struct rte_eth_conf port_conf = {
.rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
@@ -815,7 +820,7 @@ flush_port(void)
for (cnt = 0; cnt < RTE_MAX_ETHPORTS; cnt++) {
port = &p_iface_info->vhost[cnt];
if ((port->iface_type != UNDEF) && (port->dpdk_port < 0)) {
- ret = add_vhost_pmd(port->iface_no,
+ ret = spp_vf_add_vhost_pmd(port->iface_no,
g_mng_data_addr.p_startup_param->vhost_client);
if (ret < 0)
return SPP_RET_NG;
diff --git a/src/vf/common/spp_proc.h b/src/vf/common/spp_proc.h
index 4001c21..2fc8cc2 100644
--- a/src/vf/common/spp_proc.h
+++ b/src/vf/common/spp_proc.h
@@ -13,7 +13,7 @@
*/
#include <netinet/in.h>
-#include "common.h"
+#include "shared/common.h"
/**
* TODO(Yamashita) change type names.
@@ -355,7 +355,7 @@ void dump_buff(const char *name, const void *addr, const size_t size);
* @retval 0~ ring_port_id.
* @retval -1 failed.
*/
-int add_ring_pmd(int ring_id);
+int spp_vf_add_ring_pmd(int ring_id);
/**
* added vhost_pmd
@@ -368,7 +368,7 @@ int add_ring_pmd(int ring_id);
* @retval 0~ vhost_port_id.
* @retval -1 failed.
*/
-int add_vhost_pmd(int index, int client);
+int spp_vf_add_vhost_pmd(int index, int client);
/**
* Get core status
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 5/6] spp_vf: update makefile
2019-01-15 3:28 [spp] [PATCH 0/6] Refactor for including headers ogawa.yasufumi
` (3 preceding siblings ...)
2019-01-15 3:28 ` [spp] [PATCH 4/6] spp_vf/common: change name of func of adding port ogawa.yasufumi
@ 2019-01-15 3:28 ` ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 6/6] spp_mirror: " ogawa.yasufumi
5 siblings, 0 replies; 7+ messages in thread
From: ogawa.yasufumi @ 2019-01-15 3:28 UTC (permalink / raw)
To: ferruh.yigit, spp, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Change makefile and root header file of spp_vf to include updated files.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/vf/Makefile | 3 ++-
src/vf/spp_vf.h | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/vf/Makefile b/src/vf/Makefile
index ac100bb..03c668f 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -17,10 +17,11 @@ SRCS-y += common/string_buffer.c common/ringlatencystats.c common/spp_port.c
SRCS-y += common/command_conn.c common/command_dec.c common/command_proc.c
SRCS-y += common/spp_proc.c
SRCS-y += ../shared/common.c
+SRCS-y += ../shared/secondary/utils.c ../shared/secondary/add_port.c
CFLAGS += -DALLOW_EXPERIMENTAL_API
CFLAGS += $(WERROR_FLAGS) -O3 -MMD
-CFLAGS += -I$(SRCDIR)/../shared
+CFLAGS += -I$(SRCDIR)/../
CFLAGS += -I$(SRCDIR)/common
CFLAGS += -DSPP_VF_MODULE
#CFLAGS += -DSPP_DEMONIZE
diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h
index f7f08c8..8465f1b 100644
--- a/src/vf/spp_vf.h
+++ b/src/vf/spp_vf.h
@@ -13,6 +13,8 @@
* This provides the function for initializing and starting the threads.
*/
-#include "common.h"
+#include "shared/common.h"
+
+#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
#endif /* __SPP_VF_H__ */
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 6/6] spp_mirror: update makefile
2019-01-15 3:28 [spp] [PATCH 0/6] Refactor for including headers ogawa.yasufumi
` (4 preceding siblings ...)
2019-01-15 3:28 ` [spp] [PATCH 5/6] spp_vf: update makefile ogawa.yasufumi
@ 2019-01-15 3:28 ` ogawa.yasufumi
5 siblings, 0 replies; 7+ messages in thread
From: ogawa.yasufumi @ 2019-01-15 3:28 UTC (permalink / raw)
To: ferruh.yigit, spp, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Add refactored common source and header files to makefile and root
header file.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/mirror/Makefile | 3 ++-
src/mirror/spp_mirror.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/mirror/Makefile b/src/mirror/Makefile
index 073afbd..f1995fc 100644
--- a/src/mirror/Makefile
+++ b/src/mirror/Makefile
@@ -14,6 +14,7 @@ APP = spp_mirror
# all source are stored in SRCS-y
SRCS-y := spp_mirror.c
SRCS-y += ../shared/common.c
+SRCS-y += ../shared/secondary/utils.c ../shared/secondary/add_port.c
SRCS-y += ../vf/common/spp_proc.c ../vf/common/spp_port.c
SRCS-y += ../vf/common/command_conn.c ../vf/common/command_proc.c
SRCS-y += ../vf/common/command_dec.c
@@ -21,7 +22,7 @@ SRCS-y += ../vf/common/ringlatencystats.c ../vf/common/string_buffer.c
CFLAGS += -DALLOW_EXPERIMENTAL_API
CFLAGS += $(WERROR_FLAGS) -O3 -MMD
-CFLAGS += -I$(SRCDIR)/../shared
+CFLAGS += -I$(SRCDIR)/../
CFLAGS += -I$(SRCDIR)/../vf/common
CFLAGS += -DSPP_MIRROR_MODULE
CFLAGS += -DSPP_MIRROR_SHALLOWCOPY
diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index fb9bcb1..4835d55 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -9,7 +9,9 @@
#include <rte_common.h>
#include <rte_cycles.h>
-#include "common.h"
+#include "shared/common.h"
+#include "shared/secondary/utils.h"
+
#include "spp_proc.h"
#include "spp_mirror.h"
#include "command_proc.h"
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-01-15 3:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15 3:28 [spp] [PATCH 0/6] Refactor for including headers ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 1/6] shared: fix include error of add_port libs ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 2/6] spp_nfv: update to use common app_port libs ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 3/6] spp_vf/common: add RTE_LOGTYPE in each of files ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 4/6] spp_vf/common: change name of func of adding port ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 5/6] spp_vf: update makefile ogawa.yasufumi
2019-01-15 3:28 ` [spp] [PATCH 6/6] spp_mirror: " ogawa.yasufumi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).