From: Yasufumi Ogawa <yasufum.o@gmail.com>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c
Date: Fri, 2 Aug 2019 18:33:57 +0900 [thread overview]
Message-ID: <20190802093358.13696-6-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190802093358.13696-1-yasufum.o@gmail.com>
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 <yasufum.o@gmail.com>
---
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
next prev parent reply other threads:[~2019-08-02 9:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-02 9:33 [spp] [PATCH 0/6] Refactor classifier of spp_vf Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 1/6] spp_vf: rename file classifier_mac Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 2/6] spp_vf: rename func spp_classifier_mac_init Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 3/6] spp_vf: remove no meaning int variables Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 4/6] spp_vf: rename management_info to cls_mng_info Yasufumi Ogawa
2019-08-02 9:33 ` Yasufumi Ogawa [this message]
2019-08-02 9:33 ` [spp] [PATCH 6/6] spp_vf: rename spp_classifier_mac_do Yasufumi Ogawa
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=20190802093358.13696-6-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--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).