From: Long Wu <long...@corigine.com> After bonding port notification, member port hardware may create the bonding port. We want to get the result of creatition, so we add this API to do the getting action.
Signed-off-by: Long Wu <long...@corigine.com> Reviewed-by: James Hershaw <james.hers...@corigine.com> Reviewed-by: Chaoyong He <chaoyong...@corigine.com> --- drivers/net/bonding/rte_eth_bond.h | 15 ++++++++++++++ drivers/net/bonding/rte_eth_bond_api.c | 28 ++++++++++++++++++++++++++ drivers/net/bonding/version.map | 1 + lib/ethdev/ethdev_driver.h | 20 ++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h index f6c773615c..987269b323 100644 --- a/drivers/net/bonding/rte_eth_bond.h +++ b/drivers/net/bonding/rte_eth_bond.h @@ -398,6 +398,21 @@ __rte_experimental int rte_eth_bond_notify_members(uint16_t bonding_port_id); +/** + * Get the status of specified bonding port created by member port hardware. + * + * @param bonding_port_id + * Port ID of bonding device. + * @param member_port_id + * Port ID of member device. + * + * @return + * 0 on success, negative value otherwise. + */ +__rte_experimental +int +rte_eth_bond_hw_create_get(uint16_t bonding_port_id, uint16_t member_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 239f86ee92..317c3c1542 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -1170,3 +1170,31 @@ rte_eth_bond_notify_members(uint16_t bonding_port_id) return 0; } + +int +rte_eth_bond_hw_create_get(uint16_t bonding_port_id, uint16_t member_port_id) +{ + uint32_t i; + struct rte_eth_dev *bonding_dev; + struct rte_eth_dev *member_dev; + struct bond_dev_private *internals; + + if (valid_bonding_port_id(bonding_port_id) != 0) + return -EINVAL; + + bonding_dev = &rte_eth_devices[bonding_port_id]; + internals = bonding_dev->data->dev_private; + for (i = 0; i < internals->member_count; i++) { + if (internals->members[i].port_id == member_port_id) + break; + } + + if (i == internals->member_count) + return -EINVAL; + + member_dev = &rte_eth_devices[member_port_id]; + if (*member_dev->dev_ops->bond_hw_create_get == NULL) + return -ENOTSUP; + + return member_dev->dev_ops->bond_hw_create_get(member_dev, bonding_dev); +} diff --git a/drivers/net/bonding/version.map b/drivers/net/bonding/version.map index 3bd5e8ad11..3cfff51269 100644 --- a/drivers/net/bonding/version.map +++ b/drivers/net/bonding/version.map @@ -32,6 +32,7 @@ EXPERIMENTAL { global: rte_eth_bond_8023ad_member_info; rte_eth_bond_active_members_get; + rte_eth_bond_hw_create_get; rte_eth_bond_member_add; rte_eth_bond_member_remove; rte_eth_bond_members_get; diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index f626f971e5..18ff5db969 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1231,6 +1231,21 @@ typedef int (*eth_map_aggr_tx_affinity_t)(struct rte_eth_dev *dev, uint16_t tx_q typedef int (*eth_bond_notify_member)(struct rte_eth_dev *dev, struct rte_eth_dev *bonding_dev); +/** + * @internal + * Get the status of specified bonding port created by member port hardware. + * + * @param dev + * Member port (ethdev) handle. + * @param bonding_dev + * Bonding port (ethdev) handle. + * + * @return + * Negative on error, 0 on success. + */ +typedef int (*eth_bond_hw_create_get)(struct rte_eth_dev *dev, + struct rte_eth_dev *bonding_dev); + /** * @internal A structure containing the functions exported by an Ethernet driver. */ @@ -1473,6 +1488,11 @@ struct eth_dev_ops { /** Notify the member port of bonding port information */ eth_bond_notify_member bond_notify_member; + /** + * Get the status of whether bonding port is successfully created by + * the member port hardware. + */ + eth_bond_hw_create_get bond_hw_create_get; }; /** -- 2.39.1