From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 5955EA0096 for ; Wed, 8 May 2019 04:02:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 45604378B; Wed, 8 May 2019 04:02:26 +0200 (CEST) Received: from tama500.ecl.ntt.co.jp (tama500.ecl.ntt.co.jp [129.60.39.148]) by dpdk.org (Postfix) with ESMTP id 7987D2082 for ; Wed, 8 May 2019 04:02:23 +0200 (CEST) Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x4822MRQ023032; Wed, 8 May 2019 11:02:22 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 6A416EA705C; Wed, 8 May 2019 11:02:22 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 57ADEEA709B; Wed, 8 May 2019 11:02:22 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Wed, 8 May 2019 11:00:06 +0900 Message-Id: <1557280806-7672-5-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557280806-7672-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1557280806-7672-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 4/4] spp_vf: remove dependency from common functions X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa 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 --- .../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 #include +#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 #include +#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 #include #include -#include #include #include #include #include #include #include -#include +#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 +#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