Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH 0/2] Refactor port capability
@ 2019-07-01  4:11 yasufum.o
  2019-07-01  4:11 ` [spp] [PATCH 1/2] shared/sec: refactor public funcs of capability yasufum.o
  2019-07-01  4:11 ` [spp] [PATCH 2/2] shared/sec: refactor port capability funcs yasufum.o
  0 siblings, 2 replies; 3+ messages in thread
From: yasufum.o @ 2019-07-01  4:11 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

This series of patches is to refactor functions or variables defined in
`port_capability.c` and `port_capability.h`.

Yasufumi Ogawa (2):
  shared/sec: refactor public funcs of capability
  shared/sec: refactor port capability funcs

 src/mirror/mir_cmd_runner.c                   |   2 +-
 src/mirror/spp_mirror.c                       |   4 +-
 src/pcap/spp_pcap.c                           |   2 +-
 .../spp_worker_th/cmd_res_formatter.c         |   2 +-
 .../secondary/spp_worker_th/port_capability.c | 141 ++++++++++--------
 .../secondary/spp_worker_th/port_capability.h |  43 +++---
 src/vf/classifier_mac.c                       |   3 +-
 src/vf/forwarder.c                            |   3 +-
 src/vf/spp_vf.c                               |   2 +-
 src/vf/vf_cmd_runner.c                        |   2 +-
 10 files changed, 108 insertions(+), 96 deletions(-)

-- 
2.17.1


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

* [spp] [PATCH 1/2] shared/sec: refactor public funcs of capability
  2019-07-01  4:11 [spp] [PATCH 0/2] Refactor port capability yasufum.o
@ 2019-07-01  4:11 ` yasufum.o
  2019-07-01  4:11 ` [spp] [PATCH 2/2] shared/sec: refactor port capability funcs yasufum.o
  1 sibling, 0 replies; 3+ messages in thread
From: yasufum.o @ 2019-07-01  4:11 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

This update is to rename public functions `port_capability.c` and
`port_capability.h` for refactoring. It also includes revising
variables, structures or comments of them.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/mirror/mir_cmd_runner.c                   |  2 +-
 src/mirror/spp_mirror.c                       |  4 +-
 src/pcap/spp_pcap.c                           |  2 +-
 .../spp_worker_th/cmd_res_formatter.c         |  2 +-
 .../secondary/spp_worker_th/port_capability.c | 88 +++++++++++--------
 .../secondary/spp_worker_th/port_capability.h | 43 ++++-----
 src/vf/classifier_mac.c                       |  3 +-
 src/vf/forwarder.c                            |  3 +-
 src/vf/spp_vf.c                               |  2 +-
 src/vf/vf_cmd_runner.c                        |  2 +-
 10 files changed, 82 insertions(+), 69 deletions(-)

diff --git a/src/mirror/mir_cmd_runner.c b/src/mirror/mir_cmd_runner.c
index 7c9a240..3f90e9a 100644
--- a/src/mirror/mir_cmd_runner.c
+++ b/src/mirror/mir_cmd_runner.c
@@ -389,7 +389,7 @@ update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp)
 			continue;
 
 		comp_info = (p_comp_info + cnt);
-		spp_port_ability_update(comp_info);
+		sppwk_update_port_dir(comp_info);
 
 		ret = update_mirror(comp_info);
 		RTE_LOG(DEBUG, MIR_CMD_RUNNER, "Update mirror.\n");
diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index 4c2b90c..37327c7 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -288,7 +288,7 @@ change_mirror_index(int id)
 	struct mirror_info *info = &g_mirror_info[id];
 	if (info->ref_index == info->upd_index) {
 	/* Change reference index of port ability. */
-		spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF, 0, 0);
+		sppwk_swap_two_sides(SPPWK_SWAP_REF, 0, 0);
 		info->ref_index = (info->upd_index+1) % TWO_SIDES;
 	}
 }
@@ -521,7 +521,7 @@ main(int argc, char *argv[])
 			break;
 
 		mirror_proc_init();
-		spp_port_ability_init();
+		sppwk_port_capability_init();
 
 		/* Setup connection for accepting commands from controller */
 		get_spp_ctl_ip(ctl_ip);
diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c
index e32c360..bcce13f 100644
--- a/src/pcap/spp_pcap.c
+++ b/src/pcap/spp_pcap.c
@@ -946,7 +946,7 @@ main(int argc, char *argv[])
 		if (unlikely(ret_mng != 0))
 			break;
 
-		spp_port_ability_init();
+		sppwk_port_capability_init();
 
 		/* Setup connection for accepting commands from controller */
 		get_spp_ctl_ip(ctl_ip);
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 2cc7d42..1485533 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -156,7 +156,7 @@ append_vlan_block(const char *name, char **output,
 		return SPP_RET_NG;
 	}
 
-	spp_port_ability_get_info(port_id, dir, &port_attrs);
+	sppwk_get_port_attrs(&port_attrs, port_id, dir);
 	for (i = 0; i < PORT_ABL_MAX; i++) {
 		switch (port_attrs[i].ops) {
 		case SPPWK_PORT_OPS_ADD_VLAN:
diff --git a/src/shared/secondary/spp_worker_th/port_capability.c b/src/shared/secondary/spp_worker_th/port_capability.c
index ce498fd..30c6e95 100644
--- a/src/shared/secondary/spp_worker_th/port_capability.c
+++ b/src/shared/secondary/spp_worker_th/port_capability.c
@@ -12,20 +12,35 @@
 #include "shared/secondary/return_codes.h"
 #include "ringlatencystats.h"
 
-/* Port ability management information */
-struct port_abl_info {
-	volatile int ref_index; /* Index to reference area. */
-	volatile int upd_index; /* Index to update area. */
+/**
+ * TODO(yasufum) This `port capability` is intended to be used mainly for VLAN
+ * features. However, other features, such as two sides structure of
+ * management info or port direction, are also included this capability.
+ * For the reason, SPP worker processes other spp_vf should include the
+ * capability even if it is not using VLAN. It is a bad design because of
+ * tightly coupled for dependency and it is so confusing.
+ *
+ * This problem should be fixed in a future update.
+ */
+
+/* Port capability management information used as a member of port_mng_info. */
+struct port_capabl_mng_info {
+	/* TODO(yasufum) rename ref_index and upd_index because flag. */
+	/* TODO(yasufum) consider to not use two flags for (0,1) and (1,0). */
+	volatile int ref_index; /* Flag to indicate using reference side. */
+	volatile int upd_index; /* Flag to indicate using update side. */
+
+	/* A set of attrs including sppwk_port_capability. */
+	/* TODO(yasufum) confirm why using PORT_ABL_MAX. */
 	struct sppwk_port_attrs port_attrs[TWO_SIDES][PORT_ABL_MAX];
-				/* Port attributes for spp_vf. */
 };
 
 /* Port ability port information */
 struct port_mng_info {
 	enum port_type iface_type;  /* Interface type (phy, vhost or so). */
 	int iface_no;  /* Interface number. */
-	struct port_abl_info rx;  /* Mng data of port ability for RX. */
-	struct port_abl_info tx;  /* Mng data of port ability for Tx. */
+	struct port_capabl_mng_info rx;  /* Mng data of capability for RX. */
+	struct port_capabl_mng_info tx;  /* Mng data of capability for Tx. */
 };
 
 /* Information for VLAN tag management. */
@@ -34,9 +49,9 @@ struct port_mng_info g_port_mng_info[RTE_MAX_ETHPORTS];
 /* TPID of VLAN. */
 static uint16_t g_vlan_tpid;
 
-/* Initialize port ability. */
+/* Initialize g_port_mng_info, and set ref side to 0 and update side to 1. */
 void
-spp_port_ability_init(void)
+sppwk_port_capability_init(void)
 {
 	int cnt = 0;
 	g_vlan_tpid = rte_cpu_to_be_16(ETHER_TYPE_VLAN);
@@ -49,13 +64,12 @@ spp_port_ability_init(void)
 	}
 }
 
-/* Get information of port ability. */
+/* Get port attributes of given ID and direction from g_port_mng_info. */
 void
-spp_port_ability_get_info(
-		int port_id, enum sppwk_port_dir dir,
-		struct sppwk_port_attrs **info)
+sppwk_get_port_attrs(struct sppwk_port_attrs **p_attrs,
+		int port_id, enum sppwk_port_dir dir)
 {
-	struct port_abl_info *mng = NULL;
+	struct port_capabl_mng_info *mng = NULL;
 
 	switch (dir) {
 	case SPPWK_PORT_DIR_RX:
@@ -68,7 +82,8 @@ spp_port_ability_get_info(
 		/* Not used. */
 		break;
 	}
-	*info = mng->port_attrs[mng->ref_index];
+
+	*p_attrs = mng->port_attrs[mng->ref_index];
 }
 
 /* Calculation and Setting of FCS. */
@@ -190,20 +205,21 @@ del_vlantag_all_packets(
 	return cnt;
 }
 
-/* Change index of management information. */
+/* Swap ref side and update side. */
+/* TODO(yasufum) add desc for this function. */
 void
-spp_port_ability_change_index(
-		enum port_ability_chg_index_type type,
+sppwk_swap_two_sides(
+		enum sppwk_swap_type swap_type,
 		int port_id, enum sppwk_port_dir dir)
 {
 	int cnt;
 	static int num_rx;
-	static int rx_list[RTE_MAX_ETHPORTS];
 	static int num_tx;
+	static int rx_list[RTE_MAX_ETHPORTS];
 	static int tx_list[RTE_MAX_ETHPORTS];
-	struct port_abl_info *mng = NULL;
+	struct port_capabl_mng_info *mng = NULL;
 
-	if (type == PORT_ABILITY_CHG_INDEX_UPD) {
+	if (swap_type == SPPWK_SWAP_UPD) {
 		switch (dir) {
 		case SPPWK_PORT_DIR_RX:
 			mng = &g_port_mng_info[port_id].rx;
@@ -227,14 +243,12 @@ spp_port_ability_change_index(
 		mng->ref_index = (mng->upd_index+1) % TWO_SIDES;
 		rx_list[cnt] = 0;
 	}
+
 	for (cnt = 0; cnt < num_tx; cnt++) {
 		mng = &g_port_mng_info[tx_list[cnt]].tx;
 		mng->ref_index = (mng->upd_index+1) % TWO_SIDES;
 		tx_list[cnt] = 0;
 	}
-
-	num_rx = 0;
-	num_tx = 0;
 }
 
 /* Set ability data of port ability. */
@@ -245,7 +259,7 @@ port_ability_set_ability(struct sppwk_port_info *port,
 	int in_cnt, out_cnt = 0;
 	int port_id = port->ethdev_port_id;
 	struct port_mng_info *port_mng = &g_port_mng_info[port_id];
-	struct port_abl_info *mng = NULL;
+	struct port_capabl_mng_info *mng = NULL;
 	struct sppwk_port_attrs *port_attrs_in = port->port_attrs;
 	struct sppwk_port_attrs *port_attrs_out = NULL;
 	struct sppwk_vlan_tag *tag = NULL;
@@ -290,24 +304,24 @@ port_ability_set_ability(struct sppwk_port_info *port,
 		out_cnt++;
 	}
 
-	spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_UPD,
-			port_id, dir);
+	sppwk_swap_two_sides(SPPWK_SWAP_UPD, port_id, dir);
 }
 
-/* Update port capability. */
+/* Update port direction of given component. */
 void
-spp_port_ability_update(const struct sppwk_comp_info *component)
+sppwk_update_port_dir(const struct sppwk_comp_info *comp)
 {
 	int cnt;
-	struct sppwk_port_info *port = NULL;
-	for (cnt = 0; cnt < component->nof_rx; cnt++) {
-		port = component->rx_ports[cnt];
-		port_ability_set_ability(port, SPPWK_PORT_DIR_RX);
+	struct sppwk_port_info *port_info = NULL;
+
+	for (cnt = 0; cnt < comp->nof_rx; cnt++) {
+		port_info = comp->rx_ports[cnt];
+		port_ability_set_ability(port_info, SPPWK_PORT_DIR_RX);
 	}
 
-	for (cnt = 0; cnt < component->nof_tx; cnt++) {
-		port = component->tx_ports[cnt];
-		port_ability_set_ability(port, SPPWK_PORT_DIR_TX);
+	for (cnt = 0; cnt < comp->nof_tx; cnt++) {
+		port_info = comp->tx_ports[cnt];
+		port_ability_set_ability(port_info, SPPWK_PORT_DIR_TX);
 	}
 }
 
@@ -334,7 +348,7 @@ port_ability_each_operation(uint16_t port_id,
 	int ok_pkts = nb_pkts;
 	struct sppwk_port_attrs *port_attrs = NULL;
 
-	spp_port_ability_get_info(port_id, dir, &port_attrs);
+	sppwk_get_port_attrs(&port_attrs, port_id, dir);
 	if (unlikely(port_attrs[0].ops == SPPWK_PORT_OPS_NONE))
 		return nb_pkts;
 
diff --git a/src/shared/secondary/spp_worker_th/port_capability.h b/src/shared/secondary/spp_worker_th/port_capability.h
index 5d2a38a..0593f10 100644
--- a/src/shared/secondary/spp_worker_th/port_capability.h
+++ b/src/shared/secondary/spp_worker_th/port_capability.h
@@ -17,45 +17,46 @@
 /** Calculate TCI of VLAN tag. */
 #define SPP_VLANTAG_CALC_TCI(id, pcp) (((pcp & 0x07) << 13) | (id & 0x0fff))
 
-/** Type for changing index. */
-enum port_ability_chg_index_type {
-	PORT_ABILITY_CHG_INDEX_REF,  /** To change index to reference area. */
-	PORT_ABILITY_CHG_INDEX_UPD,  /** To change index to update area. */
+/** Type for swaping sides . */
+enum sppwk_swap_type {
+	SPPWK_SWAP_REF,  /** Swap to reference area. */
+	SPPWK_SWAP_UPD,  /** Swap to update area. */
 };
 
-/** Initialize port ability. */
-void spp_port_ability_init(void);
+/**
+ * Initialize global variable g_port_mng_info, and set ref side to 0 and
+ * update side to 1.
+ */
+void sppwk_port_capability_init(void);
 
 /**
- * Get information of port ability.
+ * Get port attributes of given ID and direction from global g_port_mng_info.
  *
- * @param port_id Etherdev ID.
- * @param rxtx RX/TX ID of port_id.
- * @param info Port ability information.
+ * @param[in,out] p_attrs Port attributes.
+ * @param[in] port_id Etherdev ID.
+ * @param[in] dir Direction of teh port of sppwk_port_dir.
  */
-void spp_port_ability_get_info(
-		int port_id, enum sppwk_port_dir dir,
-		struct sppwk_port_attrs **info);
+void sppwk_get_port_attrs(
+		struct sppwk_port_attrs **p_attrs,
+		int port_id, enum sppwk_port_dir dir);
 
 /**
- * Change index of management information.
+ * Swap ref side and update side.
  *
  * @param port_id Etherdev ID.
  * @param rxtx RX/TX ID of port_id.
  * @param type Type for changing index.
  */
-void spp_port_ability_change_index(
-		enum port_ability_chg_index_type type,
+void sppwk_swap_two_sides(
+		enum sppwk_swap_type swap_type,
 		int port_id, enum sppwk_port_dir dir);
 
 /**
- * Update port capability.
+ * Update port direction of given component.
  *
- * @param component_info
- *  The pointer to struct sppwk_comp_info.@n
- *  The data for updating the internal data of port ability.
+ * @param comp Pointer to sppwk_comp_info.
  */
-void spp_port_ability_update(const struct sppwk_comp_info *component);
+void sppwk_update_port_dir(const struct sppwk_comp_info *comp);
 
 /**
  * Wrapper function for rte_eth_rx_burst() with ring latency feature.
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index 6850962..e41c65a 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -679,8 +679,7 @@ change_classifier_index(struct management_info *mng_info, int id)
 	if (unlikely(mng_info->ref_index ==
 			mng_info->upd_index)) {
 		/* Change reference index of port ability. */
-		spp_port_ability_change_index(PORT_ABILITY_CHG_INDEX_REF,
-									0, 0);
+		sppwk_swap_two_sides(SPPWK_SWAP_REF, 0, 0);
 
 		/* Transmit all packets for switching the using data. */
 		transmit_all_packet(mng_info->cmp_infos + mng_info->ref_index);
diff --git a/src/vf/forwarder.c b/src/vf/forwarder.c
index 77afc4e..cd28a58 100644
--- a/src/vf/forwarder.c
+++ b/src/vf/forwarder.c
@@ -170,8 +170,7 @@ change_forward_index(int id)
 	struct forward_info *info = &g_forward_info[id];
 	if (info->ref_index == info->upd_index) {
 		/* Change reference index of port ability. */
-		spp_port_ability_change_index(
-				PORT_ABILITY_CHG_INDEX_REF, 0, 0);
+		sppwk_swap_two_sides(SPPWK_SWAP_REF, 0, 0);
 
 		info->ref_index = (info->upd_index+1) % TWO_SIDES;
 	}
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 504ee26..dbd47bf 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -248,7 +248,7 @@ main(int argc, char *argv[])
 			break;
 
 		init_forwarder();
-		spp_port_ability_init();
+		sppwk_port_capability_init();
 
 		/* Setup connection for accepting commands from controller */
 		get_spp_ctl_ip(ctl_ip);
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index 5246af7..520398b 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -529,7 +529,7 @@ update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp)
 			continue;
 
 		comp_info = (p_comp_info + cnt);
-		spp_port_ability_update(comp_info);
+		sppwk_update_port_dir(comp_info);
 
 		if (comp_info->wk_type == SPPWK_TYPE_CLS) {
 			ret = update_classifier(comp_info);
-- 
2.17.1


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

* [spp] [PATCH 2/2] shared/sec: refactor port capability funcs
  2019-07-01  4:11 [spp] [PATCH 0/2] Refactor port capability yasufum.o
  2019-07-01  4:11 ` [spp] [PATCH 1/2] shared/sec: refactor public funcs of capability yasufum.o
@ 2019-07-01  4:11 ` yasufum.o
  1 sibling, 0 replies; 3+ messages in thread
From: yasufum.o @ 2019-07-01  4:11 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

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

This update is to refactor functions for port capability defined in
`port_capability.c`. All of incorrect or ambiguous term usages are
fixed.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 .../secondary/spp_worker_th/port_capability.c | 57 +++++++++----------
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/port_capability.c b/src/shared/secondary/spp_worker_th/port_capability.c
index 30c6e95..db12f0c 100644
--- a/src/shared/secondary/spp_worker_th/port_capability.c
+++ b/src/shared/secondary/spp_worker_th/port_capability.c
@@ -96,9 +96,9 @@ set_fcs_packet(struct rte_mbuf *pkt)
 			pkt->data_len, RTE_NET_CRC32_ETH);
 }
 
-/* Add VLAN tag to packet. */
+/* Add VLAN tag to a packet. It is called from add_vlan_tag_all(). */
 static inline int
-add_vlantag_packet(
+add_vlan_tag_one(
 		struct rte_mbuf *pkt,
 		const union sppwk_port_capability *capability)
 {
@@ -135,14 +135,14 @@ add_vlantag_packet(
 
 /* Add VLAN tag to all packets. */
 static inline int
-add_vlantag_all_packets(
+add_vlan_tag_all(
 		struct rte_mbuf **pkts, int nb_pkts,
 		const union sppwk_port_capability *capability)
 {
 	int ret = SPP_RET_OK;
 	int cnt = 0;
 	for (cnt = 0; cnt < nb_pkts; cnt++) {
-		ret = add_vlantag_packet(pkts[cnt], capability);
+		ret = add_vlan_tag_one(pkts[cnt], capability);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, PORT,
 					"Failed to add VLAN tag."
@@ -153,9 +153,9 @@ add_vlantag_all_packets(
 	return cnt;
 }
 
-/* Delete VLAN tag to packet. */
+/* Delete VLAN tag from a packet. It is called from del_vlan_tag_all(). */
 static inline int
-del_vlantag_packet(
+del_vlan_tag_one(
 		struct rte_mbuf *pkt,
 		const union sppwk_port_capability *cbl __attribute__ ((unused)))
 {
@@ -185,16 +185,16 @@ del_vlantag_packet(
 	return SPP_RET_OK;
 }
 
-/* Delete VLAN tag to all packets. */
+/* Delete VLAN tag from all packets. */
 static inline int
-del_vlantag_all_packets(
+del_vlan_tag_all(
 		struct rte_mbuf **pkts, int nb_pkts,
 		const union sppwk_port_capability *capability)
 {
 	int ret = SPP_RET_OK;
 	int cnt = 0;
 	for (cnt = 0; cnt < nb_pkts; cnt++) {
-		ret = del_vlantag_packet(pkts[cnt], capability);
+		ret = del_vlan_tag_one(pkts[cnt], capability);
 		if (unlikely(ret < 0)) {
 			RTE_LOG(ERR, PORT,
 					"Failed to del VLAN tag."
@@ -251,9 +251,9 @@ sppwk_swap_two_sides(
 	}
 }
 
-/* Set ability data of port ability. */
+/* Update port attributes of given direction. */
 static void
-port_ability_set_ability(struct sppwk_port_info *port,
+update_port_attrs(struct sppwk_port_info *port,
 		enum sppwk_port_dir dir)
 {
 	int in_cnt, out_cnt = 0;
@@ -316,32 +316,33 @@ sppwk_update_port_dir(const struct sppwk_comp_info *comp)
 
 	for (cnt = 0; cnt < comp->nof_rx; cnt++) {
 		port_info = comp->rx_ports[cnt];
-		port_ability_set_ability(port_info, SPPWK_PORT_DIR_RX);
+		update_port_attrs(port_info, SPPWK_PORT_DIR_RX);
 	}
 
 	for (cnt = 0; cnt < comp->nof_tx; cnt++) {
 		port_info = comp->tx_ports[cnt];
-		port_ability_set_ability(port_info, SPPWK_PORT_DIR_TX);
+		update_port_attrs(port_info, SPPWK_PORT_DIR_TX);
 	}
 }
 
-/* Definition of functions that operate port abilities. */
-typedef int (*port_ability_func)(
+/**
+ * Define list of VLAN opeartion functions. It is only used in
+ * vlan_operation().
+ */
+typedef int (*vlan_f)(
 		struct rte_mbuf **pkts, int nb_pkts,
 		const union sppwk_port_capability *capability);
 
-/* List of functions per port ability. */
-port_ability_func port_ability_function_list[] = {
-	NULL,                    /* None */
-	add_vlantag_all_packets, /* Add VLAN tag */
-	del_vlantag_all_packets, /* Del VLAN tag */
-	NULL                     /* Termination */
+vlan_f vlan_ops[] = {
+	NULL,              /* None */
+	add_vlan_tag_all,  /* Add VLAN tag */
+	del_vlan_tag_all,  /* Del VLAN tag */
+	NULL               /* Termination */
 };
 
-/* Each packet operation of port capability. */
+/* Add or delete VLAN tag. */
 static inline int
-port_ability_each_operation(uint16_t port_id,
-		struct rte_mbuf **pkts, const uint16_t nb_pkts,
+vlan_operation(uint16_t port_id, struct rte_mbuf **pkts, const uint16_t nb_pkts,
 		enum sppwk_port_dir dir)
 {
 	int cnt, buf;
@@ -358,7 +359,7 @@ port_ability_each_operation(uint16_t port_id,
 			break;
 
 		/* Add or delete VLAN tag with operation function. */
-		ok_pkts = port_ability_function_list[port_attrs[cnt].ops](
+		ok_pkts = vlan_ops[port_attrs[cnt].ops](
 				pkts, ok_pkts, &port_attrs->capability);
 	}
 
@@ -391,8 +392,7 @@ sppwk_eth_vlan_rx_burst(uint16_t port_id,
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 
 	/* Add or delete VLAN tag. */
-	return port_ability_each_operation(port_id, rx_pkts, nb_rx,
-			SPPWK_PORT_DIR_RX);
+	return vlan_operation(port_id, rx_pkts, nb_rx, SPPWK_PORT_DIR_RX);
 }
 
 
@@ -406,8 +406,7 @@ sppwk_eth_vlan_tx_burst(uint16_t port_id,
 	uint16_t nb_tx;
 
 	/* Add or delete VLAN tag. */
-	nb_tx = port_ability_each_operation(port_id, tx_pkts, nb_pkts,
-			SPPWK_PORT_DIR_TX);
+	nb_tx = vlan_operation(port_id, tx_pkts, nb_pkts, SPPWK_PORT_DIR_TX);
 
 	if (unlikely(nb_tx == 0))
 		return SPP_RET_OK;
-- 
2.17.1


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

end of thread, other threads:[~2019-07-01  4:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-01  4:11 [spp] [PATCH 0/2] Refactor port capability yasufum.o
2019-07-01  4:11 ` [spp] [PATCH 1/2] shared/sec: refactor public funcs of capability yasufum.o
2019-07-01  4:11 ` [spp] [PATCH 2/2] shared/sec: refactor port capability funcs 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).