[7/8] net/bonding: support checking valid bonding port ID

Message ID 20231005024012.1279810-8-chaoyong.he@corigine.com (mailing list archive)
State Superseded, archived
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 Oct. 5, 2023, 2:40 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

Add API to support checking if the port id is a bonding
port id.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/bonding/rte_eth_bond.h     | 13 +++++++++++++
 drivers/net/bonding/rte_eth_bond_api.c |  7 +++++++
 drivers/net/bonding/version.map        |  1 +
 3 files changed, 21 insertions(+)
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index 2ae2f28ec1..8fa7b0aa01 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -475,6 +475,19 @@  __rte_experimental
 int
 rte_eth_bond_hw_create_get(uint16_t bonding_port_id, uint16_t member_port_id);
 
+/**
+ * Check whether bonding port id is valid.
+ *
+ * @param bonding_port_id
+ *   Port ID of bonding device.
+ *
+ * @return
+ *   0 on success, negative value otherwise.
+ */
+__rte_experimental
+int
+rte_eth_bond_valid_bonding_port_id(uint16_t bonding_port_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 0113dfdc16..80d71529cc 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -1214,3 +1214,10 @@  rte_eth_bond_hw_create_get(uint16_t bonding_port_id, uint16_t member_port_id)
 
 	return member_dev->dev_ops->bond_hw_create_get(member_dev, bonding_dev);
 }
+
+
+int
+rte_eth_bond_valid_bonding_port_id(uint16_t port_id)
+{
+	return valid_bonding_port_id(port_id);
+}
diff --git a/drivers/net/bonding/version.map b/drivers/net/bonding/version.map
index 3cfff51269..bf5e50521e 100644
--- a/drivers/net/bonding/version.map
+++ b/drivers/net/bonding/version.map
@@ -39,4 +39,5 @@  EXPERIMENTAL {
 	rte_eth_bond_notify_member_flag_get;
 	rte_eth_bond_notify_member_flag_set;
 	rte_eth_bond_notify_members;
+	rte_eth_bond_valid_bonding_port_id;
 };