From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 2/6] net/nfp: remove redundant NFP service code
Date: Wed, 19 Jun 2024 11:06:51 +0800 [thread overview]
Message-ID: <20240619030655.3216268-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619030655.3216268-1-chaoyong.he@corigine.com>
From: Long Wu <long.wu@corigine.com>
The 'rte_eal_init()' will call 'rte_service_start_with_defaults()'
to start service core, map service core and set service state.
NFP service does not have any special needs for these setps, so
remove the redundant NFP service code.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfp_service.c | 76 +++++------------------------------
drivers/net/nfp/nfp_service.h | 1 -
2 files changed, 10 insertions(+), 67 deletions(-)
diff --git a/drivers/net/nfp/nfp_service.c b/drivers/net/nfp/nfp_service.c
index 24d60857ac..37e2187a3f 100644
--- a/drivers/net/nfp/nfp_service.c
+++ b/drivers/net/nfp/nfp_service.c
@@ -5,68 +5,24 @@
#include "nfp_service.h"
-#include "nfpcore/nfp_cpp.h"
+#include <errno.h>
+#include <rte_cycles.h>
+
#include "nfp_logs.h"
/* Disable service and try to get service status */
#define NFP_SERVICE_DISABLE_WAIT_COUNT 3000
-static int
-nfp_map_service(struct nfp_service_info *info)
-{
- int32_t ret;
- uint32_t slcore = 0;
- int32_t slcore_count;
- uint8_t service_count;
- const char *service_name;
- uint32_t slcore_array[RTE_MAX_LCORE];
- uint8_t min_service_count = UINT8_MAX;
-
- slcore_count = rte_service_lcore_list(slcore_array, RTE_MAX_LCORE);
- if (slcore_count <= 0) {
- PMD_DRV_LOG(DEBUG, "No service cores found");
- return -ENOENT;
- }
-
- /*
- * Find a service core with the least number of services already
- * registered to it
- */
- while (slcore_count--) {
- service_count = rte_service_lcore_count_services(slcore_array[slcore_count]);
- if (service_count < min_service_count) {
- slcore = slcore_array[slcore_count];
- min_service_count = service_count;
- }
- }
-
- service_name = rte_service_get_name(info->id);
- PMD_INIT_LOG(INFO, "Mapping service %s to core %u", service_name, slcore);
-
- ret = rte_service_map_lcore_set(info->id, slcore, 1);
- if (ret != 0) {
- PMD_DRV_LOG(DEBUG, "Could not map flower service");
- return -ENOENT;
- }
-
- rte_service_runstate_set(info->id, 1);
- rte_service_component_runstate_set(info->id, 1);
- rte_service_lcore_start(slcore);
- if (rte_service_may_be_active(slcore))
- PMD_DRV_LOG(INFO, "The service %s is running", service_name);
- else
- PMD_DRV_LOG(ERR, "The service %s is not running", service_name);
-
- info->lcore = slcore;
-
- return 0;
-}
-
int
nfp_service_enable(const struct rte_service_spec *service_spec,
struct nfp_service_info *info)
{
int ret;
+ int32_t lcore_count;
+
+ lcore_count = rte_service_lcore_count();
+ if (lcore_count == 0)
+ return -ENOTSUP;
/* Register the service */
ret = rte_service_component_register(service_spec, &info->id);
@@ -75,12 +31,8 @@ nfp_service_enable(const struct rte_service_spec *service_spec,
return -EINVAL;
}
- /* Map it to available service core */
- ret = nfp_map_service(info);
- if (ret != 0) {
- PMD_DRV_LOG(DEBUG, "Could not map %s", service_spec->name);
- return -EINVAL;
- }
+ /* Set the NFP service runstate of a component. */
+ rte_service_component_runstate_set(info->id, 1);
PMD_DRV_LOG(DEBUG, "Enable service %s successfully", service_spec->name);
@@ -90,7 +42,6 @@ nfp_service_enable(const struct rte_service_spec *service_spec,
int
nfp_service_disable(struct nfp_service_info *info)
{
- int ret;
uint32_t i;
const char *service_name;
@@ -100,7 +51,6 @@ nfp_service_disable(struct nfp_service_info *info)
return -EINVAL;
}
- rte_service_runstate_set(info->id, 0);
rte_service_component_runstate_set(info->id, 0);
for (i = 0; i < NFP_SERVICE_DISABLE_WAIT_COUNT; i++) {
@@ -112,12 +62,6 @@ nfp_service_disable(struct nfp_service_info *info)
if (i == NFP_SERVICE_DISABLE_WAIT_COUNT)
PMD_DRV_LOG(ERR, "Could not stop service %s", service_name);
- ret = rte_service_map_lcore_set(info->id, info->lcore, 0);
- if (ret != 0) {
- PMD_DRV_LOG(DEBUG, "Could not unmap flower service");
- return -ENOENT;
- }
-
rte_service_component_unregister(info->id);
return 0;
diff --git a/drivers/net/nfp/nfp_service.h b/drivers/net/nfp/nfp_service.h
index 4b99d5b973..0db4f8b371 100644
--- a/drivers/net/nfp/nfp_service.h
+++ b/drivers/net/nfp/nfp_service.h
@@ -10,7 +10,6 @@
struct nfp_service_info {
uint32_t id;
- uint32_t lcore;
};
int nfp_service_disable(struct nfp_service_info *info);
--
2.39.1
next prev parent reply other threads:[~2024-06-19 3:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 3:06 [PATCH 0/6] refactor the service module Chaoyong He
2024-06-19 3:06 ` [PATCH 1/6] net/nfp: fix check logic for device arguments Chaoyong He
2024-06-19 3:06 ` Chaoyong He [this message]
2024-06-19 3:06 ` [PATCH 3/6] net/nfp: remove the flower service dead loop Chaoyong He
2024-06-19 3:06 ` [PATCH 4/6] net/nfp: fix disable CPP service Chaoyong He
2024-06-19 3:06 ` [PATCH 5/6] net/nfp: add CPP service enable option Chaoyong He
2024-06-19 3:06 ` [PATCH 6/6] net/nfp: add CPP service abnormal exit logic Chaoyong He
2024-07-06 18:51 ` [PATCH 0/6] refactor the service module Ferruh Yigit
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=20240619030655.3216268-3-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
/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).