DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Peng Zhang <peng.zhang@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>,
	Long Wu <long.wu@corigine.com>
Subject: [PATCH 12/23] net/nfp: refactor the logic of flower service
Date: Wed, 19 Jun 2024 17:58:19 +0800	[thread overview]
Message-ID: <20240619095830.3479757-13-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com>

From: Peng Zhang <peng.zhang@corigine.com>

For flower firmware with multi-PF, the flower service needs to get
some information beyond the 'struct nfp_app_fw_flower', so refactor
the logic to use 'struct nfp_net_hw_priv' instead.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower.c           |  4 ++--
 drivers/net/nfp/flower/nfp_flower_ctrl.c      | 16 +++++++++----
 drivers/net/nfp/flower/nfp_flower_ctrl.h      |  2 +-
 .../net/nfp/flower/nfp_flower_representor.c   |  2 +-
 drivers/net/nfp/flower/nfp_flower_service.c   | 24 +++++++++----------
 drivers/net/nfp/flower/nfp_flower_service.h   |  4 ++--
 6 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 70135574d4..87bd9dda2e 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -754,7 +754,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
 	}
 
 	/* Start up flower services */
-	ret = nfp_flower_service_start(app_fw_flower, hw_priv);
+	ret = nfp_flower_service_start(hw_priv);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Could not enable flower services");
 		ret = -ESRCH;
@@ -770,7 +770,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
 	return 0;
 
 ctrl_vnic_service_stop:
-	nfp_flower_service_stop(app_fw_flower, hw_priv);
+	nfp_flower_service_stop(hw_priv);
 ctrl_vnic_cleanup:
 	nfp_flower_cleanup_ctrl_vnic(app_fw_flower, hw_priv);
 ctrl_cpp_area_cleanup:
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 8cfafe91c8..01a680eb6d 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -415,13 +415,15 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
 }
 
 static int
-nfp_flower_cmsg_port_mod_rx(struct nfp_app_fw_flower *app_fw_flower,
+nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
 		struct rte_mbuf *pkt_burst)
 {
 	uint32_t port;
 	struct nfp_flower_representor *repr;
 	struct nfp_flower_cmsg_port_mod *msg;
+	struct nfp_app_fw_flower *app_fw_flower;
 
+	app_fw_flower = hw_priv->pf_dev->app_fw_priv;
 	msg = rte_pktmbuf_mtod_offset(pkt_burst, struct nfp_flower_cmsg_port_mod *,
 			NFP_FLOWER_CMSG_HLEN);
 	port = rte_be_to_cpu_32(msg->portnum);
@@ -456,7 +458,7 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_app_fw_flower *app_fw_flower,
 }
 
 static void
-nfp_flower_cmsg_rx(struct nfp_app_fw_flower *app_fw_flower,
+nfp_flower_cmsg_rx(struct nfp_net_hw_priv *hw_priv,
 		struct rte_mbuf **pkts_burst,
 		uint16_t count)
 {
@@ -467,7 +469,9 @@ nfp_flower_cmsg_rx(struct nfp_app_fw_flower *app_fw_flower,
 	struct nfp_mtr_priv *mtr_priv;
 	struct nfp_flow_priv *flow_priv;
 	struct nfp_flower_cmsg_hdr *cmsg_hdr;
+	struct nfp_app_fw_flower *app_fw_flower;
 
+	app_fw_flower = hw_priv->pf_dev->app_fw_priv;
 	mtr_priv = app_fw_flower->mtr_priv;
 	flow_priv = app_fw_flower->flow_priv;
 
@@ -499,7 +503,7 @@ nfp_flower_cmsg_rx(struct nfp_app_fw_flower *app_fw_flower,
 			nfp_flower_cmsg_rx_qos_stats(mtr_priv, pkts_burst[i]);
 		} else if (cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_PORT_MOD) {
 			/* Handle changes to port configuration/status */
-			nfp_flower_cmsg_port_mod_rx(app_fw_flower, pkts_burst[i]);
+			nfp_flower_cmsg_port_mod_rx(hw_priv, pkts_burst[i]);
 		}
 
 		rte_pktmbuf_free(pkts_burst[i]);
@@ -507,13 +511,15 @@ nfp_flower_cmsg_rx(struct nfp_app_fw_flower *app_fw_flower,
 }
 
 void
-nfp_flower_ctrl_vnic_process(struct nfp_app_fw_flower *app_fw_flower)
+nfp_flower_ctrl_vnic_process(struct nfp_net_hw_priv *hw_priv)
 {
 	uint16_t count;
 	struct nfp_net_rxq *rxq;
 	struct rte_eth_dev *ctrl_eth_dev;
+	struct nfp_app_fw_flower *app_fw_flower;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
+	app_fw_flower = hw_priv->pf_dev->app_fw_priv;
 	ctrl_eth_dev = app_fw_flower->ctrl_ethdev;
 
 	/* Ctrl vNIC only has a single Rx queue */
@@ -522,6 +528,6 @@ nfp_flower_ctrl_vnic_process(struct nfp_app_fw_flower *app_fw_flower)
 	if (count != 0) {
 		app_fw_flower->ctrl_vnic_rx_count += count;
 		/* Process cmsgs here */
-		nfp_flower_cmsg_rx(app_fw_flower, pkts_burst, count);
+		nfp_flower_cmsg_rx(hw_priv, pkts_burst, count);
 	}
 }
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.h b/drivers/net/nfp/flower/nfp_flower_ctrl.h
index 131d002ac6..b5d0036c01 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.h
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.h
@@ -8,7 +8,7 @@
 
 #include "nfp_flower.h"
 
-void nfp_flower_ctrl_vnic_process(struct nfp_app_fw_flower *app_fw_flower);
+void nfp_flower_ctrl_vnic_process(struct nfp_net_hw_priv *hw_priv);
 uint16_t nfp_flower_ctrl_vnic_xmit(struct nfp_app_fw_flower *app_fw_flower,
 		struct rte_mbuf *mbuf);
 void nfp_flower_ctrl_vnic_xmit_register(struct nfp_app_fw_flower *app_fw_flower);
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index a845253b01..59dc5854b5 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -460,7 +460,7 @@ nfp_flower_repr_dev_close(struct rte_eth_dev *dev)
 		return 0;
 
 	/* Stop flower service first */
-	nfp_flower_service_stop(app_fw_flower, hw_priv);
+	nfp_flower_service_stop(hw_priv);
 
 	/* Now it is safe to free all PF resources */
 	nfp_uninit_app_fw_flower(hw_priv);
diff --git a/drivers/net/nfp/flower/nfp_flower_service.c b/drivers/net/nfp/flower/nfp_flower_service.c
index 64753f5bf6..6353015c66 100644
--- a/drivers/net/nfp/flower/nfp_flower_service.c
+++ b/drivers/net/nfp/flower/nfp_flower_service.c
@@ -22,7 +22,7 @@ struct nfp_flower_service {
 	/** Flower service info */
 	struct nfp_service_info info;
 	/** Store flower cards' information */
-	struct nfp_app_fw_flower *slots[MAX_FLOWER_SERVICE_SLOT];
+	struct nfp_net_hw_priv *slots[MAX_FLOWER_SERVICE_SLOT];
 	/** Spinlock for sync slots when add/remove card */
 	rte_spinlock_t spinlock;
 };
@@ -37,7 +37,7 @@ static int
 nfp_flower_service_func(void *arg)
 {
 	uint16_t slot;
-	struct nfp_app_fw_flower *app;
+	struct nfp_net_hw_priv *hw_priv;
 	struct nfp_flower_service *service_handle;
 
 	service_handle = arg;
@@ -46,11 +46,11 @@ nfp_flower_service_func(void *arg)
 
 	rte_spinlock_lock(&service_handle->spinlock);
 	for (slot = 0; slot < MAX_FLOWER_SERVICE_SLOT; slot++) {
-		app = service_handle->slots[slot];
-		if (app == NULL)
+		hw_priv = service_handle->slots[slot];
+		if (hw_priv == NULL)
 			continue;
 
-		nfp_flower_ctrl_vnic_process(app);
+		nfp_flower_ctrl_vnic_process(hw_priv);
 	}
 	rte_spinlock_unlock(&service_handle->spinlock);
 
@@ -79,7 +79,7 @@ nfp_flower_service_enable(struct nfp_flower_service *service_handle)
 }
 
 static uint16_t
-nfp_flower_service_insert(struct nfp_app_fw_flower *app,
+nfp_flower_service_insert(struct nfp_net_hw_priv *hw_priv,
 		struct nfp_flower_service *service_handle)
 {
 	uint16_t slot;
@@ -87,7 +87,7 @@ nfp_flower_service_insert(struct nfp_app_fw_flower *app,
 	rte_spinlock_lock(&service_handle->spinlock);
 	for (slot = 0; slot < MAX_FLOWER_SERVICE_SLOT; slot++) {
 		if (service_handle->slots[slot] == NULL) {
-			service_handle->slots[slot] = app;
+			service_handle->slots[slot] = hw_priv;
 			break;
 		}
 	}
@@ -97,8 +97,7 @@ nfp_flower_service_insert(struct nfp_app_fw_flower *app,
 }
 
 int
-nfp_flower_service_start(void *app_fw_flower,
-		struct nfp_net_hw_priv *hw_priv)
+nfp_flower_service_start(struct nfp_net_hw_priv *hw_priv)
 {
 	int ret;
 	struct nfp_flower_service *service_handle;
@@ -119,7 +118,7 @@ nfp_flower_service_start(void *app_fw_flower,
 	}
 
 	/* Insert the NIC to flower service slot */
-	ret = nfp_flower_service_insert(app_fw_flower, service_handle);
+	ret = nfp_flower_service_insert(hw_priv, service_handle);
 	if (ret == MAX_FLOWER_SERVICE_SLOT) {
 		PMD_DRV_LOG(ERR, "Flower ctrl vnic service slot over %u",
 				MAX_FLOWER_SERVICE_SLOT);
@@ -130,8 +129,7 @@ nfp_flower_service_start(void *app_fw_flower,
 }
 
 void
-nfp_flower_service_stop(void *app_fw_flower,
-		struct nfp_net_hw_priv *hw_priv)
+nfp_flower_service_stop(struct nfp_net_hw_priv *hw_priv)
 {
 	uint16_t slot;
 	uint16_t count;
@@ -146,7 +144,7 @@ nfp_flower_service_stop(void *app_fw_flower,
 	rte_spinlock_lock(&service_handle->spinlock);
 	for (slot = 0; slot < MAX_FLOWER_SERVICE_SLOT; slot++) {
 		/* The app only in one slot */
-		if (service_handle->slots[slot] != app_fw_flower)
+		if (service_handle->slots[slot] != hw_priv)
 			continue;
 
 		service_handle->slots[slot] = NULL;
diff --git a/drivers/net/nfp/flower/nfp_flower_service.h b/drivers/net/nfp/flower/nfp_flower_service.h
index 2fbe4fa601..bca5f5240e 100644
--- a/drivers/net/nfp/flower/nfp_flower_service.h
+++ b/drivers/net/nfp/flower/nfp_flower_service.h
@@ -8,8 +8,8 @@
 
 #include "../nfp_net_common.h"
 
-int nfp_flower_service_start(void *app_fw_flower, struct nfp_net_hw_priv *hw_priv);
-void nfp_flower_service_stop(void *app_fw_flower, struct nfp_net_hw_priv *hw_priv);
+int nfp_flower_service_start(struct nfp_net_hw_priv *hw_priv);
+void nfp_flower_service_stop(struct nfp_net_hw_priv *hw_priv);
 
 int nfp_flower_service_sync_alloc(struct nfp_net_hw_priv *hw_priv);
 void nfp_flower_service_sync_free(struct nfp_net_hw_priv *hw_priv);
-- 
2.39.1


  parent reply	other threads:[~2024-06-19 10:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19  9:58 [PATCH 00/23] support flower firmware with multiple PF Chaoyong He
2024-06-19  9:58 ` [PATCH 01/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-07-07 18:56   ` Ferruh Yigit
2024-07-08  1:35     ` Chaoyong He
2024-06-19  9:58 ` [PATCH 02/23] net/nfp: disable ctrl VNIC queues Chaoyong He
2024-06-19  9:58 ` [PATCH 03/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-06-19  9:58 ` [PATCH 04/23] net/nfp: fix repeat disable the port Chaoyong He
2024-06-19  9:58 ` [PATCH 05/23] net/nfp: fix repeat set the speed configure Chaoyong He
2024-06-19  9:58 ` [PATCH 06/23] net/nfp: make the logic simpler by adding local variable Chaoyong He
2024-06-19  9:58 ` [PATCH 07/23] net/nfp: rename the variable name Chaoyong He
2024-06-19  9:58 ` [PATCH 08/23] net/nfp: export function ID get interface Chaoyong He
2024-06-19  9:58 ` [PATCH 09/23] net/nfp: extract total phyports Chaoyong He
2024-06-19  9:58 ` [PATCH 10/23] net/nfp: extract the initialize helper function Chaoyong He
2024-06-19  9:58 ` [PATCH 11/23] net/nfp: get the VF configuration Chaoyong He
2024-06-19  9:58 ` Chaoyong He [this message]
2024-06-19  9:58 ` [PATCH 13/23] net/nfp: get the first VF ID of the PF Chaoyong He
2024-06-19  9:58 ` [PATCH 14/23] net/nfp: add the helper function to map rtsym with offset Chaoyong He
2024-06-19  9:58 ` [PATCH 15/23] net/nfp: add the VF table to record the VF information Chaoyong He
2024-06-19  9:58 ` [PATCH 16/23] net/nfp: support configuration of VF numbers Chaoyong He
2024-06-19  9:58 ` [PATCH 17/23] net/nfp: configure the VF queue Chaoyong He
2024-06-19  9:58 ` [PATCH 18/23] net/nfp: add check for numbers of VF representor port Chaoyong He
2024-06-19  9:58 ` [PATCH 19/23] net/nfp: add support of ring pop and push Chaoyong He
2024-06-19  9:58 ` [PATCH 20/23] net/nfp: add resource share mode of host context Chaoyong He
2024-06-19  9:58 ` [PATCH 21/23] net/nfp: add resource share mode of mask ID Chaoyong He
2024-06-19  9:58 ` [PATCH 22/23] net/nfp: add device active command for nsp service Chaoyong He
2024-06-19  9:58 ` [PATCH 23/23] net/nfp: add support of flower firmware with multiple PF Chaoyong He
2024-07-07 18:56 ` [PATCH 00/23] support " 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=20240619095830.3479757-13-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).