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 4/4] spp_vf: remove dependency from common functions
Date: Wed,  8 May 2019 11:00:06 +0900	[thread overview]
Message-ID: <1557280806-7672-5-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1557280806-7672-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

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

Some of functions in `src/shared` depend on spp_vf's functions under
`src/vf`, it means these common functions are not common actually. This
update is to resolve the issue by moving vars and functions referred
by common functions from under `src/vf` to
`src/shared/secondary/spp_worker_th/vf_deps.h` as utils functions.

By this update, common functions do not depend on spp_vf, but some of
static vars and functions are changed to not static. It might cause some
slightly performance degradation possibly, but should be required to
avoid to be spaghetti code.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/command_proc.c    |  37 +++++-
 src/shared/secondary/spp_worker_th/spp_proc.c |   5 +-
 src/vf/classifier_mac.c                       | 119 +-----------------
 src/vf/classifier_mac.h                       |  32 -----
 src/vf/spp_forward.c                          |   1 +
 src/vf/spp_forward.h                          |  30 -----
 6 files changed, 37 insertions(+), 187 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/command_proc.c b/src/shared/secondary/spp_worker_th/command_proc.c
index 813e95f..2fc1829 100644
--- a/src/shared/secondary/spp_worker_th/command_proc.c
+++ b/src/shared/secondary/spp_worker_th/command_proc.c
@@ -8,15 +8,14 @@
 #include <rte_log.h>
 #include <rte_branch_prediction.h>
 
+#include "vf_deps.h"
 #include "spp_port.h"
 #include "string_buffer.h"
-#ifdef SPP_VF_MODULE
-#include "../classifier_mac.h"
-#include "../spp_forward.h"
-#endif /* SPP_VF_MODULE */
+
 #ifdef SPP_MIRROR_MODULE
 #include "../../mirror/spp_mirror.h"
 #endif /* SPP_MIRROR_MODULE */
+
 #include "command_conn.h"
 #include "command_dec.h"
 #include "command_proc.h"
@@ -103,6 +102,30 @@ const char *CLASSIFILER_TYPE_STATUS_STRINGS[] = {
 	/* termination */ "",
 };
 
+/* uninitialize classifier. */
+static void
+uninit_classifier(struct management_info *mng_info)
+{
+	int i;
+
+	mng_info->is_used = 0;
+
+	for (i = 0; i < NUM_CLASSIFIER_MAC_INFO; ++i)
+		uninit_component_info(mng_info->cmp_infos + (long)i);
+
+	memset(mng_info, 0, sizeof(struct management_info));
+}
+
+/* initialize classifier information. */
+void
+init_classifier_info(int component_id)
+{
+	struct management_info *mng_info = NULL;
+
+	mng_info = g_mng_infos + component_id;
+	uninit_classifier(mng_info);
+}
+
 /* get client id */
 static int
 spp_get_client_id(void)
@@ -1403,7 +1426,11 @@ struct command_response_list response_result_list[] = {
 	COMMAND_RESP_TAG_LIST_EMPTY
 };
 
-/* TODO(yasufum) add desc why it is needed and how to be used */
+/**
+ * TODO(yasufum) Add desc why it is needed and how to be used. At least, func
+ * name is not appropriate because not for reponse, but name of funcs returns
+ * response.
+ */
 /* command response status information string list */
 struct command_response_list response_info_list[] = {
 	{ "client-id",        append_client_id_value },
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.c b/src/shared/secondary/spp_worker_th/spp_proc.c
index b7c3ec5..8009527 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.c
+++ b/src/shared/secondary/spp_worker_th/spp_proc.c
@@ -11,16 +11,13 @@
 #include <rte_log.h>
 #include <rte_branch_prediction.h>
 
+#include "vf_deps.h"
 #include "spp_proc.h"
 #include "spp_port.h"
 
 #include "shared/secondary/add_port.h"
 #include "shared/secondary/utils.h"
 
-#ifdef SPP_VF_MODULE
-#include "../spp_forward.h"
-#include "../classifier_mac.h"
-#endif /* SPP_VF_MODULE */
 #ifdef SPP_MIRROR_MODULE
 #include "../../mirror/spp_mirror.h"
 #endif /* SPP_MIRROR_MODULE */
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c
index f599731..a7ccd78 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier_mac.c
@@ -13,15 +13,14 @@
 #include <rte_mbuf.h>
 #include <rte_log.h>
 #include <rte_cycles.h>
-#include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_random.h>
 #include <rte_byteorder.h>
 #include <rte_per_lcore.h>
 #include <rte_eal.h>
 #include <rte_launch.h>
-#include <rte_hash.h>
 
+#include "shared/secondary/spp_worker_th/vf_deps.h"
 #include "shared/secondary/spp_worker_th/spp_port.h"
 #include "spp_vf.h"
 #include "classifier_mac.h"
@@ -39,9 +38,6 @@
 /* number of classifier mac table entry */
 #define NUM_CLASSIFIER_MAC_TABLE_ENTRY 128
 
-/* number of classifier information (reference/update) */
-#define NUM_CLASSIFIER_MAC_INFO 2
-
 /* interval that wait until change update index (micro second) */
 #define CHANGE_UPDATE_INDEX_WAIT_INTERVAL SPP_CHANGE_UPDATE_INTERVAL
 
@@ -71,80 +67,8 @@ static const size_t HASH_TABLE_NAME_BUF_SZ =
 static const size_t ETHER_ADDR_STR_BUF_SZ =
 		ETHER_ADDR_LEN * 2 + (ETHER_ADDR_LEN - 1) + 1;
 
-/* classified data (destination port, target packets, etc) */
-struct classified_data {
-	/* interface type (see "enum port_type") */
-	enum port_type  iface_type;
-
-	/* index of ports handled by classifier */
-	int             iface_no;
-
-	/* id for interface generated by spp_vf */
-	int             iface_no_global;
-
-	/* port id generated by DPDK */
-	uint16_t        port;
-
-	/* the number of packets in pkts[] */
-	uint16_t        num_pkt;
-
-	/* packet array to be classified */
-	struct rte_mbuf *pkts[MAX_PKT_BURST];
-};
-
-/* mac address classification */
-struct mac_classification {
-	/* hash table keeps classification */
-	struct rte_hash *classification_tab;
-
-	/* number of valid classification */
-	int num_active_classified;
-
-	/* index of valid classification */
-	int active_classifieds[RTE_MAX_ETHPORTS];
-
-	/* index of default classification */
-	int default_classified;
-};
-
-/* classifier component information */
-struct component_info {
-	/* component name */
-	char name[SPP_NAME_STR_LEN];
-
-	/* mac address entry flag */
-	int mac_addr_entry;
-
-	/* mac address classification per vlan-id */
-	struct mac_classification *mac_classifications[SPP_NUM_VLAN_VID];
-
-	/* number of transmission ports */
-	int n_classified_data_tx;
-
-	/* receive port handled by classifier */
-	struct classified_data classified_data_rx;
-
-	/* transmission ports handled by classifier */
-	struct classified_data classified_data_tx[RTE_MAX_ETHPORTS];
-};
-
-/* classifier management information */
-struct management_info {
-	/* classifier information */
-	struct component_info cmp_infos[NUM_CLASSIFIER_MAC_INFO];
-
-	/* Reference index number for classifier information */
-	volatile int ref_index;
-
-	/* Update index number for classifier information */
-	volatile int upd_index;
-
-	/* used flag */
-	volatile int is_used;
-};
-
 /* classifier information per lcore */
-static struct management_info g_mng_infos[RTE_MAX_LCORE];
+struct management_info g_mng_infos[RTE_MAX_LCORE];
 
 /**
  * Hash table count used for making a name of hash table
@@ -469,21 +393,8 @@ init_component_info(struct component_info *cmp_info,
 	return SPP_RET_OK;
 }
 
-/* free mac classification instance. */
-static inline void
-free_mac_classification(struct mac_classification *mac_cls)
-{
-	if (mac_cls == NULL)
-		return;
-
-	if (mac_cls->classification_tab != NULL)
-		rte_hash_free(mac_cls->classification_tab);
-
-	rte_free(mac_cls);
-}
-
 /* uninitialize classifier information. */
-static void
+void
 uninit_component_info(struct component_info *cmp_info)
 {
 	int i;
@@ -494,20 +405,6 @@ uninit_component_info(struct component_info *cmp_info)
 	memset(cmp_info, 0, sizeof(struct component_info));
 }
 
-/* uninitialize classifier. */
-static void
-uninit_classifier(struct management_info *mng_info)
-{
-	int i;
-
-	mng_info->is_used = 0;
-
-	for (i = 0; i < NUM_CLASSIFIER_MAC_INFO; ++i)
-		uninit_component_info(mng_info->cmp_infos + (long)i);
-
-	memset(mng_info, 0, sizeof(struct management_info));
-}
-
 /* transmit packet to one destination. */
 static inline void
 transmit_packet(struct classified_data *clsd_data)
@@ -761,16 +658,6 @@ spp_classifier_mac_init(void)
 	return 0;
 }
 
-/* initialize classifier information. */
-void
-init_classifier_info(int component_id)
-{
-	struct management_info *mng_info = NULL;
-
-	mng_info = g_mng_infos + component_id;
-	uninit_classifier(mng_info);
-}
-
 /* classifier(mac address) update component info. */
 int
 spp_classifier_mac_update(struct spp_component_info *component_info)
diff --git a/src/vf/classifier_mac.h b/src/vf/classifier_mac.h
index 1671ff0..d3c5ab6 100644
--- a/src/vf/classifier_mac.h
+++ b/src/vf/classifier_mac.h
@@ -15,8 +15,6 @@
  * and determines which port to be transferred to incoming packets.
  */
 
-/* forward declaration */
-struct spp_component_info;
 struct spp_iterate_classifier_table_params;
 
 /**
@@ -36,17 +34,6 @@ int spp_classifier_mac_init(void);
  */
 void init_classifier_info(int component_id);
 
-/**
- * classifier(mac address) update component info.
- *
- * @param component_info
- *  The pointer to struct spp_component_info.@n
- *  The data for updating the internal data of classifier.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_classifier_mac_update(struct spp_component_info *component_info);
 
 /**
  * classifier(mac address) thread function.
@@ -59,25 +46,6 @@ int spp_classifier_mac_update(struct spp_component_info *component_info);
  */
 int spp_classifier_mac_do(int id);
 
-/**
- * classifier get component status.
- *
- *
- * @param lcore_id
- *  The logical core ID for classifier.
- * @param id
- *  The unique component ID.
- * @param params
- *  The pointer to struct spp_iterate_core_params.@n
- *  Detailed data of classifier status.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int
-spp_classifier_get_component_status(unsigned int lcore_id, int id,
-		struct spp_iterate_core_params *params);
-
 /**
  * classifier(mac address) iterate classifier table.
  *
diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c
index 8aaee80..053d7c9 100644
--- a/src/vf/spp_forward.c
+++ b/src/vf/spp_forward.c
@@ -4,6 +4,7 @@
 
 #include <rte_cycles.h>
 
+#include "shared/secondary/spp_worker_th/vf_deps.h"
 #include "shared/secondary/spp_worker_th/spp_port.h"
 #include "spp_vf.h"
 #include "spp_forward.h"
diff --git a/src/vf/spp_forward.h b/src/vf/spp_forward.h
index 14adb0c..4da083c 100644
--- a/src/vf/spp_forward.h
+++ b/src/vf/spp_forward.h
@@ -24,18 +24,6 @@
 /** Clear info */
 void spp_forward_init(void);
 
-/**
- * Update forward info
- *
- * @param component
- *  The pointer to struct spp_component_info.@n
- *  The data for updating the internal data of forwarder and merger.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_forward_update(struct spp_component_info *component);
-
 /**
  * Merge/Forward
  *
@@ -47,22 +35,4 @@ int spp_forward_update(struct spp_component_info *component);
  */
 int spp_forward(int id);
 
-/**
- * Merge/Forward get component status
- *
- * @param lcore_id
- *  The logical core ID for forwarder and merger.
- * @param id
- *  The unique component ID.
- * @param params
- *  The pointer to struct spp_iterate_core_params.@n
- *  Detailed data of forwarder/merger status.
- *
- * @retval SPP_RET_OK succeeded.
- * @retval SPP_RET_NG failed.
- */
-int spp_forward_get_component_status(
-		unsigned int lcore_id, int id,
-		struct spp_iterate_core_params *params);
-
 #endif /* __SPP_FORWARD_H__ */
-- 
2.17.1


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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08  2:00 [spp] [PATCH 0/4] Move vf/common to under shared directory ogawa.yasufumi
2019-05-08  2:00 ` [spp] [PATCH 1/4] spp_vf: move common of vf siblings to shared dir ogawa.yasufumi
2019-05-08  2:00 ` [spp] [PATCH 2/4] spp_vf: update makefile for moved common files ogawa.yasufumi
2019-05-08  2:00 ` [spp] [PATCH 3/4] spp_vf: update include paths ogawa.yasufumi
2019-05-08  2:00 ` ogawa.yasufumi [this message]

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=1557280806-7672-5-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).