Soft Patch Panel
 help / color / mirror / Atom feed
From: x-fn-spp@sl.ntt-tx.co.jp
To: spp@dpdk.org
Subject: [spp] [PATCH 09/57] spp_vf: add functions of command acceptance
Date: Thu, 28 Dec 2017 13:55:16 +0900	[thread overview]
Message-ID: <201712280456.vBS4u5tj010944@imss03.silk.ntt-tx.co.jp> (raw)
In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp>

From: Hiroyuki Nakamura <nakamura.hioryuki@po.ntt-tx.co.jp>

spp_vf supports command for modifying classifier table.
* Add functions of command acceptance.

Signed-off-by: Daiki Yamashita <yamashita.daiki.z01@as.ntt-tx.co.jp>
Signed-off-by: Yasufum Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/vf/Makefile       |   2 +-
 src/vf/command_proc.c | 669 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/vf/command_proc.h |  25 ++
 src/vf/spp_config.c   |  20 +-
 src/vf/spp_config.h   |  15 ++
 5 files changed, 720 insertions(+), 11 deletions(-)
 create mode 100644 src/vf/command_proc.c
 create mode 100644 src/vf/command_proc.h

diff --git a/src/vf/Makefile b/src/vf/Makefile
index 4961d2e..19617f6 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -40,7 +40,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = spp_vf
 
 # all source are stored in SRCS-y
-SRCS-y := spp_vf.c spp_config.c classifier_mac.c spp_forward.c ringlatencystats.c ../shared/common.c
+SRCS-y := spp_vf.c spp_config.c classifier_mac.c spp_forward.c command_proc.c ringlatencystats.c ../shared/common.c
 
 CFLAGS += $(WERROR_FLAGS) -O3
 CFLAGS += -I$(SRCDIR)/../shared
diff --git a/src/vf/command_proc.c b/src/vf/command_proc.c
new file mode 100644
index 0000000..f8d368f
--- /dev/null
+++ b/src/vf/command_proc.c
@@ -0,0 +1,669 @@
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <arpa/inet.h>
+
+#include <rte_common.h>
+#include <rte_log.h>
+#include <rte_branch_prediction.h>
+
+#include <jansson.h>
+
+#include "spp_vf.h"
+#include "spp_config.h"
+
+
+#define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+#define MESSAGE_BUFFER_BLOCK_SIZE 512
+
+static char g_controller_ip[128] = "";
+static int g_controller_port = 0;
+
+/*  */
+inline char*
+msgbuf_allocate(size_t capacity)
+{
+	char* buf = (char *)malloc(capacity + sizeof(size_t));
+	if (unlikely(buf == NULL))
+		return NULL;
+
+	*((size_t *)buf) = capacity;
+
+	return buf + sizeof(size_t);
+}
+
+/*  */
+inline void
+msgbuf_free(char* msgbuf)
+{
+	if (likely(msgbuf != NULL))
+		free(msgbuf - sizeof(size_t));
+}
+
+/*  */
+inline size_t
+msgbuf_get_capacity(const char *msgbuf)
+{
+	return *((const size_t *)(msgbuf - sizeof(size_t)));
+}
+
+/*  */
+inline char*
+msgbuf_reallocate(char *msgbuf, size_t required_len)
+{
+	size_t new_cap = msgbuf_get_capacity(msgbuf) * 2;
+	char *new_msgbuf = NULL;
+
+	while (unlikely(new_cap <= required_len))
+		new_cap *= 2;
+
+	new_msgbuf = msgbuf_allocate(new_cap);
+	if (unlikely(new_msgbuf == NULL))
+		return NULL;
+
+	strcpy(new_msgbuf, msgbuf);
+	msgbuf_free(msgbuf);
+
+	return new_msgbuf;
+}
+
+/*  */
+inline char*
+msgbuf_append(char *msgbuf, const char *append, size_t append_len)
+{
+	size_t cap = msgbuf_get_capacity(msgbuf);
+	size_t len = strlen(msgbuf);
+	char *new_msgbuf = msgbuf;
+
+	if (unlikely(len + append_len >= cap)) {
+		new_msgbuf = msgbuf_reallocate(msgbuf, len + append_len);
+		if (unlikely(new_msgbuf == NULL))
+			return NULL;
+	}
+
+	memcpy(new_msgbuf + len, append, append_len);
+	*(new_msgbuf + len + append_len) = '\0';
+
+	return new_msgbuf;
+}
+
+/*  */
+inline char*
+msgbuf_remove_front(char *msgbuf, size_t remove_len)
+{
+	size_t len = strlen(msgbuf);
+	size_t new_len = len - remove_len;
+
+	if (likely(new_len == 0)) {
+		*msgbuf = '\0';
+		return msgbuf;
+	}
+
+	return memmove(msgbuf, msgbuf + remove_len, new_len + 1);
+}
+
+/*  */
+static int
+connect_to_controller(int *sock)
+{
+	static struct sockaddr_in controller_addr;
+	int ret = -1;
+	int sock_flg = 0;
+
+	if (likely(*sock >=0))
+		return 0;
+
+	if (*sock < 0) {
+		*sock = socket(AF_INET, SOCK_STREAM, 0);
+		if (*sock < 0) {
+			RTE_LOG(ERR, SPP_COMMAND_PROC, 
+					"Cannot create tcp socket. errno=%d\n", errno);
+			return -1;
+		}
+
+		memset(&controller_addr, 0, sizeof(controller_addr));
+		controller_addr.sin_family = AF_INET;
+		controller_addr.sin_addr.s_addr = inet_addr(g_controller_ip);
+		controller_addr.sin_port = htons(g_controller_port);
+	}
+
+	ret = connect(*sock, (struct sockaddr *)&controller_addr,
+			sizeof(controller_addr));
+	if (ret < 0) {
+		RTE_LOG(ERR, SPP_COMMAND_PROC,
+				"Cannot connect to controller. errno=%d\n", errno);
+		return -1;
+	}
+
+	sock_flg = fcntl(*sock, F_GETFL, 0);
+	fcntl(*sock, F_SETFL, sock_flg | O_NONBLOCK);
+
+	return 0;
+}
+
+/*  */
+static int
+receive_request(int *sock, char **msgbuf)
+{
+	int ret = -1;
+	int n_rx = 0;
+	char *new_msgbuf = NULL;
+
+	char rx_buf[MESSAGE_BUFFER_BLOCK_SIZE];
+	size_t rx_buf_sz = MESSAGE_BUFFER_BLOCK_SIZE;
+
+	ret = recv(*sock, rx_buf, rx_buf_sz, 0);
+	if (ret <= 0) {
+		if (ret == 0) {
+
+		} else {
+			if (errno != EAGAIN && errno != EWOULDBLOCK) {
+				RTE_LOG(ERR, SPP_COMMAND_PROC,
+						"Cannot receive from socket. errno=%d\n", errno);
+			}
+			return 0;
+		}
+	}
+
+	n_rx = ret;
+
+	new_msgbuf = msgbuf_append(*msgbuf, rx_buf, n_rx);
+	if (unlikely(new_msgbuf == NULL)) {
+		return -1;
+	}
+
+	*msgbuf = new_msgbuf;
+
+	return n_rx;
+}
+
+/*  */
+static int
+send_response(void)
+{
+	return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#define CMD_MAX_COMMANDS 32
+
+#define CMD_NAME_BUFSZ 32
+
+#define CMD_CLASSIFIER_TABLE_VALUE_BUFSZ 62
+
+#define component_type spp_core_type
+
+/* command type */
+enum command_type {
+	CMDTYPE_ADD,
+	CMDTYPE_COMPONENT,
+	CMDTYPE_CLASSIFIER_TABLE,
+	CMDTYPE_FLUSH,
+	CMDTYPE_FORWARD,
+	CMDTYPE_STOP,
+
+	CMDTYPE_PROCESS,
+};
+
+/* command type string list */
+static const char *COMMAND_TYPE_STRINGS[] = {
+	"add",
+	"component",
+	"classifier_table",
+	"flush",
+	"forward",
+	"stop",
+
+	/* termination */ "",
+};
+
+/* classifier type */
+enum classifier_type {
+	CLASSIFIERTYPE_MAC,	
+};
+
+/* classifier type string list */
+static const char *CLASSIFILER_TYPE_STRINGS[] = {
+	"mac",
+
+	/* termination */ "",
+};
+
+/* "add" command parameters */
+struct add_command {
+	struct spp_config_port_info ports[RTE_MAX_ETHPORTS];
+};
+
+/* "component" command specific parameters */
+struct component_command {
+	enum component_type type;
+	unsigned int core_id;
+	struct spp_config_port_info rx_ports[RTE_MAX_ETHPORTS];
+	struct spp_config_port_info tx_ports[RTE_MAX_ETHPORTS];
+};
+
+/* "classifier_table" command specific parameters */
+struct classifier_table_command {
+	enum classifier_type type;
+	char value[CMD_CLASSIFIER_TABLE_VALUE_BUFSZ];
+	struct spp_config_port_info port;
+};
+
+#if 0
+/* "flush" command specific parameters */
+struct flush_command {
+	/* nothing specific */
+};
+#endif
+
+/* command parameters */
+struct command {
+	enum command_type type;
+
+	union {
+		struct add_command add;
+		struct component_command component;
+		struct classifier_table_command classifier_table;
+	} spec;
+};
+
+/* request parameters */
+struct request {
+	int num_command;
+	struct command commands[CMD_MAX_COMMANDS];
+};
+
+/* forward declaration */
+struct json_value_decode_rule;
+
+/* definition of decode procedure function */
+typedef int (*json_value_decode_proc)(void *, const json_t *, const struct json_value_decode_rule *);
+
+/* rule definition that decode json object to c-struct */
+struct json_value_decode_rule {
+	char name[CMD_NAME_BUFSZ];
+	json_type json_type;
+	size_t offset;
+	json_value_decode_proc decode_proc;
+#if 0
+	union {
+		size_t buf_sz;
+	} spec;
+
+	json_type sub_json_type;
+	const struct json_value_decode_rule *sub_rules;
+#endif
+	size_t sub_offset;
+	size_t sub_offset_num;
+};
+
+/* get output address for decoded json value */
+#define DR_GET_OUTPUT(output_base, rule__) ((char *)output_base + rule__->offset)
+
+/* helper */
+#define END_OF_DECODE_RULE {.name = ""},
+#define IS_END_OF_DECODE_RULE(rule) ((rule)->name[0] == '\0')
+
+/* definition helper that enum value decode procedure */
+#define DECODE_ENUM_VALUE(proc_name, enum_type, string_table)			\
+int										\
+decode_##proc_name##_value(void *output, const json_t *value_obj,		\
+		const struct json_value_decode_rule *rule)			\
+{										\
+	int i;									\
+	enum_type type;								\
+	const char *str_val = json_string_value(value_obj);			\
+										\
+	for (i = 0; string_table[i][0] != '\0'; ++i) {				\
+		if (unlikely(strcmp(str_val, string_table[i]) == 0)) {		\
+			type = i;						\
+			memcpy(output, &type, sizeof(enum_type));		\
+			return 0;						\
+		}								\
+	}									\
+										\
+	return -1;								\
+}										\
+
+/* enum value decode procedure for "command_type" */
+DECODE_ENUM_VALUE(command_type, enum command_type, COMMAND_TYPE_STRINGS)
+
+/* enum value decode procedure for "classifier_type" */
+DECODE_ENUM_VALUE(classifier_type, enum classifier_type, CLASSIFILER_TYPE_STRINGS)
+
+/* decode procedure for integer */
+static int
+decode_int_value(void *output, const json_t *value_obj,
+		const struct json_value_decode_rule *rule)
+{
+	int val = json_integer_value(value_obj);
+	memcpy(output, &val, sizeof(int));
+
+	return 0;
+}
+
+/* decode procedure for string */
+static int
+decode_string_value(void *output, const json_t *value_obj,
+		const struct json_value_decode_rule *rule)
+{
+	const char* str_val = json_string_value(value_obj);
+#if 0
+	size_t len = strlen(str_val);
+	if (unlikely(len >= rule->spec.buf_sz)) {
+		RTE_LOG(ERR, SPP_COMMAND_PROC, "Invalid json value. "
+				"name=%s\n", rule->name);
+		return -1;
+	}
+#endif
+	strcpy(output, str_val);
+
+	return 0;
+}
+
+/* decode procedure for spp_config_port_info */
+static int
+decode_port_value(void *output, const json_t *value_obj,
+		const struct json_value_decode_rule *rule)
+{
+	int ret = -1;
+	struct spp_config_port_info *port = (struct spp_config_port_info *)output;
+
+	const char* str_val = json_string_value(value_obj);
+
+	ret = spp_config_get_if_info(str_val, &port->if_type, &port->if_no);
+	if (unlikely(ret != 0))
+		return -1;
+
+	return 0;
+}
+
+/* decode json object */
+static int
+decode_json_object(void *output, const json_t *parent_obj,
+		const struct json_value_decode_rule *rules)
+{
+	int ret = -1;
+	int i, n;
+	json_t *obj;
+	json_t *value_obj;
+	const struct json_value_decode_rule *rule;
+
+	void *sub_output;
+
+	for (i = 0; unlikely(! IS_END_OF_DECODE_RULE(&rules[i])); ++ i) {
+		rule = rules + 1;
+
+		value_obj = json_object_get(parent_obj, rule->name);
+		if (unlikely(value_obj == NULL) || 
+				unlikely(json_typeof(value_obj) != rule->json_type)) {
+			RTE_LOG(ERR, SPP_COMMAND_PROC, "Invalid json value. "
+					"name=%s\n", rule->name);
+			return -1;
+		}
+
+		switch (rule->json_type) {
+		case JSON_ARRAY:
+			json_array_foreach(value_obj, n, obj) {
+				sub_output = DR_GET_OUTPUT(output, rule) + (rule->sub_offset * i);
+				ret = (*rule->decode_proc)(sub_output, obj, rule);
+			}
+			*(int *)((char *)output + rule->sub_offset_num) = n;
+			break;
+		default:
+			sub_output = DR_GET_OUTPUT(output, rule);
+			ret = (*rule->decode_proc)(sub_output, value_obj, rule);
+			break;
+		}
+	}
+
+	return 0;
+}
+
+/*  */
+const struct json_value_decode_rule DECODERULE_COMMAND_BASE[] = {
+	{
+		.name = "command",
+		.json_type = JSON_STRING,
+		.offset = offsetof(struct command, type),
+		.decode_proc = decode_command_type_value,
+	},
+	END_OF_DECODE_RULE
+};
+
+/*  */
+const struct json_value_decode_rule DECODERULE_ADD_COMMAND[] = {
+	{
+		.name = "ports",
+		.json_type = JSON_ARRAY,
+		.offset = offsetof(struct add_command, ports),
+		.decode_proc = decode_port_value,
+//		.sub_json_type = JSON_STRING,
+		.sub_offset = sizeof(struct spp_config_port_info),
+	},
+	END_OF_DECODE_RULE
+};
+
+/*  */
+const struct json_value_decode_rule DECODERULE_CLASSIFIER_TABLE_COMMAND[] = {
+	{
+		.name = "type",
+		.json_type = JSON_STRING,
+		.offset = offsetof(struct classifier_table_command, type),
+		.decode_proc = decode_classifier_type_value,
+	},{
+		.name = "value",
+		.json_type = JSON_STRING,
+		.offset = offsetof(struct classifier_table_command, value),
+		.decode_proc = decode_string_value,
+	},{
+		.name = "port",
+		.json_type = JSON_STRING,
+		.offset = offsetof(struct classifier_table_command, port),
+		.decode_proc = decode_port_value,
+	},
+	END_OF_DECODE_RULE
+};
+
+/*  */
+static int
+decode_command_object(void* output, const json_t *parent_obj,
+		const struct json_value_decode_rule *rule)
+{
+	int ret = -1;
+	struct command *command = (struct command *)output;
+	const struct json_value_decode_rule *spec_rules = NULL;
+
+	/* decode command base */
+	ret = decode_json_object(command, parent_obj, DECODERULE_COMMAND_BASE);
+	if (unlikely(ret != 0)) {
+		// TODO:コマンドがデコード失敗
+		return -1;
+	}
+
+	/* decode command specific */
+	switch (command->type) {
+		case CMDTYPE_CLASSIFIER_TABLE:
+			spec_rules = DECODERULE_CLASSIFIER_TABLE_COMMAND;
+			break;
+
+		case CMDTYPE_FLUSH:
+			break;
+
+		default:
+			break;
+	}
+
+	if (likely(spec_rules != NULL)) {
+		ret = decode_json_object(&command->spec, parent_obj, spec_rules);
+		if (unlikely(ret != 0)) {
+			// TODO:コマンドがデコード失敗
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+/*  */
+const struct json_value_decode_rule DECODERULE_REQUEST[] = {
+	{
+		.name = "commands",
+		.json_type = JSON_ARRAY,
+		.offset = offsetof(struct request, commands),
+		.decode_proc = decode_command_object,
+//		.sub_json_type = JSON_OBJECT,
+		.sub_offset = sizeof(struct command),
+		.sub_offset_num = offsetof(struct request, num_command),
+	},
+	END_OF_DECODE_RULE
+};
+
+/*  */
+static int
+decode_request(struct request *request, json_t **top_obj, const char *request_str, size_t request_str_len)
+{
+	int ret = -1;
+	int i;
+	json_error_t json_error;
+
+	/* parse json string */
+	*top_obj = json_loadb(request_str, request_str_len, 0, &json_error);
+	if (unlikely(*top_obj == NULL)) {
+		RTE_LOG(ERR, SPP_COMMAND_PROC, "Cannot parse command request. "
+				"error=%s\n", 
+				json_error.text);
+		return -1;
+	}
+
+	/* decode request object */
+	ret = decode_json_object(request, *top_obj, DECODERULE_REQUEST);
+	if (unlikely(ret != 0)) {
+		// TODO:エラー
+		return -1;
+	}
+
+	return 0;
+}
+
+/*  */
+static int
+execute_command(const struct command *command)
+{
+	int ret = -1;
+
+	switch (command->type) {
+	case CMDTYPE_CLASSIFIER_TABLE:
+		ret = spp_update_classifier_table(
+				SPP_CLASSIFIER_TYPE_MAC,
+//				command->spec.classifier_table.type,
+				command->spec.classifier_table.value,
+				&command->spec.classifier_table.port);
+		break;
+
+	case CMDTYPE_FLUSH:
+		ret = spp_flush();
+		break;
+
+	case CMDTYPE_PROCESS:
+		break;
+
+	default:
+		ret = 0;
+		break;
+	}
+
+	return 0;
+}
+
+/*  */
+static int
+process_request(const char *request_str, size_t request_str_len)
+{
+	int ret = -1;
+	int i;
+
+	struct request request;
+	json_t *top_obj;
+
+	memset(&request, 0, sizeof(struct request));
+
+	ret = decode_request(&request, &top_obj, request_str, request_str_len);
+	if (unlikely(ret != 0))
+		return -1;
+
+	for (i = 0; i < request.num_command ; ++i) {
+		ret = execute_command(request.commands + i);
+	}
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+/*  */
+int
+spp_command_proc_init(const char *controller_ip, int controller_port)
+{
+	strcpy(g_controller_ip, controller_ip);
+	g_controller_port = controller_port;
+
+	return 0;
+}
+
+/*  */
+void
+spp_command_proc_do(void)
+{
+	int ret = -1;
+	int i;
+
+	static int sock = -1;
+	static char *msgbuf = NULL;
+	static size_t msg_len = 0;
+
+	static size_t rb_cnt = 0;
+	static size_t lb_cnt = 0;
+
+	if (unlikely(msgbuf == NULL))
+		msgbuf = msgbuf_allocate(MESSAGE_BUFFER_BLOCK_SIZE);
+
+	ret = connect_to_controller(&sock);
+	if (unlikely(ret != 0))
+		return;
+
+	ret = receive_request(&sock, &msgbuf);
+	if (likely(ret == 0)) {
+		return;
+	}
+
+	for (i = 0; i < ret; ++i) {
+		switch (*(msgbuf + msg_len + i)) {
+		case '{':
+			++lb_cnt;
+			break;
+		case '}':
+			++rb_cnt;
+			break;
+		}
+
+		if (likely(lb_cnt != 0) && unlikely(rb_cnt == lb_cnt)) {
+			msg_len += (i + 1);
+			ret = process_request(msgbuf, msg_len);
+
+			msgbuf_remove_front(msgbuf, msg_len);
+			msg_len = 0;
+			rb_cnt = 0;
+			lb_cnt = 0;
+		}
+	}
+}
diff --git a/src/vf/command_proc.h b/src/vf/command_proc.h
new file mode 100644
index 0000000..8774070
--- /dev/null
+++ b/src/vf/command_proc.h
@@ -0,0 +1,25 @@
+#ifndef _COMMAND_PROC_H_
+#define _COMMAND_PROC_H_
+
+/**
+ * intialize command processor.
+ *
+ * @param controller_ip
+ *  controller listen ip address.
+ *
+ * @param controller_port
+ *  controller listen port number.
+ *
+ * @ret_val 0 succeeded.
+ * @ret_val -1 failed.
+ */
+int
+spp_command_proc_init(const char *controller_ip, int controller_port);
+
+/**
+ * process command from controller.
+ */
+void
+spp_command_proc_do(void);
+
+#endif /* _COMMAND_PROC_H_ */
diff --git a/src/vf/spp_config.c b/src/vf/spp_config.c
index 1794e84..4ad4f87 100644
--- a/src/vf/spp_config.c
+++ b/src/vf/spp_config.c
@@ -104,8 +104,8 @@ config_init_data(struct spp_config_area *config)
  * IFの情報からIF種別とIF番号を取得する
  * ("ring0" -> 種別:"ring"、番号:0)
  */
-static int
-config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
+int
+spp_config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
 {
 	enum port_type type = UNDEF;
 	const char *no_str = NULL;
@@ -150,8 +150,8 @@ config_get_if_info(const char *port, enum port_type *if_type, int *if_no)
 /*
  * MAC addressを文字列から数値へ変換
  */
-static int64_t
-config_change_mac_str_to_int64(const char *mac)
+int64_t
+spp_config_change_mac_str_to_int64(const char *mac)
 {
 	int64_t ret_mac = 0;
 	int64_t token_val = 0;
@@ -270,7 +270,7 @@ config_load_classifier_table(const json_t *obj,
 		}
 
 		/* MACアドレス数値変換 */
-		int64_t ret_mac64 = config_change_mac_str_to_int64(
+		int64_t ret_mac64 = spp_config_change_mac_str_to_int64(
 				tmp_table->mac_addr_str);
 		if (unlikely(ret_mac64 == -1)) {
 			RTE_LOG(ERR, APP,
@@ -291,7 +291,7 @@ config_load_classifier_table(const json_t *obj,
 		}
 
 		/* IF種別とIF番号に分割 */
-		int ret_if = config_get_if_info(if_str, &tmp_table->port.if_type,
+		int ret_if = spp_config_get_if_info(if_str, &tmp_table->port.if_type,
 				&tmp_table->port.if_no);
 		if (unlikely(ret_if != 0)) {
 			RTE_LOG(ERR, APP,
@@ -385,7 +385,7 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 			strcpy(if_str, json_string_value(elements_obj));
 
 			/* IF種別とIF番号に分割 */
-			int ret_if = config_get_if_info(if_str, &tmp_rx_port->if_type,
+			int ret_if = spp_config_get_if_info(if_str, &tmp_rx_port->if_type,
 					&tmp_rx_port->if_no);
 			if (unlikely(ret_if != 0)) {
 				RTE_LOG(ERR, APP,
@@ -407,7 +407,7 @@ config_set_rx_port(enum spp_core_type type, json_t *obj,
 		}
 
 		/* IF種別とIF番号に分割 */
-		int ret_if = config_get_if_info(if_str, &tmp_rx_port->if_type,
+		int ret_if = spp_config_get_if_info(if_str, &tmp_rx_port->if_type,
 				&tmp_rx_port->if_no);
 		if (unlikely(ret_if != 0)) {
 			RTE_LOG(ERR, APP,
@@ -444,7 +444,7 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 		}
 
 		/* IF種別とIF番号に分割 */
-		int ret_if = config_get_if_info(if_str, &tmp_tx_port->if_type,
+		int ret_if = spp_config_get_if_info(if_str, &tmp_tx_port->if_type,
 				&tmp_tx_port->if_no);
 		if (unlikely(ret_if != 0)) {
 			RTE_LOG(ERR, APP,
@@ -520,7 +520,7 @@ config_set_tx_port(enum spp_core_type type, json_t *obj,
 				strcpy(if_str, json_string_value(elements_obj));
 
 				/* IF種別とIF番号に分割 */
-				int ret_if = config_get_if_info(if_str, &tmp_tx_port->if_type,
+				int ret_if = spp_config_get_if_info(if_str, &tmp_tx_port->if_type,
 						&tmp_tx_port->if_no);
 				if (unlikely(ret_if != 0)) {
 					RTE_LOG(ERR, APP,
diff --git a/src/vf/spp_config.h b/src/vf/spp_config.h
index 24ddd32..37414cf 100644
--- a/src/vf/spp_config.h
+++ b/src/vf/spp_config.h
@@ -81,6 +81,21 @@ struct spp_config_area {
 };
 
 /*
+ * Change mac address string to int64
+ * OK : int64 that store mac address
+ * NG : -1
+ */
+int64_t spp_config_change_mac_str_to_int64(const char *mac);
+
+/*
+ * Extract if-type/if-number from port string
+ *
+ * OK : 0
+ * NG : -1
+ */
+int spp_config_get_if_info(const char *port, enum port_type *if_type, int *if_no);
+
+/*
  * Load config file
  * OK : 0
  * NG : -1
-- 
1.9.1

  parent reply	other threads:[~2017-12-28  4:56 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-25  4:41 [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Nakamura Hioryuki
2017-12-26  1:54 ` Yasufumi Ogawa
2017-12-28  4:55   ` [spp] [PATCH 01/57] spp_vf: add vf functions x-fn-spp
2017-12-28  8:49     ` Yasufumi Ogawa
2017-12-28  4:55   ` [spp] [PATCH 02/57] spp_vf: support multi process x-fn-spp
2018-02-07 16:50     ` Ferruh Yigit
2018-02-08  1:21       ` Yasufumi Ogawa
2018-02-08  6:44       ` [spp] [spp 02168] " Nakamura Hioryuki
2017-12-28  4:55   ` [spp] [PATCH 03/57] spp_vf: comment out check of using cores x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 04/57] spp_vf: modify classifier for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 05/57] spp_vf: add procedure that mac address is null x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 06/57] spp_vf: change config format for upd command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 07/57] spp_vf: fix compiler warning in classifier_mac.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 08/57] spp_vf: modify data struct for upd command x-fn-spp
2017-12-28  4:55   ` x-fn-spp [this message]
2017-12-28  4:55   ` [spp] [PATCH 10/57] spp_vf: add command acceptance calling x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 11/57] spp_vf: fix compiler warning in command_proc.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 12/57] " x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 13/57] spp_vf: refactor command acceptance/decode x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 14/57] spp_vf: fix return value overwrite problem x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 15/57] spp_vf: initialize message buffer x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 16/57] spp_vf: add const keyword to parameter x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 17/57] spp_vf: fix wrong comparison operator x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 18/57] spp_vf: fix wrong variable to be assigned x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 19/57] spp_vf: refactor parsing server ip address x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 20/57] spp_vf: fix error in command decode x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 21/57] spp_vf: fix comparison operator in spp_vf.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 22/57] spp_vf: check upper limit to the number of process x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 23/57] spp_vf: display usage message x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 24/57] spp_vf: split command processing source file x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 25/57] spp_vf: add new log and line break x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 26/57] spp_vf: support get-process-id command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 27/57] spp_vf: update socket creation procedure x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 28/57] spp_vf: change log level and add line break x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 29/57] spp_vf: replace unsupported jansson api x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 30/57] spp_vf: change order of command result in json object x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 31/57] spp_vf: use prediction keywords x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 32/57] spp_vf: fix wrong comparison x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 33/57] spp_vf: update sending error status x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 34/57] spp_vf: modify conditional statement x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 35/57] spp_vf: add proc on receiving l2 multicast x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 36/57] spp_vf: extend limit on number of usable cores x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 37/57] spp_vf: add restart procedure for vhost client x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 38/57] spp_vf: fix classifier mbuf handling x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 39/57] spp_vf: add status command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 40/57] spp_vf: add output source information in error log x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 41/57] spp_vf: change function names x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 42/57] spp_vf: change how to request commands x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 43/57] spp_vf: update command decode procedure x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 44/57] spp_vf: remove debug log output procedures x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 45/57] spp_vf: improve command_decoder program code x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 46/57] spp_vf: fix a bug in status command x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 47/57] spp_vf: add spp_vf.py instead of spp.py x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 48/57] spp_vf: refactor for commnets in spp_vf.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 49/57] spp_vf: refactor comments in classifier_mac.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 50/57] spp_vf: refactor comments in spp_forward.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 51/57] spp_vf: refactor for commnets in spp_config.c x-fn-spp
2017-12-28  4:55   ` [spp] [PATCH 52/57] spp_vf: refactor no self-explanatory comments x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 53/57] spp_vf: correct typo of function name x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 54/57] spp_vf: support new command x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 55/57] spp_vf: add display of status command x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 56/57] spp_vf: fix " x-fn-spp
2017-12-28  4:56   ` [spp] [PATCH 57/57] spp_vf: fix l2 multicast packet forwarding x-fn-spp
2018-01-15 11:04 ` [spp] Proposal - spp_vf(SR-IOV like feature) addition to SPP Ferruh Yigit
2018-01-16  5:16   ` [spp] [PATCH 01/30] doc: add setup guide x-fn-spp
2018-01-19  0:52     ` Yasufumi Ogawa
2018-01-22 14:37       ` Ferruh Yigit
2018-01-23  0:25         ` Yasufumi Ogawa
2018-01-16  5:16   ` [spp] [PATCH 02/30] doc: add how_to_use.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 03/30] doc: add config_manual.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 04/30] doc: add spp_vf.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 05/30] doc: revise spp_vf.md x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 06/30] doc: add config section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 07/30] doc: update jp setup manual x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 08/30] doc: modify figure in spp_vf_overview x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 09/30] doc: fix " x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 10/30] doc: fix figure in overview x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 11/30] doc: add sample usage x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 12/30] doc: revice path descs x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 13/30] doc: add network configuration diagram x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 14/30] doc: update user account x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 15/30] doc: update descriptions for todo x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 16/30] doc: add description for explanation section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 17/30] doc: add spp_sample_usage_svg in docs/spp_vf/ x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 18/30] doc: add explanation for terminating spp app x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 19/30] doc: add explanations on options of spp x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 20/30] doc: update description for the latest spp version x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 21/30] doc: update description on dpdk version x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 22/30] doc: fix vm setup procedure for network config x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 23/30] doc: update jansson installation procedure x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 24/30] doc: fix required network configuration x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 25/30] doc: add how to use vhost-user support x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 26/30] doc: add references to hugepages and isolcpus x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 27/30] doc: remove description on classifier_table x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 28/30] doc: fix typos and erros in texts x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 29/30] doc: update sample config section x-fn-spp
2018-01-16  5:16   ` [spp] [PATCH 30/30] doc: align figure title position x-fn-spp

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=201712280456.vBS4u5tj010944@imss03.silk.ntt-tx.co.jp \
    --to=x-fn-spp@sl.ntt-tx.co.jp \
    --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).