* [PATCH 0/2] enhance the flower service framework
@ 2024-10-10 7:45 Chaoyong He
2024-10-10 7:45 ` [PATCH 1/2] net/nfp: rename flower service flag Chaoyong He
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Chaoyong He @ 2024-10-10 7:45 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He
Enhance the NFP service framework when using the flower firmware, we can
using the alarm now when there is no service core.
Long Wu (2):
net/nfp: rename flower service flag
net/nfp: enhance the flower service framework
drivers/net/nfp/flower/nfp_flower_service.c | 76 ++++++++++++++++++---
1 file changed, 68 insertions(+), 8 deletions(-)
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] net/nfp: rename flower service flag
2024-10-10 7:45 [PATCH 0/2] enhance the flower service framework Chaoyong He
@ 2024-10-10 7:45 ` Chaoyong He
2024-10-10 7:45 ` [PATCH 2/2] net/nfp: enhance the flower service framework Chaoyong He
2024-10-12 0:23 ` [PATCH 0/2] " Ferruh Yigit
2 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2024-10-10 7:45 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He
From: Long Wu <long.wu@corigine.com>
Rename the flower service flag to make the logic more readable.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_service.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_service.c b/drivers/net/nfp/flower/nfp_flower_service.c
index 6353015c66..782f083b71 100644
--- a/drivers/net/nfp/flower/nfp_flower_service.c
+++ b/drivers/net/nfp/flower/nfp_flower_service.c
@@ -18,7 +18,7 @@
struct nfp_flower_service {
/** Flower service is enabled */
- bool enabled;
+ bool service_enabled;
/** Flower service info */
struct nfp_service_info info;
/** Store flower cards' information */
@@ -41,7 +41,7 @@ nfp_flower_service_func(void *arg)
struct nfp_flower_service *service_handle;
service_handle = arg;
- if (!service_handle->enabled)
+ if (!service_handle->service_enabled)
return 0;
rte_spinlock_lock(&service_handle->spinlock);
@@ -73,7 +73,7 @@ nfp_flower_service_enable(struct nfp_flower_service *service_handle)
return ret;
rte_spinlock_init(&service_handle->spinlock);
- service_handle->enabled = true;
+ service_handle->service_enabled = true;
return 0;
}
@@ -109,7 +109,7 @@ nfp_flower_service_start(struct nfp_net_hw_priv *hw_priv)
}
/* Enable flower service when driver initializes the first NIC */
- if (!service_handle->enabled) {
+ if (!service_handle->service_enabled) {
ret = nfp_flower_service_enable(service_handle);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Could not enable flower service");
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] net/nfp: enhance the flower service framework
2024-10-10 7:45 [PATCH 0/2] enhance the flower service framework Chaoyong He
2024-10-10 7:45 ` [PATCH 1/2] net/nfp: rename flower service flag Chaoyong He
@ 2024-10-10 7:45 ` Chaoyong He
2024-10-10 14:55 ` Stephen Hemminger
2024-10-12 0:23 ` [PATCH 0/2] " Ferruh Yigit
2 siblings, 1 reply; 6+ messages in thread
From: Chaoyong He @ 2024-10-10 7:45 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He
From: Long Wu <long.wu@corigine.com>
Some DPDK applications may not have the service core which
can be used for the NFP flower service, so enhance the flower
service framework by adding an alarm for this situation.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_service.c | 70 +++++++++++++++++++--
1 file changed, 65 insertions(+), 5 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_service.c b/drivers/net/nfp/flower/nfp_flower_service.c
index 782f083b71..aac11dbb94 100644
--- a/drivers/net/nfp/flower/nfp_flower_service.c
+++ b/drivers/net/nfp/flower/nfp_flower_service.c
@@ -5,6 +5,7 @@
#include "nfp_flower_service.h"
+#include <rte_alarm.h>
#include <rte_spinlock.h>
#include "nfp_flower_ctrl.h"
@@ -16,9 +17,13 @@
/* Driver limitation, PMD can enlarge it if need. */
#define MAX_FLOWER_SERVICE_SLOT 8
+#define FLOWER_ALARM_INTERVAL 3000
+
struct nfp_flower_service {
/** Flower service is enabled */
bool service_enabled;
+ /** Flower alarm is enabled */
+ bool alarm_enabled;
/** Flower service info */
struct nfp_service_info info;
/** Store flower cards' information */
@@ -33,6 +38,52 @@ nfp_flower_service_handle_get(struct nfp_net_hw_priv *hw_priv)
return hw_priv->pf_dev->process_share.fl_service;
}
+static void
+nfp_flower_service_alarm_func(void *arg)
+{
+ int ret;
+ uint16_t slot;
+ struct nfp_net_hw_priv *hw_priv;
+ struct nfp_flower_service *service_handle;
+
+ service_handle = arg;
+ if (!service_handle->alarm_enabled)
+ goto alarm_set;
+
+ rte_spinlock_lock(&service_handle->spinlock);
+ for (slot = 0; slot < MAX_FLOWER_SERVICE_SLOT; slot++) {
+ hw_priv = service_handle->slots[slot];
+ if (hw_priv == NULL)
+ continue;
+
+ nfp_flower_ctrl_vnic_process(hw_priv);
+ }
+ rte_spinlock_unlock(&service_handle->spinlock);
+
+alarm_set:
+ ret = rte_eal_alarm_set(FLOWER_ALARM_INTERVAL, nfp_flower_service_alarm_func, arg);
+ if (ret < 0)
+ PMD_DRV_LOG(ERR, "Set flower service alarm failed.");
+}
+
+static int
+nfp_flower_service_alarm_enable(struct nfp_flower_service *service_handle)
+{
+ int ret;
+
+ ret = rte_eal_alarm_set(FLOWER_ALARM_INTERVAL, nfp_flower_service_alarm_func,
+ (void *)service_handle);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "Flower service alarm initialization failed.");
+ return ret;
+ }
+
+ rte_spinlock_init(&service_handle->spinlock);
+ service_handle->alarm_enabled = true;
+
+ return 0;
+}
+
static int
nfp_flower_service_func(void *arg)
{
@@ -109,11 +160,15 @@ nfp_flower_service_start(struct nfp_net_hw_priv *hw_priv)
}
/* Enable flower service when driver initializes the first NIC */
- if (!service_handle->service_enabled) {
+ if (!service_handle->service_enabled && !service_handle->alarm_enabled) {
ret = nfp_flower_service_enable(service_handle);
if (ret != 0) {
- PMD_DRV_LOG(ERR, "Could not enable flower service");
- return -ESRCH;
+ PMD_DRV_LOG(INFO, "Could not enable flower service.");
+ ret = nfp_flower_service_alarm_enable(service_handle);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Could not set flower service alarm.");
+ return ret;
+ }
}
}
@@ -157,8 +212,13 @@ nfp_flower_service_stop(struct nfp_net_hw_priv *hw_priv)
if (count > 1)
return;
- if (nfp_service_disable(&service_handle->info) != 0)
- PMD_DRV_LOG(ERR, "Could not disable service");
+ if (service_handle->service_enabled) {
+ if (nfp_service_disable(&service_handle->info) != 0)
+ PMD_DRV_LOG(ERR, "Could not disable service.");
+ } else if (service_handle->alarm_enabled) {
+ rte_eal_alarm_cancel(nfp_flower_service_alarm_func,
+ (void *)service_handle);
+ }
}
int
--
2.39.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] net/nfp: enhance the flower service framework
2024-10-10 7:45 ` [PATCH 2/2] net/nfp: enhance the flower service framework Chaoyong He
@ 2024-10-10 14:55 ` Stephen Hemminger
2024-10-11 2:23 ` Chaoyong He
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2024-10-10 14:55 UTC (permalink / raw)
To: Chaoyong He; +Cc: dev, oss-drivers, Long Wu
On Thu, 10 Oct 2024 15:45:57 +0800
Chaoyong He <chaoyong.he@corigine.com> wrote:
> +static void
> +nfp_flower_service_alarm_func(void *arg)
> +{
> + int ret;
> + uint16_t slot;
> + struct nfp_net_hw_priv *hw_priv;
> + struct nfp_flower_service *service_handle;
> +
> + service_handle = arg;
> + if (!service_handle->alarm_enabled)
> + goto alarm_set;
> +
> + rte_spinlock_lock(&service_handle->spinlock);
> + for (slot = 0; slot < MAX_FLOWER_SERVICE_SLOT; slot++) {
> + hw_priv = service_handle->slots[slot];
> + if (hw_priv == NULL)
> + continue;
> +
> + nfp_flower_ctrl_vnic_process(hw_priv);
> + }
> + rte_spinlock_unlock(&service_handle->spinlock);
> +
The alarm handling is in a non EAL thread, and service is an lcore;
does that matter to this code?
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 2/2] net/nfp: enhance the flower service framework
2024-10-10 14:55 ` Stephen Hemminger
@ 2024-10-11 2:23 ` Chaoyong He
0 siblings, 0 replies; 6+ messages in thread
From: Chaoyong He @ 2024-10-11 2:23 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, oss-drivers, Long Wu
> On Thu, 10 Oct 2024 15:45:57 +0800
> Chaoyong He <chaoyong.he@corigine.com> wrote:
>
> > +static void
> > +nfp_flower_service_alarm_func(void *arg) {
> > + int ret;
> > + uint16_t slot;
> > + struct nfp_net_hw_priv *hw_priv;
> > + struct nfp_flower_service *service_handle;
> > +
> > + service_handle = arg;
> > + if (!service_handle->alarm_enabled)
> > + goto alarm_set;
> > +
> > + rte_spinlock_lock(&service_handle->spinlock);
> > + for (slot = 0; slot < MAX_FLOWER_SERVICE_SLOT; slot++) {
> > + hw_priv = service_handle->slots[slot];
> > + if (hw_priv == NULL)
> > + continue;
> > +
> > + nfp_flower_ctrl_vnic_process(hw_priv);
> > + }
> > + rte_spinlock_unlock(&service_handle->spinlock);
> > +
>
> The alarm handling is in a non EAL thread, and service is an lcore; does that
> matter to this code?
It does not matter to this code, maybe the name of this function and some variables introduced a few doubts, but the logic is okay.
Thanks for the review.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] enhance the flower service framework
2024-10-10 7:45 [PATCH 0/2] enhance the flower service framework Chaoyong He
2024-10-10 7:45 ` [PATCH 1/2] net/nfp: rename flower service flag Chaoyong He
2024-10-10 7:45 ` [PATCH 2/2] net/nfp: enhance the flower service framework Chaoyong He
@ 2024-10-12 0:23 ` Ferruh Yigit
2 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2024-10-12 0:23 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers
On 10/10/2024 8:45 AM, Chaoyong He wrote:
> Enhance the NFP service framework when using the flower firmware, we can
> using the alarm now when there is no service core.
>
> Long Wu (2):
> net/nfp: rename flower service flag
> net/nfp: enhance the flower service framework
>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-12 0:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10 7:45 [PATCH 0/2] enhance the flower service framework Chaoyong He
2024-10-10 7:45 ` [PATCH 1/2] net/nfp: rename flower service flag Chaoyong He
2024-10-10 7:45 ` [PATCH 2/2] net/nfp: enhance the flower service framework Chaoyong He
2024-10-10 14:55 ` Stephen Hemminger
2024-10-11 2:23 ` Chaoyong He
2024-10-12 0:23 ` [PATCH 0/2] " Ferruh Yigit
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).