Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 03/17] shared/sec: revice cmd parser of SPP worker
Date: Wed,  8 May 2019 11:01:21 +0900	[thread overview]
Message-ID: <1557280895-7978-4-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1557280895-7978-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

The name of header file of command parser for SPP worker threads is
`command_dec.h` which means "decode commands", but the features are
not for decoding but parsing. This update is to change it to
`cmd_parser.h` and refactor name of vars, functions and its comments
defined in the header file.

This update also includes refactoring name of attributes of
sppwk_parse_err_msg object and comments for functions in which this
object is used.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/mirror/spp_mirror.c                       |   2 +-
 .../secondary/spp_worker_th/cmd_parser.h      | 156 ++++++++++++++
 .../secondary/spp_worker_th/command_dec.c     |  84 ++++----
 .../secondary/spp_worker_th/command_dec.h     | 203 ------------------
 .../secondary/spp_worker_th/command_proc.c    |  12 +-
 src/vf/spp_vf.c                               |   2 +-
 6 files changed, 207 insertions(+), 252 deletions(-)
 create mode 100644 src/shared/secondary/spp_worker_th/cmd_parser.h
 delete mode 100644 src/shared/secondary/spp_worker_th/command_dec.h

diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index ba0919a..6d01501 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -13,7 +13,7 @@
 #include "shared/common.h"
 #include "shared/secondary/utils.h"
 #include "shared/secondary/spp_worker_th/command_proc.h"
-#include "shared/secondary/spp_worker_th/command_dec.h"
+#include "shared/secondary/spp_worker_th/cmd_parser.h"
 #include "shared/secondary/spp_worker_th/spp_proc.h"
 #include "shared/secondary/spp_worker_th/spp_port.h"
 
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.h b/src/shared/secondary/spp_worker_th/cmd_parser.h
new file mode 100644
index 0000000..6792b08
--- /dev/null
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.h
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
+ */
+
+#ifndef _SPPWK_CMD_PARSER_H_
+#define _SPPWK_CMD_PARSER_H_
+
+/**
+ * @file cmd_parser.h
+ * @brief Define a set of vars and functions for parsing SPP worker commands.
+ */
+
+#include "spp_proc.h"
+
+/* Maximum number of commands per request. */
+#define SPP_CMD_MAX_COMMANDS 32
+
+/* Maximum number of parameters per command. */
+#define SPP_CMD_MAX_PARAMETERS 8
+
+/* Size of string buffer of message including null char. */
+#define SPP_CMD_NAME_BUFSZ  32
+
+/* Size of string buffer of detailed message including null char. */
+#define SPP_CMD_VALUE_BUFSZ 111
+
+/* Fix value for 'unused' status. */
+#define SPP_CMD_UNUSE "unuse"
+
+/**
+ * Error code for diagnosis and notifying the reason. It starts from 1 because
+ * 0 is used for succeeded and not appropriate for error in general.
+ */
+enum sppwk_parse_error_code {
+	SPPWK_PARSE_WRONG_FORMAT = 1,  /**< Wrong format */
+	SPPWK_PARSE_UNKNOWN_CMD,  /**< Unknown command */
+	SPPWK_PARSE_NO_PARAM,  /**< No parameters */
+	SPPWK_PARSE_INVALID_TYPE,  /**< Invalid data type */
+	SPPWK_PARSE_INVALID_VALUE,  /**< Invalid value */
+};
+
+/**
+ * Define actions of SPP worker threads. Each of targeting objects and actions
+ * is defined as following.
+ *   - compomnent      : start, stop
+ *   - port            : add, del
+ *   - classifier_table: add, del
+ */
+/* TODO(yasufum) refactor each name prefix `SPP_CMD_ACTION_`. */
+enum spp_command_action {
+	SPP_CMD_ACTION_NONE,  /**< none */
+	SPP_CMD_ACTION_START, /**< start */
+	SPP_CMD_ACTION_STOP,  /**< stop */
+	SPP_CMD_ACTION_ADD,   /**< add */
+	SPP_CMD_ACTION_DEL,   /**< delete */
+};
+
+/**
+ * SPP command type.
+ *
+ * @attention This enumerated type must have the same order of command_list
+ *            defined in command_dec.c
+ */
+/* TODO(yasufum) refactor each name prefix `SPP_`. */
+enum spp_command_type {
+	SPP_CMDTYPE_CLASSIFIER_TABLE_MAC,
+	SPP_CMDTYPE_CLASSIFIER_TABLE_VLAN,
+	SPP_CMDTYPE_CLIENT_ID,  /**< get_client_id */
+	SPP_CMDTYPE_STATUS,  /**< status */
+	SPP_CMDTYPE_EXIT,  /**< exit */
+	SPP_CMDTYPE_COMPONENT,  /**< component */
+	SPP_CMDTYPE_PORT,  /**< port */
+};
+
+/* `classifier_table` command specific parameters. */
+struct spp_command_classifier_table {
+	enum spp_command_action action;  /**< add or del */
+	enum spp_classifier_type type;  /**< currently only for mac */
+	int vid;  /**< VLAN ID  */
+	char mac[SPP_CMD_VALUE_BUFSZ];  /**< MAC address  */
+	struct spp_port_index port;/**< Destination port type and number */
+};
+
+/* `flush` command specific parameters. */
+struct spp_command_flush {
+	/* nothing specific */
+};
+
+/* `component` command parameters. */
+struct spp_command_component {
+	enum spp_command_action action;  /**< start or stop */
+	char name[SPP_CMD_NAME_BUFSZ];  /**< component name */
+	unsigned int core;  /**< logical core number */
+	enum spp_component_type type;  /**< component type */
+};
+
+/* `port` command parameters. */
+struct spp_command_port {
+	enum spp_command_action action;  /**< add or del */
+	struct spp_port_index port;  /**< port type and number */
+	enum spp_port_rxtx rxtx;  /**< rx or tx identifier */
+	char name[SPP_CMD_NAME_BUFSZ];  /**<  component name */
+	struct spp_port_ability ability;  /**< port ability */
+};
+
+struct spp_command {
+	enum spp_command_type type; /**< command type */
+
+	union {  /**< command descriptors */
+		struct spp_command_classifier_table classifier_table;
+		struct spp_command_flush flush;
+		struct spp_command_component component;
+		struct spp_command_port port;
+	} spec;
+};
+
+/* Request parameters. */
+struct spp_command_request {
+	int num_command;  /**< Number of accepted commands */
+	int num_valid_command;  /**< Number of executed commands */
+	struct spp_command commands[SPP_CMD_MAX_COMMANDS];  /**< list of cmds */
+
+	int is_requested_client_id;
+	int is_requested_status;
+	int is_requested_exit;
+};
+
+/* Error message if parse failed. */
+struct sppwk_parse_err_msg {
+	int code;  /**< Code in enu sppwk_parse_error_code */
+	char msg[SPP_CMD_NAME_BUFSZ];   /**< Message in short */
+	char details[SPP_CMD_VALUE_BUFSZ];  /**< Detailed message */
+};
+
+/**
+ * Parse request of non null terminated string.
+ *
+ * @param request
+ *  The pointer to struct spp_command_request.@n
+ *  The result value of decoding the command message.
+ * @param request_str
+ *  The pointer to requested command message.
+ * @param request_str_len
+ *  The length of requested command message.
+ * @param wk_err_msg
+ *  The pointer to struct sppwk_parse_err_msg.@n
+ *  Detailed error information will be stored.
+ *
+ * @retval SPP_RET_OK succeeded.
+ * @retval !0 failed.
+ */
+int spp_command_decode_request(struct spp_command_request *request,
+		const char *request_str, size_t request_str_len,
+		struct sppwk_parse_err_msg *wk_err_msg);
+
+#endif /* _SPPWK_CMD_PARSER_H_ */
diff --git a/src/shared/secondary/spp_worker_th/command_dec.c b/src/shared/secondary/spp_worker_th/command_dec.c
index db69dfe..77f15c5 100644
--- a/src/shared/secondary/spp_worker_th/command_dec.c
+++ b/src/shared/secondary/spp_worker_th/command_dec.c
@@ -9,7 +9,7 @@
 #include <rte_log.h>
 #include <rte_branch_prediction.h>
 
-#include "command_dec.h"
+#include "cmd_parser.h"
 
 #define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER2
@@ -58,7 +58,7 @@ const char *CLASSIFILER_TYPE_STRINGS[] = {
 
 /*
  * command action type string list
- * do it same as the order of enum spp_command_action (command_dec.h)
+ * do it same as the order of enum spp_command_action (cmd_parser.h)
  */
 const char *COMMAND_ACTION_STRINGS[] = {
 	SPP_ACTION_NONE_STR,
@@ -201,29 +201,29 @@ spp_convert_component_type(const char *type_str)
 	return SPP_COMPONENT_UNUSE;
 }
 
-/* Format error message object and return error code for an error case */
+/* Format error message object and return error code for an error case. */
 static inline int
-set_parse_error(struct sppwk_parse_err_msg *err_msg,
-		const int err_code, const char *err_name)
+set_parse_error(struct sppwk_parse_err_msg *wk_err_msg,
+		const int err_code, const char *err_msg)
 {
-	err_msg->code = err_code;
+	wk_err_msg->code = err_code;
 
-	if (likely(err_name != NULL))
-		strcpy(err_msg->value_name, err_name);
+	if (likely(err_msg != NULL))
+		strcpy(wk_err_msg->msg, err_msg);
 
-	return err_msg->code;
+	return wk_err_msg->code;
 }
 
-/* set decode error */
+/* Set parse error message. */
 static inline int
-set_string_value_decode_error(struct sppwk_parse_err_msg *error,
-		const char *value, const char *error_name)
+set_string_value_decode_error(struct sppwk_parse_err_msg *wk_err_msg,
+		const char *err_details, const char *err_msg)
 {
-	strcpy(error->value, value);
-	return set_parse_error(error, SPPWK_PARSE_INVALID_VALUE, error_name);
+	strcpy(wk_err_msg->details, err_details);
+	return set_parse_error(wk_err_msg, SPPWK_PARSE_INVALID_VALUE, err_msg);
 }
 
-/* Split command line parameter with spaces */
+/* Split command line parameter with spaces. */
 static int
 decode_parameter_value(char *string, int max, int *argc, char *argv[])
 {
@@ -453,7 +453,7 @@ decode_port_action_value(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of port for port command */
+/* decoding procedure of port for port command. */
 static int
 decode_port_port_value(void *output, const char *arg_val, int allow_override)
 {
@@ -894,11 +894,11 @@ parameter_list[][SPP_CMD_MAX_PARAMETERS] = {
 	{ DECODE_PARAMETER_LIST_EMPTY }, /* termination      */
 };
 
-/* check by list for each command line parameter component */
+/* Validate given command. */
 static int
 decode_command_parameter_component(struct spp_command_request *request,
 				int argc, char *argv[],
-				struct sppwk_parse_err_msg *error,
+				struct sppwk_parse_err_msg *wk_err_msg,
 				int maxargc __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
@@ -912,34 +912,34 @@ decode_command_parameter_component(struct spp_command_request *request,
 				argv[pi], 0);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Bad value. command=%s, name=%s, "
+					"Invalid value. command=%s, name=%s, "
 					"index=%d, value=%s\n",
 					argv[0], list->name, pi, argv[pi]);
-			return set_string_value_decode_error(error, argv[pi],
-					list->name);
+			return set_string_value_decode_error(wk_err_msg,
+					argv[pi], list->name);
 		}
 	}
 	return SPP_RET_OK;
 }
 
-/* check by list for each command line parameter clssfier_table */
+/* Validate given command for clssfier_table. */
 static int
 decode_command_parameter_cls_table(struct spp_command_request *request,
 				int argc, char *argv[],
-				struct sppwk_parse_err_msg *error,
+				struct sppwk_parse_err_msg *wk_err_msg,
 				int maxargc)
 {
 	return decode_command_parameter_component(request,
 						argc,
 						argv,
-						error,
+						wk_err_msg,
 						maxargc);
 }
-/* check by list for each command line parameter clssfier_table(vlan) */
+/* Validate given command for clssfier_table of vlan. */
 static int
 decode_command_parameter_cls_table_vlan(struct spp_command_request *request,
 				int argc, char *argv[],
-				struct sppwk_parse_err_msg *error,
+				struct sppwk_parse_err_msg *wk_err_msg,
 				int maxargc __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
@@ -955,18 +955,18 @@ decode_command_parameter_cls_table_vlan(struct spp_command_request *request,
 			RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad value. "
 				"command=%s, name=%s, index=%d, value=%s\n",
 					argv[0], list->name, pi, argv[pi]);
-			return set_string_value_decode_error(error, argv[pi],
-				list->name);
+			return set_string_value_decode_error(wk_err_msg,
+					argv[pi], list->name);
 		}
 	}
 	return SPP_RET_OK;
 }
 
-/* check by list for each command line parameter port */
+/* Validate given command for port. */
 static int
 decode_command_parameter_port(struct spp_command_request *request,
 				int argc, char *argv[],
-				struct sppwk_parse_err_msg *error,
+				struct sppwk_parse_err_msg *wk_err_msg,
 				int maxargc)
 {
 	int ret = SPP_RET_OK;
@@ -988,8 +988,8 @@ decode_command_parameter_port(struct spp_command_request *request,
 			RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad value. "
 				"command=%s, name=%s, index=%d, value=%s\n",
 					argv[0], list->name, pi, argv[pi]);
-			return set_string_value_decode_error(error, argv[pi],
-				list->name);
+			return set_string_value_decode_error(wk_err_msg,
+					argv[pi], list->name);
 		}
 	}
 	return SPP_RET_OK;
@@ -1001,7 +1001,7 @@ struct decode_command_list {
 	int   param_min;        /* Min number of parameters */
 	int   param_max;        /* Max number of parameters */
 	int (*func)(struct spp_command_request *request, int argc,
-			char *argv[], struct sppwk_parse_err_msg *error,
+			char *argv[], struct sppwk_parse_err_msg *wk_err_msg,
 			int maxargc);
 				/* Pointer to command handling function */
 };
@@ -1024,11 +1024,11 @@ static struct decode_command_list command_list[] = {
 	{ "",				 0, 0, NULL }  /* termination     */
 };
 
-/* Decode command line parameters */
+/* Parse command line parameters. */
 static int
 decode_command_in_list(struct spp_command_request *request,
 			const char *request_str,
-			struct sppwk_parse_err_msg *error)
+			struct sppwk_parse_err_msg *wk_err_msg)
 {
 	int ret = SPP_RET_OK;
 	int command_name_check = 0;
@@ -1046,7 +1046,8 @@ decode_command_in_list(struct spp_command_request *request,
 	if (ret < SPP_RET_OK) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Parameter number over limit."
 				"request_str=%s\n", request_str);
-		return set_parse_error(error, SPPWK_PARSE_WRONG_FORMAT, NULL);
+		return set_parse_error(wk_err_msg, SPPWK_PARSE_WRONG_FORMAT,
+				NULL);
 	}
 	RTE_LOG(DEBUG, SPP_COMMAND_PROC, "Decode array. num=%d\n", argc);
 
@@ -1063,7 +1064,7 @@ decode_command_in_list(struct spp_command_request *request,
 
 		request->commands[0].type = i;
 		if (list->func != NULL)
-			return (*list->func)(request, argc, argv, error,
+			return (*list->func)(request, argc, argv, wk_err_msg,
 							list->param_max);
 
 		return SPP_RET_OK;
@@ -1072,13 +1073,14 @@ decode_command_in_list(struct spp_command_request *request,
 	if (command_name_check != 0) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Parameter number out of range."
 				"request_str=%s\n", request_str);
-		return set_parse_error(error, SPPWK_PARSE_WRONG_FORMAT, NULL);
+		return set_parse_error(wk_err_msg, SPPWK_PARSE_WRONG_FORMAT,
+				NULL);
 	}
 
 	RTE_LOG(ERR, SPP_COMMAND_PROC,
 			"Unknown command. command=%s, request_str=%s\n",
 			argv[0], request_str);
-	return set_string_value_decode_error(error, argv[0], "command");
+	return set_string_value_decode_error(wk_err_msg, argv[0], "command");
 }
 
 /* decode request from no-null-terminated string */
@@ -1086,14 +1088,14 @@ int
 spp_command_decode_request(
 		struct spp_command_request *request,
 		const char *request_str, size_t request_str_len,
-		struct sppwk_parse_err_msg *error)
+		struct sppwk_parse_err_msg *wk_err_msg)
 {
 	int ret = SPP_RET_NG;
 	int i;
 
 	/* decode request */
 	request->num_command = 1;
-	ret = decode_command_in_list(request, request_str, error);
+	ret = decode_command_in_list(request, request_str, wk_err_msg);
 	if (unlikely(ret != SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Cannot decode command request. "
diff --git a/src/shared/secondary/spp_worker_th/command_dec.h b/src/shared/secondary/spp_worker_th/command_dec.h
deleted file mode 100644
index 7da562a..0000000
--- a/src/shared/secondary/spp_worker_th/command_dec.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
- */
-
-#ifndef _COMMAND_DEC_H_
-#define _COMMAND_DEC_H_
-
-/**
- * @file
- * SPP command decode
- *
- * Decode and validate the command message string.
- */
-
-#include "spp_proc.h"
-
-/** max number of command per request */
-#define SPP_CMD_MAX_COMMANDS 32
-
-/** maximum number of parameters per command */
-#define SPP_CMD_MAX_PARAMETERS 8
-
-/** command name string buffer size (include null char) */
-#define SPP_CMD_NAME_BUFSZ  32
-
-/** command value string buffer size (include null char) */
-#define SPP_CMD_VALUE_BUFSZ 111
-
-/** string that specify unused */
-#define SPP_CMD_UNUSE "unuse"
-
-/**
- * Error code for diagnosis and notifying the reason. It starts from 1 because
- * 0 is used for succeeded and not appropriate for error in general.
- */
-enum sppwk_parse_error_code {
-	SPPWK_PARSE_WRONG_FORMAT = 1,  /**< Wrong format */
-	SPPWK_PARSE_UNKNOWN_CMD,  /**< Unknown command */
-	SPPWK_PARSE_NO_PARAM,  /**< No parameters */
-	SPPWK_PARSE_INVALID_TYPE,  /**< Invalid data type */
-	SPPWK_PARSE_INVALID_VALUE,  /**< Invalid value */
-};
-
-/**
- * Define actions of each of components
- *  The Run option of the folllwing commands.
- *   compomnent       : start,stop
- *   port             : add,del
- *   classifier_table : add,del
- */
-enum spp_command_action {
-	SPP_CMD_ACTION_NONE,  /**< none */
-	SPP_CMD_ACTION_START, /**< start */
-	SPP_CMD_ACTION_STOP,  /**< stop */
-	SPP_CMD_ACTION_ADD,   /**< add */
-	SPP_CMD_ACTION_DEL,   /**< delete */
-};
-
-/**
- * spp command type.
- *
- * @attention This enumerated type must have the same order of command_list
- *            defined in command_dec.c
- */
-enum spp_command_type {
-	/** classifier_table command(mac) */
-	SPP_CMDTYPE_CLASSIFIER_TABLE_MAC,
-
-	/** classifier_table command(VLAN) */
-	SPP_CMDTYPE_CLASSIFIER_TABLE_VLAN,
-
-	/** get_client_id command */
-	SPP_CMDTYPE_CLIENT_ID,
-
-	/** status command */
-	SPP_CMDTYPE_STATUS,
-
-	/** exit command */
-	SPP_CMDTYPE_EXIT,
-
-	/** component command */
-	SPP_CMDTYPE_COMPONENT,
-
-	/** port command */
-	SPP_CMDTYPE_PORT,
-};
-
-/** "classifier_table" command specific parameters */
-struct spp_command_classifier_table {
-	/** Action identifier (add or del) */
-	enum spp_command_action action;
-
-	/** Classify type (currently only for mac) */
-	enum spp_classifier_type type;
-
-	/** VLAN ID to be classified */
-	int vid;
-
-	/** MAC address to be classified */
-	char mac[SPP_CMD_VALUE_BUFSZ];
-
-	/** Destination port type and number */
-	struct spp_port_index port;
-};
-
-/* "flush" command specific parameters */
-struct spp_command_flush {
-	/* nothing specific */
-};
-
-/** "component" command parameters */
-struct spp_command_component {
-	/** Action identifier (start or stop) */
-	enum spp_command_action action;
-
-	/** Component name */
-	char name[SPP_CMD_NAME_BUFSZ];
-
-	/** Logical core number */
-	unsigned int core;
-
-	/** Component type */
-	enum spp_component_type type;
-};
-
-/** "port" command parameters */
-struct spp_command_port {
-	/** Action identifier (add or del) */
-	enum spp_command_action action;
-
-	/** Port type and number */
-	struct spp_port_index port;
-
-	/** rx/tx identifier */
-	enum spp_port_rxtx rxtx;
-
-	/** Attached component name */
-	char name[SPP_CMD_NAME_BUFSZ];
-
-	/** Port ability */
-	struct spp_port_ability ability;
-};
-
-/** command parameters */
-struct spp_command {
-	enum spp_command_type type; /**< Command type */
-
-	union {
-		/** Structured data for classifier_table command  */
-		struct spp_command_classifier_table classifier_table;
-
-		/** Structured data for flush command  */
-		struct spp_command_flush flush;
-
-		/** Structured data for component command  */
-		struct spp_command_component component;
-
-		/** Structured data for port command  */
-		struct spp_command_port port;
-	} spec;
-};
-
-/** request parameters */
-struct spp_command_request {
-	int num_command;                /**< Number of accepted commands */
-	int num_valid_command;          /**< Number of executed commands */
-	struct spp_command commands[SPP_CMD_MAX_COMMANDS];
-					/**<Information of executed commands */
-
-	int is_requested_client_id;     /**< Id for get_client_id command */
-	int is_requested_status;        /**< Id for status command */
-	int is_requested_exit;          /**< Id for exit command */
-};
-
-/** decode error information */
-struct sppwk_parse_err_msg {
-	int code;                            /**< Error code */
-	char value_name[SPP_CMD_NAME_BUFSZ]; /**< Error value name */
-	char value[SPP_CMD_VALUE_BUFSZ];     /**< Error value */
-};
-
-/**
- * decode request from no-null-terminated string
- *
- * @param request
- *  The pointer to struct spp_command_request.@n
- *  The result value of decoding the command message.
- * @param request_str
- *  The pointer to requested command message.
- * @param request_str_len
- *  The length of requested command message.
- * @param error
- *  The pointer to struct sppwk_parse_err_msg.@n
- *  Detailed error information will be stored.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval !0 failed.
- */
-int spp_command_decode_request(struct spp_command_request *request,
-		const char *request_str, size_t request_str_len,
-		struct sppwk_parse_err_msg *err_msg);
-
-#endif /* _COMMAND_DEC_H_ */
diff --git a/src/shared/secondary/spp_worker_th/command_proc.c b/src/shared/secondary/spp_worker_th/command_proc.c
index 2911266..38cc45f 100644
--- a/src/shared/secondary/spp_worker_th/command_proc.c
+++ b/src/shared/secondary/spp_worker_th/command_proc.c
@@ -14,7 +14,7 @@
 #include "string_buffer.h"
 
 #include "command_conn.h"
-#include "command_dec.h"
+#include "cmd_parser.h"
 #include "command_proc.h"
 
 #define RTE_LOGTYPE_SPP_COMMAND_PROC RTE_LOGTYPE_USER1
@@ -802,7 +802,7 @@ execute_command(const struct spp_command *command)
 	return ret;
 }
 
-/* make decode error message for response */
+/* Fill err_msg obj with given error message. */
 static const char *
 make_decode_error_message(
 		const struct sppwk_parse_err_msg *err_msg,
@@ -815,21 +815,21 @@ make_decode_error_message(
 
 	case SPPWK_PARSE_UNKNOWN_CMD:
 		/* TODO(yasufum) Fix compile err if space exists before "(" */
-		sprintf(message, "Unknown command(%s)", err_msg->value);
+		sprintf(message, "Unknown command(%s)", err_msg->details);
 		break;
 
 	case SPPWK_PARSE_NO_PARAM:
 		sprintf(message, "No or insufficient number of params (%s)",
-				err_msg->value_name);
+				err_msg->msg);
 		break;
 
 	case SPPWK_PARSE_INVALID_TYPE:
 		sprintf(message, "Invalid value type (%s)",
-				err_msg->value_name);
+				err_msg->msg);
 		break;
 
 	case SPPWK_PARSE_INVALID_VALUE:
-		sprintf(message, "Invalid value (%s)", err_msg->value_name);
+		sprintf(message, "Invalid value (%s)", err_msg->msg);
 		break;
 
 	default:
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index b2acb58..9831058 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -11,7 +11,7 @@
 #include "classifier_mac.h"
 #include "spp_forward.h"
 #include "shared/secondary/spp_worker_th/command_proc.h"
-#include "shared/secondary/spp_worker_th/command_dec.h"
+#include "shared/secondary/spp_worker_th/cmd_parser.h"
 #include "shared/secondary/spp_worker_th/spp_port.h"
 
 /* Declare global variables */
-- 
2.17.1


  parent reply	other threads:[~2019-05-08  2:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08  2:01 [spp] [PATCH 00/17] Refactor command " ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 01/17] shared/sec: change prefix of common functions ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 02/17] shared/sec: refactor parse error code ogawa.yasufumi
2019-05-08  2:01 ` ogawa.yasufumi [this message]
2019-05-08  2:01 ` [spp] [PATCH 04/17] shared/sec: refactor branching for cmd action ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 05/17] shared/sec: rename define starts from SPP_CMD_MAX ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 06/17] shared/sec: rename define of buffer size for cmds ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 07/17] shared/sec: remove unused define of cmd parser ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 08/17] shared/sec: refactor commad type of SPP worker ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 09/17] shared/sec: change struct of classier table attrs ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 10/17] shared/sec: refactor function parsing cls port ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 11/17] shared/sec: rename func of flush command ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 12/17] shared/sec: change struct of comp command ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 13/17] shared/sec: revise port info of SPP worker ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 14/17] shared/sec: rename func for getting port ID ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 15/17] shared/sec: rename dpdk_port attr ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 16/17] shared/sec: rename struct for command request ogawa.yasufumi
2019-05-08  2:01 ` [spp] [PATCH 17/17] shared/sec: rename func for parsing request ogawa.yasufumi

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=1557280895-7978-4-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --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).