Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH 0/3] Rename spp_port_rxtx
@ 2019-06-24  8:40 yasufum.o
  2019-06-24  8:40 ` [spp] [PATCH 1/3] shared/sec: revise enum spp_port_rxtx yasufum.o
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: yasufum.o @ 2019-06-24  8:40 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

Enum `spp_port_rxtx` is used as a port attribute to have a direction,
RX or TX. It is not used to have a set of RX and TX, but defines the
direction. So, It is better to be named as `port_dir` or so. This series
of patches is to rename this enum for spp_vf, spp_mirror and spp_pcap.

Yasufumi Ogawa (3):
  shared/sec: revise enum spp_port_rxtx
  shared/sec: rename members of enum sppwk_port_dir
  spp_pcap: revise enum spp_port_rxtx

 src/mirror/mir_cmd_runner.c                   | 24 +++++------
 src/pcap/cmd_runner.c                         |  8 ++--
 src/pcap/cmd_utils.h                          | 17 ++++----
 .../secondary/spp_worker_th/cmd_parser.c      | 18 ++++-----
 .../secondary/spp_worker_th/cmd_parser.h      |  4 +-
 .../spp_worker_th/cmd_res_formatter.c         | 16 ++++----
 .../spp_worker_th/cmd_res_formatter.h         |  6 +--
 .../secondary/spp_worker_th/cmd_utils.c       | 17 ++++----
 .../secondary/spp_worker_th/cmd_utils.h       | 27 ++++++-------
 src/shared/secondary/spp_worker_th/spp_port.c | 40 +++++++++----------
 src/shared/secondary/spp_worker_th/spp_port.h |  4 +-
 src/vf/vf_cmd_runner.c                        | 32 +++++++--------
 12 files changed, 104 insertions(+), 109 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 1/3] shared/sec: revise enum spp_port_rxtx
  2019-06-24  8:40 [spp] [PATCH 0/3] Rename spp_port_rxtx yasufum.o
@ 2019-06-24  8:40 ` yasufum.o
  2019-06-24  8:40 ` [spp] [PATCH 2/3] shared/sec: rename members of enum sppwk_port_dir yasufum.o
  2019-06-24  8:40 ` [spp] [PATCH 3/3] spp_pcap: revise enum spp_port_rxtx yasufum.o
  2 siblings, 0 replies; 4+ messages in thread
From: yasufum.o @ 2019-06-24  8:40 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

This update is to revise the name of enum `spp_port_rxtx` to
`sppwk_port_dir` because it is used to specify which of direction
packets are forwarded on a port. Term `rxtx` is used for a set of RX and
TX, so it should not be used for specifying the direction. This update
is also rename a member of structs using this enum from `rxtx` to `dir`.

Some error are occured while compiling spp_pcap for this update. It is
fixed by next pathces.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/mirror/mir_cmd_runner.c                   | 24 +++++++--------
 .../secondary/spp_worker_th/cmd_parser.c      | 14 ++++-----
 .../secondary/spp_worker_th/cmd_parser.h      |  4 +--
 .../spp_worker_th/cmd_res_formatter.c         | 12 ++++----
 .../spp_worker_th/cmd_res_formatter.h         |  6 ++--
 .../secondary/spp_worker_th/cmd_utils.c       | 13 ++++----
 .../secondary/spp_worker_th/cmd_utils.h       | 19 +++++-------
 src/shared/secondary/spp_worker_th/spp_port.c | 20 ++++++-------
 src/shared/secondary/spp_worker_th/spp_port.h |  4 +--
 src/vf/vf_cmd_runner.c                        | 30 +++++++++----------
 10 files changed, 72 insertions(+), 74 deletions(-)

diff --git a/src/mirror/mir_cmd_runner.c b/src/mirror/mir_cmd_runner.c
index a4ca397..eda4d1a 100644
--- a/src/mirror/mir_cmd_runner.c
+++ b/src/mirror/mir_cmd_runner.c
@@ -107,19 +107,19 @@ update_comp(enum sppwk_action wk_action, const char *name,
 
 /* Check if over the maximum num of rx and tx ports of component. */
 static int
-check_mir_port_count(enum spp_port_rxtx rxtx, int num_rx, int num_tx)
+check_mir_port_count(enum sppwk_port_dir dir, int nof_rx, int nof_tx)
 {
 	RTE_LOG(INFO, MIR_CMD_RUNNER, "port count, port_type=%d,"
-				" rx=%d, tx=%d\n", rxtx, num_rx, num_tx);
-	if (rxtx == SPP_PORT_RXTX_RX)
-		num_rx++;
+				" rx=%d, tx=%d\n", dir, nof_rx, nof_tx);
+	if (dir == SPP_PORT_RXTX_RX)
+		nof_rx++;
 	else
-		num_tx++;
+		nof_tx++;
 	/* Add rx or tx port appointed in port_type. */
 	RTE_LOG(INFO, MIR_CMD_RUNNER, "Num of ports after count up,"
 				" port_type=%d, rx=%d, tx=%d\n",
-				rxtx, num_rx, num_tx);
-	if (num_rx > 1 || num_tx > 2)
+				dir, nof_rx, nof_tx);
+	if (nof_rx > 1 || nof_tx > 2)
 		return SPP_RET_NG;
 
 	return SPP_RET_OK;
@@ -129,7 +129,7 @@ check_mir_port_count(enum spp_port_rxtx rxtx, int num_rx, int num_tx)
 static int
 update_port(enum sppwk_action wk_action,
 		const struct sppwk_port_idx *port,
-		enum spp_port_rxtx rxtx,
+		enum sppwk_port_dir dir,
 		const char *name,
 		const struct spp_port_ability *ability)
 {
@@ -155,7 +155,7 @@ update_port(enum sppwk_action wk_action,
 			&comp_info_base, NULL, NULL, &change_component, NULL);
 	comp_info = (comp_info_base + comp_lcore_id);
 	port_info = get_sppwk_port(port->iface_type, port->iface_no);
-	if (rxtx == SPP_PORT_RXTX_RX) {
+	if (dir == SPP_PORT_RXTX_RX) {
 		nof_ports = &comp_info->nof_rx;
 		ports = comp_info->rx_ports;
 	} else {
@@ -166,7 +166,7 @@ update_port(enum sppwk_action wk_action,
 	switch (wk_action) {
 	case SPPWK_ACT_ADD:
 		/* Check if over the maximum num of ports of component. */
-		if (check_mir_port_count(rxtx, comp_info->nof_rx,
+		if (check_mir_port_count(dir, comp_info->nof_rx,
 				comp_info->nof_tx) != SPP_RET_OK)
 			return SPP_RET_NG;
 
@@ -228,7 +228,7 @@ update_port(enum sppwk_action wk_action,
 					SPPWK_PORT_ABL_OPS_NONE)
 				continue;
 
-			if (port_info->ability[cnt].rxtx == rxtx)
+			if (port_info->ability[cnt].dir == dir)
 				memset(&port_info->ability[cnt], 0x00,
 					sizeof(struct spp_port_ability));
 		}
@@ -274,7 +274,7 @@ exec_one_cmd(const struct sppwk_cmd_attrs *cmd)
 		RTE_LOG(INFO, MIR_CMD_RUNNER, "with action `%s`.\n",
 				sppwk_action_str(cmd->spec.port.wk_action));
 		ret = update_port(cmd->spec.port.wk_action,
-				&cmd->spec.port.port, cmd->spec.port.rxtx,
+				&cmd->spec.port.port, cmd->spec.port.dir,
 				cmd->spec.port.name, &cmd->spec.port.ability);
 		if (ret == 0) {
 			RTE_LOG(INFO, MIR_CMD_RUNNER, "Exec flush.\n");
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 5a2fb82..c1b311c 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -480,14 +480,14 @@ parse_port(void *output, const char *arg_val, int allow_override)
 
 /* Parse port rx and tx value. */
 static int
-parse_port_rxtx(void *output, const char *arg_val, int allow_override)
+parse_port_direction(void *output, const char *arg_val, int allow_override)
 {
-	int ret = SPP_RET_OK;
+	int ret;
 	struct sppwk_cmd_port *port = output;
 
 	ret = get_list_idx(arg_val, PORT_DIR_LIST);
 	if (unlikely(ret <= 0)) {
-		RTE_LOG(ERR, WK_CMD_PARSER, "Unknown port rxtx. val=%s\n",
+		RTE_LOG(ERR, WK_CMD_PARSER, "Unknown port direction. val=%s\n",
 				arg_val);
 		return SPP_RET_NG;
 	}
@@ -504,7 +504,7 @@ parse_port_rxtx(void *output, const char *arg_val, int allow_override)
 		}
 	}
 
-	port->rxtx = ret;
+	port->dir = ret;
 	return SPP_RET_OK;
 }
 
@@ -551,8 +551,8 @@ parse_port_vlan_ops(void *output, const char *arg_val,
 					arg_val);
 			return SPP_RET_NG;
 		}
-		ability->ops  = ret;
-		ability->rxtx = port->rxtx;
+		ability->ops = ret;
+		ability->dir = port->dir;
 		break;
 	case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
 		/* Nothing to do. */
@@ -875,7 +875,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "port rxtx",
 			.offset = offsetof(struct sppwk_cmd_attrs, spec.port),
-			.func = parse_port_rxtx
+			.func = parse_port_direction
 		},
 		{
 			.name = "component name",
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.h b/src/shared/secondary/spp_worker_th/cmd_parser.h
index 1018444..d50e3a6 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.h
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.h
@@ -102,8 +102,8 @@ struct sppwk_cmd_comp {
 /* `port` command parameters. */
 struct sppwk_cmd_port {
 	enum sppwk_action wk_action;  /**< add or del */
-	struct sppwk_port_idx port;  /**< port type and number */
-	enum spp_port_rxtx rxtx;  /**< rx or tx identifier */
+	struct sppwk_port_idx port;   /**< port type and number */
+	enum sppwk_port_dir dir;  /**< Direction of RX, TX or both. */
 	char name[SPPWK_NAME_BUFSZ];  /**<  component name */
 	struct spp_port_ability ability;  /**< port ability */
 };
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
index fdc8675..a174890 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -164,7 +164,7 @@ append_vlan_value(char **output, const int ope, const int vid, const int pcp)
 /* append a block of vlan for JSON format */
 int
 append_vlan_block(const char *name, char **output,
-		const int port_id, const enum spp_port_rxtx rxtx)
+		const int port_id, const enum sppwk_port_dir dir)
 {
 	int ret = SPP_RET_NG;
 	int i = 0;
@@ -178,7 +178,7 @@ append_vlan_block(const char *name, char **output,
 		return SPP_RET_NG;
 	}
 
-	spp_port_ability_get_info(port_id, rxtx, &info);
+	spp_port_ability_get_info(port_id, dir, &info);
 	for (i = 0; i < SPP_PORT_ABILITY_MAX; i++) {
 		switch (info[i].ops) {
 		case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
@@ -239,7 +239,7 @@ get_ethdev_port_id(enum port_type iface_type, int iface_no)
 /* append a block of port numbers for JSON format */
 int
 append_port_block(char **output, const struct sppwk_port_idx *port,
-		const enum spp_port_rxtx rxtx)
+		const enum sppwk_port_dir dir)
 {
 	int ret = SPP_RET_NG;
 	char port_str[CMD_TAG_APPEND_SIZE];
@@ -259,7 +259,7 @@ append_port_block(char **output, const struct sppwk_port_idx *port,
 	ret = append_vlan_block("vlan", &tmp_buff,
 			get_ethdev_port_id(
 				port->iface_type, port->iface_no),
-			rxtx);
+			dir);
 	if (unlikely(ret < SPP_RET_OK))
 		return SPP_RET_NG;
 
@@ -272,7 +272,7 @@ append_port_block(char **output, const struct sppwk_port_idx *port,
 int
 append_port_array(const char *name, char **output, const int num,
 		const struct sppwk_port_idx *ports,
-		const enum spp_port_rxtx rxtx)
+		const enum sppwk_port_dir dir)
 {
 	int ret = SPP_RET_NG;
 	int i = 0;
@@ -286,7 +286,7 @@ append_port_array(const char *name, char **output, const int num,
 	}
 
 	for (i = 0; i < num; i++) {
-		ret = append_port_block(&tmp_buff, &ports[i], rxtx);
+		ret = append_port_block(&tmp_buff, &ports[i], dir);
 		if (unlikely(ret < SPP_RET_OK))
 			return SPP_RET_NG;
 	}
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 d304e4f..66eabb5 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
@@ -40,14 +40,14 @@ int append_vlan_value(char **output, const int ope, const int vid,
 		const int pcp);
 
 int append_vlan_block(const char *name, char **output,
-		const int port_id, const enum spp_port_rxtx rxtx);
+		const int port_id, const enum sppwk_port_dir dir);
 
 int append_port_block(char **output, const struct sppwk_port_idx *port,
-		const enum spp_port_rxtx rxtx);
+		const enum sppwk_port_dir dir);
 
 int append_port_array(const char *name, char **output, const int num,
 		const struct sppwk_port_idx *ports,
-		const enum spp_port_rxtx rxtx);
+		const enum sppwk_port_dir dir);
 
 int append_core_element_value(struct spp_iterate_core_params *params,
 		const unsigned int lcore_id,
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index e61f59c..4f80b2e 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -661,7 +661,7 @@ int
 spp_check_used_port(
 		enum port_type iface_type,
 		int iface_no,
-		enum spp_port_rxtx rxtx)
+		enum sppwk_port_dir dir)
 {
 	int cnt, port_cnt, max = 0;
 	struct sppwk_comp_info *component = NULL;
@@ -678,10 +678,10 @@ spp_check_used_port(
 		if (component->wk_type == SPPWK_TYPE_NONE)
 			continue;
 
-		if (rxtx == SPP_PORT_RXTX_RX) {
+		if (dir == SPP_PORT_RXTX_RX) {
 			max = component->nof_rx;
 			port_array = component->rx_ports;
-		} else if (rxtx == SPP_PORT_RXTX_TX) {
+		} else if (dir == SPP_PORT_RXTX_TX) {
 			max = component->nof_tx;
 			port_array = component->tx_ports;
 		}
@@ -696,17 +696,18 @@ spp_check_used_port(
 
 /* Set component update flag for given port */
 void
-set_component_change_port(struct sppwk_port_info *port, enum spp_port_rxtx rxtx)
+set_component_change_port(struct sppwk_port_info *port,
+		enum sppwk_port_dir dir)
 {
 	int ret = 0;
-	if ((rxtx == SPP_PORT_RXTX_RX) || (rxtx == SPP_PORT_RXTX_ALL)) {
+	if ((dir == SPP_PORT_RXTX_RX) || (dir == SPP_PORT_RXTX_ALL)) {
 		ret = spp_check_used_port(port->iface_type, port->iface_no,
 				SPP_PORT_RXTX_RX);
 		if (ret >= 0)
 			*(g_mng_data.p_change_component + ret) = 1;
 	}
 
-	if ((rxtx == SPP_PORT_RXTX_TX) || (rxtx == SPP_PORT_RXTX_ALL)) {
+	if ((dir == SPP_PORT_RXTX_TX) || (dir == SPP_PORT_RXTX_ALL)) {
 		ret = spp_check_used_port(port->iface_type, port->iface_no,
 				SPP_PORT_RXTX_TX);
 		if (ret >= 0)
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index b0009c3..e08e4fb 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -95,11 +95,8 @@ enum spp_classifier_type {
 	SPP_CLASSIFIER_TYPE_VLAN  /**< VLAN ID */
 };
 
-/**
- * Port type (rx or tx) to indicate which direction packet goes
- * (e.g. receiving or transmitting)
- */
-enum spp_port_rxtx {
+/* Direction of RX or TX on a port. */
+enum sppwk_port_dir {
 	SPP_PORT_RXTX_NONE, /**< none */
 	SPP_PORT_RXTX_RX,   /**< rx port */
 	SPP_PORT_RXTX_TX,   /**< tx port */
@@ -155,9 +152,9 @@ union spp_ability_data {
 
 /* Port ability information. */
 struct spp_port_ability {
-	enum sppwk_port_abl_ops ops;  /**< Port ability Operations */
-	enum spp_port_rxtx rxtx;      /**< rx/tx identifier */
-	union spp_ability_data data;  /**< Port ability data */
+	enum sppwk_port_abl_ops ops;   /**< Port ability Operations */
+	enum sppwk_port_dir dir;  /**< Direction of RX, TX or both */
+	union spp_ability_data data;   /**< Port ability data */
 };
 
 /* Attributes for classifying. */
@@ -436,7 +433,7 @@ int spp_check_core_update(unsigned int lcore_id);
 int spp_check_used_port(
 		enum port_type iface_type,
 		int iface_no,
-		enum spp_port_rxtx rxtx);
+		enum sppwk_port_dir dir);
 
 /**
  * Set component update flag for given port.
@@ -448,8 +445,8 @@ int spp_check_used_port(
  *
  */
 void
-set_component_change_port(
-		struct sppwk_port_info *port, enum spp_port_rxtx rxtx);
+set_component_change_port(struct sppwk_port_info *port,
+		enum sppwk_port_dir dir);
 
 /**
  * Get ID of unused lcore.
diff --git a/src/shared/secondary/spp_worker_th/spp_port.c b/src/shared/secondary/spp_worker_th/spp_port.c
index 3163274..7ac6858 100644
--- a/src/shared/secondary/spp_worker_th/spp_port.c
+++ b/src/shared/secondary/spp_worker_th/spp_port.c
@@ -60,12 +60,12 @@ spp_port_ability_init(void)
 /* Get information of port ability. */
 void
 spp_port_ability_get_info(
-		int port_id, enum spp_port_rxtx rxtx,
+		int port_id, enum sppwk_port_dir dir,
 		struct spp_port_ability **info)
 {
 	struct port_ability_mng_info *mng = NULL;
 
-	switch (rxtx) {
+	switch (dir) {
 	case SPP_PORT_RXTX_RX:
 		mng = &g_port_mng_info[port_id].rx;
 		break;
@@ -202,7 +202,7 @@ del_vlantag_all_packets(
 void
 spp_port_ability_change_index(
 		enum port_ability_chg_index_type type,
-		int port_id, enum spp_port_rxtx rxtx)
+		int port_id, enum sppwk_port_dir dir)
 {
 	int cnt;
 	static int num_rx;
@@ -212,7 +212,7 @@ spp_port_ability_change_index(
 	struct port_ability_mng_info *mng = NULL;
 
 	if (type == PORT_ABILITY_CHG_INDEX_UPD) {
-		switch (rxtx) {
+		switch (dir) {
 		case SPP_PORT_RXTX_RX:
 			mng = &g_port_mng_info[port_id].rx;
 			mng->upd_index = mng->ref_index;
@@ -249,7 +249,7 @@ spp_port_ability_change_index(
 static void
 port_ability_set_ability(
 		struct sppwk_port_info *port,
-		enum spp_port_rxtx rxtx)
+		enum sppwk_port_dir dir)
 {
 	int in_cnt, out_cnt = 0;
 	int port_id = port->ethdev_port_id;
@@ -263,7 +263,7 @@ port_ability_set_ability(
 	port_mng->iface_type = port->iface_type;
 	port_mng->iface_no   = port->iface_no;
 
-	switch (rxtx) {
+	switch (dir) {
 	case SPP_PORT_RXTX_RX:
 		mng = &port_mng->rx;
 		break;
@@ -279,7 +279,7 @@ port_ability_set_ability(
 	memset(out_ability, 0x00, sizeof(struct spp_port_ability)
 			* SPP_PORT_ABILITY_MAX);
 	for (in_cnt = 0; in_cnt < SPP_PORT_ABILITY_MAX; in_cnt++) {
-		if (in_ability[in_cnt].rxtx != rxtx)
+		if (in_ability[in_cnt].dir != dir)
 			continue;
 
 		memcpy(&out_ability[out_cnt], &in_ability[in_cnt],
@@ -301,7 +301,7 @@ port_ability_set_ability(
 	}
 
 	spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_UPD,
-			port_id, rxtx);
+			port_id, dir);
 }
 
 /* Update port capability. */
@@ -338,13 +338,13 @@ port_ability_func port_ability_function_list[] = {
 static inline int
 port_ability_each_operation(uint16_t port_id,
 		struct rte_mbuf **pkts, const uint16_t nb_pkts,
-		enum spp_port_rxtx rxtx)
+		enum sppwk_port_dir dir)
 {
 	int cnt, buf;
 	int ok_pkts = nb_pkts;
 	struct spp_port_ability *info = NULL;
 
-	spp_port_ability_get_info(port_id, rxtx, &info);
+	spp_port_ability_get_info(port_id, dir, &info);
 	if (unlikely(info[0].ops == SPPWK_PORT_ABL_OPS_NONE))
 		return nb_pkts;
 
diff --git a/src/shared/secondary/spp_worker_th/spp_port.h b/src/shared/secondary/spp_worker_th/spp_port.h
index 274b24b..5cde7d2 100644
--- a/src/shared/secondary/spp_worker_th/spp_port.h
+++ b/src/shared/secondary/spp_worker_th/spp_port.h
@@ -40,7 +40,7 @@ void spp_port_ability_init(void);
  *  Port ability information.
  */
 void spp_port_ability_get_info(
-		int port_id, enum spp_port_rxtx rxtx,
+		int port_id, enum sppwk_port_dir dir,
 		struct spp_port_ability **info);
 
 /**
@@ -55,7 +55,7 @@ void spp_port_ability_get_info(
  */
 void spp_port_ability_change_index(
 		enum port_ability_chg_index_type type,
-		int port_id, enum spp_port_rxtx rxtx);
+		int port_id, enum sppwk_port_dir dir);
 
 /**
  * Update port capability.
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index 51f50a7..89cf12f 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -209,32 +209,32 @@ update_comp(enum sppwk_action wk_action, const char *name,
 
 /* Check if over the maximum num of rx and tx ports of component. */
 static int
-check_vf_port_count(int component_type, enum spp_port_rxtx rxtx, int num_rx,
-								int num_tx)
+check_vf_port_count(int component_type, enum sppwk_port_dir dir,
+		int nof_rx, int nof_tx)
 {
 	RTE_LOG(INFO, VF_CMD_RUNNER, "port count, port_type=%d,"
-				" rx=%d, tx=%d\n", rxtx, num_rx, num_tx);
-	if (rxtx == SPP_PORT_RXTX_RX)
-		num_rx++;
+				" rx=%d, tx=%d\n", dir, nof_rx, nof_tx);
+	if (dir == SPP_PORT_RXTX_RX)
+		nof_rx++;
 	else
-		num_tx++;
+		nof_tx++;
 	/* Add rx or tx port appointed in port_type. */
 	RTE_LOG(INFO, VF_CMD_RUNNER, "Num of ports after count up,"
 				" port_type=%d, rx=%d, tx=%d\n",
-				rxtx, num_rx, num_tx);
+				dir, nof_rx, nof_tx);
 	switch (component_type) {
 	case SPPWK_TYPE_FWD:
-		if (num_rx > 1 || num_tx > 1)
+		if (nof_rx > 1 || nof_tx > 1)
 			return SPP_RET_NG;
 		break;
 
 	case SPPWK_TYPE_MRG:
-		if (num_tx > 1)
+		if (nof_tx > 1)
 			return SPP_RET_NG;
 		break;
 
 	case SPPWK_TYPE_CLS:
-		if (num_rx > 1)
+		if (nof_rx > 1)
 			return SPP_RET_NG;
 		break;
 
@@ -250,7 +250,7 @@ check_vf_port_count(int component_type, enum spp_port_rxtx rxtx, int num_rx,
 static int
 update_port(enum sppwk_action wk_action,
 		const struct sppwk_port_idx *port,
-		enum spp_port_rxtx rxtx,
+		enum sppwk_port_dir dir,
 		const char *name,
 		const struct spp_port_ability *ability)
 {
@@ -276,7 +276,7 @@ update_port(enum sppwk_action wk_action,
 			&comp_info_base, NULL, NULL, &change_component, NULL);
 	comp_info = (comp_info_base + comp_lcore_id);
 	port_info = get_sppwk_port(port->iface_type, port->iface_no);
-	if (rxtx == SPP_PORT_RXTX_RX) {
+	if (dir == SPP_PORT_RXTX_RX) {
 		nof_ports = &comp_info->nof_rx;
 		ports = comp_info->rx_ports;
 	} else {
@@ -287,7 +287,7 @@ update_port(enum sppwk_action wk_action,
 	switch (wk_action) {
 	case SPPWK_ACT_ADD:
 		/* Check if over the maximum num of ports of component. */
-		if (check_vf_port_count(comp_info->wk_type, rxtx,
+		if (check_vf_port_count(comp_info->wk_type, dir,
 				comp_info->nof_rx,
 				comp_info->nof_tx) != SPP_RET_OK)
 			return SPP_RET_NG;
@@ -349,7 +349,7 @@ update_port(enum sppwk_action wk_action,
 					SPPWK_PORT_ABL_OPS_NONE)
 				continue;
 
-			if (port_info->ability[cnt].rxtx == rxtx)
+			if (port_info->ability[cnt].dir == dir)
 				memset(&port_info->ability[cnt], 0x00,
 					sizeof(struct spp_port_ability));
 		}
@@ -408,7 +408,7 @@ exec_one_cmd(const struct sppwk_cmd_attrs *cmd)
 		RTE_LOG(INFO, VF_CMD_RUNNER, "with action `%s`.\n",
 				sppwk_action_str(cmd->spec.port.wk_action));
 		ret = update_port(cmd->spec.port.wk_action,
-				&cmd->spec.port.port, cmd->spec.port.rxtx,
+				&cmd->spec.port.port, cmd->spec.port.dir,
 				cmd->spec.port.name, &cmd->spec.port.ability);
 		if (ret == 0) {
 			RTE_LOG(INFO, VF_CMD_RUNNER, "Exec flush.\n");
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 2/3] shared/sec: rename members of enum sppwk_port_dir
  2019-06-24  8:40 [spp] [PATCH 0/3] Rename spp_port_rxtx yasufum.o
  2019-06-24  8:40 ` [spp] [PATCH 1/3] shared/sec: revise enum spp_port_rxtx yasufum.o
@ 2019-06-24  8:40 ` yasufum.o
  2019-06-24  8:40 ` [spp] [PATCH 3/3] spp_pcap: revise enum spp_port_rxtx yasufum.o
  2 siblings, 0 replies; 4+ messages in thread
From: yasufum.o @ 2019-06-24  8:40 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

This update is to rename members of enum `sppwk_port_dir` such as
`SPP_PORT_RXTX_RX` to `SPPWK_PORT_DIR_RX` or so.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/mirror/mir_cmd_runner.c                   |  4 ++--
 .../secondary/spp_worker_th/cmd_parser.c      |  4 ++--
 .../spp_worker_th/cmd_res_formatter.c         |  4 ++--
 .../secondary/spp_worker_th/cmd_utils.c       | 12 +++++------
 .../secondary/spp_worker_th/cmd_utils.h       |  8 ++++----
 src/shared/secondary/spp_worker_th/spp_port.c | 20 +++++++++----------
 src/vf/vf_cmd_runner.c                        |  6 +++---
 7 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/mirror/mir_cmd_runner.c b/src/mirror/mir_cmd_runner.c
index eda4d1a..312ded5 100644
--- a/src/mirror/mir_cmd_runner.c
+++ b/src/mirror/mir_cmd_runner.c
@@ -111,7 +111,7 @@ check_mir_port_count(enum sppwk_port_dir dir, int nof_rx, int nof_tx)
 {
 	RTE_LOG(INFO, MIR_CMD_RUNNER, "port count, port_type=%d,"
 				" rx=%d, tx=%d\n", dir, nof_rx, nof_tx);
-	if (dir == SPP_PORT_RXTX_RX)
+	if (dir == SPPWK_PORT_DIR_RX)
 		nof_rx++;
 	else
 		nof_tx++;
@@ -155,7 +155,7 @@ update_port(enum sppwk_action wk_action,
 			&comp_info_base, NULL, NULL, &change_component, NULL);
 	comp_info = (comp_info_base + comp_lcore_id);
 	port_info = get_sppwk_port(port->iface_type, port->iface_no);
-	if (dir == SPP_PORT_RXTX_RX) {
+	if (dir == SPPWK_PORT_DIR_RX) {
 		nof_ports = &comp_info->nof_rx;
 		ports = comp_info->rx_ports;
 	} else {
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index c1b311c..10d46d8 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -462,10 +462,10 @@ parse_port(void *output, const char *arg_val, int allow_override)
 		if ((port->wk_action == SPPWK_ACT_ADD) &&
 				(spp_check_used_port(tmp_port.iface_type,
 						tmp_port.iface_no,
-						SPP_PORT_RXTX_RX) >= 0) &&
+						SPPWK_PORT_DIR_RX) >= 0) &&
 				(spp_check_used_port(tmp_port.iface_type,
 						tmp_port.iface_no,
-						SPP_PORT_RXTX_TX) >= 0)) {
+						SPPWK_PORT_DIR_TX) >= 0)) {
 			RTE_LOG(ERR, WK_CMD_PARSER,
 				"Port `%s` is already used.\n",
 				arg_val);
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
index a174890..3c2c3a6 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -345,12 +345,12 @@ append_core_element_value(
 
 	if (unuse_flg) {
 		ret = append_port_array("rx_port", &tmp_buff,
-				num_rx, rx_ports, SPP_PORT_RXTX_RX);
+				num_rx, rx_ports, SPPWK_PORT_DIR_RX);
 		if (unlikely(ret < 0))
 			return ret;
 
 		ret = append_port_array("tx_port", &tmp_buff,
-				num_tx, tx_ports, SPP_PORT_RXTX_TX);
+				num_tx, tx_ports, SPPWK_PORT_DIR_TX);
 		if (unlikely(ret < SPP_RET_OK))
 			return ret;
 	}
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c
index 4f80b2e..d21c23a 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.c
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.c
@@ -678,10 +678,10 @@ spp_check_used_port(
 		if (component->wk_type == SPPWK_TYPE_NONE)
 			continue;
 
-		if (dir == SPP_PORT_RXTX_RX) {
+		if (dir == SPPWK_PORT_DIR_RX) {
 			max = component->nof_rx;
 			port_array = component->rx_ports;
-		} else if (dir == SPP_PORT_RXTX_TX) {
+		} else if (dir == SPPWK_PORT_DIR_TX) {
 			max = component->nof_tx;
 			port_array = component->tx_ports;
 		}
@@ -700,16 +700,16 @@ set_component_change_port(struct sppwk_port_info *port,
 		enum sppwk_port_dir dir)
 {
 	int ret = 0;
-	if ((dir == SPP_PORT_RXTX_RX) || (dir == SPP_PORT_RXTX_ALL)) {
+	if ((dir == SPPWK_PORT_DIR_RX) || (dir == SPPWK_PORT_DIR_BOTH)) {
 		ret = spp_check_used_port(port->iface_type, port->iface_no,
-				SPP_PORT_RXTX_RX);
+				SPPWK_PORT_DIR_RX);
 		if (ret >= 0)
 			*(g_mng_data.p_change_component + ret) = 1;
 	}
 
-	if ((dir == SPP_PORT_RXTX_TX) || (dir == SPP_PORT_RXTX_ALL)) {
+	if ((dir == SPPWK_PORT_DIR_TX) || (dir == SPPWK_PORT_DIR_BOTH)) {
 		ret = spp_check_used_port(port->iface_type, port->iface_no,
-				SPP_PORT_RXTX_TX);
+				SPPWK_PORT_DIR_TX);
 		if (ret >= 0)
 			*(g_mng_data.p_change_component + ret) = 1;
 	}
diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index e08e4fb..b15b40a 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -97,10 +97,10 @@ enum spp_classifier_type {
 
 /* Direction of RX or TX on a port. */
 enum sppwk_port_dir {
-	SPP_PORT_RXTX_NONE, /**< none */
-	SPP_PORT_RXTX_RX,   /**< rx port */
-	SPP_PORT_RXTX_TX,   /**< tx port */
-	SPP_PORT_RXTX_ALL,  /**< rx/tx port */
+	SPPWK_PORT_DIR_NONE,  /**< None */
+	SPPWK_PORT_DIR_RX,    /**< RX port */
+	SPPWK_PORT_DIR_TX,    /**< TX port */
+	SPPWK_PORT_DIR_BOTH,  /**< Both of RX and TX */
 };
 
 /**
diff --git a/src/shared/secondary/spp_worker_th/spp_port.c b/src/shared/secondary/spp_worker_th/spp_port.c
index 7ac6858..b0a29f7 100644
--- a/src/shared/secondary/spp_worker_th/spp_port.c
+++ b/src/shared/secondary/spp_worker_th/spp_port.c
@@ -66,10 +66,10 @@ spp_port_ability_get_info(
 	struct port_ability_mng_info *mng = NULL;
 
 	switch (dir) {
-	case SPP_PORT_RXTX_RX:
+	case SPPWK_PORT_DIR_RX:
 		mng = &g_port_mng_info[port_id].rx;
 		break;
-	case SPP_PORT_RXTX_TX:
+	case SPPWK_PORT_DIR_TX:
 		mng = &g_port_mng_info[port_id].tx;
 		break;
 	default:
@@ -213,12 +213,12 @@ spp_port_ability_change_index(
 
 	if (type == PORT_ABILITY_CHG_INDEX_UPD) {
 		switch (dir) {
-		case SPP_PORT_RXTX_RX:
+		case SPPWK_PORT_DIR_RX:
 			mng = &g_port_mng_info[port_id].rx;
 			mng->upd_index = mng->ref_index;
 			rx_list[num_rx++] = port_id;
 			break;
-		case SPP_PORT_RXTX_TX:
+		case SPPWK_PORT_DIR_TX:
 			mng = &g_port_mng_info[port_id].tx;
 			mng->upd_index = mng->ref_index;
 			tx_list[num_tx++] = port_id;
@@ -264,10 +264,10 @@ port_ability_set_ability(
 	port_mng->iface_no   = port->iface_no;
 
 	switch (dir) {
-	case SPP_PORT_RXTX_RX:
+	case SPPWK_PORT_DIR_RX:
 		mng = &port_mng->rx;
 		break;
-	case SPP_PORT_RXTX_TX:
+	case SPPWK_PORT_DIR_TX:
 		mng = &port_mng->tx;
 		break;
 	default:
@@ -312,12 +312,12 @@ spp_port_ability_update(const struct sppwk_comp_info *component)
 	struct sppwk_port_info *port = NULL;
 	for (cnt = 0; cnt < component->nof_rx; cnt++) {
 		port = component->rx_ports[cnt];
-		port_ability_set_ability(port, SPP_PORT_RXTX_RX);
+		port_ability_set_ability(port, SPPWK_PORT_DIR_RX);
 	}
 
 	for (cnt = 0; cnt < component->nof_tx; cnt++) {
 		port = component->tx_ports[cnt];
-		port_ability_set_ability(port, SPP_PORT_RXTX_TX);
+		port_ability_set_ability(port, SPPWK_PORT_DIR_TX);
 	}
 }
 
@@ -384,7 +384,7 @@ spp_eth_rx_burst(
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 
 	return port_ability_each_operation(port_id, rx_pkts, nb_rx,
-			SPP_PORT_RXTX_RX);
+			SPPWK_PORT_DIR_RX);
 }
 
 /* Wrapper function for rte_eth_tx_burst(). */
@@ -395,7 +395,7 @@ spp_eth_tx_burst(
 {
 	uint16_t nb_tx = 0;
 	nb_tx = port_ability_each_operation(port_id, tx_pkts, nb_pkts,
-			SPP_PORT_RXTX_TX);
+			SPPWK_PORT_DIR_TX);
 	if (unlikely(nb_tx == 0))
 		return SPP_RET_OK;
 
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index 89cf12f..4a78ab2 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -107,7 +107,7 @@ update_cls_table(enum sppwk_action wk_action,
 		strcpy(port_info->cls_attrs.mac_addr_str, mac_str);
 	}
 
-	set_component_change_port(port_info, SPP_PORT_RXTX_TX);
+	set_component_change_port(port_info, SPPWK_PORT_DIR_TX);
 	return SPP_RET_OK;
 }
 
@@ -214,7 +214,7 @@ check_vf_port_count(int component_type, enum sppwk_port_dir dir,
 {
 	RTE_LOG(INFO, VF_CMD_RUNNER, "port count, port_type=%d,"
 				" rx=%d, tx=%d\n", dir, nof_rx, nof_tx);
-	if (dir == SPP_PORT_RXTX_RX)
+	if (dir == SPPWK_PORT_DIR_RX)
 		nof_rx++;
 	else
 		nof_tx++;
@@ -276,7 +276,7 @@ update_port(enum sppwk_action wk_action,
 			&comp_info_base, NULL, NULL, &change_component, NULL);
 	comp_info = (comp_info_base + comp_lcore_id);
 	port_info = get_sppwk_port(port->iface_type, port->iface_no);
-	if (dir == SPP_PORT_RXTX_RX) {
+	if (dir == SPPWK_PORT_DIR_RX) {
 		nof_ports = &comp_info->nof_rx;
 		ports = comp_info->rx_ports;
 	} else {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 3/3] spp_pcap: revise enum spp_port_rxtx
  2019-06-24  8:40 [spp] [PATCH 0/3] Rename spp_port_rxtx yasufum.o
  2019-06-24  8:40 ` [spp] [PATCH 1/3] shared/sec: revise enum spp_port_rxtx yasufum.o
  2019-06-24  8:40 ` [spp] [PATCH 2/3] shared/sec: rename members of enum sppwk_port_dir yasufum.o
@ 2019-06-24  8:40 ` yasufum.o
  2 siblings, 0 replies; 4+ messages in thread
From: yasufum.o @ 2019-06-24  8:40 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

This update is to revise the name of enum `spp_port_rxtx` to
`sppwk_port_dir` because it is used to specify which of direction
packets are forwarded on a port. Term `rxtx` is used for a set of RX and
TX, so it should not be used for specifying the direction. This update
is also rename members of the enum, and a member of structs using this
enum from `rxtx` to `dir`.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/pcap/cmd_runner.c |  8 ++++----
 src/pcap/cmd_utils.h  | 17 +++++++----------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/pcap/cmd_runner.c b/src/pcap/cmd_runner.c
index 4a74af2..7f17d40 100644
--- a/src/pcap/cmd_runner.c
+++ b/src/pcap/cmd_runner.c
@@ -399,7 +399,7 @@ append_client_id_value(const char *name, char **output,
 /* append a block of port entry for JSON format */
 static int
 append_port_entry(char **output, const struct sppwk_port_idx *port,
-		const enum spp_port_rxtx rxtx __attribute__ ((unused)))
+		const enum sppwk_port_dir dir __attribute__ ((unused)))
 {
 	int ret = SPPWK_RET_NG;
 	char port_str[CMD_TAG_APPEND_SIZE];
@@ -424,7 +424,7 @@ append_port_entry(char **output, const struct sppwk_port_idx *port,
 static int
 append_port_array(const char *name, char **output, const int num,
 		const struct sppwk_port_idx *ports,
-		const enum spp_port_rxtx rxtx)
+		const enum sppwk_port_dir dir)
 {
 	int ret = SPPWK_RET_NG;
 	int i = 0;
@@ -437,7 +437,7 @@ append_port_array(const char *name, char **output, const int num,
 	}
 
 	for (i = 0; i < num; i++) {
-		ret = append_port_entry(&tmp_buff, &ports[i], rxtx);
+		ret = append_port_entry(&tmp_buff, &ports[i], dir);
 		if (unlikely(ret < SPPWK_RET_OK))
 			return SPPWK_RET_NG;
 	}
@@ -493,7 +493,7 @@ append_pcap_core_element_value(
 
 	if (num_rx != 0)
 		ret = append_port_array("rx_port", &tmp_buff,
-				num_rx, rx_ports, SPP_PORT_RXTX_RX);
+				num_rx, rx_ports, SPPWK_PORT_DIR_RX);
 	else
 		ret = append_json_str_value("filename", &tmp_buff, name);
 	if (unlikely(ret < 0))
diff --git a/src/pcap/cmd_utils.h b/src/pcap/cmd_utils.h
index 5528e00..d38e0eb 100644
--- a/src/pcap/cmd_utils.h
+++ b/src/pcap/cmd_utils.h
@@ -59,15 +59,12 @@ enum sppwk_return_val {
 	SPPWK_RET_NG = -1, /**< failed */
 };
 
-/**
- * Port type (rx or tx) to indicate which direction packet goes
- * (e.g. receiving or transmitting)
- */
-enum spp_port_rxtx {
-	SPP_PORT_RXTX_NONE, /**< none */
-	SPP_PORT_RXTX_RX,   /**< rx port */
-	SPP_PORT_RXTX_TX,   /**< tx port */
-	SPP_PORT_RXTX_ALL,  /**< rx/tx port */
+/* Direction of RX or TX on a port. */
+enum sppwk_port_dir {
+	SPPWK_PORT_DIR_NONE,  /**< None */
+	SPPWK_PORT_DIR_RX,    /**< RX port */
+	SPPWK_PORT_DIR_TX,    /**< TX port */
+	SPPWK_PORT_DIR_BOTH,  /**< Both of RX and TX */
 };
 
 /* TODO(yasufum) merge it to the same definition in shared/.../cmd_utils.h */
@@ -122,7 +119,7 @@ union spp_ability_data {
 /** Port ability information */
 struct spp_port_ability {
 	enum spp_port_ability_ope ope; /**< Operation */
-	enum spp_port_rxtx rxtx;       /**< rx/tx identifier */
+	enum sppwk_port_dir dir;  /**< Direction of RX, TX or both */
 	union spp_ability_data data;   /**< Port ability data */
 };
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-24  8:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24  8:40 [spp] [PATCH 0/3] Rename spp_port_rxtx yasufum.o
2019-06-24  8:40 ` [spp] [PATCH 1/3] shared/sec: revise enum spp_port_rxtx yasufum.o
2019-06-24  8:40 ` [spp] [PATCH 2/3] shared/sec: rename members of enum sppwk_port_dir yasufum.o
2019-06-24  8:40 ` [spp] [PATCH 3/3] spp_pcap: revise enum spp_port_rxtx yasufum.o

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).