* [spp] [PATCH 0/6] Refactor classifier of spp_vf
@ 2019-08-02 9:33 Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 1/6] spp_vf: rename file classifier_mac Yasufumi Ogawa
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Yasufumi Ogawa @ 2019-08-02 9:33 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
This series of patch is to refactor classifier of spp_vf by removing
nouse functions, revise names or so.
Yasufumi Ogawa (6):
spp_vf: rename file classifier_mac
spp_vf: rename func spp_classifier_mac_init
spp_vf: remove no meaning int variables
spp_vf: rename management_info to cls_mng_info
spp_vf: refactor variables in classifier.c
spp_vf: rename spp_classifier_mac_do
src/vf/Makefile | 2 +-
src/vf/{classifier_mac.c => classifier.c} | 114 +++++++++-------------
src/vf/{classifier_mac.h => classifier.h} | 12 +--
src/vf/spp_vf.c | 48 +++++----
src/vf/vf_cmd_runner.c | 2 +-
5 files changed, 76 insertions(+), 102 deletions(-)
rename src/vf/{classifier_mac.c => classifier.c} (91%)
rename src/vf/{classifier_mac.h => classifier.h} (90%)
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 1/6] spp_vf: rename file classifier_mac
2019-08-02 9:33 [spp] [PATCH 0/6] Refactor classifier of spp_vf Yasufumi Ogawa
@ 2019-08-02 9:33 ` Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 2/6] spp_vf: rename func spp_classifier_mac_init Yasufumi Ogawa
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Yasufumi Ogawa @ 2019-08-02 9:33 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
This update is to change files named as `classifier_mac` to
`classifier` because claffisication only supports MAC and `_mac` has
no meaning.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/vf/Makefile | 2 +-
src/vf/{classifier_mac.c => classifier.c} | 2 +-
src/vf/{classifier_mac.h => classifier.h} | 0
src/vf/spp_vf.c | 2 +-
src/vf/vf_cmd_runner.c | 2 +-
5 files changed, 4 insertions(+), 4 deletions(-)
rename src/vf/{classifier_mac.c => classifier.c} (99%)
rename src/vf/{classifier_mac.h => classifier.h} (100%)
diff --git a/src/vf/Makefile b/src/vf/Makefile
index 92d2854..5981d62 100644
--- a/src/vf/Makefile
+++ b/src/vf/Makefile
@@ -15,7 +15,7 @@ SPP_SEC_DIR = ../shared/secondary
SPP_WKT_DIR = ../shared/secondary/spp_worker_th
# all source are stored in SRCS-y
-SRCS-y := spp_vf.c classifier_mac.c forwarder.c
+SRCS-y := spp_vf.c classifier.c forwarder.c
SRCS-y += $(SPP_SEC_DIR)/string_buffer.c
SRCS-y += $(SPP_SEC_DIR)/json_helper.c
SRCS-y += $(SPP_SEC_DIR)/utils.c $(SPP_SEC_DIR)/add_port.c
diff --git a/src/vf/classifier_mac.c b/src/vf/classifier.c
similarity index 99%
rename from src/vf/classifier_mac.c
rename to src/vf/classifier.c
index f3be5b6..49c7d01 100644
--- a/src/vf/classifier_mac.c
+++ b/src/vf/classifier.c
@@ -21,7 +21,7 @@
#include <rte_launch.h>
#include <netinet/in.h>
-#include "classifier_mac.h"
+#include "classifier.h"
#include "spp_vf.h"
#include "shared/secondary/return_codes.h"
#include "shared/secondary/string_buffer.h"
diff --git a/src/vf/classifier_mac.h b/src/vf/classifier.h
similarity index 100%
rename from src/vf/classifier_mac.h
rename to src/vf/classifier.h
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index caf4678..2091023 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -7,7 +7,7 @@
#include <getopt.h>
#include "spp_vf.h"
-#include "classifier_mac.h"
+#include "classifier.h"
#include "forwarder.h"
#include "shared/secondary/utils.h"
#include "shared/secondary/spp_worker_th/cmd_utils.h"
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index 16328f4..9536a80 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -2,7 +2,7 @@
* Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
*/
-#include "classifier_mac.h"
+#include "classifier.h"
#include "forwarder.h"
#include "shared/secondary/return_codes.h"
#include "shared/secondary/json_helper.h"
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 2/6] spp_vf: rename func spp_classifier_mac_init
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 ` Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 3/6] spp_vf: remove no meaning int variables Yasufumi Ogawa
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Yasufumi Ogawa @ 2019-08-02 9:33 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
This update is to rename spp_classifier_mac_init() to
init_cls_mng_info() because this function is just to initialize
management info with memset().
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/vf/classifier.c | 2 +-
src/vf/classifier.h | 2 +-
src/vf/spp_vf.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/vf/classifier.c b/src/vf/classifier.c
index 49c7d01..be50916 100644
--- a/src/vf/classifier.c
+++ b/src/vf/classifier.c
@@ -703,7 +703,7 @@ change_classifier_index(struct management_info *mng_info, int id)
/* classifier(mac address) initialize globals. */
int
-spp_classifier_mac_init(void)
+init_cls_mng_info(void)
{
memset(g_mng_infos, 0, sizeof(g_mng_infos));
return 0;
diff --git a/src/vf/classifier.h b/src/vf/classifier.h
index ca8d8da..69cbb88 100644
--- a/src/vf/classifier.h
+++ b/src/vf/classifier.h
@@ -25,7 +25,7 @@ struct spp_iterate_classifier_table_params;
* @retval SPPWK_RET_OK succeeded.
* @retval SPPWK_RET_NG failed.
*/
-int spp_classifier_mac_init(void);
+int init_cls_mng_info(void);
/**
* initialize classifier information.
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index 2091023..e10ae71 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -265,7 +265,7 @@ main(int argc, char *argv[])
if (unlikely(ret_mng != SPPWK_RET_OK))
break;
- int ret_classifier_mac_init = spp_classifier_mac_init();
+ int ret_classifier_mac_init = init_cls_mng_info();
if (unlikely(ret_classifier_mac_init != SPPWK_RET_OK))
break;
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 3/6] spp_vf: remove no meaning int variables
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 ` Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 4/6] spp_vf: rename management_info to cls_mng_info Yasufumi Ogawa
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Yasufumi Ogawa @ 2019-08-02 9:33 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
In main(), there are many no meaning variables for receiveing results
of functions such as `ret_do` or `ret_parse` or so and each of which is
used only one time for checking. It is enough by using `int ret`
defined at the head of the function.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/vf/spp_vf.c | 44 +++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index e10ae71..b2f2af4 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -211,17 +211,16 @@ main(int argc, char *argv[])
int ret;
char ctl_ip[IPADDR_LEN] = { 0 };
int ctl_port;
- int ret_cmd_init;
unsigned int master_lcore;
unsigned int lcore_id;
#ifdef SPP_DEMONIZE
/* Daemonize process */
- int ret_daemon = daemon(0, 0);
- if (unlikely(ret_daemon != 0)) {
+ ret = daemon(0, 0);
+ if (unlikely(ret != 0)) {
RTE_LOG(ERR, APP, "daemonize is failed. (ret = %d)\n",
- ret_daemon);
- return ret_daemon;
+ ret);
+ return ret;
}
#endif
@@ -248,8 +247,8 @@ main(int argc, char *argv[])
*/
while (1) {
/* Parse spp_vf specific parameters */
- int ret_parse = parse_app_args(argc, argv);
- if (unlikely(ret_parse != SPPWK_RET_OK))
+ ret = parse_app_args(argc, argv);
+ if (unlikely(ret != SPPWK_RET_OK))
break;
if (sppwk_set_mng_data(&g_iface_info, g_component_info,
@@ -261,12 +260,12 @@ main(int argc, char *argv[])
break;
}
- int ret_mng = init_mng_data();
- if (unlikely(ret_mng != SPPWK_RET_OK))
+ ret = init_mng_data();
+ if (unlikely(ret != SPPWK_RET_OK))
break;
- int ret_classifier_mac_init = init_cls_mng_info();
- if (unlikely(ret_classifier_mac_init != SPPWK_RET_OK))
+ ret = init_cls_mng_info();
+ if (unlikely(ret != SPPWK_RET_OK))
break;
init_forwarder();
@@ -275,8 +274,8 @@ main(int argc, char *argv[])
/* Setup connection for accepting commands from controller */
get_spp_ctl_ip(ctl_ip);
ctl_port = get_spp_ctl_port();
- ret_cmd_init = sppwk_cmd_runner_conn(ctl_ip, ctl_port);
- if (unlikely(ret_cmd_init != SPPWK_RET_OK))
+ ret = sppwk_cmd_runner_conn(ctl_ip, ctl_port);
+ if (unlikely(ret != SPPWK_RET_OK))
break;
#ifdef SPP_RINGLATENCYSTATS_ENABLE
@@ -291,10 +290,10 @@ main(int argc, char *argv[])
if (port_type == RING)
nof_rings++;
}
- int ret_ringlatency = spp_ringlatencystats_init(
+ ret = spp_ringlatencystats_init(
SPP_RING_LATENCY_STATS_SAMPLING_INTERVAL,
nof_rings);
- if (unlikely(ret_ringlatency != SPPWK_RET_OK))
+ if (unlikely(ret != SPPWK_RET_OK))
break;
#endif /* SPP_RINGLATENCYSTATS_ENABLE */
@@ -305,8 +304,8 @@ main(int argc, char *argv[])
/* Set the status of main thread to idle */
g_core_info[master_lcore].status = SPPWK_LCORE_IDLING;
- int ret_wait = check_core_status_wait(SPPWK_LCORE_IDLING);
- if (unlikely(ret_wait != SPPWK_RET_OK))
+ ret = check_core_status_wait(SPPWK_LCORE_IDLING);
+ if (unlikely(ret != SPPWK_RET_OK))
break;
/* Start forwarding */
@@ -318,7 +317,6 @@ main(int argc, char *argv[])
backup_mng_info(&g_backup_info);
/* Enter loop for accepting commands */
- int ret_do = SPPWK_RET_OK;
#ifndef USE_UT_SPP_VF
while (likely(g_core_info[master_lcore].status !=
SPPWK_LCORE_REQ_STOP)) {
@@ -326,8 +324,8 @@ main(int argc, char *argv[])
{
#endif
/* Receive command */
- ret_do = sppwk_run_cmd();
- if (unlikely(ret_do != SPPWK_RET_OK))
+ ret = sppwk_run_cmd();
+ if (unlikely(ret != SPPWK_RET_OK))
break;
/*
@@ -340,7 +338,7 @@ main(int argc, char *argv[])
#endif /* SPP_RINGLATENCYSTATS_ENABLE */
}
- if (unlikely(ret_do != SPPWK_RET_OK)) {
+ if (unlikely(ret != SPPWK_RET_OK)) {
set_all_core_status(SPPWK_LCORE_REQ_STOP);
break;
}
@@ -351,8 +349,8 @@ main(int argc, char *argv[])
/* Finalize to exit */
g_core_info[master_lcore].status = SPPWK_LCORE_STOPPED;
- int ret_core_end = check_core_status_wait(SPPWK_LCORE_STOPPED);
- if (unlikely(ret_core_end != SPPWK_RET_OK))
+ ret = check_core_status_wait(SPPWK_LCORE_STOPPED);
+ if (unlikely(ret != SPPWK_RET_OK))
RTE_LOG(ERR, APP, "Failed to terminate master thread.\n");
/*
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 4/6] spp_vf: rename management_info to cls_mng_info
2019-08-02 9:33 [spp] [PATCH 0/6] Refactor classifier of spp_vf Yasufumi Ogawa
` (2 preceding siblings ...)
2019-08-02 9:33 ` [spp] [PATCH 3/6] spp_vf: remove no meaning int variables Yasufumi Ogawa
@ 2019-08-02 9:33 ` Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 6/6] spp_vf: rename spp_classifier_mac_do Yasufumi Ogawa
5 siblings, 0 replies; 7+ messages in thread
From: Yasufumi Ogawa @ 2019-08-02 9:33 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
There are several similar definition for management info in spp_vf,
spp_mirror or so, and it is confusing. This patch is to rename
`management_info` used in `classifier.c` to `cls_mng_info` to be more
specific.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/vf/classifier.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/vf/classifier.c b/src/vf/classifier.c
index be50916..9cc0a2c 100644
--- a/src/vf/classifier.c
+++ b/src/vf/classifier.c
@@ -66,7 +66,7 @@
#define CLS_DUMMY_ADDR 0x010000000000
/* classifier management information */
-struct management_info {
+struct cls_mng_info {
/* classifier information */
struct cls_comp_info cmp_infos[NOF_CLS_INFO];
@@ -80,11 +80,11 @@ struct management_info {
volatile int is_used;
};
-struct management_info g_mng_infos[RTE_MAX_LCORE];
+struct cls_mng_info g_mng_infos[RTE_MAX_LCORE];
/* uninitialize classifier. */
static void
-uninit_classifier(struct management_info *mng_info)
+uninit_classifier(struct cls_mng_info *mng_info)
{
int i;
@@ -93,14 +93,14 @@ uninit_classifier(struct management_info *mng_info)
for (i = 0; i < NOF_CLS_INFO; ++i)
uninit_component_info(mng_info->cmp_infos + (long)i);
- memset(mng_info, 0, sizeof(struct management_info));
+ memset(mng_info, 0, sizeof(struct cls_mng_info));
}
/* initialize classifier information. */
void
init_classifier_info(int component_id)
{
- struct management_info *mng_info = NULL;
+ struct cls_mng_info *mng_info = NULL;
mng_info = g_mng_infos + component_id;
uninit_classifier(mng_info);
@@ -124,7 +124,7 @@ static const size_t ETHER_ADDR_STR_BUF_SZ =
ETHER_ADDR_LEN * 2 + (ETHER_ADDR_LEN - 1) + 1;
/* classifier information per lcore */
-struct management_info g_mng_infos[RTE_MAX_LCORE];
+struct cls_mng_info g_mng_infos[RTE_MAX_LCORE];
/**
* Hash table count used for making a name of hash table
@@ -277,7 +277,7 @@ log_entry(
/* check if management information is used. */
static inline int
-is_used_mng_info(const struct management_info *mng_info)
+is_used_mng_info(const struct cls_mng_info *mng_info)
{
return (mng_info != NULL && mng_info->is_used);
}
@@ -684,7 +684,7 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
/* change update index at classifier management information */
static inline void
-change_classifier_index(struct management_info *mng_info, int id)
+change_classifier_index(struct cls_mng_info *mng_info, int id)
{
if (unlikely(mng_info->ref_index ==
mng_info->upd_index)) {
@@ -715,7 +715,7 @@ update_classifier(struct sppwk_comp_info *wk_comp_info)
{
int ret;
int wk_id = wk_comp_info->comp_id;
- struct management_info *mng_info = g_mng_infos + wk_id;
+ struct cls_mng_info *mng_info = g_mng_infos + wk_id;
struct cls_comp_info *cls_info = NULL;
RTE_LOG(INFO, SPP_CLASSIFIER_MAC,
@@ -757,7 +757,7 @@ spp_classifier_mac_do(int id)
{
int i;
int n_rx;
- struct management_info *mng_info = g_mng_infos + id;
+ struct cls_mng_info *mng_info = g_mng_infos + id;
struct cls_comp_info *cmp_info = NULL;
struct rte_mbuf *rx_pkts[MAX_PKT_BURST];
@@ -831,7 +831,7 @@ get_classifier_status(unsigned int lcore_id, int id,
int ret = SPPWK_RET_NG;
int i;
int nof_tx, nof_rx = 0; /* Num of RX and TX ports. */
- struct management_info *mng_info;
+ struct cls_mng_info *mng_info;
struct cls_comp_info *cmp_info;
struct cls_port_info *port_info;
struct sppwk_port_idx rx_ports[RTE_MAX_ETHPORTS];
@@ -948,7 +948,7 @@ add_classifier_table_val(
struct spp_iterate_classifier_table_params *params)
{
int i, vlan_id;
- struct management_info *mng_info;
+ struct cls_mng_info *mng_info;
struct cls_comp_info *cmp_info;
struct cls_port_info *port_info;
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c
2019-08-02 9:33 [spp] [PATCH 0/6] Refactor classifier of spp_vf Yasufumi Ogawa
` (3 preceding siblings ...)
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
2019-08-02 9:33 ` [spp] [PATCH 6/6] spp_vf: rename spp_classifier_mac_do Yasufumi Ogawa
5 siblings, 0 replies; 7+ messages in thread
From: Yasufumi Ogawa @ 2019-08-02 9:33 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [spp] [PATCH 6/6] spp_vf: rename spp_classifier_mac_do
2019-08-02 9:33 [spp] [PATCH 0/6] Refactor classifier of spp_vf Yasufumi Ogawa
` (4 preceding siblings ...)
2019-08-02 9:33 ` [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c Yasufumi Ogawa
@ 2019-08-02 9:33 ` Yasufumi Ogawa
5 siblings, 0 replies; 7+ messages in thread
From: Yasufumi Ogawa @ 2019-08-02 9:33 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
Function spp_classifier_mac_do() is for classification incoming packets
on each of threads, but the name is not intuitive. This udpate is to
rename this function simply to classify_packets().
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/vf/classifier.c | 37 ++++++++++++++-----------------------
src/vf/classifier.h | 10 ++++------
src/vf/spp_vf.c | 2 +-
3 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/src/vf/classifier.c b/src/vf/classifier.c
index 233c780..b85dd79 100644
--- a/src/vf/classifier.c
+++ b/src/vf/classifier.c
@@ -87,7 +87,7 @@ uninit_classifier(struct cls_mng_info *mng_info)
memset(mng_info, 0, sizeof(struct cls_mng_info));
}
-/* initialize classifier information. */
+/* Initialize classifier information. */
void
init_classifier_info(int comp_id)
{
@@ -445,7 +445,7 @@ uninit_component_info(struct cls_comp_info *comp_info)
/* transmit packet to one destination. */
static inline void
-transmit_packet(struct cls_port_info *clsd_data)
+transmit_packets(struct cls_port_info *clsd_data)
{
int i;
uint16_t n_tx;
@@ -488,7 +488,7 @@ transmit_all_packet(struct cls_comp_info *cmp_info)
"nof_pkts=%hu\n",
i,
clsd_data_tx[i].nof_pkts);
- transmit_packet(&clsd_data_tx[i]);
+ transmit_packets(&clsd_data_tx[i]);
}
}
}
@@ -510,7 +510,7 @@ push_packet(struct rte_mbuf *pkt, struct cls_port_info *clsd_data)
clsd_data->iface_no,
clsd_data->ethdev_port_id,
clsd_data->nof_pkts);
- transmit_packet(clsd_data);
+ transmit_packets(clsd_data);
}
}
@@ -634,12 +634,8 @@ select_classified_index(const struct rte_mbuf *pkt,
return mac_cls->default_cls_idx;
}
-/*
- * classify packet by destination mac address,
- * and transmit packet (conditional).
- */
static inline void
-classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
+_classify_packets(struct rte_mbuf **rx_pkts, uint16_t n_rx,
struct cls_comp_info *cmp_info,
struct cls_port_info *clsd_data)
{
@@ -669,6 +665,7 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx,
}
}
+/* TODO(yasufum) Revise this comment and name of func. */
/* change update index at classifier management information */
static inline void
change_classifier_index(struct cls_mng_info *mng_info, int id)
@@ -738,13 +735,13 @@ update_classifier(struct sppwk_comp_info *wk_comp_info)
return SPPWK_RET_OK;
}
-/* classifier(mac address) thread function. */
+/* Classify incoming packets on a thread of given `comp_id`. */
int
-spp_classifier_mac_do(int id)
+classify_packets(int comp_id)
{
int i;
int n_rx;
- struct cls_mng_info *mng_info = cls_mng_info_list + id;
+ struct cls_mng_info *mng_info = cls_mng_info_list + comp_id;
struct cls_comp_info *cmp_info = NULL;
struct rte_mbuf *rx_pkts[MAX_PKT_BURST];
@@ -756,23 +753,18 @@ spp_classifier_mac_do(int id)
US_PER_S * DRAIN_TX_PACKET_INTERVAL;
/* change index of update classifier management information */
- change_classifier_index(mng_info, id);
+ change_classifier_index(mng_info, comp_id);
cmp_info = mng_info->cmp_infos + mng_info->ref_index;
clsd_data_rx = &cmp_info->rx_port_i;
clsd_data_tx = cmp_info->tx_ports_i;
- /**
- * decide classifier information of the current cycle If at least,
- * one rx port, one tx port and one classifier_table exist, then start
- * classifying. If not, stop classifying.
- */
+ /* Check if it is ready to do classifying. */
if (!(clsd_data_rx->iface_type != UNDEF &&
cmp_info->nof_tx_ports >= 1 &&
cmp_info->mac_addr_entry == 1))
return SPPWK_RET_OK;
- /* drain tx packets, if buffer is not filled for interval */
cur_tsc = rte_rdtsc();
if (unlikely(cur_tsc - prev_tsc > drain_tsc)) {
for (i = 0; i < cmp_info->nof_tx_ports; i++) {
@@ -784,7 +776,7 @@ spp_classifier_mac_do(int id)
"nof_pkts=%hu, interval=%lu\n",
i, clsd_data_tx[i].nof_pkts,
cur_tsc - prev_tsc);
- transmit_packet(&clsd_data_tx[i]);
+ transmit_packets(&clsd_data_tx[i]);
}
prev_tsc = cur_tsc;
}
@@ -792,7 +784,7 @@ spp_classifier_mac_do(int id)
if (clsd_data_rx->iface_type == UNDEF)
return SPPWK_RET_OK;
- /* retrieve packets */
+ /* Retrieve packets */
#ifdef SPP_RINGLATENCYSTATS_ENABLE
n_rx = sppwk_eth_vlan_ring_stats_rx_burst(clsd_data_rx->ethdev_port_id,
clsd_data_rx->iface_type, clsd_data_rx->iface_no,
@@ -804,8 +796,7 @@ spp_classifier_mac_do(int id)
if (unlikely(n_rx == 0))
return SPPWK_RET_OK;
- /* classify and interval that transmit burst packet */
- classify_packet(rx_pkts, n_rx, cmp_info, clsd_data_tx);
+ _classify_packets(rx_pkts, n_rx, cmp_info, clsd_data_tx);
return SPPWK_RET_OK;
}
diff --git a/src/vf/classifier.h b/src/vf/classifier.h
index 69cbb88..0f28a51 100644
--- a/src/vf/classifier.h
+++ b/src/vf/classifier.h
@@ -34,19 +34,17 @@ int init_cls_mng_info(void);
* The unique component ID.
*
*/
-void init_classifier_info(int component_id);
+void init_classifier_info(int comp_id);
/**
- * classifier(mac address) thread function.
- *
- * @param id
- * The unique component ID.
+ * Classify incoming packets.
*
+ * @param id Component ID.
* @retval SPPWK_RET_OK succeeded.
* @retval SPPWK_RET_NG failed.
*/
-int spp_classifier_mac_do(int id);
+int classify_packets(int comp_id);
/**
* classifier(mac address) iterate classifier table.
diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index b2f2af4..a86acec 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -177,7 +177,7 @@ slave_main(void *arg __attribute__ ((unused)))
if (spp_get_component_type(core->id[cnt]) ==
SPPWK_TYPE_CLS) {
/* Component type for classifier. */
- ret = spp_classifier_mac_do(core->id[cnt]);
+ ret = classify_packets(core->id[cnt]);
if (unlikely(ret != 0))
break;
} else {
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-08-02 9:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c Yasufumi Ogawa
2019-08-02 9:33 ` [spp] [PATCH 6/6] spp_vf: rename spp_classifier_mac_do Yasufumi Ogawa
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).