[v6,13/14] net/nfp: support getting bond firmware creation

Message ID 20231226072824.3163121-14-chaoyong.he@corigine.com (mailing list archive)
State Deferred
Delegated to: Ferruh Yigit
Headers
Series Enhance the bond framework to support offload |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Dec. 26, 2023, 7:28 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

Support getting the status that whether the bonding port
is created by the nfp firmware.

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/flower/nfp_flower_bond.c      | 27 +++++++++++++++++++
 drivers/net/nfp/flower/nfp_flower_bond.h      |  2 ++
 .../net/nfp/flower/nfp_flower_representor.c   |  1 +
 3 files changed, 30 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower_bond.c b/drivers/net/nfp/flower/nfp_flower_bond.c
index 73b616360a..c809465ffc 100644
--- a/drivers/net/nfp/flower/nfp_flower_bond.c
+++ b/drivers/net/nfp/flower/nfp_flower_bond.c
@@ -640,3 +640,30 @@  nfp_fl_bond_get_unprocessed(struct nfp_flower_bond *nfp_bond)
 
 	return mbuf;
 }
+
+int
+nfp_flower_bond_fw_create_get(struct rte_eth_dev *bond_dev,
+		struct rte_eth_dev *nfp_dev)
+{
+	int ret = -EINVAL;
+	struct nfp_bond_group *group;
+	struct nfp_flower_bond *nfp_bond;
+	struct nfp_flower_representor *repr;
+
+	if (!nfp_flower_bond_is_member_port(bond_dev, nfp_dev))
+		return ret;
+
+	repr = nfp_dev->data->dev_private;
+	nfp_bond = repr->app_fw_flower->nfp_bond;
+
+	pthread_mutex_lock(&nfp_bond->mutex);
+	LIST_FOREACH(group, &nfp_bond->group_list, next) {
+		if (group->main_dev == bond_dev && group->offloaded == true) {
+			ret = 0;
+			break;
+		}
+	}
+	pthread_mutex_unlock(&nfp_bond->mutex);
+
+	return ret;
+}
diff --git a/drivers/net/nfp/flower/nfp_flower_bond.h b/drivers/net/nfp/flower/nfp_flower_bond.h
index e88d72899f..41cd64d9eb 100644
--- a/drivers/net/nfp/flower/nfp_flower_bond.h
+++ b/drivers/net/nfp/flower/nfp_flower_bond.h
@@ -153,5 +153,7 @@  bool nfp_flower_bond_all_member_are_phyrepr(struct rte_eth_dev *bond_dev);
 struct rte_mbuf *nfp_fl_bond_get_unprocessed(struct nfp_flower_bond *nfp_bond);
 int nfp_fl_bond_put_unprocessed(struct nfp_flower_bond *nfp_bond,
 		struct rte_mbuf *mbuf);
+int nfp_flower_bond_fw_create_get(struct rte_eth_dev *bond_dev,
+		struct rte_eth_dev *nfp_dev);
 
 #endif /* __NFP_FLOWER_BOND_H__ */
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 43106da90e..8a1b2eff66 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -458,6 +458,7 @@  static const struct eth_dev_ops nfp_flower_repr_dev_ops = {
 	.mtr_ops_get          = nfp_net_mtr_ops_get,
 
 	.bond_notify_member   = nfp_flower_repr_bond_notify_member,
+	.bond_fw_create_get   = nfp_flower_bond_fw_create_get,
 };
 
 static uint32_t