* [spp] [PATCH] shared/sec: rename struct spp_iterate_core_params
@ 2019-08-02 9:36 Yasufumi Ogawa
0 siblings, 0 replies; only message in thread
From: Yasufumi Ogawa @ 2019-08-02 9:36 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
To simplify, rename struct `spp_iterate_core_params` to
`sppwk_lcore_params`.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/mirror/mir_cmd_runner.c | 18 +++++++--------
src/mirror/spp_mirror.c | 4 ++--
src/mirror/spp_mirror.h | 2 +-
src/pcap/cmd_runner.c | 22 ++++++++----------
src/pcap/spp_pcap.c | 4 ++--
src/pcap/spp_pcap.h | 9 ++++----
.../spp_worker_th/cmd_res_formatter.c | 3 +--
.../spp_worker_th/cmd_res_formatter.h | 2 +-
.../secondary/spp_worker_th/data_types.h | 13 +++++------
src/vf/classifier.c | 5 ++--
src/vf/classifier.h | 2 +-
src/vf/forwarder.c | 9 ++++----
src/vf/forwarder.h | 2 +-
src/vf/vf_cmd_runner.c | 23 ++++++++-----------
14 files changed, 54 insertions(+), 64 deletions(-)
diff --git a/src/mirror/mir_cmd_runner.c b/src/mirror/mir_cmd_runner.c
index 846ac4a..730d75f 100644
--- a/src/mirror/mir_cmd_runner.c
+++ b/src/mirror/mir_cmd_runner.c
@@ -296,7 +296,7 @@ exec_one_cmd(const struct sppwk_cmd_attrs *cmd)
/* Iterate core information to create response to status command */
static int
-spp_iterate_core_info(struct spp_iterate_core_params *params)
+spp_iterate_core_info(struct sppwk_lcore_params *params)
{
int ret;
int lcore_id, cnt;
@@ -310,7 +310,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
core = get_core_info(lcore_id);
if (core->num == 0) {
- ret = (*params->element_proc)(
+ ret = (*params->lcore_proc)(
params, lcore_id,
"", SPPWK_TYPE_NONE_STR,
0, NULL, 0, NULL);
@@ -352,7 +352,7 @@ add_core(const char *name, char **output,
void *tmp __attribute__ ((unused)))
{
int ret = SPPWK_RET_NG;
- struct spp_iterate_core_params itr_params;
+ struct sppwk_lcore_params lcore_params;
char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
if (unlikely(tmp_buff == NULL)) {
RTE_LOG(ERR, MIR_CMD_RUNNER,
@@ -362,17 +362,17 @@ add_core(const char *name, char **output,
return SPPWK_RET_NG;
}
- itr_params.output = tmp_buff;
- itr_params.element_proc = append_core_element_value;
+ lcore_params.output = tmp_buff;
+ lcore_params.lcore_proc = append_core_element_value;
- ret = spp_iterate_core_info(&itr_params);
+ ret = spp_iterate_core_info(&lcore_params);
if (unlikely(ret != SPPWK_RET_OK)) {
- spp_strbuf_free(itr_params.output);
+ spp_strbuf_free(lcore_params.output);
return SPPWK_RET_NG;
}
- ret = append_json_array_brackets(output, name, itr_params.output);
- spp_strbuf_free(itr_params.output);
+ ret = append_json_array_brackets(output, name, lcore_params.output);
+ spp_strbuf_free(lcore_params.output);
return ret;
}
diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index 6cf7b93..96906fb 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -665,7 +665,7 @@ main(int argc, char *argv[])
/* Mirror get component status */
int
get_mirror_status(unsigned int lcore_id, int id,
- struct spp_iterate_core_params *params)
+ struct sppwk_lcore_params *params)
{
int ret = SPPWK_RET_NG;
int cnt;
@@ -697,7 +697,7 @@ get_mirror_status(unsigned int lcore_id, int id,
}
/* Set the information with the function specified by the command. */
- ret = (*params->element_proc)(params, lcore_id, path->name,
+ ret = (*params->lcore_proc)(params, lcore_id, path->name,
component_type, path->nof_rx, rx_ports, path->nof_tx,
tx_ports);
if (unlikely(ret != 0))
diff --git a/src/mirror/spp_mirror.h b/src/mirror/spp_mirror.h
index 6c508cf..dafe114 100644
--- a/src/mirror/spp_mirror.h
+++ b/src/mirror/spp_mirror.h
@@ -23,6 +23,6 @@
* in this file. It is bad dependency for the global variable.
*/
int get_mirror_status(unsigned int lcore_id, int id,
- struct spp_iterate_core_params *params);
+ struct sppwk_lcore_params *params);
#endif /* __SPP_MIRROR_H__ */
diff --git a/src/pcap/cmd_runner.c b/src/pcap/cmd_runner.c
index 10e72bb..63658a5 100644
--- a/src/pcap/cmd_runner.c
+++ b/src/pcap/cmd_runner.c
@@ -66,7 +66,7 @@ const char *CAPTURE_STATUS_STRINGS[] = {
* append response for status command.
*/
static int
-spp_iterate_core_info(struct spp_iterate_core_params *params)
+spp_iterate_core_info(struct sppwk_lcore_params *params)
{
int ret;
int lcore_id;
@@ -449,7 +449,7 @@ append_process_type_value(const char *name, char **output,
static int
append_pcap_core_element_value(
- struct spp_iterate_core_params *params,
+ struct sppwk_lcore_params *params,
const unsigned int lcore_id,
const char *name, const char *type,
const int num_rx,
@@ -513,27 +513,25 @@ append_core_value(const char *name, char **output,
void *tmp __attribute__ ((unused)))
{
int ret = SPPWK_RET_NG;
- struct spp_iterate_core_params itr_params;
+ struct sppwk_lcore_params lcore_params;
char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
if (unlikely(tmp_buff == NULL)) {
- RTE_LOG(ERR, PCAP_RUNNER,
- "allocate error. (name = %s)\n",
- name);
+ RTE_LOG(ERR, PCAP_RUNNER, "Failed to alloc buff.\n");
return SPPWK_RET_NG;
}
- itr_params.output = tmp_buff;
- itr_params.element_proc = append_pcap_core_element_value;
+ lcore_params.output = tmp_buff;
+ lcore_params.lcore_proc = append_pcap_core_element_value;
- ret = spp_iterate_core_info(&itr_params);
+ ret = spp_iterate_core_info(&lcore_params);
if (unlikely(ret != SPPWK_RET_OK)) {
- spp_strbuf_free(itr_params.output);
+ spp_strbuf_free(lcore_params.output);
return SPPWK_RET_NG;
}
- ret = append_json_array_brackets(name, output, itr_params.output);
- spp_strbuf_free(itr_params.output);
+ ret = append_json_array_brackets(name, output, lcore_params.output);
+ spp_strbuf_free(lcore_params.output);
return ret;
}
diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c
index 58a2c52..7f8d60a 100644
--- a/src/pcap/spp_pcap.c
+++ b/src/pcap/spp_pcap.c
@@ -369,7 +369,7 @@ parse_app_args(int argc, char *argv[])
int
spp_pcap_get_core_status(
unsigned int lcore_id,
- struct spp_iterate_core_params *params)
+ struct sppwk_lcore_params *params)
{
char role_type[8];
struct pcap_mng_info *info = &g_pcap_info[lcore_id];
@@ -396,7 +396,7 @@ spp_pcap_get_core_status(
}
/* Set information with specified by the command. */
- res = (*params->element_proc)(params, lcore_id, name, role_type,
+ res = (*params->lcore_proc)(params, lcore_id, name, role_type,
rx_num, rx_ports, 0, NULL);
if (unlikely(res != 0))
return SPPWK_RET_NG;
diff --git a/src/pcap/spp_pcap.h b/src/pcap/spp_pcap.h
index b23fbbc..194e622 100644
--- a/src/pcap/spp_pcap.h
+++ b/src/pcap/spp_pcap.h
@@ -10,16 +10,15 @@
/**
* Pcap get core status
*
- * @param lcore_id The logical core ID for forwarder and merger.
- * @param params
- * The pointer to struct spp_iterate_core_params.@n
- * Detailed data of pcap status.
+ * @param lcore_id Lcore ID.
+ * @param params Pointer to struct sppwk_lcore_params.
*
* @retval SPPWK_RET_OK succeeded.
* @retval SPPWK_RET_NG failed.
*/
+/* TODO(yasufum) consider to move spp_pcap.c. */
int spp_pcap_get_core_status(
unsigned int lcore_id,
- struct spp_iterate_core_params *params);
+ struct sppwk_lcore_params *params);
#endif /* __SPP_PCAP_H__ */
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
index c6a9e3c..85b48af 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c
@@ -278,8 +278,7 @@ append_port_array(const char *name, char **output, const int num,
*/
/* append one element of core information for JSON format */
int
-append_core_element_value(
- struct spp_iterate_core_params *params,
+append_core_element_value(struct sppwk_lcore_params *params,
const unsigned int lcore_id,
const char *name, const char *type,
const int num_rx, const struct sppwk_port_idx *rx_ports,
diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
index 34491d4..393b607 100644
--- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
+++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h
@@ -48,7 +48,7 @@ int append_port_array(const char *name, char **output, const int num,
const struct sppwk_port_idx *ports,
const enum sppwk_port_dir dir);
-int append_core_element_value(struct spp_iterate_core_params *params,
+int append_core_element_value(struct sppwk_lcore_params *params,
const unsigned int lcore_id,
const char *name, const char *type,
const int num_rx, const struct sppwk_port_idx *rx_ports,
diff --git a/src/shared/secondary/spp_worker_th/data_types.h b/src/shared/secondary/spp_worker_th/data_types.h
index f6dd60f..57bf182 100644
--- a/src/shared/secondary/spp_worker_th/data_types.h
+++ b/src/shared/secondary/spp_worker_th/data_types.h
@@ -125,14 +125,13 @@ struct iface_info {
struct sppwk_port_info ring[RTE_MAX_ETHPORTS];
};
-/* TODO(yasufum) revise using term `iterate`, or comments. */
-struct spp_iterate_core_params;
+struct sppwk_lcore_params;
/**
* Define func to iterate lcore to list core information for showing status
- * or so, as a member of struct `spp_iterate_core_params`.
+ * or so, as a member of struct `sppwk_lcore_params`.
*/
-typedef int (*spp_iterate_core_element_proc)(
- struct spp_iterate_core_params *params,
+typedef int (*sppwk_lcore_proc)(
+ struct sppwk_lcore_params *params,
const unsigned int lcore_id,
const char *wk_name, /* Name of worker named as component. */
const char *wk_type, /* Type of worker named as component. */
@@ -146,10 +145,10 @@ typedef int (*spp_iterate_core_element_proc)(
* showing status or so.
*/
/* TODO(yasufum) refactor name of func and vars, and comments. */
-struct spp_iterate_core_params {
+struct sppwk_lcore_params {
char *output; /* Buffer used for output */
/** The function for creating core information */
- spp_iterate_core_element_proc element_proc;
+ sppwk_lcore_proc lcore_proc;
};
#endif /* __SPPWK_DATA_TYPES_H__ */
diff --git a/src/vf/classifier.c b/src/vf/classifier.c
index 5743051..622c102 100644
--- a/src/vf/classifier.c
+++ b/src/vf/classifier.c
@@ -801,7 +801,7 @@ classify_packets(int comp_id)
/* classifier iterate component information */
int
get_classifier_status(unsigned int lcore_id, int id,
- struct spp_iterate_core_params *lcore_params)
+ struct sppwk_lcore_params *lcore_params)
{
int ret = SPPWK_RET_NG;
int i;
@@ -839,8 +839,7 @@ get_classifier_status(unsigned int lcore_id, int id,
}
/* Set the information with the function specified by the command. */
- /* TODO(yasufum) rename `element_proc` */
- ret = (*lcore_params->element_proc)(
+ ret = (*lcore_params->lcore_proc)(
lcore_params, lcore_id, cmp_info->name, SPPWK_TYPE_CLS_STR,
nof_rx, rx_ports, nof_tx, tx_ports);
if (unlikely(ret != SPPWK_RET_OK))
diff --git a/src/vf/classifier.h b/src/vf/classifier.h
index 27bbe9a..2f1eb91 100644
--- a/src/vf/classifier.h
+++ b/src/vf/classifier.h
@@ -100,6 +100,6 @@ int classify_packets(int comp_id);
* in this file. It is bad dependency for the global variable.
*/
int get_classifier_status(unsigned int lcore_id, int id,
- struct spp_iterate_core_params *params);
+ struct sppwk_lcore_params *params);
#endif /* _CLASSIFIER_MAC_H_ */
diff --git a/src/vf/forwarder.c b/src/vf/forwarder.c
index b019d6c..20c2084 100644
--- a/src/vf/forwarder.c
+++ b/src/vf/forwarder.c
@@ -56,7 +56,7 @@ init_forwarder(void)
/* Get forwarder status. */
int
get_forwarder_status(unsigned int lcore_id, int id,
- struct spp_iterate_core_params *params)
+ struct sppwk_lcore_params *params)
{
int ret = SPPWK_RET_NG;
int cnt;
@@ -92,10 +92,9 @@ get_forwarder_status(unsigned int lcore_id, int id,
}
/* Set the information with the function specified by the command. */
- ret = (*params->element_proc)(
- params, lcore_id,
- fwd_path->name, component_type,
- fwd_path->nof_rx, rx_ports, fwd_path->nof_tx, tx_ports);
+ ret = (*params->lcore_proc)(params, lcore_id, fwd_path->name,
+ component_type, fwd_path->nof_rx, rx_ports,
+ fwd_path->nof_tx, tx_ports);
if (unlikely(ret != SPPWK_RET_OK))
return SPPWK_RET_NG;
diff --git a/src/vf/forwarder.h b/src/vf/forwarder.h
index 606e5da..fe36934 100644
--- a/src/vf/forwarder.h
+++ b/src/vf/forwarder.h
@@ -55,6 +55,6 @@ int forward_packets(int id);
*/
int
get_forwarder_status(unsigned int lcore_id, int id,
- struct spp_iterate_core_params *params);
+ struct sppwk_lcore_params *params);
#endif /* __SPP_FORWARD_H__ */
diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c
index 7d3db66..c94288a 100644
--- a/src/vf/vf_cmd_runner.c
+++ b/src/vf/vf_cmd_runner.c
@@ -430,7 +430,7 @@ exec_one_cmd(const struct sppwk_cmd_attrs *cmd)
/* Iterate core information to create response to status command */
static int
-spp_iterate_core_info(struct spp_iterate_core_params *params)
+spp_iterate_core_info(struct sppwk_lcore_params *params)
{
int ret;
int lcore_id, cnt;
@@ -444,7 +444,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
core = get_core_info(lcore_id);
if (core->num == 0) {
- ret = (*params->element_proc)(
+ ret = (*params->lcore_proc)(
params, lcore_id,
"", SPPWK_TYPE_NONE_STR,
0, NULL, 0, NULL);
@@ -492,27 +492,24 @@ add_core(const char *name, char **output,
void *tmp __attribute__ ((unused)))
{
int ret = SPPWK_RET_NG;
- struct spp_iterate_core_params itr_params;
+ struct sppwk_lcore_params lcore_params;
char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
if (unlikely(tmp_buff == NULL)) {
- RTE_LOG(ERR, VF_CMD_RUNNER,
- /* TODO(yasufum) refactor no meaning err msg */
- "allocate error. (name = %s)\n",
- name);
+ RTE_LOG(ERR, VF_CMD_RUNNER, "Failed to alloc buff.\n");
return SPPWK_RET_NG;
}
- itr_params.output = tmp_buff;
- itr_params.element_proc = append_core_element_value;
+ lcore_params.output = tmp_buff;
+ lcore_params.lcore_proc = append_core_element_value;
- ret = spp_iterate_core_info(&itr_params);
+ ret = spp_iterate_core_info(&lcore_params);
if (unlikely(ret != SPPWK_RET_OK)) {
- spp_strbuf_free(itr_params.output);
+ spp_strbuf_free(lcore_params.output);
return SPPWK_RET_NG;
}
- ret = append_json_array_brackets(output, name, itr_params.output);
- spp_strbuf_free(itr_params.output);
+ ret = append_json_array_brackets(output, name, lcore_params.output);
+ spp_strbuf_free(lcore_params.output);
return ret;
}
--
2.17.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-08-02 9:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-02 9:36 [spp] [PATCH] shared/sec: rename struct spp_iterate_core_params 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).