From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH] shared/sec: add shared lib for secondary
Date: Tue, 6 Aug 2019 16:28:53 +0900 [thread overview]
Message-ID: <20190806072853.11530-1-yasufum.o@gmail.com> (raw)
From: Yasufumi Ogawa <yasufum.o@gmail.com>
`shared/common.c` defines features for both of primary and secondary.
However, it also includes used only for secondary. This update is to add
`shared/secondary/common.c` and its header file to define features only
for secondary.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/mirror/Makefile | 1 +
src/mirror/spp_mirror.c | 2 +-
src/nfv/Makefile | 4 +-
src/nfv/commands.h | 2 +-
src/nfv/main.c | 4 +-
src/pcap/Makefile | 1 +
src/pcap/spp_pcap.c | 1 +
src/shared/common.c | 48 ---------------
src/shared/common.h | 49 +---------------
src/shared/secondary/common.c | 58 +++++++++++++++++++
src/shared/secondary/common.h | 43 ++++++++++++++
.../spp_worker_th/cmd_res_formatter.h | 1 -
src/shared/secondary/spp_worker_th/vf_deps.h | 1 +
src/vf/Makefile | 1 +
src/vf/spp_vf.c | 1 +
15 files changed, 117 insertions(+), 100 deletions(-)
create mode 100644 src/shared/secondary/common.c
create mode 100644 src/shared/secondary/common.h
diff --git a/src/mirror/Makefile b/src/mirror/Makefile
index af9667e..ed2cb33 100644
--- a/src/mirror/Makefile
+++ b/src/mirror/Makefile
@@ -20,6 +20,7 @@ SRCS-y += ../shared/common.c
SRCS-y += $(SPP_SEC_DIR)/utils.c $(SPP_SEC_DIR)/add_port.c
SRCS-y += $(SPP_SEC_DIR)/json_helper.c
SRCS-y += $(SPP_SEC_DIR)/string_buffer.c
+SRCS-y += $(SPP_SEC_DIR)/common.c
SRCS-y += $(SPP_WKT_DIR)/cmd_utils.c
SRCS-y += $(SPP_WKT_DIR)/port_capability.c
SRCS-y += $(SPP_WKT_DIR)/conn_spp_ctl.c
diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index 96906fb..835c760 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -10,7 +10,7 @@
#include <rte_cycles.h>
#include "spp_mirror.h"
-#include "shared/common.h"
+#include "shared/secondary/common.h"
#include "shared/secondary/add_port.h"
#include "shared/secondary/return_codes.h"
#include "shared/secondary/utils.h"
diff --git a/src/nfv/Makefile b/src/nfv/Makefile
index 88533af..1328f61 100644
--- a/src/nfv/Makefile
+++ b/src/nfv/Makefile
@@ -13,7 +13,9 @@ 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
+SRCS-y := main.c nfv_status.c
+SRCS-y += ../shared/common.c
+SRCS-y += ../shared/secondary/common.c
SRCS-y += ../shared/secondary/utils.c ../shared/secondary/add_port.c
CFLAGS += -DALLOW_EXPERIMENTAL_API
diff --git a/src/nfv/commands.h b/src/nfv/commands.h
index 4b406ab..6eda72f 100644
--- a/src/nfv/commands.h
+++ b/src/nfv/commands.h
@@ -6,7 +6,7 @@
#ifndef _NFV_COMMANDS_H_
#define _NFV_COMMANDS_H_
-#include "shared/common.h"
+#include "shared/secondary/common.h"
#include "shared/secondary/add_port.h"
#include "shared/secondary/utils.h"
diff --git a/src/nfv/main.c b/src/nfv/main.c
index aa2dbc7..89e7714 100644
--- a/src/nfv/main.c
+++ b/src/nfv/main.c
@@ -11,9 +11,11 @@
#include <rte_memzone.h>
#include <rte_log.h>
-#include "shared/common.h"
+#include "shared/secondary/common.h"
#include "shared/secondary/utils.h"
#include "shared/secondary/add_port.h"
+#include "shared/secondary/common.h"
+#include "shared/common.h"
#include "params.h"
#include "init.h"
diff --git a/src/pcap/Makefile b/src/pcap/Makefile
index 6273b41..5e6f0a6 100644
--- a/src/pcap/Makefile
+++ b/src/pcap/Makefile
@@ -19,6 +19,7 @@ SRCS-y := spp_pcap.c
SRCS-y += cmd_utils.c
SRCS-y += cmd_runner.c cmd_parser.c
SRCS-y += ../shared/common.c
+SRCS-y += $(SPP_SEC_DIR)/common.c
SRCS-y += $(SPP_SEC_DIR)/utils.c
SRCS-y += $(SPP_SEC_DIR)/string_buffer.c
SRCS-y += $(SPP_WKT_DIR)/conn_spp_ctl.c
diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c
index 7f8d60a..ac87bd3 100644
--- a/src/pcap/spp_pcap.c
+++ b/src/pcap/spp_pcap.c
@@ -18,6 +18,7 @@
#include "spp_pcap.h"
#include "cmd_runner.h"
#include "cmd_parser.h"
+#include "shared/secondary/common.h"
#include "shared/secondary/return_codes.h"
#include "shared/secondary/utils.h"
#include "shared/secondary/spp_worker_th/port_capability.h"
diff --git a/src/shared/common.c b/src/shared/common.c
index aa1486a..afdc774 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -8,9 +8,6 @@
#define RTE_LOGTYPE_SHARED RTE_LOGTYPE_USER1
-char spp_ctl_ip[IPADDR_LEN] = { 0 }; /* IP address of spp_ctl. */
-int spp_ctl_port = -1; /* Port num to connect spp_ctl. */
-
/**
* Set log level of type RTE_LOGTYPE_USER* to given level, for instance,
* RTE_LOG_INFO or RTE_LOG_DEBUG.
@@ -119,51 +116,6 @@ int get_sec_dir(char *proc_name, char *dir_name)
return 0;
}
-/* Get IP address of spp_ctl as string. */
-int get_spp_ctl_ip(char *s_ip)
-{
- if (spp_ctl_ip == NULL) {
- RTE_LOG(ERR, SHARED, "IP addr of spp_ctl not initialized.\n");
- return -1;
- }
- sprintf(s_ip, "%s", spp_ctl_ip);
- return 0;
-}
-
-/* Set IP address of spp_ctl. */
-int set_spp_ctl_ip(const char *s_ip)
-{
- memset(spp_ctl_ip, 0x00, sizeof(spp_ctl_ip));
- sprintf(spp_ctl_ip, "%s", s_ip);
- if (spp_ctl_ip == NULL) {
- RTE_LOG(ERR, SHARED, "Failed to set IP of spp_ctl.\n");
- return -1;
- }
- return 0;
-}
-
-/* Get port number for connecting to spp_ctl as string. */
-int get_spp_ctl_port(void)
-{
- if (spp_ctl_port < 0) {
- RTE_LOG(ERR, SHARED, "Server port is not initialized.\n");
- return -1;
- }
- return spp_ctl_port;
-}
-
-/* Set port number for connecting to spp_ctl. */
-int set_spp_ctl_port(int s_port)
-{
- if (s_port < 0) {
- RTE_LOG(ERR, SHARED, "Given invalid port number '%d'.\n",
- s_port);
- return -1;
- }
- spp_ctl_port = s_port;
- return 0;
-}
-
/**
* Get port type and port ID from ethdev name, such as `eth_vhost1` which
* can be retrieved with rte_eth_dev_get_name_by_port().
diff --git a/src/shared/common.h b/src/shared/common.h
index 4d0dbe8..e414522 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -3,15 +3,13 @@
* Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
*/
-#ifndef _SHARED_COMMON_H_
-#define _SHARED_COMMON_H_
+#ifndef __SHARED_COMMON_H__
+#define __SHARED_COMMON_H__
#include <signal.h>
#include <unistd.h>
#include <rte_ethdev_driver.h>
-#define IPADDR_LEN 16 /* Length of IP address in string. */
-
#define MSG_SIZE 2048 /* socket buffer len */
#define SOCK_RESET -1
@@ -28,18 +26,6 @@
/* Interval time to retry connection. */
#define CONN_RETRY_USEC (1000 * 1000) /* micro sec */
-/*
- * When doing reads from the NIC or the client queues,
- * use this batch size
- */
-//#define PACKET_READ_SIZE 32
-
-/*
- * TODO(yasufum) move it from common.h used only for spp_nfv, spp_vf and
- * spp_mirror.
- */
-#define MAX_PKT_BURST 32
-
#define RTE_MP_RX_DESC_DEFAULT 512
#define RTE_MP_TX_DESC_DEFAULT 512
@@ -152,37 +138,6 @@ int get_sec_dir(char *proc_name, char *dir_name);
extern uint8_t lcore_id_used[RTE_MAX_LCORE];
-/**
- * Get IP address of spp_ctl as string.
- *
- * @param[in,out] s_ip IP address of spp_ctl.
- * @return 0 if succeeded, or -1 if failed.
- */
-int get_spp_ctl_ip(char *s_ip);
-
-/**
- * Set IP address of spp_ctl.
- *
- * @param[in] s_ip IP address of spp_ctl.
- * @return 0 if succeeded, or -1 if failed.
- */
-int set_spp_ctl_ip(const char *s_ip);
-
-/**
- * Get port number for connecting to spp_ctl as string.
- *
- * @return Port number, or -1 if failed.
- */
-int get_spp_ctl_port(void);
-
-/**
- * Set port number for connecting to spp_ctl.
- *
- * @param[in] s_port Port number for spp_ctl.
- * @return 0 if succeeded, or -1 if failed.
- */
-int set_spp_ctl_port(int s_port);
-
/**
* Get port type and port ID from ethdev name, such as `eth_vhost1` which
* can be retrieved with rte_eth_dev_get_name_by_port().
diff --git a/src/shared/secondary/common.c b/src/shared/secondary/common.c
new file mode 100644
index 0000000..f95c8ab
--- /dev/null
+++ b/src/shared/secondary/common.c
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#include <string.h>
+#include <rte_log.h>
+#include "common.h"
+
+#define RTE_LOGTYPE_SEC_COMMON RTE_LOGTYPE_USER1
+
+char spp_ctl_ip[IPADDR_LEN] = { 0 }; /* IP address of spp_ctl. */
+int spp_ctl_port = -1; /* Port num to connect spp_ctl. */
+
+/* Get IP address of spp_ctl as string. */
+int get_spp_ctl_ip(char *s_ip)
+{
+ if (spp_ctl_ip == NULL) {
+ RTE_LOG(ERR, SEC_COMMON,
+ "IP addr of spp_ctl not initialized.\n");
+ return -1;
+ }
+ sprintf(s_ip, "%s", spp_ctl_ip);
+ return 0;
+}
+
+/* Set IP address of spp_ctl. */
+int set_spp_ctl_ip(const char *s_ip)
+{
+ memset(spp_ctl_ip, 0x00, sizeof(spp_ctl_ip));
+ sprintf(spp_ctl_ip, "%s", s_ip);
+ if (spp_ctl_ip == NULL) {
+ RTE_LOG(ERR, SEC_COMMON, "Failed to set IP of spp_ctl.\n");
+ return -1;
+ }
+ return 0;
+}
+
+/* Get port number for connecting to spp_ctl as string. */
+int get_spp_ctl_port(void)
+{
+ if (spp_ctl_port < 0) {
+ RTE_LOG(ERR, SEC_COMMON, "Server port is not initialized.\n");
+ return -1;
+ }
+ return spp_ctl_port;
+}
+
+/* Set port number for connecting to spp_ctl. */
+int set_spp_ctl_port(int s_port)
+{
+ if (s_port < 0) {
+ RTE_LOG(ERR, SEC_COMMON, "Given invalid port number '%d'.\n",
+ s_port);
+ return -1;
+ }
+ spp_ctl_port = s_port;
+ return 0;
+}
diff --git a/src/shared/secondary/common.h b/src/shared/secondary/common.h
new file mode 100644
index 0000000..44c1b8b
--- /dev/null
+++ b/src/shared/secondary/common.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef __SHARED_SECONDARY_COMMON_H__
+#define __SHARED_SECONDARY_COMMON_H__
+
+#define MAX_PKT_BURST 32
+
+#define IPADDR_LEN 16 /* Length of IP address in string. */
+
+/**
+ * Get IP address of spp_ctl as string.
+ *
+ * @param[in,out] s_ip IP address of spp_ctl.
+ * @return 0 if succeeded, or -1 if failed.
+ */
+int get_spp_ctl_ip(char *s_ip);
+
+/**
+ * Set IP address of spp_ctl.
+ *
+ * @param[in] s_ip IP address of spp_ctl.
+ * @return 0 if succeeded, or -1 if failed.
+ */
+int set_spp_ctl_ip(const char *s_ip);
+
+/**
+ * Get port number for connecting to spp_ctl as string.
+ *
+ * @return Port number, or -1 if failed.
+ */
+int get_spp_ctl_port(void);
+
+/**
+ * Set port number for connecting to spp_ctl.
+ *
+ * @param[in] s_port Port number for spp_ctl.
+ * @return 0 if succeeded, or -1 if failed.
+ */
+int set_spp_ctl_port(int s_port);
+
+#endif
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
index 23abe27..b010a94 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
@@ -6,7 +6,6 @@
#define _SPPWK_CMD_RES_FORMATTER_H_
#include "cmd_utils.h"
-#include "shared/common.h"
#define CMD_RES_LEN 32 /* Size of message including null char. */
#define CMD_RES_TAG_LEN 32
diff --git a/src/shared/secondary/spp_worker_th/vf_deps.h b/src/shared/secondary/spp_worker_th/vf_deps.h
index a73329b..f2ea62a 100644
--- a/src/shared/secondary/spp_worker_th/vf_deps.h
+++ b/src/shared/secondary/spp_worker_th/vf_deps.h
@@ -10,6 +10,7 @@
#include "cmd_utils.h"
#include "cmd_parser.h"
#include "cmd_res_formatter.h"
+#include "shared/secondary/common.h"
#define SPPWK_PROC_TYPE "vf"
diff --git a/src/vf/Makefile b/src/vf/Makefile
index 5981d62..784d636 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -18,6 +18,7 @@ SPP_WKT_DIR = ../shared/secondary/spp_worker_th
SRCS-y := spp_vf.c classifier.c forwarder.c
SRCS-y += $(SPP_SEC_DIR)/string_buffer.c
SRCS-y += $(SPP_SEC_DIR)/json_helper.c
+SRCS-y += $(SPP_SEC_DIR)/common.c
SRCS-y += $(SPP_SEC_DIR)/utils.c $(SPP_SEC_DIR)/add_port.c
SRCS-y += $(SPP_WKT_DIR)/ringlatencystats.c
SRCS-y += $(SPP_WKT_DIR)/port_capability.c
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index e7f08f4..e56545f 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -8,6 +8,7 @@
#include "classifier.h"
#include "forwarder.h"
+#include "shared/secondary/common.h"
#include "shared/secondary/utils.h"
#include "shared/secondary/spp_worker_th/cmd_utils.h"
#include "shared/secondary/return_codes.h"
--
2.17.1
reply other threads:[~2019-08-06 7:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190806072853.11530-1-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--cc=ferruh.yigit@intel.com \
--cc=spp@dpdk.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).