[17/20] net/mlx5: using function to detect operation by DevX
Checks
Commit Message
Add inline function indicating whether HW objects operations can be
created by DevX. It makes the code more readable.
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/linux/mlx5_os.c | 6 ++----
drivers/net/mlx5/mlx5.h | 24 ++++++++++++++++++++++++
drivers/net/mlx5/mlx5_ethdev.c | 3 +--
drivers/net/mlx5/mlx5_trigger.c | 3 +--
4 files changed, 28 insertions(+), 8 deletions(-)
@@ -370,8 +370,7 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)
sh->dev_cap.txpp_en = 0;
#endif
/* Check for LRO support. */
- if (sh->dev_cap.dest_tir && sh->dev_cap.dv_flow_en &&
- hca_attr->lro_cap) {
+ if (mlx5_devx_obj_ops_en(sh) && hca_attr->lro_cap) {
/* TBD check tunnel lro caps. */
sh->dev_cap.lro_supported = 1;
DRV_LOG(DEBUG, "Device supports LRO.");
@@ -1550,8 +1549,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
if (mlx5_flex_item_port_init(eth_dev) < 0)
goto error;
}
- if (sh->cdev->config.devx && sh->config.dv_flow_en &&
- sh->dev_cap.dest_tir) {
+ if (mlx5_devx_obj_ops_en(sh)) {
priv->obj_ops = devx_obj_ops;
mlx5_queue_counter_id_prepare(eth_dev);
priv->obj_ops.lb_dummy_queue_create =
@@ -1496,6 +1496,30 @@ enum dr_dump_rec_type {
DR_DUMP_REC_TYPE_PMD_COUNTER = 4430,
};
+/**
+ * Indicates whether HW objects operations can be created by DevX.
+ *
+ * This function is used for both:
+ * Before creation - deciding whether to create HW objects operations by DevX.
+ * After creation - indicator if HW objects operations were created by DevX.
+ *
+ * @param sh
+ * Pointer to shared device context.
+ *
+ * @return
+ * True if HW objects were created by DevX, False otherwise.
+ */
+static inline bool
+mlx5_devx_obj_ops_en(struct mlx5_dev_ctx_shared *sh)
+{
+ /*
+ * When advanced DR API is available and DV flow is supported and
+ * DevX is supported, HW objects operations are created by DevX.
+ */
+ return (sh->cdev->config.devx && sh->config.dv_flow_en &&
+ sh->dev_cap.dest_tir);
+}
+
/* mlx5.c */
int mlx5_getenv_int(const char *);
@@ -721,8 +721,7 @@ mlx5_hairpin_cap_get(struct rte_eth_dev *dev, struct rte_eth_hairpin_cap *cap)
{
struct mlx5_priv *priv = dev->data->dev_private;
- if (!priv->sh->cdev->config.devx || !priv->sh->dev_cap.dest_tir ||
- !priv->sh->config.dv_flow_en) {
+ if (!mlx5_devx_obj_ops_en(priv->sh)) {
rte_errno = ENOTSUP;
return -rte_errno;
}
@@ -1104,8 +1104,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
dev->data->port_id, strerror(rte_errno));
goto error;
}
- if ((priv->sh->cdev->config.devx && priv->sh->config.dv_flow_en &&
- priv->sh->dev_cap.dest_tir) &&
+ if (mlx5_devx_obj_ops_en(priv->sh) &&
priv->obj_ops.lb_dummy_queue_create) {
ret = priv->obj_ops.lb_dummy_queue_create(dev);
if (ret)