From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8265EA00E6 for ; Tue, 6 Aug 2019 09:28:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7BF7E1B954; Tue, 6 Aug 2019 09:28:59 +0200 (CEST) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by dpdk.org (Postfix) with ESMTP id 23CE11B954 for ; Tue, 6 Aug 2019 09:28:58 +0200 (CEST) Received: by mail-pl1-f177.google.com with SMTP id b3so37529871plr.4 for ; Tue, 06 Aug 2019 00:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=UvsysQE9oC8XgfWO6/28Wgr0GfPV+3f3Eub2Bnaik88=; b=S3zbMGQOi5F/NVgpTKSl9ChWBbyOff4UwUBNPtDkTm9Sf8wJd7eX5sUMofw+g6N8Lj Wxz8Ff44CM1lu92mN54G1nUrxUJx5pZVIkrYaUK30OEfNTGw2J4qkliQ3W0yWfZN2AEP 16R2kY3KaEQ18kutegPY/cNjcfquKTDXrK9KPrSoR16MTOl8FE5YmwPJY+92ahYE+kEy 99tnFkPrUEbLaIl8clnfWZyLI38XtRafaglZhVdc0Q5mRn9xqFNPRL6yzYJ3GcxlxkER 799gOiWjjX7taKgkZMcQr3Ex8m7LU60CQ1l7CGYvCmdL+UM3VRPXDtex/wzzcalgwdeO XSOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=UvsysQE9oC8XgfWO6/28Wgr0GfPV+3f3Eub2Bnaik88=; b=jeWl5UDYY5xT3aQZhvEO8/9wTHZb89AHSubxILsV0NkME675dqiOZiVGEQlZ/Ey6Tu MihGMPmj4kF/CgXg4iCsNvFv/XXZXfUXXfIXsqEIOOE0ZS2oRTmr65Q87EF+6w90p958 QC8BkeOFgYGcUTt2Br6t8B4Ps7Ks4/fpCTH4Nw5hhu1ECW+DsoXcWxV7+csPOpzdKMs2 xAAIKCAmfIx9ir9dRXmrLcVDnq4rBUMR4gWzedSq7npRkIykyV1hHfnHBTbMAE1GezSG yb7hd0xxRg8kIfuVLlgIPHEKrktWwbbM+1a3lX6lIjJCmbCa1VSA2JU10FLC641fqI2U tMtg== X-Gm-Message-State: APjAAAVVrnF2Xv7X4ugwj6iPj3CjiHeOMTI1q5nZgsDawz66XcaWtM2a qdooY8993fHn5sn1zX2WQNdbqWwm X-Google-Smtp-Source: APXvYqwWokZoa3w07G1Qwbm62Yvlxowzi8rnhP12vvajArLykyttP5S1i1hI9yLSAp4YIRqq1OurZw== X-Received: by 2002:a17:902:bf4c:: with SMTP id u12mr1691569pls.317.1565076537090; Tue, 06 Aug 2019 00:28:57 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id b126sm125087973pfa.126.2019.08.06.00.28.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 00:28:56 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Tue, 6 Aug 2019 16:28:53 +0900 Message-Id: <20190806072853.11530-1-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [spp] [PATCH] shared/sec: add shared lib for secondary X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa `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 --- 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 #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 #include -#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 #include #include -#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 +#include +#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