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 A4917A046B for ; Thu, 27 Jun 2019 06:40:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 521BC2BA7; Thu, 27 Jun 2019 06:40:13 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 986672BA7 for ; Thu, 27 Jun 2019 06:40:12 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id bh12so559231plb.4 for ; Wed, 26 Jun 2019 21:40: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; bh=tdyqkGB7rK0aC8aRhLjTkvr1D5BjXHUzcfhJUoAeEC8=; b=A/Fb+/vbHCYX2h5sevztPYcVCjZq5BYJ60dRmIAqqHSuhyyjzbt9ZmciZ7ikzXyV4J en53pQLxhxAX3o8BYq/iNXMkMQawRTirPY8rHlYjvWGsJBqY/1l4dJ6m0yW/S/NGJtQq zVoFuUnSU4RBI72agZ80SleuwrhLKk5O9Uj82uJe7yZaf/NIT9KxrdaaXpPVN1VG8vZw soOSXeLBi552eu41OX6YEI6MeukD58mfpaOCCmTJ+nel3xJ1V8QTiz9KfZmRpA1Q5+bi AhCkWUAYj5KWWKXDhiZDkuKMyktJMKBY3lBmLKaA25uhn/X0xD9K1IzzGmdccDYjyhr7 As6Q== 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; bh=tdyqkGB7rK0aC8aRhLjTkvr1D5BjXHUzcfhJUoAeEC8=; b=eOxsi4aw/Ol3oOVJ+K+PDc86LHluSSwZgRgwnN1mPaIJk4IAk4apShYO7O8PcbygR4 9LTwGLq4GM6hZbXdCxgex+WtBLBgZ7HKpRfn7PinRE9Sl0BOA4xaIYf5RSdt350GSzt8 GsbJMJHW3D1HovMku/FjjO6bt7wwJeOnXndAxQ8iqsq27oBV7kwZMiaCcWqJCOKS8AZu 9P7trnMAhKcWllygpBahtOXUdhPlr6MGoBv45mfvPOrDUrDeHidpO9JNuoZ0ZQBsZCQi q0cp6ld5xvMlaXgOE3K2sOOl89LABHJHi36iWBhlYCokIVlKHNx4jHWvpslO5mbphwW4 4LmA== X-Gm-Message-State: APjAAAVIJWIOq74UhtxO+F3bhx2wQD8mFSv2EKB0/QiqZRJk7cVANFBA zrN1b9XQeNL8T9bZsdThLX5hSa1C X-Google-Smtp-Source: APXvYqz5TgQuxfWAF6gVxz23cm5yTZawK5Xb2okvIiulLWM+Oj9eEJM9makQBxwajjZd4kcx/fJ27A== X-Received: by 2002:a17:902:8a87:: with SMTP id p7mr2220138plo.124.1561610411486; Wed, 26 Jun 2019 21:40:11 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id j14sm935835pfe.10.2019.06.26.21.40.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2019 21:40:10 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Thu, 27 Jun 2019 13:39:53 +0900 Message-Id: <20190627043953.14876-1-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [spp] [PATCH] shared/sec: move del_comp_info to cmd_runner.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" From: Yasufumi Ogawa Function del_comp_info() is called for `stop` command by which running worker thread is terminated. It should be included in `cmd_runner.c` for considering this behavior. This update is to move this function from `cmd_utils.c` to `cmd_runner.c`, and also its header files. Signed-off-by: Yasufumi Ogawa --- .../secondary/spp_worker_th/cmd_runner.c | 26 ++++++++++++++++ .../secondary/spp_worker_th/cmd_runner.h | 13 ++++++++ .../secondary/spp_worker_th/cmd_utils.c | 30 ------------------- .../secondary/spp_worker_th/cmd_utils.h | 26 ++-------------- 4 files changed, 42 insertions(+), 53 deletions(-) diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c index 3ab69f9..4e43fe6 100644 --- a/src/shared/secondary/spp_worker_th/cmd_runner.c +++ b/src/shared/secondary/spp_worker_th/cmd_runner.c @@ -405,3 +405,29 @@ sppwk_run_cmd(void) return ret; } + +/* Delete component information */ +int +del_comp_info(int lcore_id, int nof_comps, int *comp_ary) +{ + int idx = 0; /* The index of comp_ary to be deleted. */ + int cnt; + + /* Find the index. */ + for (cnt = 0; cnt < nof_comps; cnt++) { + if (lcore_id == comp_ary[cnt]) + idx = cnt; + } + if (idx < 0) + return SPP_RET_NG; + + /* Overwrite the deleted entry, and shift the remained. */ + nof_comps--; + for (cnt = idx; cnt < nof_comps; cnt++) + comp_ary[cnt] = comp_ary[cnt + 1]; + + /* Clean the unused last entry. */ + comp_ary[cnt] = 0; + + return SPP_RET_OK; +} diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.h b/src/shared/secondary/spp_worker_th/cmd_runner.h index 3a71e3e..e13e936 100644 --- a/src/shared/secondary/spp_worker_th/cmd_runner.h +++ b/src/shared/secondary/spp_worker_th/cmd_runner.h @@ -43,4 +43,17 @@ sppwk_cmd_runner_conn(const char *ctl_ipaddr, int ctl_port); int sppwk_run_cmd(void); +/** + * Delete component information. + * + * @param[in] lcore_id The lcore ID of deleted comp. + * @param[in] nof_comps The num of elements in comp_ary. + * @param[in] *comp_ary Set of comps from which an comp is deleted. + * + * @retval SPP_RET_OK If succeeded. + * @retval SPP_RET_NG If failed. + */ +int +del_comp_info(int lcore_id, int nof_comps, int *comp_ary); + #endif /* _SPPWK_CMD_RUNNER_H_ */ diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c index 6072186..894f559 100644 --- a/src/shared/secondary/spp_worker_th/cmd_utils.c +++ b/src/shared/secondary/spp_worker_th/cmd_utils.c @@ -628,36 +628,6 @@ sppwk_get_lcore_id(const char *comp_name) return SPP_RET_NG; } -/* Delete component information */ -/** - * TODO(yasufum) consider to move to cmd_runner because this func is only - * used in. - */ -int -del_comp_info(int lcore_id, int nof_comps, int *comp_ary) -{ - int idx = 0; /* The index of comp_ary to be deleted. */ - int cnt; - - /* Find the index. */ - for (cnt = 0; cnt < nof_comps; cnt++) { - if (lcore_id == comp_ary[cnt]) - idx = cnt; - } - if (idx < 0) - return SPP_RET_NG; - - /* Overwrite the deleted entry, and shift the remained. */ - nof_comps--; - for (cnt = idx; cnt < nof_comps; cnt++) - comp_ary[cnt] = comp_ary[cnt + 1]; - - /* Clean the unused last entry. */ - comp_ary[cnt] = 0; - - return SPP_RET_OK; -} - /** * Get index of given entry in given port info array. It returns the index, * or NG code if the entry is not found. diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h index ff363f5..7e5cda3 100644 --- a/src/shared/secondary/spp_worker_th/cmd_utils.h +++ b/src/shared/secondary/spp_worker_th/cmd_utils.h @@ -384,7 +384,7 @@ void print_ring_latency_stats(void); #endif /* SPP_RINGLATENCYSTATS_ENABLE */ /* Remove sock file if spp is not running */ -void del_vhost_sockfile(struct sppwk_port_info *vhost); +void del_vhost_sockfile(struct sppwk_port_info *vhost); /** * Get core ID of target component @@ -423,11 +423,8 @@ int spp_check_used_port( /** * Set component update flag for given port. * - * @param port - * sppwk_port_info address - * @param rxtx - * enum spp_port_rxtx - * + * @param port Pointer of sppwk_port_info. + * @param rxtx Enum spp_port_rxtx. */ void set_component_change_port(struct sppwk_port_info *port, @@ -450,23 +447,6 @@ int get_free_lcore_id(void); */ int sppwk_get_lcore_id(const char *comp_name); -/** - * Delete component information. - * - * @param[in] lcore_id The lcore ID of deleted comp. - * @param[in] nof_comps The num of elements in comp_ary. - * @param[in] *comp_ary Set of comps from which an comp is deleted. - * - * @retval SPP_RET_OK If succeeded. - * @retval SPP_RET_NG If failed. - */ -/** - * TODO(yasufum) consider to move to cmd_runner because this func is only - * used in. - */ -int -del_comp_info(int lcore_id, int nof_comps, int *comp_ary); - /** * Get index of given entry in given port info array. It returns the index, * or NG code if the entry is not found. -- 2.17.1