Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH] shared/sec: rename enum spp_classifier_type
@ 2019-06-26  5:36 yasufum.o
  0 siblings, 0 replies; only message in thread
From: yasufum.o @ 2019-06-26  5:36 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

From: Yasufumi Ogawa <yasufum.o@gmail.com>

This update is to refactor the name of enum `spp_classifier_type` and
its members to be more specific and short.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/shared/secondary/spp_worker_th/cmd_parser.c |  6 +++---
 src/shared/secondary/spp_worker_th/cmd_parser.h |  2 +-
 src/shared/secondary/spp_worker_th/cmd_utils.c  |  2 +-
 src/shared/secondary/spp_worker_th/cmd_utils.h  | 10 +++++-----
 src/shared/secondary/spp_worker_th/vf_deps.h    |  2 +-
 src/vf/classifier_mac.c                         | 14 +++++++-------
 src/vf/vf_cmd_runner.c                          | 17 ++++++++---------
 7 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index cd79bdb..931c53b 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -728,7 +728,7 @@ parse_cls_port(void *cls_cmd_attr, const char *arg_val,
 		return SPP_RET_NG;
 	}
 
-	if (cls_attrs->type == SPP_CLASSIFIER_TYPE_MAC)
+	if (cls_attrs->cls_type == SPPWK_CLS_TYPE_MAC)
 		cls_attrs->vid = ETH_VLAN_ID_MAX;
 
 	if (unlikely(cls_attrs->wk_action == SPPWK_ACT_ADD)) {
@@ -783,7 +783,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "type",
 			.offset = offsetof(struct sppwk_cmd_attrs,
-					spec.cls_table.type),
+					spec.cls_table.cls_type),
 			.func = parse_cls_type
 		},
 		{
@@ -810,7 +810,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "type",
 			.offset = offsetof(struct sppwk_cmd_attrs,
-					spec.cls_table.type),
+					spec.cls_table.cls_type),
 			.func = parse_cls_type
 		},
 		{
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.h b/src/shared/secondary/spp_worker_th/cmd_parser.h
index d50e3a6..b124dc1 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.h
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.h
@@ -80,7 +80,7 @@ const char *sppwk_cmd_type_str(enum sppwk_cmd_type ctype);
 /* `classifier_table` command specific parameters. */
 struct sppwk_cls_cmd_attrs {
 	enum sppwk_action wk_action;  /**< add or del */
-	enum spp_classifier_type type;  /**< currently only for mac */
+	enum sppwk_cls_type cls_type;  /**< currently only for MAC. */
 	int vid;  /**< VLAN ID  */
 	char mac[SPPWK_VAL_BUFSZ];  /**< MAC address  */
 	struct sppwk_port_idx port;/**< Destination port type and number */
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 6f93400..6072186 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -69,7 +69,7 @@ log_hexdumped(const char *obj_name, const void *obj_addr, const size_t size)
 	}
 }
 
-/* Get core status */
+/* Get status of lcore of given ID. */
 enum sppwk_lcore_status
 spp_get_core_status(unsigned int lcore_id)
 {
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index 87c9b2c..a935312 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -93,10 +93,10 @@ enum sppwk_worker_type {
 };
 
 /* Classifier Type */
-enum spp_classifier_type {
-	SPP_CLASSIFIER_TYPE_NONE, /**< Type none */
-	SPP_CLASSIFIER_TYPE_MAC,  /**< MAC address */
-	SPP_CLASSIFIER_TYPE_VLAN  /**< VLAN ID */
+enum sppwk_cls_type {
+	SPPWK_CLS_TYPE_NONE,
+	SPPWK_CLS_TYPE_MAC,
+	SPPWK_CLS_TYPE_VLAN
 };
 
 /* Direction of RX or TX on a port. */
@@ -258,7 +258,7 @@ struct spp_iterate_classifier_table_params;
  */
 typedef int (*spp_iterate_classifier_element_proc)(
 		struct spp_iterate_classifier_table_params *params,
-		enum spp_classifier_type type,
+		enum sppwk_cls_type cls_type,
 		int vid, const char *mac,
 		const struct sppwk_port_idx *port);
 
diff --git a/src/shared/secondary/spp_worker_th/vf_deps.h b/src/shared/secondary/spp_worker_th/vf_deps.h
index fd3c201..83ddf09 100644
--- a/src/shared/secondary/spp_worker_th/vf_deps.h
+++ b/src/shared/secondary/spp_worker_th/vf_deps.h
@@ -108,7 +108,7 @@ int update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp);
 
 int append_classifier_element_value(
 		struct spp_iterate_classifier_table_params *params,
-		enum spp_classifier_type type,
+		enum sppwk_cls_type cls_type,
 		int vid, const char *mac,
 		const struct sppwk_port_idx *port);
 
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index c7873e3..9c4bedf 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -878,11 +878,11 @@ iterate_adding_mac_entry(
 	uint32_t next;
 	struct sppwk_port_idx port;
 	char mac_addr_str[ETHER_ADDR_STR_BUF_SZ];
-	enum spp_classifier_type type;
+	enum sppwk_cls_type cls_type;
 
-	type = SPP_CLASSIFIER_TYPE_VLAN;
+	cls_type = SPPWK_CLS_TYPE_VLAN;
 	if (unlikely(vid == VLAN_UNTAGGED_VID))
-		type = SPP_CLASSIFIER_TYPE_MAC;
+		cls_type = SPPWK_CLS_TYPE_MAC;
 
 	if (mac_cls->default_cls_idx >= 0) {
 		port.iface_type = (port_info +
@@ -897,8 +897,8 @@ iterate_adding_mac_entry(
 		 * Append "default" entry. `element_proc` is a funciton
 		 * pointer to append_classifier_element_value().
 		 */
-		(*params->element_proc)(params, type, vid, SPPWK_TERM_DEFAULT,
-				&port);
+		(*params->element_proc)(params, cls_type, vid,
+				SPPWK_TERM_DEFAULT, &port);
 	}
 
 	next = 0;
@@ -920,8 +920,8 @@ iterate_adding_mac_entry(
 		 * Append each entry of MAC address. `element_proc` is a
 		 * funciton pointer to append_classifier_element_value().
 		 */
-		(*params->element_proc)(params, type, vid, mac_addr_str,
-				&port);
+		(*params->element_proc)(params, cls_type, vid,
+				mac_addr_str, &port);
 	}
 }
 
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index f5854b0..b28d8a6 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -28,7 +28,7 @@ const char *CLS_TYPE_A_LIST[] = {
 /* Update classifier table with given action, add or del. */
 static int
 update_cls_table(enum sppwk_action wk_action,
-		enum spp_classifier_type type __attribute__ ((unused)),
+		enum sppwk_cls_type cls_type __attribute__ ((unused)),
 		int vid, const char *mac_str,
 		const struct sppwk_port_idx *port)
 {
@@ -383,7 +383,7 @@ exec_one_cmd(const struct sppwk_cmd_attrs *cmd)
 	case SPPWK_CMDTYPE_CLS_MAC:
 	case SPPWK_CMDTYPE_CLS_VLAN:
 		ret = update_cls_table(cmd->spec.cls_table.wk_action,
-				cmd->spec.cls_table.type,
+				cmd->spec.cls_table.cls_type,
 				cmd->spec.cls_table.vid,
 				cmd->spec.cls_table.mac,
 				&cmd->spec.cls_table.port);
@@ -555,7 +555,7 @@ update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp)
 int
 append_classifier_element_value(
 		struct spp_iterate_classifier_table_params *params,
-		enum spp_classifier_type type,
+		enum sppwk_cls_type cls_type,
 		int vid, const char *mac,
 		const struct sppwk_port_idx *port)
 {
@@ -567,23 +567,22 @@ append_classifier_element_value(
 	tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
 	if (unlikely(tmp_buff == NULL)) {
 		RTE_LOG(ERR, VF_CMD_RUNNER,
-				/* TODO(yasufum) refactor no meaning err msg */
-				"allocate error. (name = classifier_table)\n");
+				"Failed to allocate buffer.\n");
 		return ret;
 	}
 
 	spp_format_port_string(port_str, port->iface_type, port->iface_no);
 
-	ret = append_json_str_value(&tmp_buff, "type", CLS_TYPE_A_LIST[type]);
+	ret = append_json_str_value(&tmp_buff, "type", CLS_TYPE_A_LIST[cls_type]);
 	if (unlikely(ret < SPP_RET_OK))
 		return ret;
 
 	memset(value_str, 0x00, STR_LEN_SHORT);
-	switch (type) {
-	case SPP_CLASSIFIER_TYPE_MAC:
+	switch (cls_type) {
+	case SPPWK_CLS_TYPE_MAC:
 		sprintf(value_str, "%s", mac);
 		break;
-	case SPP_CLASSIFIER_TYPE_VLAN:
+	case SPPWK_CLS_TYPE_VLAN:
 		sprintf(value_str, "%d/%s", vid, mac);
 		break;
 	default:
-- 
2.17.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26  5:36 [spp] [PATCH] shared/sec: rename enum spp_classifier_type yasufum.o

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox