From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E713A10DA for ; Fri, 2 Aug 2019 11:34:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 48AA01C243; Fri, 2 Aug 2019 11:34:13 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id A29621C243 for ; Fri, 2 Aug 2019 11:34:12 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id k189so16740299pgk.13 for ; Fri, 02 Aug 2019 02:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=A3sXfRX5GL8JGP38eGRZJwx+VadJvUnGGaeBlUEapZU=; b=nljFUE8G6Bbc1QRZIKqI4l7doRPVYDlik+Y+8SGxZigU9/EjmkovQ2Jv7qepXjU/AJ n1a8trmYtiQOqRHSK7ZkpLY1fTn4OZiv1ia5rWu4VTJq0ijibuYzG27MRmFfKPtrCgM0 Al5qGj4LfnakJMz5kjQz27Y8M4O+EWW3rdPxSbLisizGNDahsy9SI6l8KMUGGAyAryye iG2AGl8WFrv2Khi5x5M9YfGtY0ldEwjvQAC2tv6ObzWBoMnvRPcdYta57VKvfb5ocp+V p6Le5JWA+VYQ7YOxIicEeUir67ZSEZcI36wtjvxvl2OtXT/sptKy7h2TYVKAUJ3zknb4 /mOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=A3sXfRX5GL8JGP38eGRZJwx+VadJvUnGGaeBlUEapZU=; b=JqzOALuPxqc1BKYKbxL8XfYk6rirH7Har0M/muVmEW2FR/YcgWxZo+F3M7p/5bOZCo iG8YHGEKKcv6Zr6dUE3XksCRupGWXGR2uQ3bJuN9IfEMKRl645qvJf3ksRPqL4ze68zH sKu6b4KRLOLKpru6ug1MAy6H+KkJFmSohnnuqB/+SZ1eCPH9YJljFpoGAi4HtcBZcf66 /++67N78nIddEl091fd8bZVKoFJBnFqO9YYK8RtIfDO43vpO/hXNt2Qwf96J6ZLKLHL0 ESKmMcUgYbFwk4J/SiEW7mpBUx780cxPAPXFFYML1KV10tu9R2nCwyCXnWdlgFGjZnjv FPMg== X-Gm-Message-State: APjAAAWeoeyGpuv/y/MH9qJd2ZUBkYdi3wTPs5Mp0s3U/t5Yp58RdSnZ oKrkGWrPm466+n8cG88bjut6HTJC X-Google-Smtp-Source: APXvYqwMNNz5tciUSeV+0OVIpe70RMPHRJdvtTd7JabpXr1lflmje+NsBccUy47ICKC0jQlKUbcxtQ== X-Received: by 2002:a63:c03:: with SMTP id b3mr60247004pgl.23.1564738451718; Fri, 02 Aug 2019 02:34:11 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c8c2:de00:9c1a:eba9:3129:63d2]) by smtp.gmail.com with ESMTPSA id n10sm1458509pgv.67.2019.08.02.02.34.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 02:34:11 -0700 (PDT) From: Yasufumi Ogawa To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Fri, 2 Aug 2019 18:33:57 +0900 Message-Id: <20190802093358.13696-6-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190802093358.13696-1-yasufum.o@gmail.com> References: <20190802093358.13696-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c 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" This update is to refactor following variables and comments. * Replace ambiguous `NOF_CLS_INFO` with shared `TWO_SIDES`. * Rename `g_mng_infos` to `cls_mng_info_list`. Signed-off-by: Yasufumi Ogawa --- src/vf/classifier.c | 59 ++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/src/vf/classifier.c b/src/vf/classifier.c index 9cc0a2c..233c780 100644 --- a/src/vf/classifier.c +++ b/src/vf/classifier.c @@ -44,9 +44,6 @@ #define DEFAULT_HASH_FUNC rte_jhash #endif -/* number of classifier information (reference/update) */ -#define NOF_CLS_INFO 2 - /* number of classifier mac table entry */ #define NOF_CLS_TABLE_ENTRIES 128 @@ -67,20 +64,14 @@ /* classifier management information */ struct cls_mng_info { - /* classifier information */ - struct cls_comp_info cmp_infos[NOF_CLS_INFO]; - - /* Reference index number for classifier information */ - volatile int ref_index; - - /* Update index number for classifier information */ - volatile int upd_index; - - /* used flag */ + struct cls_comp_info cmp_infos[TWO_SIDES]; + volatile int ref_index; /* Flag for ref side */ + volatile int upd_index; /* Flag for update side */ volatile int is_used; }; -struct cls_mng_info g_mng_infos[RTE_MAX_LCORE]; +/* classifier information per lcore */ +struct cls_mng_info cls_mng_info_list[RTE_MAX_LCORE]; /* uninitialize classifier. */ static void @@ -90,7 +81,7 @@ uninit_classifier(struct cls_mng_info *mng_info) mng_info->is_used = 0; - for (i = 0; i < NOF_CLS_INFO; ++i) + for (i = 0; i < TWO_SIDES; ++i) uninit_component_info(mng_info->cmp_infos + (long)i); memset(mng_info, 0, sizeof(struct cls_mng_info)); @@ -98,36 +89,32 @@ uninit_classifier(struct cls_mng_info *mng_info) /* initialize classifier information. */ void -init_classifier_info(int component_id) +init_classifier_info(int comp_id) { struct cls_mng_info *mng_info = NULL; - mng_info = g_mng_infos + component_id; + mng_info = cls_mng_info_list + comp_id; uninit_classifier(mng_info); } -/* - * hash table name buffer size - *[reson for value] - * in dpdk's lib/librte_hash/rte_cuckoo_hash.c - * snprintf(ring_name, sizeof(ring_name), "HT_%s", params->name); - * snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name); - * ring_name buffer size is RTE_RING_NAMESIZE - * hash_name buffer size is RTE_HASH_NAMESIZE +/** + * Define the size of name of hash table. + * In `dpdk/lib/librte_hash/rte_cuckoo_hash.c`, RTE_RING_NAMESIZE and + * RTE_HASH_NAMESIZE are defined as `ring_name` and `hash_name`. Both of them + * have prefix `HT_`, so required `-3`. + * - snprintf(ring_name, sizeof(ring_name), "HT_%s", params->name); + * - snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name); */ static const size_t HASH_TABLE_NAME_BUF_SZ = ((RTE_HASH_NAMESIZE < RTE_RING_NAMESIZE) ? RTE_HASH_NAMESIZE : RTE_RING_NAMESIZE) - 3; -/* mac address string(xx:xx:xx:xx:xx:xx) buffer size */ +/* MAC address string(xx:xx:xx:xx:xx:xx) buffer size */ static const size_t ETHER_ADDR_STR_BUF_SZ = ETHER_ADDR_LEN * 2 + (ETHER_ADDR_LEN - 1) + 1; -/* classifier information per lcore */ -struct cls_mng_info g_mng_infos[RTE_MAX_LCORE]; - /** - * Hash table count used for making a name of hash table + * Hash table count used for making a name of hash table. * * This function is required because it is incremented at the time of use, * but since we want to start at 0. @@ -697,7 +684,7 @@ change_classifier_index(struct cls_mng_info *mng_info, int id) RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC, "Core[%u] Change update index.\n", id); mng_info->ref_index = - (mng_info->upd_index + 1) % NOF_CLS_INFO; + (mng_info->upd_index + 1) % TWO_SIDES; } } @@ -705,7 +692,7 @@ change_classifier_index(struct cls_mng_info *mng_info, int id) int init_cls_mng_info(void) { - memset(g_mng_infos, 0, sizeof(g_mng_infos)); + memset(cls_mng_info_list, 0, sizeof(cls_mng_info_list)); return 0; } @@ -715,7 +702,7 @@ update_classifier(struct sppwk_comp_info *wk_comp_info) { int ret; int wk_id = wk_comp_info->comp_id; - struct cls_mng_info *mng_info = g_mng_infos + wk_id; + struct cls_mng_info *mng_info = cls_mng_info_list + wk_id; struct cls_comp_info *cls_info = NULL; RTE_LOG(INFO, SPP_CLASSIFIER_MAC, @@ -757,7 +744,7 @@ spp_classifier_mac_do(int id) { int i; int n_rx; - struct cls_mng_info *mng_info = g_mng_infos + id; + struct cls_mng_info *mng_info = cls_mng_info_list + id; struct cls_comp_info *cmp_info = NULL; struct rte_mbuf *rx_pkts[MAX_PKT_BURST]; @@ -837,7 +824,7 @@ get_classifier_status(unsigned int lcore_id, int id, struct sppwk_port_idx rx_ports[RTE_MAX_ETHPORTS]; struct sppwk_port_idx tx_ports[RTE_MAX_ETHPORTS]; - mng_info = g_mng_infos + id; + mng_info = cls_mng_info_list + id; if (!is_used_mng_info(mng_info)) { RTE_LOG(ERR, SPP_CLASSIFIER_MAC, "Classifier is not used " @@ -953,7 +940,7 @@ add_classifier_table_val( struct cls_port_info *port_info; for (i = 0; i < RTE_MAX_LCORE; i++) { - mng_info = g_mng_infos + i; + mng_info = cls_mng_info_list + i; if (!is_used_mng_info(mng_info)) continue; -- 2.17.1