From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 2/4] spp_mirror: unify return codes
Date: Mon, 22 Jul 2019 10:38:44 +0900 [thread overview]
Message-ID: <20190722013846.18618-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190722013846.18618-1-yasufum.o@gmail.com>
From: Yasufumi Ogawa <yasufum.o@gmail.com>
Change return codes of SPP_RET_OK and SPP_RET_NG to SPPWK_RET_OK and
SPPWK_RET_NG to unify the return codes.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/mirror/mir_cmd_runner.c | 64 ++++++++++++++++++-------------------
src/mirror/spp_mirror.c | 58 ++++++++++++++++-----------------
src/mirror/spp_mirror.h | 4 +--
3 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/src/mirror/mir_cmd_runner.c b/src/mirror/mir_cmd_runner.c
index 3f90e9a..572fb43 100644
--- a/src/mirror/mir_cmd_runner.c
+++ b/src/mirror/mir_cmd_runner.c
@@ -44,21 +44,21 @@ update_comp(enum sppwk_action wk_action, const char *name,
RTE_LOG(ERR, MIR_CMD_RUNNER,
"Not available lcore %d for %s.\n",
lcore_id, "SPPWK_LCORE_UNUSED");
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
comp_lcore_id = sppwk_get_lcore_id(name);
if (comp_lcore_id >= 0) {
RTE_LOG(ERR, MIR_CMD_RUNNER, "Component name '%s' is already "
"used.\n", name);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
comp_lcore_id = get_free_lcore_id();
if (comp_lcore_id < 0) {
RTE_LOG(ERR, MIR_CMD_RUNNER, "Cannot assign component over the "
"maximum number.\n");
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
core = &info->core[info->upd_index];
@@ -72,7 +72,7 @@ update_comp(enum sppwk_action wk_action, const char *name,
core->id[core->num] = comp_lcore_id;
core->num++;
- ret = SPP_RET_OK;
+ ret = SPPWK_RET_OK;
tmp_lcore_id = lcore_id;
*(change_component + comp_lcore_id) = 1;
break;
@@ -80,7 +80,7 @@ update_comp(enum sppwk_action wk_action, const char *name,
case SPPWK_ACT_STOP:
comp_lcore_id = sppwk_get_lcore_id(name);
if (comp_lcore_id < 0)
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
comp_info = (comp_info_base + comp_lcore_id);
tmp_lcore_id = comp_info->lcore_id;
@@ -94,12 +94,12 @@ update_comp(enum sppwk_action wk_action, const char *name,
if (ret_del >= 0)
core->num--;
- ret = SPP_RET_OK;
+ ret = SPPWK_RET_OK;
*(change_component + comp_lcore_id) = 0;
break;
default: /* Unexpected case. */
- ret = SPP_RET_NG;
+ ret = SPPWK_RET_NG;
break;
}
@@ -122,9 +122,9 @@ check_mir_port_count(enum sppwk_port_dir dir, int nof_rx, int nof_tx)
" port_type=%d, rx=%d, tx=%d\n",
dir, nof_rx, nof_tx);
if (nof_rx > 1 || nof_tx > 2)
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
/* Port add or del to execute it */
@@ -135,7 +135,7 @@ update_port(enum sppwk_action wk_action,
const char *name,
const struct sppwk_port_attrs *port_attrs)
{
- int ret = SPP_RET_NG;
+ int ret = SPPWK_RET_NG;
int port_idx;
int ret_del = -1;
int comp_lcore_id = 0;
@@ -151,7 +151,7 @@ update_port(enum sppwk_action wk_action,
if (comp_lcore_id < 0) {
RTE_LOG(ERR, MIR_CMD_RUNNER, "Unknown component by port command. "
"(component = %s)\n", name);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
sppwk_get_mng_data(NULL, &comp_info_base, NULL, NULL,
&change_component, NULL);
@@ -169,12 +169,12 @@ update_port(enum sppwk_action wk_action,
case SPPWK_ACT_ADD:
/* Check if over the maximum num of ports of component. */
if (check_mir_port_count(dir, comp_info->nof_rx,
- comp_info->nof_tx) != SPP_RET_OK)
- return SPP_RET_NG;
+ comp_info->nof_tx) != SPPWK_RET_OK)
+ return SPPWK_RET_NG;
/* Check if the port_info is included in array `ports`. */
port_idx = get_idx_port_info(port_info, *nof_ports, ports);
- if (port_idx >= SPP_RET_OK) {
+ if (port_idx >= SPPWK_RET_OK) {
/* registered */
/* TODO(yasufum) confirm it is needed for spp_mirror. */
if (port_attrs->ops == SPPWK_PORT_OPS_ADD_VLAN) {
@@ -185,21 +185,21 @@ update_port(enum sppwk_action wk_action,
if (cnt >= PORT_ABL_MAX) {
RTE_LOG(ERR, MIR_CMD_RUNNER, "update VLAN tag "
"Non-registratio\n");
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
memcpy(&port_info->port_attrs[cnt], port_attrs,
sizeof(struct sppwk_port_attrs));
- ret = SPP_RET_OK;
+ ret = SPPWK_RET_OK;
break;
}
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
if (*nof_ports >= RTE_MAX_ETHPORTS) {
RTE_LOG(ERR, MIR_CMD_RUNNER, "Cannot assign port over the "
"maximum number.\n");
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
if (port_attrs->ops != SPPWK_PORT_OPS_NONE) {
@@ -211,7 +211,7 @@ update_port(enum sppwk_action wk_action,
if (cnt >= PORT_ABL_MAX) {
RTE_LOG(ERR, MIR_CMD_RUNNER,
"No space of port port_attrs.\n");
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
memcpy(&port_info->port_attrs[cnt], port_attrs,
sizeof(struct sppwk_port_attrs));
@@ -221,7 +221,7 @@ update_port(enum sppwk_action wk_action,
ports[*nof_ports] = port_info;
(*nof_ports)++;
- ret = SPP_RET_OK;
+ ret = SPPWK_RET_OK;
break;
case SPPWK_ACT_DEL:
@@ -239,11 +239,11 @@ update_port(enum sppwk_action wk_action,
if (ret_del == 0)
(*nof_ports)--; /* If deleted, decrement number. */
- ret = SPP_RET_OK;
+ ret = SPPWK_RET_OK;
break;
default: /* This case cannot be happend without invlid wk_action. */
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
*(change_component + comp_lcore_id) = 1;
@@ -287,7 +287,7 @@ exec_one_cmd(const struct sppwk_cmd_attrs *cmd)
default:
/* Do nothing. */
- ret = SPP_RET_OK;
+ ret = SPPWK_RET_OK;
break;
}
@@ -320,7 +320,7 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
"information. "
"(core = %d, type = %d)\n",
lcore_id, SPPWK_TYPE_NONE);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
continue;
}
@@ -338,12 +338,12 @@ spp_iterate_core_info(struct spp_iterate_core_params *params)
"information. "
"(core = %d, type = %d)\n",
lcore_id, comp_info->wk_type);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
}
}
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
/* Add entry of core info of worker to a response in JSON such as "core:0". */
@@ -351,7 +351,7 @@ int
add_core(const char *name, char **output,
void *tmp __attribute__ ((unused)))
{
- int ret = SPP_RET_NG;
+ int ret = SPPWK_RET_NG;
struct spp_iterate_core_params itr_params;
char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE);
if (unlikely(tmp_buff == NULL)) {
@@ -359,16 +359,16 @@ add_core(const char *name, char **output,
/* TODO(yasufum) refactor no meaning err msg */
"allocate error. (name = %s)\n",
name);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
itr_params.output = tmp_buff;
itr_params.element_proc = append_core_element_value;
ret = spp_iterate_core_info(&itr_params);
- if (unlikely(ret != SPP_RET_OK)) {
+ if (unlikely(ret != SPPWK_RET_OK)) {
spp_strbuf_free(itr_params.output);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
ret = append_json_array_brackets(output, name, itr_params.output);
@@ -399,10 +399,10 @@ update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp)
"( component = %s, type = %d)\n",
comp_info->name,
comp_info->wk_type);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
}
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
/* Get component type from string of its name. */
diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c
index 4b62349..f5cdefb 100644
--- a/src/mirror/spp_mirror.c
+++ b/src/mirror/spp_mirror.c
@@ -142,9 +142,9 @@ parse_app_args(int argc, char *argv[])
&option_index)) != EOF) {
switch (opt) {
case SPP_LONGOPT_RETVAL_CLIENT_ID:
- if (parse_client_id(&cli_id, optarg) != SPP_RET_OK) {
+ if (parse_client_id(&cli_id, optarg) != SPPWK_RET_OK) {
usage(progname);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
set_client_id(cli_id);
@@ -155,9 +155,9 @@ parse_app_args(int argc, char *argv[])
break;
case 's':
ret = parse_server(&ctl_ip, &ctl_port, optarg);
- if (ret != SPP_RET_OK) {
+ if (ret != SPPWK_RET_OK) {
usage(progname);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
set_spp_ctl_ip(ctl_ip);
set_spp_ctl_port(ctl_port);
@@ -165,20 +165,20 @@ parse_app_args(int argc, char *argv[])
break;
default:
usage(progname);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
}
/* Check mandatory parameters */
if ((proc_flg == 0) || (server_flg == 0)) {
usage(progname);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
RTE_LOG(INFO, MIRROR,
"Parsed app args (client_id=%d, server=%s:%d, "
"vhost_client=%d)\n",
cli_id, ctl_ip, ctl_port, get_vhost_cli_mode());
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
/* mirror mbuf pool create */
@@ -212,10 +212,10 @@ mirror_pool_create(int id)
}
if (g_mirror_pool == NULL) {
RTE_LOG(ERR, MIRROR, "Cannot init mbuf pool\n");
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
/* Clear info */
@@ -245,13 +245,13 @@ update_mirror(struct sppwk_comp_info *wk_comp)
RTE_LOG(ERR, MIRROR,
"Invalid num of RX (id=%d, type=%d, nof_rx=%d)\n",
wk_comp->comp_id, wk_comp->wk_type, nof_rx);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
if (unlikely(nof_tx > 2)) {
RTE_LOG(ERR, MIRROR,
"Invalid num of TX (id=%d, type=%d, nof_tx=%d)\n",
wk_comp->comp_id, wk_comp->wk_type, nof_tx);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
memset(path, 0x00, sizeof(struct mirror_path));
@@ -281,7 +281,7 @@ update_mirror(struct sppwk_comp_info *wk_comp)
"Done update mirror (id=%d, name=%s, type=%d)\n",
wk_comp->comp_id, wk_comp->name, wk_comp->wk_type);
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
/* Change index of mirror info */
@@ -323,7 +323,7 @@ mirror_proc(int id)
/* Practice condition check */
if (!(path->nof_tx == 2 && path->nof_rx == 1))
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
rx = &path->ports[0].rx;
@@ -335,7 +335,7 @@ mirror_proc(int id)
#endif
if (unlikely(nb_rx == 0))
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
/* mirror */
tx = &path->ports[1].tx;
@@ -426,14 +426,14 @@ mirror_proc(int id)
for (buf = nb_tx2; buf < nb_rx; buf++)
rte_pktmbuf_free(copybufs[buf]);
}
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
/* Main process of slave core */
static int
slave_main(void *arg __attribute__ ((unused)))
{
- int ret = SPP_RET_OK;
+ int ret = SPPWK_RET_OK;
int cnt = 0;
unsigned int lcore_id = rte_lcore_id();
enum sppwk_lcore_status status = SPPWK_LCORE_STOPPED;
@@ -448,7 +448,7 @@ slave_main(void *arg __attribute__ ((unused)))
if (status != SPPWK_LCORE_RUNNING)
continue;
- if (spp_check_core_update(lcore_id) == SPP_RET_OK) {
+ if (spp_check_core_update(lcore_id) == SPPWK_RET_OK) {
/* Setting with the flush command trigger. */
info->ref_index = (info->upd_index+1) % TWO_SIDES;
core = get_core_info(lcore_id);
@@ -479,7 +479,7 @@ slave_main(void *arg __attribute__ ((unused)))
/**
* Main function
*
- * Return SPP_RET_NG explicitly if error is occurred.
+ * Return SPPWK_RET_NG explicitly if error is occurred.
*/
int
main(int argc, char *argv[])
@@ -539,10 +539,10 @@ main(int argc, char *argv[])
/* create the mbuf pool */
ret = mirror_pool_create(get_client_id());
- if (ret == SPP_RET_NG) {
+ if (ret == SPPWK_RET_NG) {
RTE_LOG(ERR, MIRROR,
"Failed to create mbuf pool.\n");
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
int ret_mng = init_mng_data();
@@ -556,7 +556,7 @@ main(int argc, char *argv[])
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 != SPP_RET_OK))
+ if (unlikely(ret_cmd_init != SPPWK_RET_OK))
break;
#ifdef SPP_RINGLATENCYSTATS_ENABLE
@@ -574,7 +574,7 @@ main(int argc, char *argv[])
int ret_ringlatency = spp_ringlatencystats_init(
SPP_RING_LATENCY_STATS_SAMPLING_INTERVAL,
nof_rings);
- if (unlikely(ret_ringlatency != SPP_RET_OK))
+ if (unlikely(ret_ringlatency != SPPWK_RET_OK))
break;
#endif /* SPP_RINGLATENCYSTATS_ENABLE */
@@ -614,7 +614,7 @@ main(int argc, char *argv[])
#endif
/* Receive command */
ret_do = sppwk_run_cmd();
- if (unlikely(ret_do != SPP_RET_OK))
+ if (unlikely(ret_do != SPPWK_RET_OK))
break;
/*
* To avoid making CPU busy, this thread waits
@@ -627,12 +627,12 @@ main(int argc, char *argv[])
#endif /* SPP_RINGLATENCYSTATS_ENABLE */
}
- if (unlikely(ret_do != SPP_RET_OK)) {
+ if (unlikely(ret_do != SPPWK_RET_OK)) {
set_all_core_status(SPPWK_LCORE_REQ_STOP);
break;
}
- ret = SPP_RET_OK;
+ ret = SPPWK_RET_OK;
break;
}
@@ -658,7 +658,7 @@ int
get_mirror_status(unsigned int lcore_id, int id,
struct spp_iterate_core_params *params)
{
- int ret = SPP_RET_NG;
+ int ret = SPPWK_RET_NG;
int cnt;
const char *component_type = NULL;
struct mirror_info *info = &g_mirror_info[id];
@@ -670,7 +670,7 @@ get_mirror_status(unsigned int lcore_id, int id,
RTE_LOG(ERR, MIRROR,
"Mirror is not used. (id=%d, lcore=%d, type=%d)\n",
id, lcore_id, path->wk_type);
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
}
component_type = SPPWK_TYPE_MIR_STR;
@@ -692,7 +692,7 @@ get_mirror_status(unsigned int lcore_id, int id,
component_type, path->nof_rx, rx_ports, path->nof_tx,
tx_ports);
if (unlikely(ret != 0))
- return SPP_RET_NG;
+ return SPPWK_RET_NG;
- return SPP_RET_OK;
+ return SPPWK_RET_OK;
}
diff --git a/src/mirror/spp_mirror.h b/src/mirror/spp_mirror.h
index c742541..6c508cf 100644
--- a/src/mirror/spp_mirror.h
+++ b/src/mirror/spp_mirror.h
@@ -13,8 +13,8 @@
* @param lcore_id Lcore ID for forwarder and merger.
* @param id Unique component ID.
* @param params Pointer to detailed data of mirror status.
- * @retval SPP_RET_OK If succeeded.
- * @retval SPP_RET_NG If failed.
+ * @retval SPPWK_RET_OK If succeeded.
+ * @retval SPPWK_RET_NG If failed.
*/
/**
* TODO(yasufum) Consider to move this function to `mir_cmd_runner.c`.
--
2.17.1
next prev parent reply other threads:[~2019-07-22 1:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-22 1:38 [spp] [PATCH 0/4] Update to " yasufum.o
2019-07-22 1:38 ` [spp] [PATCH 1/4] spp_vf: " yasufum.o
2019-07-22 1:38 ` yasufum.o [this message]
2019-07-22 1:38 ` [spp] [PATCH 3/4] spp_pcap: " yasufum.o
2019-07-22 1:38 ` [spp] [PATCH 4/4] docs: " yasufum.o
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=20190722013846.18618-3-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).